]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
aarch64: Extend -mtp= arguments
[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
234-fno-optional-diags -fpermissive
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
257-Weffc++ -Wno-exceptions -Wextra-semi -Wno-inaccessible-base
258-Wno-inherited-variadic-ctor -Wno-init-list-lifetime
259-Winvalid-constexpr -Winvalid-imported-macros
260-Wno-invalid-offsetof -Wno-literal-suffix
261-Wmismatched-new-delete -Wmismatched-tags
262-Wmultiple-inheritance -Wnamespaces -Wnarrowing
263-Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor
264-Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n}
265-Wrange-loop-construct -Wredundant-move -Wredundant-tags
266-Wreorder -Wregister
267-Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates
268-Wno-non-template-friend -Wold-style-cast
269-Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo
270-Wsized-deallocation -Wsuggest-final-methods
271-Wsuggest-final-types -Wsuggest-override
272-Wno-terminate -Wuseless-cast -Wno-vexing-parse
273-Wvirtual-inheritance
d77de738
ML
274-Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant}
275
276@item Objective-C and Objective-C++ Language Options
277@xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling
278Objective-C and Objective-C++ Dialects}.
43b72ede
AA
279@gccoptlist{-fconstant-string-class=@var{class-name}
280-fgnu-runtime -fnext-runtime
281-fno-nil-receivers
282-fobjc-abi-version=@var{n}
283-fobjc-call-cxx-cdtors
284-fobjc-direct-dispatch
285-fobjc-exceptions
286-fobjc-gc
287-fobjc-nilcheck
288-fobjc-std=objc1
289-fno-local-ivars
290-fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
291-freplace-objc-classes
292-fzero-link
293-gen-decls
294-Wassign-intercept -Wno-property-assign-default
295-Wno-protocol -Wobjc-root-class -Wselector
296-Wstrict-selector-match
d77de738
ML
297-Wundeclared-selector}
298
299@item Diagnostic Message Formatting Options
300@xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
43b72ede
AA
301@gccoptlist{-fmessage-length=@var{n}
302-fdiagnostics-plain-output
303-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
304-fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]}
305-fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]}
306-fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]}
307-fno-diagnostics-show-option -fno-diagnostics-show-caret
308-fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers
309-fno-diagnostics-show-cwe
310-fno-diagnostics-show-rule
311-fdiagnostics-minimum-margin-width=@var{width}
312-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
313-fdiagnostics-show-template-tree -fno-elide-type
314-fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]}
315-fdiagnostics-show-path-depths
316-fno-show-column
317-fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]}
318-fdiagnostics-column-origin=@var{origin}
d77de738
ML
319-fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}}
320
321@item Warning Options
322@xref{Warning Options,,Options to Request or Suppress Warnings}.
43b72ede
AA
323@gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic
324-pedantic-errors
325-w -Wextra -Wall -Wabi=@var{n}
326-Waddress -Wno-address-of-packed-member -Waggregate-return
327-Walloc-size-larger-than=@var{byte-size} -Walloc-zero
328-Walloca -Walloca-larger-than=@var{byte-size}
329-Wno-aggressive-loop-optimizations
330-Warith-conversion
331-Warray-bounds -Warray-bounds=@var{n} -Warray-compare
332-Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias
333-Wno-attribute-warning
334-Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
335-Wbool-compare -Wbool-operation
336-Wno-builtin-declaration-mismatch
337-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat
338-Wc11-c2x-compat
339-Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat
340-Wc++20-compat
341-Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions
342-Wno-c++20-extensions -Wno-c++23-extensions
343-Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual
344-Wchar-subscripts
345-Wclobbered -Wcomment
346-Wno-complain-wrong-lang
347-Wconversion -Wno-coverage-mismatch -Wno-cpp
348-Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n}
349-Wdate-time
350-Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init
351-Wdisabled-optimization
352-Wno-discarded-array-qualifiers -Wno-discarded-qualifiers
353-Wno-div-by-zero -Wdouble-promotion
354-Wduplicated-branches -Wduplicated-cond
355-Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion
356-Wenum-int-mismatch
357-Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors
358-Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2
359-Wno-format-contains-nul -Wno-format-extra-args
360-Wformat-nonliteral -Wformat-overflow=@var{n}
361-Wformat-security -Wformat-signedness -Wformat-truncation=@var{n}
362-Wformat-y2k -Wframe-address
363-Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object
364-Wno-if-not-aligned -Wno-ignored-attributes
365-Wignored-qualifiers -Wno-incompatible-pointer-types
366-Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n}
367-Wno-implicit-function-declaration -Wno-implicit-int
368-Winfinite-recursion
369-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context
370-Wno-int-to-pointer-cast -Wno-invalid-memory-model
371-Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init
372-Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op
373-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized
374-Wmemset-elt-size -Wmemset-transposed-args
375-Wmisleading-indentation -Wmissing-attributes -Wmissing-braces
376-Wmissing-field-initializers -Wmissing-format-attribute
377-Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile
378-Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare
379-Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
380-Wnull-dereference -Wno-odr
381-Wopenacc-parallelism
382-Wopenmp-simd
383-Wno-overflow -Woverlength-strings -Wno-override-init-side-effects
384-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
385-Wparentheses -Wno-pedantic-ms-format
386-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
387-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls
388-Wrestrict -Wno-return-local-addr -Wreturn-type
389-Wno-scalar-storage-order -Wsequence-point
390-Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local
391-Wno-shadow-ivar
392-Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value
393-Wno-shift-overflow -Wshift-overflow=@var{n}
394-Wsign-compare -Wsign-conversion
395-Wno-sizeof-array-argument
396-Wsizeof-array-div
397-Wsizeof-pointer-div -Wsizeof-pointer-memaccess
398-Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing
399-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n}
400-Wstring-compare
401-Wno-stringop-overflow -Wno-stringop-overread
402-Wno-stringop-truncation -Wstrict-flex-arrays
403-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]}
404-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum
405-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand
406-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs
407-Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef
408-Wuninitialized -Wunknown-pragmas
409-Wunsuffixed-float-constants -Wunused
410-Wunused-but-set-parameter -Wunused-but-set-variable
411-Wunused-const-variable -Wunused-const-variable=@var{n}
412-Wunused-function -Wunused-label -Wunused-local-typedefs
413-Wunused-macros
414-Wunused-parameter -Wno-unused-result
415-Wunused-value -Wunused-variable
416-Wno-varargs -Wvariadic-macros
417-Wvector-operation-performance
418-Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than
419-Wvolatile-register-var -Wwrite-strings
420-Wxor-used-as-pow
d77de738
ML
421-Wzero-length-bounds}
422
423@item Static Analyzer Options
424@gccoptlist{
43b72ede
AA
425-fanalyzer
426-fanalyzer-call-summaries
427-fanalyzer-checker=@var{name}
428-fno-analyzer-feasibility
429-fanalyzer-fine-grained
430-fno-analyzer-state-merge
431-fno-analyzer-state-purge
432-fno-analyzer-suppress-followups
433-fanalyzer-transitivity
434-fno-analyzer-undo-inlining
435-fanalyzer-verbose-edges
436-fanalyzer-verbose-state-changes
437-fanalyzer-verbosity=@var{level}
438-fdump-analyzer
439-fdump-analyzer-callgraph
440-fdump-analyzer-exploded-graph
441-fdump-analyzer-exploded-nodes
442-fdump-analyzer-exploded-nodes-2
443-fdump-analyzer-exploded-nodes-3
444-fdump-analyzer-exploded-paths
445-fdump-analyzer-feasibility
446-fdump-analyzer-json
447-fdump-analyzer-state-purge
448-fdump-analyzer-stderr
449-fdump-analyzer-supergraph
450-fdump-analyzer-untracked
451-Wno-analyzer-double-fclose
452-Wno-analyzer-double-free
453-Wno-analyzer-exposure-through-output-file
454-Wno-analyzer-exposure-through-uninit-copy
455-Wno-analyzer-fd-access-mode-mismatch
456-Wno-analyzer-fd-double-close
457-Wno-analyzer-fd-leak
458-Wno-analyzer-fd-phase-mismatch
459-Wno-analyzer-fd-type-mismatch
460-Wno-analyzer-fd-use-after-close
461-Wno-analyzer-fd-use-without-check
462-Wno-analyzer-file-leak
463-Wno-analyzer-free-of-non-heap
464-Wno-analyzer-imprecise-fp-arithmetic
465-Wno-analyzer-infinite-recursion
466-Wno-analyzer-jump-through-null
467-Wno-analyzer-malloc-leak
468-Wno-analyzer-mismatching-deallocation
469-Wno-analyzer-null-argument
470-Wno-analyzer-null-dereference
471-Wno-analyzer-out-of-bounds
472-Wno-analyzer-possible-null-argument
473-Wno-analyzer-possible-null-dereference
474-Wno-analyzer-putenv-of-auto-var
475-Wno-analyzer-shift-count-negative
476-Wno-analyzer-shift-count-overflow
477-Wno-analyzer-stale-setjmp-buffer
478-Wno-analyzer-tainted-allocation-size
479-Wno-analyzer-tainted-assertion
480-Wno-analyzer-tainted-array-index
481-Wno-analyzer-tainted-divisor
482-Wno-analyzer-tainted-offset
483-Wno-analyzer-tainted-size
484-Wanalyzer-too-complex
485-Wno-analyzer-unsafe-call-within-signal-handler
486-Wno-analyzer-use-after-free
487-Wno-analyzer-use-of-pointer-in-stale-stack-frame
488-Wno-analyzer-use-of-uninitialized-value
489-Wno-analyzer-va-arg-type-mismatch
490-Wno-analyzer-va-list-exhausted
491-Wno-analyzer-va-list-leak
492-Wno-analyzer-va-list-use-after-va-end
493-Wno-analyzer-write-to-const
494-Wno-analyzer-write-to-string-literal
d77de738
ML
495}
496
497@item C and Objective-C-only Warning Options
43b72ede
AA
498@gccoptlist{-Wbad-function-cast -Wmissing-declarations
499-Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs
500-Wold-style-declaration -Wold-style-definition
501-Wstrict-prototypes -Wtraditional -Wtraditional-conversion
d77de738
ML
502-Wdeclaration-after-statement -Wpointer-sign}
503
504@item Debugging Options
505@xref{Debugging Options,,Options for Debugging Your Program}.
43b72ede
AA
506@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version}
507-gbtf -gctf -gctf@var{level}
508-ggdb -grecord-gcc-switches -gno-record-gcc-switches
509-gstrict-dwarf -gno-strict-dwarf
510-gas-loc-support -gno-as-loc-support
511-gas-locview-support -gno-as-locview-support
3eeb4801 512-gcodeview
43b72ede
AA
513-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64
514-gstatement-frontiers -gno-statement-frontiers
515-gvariable-location-views -gno-variable-location-views
516-ginternal-reset-location-views -gno-internal-reset-location-views
517-ginline-points -gno-inline-points
518-gvms -gz@r{[}=@var{type}@r{]}
519-gsplit-dwarf -gdescribe-dies -gno-describe-dies
520-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section
521-fno-eliminate-unused-debug-types
522-femit-struct-debug-baseonly -femit-struct-debug-reduced
523-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
524-fno-eliminate-unused-debug-symbols -femit-class-debug-always
525-fno-merge-debug-strings -fno-dwarf2-cfi-asm
d77de738
ML
526-fvar-tracking -fvar-tracking-assignments}
527
528@item Optimization Options
529@xref{Optimize Options,,Options that Control Optimization}.
43b72ede
AA
530@gccoptlist{-faggressive-loop-optimizations
531-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
532-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
533-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
534-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]]
535-fno-allocation-dce -fallow-store-data-races
536-fassociative-math -fauto-profile -fauto-profile[=@var{path}]
537-fauto-inc-dec -fbranch-probabilities
538-fcaller-saves
539-fcombine-stack-adjustments -fconserve-stack
540-fcompare-elim -fcprop-registers -fcrossjumping
541-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
542-fcx-limited-range
543-fdata-sections -fdce -fdelayed-branch
544-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
545-fdevirtualize-at-ltrans -fdse
546-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
547-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style}
548-ffinite-loops
549-fforward-propagate -ffp-contract=@var{style} -ffunction-sections
550-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
551-fgcse-sm -fhoist-adjacent-loads -fif-conversion
552-fif-conversion2 -findirect-inlining
553-finline-functions -finline-functions-called-once -finline-limit=@var{n}
554-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone
555-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const
556-fipa-reference -fipa-reference-addressable
557-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm}
558-flive-patching=@var{level}
559-fira-region=@var{region} -fira-hoist-pressure
560-fira-loop-pressure -fno-ira-share-save-slots
561-fno-ira-share-spill-slots
562-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
563-fivopts -fkeep-inline-functions -fkeep-static-functions
564-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
565-floop-block -floop-interchange -floop-strip-mine
566-floop-unroll-and-jam -floop-nest-optimize
567-floop-parallelize-all -flra-remat -flto -flto-compression-level
568-flto-partition=@var{alg} -fmerge-all-constants
569-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
570-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg
571-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
572-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
573-fno-peephole2 -fno-printf-return-value -fno-sched-interblock
574-fno-sched-spec -fno-signed-zeros
575-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
576-fomit-frame-pointer -foptimize-sibling-calls
577-fpartial-inlining -fpeel-loops -fpredictive-commoning
578-fprefetch-loop-arrays
579-fprofile-correction
580-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training
581-fprofile-values -fprofile-reorder-functions
582-freciprocal-math -free -frename-registers -freorder-blocks
583-freorder-blocks-algorithm=@var{algorithm}
584-freorder-blocks-and-partition -freorder-functions
585-frerun-cse-after-loop -freschedule-modulo-scheduled-loops
586-frounding-math -fsave-optimization-record
587-fsched2-use-superblocks -fsched-pressure
588-fsched-spec-load -fsched-spec-load-dangerous
589-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}]
590-fsched-group-heuristic -fsched-critical-path-heuristic
591-fsched-spec-insn-heuristic -fsched-rank-heuristic
592-fsched-last-insn-heuristic -fsched-dep-count-heuristic
593-fschedule-fusion
594-fschedule-insns -fschedule-insns2 -fsection-anchors
595-fselective-scheduling -fselective-scheduling2
596-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
597-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
598-fsignaling-nans
599-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
600-fsplit-paths
601-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt
602-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing
603-fthread-jumps -ftracer -ftree-bit-ccp
604-ftree-builtin-call-dce -ftree-ccp -ftree-ch
605-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts
606-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
607-ftree-loop-if-convert -ftree-loop-im
608-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
609-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
610-ftree-loop-vectorize
611-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta
612-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra
613-ftree-switch-conversion -ftree-tail-merge
614-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init
615-funconstrained-commons -funit-at-a-time -funroll-all-loops
616-funroll-loops -funsafe-math-optimizations -funswitch-loops
617-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
618-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs
d77de738
ML
619--param @var{name}=@var{value}
620-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
621
622@item Program Instrumentation Options
623@xref{Instrumentation Options,,Program Instrumentation Options}.
43b72ede
AA
624@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage
625-fprofile-abs-path
626-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path}
627-fprofile-info-section -fprofile-info-section=@var{name}
628-fprofile-note=@var{path} -fprofile-prefix-path=@var{path}
629-fprofile-update=@var{method} -fprofile-filter-files=@var{regex}
630-fprofile-exclude-files=@var{regex}
631-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
632-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style}
633-fsanitize-trap -fsanitize-trap=@var{style}
634-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},...
635-fsanitize-undefined-trap-on-error -fbounds-check
636-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
637-fharden-compares -fharden-conditional-branches
638-fstack-protector -fstack-protector-all -fstack-protector-strong
639-fstack-protector-explicit -fstack-check
640-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym}
641-fno-stack-limit -fsplit-stack
642-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
643-fvtv-counts -fvtv-debug
644-finstrument-functions -finstrument-functions-once
645-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
646-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
647-fprofile-prefix-map=@var{old}=@var{new}}
d77de738
ML
648
649@item Preprocessor Options
650@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
43b72ede
AA
651@gccoptlist{-A@var{question}=@var{answer}
652-A-@var{question}@r{[}=@var{answer}@r{]}
653-C -CC -D@var{macro}@r{[}=@var{defn}@r{]}
654-dD -dI -dM -dN -dU
655-fdebug-cpp -fdirectives-only -fdollars-in-identifiers
656-fexec-charset=@var{charset} -fextended-identifiers
657-finput-charset=@var{charset} -flarge-source-files
658-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth}
659-fno-canonical-system-headers -fpch-deps -fpch-preprocess
660-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion
661-fwide-exec-charset=@var{charset} -fworking-directory
662-H -imacros @var{file} -include @var{file}
663-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules
664-no-integrated-cpp -P -pthread -remap
665-traditional -traditional-cpp -trigraphs
666-U@var{macro} -undef
d77de738
ML
667-Wp,@var{option} -Xpreprocessor @var{option}}
668
669@item Assembler Options
670@xref{Assembler Options,,Passing Options to the Assembler}.
671@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
672
673@item Linker Options
674@xref{Link Options,,Options for Linking}.
43b72ede
AA
675@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library}
676-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++
677-e @var{entry} --entry=@var{entry}
678-pie -pthread -r -rdynamic
679-s -static -static-pie -static-libgcc -static-libstdc++
680-static-libasan -static-libtsan -static-liblsan -static-libubsan
681-shared -shared-libgcc -symbolic
682-T @var{script} -Wl,@var{option} -Xlinker @var{option}
d77de738
ML
683-u @var{symbol} -z @var{keyword}}
684
685@item Directory Options
686@xref{Directory Options,,Options for Directory Search}.
43b72ede
AA
687@gccoptlist{-B@var{prefix} -I@var{dir} -I-
688-idirafter @var{dir}
689-imacros @var{file} -imultilib @var{dir}
690-iplugindir=@var{dir} -iprefix @var{file}
691-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir}
692-iwithprefix @var{dir} -iwithprefixbefore @var{dir}
693-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix
d77de738
ML
694-nostdinc -nostdinc++ --sysroot=@var{dir}}
695
696@item Code Generation Options
697@xref{Code Gen Options,,Options for Code Generation Conventions}.
43b72ede
AA
698@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg}
699-ffixed-@var{reg} -fexceptions
700-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
701-fasynchronous-unwind-tables
702-fno-gnu-unique
703-finhibit-size-directive -fcommon -fno-ident
704-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
705-fno-jump-tables -fno-bit-tests
706-frecord-gcc-switches
707-freg-struct-return -fshort-enums -fshort-wchar
708-fverbose-asm -fpack-struct[=@var{n}]
709-fleading-underscore -ftls-model=@var{model}
710-fstack-reuse=@var{reuse_level}
711-ftrampolines -ftrapv -fwrapv
712-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
713-fstrict-volatile-bitfields -fsync-libcalls}
714
715@item Developer Options
716@xref{Developer Options,,GCC Developer Options}.
43b72ede 717@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion
d77de738 718-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
43b72ede
AA
719-fchecking -fchecking=@var{n}
720-fdbg-cnt-list -fdbg-cnt=@var{counter-value-list}
721-fdisable-ipa-@var{pass_name}
722-fdisable-rtl-@var{pass_name}
723-fdisable-rtl-@var{pass-name}=@var{range-list}
724-fdisable-tree-@var{pass_name}
725-fdisable-tree-@var{pass-name}=@var{range-list}
726-fdump-debug -fdump-earlydebug
727-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links
728-fdump-final-insns@r{[}=@var{file}@r{]}
729-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
730-fdump-lang-all
731-fdump-lang-@var{switch}
732-fdump-lang-@var{switch}-@var{options}
733-fdump-lang-@var{switch}-@var{options}=@var{filename}
734-fdump-passes
735-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename}
736-fdump-statistics
737-fdump-tree-all
738-fdump-tree-@var{switch}
739-fdump-tree-@var{switch}-@var{options}
740-fdump-tree-@var{switch}-@var{options}=@var{filename}
741-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second
742-fenable-@var{kind}-@var{pass}
743-fenable-@var{kind}-@var{pass}=@var{range-list}
744-fira-verbose=@var{n}
745-flto-report -flto-report-wpa -fmem-report-wpa
746-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report
747-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]}
748-fmultiflags -fprofile-report
749-frandom-seed=@var{string} -fsched-verbose=@var{n}
750-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
751-fstats -fstack-usage -ftime-report -ftime-report-details
752-fvar-tracking-assignments-toggle -gtoggle
753-print-file-name=@var{library} -print-libgcc-file-name
754-print-multi-directory -print-multi-lib -print-multi-os-directory
755-print-prog-name=@var{program} -print-search-dirs -Q
756-print-sysroot -print-sysroot-headers-suffix
d77de738
ML
757-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
758
759@item Machine-Dependent Options
760@xref{Submodel Options,,Machine-Dependent Options}.
761@c This list is ordered alphanumerically by subsection name.
762@c Try and put the significant identifier (CPU or system) first,
763@c so users have a clue at guessing where the ones they want will be.
764
765@emph{AArch64 Options}
43b72ede
AA
766@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian
767-mgeneral-regs-only
768-mcmodel=tiny -mcmodel=small -mcmodel=large
769-mstrict-align -mno-strict-align
770-momit-leaf-frame-pointer
771-mtls-dialect=desc -mtls-dialect=traditional
772-mtls-size=@var{size}
773-mfix-cortex-a53-835769 -mfix-cortex-a53-843419
774-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div
775-mpc-relative-literal-loads
776-msign-return-address=@var{scope}
d77de738 777-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
43b72ede
AA
778+@var{b-key}]|@var{bti}
779-mharden-sls=@var{opts}
780-march=@var{name} -mcpu=@var{name} -mtune=@var{name}
781-moverride=@var{string} -mverbose-cost-dump
782-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg}
783-mstack-protector-guard-offset=@var{offset} -mtrack-speculation
d77de738
ML
784-moutline-atomics }
785
786@emph{Adapteva Epiphany Options}
43b72ede
AA
787@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs
788-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf
789-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num}
790-mround-nearest -mlong-calls -mshort-calls -msmall16
791-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num}
d77de738
ML
792-msplit-vecmove-early -m1reg-@var{reg}}
793
794@emph{AMD GCN Options}
795@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
796
797@emph{ARC Options}
43b72ede
AA
798@gccoptlist{-mbarrel-shifter -mjli-always
799-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700
800-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr
801-mea -mno-mpy -mmul32x16 -mmul64 -matomic
802-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap
803-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape
804-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof
805-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved
806-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num}
807-mvolatile-cache -mtp-regno=@var{regno}
808-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc
809-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi
810-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none
811-mlra-priority-compact -mlra-priority-noncompact -mmillicode
812-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level}
813-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame
814-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo}
d77de738
ML
815-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
816
817@emph{ARM Options}
43b72ede
AA
818@gccoptlist{-mapcs-frame -mno-apcs-frame
819-mabi=@var{name}
820-mapcs-stack-check -mno-apcs-stack-check
821-mapcs-reentrant -mno-apcs-reentrant
822-mgeneral-regs-only
823-msched-prolog -mno-sched-prolog
824-mlittle-endian -mbig-endian
825-mbe8 -mbe32
826-mfloat-abi=@var{name}
d77de738 827-mfp16-format=@var{name}
43b72ede
AA
828-mthumb-interwork -mno-thumb-interwork
829-mcpu=@var{name} -march=@var{name} -mfpu=@var{name}
830-mtune=@var{name} -mprint-tune-info
831-mstructure-size-boundary=@var{n}
832-mabort-on-noreturn
833-mlong-calls -mno-long-calls
834-msingle-pic-base -mno-single-pic-base
835-mpic-register=@var{reg}
836-mnop-fun-dllimport
837-mpoke-function-name
838-mthumb -marm -mflip-thumb
839-mtpcs-frame -mtpcs-leaf-frame
840-mcaller-super-interworking -mcallee-super-interworking
841-mtp=@var{name} -mtls-dialect=@var{dialect}
842-mword-relocations
843-mfix-cortex-m3-ldrd
844-mfix-cortex-a57-aes-1742098
845-mfix-cortex-a72-aes-1655431
846-munaligned-access
847-mneon-for-64bits
848-mslow-flash-data
849-masm-syntax-unified
850-mrestrict-it
851-mverbose-cost-dump
852-mpure-code
853-mcmse
854-mfix-cmse-cve-2021-35465
855-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset}
856-mfdpic
14fab5fb
AC
857-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
858[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
d77de738
ML
859
860@emph{AVR Options}
43b72ede
AA
861@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args
862-mbranch-cost=@var{cost}
863-mcall-prologues -mgas-isr-prologues -mint8
864-mdouble=@var{bits} -mlong-double=@var{bits}
865-mn_flash=@var{size} -mno-interrupts
866-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack
867-mfract-convert-truncate
868-mshort-calls -nodevicelib -nodevicespecs
d77de738
ML
869-Waddr-space-convert -Wmisspelled-isr}
870
871@emph{Blackfin Options}
43b72ede
AA
872@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
873-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer
874-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly
875-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
876-mno-id-shared-library -mshared-library-id=@var{n}
877-mleaf-id-shared-library -mno-leaf-id-shared-library
878-msep-data -mno-sep-data -mlong-calls -mno-long-calls
879-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram
d77de738
ML
880-micplb}
881
882@emph{C6X Options}
43b72ede 883@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu}
d77de738
ML
884-msim -msdata=@var{sdata-type}}
885
886@emph{CRIS Options}
887@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
43b72ede
AA
888-mtune=@var{cpu} -mmax-stack-frame=@var{n}
889-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects
890-mstack-align -mdata-align -mconst-align
891-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
892-melf -maout -sim -sim2
d77de738
ML
893-mmul-bug-workaround -mno-mul-bug-workaround}
894
895@emph{C-SKY Options}
43b72ede
AA
896@gccoptlist{-march=@var{arch} -mcpu=@var{cpu}
897-mbig-endian -EB -mlittle-endian -EL
898-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu
899-mfloat-abi=@var{name}
900-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust
901-mdsp -medsp -mvdsp
902-mdiv -msmart -mhigh-registers -manchor
903-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt
d77de738
ML
904-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
905
906@emph{Darwin Options}
43b72ede
AA
907@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal
908-arch_only -bind_at_load -bundle -bundle_loader
909-client_name -compatibility_version -current_version
910-dead_strip
911-dependency-file -dylib_file -dylinker_install_name
912-dynamic -dynamiclib -exported_symbols_list
913-filelist -flat_namespace -force_cpusubtype_ALL
914-force_flat_namespace -headerpad_max_install_names
915-iframework
916-image_base -init -install_name -keep_private_externs
917-multi_module -multiply_defined -multiply_defined_unused
918-noall_load -no_dead_strip_inits_and_terms
919-nofixprebinding -nomultidefs -noprebind -noseglinkedit
920-pagezero_size -prebind -prebind_all_twolevel_modules
921-private_bundle -read_only_relocs -sectalign
922-sectobjectsymbols -whyload -seg1addr
923-sectcreate -sectobjectsymbols -sectorder
924-segaddr -segs_read_only_addr -segs_read_write_addr
925-seg_addr_table -seg_addr_table_filename -seglinkedit
926-segprot -segs_read_only_addr -segs_read_write_addr
927-single_module -static -sub_library -sub_umbrella
928-twolevel_namespace -umbrella -undefined
929-unexported_symbols_list -weak_reference_mismatches
930-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version}
d77de738
ML
931-mkernel -mone-byte-bool}
932
933@emph{DEC Alpha Options}
43b72ede
AA
934@gccoptlist{-mno-fp-regs -msoft-float
935-mieee -mieee-with-inexact -mieee-conformant
936-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode}
937-mtrap-precision=@var{mode} -mbuild-constants
938-mcpu=@var{cpu-type} -mtune=@var{cpu-type}
939-mbwx -mmax -mfix -mcix
940-mfloat-vax -mfloat-ieee
941-mexplicit-relocs -msmall-data -mlarge-data
942-msmall-text -mlarge-text
d77de738
ML
943-mmemory-latency=@var{time}}
944
945@emph{eBPF Options}
946@gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version}
947-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re
948-mjmpext -mjmp32 -malu32 -mcpu=@var{version}}
949
950@emph{FR30 Options}
951@gccoptlist{-msmall-model -mno-lsim}
952
953@emph{FT32 Options}
954@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
955
956@emph{FRV Options}
43b72ede
AA
957@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64
958-mhard-float -msoft-float
959-malloc-cc -mfixed-cc -mdword -mno-dword
960-mdouble -mno-double
961-mmedia -mno-media -mmuladd -mno-muladd
962-mfdpic -minline-plt -mgprel-ro -multilib-library-pic
963-mlinked-fp -mlong-calls -malign-labels
964-mlibrary-pic -macc-4 -macc-8
965-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move
966-moptimize-membar -mno-optimize-membar
967-mscc -mno-scc -mcond-exec -mno-cond-exec
968-mvliw-branch -mno-vliw-branch
969-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec
970-mno-nested-cond-exec -mtomcat-stats
971-mTLS -mtls
d77de738
ML
972-mcpu=@var{cpu}}
973
974@emph{GNU/Linux Options}
43b72ede 975@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid
d77de738
ML
976-tno-android-cc -tno-android-ld}
977
978@emph{H8/300 Options}
979@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
980
981@emph{HPPA Options}
43b72ede
AA
982@gccoptlist{-march=@var{architecture-type}
983-matomic-libcalls -mbig-switch
984-mcaller-copies -mdisable-fpregs -mdisable-indexing
985-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld
986-mfixed-range=@var{register-range}
987-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls
988-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs
989-mno-disable-indexing -mno-fast-indirect-calls -mno-gas
990-mno-jump-in-delay -mno-long-load-store
991-mno-portable-runtime -mno-soft-float
992-mno-space-regs -msoft-float -mpa-risc-1-0
993-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime
994-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio
d77de738
ML
995-munix=@var{unix-std} -nolibdld -static -threads}
996
997@emph{IA-64 Options}
43b72ede
AA
998@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic
999-mvolatile-asm-stop -mregister-names -msdata -mno-sdata
1000-mconstant-gp -mauto-pic -mfused-madd
1001-minline-float-divide-min-latency
1002-minline-float-divide-max-throughput
1003-mno-inline-float-divide
1004-minline-int-divide-min-latency
1005-minline-int-divide-max-throughput
1006-mno-inline-int-divide
1007-minline-sqrt-min-latency -minline-sqrt-max-throughput
1008-mno-inline-sqrt
1009-mdwarf2-asm -mearly-stop-bits
1010-mfixed-range=@var{register-range} -mtls-size=@var{tls-size}
1011-mtune=@var{cpu-type} -milp32 -mlp64
1012-msched-br-data-spec -msched-ar-data-spec -msched-control-spec
1013-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec
1014-msched-spec-ldc -msched-spec-control-ldc
1015-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns
1016-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path
1017-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
d77de738
ML
1018-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1019
1020@emph{LM32 Options}
43b72ede 1021@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled
d77de738
ML
1022-msign-extend-enabled -muser-enabled}
1023
1024@emph{LoongArch Options}
43b72ede
AA
1025@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type}
1026-mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float
1027-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division
1028-mcond-move-int -mno-cond-move-int
1029-mcond-move-float -mno-cond-move-float
1030-memcpy -mno-memcpy -mstrict-align -mno-strict-align
1031-mmax-inline-memcpy-size=@var{n}
1032-mexplicit-relocs -mno-explicit-relocs
1033-mdirect-extern-access -mno-direct-extern-access
d77de738
ML
1034-mcmodel=@var{code-model}}
1035
1036@emph{M32R/D Options}
43b72ede
AA
1037@gccoptlist{-m32r2 -m32rx -m32r
1038-mdebug
1039-malign-loops -mno-align-loops
1040-missue-rate=@var{number}
1041-mbranch-cost=@var{number}
1042-mmodel=@var{code-size-model-type}
1043-msdata=@var{sdata-type}
1044-mno-flush-func -mflush-func=@var{name}
1045-mno-flush-trap -mflush-trap=@var{number}
d77de738
ML
1046-G @var{num}}
1047
1048@emph{M32C Options}
1049@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1050
1051@emph{M680x0 Options}
43b72ede
AA
1052@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune}
1053-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040
1054-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407
1055-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020
1056-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort
1057-mno-short -mhard-float -m68881 -msoft-float -mpcrel
1058-malign-int -mstrict-align -msep-data -mno-sep-data
1059-mshared-library-id=n -mid-shared-library -mno-id-shared-library
d77de738
ML
1060-mxgot -mno-xgot -mlong-jump-table-offsets}
1061
1062@emph{MCore Options}
43b72ede
AA
1063@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates
1064-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields
1065-m4byte-functions -mno-4byte-functions -mcallgraph-data
1066-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim
d77de738
ML
1067-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1068
d77de738 1069@emph{MicroBlaze Options}
43b72ede
AA
1070@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu}
1071-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift
1072-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss
1073-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt
1074-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model}
d77de738
ML
1075-mpic-data-is-text-relative}
1076
1077@emph{MIPS Options}
43b72ede
AA
1078@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch}
1079-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
1080-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6
1081-mips16 -mno-mips16 -mflip-mips16
1082-minterlink-compressed -mno-interlink-compressed
1083-minterlink-mips16 -mno-interlink-mips16
1084-mabi=@var{abi} -mabicalls -mno-abicalls
1085-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot
1086-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float
1087-mno-float -msingle-float -mdouble-float
1088-modd-spreg -mno-odd-spreg
1089-mabs=@var{mode} -mnan=@var{encoding}
1090-mdsp -mno-dsp -mdspr2 -mno-dspr2
1091-mmcu -mmno-mcu
1092-meva -mno-eva
1093-mvirt -mno-virt
1094-mxpa -mno-xpa
1095-mcrc -mno-crc
1096-mginv -mno-ginv
1097-mmicromips -mno-micromips
1098-mmsa -mno-msa
1099-mloongson-mmi -mno-loongson-mmi
1100-mloongson-ext -mno-loongson-ext
1101-mloongson-ext2 -mno-loongson-ext2
1102-mfpu=@var{fpu-type}
1103-msmartmips -mno-smartmips
1104-mpaired-single -mno-paired-single -mdmx -mno-mdmx
1105-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc
1106-mlong64 -mlong32 -msym32 -mno-sym32
1107-G@var{num} -mlocal-sdata -mno-local-sdata
1108-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt
1109-membedded-data -mno-embedded-data
1110-muninit-const-in-rodata -mno-uninit-const-in-rodata
1111-mcode-readable=@var{setting}
1112-msplit-addresses -mno-split-addresses
1113-mexplicit-relocs -mno-explicit-relocs
1114-mcheck-zero-division -mno-check-zero-division
1115-mdivide-traps -mdivide-breaks
1116-mload-store-pairs -mno-load-store-pairs
1117-munaligned-access -mno-unaligned-access
1118-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls
1119-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp
1120-mfix-24k -mno-fix-24k
1121-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400
1122-mfix-r5900 -mno-fix-r5900
1123-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000
1124-mfix-vr4120 -mno-fix-vr4120
1125-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1
1126-mflush-func=@var{func} -mno-flush-func
1127-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely
1128-mcompact-branches=@var{policy}
1129-mfp-exceptions -mno-fp-exceptions
1130-mvr4130-align -mno-vr4130-align -msynci -mno-synci
1131-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4
1132-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
d77de738
ML
1133-mframe-header-opt -mno-frame-header-opt}
1134
1135@emph{MMIX Options}
43b72ede
AA
1136@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu
1137-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols
1138-melf -mbranch-predict -mno-branch-predict -mbase-addresses
d77de738
ML
1139-mno-base-addresses -msingle-exit -mno-single-exit}
1140
1141@emph{MN10300 Options}
43b72ede
AA
1142@gccoptlist{-mmult-bug -mno-mult-bug
1143-mno-am33 -mam33 -mam33-2 -mam34
1144-mtune=@var{cpu-type}
1145-mreturn-pointer-on-d0
d77de738
ML
1146-mno-crt0 -mrelax -mliw -msetlb}
1147
1148@emph{Moxie Options}
1149@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1150
1151@emph{MSP430 Options}
43b72ede
AA
1152@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax
1153-mwarn-mcu
1154-mcode-region= -mdata-region=
1155-msilicon-errata= -msilicon-errata-warn=
d77de738
ML
1156-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1157
1158@emph{NDS32 Options}
43b72ede
AA
1159@gccoptlist{-mbig-endian -mlittle-endian
1160-mreduced-regs -mfull-regs
1161-mcmov -mno-cmov
1162-mext-perf -mno-ext-perf
1163-mext-perf2 -mno-ext-perf2
1164-mext-string -mno-ext-string
1165-mv3push -mno-v3push
1166-m16bit -mno-16bit
1167-misr-vector-size=@var{num}
1168-mcache-block-size=@var{num}
1169-march=@var{arch}
1170-mcmodel=@var{code-model}
d77de738
ML
1171-mctor-dtor -mrelax}
1172
1173@emph{Nios II Options}
43b72ede
AA
1174@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt
1175-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp}
1176-mel -meb
1177-mno-bypass-cache -mbypass-cache
1178-mno-cache-volatile -mcache-volatile
1179-mno-fast-sw-div -mfast-sw-div
1180-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div
1181-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn}
1182-mcustom-fpu-cfg=@var{name}
1183-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name}
d77de738
ML
1184-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1185
1186@emph{Nvidia PTX Options}
1187@gccoptlist{-m64 -mmainkernel -moptimize}
1188
1189@emph{OpenRISC Options}
43b72ede
AA
1190@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div
1191-msoft-mul -msoft-div
1192-msoft-float -mhard-float -mdouble-float -munordered-float
1193-mcmov -mror -mrori -msext -msfimm -mshftimm
d77de738
ML
1194-mcmodel=@var{code-model}}
1195
1196@emph{PDP-11 Options}
43b72ede
AA
1197@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10
1198-mint32 -mno-int16 -mint16 -mno-int32
d77de738
ML
1199-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1200
d77de738
ML
1201@emph{PowerPC Options}
1202See RS/6000 and PowerPC Options.
1203
1204@emph{PRU Options}
43b72ede 1205@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop
f58e6d42 1206-mabi=@var{variant}}
d77de738
ML
1207
1208@emph{RISC-V Options}
43b72ede
AA
1209@gccoptlist{-mbranch-cost=@var{N-instruction}
1210-mplt -mno-plt
1211-mabi=@var{ABI-string}
1212-mfdiv -mno-fdiv
1213-mdiv -mno-div
1214-misa-spec=@var{ISA-spec-string}
1215-march=@var{ISA-string}
1216-mtune=@var{processor-string}
1217-mpreferred-stack-boundary=@var{num}
1218-msmall-data-limit=@var{N-bytes}
1219-msave-restore -mno-save-restore
1220-mshorten-memrefs -mno-shorten-memrefs
1221-mstrict-align -mno-strict-align
1222-mcmodel=medlow -mcmodel=medany
1223-mexplicit-relocs -mno-explicit-relocs
1224-mrelax -mno-relax
1225-mriscv-attribute -mno-riscv-attribute
1226-malign-data=@var{type}
1227-mbig-endian -mlittle-endian
1228-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1229-mstack-protector-guard-offset=@var{offset}
f797260a
PN
1230-mcsr-check -mno-csr-check
1231-minline-atomics -mno-inline-atomics}
d77de738
ML
1232
1233@emph{RL78 Options}
43b72ede
AA
1234@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs
1235-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
d77de738
ML
1236-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1237
1238@emph{RS/6000 and PowerPC Options}
43b72ede
AA
1239@gccoptlist{-mcpu=@var{cpu-type}
1240-mtune=@var{cpu-type}
1241-mcmodel=@var{code-model}
1242-mpowerpc64
1243-maltivec -mno-altivec
1244-mpowerpc-gpopt -mno-powerpc-gpopt
1245-mpowerpc-gfxopt -mno-powerpc-gfxopt
1246-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd
1247-mfprnd -mno-fprnd
1248-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp
1249-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc
1250-m64 -m32 -mxl-compat -mno-xl-compat -mpe
1251-malign-power -malign-natural
1252-msoft-float -mhard-float -mmultiple -mno-multiple
1253-mupdate -mno-update
1254-mavoid-indexed-addresses -mno-avoid-indexed-addresses
1255-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align
1256-mstrict-align -mno-strict-align -mrelocatable
1257-mno-relocatable -mrelocatable-lib -mno-relocatable-lib
1258-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian
1259-mdynamic-no-pic -mswdiv -msingle-pic-base
1260-mprioritize-restricted-insns=@var{priority}
1261-msched-costly-dep=@var{dependence_type}
1262-minsert-sched-nops=@var{scheme}
1263-mcall-aixdesc -mcall-eabi -mcall-freebsd
1264-mcall-linux -mcall-netbsd -mcall-openbsd
1265-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi
1266-mtraceback=@var{traceback_type}
1267-maix-struct-return -msvr4-struct-return
1268-mabi=@var{abi-type} -msecure-plt -mbss-plt
1269-mlongcall -mno-longcall -mpltseq -mno-pltseq
1270-mblock-move-inline-limit=@var{num}
1271-mblock-compare-inline-limit=@var{num}
1272-mblock-compare-inline-loop-limit=@var{num}
1273-mno-block-ops-unaligned-vsx
1274-mstring-compare-inline-limit=@var{num}
1275-misel -mno-isel
1276-mvrsave -mno-vrsave
1277-mmulhw -mno-mulhw
1278-mdlmzb -mno-dlmzb
1279-mprototype -mno-prototype
1280-msim -mmvme -mads -myellowknife -memb -msdata
1281-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num}
1282-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision
1283-mno-recip-precision
1284-mveclibabi=@var{type} -mfriz -mno-friz
1285-mpointers-to-nested-functions -mno-pointers-to-nested-functions
1286-msave-toc-indirect -mno-save-toc-indirect
1287-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector
1288-mcrypto -mno-crypto -mhtm -mno-htm
1289-mquad-memory -mno-quad-memory
1290-mquad-memory-atomic -mno-quad-memory-atomic
1291-mcompat-align-parm -mno-compat-align-parm
1292-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware
1293-mgnu-attribute -mno-gnu-attribute
1294-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg}
1295-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed
1296-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect
d77de738
ML
1297-mprivileged -mno-privileged}
1298
1299@emph{RX Options}
43b72ede
AA
1300@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu
1301-mcpu=
1302-mbig-endian-data -mlittle-endian-data
1303-msmall-data
1304-msim -mno-sim
1305-mas100-syntax -mno-as100-syntax
1306-mrelax
1307-mmax-constant-size=
1308-mint-register=
1309-mpid
1310-mallow-string-insns -mno-allow-string-insns
1311-mjsr
1312-mno-warn-multiple-fast-interrupts
d77de738
ML
1313-msave-acc-in-interrupts}
1314
1315@emph{S/390 and zSeries Options}
43b72ede
AA
1316@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1317-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp
1318-mlong-double-64 -mlong-double-128
1319-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack
1320-msmall-exec -mno-small-exec -mmvcle -mno-mvcle
1321-m64 -m31 -mdebug -mno-debug -mesa -mzarch
1322-mhtm -mvx -mzvector
1323-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip
1324-mfused-madd -mno-fused-madd
1325-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard
d77de738
ML
1326-mhotpatch=@var{halfwords},@var{halfwords}}
1327
d77de738 1328@emph{SH Options}
43b72ede
AA
1329@gccoptlist{-m1 -m2 -m2e
1330-m2a-nofpu -m2a-single-only -m2a-single -m2a
1331-m3 -m3e
1332-m4-nofpu -m4-single-only -m4-single -m4
1333-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al
1334-mb -ml -mdalign -mrelax
1335-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave
1336-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct
1337-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy}
1338-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range}
1339-maccumulate-outgoing-args
1340-matomic-model=@var{atomic-model}
1341-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch
1342-mcbranch-force-delay-slot
1343-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra
d77de738
ML
1344-mpretend-cmove -mtas}
1345
1346@emph{Solaris 2 Options}
43b72ede 1347@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text
d77de738
ML
1348-pthreads}
1349
1350@emph{SPARC Options}
43b72ede
AA
1351@gccoptlist{-mcpu=@var{cpu-type}
1352-mtune=@var{cpu-type}
1353-mcmodel=@var{code-model}
1354-mmemory-model=@var{mem-model}
1355-m32 -m64 -mapp-regs -mno-app-regs
1356-mfaster-structs -mno-faster-structs -mflat -mno-flat
1357-mfpu -mno-fpu -mhard-float -msoft-float
1358-mhard-quad-float -msoft-quad-float
1359-mstack-bias -mno-stack-bias
1360-mstd-struct-return -mno-std-struct-return
1361-munaligned-doubles -mno-unaligned-doubles
1362-muser-mode -mno-user-mode
1363-mv8plus -mno-v8plus -mvis -mno-vis
1364-mvis2 -mno-vis2 -mvis3 -mno-vis3
1365-mvis4 -mno-vis4 -mvis4b -mno-vis4b
1366-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld
1367-mpopc -mno-popc -msubxc -mno-subxc
1368-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc
d77de738
ML
1369-mlra -mno-lra}
1370
1371@emph{System V Options}
1372@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1373
1374@emph{V850 Options}
43b72ede
AA
1375@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep
1376-mprolog-function -mno-prolog-function -mspace
1377-mtda=@var{n} -msda=@var{n} -mzda=@var{n}
1378-mapp-regs -mno-app-regs
1379-mdisable-callt -mno-disable-callt
1380-mv850e2v3 -mv850e2 -mv850e1 -mv850es
1381-mv850e -mv850 -mv850e3v5
1382-mloop
1383-mrelax
1384-mlong-jumps
1385-msoft-float
1386-mhard-float
1387-mgcc-abi
1388-mrh850-abi
d77de738
ML
1389-mbig-switch}
1390
1391@emph{VAX Options}
1392@gccoptlist{-mg -mgnu -munix -mlra}
1393
1394@emph{Visium Options}
43b72ede 1395@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float
d77de738
ML
1396-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1397
1398@emph{VMS Options}
43b72ede 1399@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64
d77de738
ML
1400-mpointer-size=@var{size}}
1401
1402@emph{VxWorks Options}
43b72ede 1403@gccoptlist{-mrtp -non-static -Bstatic -Bdynamic
d77de738
ML
1404-Xbind-lazy -Xbind-now}
1405
1406@emph{x86 Options}
43b72ede
AA
1407@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type}
1408-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default
1409-mfpmath=@var{unit}
1410-masm=@var{dialect} -mno-fancy-math-387
1411-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
1412-mno-wide-multiply -mrtd -malign-double
1413-mpreferred-stack-boundary=@var{num}
1414-mincoming-stack-boundary=@var{num}
1415-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait
1416-mrecip -mrecip=@var{opt}
1417-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt}
1418-mmove-max=@var{bits} -mstore-max=@var{bits}
1419-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
1420-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl
1421-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
1422-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
1423-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves
1424-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
1425-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp
1426-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg
1427-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call
1428-mavx512vbmi2 -mavx512bf16 -menqcmd
1429-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
1430-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid
1431-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk
1432-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni
1433-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16
efa6a82b 1434-mprefetchi -mraoint -mamx-complex
43b72ede
AA
1435-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops
1436-minline-stringops-dynamically -mstringop-strategy=@var{alg}
1437-mkl -mwidekl
1438-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy}
1439-mpush-args -maccumulate-outgoing-args -m128bit-long-double
1440-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
1441-mregparm=@var{num} -msseregparm
1442-mveclibabi=@var{type} -mvect8-ret-in-mem
1443-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign
1444-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
1445-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode}
1446-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num}
1447-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
1448-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name}
1449-mavx256-split-unaligned-load -mavx256-split-unaligned-store
1450-malign-data=@var{type} -mstack-protector-guard=@var{guard}
1451-mstack-protector-guard-reg=@var{reg}
1452-mstack-protector-guard-offset=@var{offset}
1453-mstack-protector-guard-symbol=@var{symbol}
1454-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop
1455-mindirect-branch=@var{choice} -mfunction-return=@var{choice}
1456-mindirect-branch-register -mharden-sls=@var{choice}
1457-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access
bb576017 1458-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1459
1460@emph{x86 Windows Options}
43b72ede
AA
1461@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll
1462-mnop-fun-dllimport -mthread
d77de738
ML
1463-municode -mwin32 -mwindows -fno-set-stack-executable}
1464
1465@emph{Xstormy16 Options}
1466@gccoptlist{-msim}
1467
1468@emph{Xtensa Options}
43b72ede
AA
1469@gccoptlist{-mconst16 -mno-const16
1470-mfused-madd -mno-fused-madd
1471-mforce-no-pic
1472-mserialize-volatile -mno-serialize-volatile
1473-mtext-section-literals -mno-text-section-literals
1474-mauto-litpools -mno-auto-litpools
1475-mtarget-align -mno-target-align
1476-mlongcalls -mno-longcalls
1477-mabi=@var{abi-type}
675b390e
MF
1478-mextra-l32r-costs=@var{cycles}
1479-mstrict-align -mno-strict-align}
d77de738
ML
1480
1481@emph{zSeries Options}
1482See S/390 and zSeries Options.
1483@end table
1484
1485
1486@node Overall Options
1487@section Options Controlling the Kind of Output
1488
1489Compilation can involve up to four stages: preprocessing, compilation
1490proper, assembly and linking, always in that order. GCC is capable of
1491preprocessing and compiling several files either into several
1492assembler input files, or into one assembler input file; then each
1493assembler input file produces an object file, and linking combines all
1494the object files (those newly compiled, and those specified as input)
1495into an executable file.
1496
1497@cindex file name suffix
1498For any given input file, the file name suffix determines what kind of
1499compilation is done:
1500
1501@table @gcctabopt
1502@item @var{file}.c
1503C source code that must be preprocessed.
1504
1505@item @var{file}.i
1506C source code that should not be preprocessed.
1507
1508@item @var{file}.ii
1509C++ source code that should not be preprocessed.
1510
1511@item @var{file}.m
1512Objective-C source code. Note that you must link with the @file{libobjc}
1513library to make an Objective-C program work.
1514
1515@item @var{file}.mi
1516Objective-C source code that should not be preprocessed.
1517
1518@item @var{file}.mm
1519@itemx @var{file}.M
1520Objective-C++ source code. Note that you must link with the @file{libobjc}
1521library to make an Objective-C++ program work. Note that @samp{.M} refers
1522to a literal capital M@.
1523
1524@item @var{file}.mii
1525Objective-C++ source code that should not be preprocessed.
1526
1527@item @var{file}.h
1528C, C++, Objective-C or Objective-C++ header file to be turned into a
1529precompiled header (default), or C, C++ header file to be turned into an
1530Ada spec (via the @option{-fdump-ada-spec} switch).
1531
1532@item @var{file}.cc
1533@itemx @var{file}.cp
1534@itemx @var{file}.cxx
1535@itemx @var{file}.cpp
1536@itemx @var{file}.CPP
1537@itemx @var{file}.c++
1538@itemx @var{file}.C
1539C++ source code that must be preprocessed. Note that in @samp{.cxx},
1540the last two letters must both be literally @samp{x}. Likewise,
1541@samp{.C} refers to a literal capital C@.
1542
1543@item @var{file}.mm
1544@itemx @var{file}.M
1545Objective-C++ source code that must be preprocessed.
1546
1547@item @var{file}.mii
1548Objective-C++ source code that should not be preprocessed.
1549
1550@item @var{file}.hh
1551@itemx @var{file}.H
1552@itemx @var{file}.hp
1553@itemx @var{file}.hxx
1554@itemx @var{file}.hpp
1555@itemx @var{file}.HPP
1556@itemx @var{file}.h++
1557@itemx @var{file}.tcc
1558C++ header file to be turned into a precompiled header or Ada spec.
1559
1560@item @var{file}.f
1561@itemx @var{file}.for
1562@itemx @var{file}.ftn
1563Fixed form Fortran source code that should not be preprocessed.
1564
1565@item @var{file}.F
1566@itemx @var{file}.FOR
1567@itemx @var{file}.fpp
1568@itemx @var{file}.FPP
1569@itemx @var{file}.FTN
1570Fixed form Fortran source code that must be preprocessed (with the traditional
1571preprocessor).
1572
1573@item @var{file}.f90
1574@itemx @var{file}.f95
1575@itemx @var{file}.f03
1576@itemx @var{file}.f08
1577Free form Fortran source code that should not be preprocessed.
1578
1579@item @var{file}.F90
1580@itemx @var{file}.F95
1581@itemx @var{file}.F03
1582@itemx @var{file}.F08
1583Free form Fortran source code that must be preprocessed (with the
1584traditional preprocessor).
1585
1586@item @var{file}.go
1587Go source code.
1588
1589@item @var{file}.d
1590D source code.
1591
1592@item @var{file}.di
1593D interface file.
1594
1595@item @var{file}.dd
1596D documentation code (Ddoc).
1597
1598@item @var{file}.ads
1599Ada source code file that contains a library unit declaration (a
1600declaration of a package, subprogram, or generic, or a generic
1601instantiation), or a library unit renaming declaration (a package,
1602generic, or subprogram renaming declaration). Such files are also
1603called @dfn{specs}.
1604
1605@item @var{file}.adb
1606Ada source code file containing a library unit body (a subprogram or
1607package body). Such files are also called @dfn{bodies}.
1608
1609@c GCC also knows about some suffixes for languages not yet included:
1610@c Ratfor:
1611@c @var{file}.r
1612
1613@item @var{file}.s
1614Assembler code.
1615
1616@item @var{file}.S
1617@itemx @var{file}.sx
1618Assembler code that must be preprocessed.
1619
1620@item @var{other}
1621An object file to be fed straight into linking.
1622Any file name with no recognized suffix is treated this way.
1623@end table
1624
1625@opindex x
1626You can specify the input language explicitly with the @option{-x} option:
1627
1628@table @gcctabopt
1629@item -x @var{language}
1630Specify explicitly the @var{language} for the following input files
1631(rather than letting the compiler choose a default based on the file
1632name suffix). This option applies to all following input files until
1633the next @option{-x} option. Possible values for @var{language} are:
1634@smallexample
1635c c-header cpp-output
1636c++ c++-header c++-system-header c++-user-header c++-cpp-output
1637objective-c objective-c-header objective-c-cpp-output
1638objective-c++ objective-c++-header objective-c++-cpp-output
1639assembler assembler-with-cpp
1640ada
1641d
1642f77 f77-cpp-input f95 f95-cpp-input
1643go
1644@end smallexample
1645
1646@item -x none
1647Turn off any specification of a language, so that subsequent files are
1648handled according to their file name suffixes (as they are if @option{-x}
1649has not been used at all).
1650@end table
1651
1652If you only want some of the stages of compilation, you can use
1653@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1654one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1655@command{gcc} is to stop. Note that some combinations (for example,
1656@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1657
1658@table @gcctabopt
d77de738 1659@opindex c
ddf6fe37 1660@item -c
d77de738
ML
1661Compile or assemble the source files, but do not link. The linking
1662stage simply is not done. The ultimate output is in the form of an
1663object file for each source file.
1664
1665By default, the object file name for a source file is made by replacing
1666the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1667
1668Unrecognized input files, not requiring compilation or assembly, are
1669ignored.
1670
d77de738 1671@opindex S
ddf6fe37 1672@item -S
d77de738
ML
1673Stop after the stage of compilation proper; do not assemble. The output
1674is in the form of an assembler code file for each non-assembler input
1675file specified.
1676
1677By default, the assembler file name for a source file is made by
1678replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1679
1680Input files that don't require compilation are ignored.
1681
d77de738 1682@opindex E
ddf6fe37 1683@item -E
d77de738
ML
1684Stop after the preprocessing stage; do not run the compiler proper. The
1685output is in the form of preprocessed source code, which is sent to the
1686standard output.
1687
1688Input files that don't require preprocessing are ignored.
1689
1690@cindex output file option
d77de738 1691@opindex o
ddf6fe37 1692@item -o @var{file}
d77de738
ML
1693Place the primary output in file @var{file}. This applies to whatever
1694sort of output is being produced, whether it be an executable file, an
1695object file, an assembler file or preprocessed C code.
1696
1697If @option{-o} is not specified, the default is to put an executable
1698file in @file{a.out}, the object file for
1699@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1700assembler file in @file{@var{source}.s}, a precompiled header file in
1701@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1702standard output.
1703
1704Though @option{-o} names only the primary output, it also affects the
1705naming of auxiliary and dump outputs. See the examples below. Unless
1706overridden, both auxiliary outputs and dump outputs are placed in the
1707same directory as the primary output. In auxiliary outputs, the suffix
1708of the input file is replaced with that of the auxiliary output file
1709type; in dump outputs, the suffix of the dump file is appended to the
1710input file suffix. In compilation commands, the base name of both
1711auxiliary and dump outputs is that of the primary output; in compile and
1712link commands, the primary output name, minus the executable suffix, is
1713combined with the input file name. If both share the same base name,
1714disregarding the suffix, the result of the combination is that base
1715name, otherwise, they are concatenated, separated by a dash.
1716
1717@smallexample
1718gcc -c foo.c ...
1719@end smallexample
1720
1721will use @file{foo.o} as the primary output, and place aux outputs and
1722dumps next to it, e.g., aux file @file{foo.dwo} for
1723@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1724@option{-fdump-rtl-final}.
1725
1726If a non-linker output file is explicitly specified, aux and dump files
1727by default take the same base name:
1728
1729@smallexample
1730gcc -c foo.c -o dir/foobar.o ...
1731@end smallexample
1732
1733will name aux outputs @file{dir/foobar.*} and dump outputs
1734@file{dir/foobar.c.*}.
1735
1736A linker output will instead prefix aux and dump outputs:
1737
1738@smallexample
1739gcc foo.c bar.c -o dir/foobar ...
1740@end smallexample
1741
1742will generally name aux outputs @file{dir/foobar-foo.*} and
1743@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1744@file{dir/foobar-bar.c.*}.
1745
1746The one exception to the above is when the executable shares the base
1747name with the single input:
1748
1749@smallexample
1750gcc foo.c -o dir/foo ...
1751@end smallexample
1752
1753in which case aux outputs are named @file{dir/foo.*} and dump outputs
1754named @file{dir/foo.c.*}.
1755
1756The location and the names of auxiliary and dump outputs can be adjusted
1757by the options @option{-dumpbase}, @option{-dumpbase-ext},
1758@option{-dumpdir}, @option{-save-temps=cwd}, and
1759@option{-save-temps=obj}.
1760
1761
d77de738 1762@opindex dumpbase
ddf6fe37 1763@item -dumpbase @var{dumpbase}
d77de738
ML
1764This option sets the base name for auxiliary and dump output files. It
1765does not affect the name of the primary output file. Intermediate
1766outputs, when preserved, are not regarded as primary outputs, but as
1767auxiliary outputs:
1768
1769@smallexample
1770gcc -save-temps -S foo.c
1771@end smallexample
1772
1773saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1774then compiles to the (implied) output file @file{foo.s}, whereas:
1775
1776@smallexample
1777gcc -save-temps -dumpbase save-foo -c foo.c
1778@end smallexample
1779
1780preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1781an intermediate, thus auxiliary output), and then assembles to the
1782(implied) output file @file{foo.o}.
1783
1784Absent this option, dump and aux files take their names from the input
1785file, or from the (non-linker) output file, if one is explicitly
1786specified: dump output files (e.g. those requested by @option{-fdump-*}
1787options) with the input name suffix, and aux output files (those
1788requested by other non-dump options, e.g. @code{-save-temps},
1789@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1790
1791Similar suffix differentiation of dump and aux outputs can be attained
1792for explicitly-given @option{-dumpbase basename.suf} by also specifying
1793@option{-dumpbase-ext .suf}.
1794
1795If @var{dumpbase} is explicitly specified with any directory component,
1796any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1797@option{-save-temps=*}) is ignored, and instead of appending to it,
1798@var{dumpbase} fully overrides it:
1799
1800@smallexample
1801gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1802 -dumpdir pfx- -save-temps=cwd ...
1803@end smallexample
1804
1805creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1806@file{dir/} in @option{-o}, the @file{./} prefix implied by
1807@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1808
1809When @option{-dumpbase} is specified in a command that compiles multiple
1810inputs, or that compiles and then links, it may be combined with
1811@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1812file is compiled using the combined @var{dumppfx}, and default values
1813for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1814file:
1815
1816@smallexample
1817gcc foo.c bar.c -c -dumpbase main ...
1818@end smallexample
1819
1820creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1821overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1822as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1823and @file{main-bar.*}.
1824
1825An empty string specified as @var{dumpbase} avoids the influence of the
1826output basename in the naming of auxiliary and dump outputs during
1827compilation, computing default values :
1828
1829@smallexample
1830gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1831@end smallexample
1832
1833will name aux outputs @file{dir/foo.*} and dump outputs
1834@file{dir/foo.c.*}. Note how their basenames are taken from the input
1835name, but the directory still defaults to that of the output.
1836
1837The empty-string dumpbase does not prevent the use of the output
1838basename for outputs during linking:
1839
1840@smallexample
1841gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1842@end smallexample
1843
1844The compilation of the source files will name auxiliary outputs
1845@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1846@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1847linking will use @file{dir/foobar.} as the prefix for dumps and
1848auxiliary files.
1849
1850
d77de738 1851@opindex dumpbase-ext
ddf6fe37 1852@item -dumpbase-ext @var{auxdropsuf}
d77de738
ML
1853When forming the name of an auxiliary (but not a dump) output file, drop
1854trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1855suffixes. If not specified, this option defaults to the suffix of a
1856default @var{dumpbase}, i.e., the suffix of the input file when
1857@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1858is combined with @var{dumppfx}.
1859
1860@smallexample
1861gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1862@end smallexample
1863
1864creates @file{dir/foo.o} as the main output, and generates auxiliary
1865outputs in @file{dir/x-foo.*}, taking the location of the primary
1866output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1867outputs retain the suffix: @file{dir/x-foo.c.*}.
1868
1869This option is disregarded if it does not match the suffix of a
1870specified @var{dumpbase}, except as an alternative to the executable
1871suffix when appending the linker output base name to @var{dumppfx}, as
1872specified below:
1873
1874@smallexample
1875gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1876@end smallexample
1877
1878creates @file{main.out} as the primary output, and avoids overwriting
1879the auxiliary and dump outputs by using the executable name minus
1880@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1881@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1882@file{main-foo.c.*} and @file{main-bar.c.*}.
1883
1884
d77de738 1885@opindex dumpdir
ddf6fe37 1886@item -dumpdir @var{dumppfx}
d77de738
ML
1887When forming the name of an auxiliary or dump output file, use
1888@var{dumppfx} as a prefix:
1889
1890@smallexample
1891gcc -dumpdir pfx- -c foo.c ...
1892@end smallexample
1893
1894creates @file{foo.o} as the primary output, and auxiliary outputs named
1895@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1896@var{dumpbase} derived from the default primary output, derived in turn
1897from the input name. Dump outputs also take the input name suffix:
1898@file{pfx-foo.c.*}.
1899
1900If @var{dumppfx} is to be used as a directory name, it must end with a
1901directory separator:
1902
1903@smallexample
1904gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1905@end smallexample
1906
1907creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1908named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1909default @var{dumpbase} derived from the primary output name. Dump
1910outputs also take the input name suffix: @file{dir/bar.c.*}.
1911
1912It defaults to the location of the output file, unless the output
1913file is a special file like @code{/dev/null}. Options
1914@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1915default, just like an explicit @option{-dumpdir} option. In case
1916multiple such options are given, the last one prevails:
1917
1918@smallexample
1919gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1920@end smallexample
1921
1922outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1923@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1924@option{-dumpdir} option. It does not matter that @option{=obj} is the
1925default for @option{-save-temps}, nor that the output directory is
1926implicitly the current directory. Dump outputs are named
1927@file{foo.c.*}.
1928
1929When compiling from multiple input files, if @option{-dumpbase} is
1930specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1931are appended to (or override, if containing any directory components) an
1932explicit or defaulted @var{dumppfx}, so that each of the multiple
1933compilations gets differently-named aux and dump outputs.
1934
1935@smallexample
1936gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1937@end smallexample
1938
1939outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1940@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1941Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1942and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1943single-input compilation:
1944
1945@smallexample
1946gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1947@end smallexample
1948
1949that, applying @option{-dumpbase} to a single source, does not compute
1950and append a separate @var{dumpbase} per input file. Its auxiliary and
1951dump outputs go in @file{dir/pfx-main.*}.
1952
1953When compiling and then linking from multiple input files, a defaulted
1954or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1955transformation above (e.g. the compilation of @file{foo.c} and
1956@file{bar.c} above, but without @option{-c}). If neither
1957@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1958base name, minus @var{auxdropsuf}, if specified, or the executable
1959suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1960instead. Note, however, that unlike earlier cases of linking:
1961
1962@smallexample
1963gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1964@end smallexample
1965
1966does not append the output name @file{main} to @var{dumppfx}, because
1967@option{-dumpdir} is explicitly specified. The goal is that the
1968explicitly-specified @var{dumppfx} may contain the specified output name
1969as part of the prefix, if desired; only an explicitly-specified
1970@option{-dumpbase} would be combined with it, in order to avoid simply
1971discarding a meaningful option.
1972
1973When compiling and then linking from a single input file, the linker
1974output base name will only be appended to the default @var{dumppfx} as
1975above if it does not share the base name with the single input file
1976name. This has been covered in single-input linking cases above, but
1977not with an explicit @option{-dumpdir} that inhibits the combination,
1978even if overridden by @option{-save-temps=*}:
1979
1980@smallexample
1981gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1982@end smallexample
1983
1984Auxiliary outputs are named @file{foo.*}, and dump outputs
1985@file{foo.c.*}, in the current working directory as ultimately requested
1986by @option{-save-temps=cwd}.
1987
1988Summing it all up for an intuitive though slightly imprecise data flow:
1989the primary output name is broken into a directory part and a basename
1990part; @var{dumppfx} is set to the former, unless overridden by
1991@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
1992to the latter, unless overriden by @option{-dumpbase}. If there are
1993multiple inputs or linking, this @var{dumpbase} may be combined with
1994@var{dumppfx} and taken from each input file. Auxiliary output names
1995for each input are formed by combining @var{dumppfx}, @var{dumpbase}
1996minus suffix, and the auxiliary output suffix; dump output names are
1997only different in that the suffix from @var{dumpbase} is retained.
1998
1999When it comes to auxiliary and dump outputs created during LTO
2000recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
2001given or as derived from the linker output name but not from inputs,
2002even in cases in which this combination would not otherwise be used as
2003such, is passed down with a trailing period replacing the compiler-added
2004dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2005being involved in linking, this program does not normally get any
2006@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2007
2008When running sub-compilers, @command{lto-wrapper} appends LTO stage
2009names to the received @var{dumppfx}, ensures it contains a directory
2010component so that it overrides any @option{-dumpdir}, and passes that as
2011@option{-dumpbase} to sub-compilers.
2012
d77de738 2013@opindex v
ddf6fe37 2014@item -v
d77de738
ML
2015Print (on standard error output) the commands executed to run the stages
2016of compilation. Also print the version number of the compiler driver
2017program and of the preprocessor and the compiler proper.
2018
d77de738 2019@opindex ###
ddf6fe37 2020@item -###
d77de738
ML
2021Like @option{-v} except the commands are not executed and arguments
2022are quoted unless they contain only alphanumeric characters or @code{./-_}.
2023This is useful for shell scripts to capture the driver-generated command lines.
2024
d77de738 2025@opindex help
ddf6fe37 2026@item --help
d77de738
ML
2027Print (on the standard output) a description of the command-line options
2028understood by @command{gcc}. If the @option{-v} option is also specified
2029then @option{--help} is also passed on to the various processes
2030invoked by @command{gcc}, so that they can display the command-line options
2031they accept. If the @option{-Wextra} option has also been specified
2032(prior to the @option{--help} option), then command-line options that
2033have no documentation associated with them are also displayed.
2034
d77de738 2035@opindex target-help
ddf6fe37 2036@item --target-help
d77de738
ML
2037Print (on the standard output) a description of target-specific command-line
2038options for each tool. For some targets extra target-specific
2039information may also be printed.
2040
2041@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2042Print (on the standard output) a description of the command-line
2043options understood by the compiler that fit into all specified classes
2044and qualifiers. These are the supported classes:
2045
2046@table @asis
2047@item @samp{optimizers}
2048Display all of the optimization options supported by the
2049compiler.
2050
2051@item @samp{warnings}
2052Display all of the options controlling warning messages
2053produced by the compiler.
2054
2055@item @samp{target}
2056Display target-specific options. Unlike the
2057@option{--target-help} option however, target-specific options of the
2058linker and assembler are not displayed. This is because those
2059tools do not currently support the extended @option{--help=} syntax.
2060
2061@item @samp{params}
2062Display the values recognized by the @option{--param}
2063option.
2064
2065@item @var{language}
2066Display the options supported for @var{language}, where
2067@var{language} is the name of one of the languages supported in this
2068version of GCC@. If an option is supported by all languages, one needs
2069to select @samp{common} class.
2070
2071@item @samp{common}
2072Display the options that are common to all languages.
2073@end table
2074
2075These are the supported qualifiers:
2076
2077@table @asis
2078@item @samp{undocumented}
2079Display only those options that are undocumented.
2080
2081@item @samp{joined}
2082Display options taking an argument that appears after an equal
2083sign in the same continuous piece of text, such as:
2084@samp{--help=target}.
2085
2086@item @samp{separate}
2087Display options taking an argument that appears as a separate word
2088following the original option, such as: @samp{-o output-file}.
2089@end table
2090
2091Thus for example to display all the undocumented target-specific
2092switches supported by the compiler, use:
2093
2094@smallexample
2095--help=target,undocumented
2096@end smallexample
2097
2098The sense of a qualifier can be inverted by prefixing it with the
2099@samp{^} character, so for example to display all binary warning
2100options (i.e., ones that are either on or off and that do not take an
2101argument) that have a description, use:
2102
2103@smallexample
2104--help=warnings,^joined,^undocumented
2105@end smallexample
2106
2107The argument to @option{--help=} should not consist solely of inverted
2108qualifiers.
2109
2110Combining several classes is possible, although this usually
2111restricts the output so much that there is nothing to display. One
2112case where it does work, however, is when one of the classes is
2113@var{target}. For example, to display all the target-specific
2114optimization options, use:
2115
2116@smallexample
2117--help=target,optimizers
2118@end smallexample
2119
2120The @option{--help=} option can be repeated on the command line. Each
2121successive use displays its requested class of options, skipping
2122those that have already been displayed. If @option{--help} is also
2123specified anywhere on the command line then this takes precedence
2124over any @option{--help=} option.
2125
2126If the @option{-Q} option appears on the command line before the
2127@option{--help=} option, then the descriptive text displayed by
2128@option{--help=} is changed. Instead of describing the displayed
2129options, an indication is given as to whether the option is enabled,
2130disabled or set to a specific value (assuming that the compiler
2131knows this at the point where the @option{--help=} option is used).
2132
2133Here is a truncated example from the ARM port of @command{gcc}:
2134
2135@smallexample
2136 % gcc -Q -mabi=2 --help=target -c
2137 The following options are target specific:
2138 -mabi= 2
2139 -mabort-on-noreturn [disabled]
2140 -mapcs [disabled]
2141@end smallexample
2142
2143The output is sensitive to the effects of previous command-line
2144options, so for example it is possible to find out which optimizations
2145are enabled at @option{-O2} by using:
2146
2147@smallexample
2148-Q -O2 --help=optimizers
2149@end smallexample
2150
2151Alternatively you can discover which binary optimizations are enabled
2152by @option{-O3} by using:
2153
2154@smallexample
2155gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2156gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2157diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2158@end smallexample
2159
d77de738 2160@opindex version
ddf6fe37 2161@item --version
d77de738
ML
2162Display the version number and copyrights of the invoked GCC@.
2163
d77de738 2164@opindex pass-exit-codes
ddf6fe37 2165@item -pass-exit-codes
d77de738
ML
2166Normally the @command{gcc} program exits with the code of 1 if any
2167phase of the compiler returns a non-success return code. If you specify
2168@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2169the numerically highest error produced by any phase returning an error
2170indication. The C, C++, and Fortran front ends return 4 if an internal
2171compiler error is encountered.
2172
d77de738 2173@opindex pipe
ddf6fe37 2174@item -pipe
d77de738
ML
2175Use pipes rather than temporary files for communication between the
2176various stages of compilation. This fails to work on some systems where
2177the assembler is unable to read from a pipe; but the GNU assembler has
2178no trouble.
2179
d77de738 2180@opindex specs
ddf6fe37 2181@item -specs=@var{file}
d77de738
ML
2182Process @var{file} after the compiler reads in the standard @file{specs}
2183file, in order to override the defaults which the @command{gcc} driver
2184program uses when determining what switches to pass to @command{cc1},
2185@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2186@option{-specs=@var{file}} can be specified on the command line, and they
2187are processed in order, from left to right. @xref{Spec Files}, for
2188information about the format of the @var{file}.
2189
d77de738 2190@opindex wrapper
ddf6fe37 2191@item -wrapper
d77de738
ML
2192Invoke all subcommands under a wrapper program. The name of the
2193wrapper program and its parameters are passed as a comma separated
2194list.
2195
2196@smallexample
2197gcc -c t.c -wrapper gdb,--args
2198@end smallexample
2199
2200@noindent
2201This invokes all subprograms of @command{gcc} under
2202@samp{gdb --args}, thus the invocation of @command{cc1} is
2203@samp{gdb --args cc1 @dots{}}.
2204
d77de738 2205@opindex ffile-prefix-map
ddf6fe37 2206@item -ffile-prefix-map=@var{old}=@var{new}
d77de738
ML
2207When compiling files residing in directory @file{@var{old}}, record
2208any references to them in the result of the compilation as if the
2209files resided in directory @file{@var{new}} instead. Specifying this
2210option is equivalent to specifying all the individual
2211@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27 2212builds that are location independent. Directories referenced by
2eb0191a
JJ
2213directives are not affected by these options. See also
2214@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2215@option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2216
2eb0191a 2217@opindex fcanon-prefix-map
e54b01a1 2218@item -fcanon-prefix-map
2eb0191a
JJ
2219For the @option{-f*-prefix-map} options normally comparison
2220of @file{@var{old}} prefix against the filename that would be normally
2221referenced in the result of the compilation is done using textual
2222comparison of the prefixes, or ignoring character case for case insensitive
2223filesystems and considering slashes and backslashes as equal on DOS based
2224filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2225to be done on canonicalized paths of @file{@var{old}}
2226and the referenced filename.
d77de738 2227
d77de738 2228@opindex fplugin
ddf6fe37 2229@item -fplugin=@var{name}.so
d77de738
ML
2230Load the plugin code in file @var{name}.so, assumed to be a
2231shared object to be dlopen'd by the compiler. The base name of
2232the shared object file is used to identify the plugin for the
2233purposes of argument parsing (See
2234@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2235Each plugin should define the callback functions specified in the
2236Plugins API.
2237
d77de738 2238@opindex fplugin-arg
ddf6fe37 2239@item -fplugin-arg-@var{name}-@var{key}=@var{value}
d77de738
ML
2240Define an argument called @var{key} with a value of @var{value}
2241for the plugin called @var{name}.
2242
d77de738 2243@opindex fdump-ada-spec
ddf6fe37 2244@item -fdump-ada-spec@r{[}-slim@r{]}
d77de738
ML
2245For C and C++ source and include files, generate corresponding Ada specs.
2246@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2247GNAT User's Guide}, which provides detailed documentation on this feature.
2248
d77de738 2249@opindex fada-spec-parent
ddf6fe37 2250@item -fada-spec-parent=@var{unit}
d77de738
ML
2251In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2252Ada specs as child units of parent @var{unit}.
2253
d77de738 2254@opindex fdump-go-spec
ddf6fe37 2255@item -fdump-go-spec=@var{file}
d77de738
ML
2256For input files in any language, generate corresponding Go
2257declarations in @var{file}. This generates Go @code{const},
2258@code{type}, @code{var}, and @code{func} declarations which may be a
2259useful way to start writing a Go interface to code written in some
2260other language.
2261
2262@include @value{srcdir}/../libiberty/at-file.texi
2263@end table
2264
2265@node Invoking G++
2266@section Compiling C++ Programs
2267
2268@cindex suffixes for C++ source
2269@cindex C++ source file suffixes
2270C++ source files conventionally use one of the suffixes @samp{.C},
2271@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2272@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2273@samp{.H}, or (for shared template code) @samp{.tcc}; and
2274preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2275files with these names and compiles them as C++ programs even if you
2276call the compiler the same way as for compiling C programs (usually
2277with the name @command{gcc}).
2278
2279@findex g++
2280@findex c++
2281However, the use of @command{gcc} does not add the C++ library.
2282@command{g++} is a program that calls GCC and automatically specifies linking
2283against the C++ library. It treats @samp{.c},
2284@samp{.h} and @samp{.i} files as C++ source files instead of C source
2285files unless @option{-x} is used. This program is also useful when
2286precompiling a C header file with a @samp{.h} extension for use in C++
2287compilations. On many systems, @command{g++} is also installed with
2288the name @command{c++}.
2289
2290@cindex invoking @command{g++}
2291When you compile C++ programs, you may specify many of the same
2292command-line options that you use for compiling programs in any
2293language; or command-line options meaningful for C and related
2294languages; or options that are meaningful only for C++ programs.
2295@xref{C Dialect Options,,Options Controlling C Dialect}, for
2296explanations of options for languages related to C@.
2297@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2298explanations of options that are meaningful only for C++ programs.
2299
2300@node C Dialect Options
2301@section Options Controlling C Dialect
2302@cindex dialect options
2303@cindex language dialect options
2304@cindex options, dialect
2305
2306The following options control the dialect of C (or languages derived
2307from C, such as C++, Objective-C and Objective-C++) that the compiler
2308accepts:
2309
2310@table @gcctabopt
2311@cindex ANSI support
2312@cindex ISO support
d77de738 2313@opindex ansi
ddf6fe37 2314@item -ansi
d77de738
ML
2315In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2316equivalent to @option{-std=c++98}.
2317
2318This turns off certain features of GCC that are incompatible with ISO
2319C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2320such as the @code{asm} and @code{typeof} keywords, and
2321predefined macros such as @code{unix} and @code{vax} that identify the
2322type of system you are using. It also enables the undesirable and
2323rarely used ISO trigraph feature. For the C compiler,
2324it disables recognition of C++ style @samp{//} comments as well as
2325the @code{inline} keyword.
2326
2327The alternate keywords @code{__asm__}, @code{__extension__},
2328@code{__inline__} and @code{__typeof__} continue to work despite
2329@option{-ansi}. You would not want to use them in an ISO C program, of
2330course, but it is useful to put them in header files that might be included
2331in compilations done with @option{-ansi}. Alternate predefined macros
2332such as @code{__unix__} and @code{__vax__} are also available, with or
2333without @option{-ansi}.
2334
2335The @option{-ansi} option does not cause non-ISO programs to be
2336rejected gratuitously. For that, @option{-Wpedantic} is required in
2337addition to @option{-ansi}. @xref{Warning Options}.
2338
2339The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2340option is used. Some header files may notice this macro and refrain
2341from declaring certain functions or defining certain macros that the
2342ISO standard doesn't call for; this is to avoid interfering with any
2343programs that might use these names for other things.
2344
2345Functions that are normally built in but do not have semantics
2346defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2347functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2348built-in functions provided by GCC}, for details of the functions
2349affected.
2350
d77de738 2351@opindex std
ddf6fe37 2352@item -std=
d77de738
ML
2353Determine the language standard. @xref{Standards,,Language Standards
2354Supported by GCC}, for details of these standard versions. This option
2355is currently only supported when compiling C or C++.
2356
2357The compiler can accept several base standards, such as @samp{c90} or
2358@samp{c++98}, and GNU dialects of those standards, such as
2359@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2360compiler accepts all programs following that standard plus those
2361using GNU extensions that do not contradict it. For example,
2362@option{-std=c90} turns off certain features of GCC that are
2363incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2364keywords, but not other GNU extensions that do not have a meaning in
2365ISO C90, such as omitting the middle term of a @code{?:}
2366expression. On the other hand, when a GNU dialect of a standard is
2367specified, all features supported by the compiler are enabled, even when
2368those features change the meaning of the base standard. As a result, some
2369strict-conforming programs may be rejected. The particular standard
2370is used by @option{-Wpedantic} to identify which features are GNU
2371extensions given that version of the standard. For example
2372@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2373comments, while @option{-std=gnu99 -Wpedantic} does not.
2374
2375A value for this option must be provided; possible values are
2376
2377@table @samp
2378@item c90
2379@itemx c89
2380@itemx iso9899:1990
2381Support all ISO C90 programs (certain GNU extensions that conflict
2382with ISO C90 are disabled). Same as @option{-ansi} for C code.
2383
2384@item iso9899:199409
2385ISO C90 as modified in amendment 1.
2386
2387@item c99
2388@itemx c9x
2389@itemx iso9899:1999
2390@itemx iso9899:199x
2391ISO C99. This standard is substantially completely supported, modulo
2392bugs and floating-point issues
2393(mainly but not entirely relating to optional C99 features from
2394Annexes F and G). See
2395@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2396names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2397
2398@item c11
2399@itemx c1x
2400@itemx iso9899:2011
2401ISO C11, the 2011 revision of the ISO C standard. This standard is
2402substantially completely supported, modulo bugs, floating-point issues
2403(mainly but not entirely relating to optional C11 features from
2404Annexes F and G) and the optional Annexes K (Bounds-checking
2405interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2406
2407@item c17
2408@itemx c18
2409@itemx iso9899:2017
2410@itemx iso9899:2018
2411ISO C17, the 2017 revision of the ISO C standard
2412(published in 2018). This standard is
2413same as C11 except for corrections of defects (all of which are also
2414applied with @option{-std=c11}) and a new value of
2415@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2416
2417@item c2x
2418The next version of the ISO C standard, still under development. The
2419support for this version is experimental and incomplete.
2420
2421@item gnu90
2422@itemx gnu89
2423GNU dialect of ISO C90 (including some C99 features).
2424
2425@item gnu99
2426@itemx gnu9x
2427GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2428
2429@item gnu11
2430@itemx gnu1x
2431GNU dialect of ISO C11.
2432The name @samp{gnu1x} is deprecated.
2433
2434@item gnu17
2435@itemx gnu18
2436GNU dialect of ISO C17. This is the default for C code.
2437
2438@item gnu2x
2439The next version of the ISO C standard, still under development, plus
2440GNU extensions. The support for this version is experimental and
2441incomplete.
2442
2443@item c++98
2444@itemx c++03
2445The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2446additional defect reports. Same as @option{-ansi} for C++ code.
2447
2448@item gnu++98
2449@itemx gnu++03
2450GNU dialect of @option{-std=c++98}.
2451
2452@item c++11
2453@itemx c++0x
2454The 2011 ISO C++ standard plus amendments.
2455The name @samp{c++0x} is deprecated.
2456
2457@item gnu++11
2458@itemx gnu++0x
2459GNU dialect of @option{-std=c++11}.
2460The name @samp{gnu++0x} is deprecated.
2461
2462@item c++14
2463@itemx c++1y
2464The 2014 ISO C++ standard plus amendments.
2465The name @samp{c++1y} is deprecated.
2466
2467@item gnu++14
2468@itemx gnu++1y
2469GNU dialect of @option{-std=c++14}.
2470The name @samp{gnu++1y} is deprecated.
2471
2472@item c++17
2473@itemx c++1z
2474The 2017 ISO C++ standard plus amendments.
2475The name @samp{c++1z} is deprecated.
2476
2477@item gnu++17
2478@itemx gnu++1z
2479GNU dialect of @option{-std=c++17}.
2480This is the default for C++ code.
2481The name @samp{gnu++1z} is deprecated.
2482
2483@item c++20
2484@itemx c++2a
2485The 2020 ISO C++ standard plus amendments.
2486Support is experimental, and could change in incompatible ways in
2487future releases.
2488The name @samp{c++2a} is deprecated.
2489
2490@item gnu++20
2491@itemx gnu++2a
2492GNU dialect of @option{-std=c++20}.
2493Support is experimental, and could change in incompatible ways in
2494future releases.
2495The name @samp{gnu++2a} is deprecated.
2496
2497@item c++2b
2498@itemx c++23
2499The next revision of the ISO C++ standard, planned for
25002023. Support is highly experimental, and will almost certainly
2501change in incompatible ways in future releases.
2502
2503@item gnu++2b
2504@itemx gnu++23
2505GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2506and will almost certainly change in incompatible ways in future
2507releases.
2508@end table
2509
d77de738 2510@opindex aux-info
ddf6fe37 2511@item -aux-info @var{filename}
d77de738
ML
2512Output to the given filename prototyped declarations for all functions
2513declared and/or defined in a translation unit, including those in header
2514files. This option is silently ignored in any language other than C@.
2515
2516Besides declarations, the file indicates, in comments, the origin of
2517each declaration (source file and line), whether the declaration was
2518implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2519@samp{O} for old, respectively, in the first character after the line
2520number and the colon), and whether it came from a declaration or a
2521definition (@samp{C} or @samp{F}, respectively, in the following
2522character). In the case of function definitions, a K&R-style list of
2523arguments followed by their declarations is also provided, inside
2524comments, after the declaration.
2525
d77de738
ML
2526@opindex fno-asm
2527@opindex fasm
ddf6fe37 2528@item -fno-asm
d77de738
ML
2529Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2530keyword, so that code can use these words as identifiers. You can use
2531the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2532instead. In C, @option{-ansi} implies @option{-fno-asm}.
2533
2534In C++, @code{inline} is a standard keyword and is not affected by
2535this switch. You may want to use the @option{-fno-gnu-keywords} flag
2536instead, which disables @code{typeof} but not @code{asm} and
2537@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2538this switch only affects the @code{asm} and @code{typeof} keywords,
2539since @code{inline} is a standard keyword in ISO C99. In C2X mode
2540(@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects
2541the @code{asm} keyword, since @code{typeof} is a standard keyword in
2542ISO C2X.
2543
d77de738
ML
2544@opindex fno-builtin
2545@opindex fbuiltin
f33d7a88 2546@cindex built-in functions
ddf6fe37
AA
2547@item -fno-builtin
2548@itemx -fno-builtin-@var{function}
d77de738
ML
2549Don't recognize built-in functions that do not begin with
2550@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2551functions provided by GCC}, for details of the functions affected,
2552including those which are not built-in functions when @option{-ansi} or
2553@option{-std} options for strict ISO C conformance are used because they
2554do not have an ISO standard meaning.
2555
2556GCC normally generates special code to handle certain built-in functions
2557more efficiently; for instance, calls to @code{alloca} may become single
2558instructions which adjust the stack directly, and calls to @code{memcpy}
2559may become inline copy loops. The resulting code is often both smaller
2560and faster, but since the function calls no longer appear as such, you
2561cannot set a breakpoint on those calls, nor can you change the behavior
2562of the functions by linking with a different library. In addition,
2563when a function is recognized as a built-in function, GCC may use
2564information about that function to warn about problems with calls to
2565that function, or to generate more efficient code, even if the
2566resulting code still contains calls to that function. For example,
2567warnings are given with @option{-Wformat} for bad calls to
2568@code{printf} when @code{printf} is built in and @code{strlen} is
2569known not to modify global memory.
2570
2571With the @option{-fno-builtin-@var{function}} option
2572only the built-in function @var{function} is
2573disabled. @var{function} must not begin with @samp{__builtin_}. If a
2574function is named that is not built-in in this version of GCC, this
2575option is ignored. There is no corresponding
2576@option{-fbuiltin-@var{function}} option; if you wish to enable
2577built-in functions selectively when using @option{-fno-builtin} or
2578@option{-ffreestanding}, you may define macros such as:
2579
2580@smallexample
2581#define abs(n) __builtin_abs ((n))
2582#define strcpy(d, s) __builtin_strcpy ((d), (s))
2583@end smallexample
2584
d77de738 2585@opindex fcond-mismatch
ddf6fe37 2586@item -fcond-mismatch
d77de738
ML
2587Allow conditional expressions with mismatched types in the second and
2588third arguments. The value of such an expression is void. This option
2589is not supported for C++.
2590
d77de738
ML
2591@opindex ffreestanding
2592@cindex hosted environment
f33d7a88 2593@item -ffreestanding
d77de738
ML
2594
2595Assert that compilation targets a freestanding environment. This
2596implies @option{-fno-builtin}. A freestanding environment
2597is one in which the standard library may not exist, and program startup may
2598not necessarily be at @code{main}. The most obvious example is an OS kernel.
2599This is equivalent to @option{-fno-hosted}.
2600
2601@xref{Standards,,Language Standards Supported by GCC}, for details of
2602freestanding and hosted environments.
2603
d77de738 2604@opindex fgimple
ddf6fe37 2605@item -fgimple
d77de738
ML
2606
2607Enable parsing of function definitions marked with @code{__GIMPLE}.
2608This is an experimental feature that allows unit testing of GIMPLE
2609passes.
2610
d77de738 2611@opindex fgnu-tm
ddf6fe37 2612@item -fgnu-tm
d77de738
ML
2613When the option @option{-fgnu-tm} is specified, the compiler
2614generates code for the Linux variant of Intel's current Transactional
2615Memory ABI specification document (Revision 1.1, May 6 2009). This is
2616an experimental feature whose interface may change in future versions
2617of GCC, as the official specification changes. Please note that not
2618all architectures are supported for this feature.
2619
2620For more information on GCC's support for transactional memory,
2621@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2622Transactional Memory Library}.
2623
2624Note that the transactional memory feature is not supported with
2625non-call exceptions (@option{-fnon-call-exceptions}).
2626
d77de738 2627@opindex fgnu89-inline
ddf6fe37 2628@item -fgnu89-inline
d77de738
ML
2629The option @option{-fgnu89-inline} tells GCC to use the traditional
2630GNU semantics for @code{inline} functions when in C99 mode.
2631@xref{Inline,,An Inline Function is As Fast As a Macro}.
2632Using this option is roughly equivalent to adding the
2633@code{gnu_inline} function attribute to all inline functions
2634(@pxref{Function Attributes}).
2635
2636The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2637C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2638specifies the default behavior).
2639This option is not supported in @option{-std=c90} or
2640@option{-std=gnu90} mode.
2641
2642The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2643@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2644in effect for @code{inline} functions. @xref{Common Predefined
2645Macros,,,cpp,The C Preprocessor}.
2646
d77de738
ML
2647@opindex fhosted
2648@cindex hosted environment
f33d7a88 2649@item -fhosted
d77de738
ML
2650
2651Assert that compilation targets a hosted environment. This implies
2652@option{-fbuiltin}. A hosted environment is one in which the
2653entire standard library is available, and in which @code{main} has a return
2654type of @code{int}. Examples are nearly everything except a kernel.
2655This is equivalent to @option{-fno-freestanding}.
2656
d77de738 2657@opindex flax-vector-conversions
ddf6fe37 2658@item -flax-vector-conversions
d77de738
ML
2659Allow implicit conversions between vectors with differing numbers of
2660elements and/or incompatible element types. This option should not be
2661used for new code.
2662
d77de738 2663@opindex fms-extensions
ddf6fe37 2664@item -fms-extensions
d77de738
ML
2665Accept some non-standard constructs used in Microsoft header files.
2666
2667In C++ code, this allows member names in structures to be similar
2668to previous types declarations.
2669
2670@smallexample
2671typedef int UOW;
2672struct ABC @{
2673 UOW UOW;
2674@};
2675@end smallexample
2676
2677Some cases of unnamed fields in structures and unions are only
2678accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2679fields within structs/unions}, for details.
2680
2681Note that this option is off for all targets except for x86
2682targets using ms-abi.
2683
ddf6fe37 2684@opindex foffload
d77de738
ML
2685@cindex Offloading targets
2686@cindex OpenACC offloading targets
2687@cindex OpenMP offloading targets
f33d7a88
AA
2688@item -foffload=disable
2689@itemx -foffload=default
2690@itemx -foffload=@var{target-list}
d77de738
ML
2691Specify for which OpenMP and OpenACC offload targets code should be generated.
2692The default behavior, equivalent to @option{-foffload=default}, is to generate
2693code for all supported offload targets. The @option{-foffload=disable} form
2694generates code only for the host fallback, while
2695@option{-foffload=@var{target-list}} generates code only for the specified
2696comma-separated list of offload targets.
2697
2698Offload targets are specified in GCC's internal target-triplet format. You can
2699run the compiler with @option{-v} to show the list of configured offload targets
2700under @code{OFFLOAD_TARGET_NAMES}.
2701
ddf6fe37 2702@opindex foffload-options
d77de738
ML
2703@cindex Offloading options
2704@cindex OpenACC offloading options
2705@cindex OpenMP offloading options
f33d7a88
AA
2706@item -foffload-options=@var{options}
2707@itemx -foffload-options=@var{target-triplet-list}=@var{options}
d77de738
ML
2708
2709With @option{-foffload-options=@var{options}}, GCC passes the specified
2710@var{options} to the compilers for all enabled offloading targets. You can
2711specify options that apply only to a specific target or targets by using
2712the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2713@var{target-list} is a comma-separated list in the same format as for the
2714@option{-foffload=} option.
2715
2716Typical command lines are
2717
2718@smallexample
2719-foffload-options=-lgfortran -foffload-options=-lm
2720-foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic
2721-foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm
2722@end smallexample
2723
d77de738
ML
2724@opindex fopenacc
2725@cindex OpenACC accelerator programming
f33d7a88 2726@item -fopenacc
d77de738
ML
2727Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and
2728@code{!$acc} in Fortran. When @option{-fopenacc} is specified, the
2729compiler generates accelerated code according to the OpenACC Application
2730Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2731implies @option{-pthread}, and thus is only supported on targets that
2732have support for @option{-pthread}.
2733
d77de738
ML
2734@opindex fopenacc-dim
2735@cindex OpenACC accelerator programming
f33d7a88 2736@item -fopenacc-dim=@var{geom}
d77de738
ML
2737Specify default compute dimensions for parallel offload regions that do
2738not explicitly specify. The @var{geom} value is a triple of
2739':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2740can be omitted, to use a target-specific default value.
2741
d77de738
ML
2742@opindex fopenmp
2743@cindex OpenMP parallel
f33d7a88 2744@item -fopenmp
d77de738
ML
2745Enable handling of OpenMP directives @code{#pragma omp} in C/C++,
2746@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and
2747@code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
2748compiler generates parallel code according to the OpenMP Application
2749Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2750implies @option{-pthread}, and thus is only supported on targets that
2751have support for @option{-pthread}. @option{-fopenmp} implies
2752@option{-fopenmp-simd}.
2753
d77de738
ML
2754@opindex fopenmp-simd
2755@cindex OpenMP SIMD
2756@cindex SIMD
f33d7a88 2757@item -fopenmp-simd
d77de738
ML
2758Enable handling of OpenMP's @code{simd}, @code{declare simd},
2759@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan},
2760@code{loop} directives and combined or composite directives with
2761@code{simd} as constituent with @code{#pragma omp} in C/C++,
2762@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++
2763and @code{!$omp} in Fortran. Other OpenMP directives are ignored.
2764
ddf6fe37 2765@opindex fopenmp-target-simd-clone
f33d7a88 2766@cindex OpenMP target SIMD clone
309e2d95
SL
2767@item -fopenmp-target-simd-clone
2768@item -fopenmp-target-simd-clone=@var{device-type}
309e2d95
SL
2769In addition to generating SIMD clones for functions marked with the
2770@code{declare simd} directive, GCC also generates clones
2771for functions marked with the OpenMP @code{declare target} directive
2772that are suitable for vectorization when this option is in effect. The
2773@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2774and @code{any}, which correspond to keywords for the @code{device_type}
2775clause of the @code{declare target} directive; clones are generated for
2776the intersection of devices specified.
2777@option{-fopenmp-target-simd-clone} is equivalent to
2778@option{-fopenmp-target-simd-clone=any} and
2779@option{-fno-openmp-target-simd-clone} is equivalent to
2780@option{-fopenmp-target-simd-clone=none}.
2781
2782At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2783optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2784it is disabled by default.
2785
d77de738
ML
2786@opindex fpermitted-flt-eval-methods
2787@opindex fpermitted-flt-eval-methods=c11
2788@opindex fpermitted-flt-eval-methods=ts-18661-3
ddf6fe37 2789@item -fpermitted-flt-eval-methods=@var{style}
d77de738
ML
2790ISO/IEC TS 18661-3 defines new permissible values for
2791@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2792a semantic type that is an interchange or extended format should be
2793evaluated to the precision and range of that type. These new values are
2794a superset of those permitted under C99/C11, which does not specify the
2795meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2796conforming to C11 may not have been written expecting the possibility of
2797the new values.
2798
2799@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2800should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2801or the extended set of values specified in ISO/IEC TS 18661-3.
2802
2803@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2804
2805The default when in a standards compliant mode (@option{-std=c11} or similar)
2806is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2807dialect (@option{-std=gnu11} or similar) is
2808@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2809
d77de738 2810@opindex fplan9-extensions
ddf6fe37 2811@item -fplan9-extensions
d77de738
ML
2812Accept some non-standard constructs used in Plan 9 code.
2813
2814This enables @option{-fms-extensions}, permits passing pointers to
2815structures with anonymous fields to functions that expect pointers to
2816elements of the type of the field, and permits referring to anonymous
2817fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2818struct/union fields within structs/unions}, for details. This is only
2819supported for C, not C++.
2820
d77de738
ML
2821@opindex fsigned-bitfields
2822@opindex funsigned-bitfields
2823@opindex fno-signed-bitfields
2824@opindex fno-unsigned-bitfields
ddf6fe37
AA
2825@item -fsigned-bitfields
2826@itemx -funsigned-bitfields
2827@itemx -fno-signed-bitfields
2828@itemx -fno-unsigned-bitfields
d77de738
ML
2829These options control whether a bit-field is signed or unsigned, when the
2830declaration does not use either @code{signed} or @code{unsigned}. By
2831default, such a bit-field is signed, because this is consistent: the
2832basic integer types such as @code{int} are signed types.
2833
d77de738 2834@opindex fsigned-char
ddf6fe37 2835@item -fsigned-char
d77de738
ML
2836Let the type @code{char} be signed, like @code{signed char}.
2837
2838Note that this is equivalent to @option{-fno-unsigned-char}, which is
2839the negative form of @option{-funsigned-char}. Likewise, the option
2840@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2841
d77de738 2842@opindex funsigned-char
ddf6fe37 2843@item -funsigned-char
d77de738
ML
2844Let the type @code{char} be unsigned, like @code{unsigned char}.
2845
2846Each kind of machine has a default for what @code{char} should
2847be. It is either like @code{unsigned char} by default or like
2848@code{signed char} by default.
2849
2850Ideally, a portable program should always use @code{signed char} or
2851@code{unsigned char} when it depends on the signedness of an object.
2852But many programs have been written to use plain @code{char} and
2853expect it to be signed, or expect it to be unsigned, depending on the
2854machines they were written for. This option, and its inverse, let you
2855make such a program work with the opposite default.
2856
2857The type @code{char} is always a distinct type from each of
2858@code{signed char} or @code{unsigned char}, even though its behavior
2859is always just like one of those two.
2860
d77de738
ML
2861@opindex fstrict-flex-arrays
2862@opindex fno-strict-flex-arrays
ddf6fe37 2863@item -fstrict-flex-arrays
d77de738
ML
2864Control when to treat the trailing array of a structure as a flexible array
2865member for the purpose of accessing the elements of such an array.
2866The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2867strictest. A trailing array is treated as a flexible array member only when it
2868is declared as a flexible array member per C99 standard onwards.
2869The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2870least strict. All trailing arrays of structures are treated as flexible array
2871members.
2872
d77de738 2873@opindex fstrict-flex-arrays=@var{level}
ddf6fe37 2874@item -fstrict-flex-arrays=@var{level}
d77de738
ML
2875Control when to treat the trailing array of a structure as a flexible array
2876member for the purpose of accessing the elements of such an array. The value
2877of @var{level} controls the level of strictness.
2878
2879The possible values of @var{level} are the same as for the
2880@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2881
2882You can control this behavior for a specific trailing array field of a
2883structure by using the variable attribute @code{strict_flex_array} attribute
2884(@pxref{Variable Attributes}).
2885
d77de738 2886@opindex fsso-struct
ddf6fe37 2887@item -fsso-struct=@var{endianness}
d77de738
ML
2888Set the default scalar storage order of structures and unions to the
2889specified endianness. The accepted values are @samp{big-endian},
2890@samp{little-endian} and @samp{native} for the native endianness of
2891the target (the default). This option is not supported for C++.
2892
2893@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2894code that is not binary compatible with code generated without it if the
2895specified endianness is not the native endianness of the target.
2896@end table
2897
2898@node C++ Dialect Options
2899@section Options Controlling C++ Dialect
2900
2901@cindex compiler options, C++
2902@cindex C++ options, command-line
2903@cindex options, C++
2904This section describes the command-line options that are only meaningful
2905for C++ programs. You can also use most of the GNU compiler options
2906regardless of what language your program is in. For example, you
2907might compile a file @file{firstClass.C} like this:
2908
2909@smallexample
2910g++ -g -fstrict-enums -O -c firstClass.C
2911@end smallexample
2912
2913@noindent
2914In this example, only @option{-fstrict-enums} is an option meant
2915only for C++ programs; you can use the other options with any
2916language supported by GCC@.
2917
2918Some options for compiling C programs, such as @option{-std}, are also
2919relevant for C++ programs.
2920@xref{C Dialect Options,,Options Controlling C Dialect}.
2921
2922Here is a list of options that are @emph{only} for compiling C++ programs:
2923
2924@table @gcctabopt
2925
d77de738 2926@opindex fabi-version
ddf6fe37 2927@item -fabi-version=@var{n}
d77de738
ML
2928Use version @var{n} of the C++ ABI@. The default is version 0.
2929
2930Version 0 refers to the version conforming most closely to
2931the C++ ABI specification. Therefore, the ABI obtained using version 0
2932will change in different versions of G++ as ABI bugs are fixed.
2933
2934Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2935
2936Version 2 is the version of the C++ ABI that first appeared in G++
29373.4, and was the default through G++ 4.9.
2938
2939Version 3 corrects an error in mangling a constant address as a
2940template argument.
2941
2942Version 4, which first appeared in G++ 4.5, implements a standard
2943mangling for vector types.
2944
2945Version 5, which first appeared in G++ 4.6, corrects the mangling of
2946attribute const/volatile on function pointer types, decltype of a
2947plain decl, and use of a function parameter in the declaration of
2948another parameter.
2949
2950Version 6, which first appeared in G++ 4.7, corrects the promotion
2951behavior of C++11 scoped enums and the mangling of template argument
2952packs, const/static_cast, prefix ++ and --, and a class scope function
2953used as a template argument.
2954
2955Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2956builtin type and corrects the mangling of lambdas in default argument
2957scope.
2958
2959Version 8, which first appeared in G++ 4.9, corrects the substitution
2960behavior of function types with function-cv-qualifiers.
2961
2962Version 9, which first appeared in G++ 5.2, corrects the alignment of
2963@code{nullptr_t}.
2964
2965Version 10, which first appeared in G++ 6.1, adds mangling of
2966attributes that affect type identity, such as ia32 calling convention
2967attributes (e.g.@: @samp{stdcall}).
2968
2969Version 11, which first appeared in G++ 7, corrects the mangling of
2970sizeof... expressions and operator names. For multiple entities with
2971the same name within a function, that are declared in different scopes,
2972the mangling now changes starting with the twelfth occurrence. It also
2973implies @option{-fnew-inheriting-ctors}.
2974
2975Version 12, which first appeared in G++ 8, corrects the calling
2976conventions for empty classes on the x86_64 target and for classes
2977with only deleted copy/move constructors. It accidentally changes the
2978calling convention for classes with a deleted copy constructor and a
2979trivial move constructor.
2980
2981Version 13, which first appeared in G++ 8.2, fixes the accidental
2982change in version 12.
2983
2984Version 14, which first appeared in G++ 10, corrects the mangling of
2985the nullptr expression.
2986
2987Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2988tag regression.
2989
2990Version 16, which first appeared in G++ 11, changes the mangling of
2991@code{__alignof__} to be distinct from that of @code{alignof}, and
2992dependent operator names.
2993
2994Version 17, which first appeared in G++ 12, fixes layout of classes
2995that inherit from aggregate classes with default member initializers
2996in C++14 and up.
2997
2998Version 18, which first appeard in G++ 13, fixes manglings of lambdas
2999that have additional context.
3000
3001See also @option{-Wabi}.
3002
d77de738 3003@opindex fabi-compat-version
ddf6fe37 3004@item -fabi-compat-version=@var{n}
d77de738
ML
3005On targets that support strong aliases, G++
3006works around mangling changes by creating an alias with the correct
3007mangled name when defining a symbol with an incorrect mangled name.
3008This switch specifies which ABI version to use for the alias.
3009
3010With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3011compatibility). If another ABI version is explicitly selected, this
3012defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3013use @option{-fabi-compat-version=2}.
3014
3015If this option is not provided but @option{-Wabi=@var{n}} is, that
3016version is used for compatibility aliases. If this option is provided
3017along with @option{-Wabi} (without the version), the version from this
3018option is used for the warning.
3019
d77de738
ML
3020@opindex fno-access-control
3021@opindex faccess-control
ddf6fe37 3022@item -fno-access-control
d77de738
ML
3023Turn off all access checking. This switch is mainly useful for working
3024around bugs in the access control code.
3025
d77de738 3026@opindex faligned-new
ddf6fe37 3027@item -faligned-new
d77de738
ML
3028Enable support for C++17 @code{new} of types that require more
3029alignment than @code{void* ::operator new(std::size_t)} provides. A
3030numeric argument such as @code{-faligned-new=32} can be used to
3031specify how much alignment (in bytes) is provided by that function,
3032but few users will need to override the default of
3033@code{alignof(std::max_align_t)}.
3034
3035This flag is enabled by default for @option{-std=c++17}.
3036
d77de738
ML
3037@opindex fchar8_t
3038@opindex fno-char8_t
ddf6fe37
AA
3039@item -fchar8_t
3040@itemx -fno-char8_t
d77de738
ML
3041Enable support for @code{char8_t} as adopted for C++20. This includes
3042the addition of a new @code{char8_t} fundamental type, changes to the
3043types of UTF-8 string and character literals, new signatures for
3044user-defined literals, associated standard library updates, and new
3045@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3046
3047This option enables functions to be overloaded for ordinary and UTF-8
3048strings:
3049
3050@smallexample
3051int f(const char *); // #1
3052int f(const char8_t *); // #2
3053int v1 = f("text"); // Calls #1
3054int v2 = f(u8"text"); // Calls #2
3055@end smallexample
3056
3057@noindent
3058and introduces new signatures for user-defined literals:
3059
3060@smallexample
3061int operator""_udl1(char8_t);
3062int v3 = u8'x'_udl1;
3063int operator""_udl2(const char8_t*, std::size_t);
3064int v4 = u8"text"_udl2;
3065template<typename T, T...> int operator""_udl3();
3066int v5 = u8"text"_udl3;
3067@end smallexample
3068
3069@noindent
3070The change to the types of UTF-8 string and character literals introduces
3071incompatibilities with ISO C++11 and later standards. For example, the
3072following code is well-formed under ISO C++11, but is ill-formed when
3073@option{-fchar8_t} is specified.
3074
3075@smallexample
d77de738
ML
3076const char *cp = u8"xx";// error: invalid conversion from
3077 // `const char8_t*' to `const char*'
3078int f(const char*);
3079auto v = f(u8"xx"); // error: invalid conversion from
3080 // `const char8_t*' to `const char*'
3081std::string s@{u8"xx"@}; // error: no matching function for call to
3082 // `std::basic_string<char>::basic_string()'
3083using namespace std::literals;
3084s = u8"xx"s; // error: conversion from
3085 // `basic_string<char8_t>' to non-scalar
3086 // type `basic_string<char>' requested
3087@end smallexample
3088
d77de738 3089@opindex fcheck-new
ddf6fe37 3090@item -fcheck-new
d77de738
ML
3091Check that the pointer returned by @code{operator new} is non-null
3092before attempting to modify the storage allocated. This check is
3093normally unnecessary because the C++ standard specifies that
3094@code{operator new} only returns @code{0} if it is declared
3095@code{throw()}, in which case the compiler always checks the
3096return value even without this option. In all other cases, when
3097@code{operator new} has a non-empty exception specification, memory
3098exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3099@samp{new (nothrow)}.
3100
d77de738
ML
3101@opindex fconcepts
3102@opindex fconcepts-ts
ddf6fe37
AA
3103@item -fconcepts
3104@itemx -fconcepts-ts
d77de738
ML
3105Enable support for the C++ Concepts feature for constraining template
3106arguments. With @option{-std=c++20} and above, Concepts are part of
3107the language standard, so @option{-fconcepts} defaults to on.
3108
3109Some constructs that were allowed by the earlier C++ Extensions for
3110Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3111into the standard, can additionally be enabled by
3112@option{-fconcepts-ts}.
3113
d77de738 3114@opindex fconstexpr-depth
ddf6fe37 3115@item -fconstexpr-depth=@var{n}
d77de738
ML
3116Set the maximum nested evaluation depth for C++11 constexpr functions
3117to @var{n}. A limit is needed to detect endless recursion during
3118constant expression evaluation. The minimum specified by the standard
3119is 512.
3120
d77de738 3121@opindex fconstexpr-cache-depth
ddf6fe37 3122@item -fconstexpr-cache-depth=@var{n}
d77de738
ML
3123Set the maximum level of nested evaluation depth for C++11 constexpr
3124functions that will be cached to @var{n}. This is a heuristic that
3125trades off compilation speed (when the cache avoids repeated
3126calculations) against memory consumption (when the cache grows very
3127large from highly recursive evaluations). The default is 8. Very few
3128users are likely to want to adjust it, but if your code does heavy
3129constexpr calculations you might want to experiment to find which
3130value works best for you.
3131
d77de738 3132@opindex fconstexpr-fp-except
ddf6fe37 3133@item -fconstexpr-fp-except
d77de738
ML
3134Annex F of the C standard specifies that IEC559 floating point
3135exceptions encountered at compile time should not stop compilation.
3136C++ compilers have historically not followed this guidance, instead
3137treating floating point division by zero as non-constant even though
3138it has a well defined value. This flag tells the compiler to give
3139Annex F priority over other rules saying that a particular operation
3140is undefined.
3141
3142@smallexample
3143constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3144@end smallexample
3145
d77de738 3146@opindex fconstexpr-loop-limit
ddf6fe37 3147@item -fconstexpr-loop-limit=@var{n}
d77de738
ML
3148Set the maximum number of iterations for a loop in C++14 constexpr functions
3149to @var{n}. A limit is needed to detect infinite loops during
3150constant expression evaluation. The default is 262144 (1<<18).
3151
d77de738 3152@opindex fconstexpr-ops-limit
ddf6fe37 3153@item -fconstexpr-ops-limit=@var{n}
d77de738
ML
3154Set the maximum number of operations during a single constexpr evaluation.
3155Even when number of iterations of a single loop is limited with the above limit,
3156if there are several nested loops and each of them has many iterations but still
3157smaller than the above limit, or if in a body of some loop or even outside
3158of a loop too many expressions need to be evaluated, the resulting constexpr
3159evaluation might take too long.
3160The default is 33554432 (1<<25).
3161
2efb237f 3162@opindex fcontracts
ddf6fe37 3163@item -fcontracts
2efb237f
JCI
3164Enable experimental support for the C++ Contracts feature, as briefly
3165added to and then removed from the C++20 working paper (N4820). The
3166implementation also includes proposed enhancements from papers P1290,
3167P1332, and P1429. This functionality is intended mostly for those
3168interested in experimentation towards refining the feature to get it
3169into shape for a future C++ standard.
3170
3171On violation of a checked contract, the violation handler is called.
3172Users can replace the violation handler by defining
3173@smallexample
4ace81b6
SL
3174void
3175handle_contract_violation (const std::experimental::contract_violation&);
2efb237f
JCI
3176@end smallexample
3177
3178There are different sets of additional flags that can be used together
3179to specify which contracts will be checked and how, for N4820
3180contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3181used together.
3182
3183@table @gcctabopt
2efb237f 3184@opindex fcontract-mode
ddf6fe37 3185@item -fcontract-mode=[on|off]
2efb237f
JCI
3186Control whether any contracts have any semantics at all. Defaults to on.
3187
2efb237f 3188@opindex fcontract-assumption-mode
ddf6fe37 3189@item -fcontract-assumption-mode=[on|off]
2efb237f
JCI
3190[N4820] Control whether contracts with level @samp{axiom}
3191should have the assume semantic. Defaults to on.
3192
2efb237f 3193@opindex fcontract-build-level
ddf6fe37 3194@item -fcontract-build-level=[off|default|audit]
2efb237f
JCI
3195[N4820] Specify which level of contracts to generate checks
3196for. Defaults to @samp{default}.
3197
2efb237f 3198@opindex fcontract-continuation-mode
ddf6fe37 3199@item -fcontract-continuation-mode=[on|off]
2efb237f
JCI
3200[N4820] Control whether to allow the program to continue executing
3201after a contract violation. That is, do checked contracts have the
3202@samp{maybe} semantic described below rather than the @samp{never}
3203semantic. Defaults to off.
3204
2efb237f 3205@opindex fcontract-role
ddf6fe37 3206@item -fcontract-role=<name>:<default>,<audit>,<axiom>
2efb237f
JCI
3207[P1332] Specify the concrete semantics for each contract level
3208of a particular contract role.
3209
3210@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3211[P1429] Specify the concrete semantic for a particular
3212contract level.
3213
2efb237f 3214@opindex fcontract-strict-declarations
ddf6fe37 3215@item -fcontract-strict-declarations=[on|off]
2efb237f
JCI
3216Control whether to reject adding contracts to a function after its
3217first declaration. Defaults to off.
3218@end table
3219
3220The possible concrete semantics for that can be specified with
3221@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3222
3223@table @code
3224@item ignore
3225This contract has no effect.
3226
3227@item assume
3228This contract is treated like C++23 @code{[[assume]]}.
3229
3230@item check_never_continue
3231@itemx never
3232@itemx abort
3233This contract is checked. If it fails, the violation handler is
3234called. If the handler returns, @code{std::terminate} is called.
3235
3236@item check_maybe_continue
3237@itemx maybe
3238This contract is checked. If it fails, the violation handler is
3239called. If the handler returns, execution continues normally.
3240@end table
3241
d77de738 3242@opindex fcoroutines
ddf6fe37 3243@item -fcoroutines
d77de738
ML
3244Enable support for the C++ coroutines extension (experimental).
3245
d77de738
ML
3246@opindex fno-elide-constructors
3247@opindex felide-constructors
ddf6fe37 3248@item -fno-elide-constructors
d77de738
ML
3249The C++ standard allows an implementation to omit creating a temporary
3250that is only used to initialize another object of the same type.
3251Specifying this option disables that optimization, and forces G++ to
3252call the copy constructor in all cases. This option also causes G++
3253to call trivial member functions which otherwise would be expanded inline.
3254
3255In C++17, the compiler is required to omit these temporaries, but this
3256option still affects trivial member functions.
3257
d77de738
ML
3258@opindex fno-enforce-eh-specs
3259@opindex fenforce-eh-specs
ddf6fe37 3260@item -fno-enforce-eh-specs
d77de738
ML
3261Don't generate code to check for violation of exception specifications
3262at run time. This option violates the C++ standard, but may be useful
3263for reducing code size in production builds, much like defining
3264@code{NDEBUG}. This does not give user code permission to throw
3265exceptions in violation of the exception specifications; the compiler
3266still optimizes based on the specifications, so throwing an
3267unexpected exception results in undefined behavior at run time.
3268
d77de738
ML
3269@opindex fextern-tls-init
3270@opindex fno-extern-tls-init
ddf6fe37
AA
3271@item -fextern-tls-init
3272@itemx -fno-extern-tls-init
d77de738
ML
3273The C++11 and OpenMP standards allow @code{thread_local} and
3274@code{threadprivate} variables to have dynamic (runtime)
3275initialization. To support this, any use of such a variable goes
3276through a wrapper function that performs any necessary initialization.
3277When the use and definition of the variable are in the same
3278translation unit, this overhead can be optimized away, but when the
3279use is in a different translation unit there is significant overhead
3280even if the variable doesn't actually need dynamic initialization. If
3281the programmer can be sure that no use of the variable in a
3282non-defining TU needs to trigger dynamic initialization (either
3283because the variable is statically initialized, or a use of the
3284variable in the defining TU will be executed before any uses in
3285another TU), they can avoid this overhead with the
3286@option{-fno-extern-tls-init} option.
3287
3288On targets that support symbol aliases, the default is
3289@option{-fextern-tls-init}. On targets that do not support symbol
3290aliases, the default is @option{-fno-extern-tls-init}.
3291
d77de738
ML
3292@opindex ffold-simple-inlines
3293@opindex fno-fold-simple-inlines
ddf6fe37
AA
3294@item -ffold-simple-inlines
3295@itemx -fno-fold-simple-inlines
d77de738
ML
3296Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3297@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3298means no debug information will be generated for such calls. Since these
3299functions are rarely interesting to debug, this flag is enabled by default
3300unless @option{-fno-inline} is active.
3301
d77de738
ML
3302@opindex fno-gnu-keywords
3303@opindex fgnu-keywords
ddf6fe37 3304@item -fno-gnu-keywords
d77de738
ML
3305Do not recognize @code{typeof} as a keyword, so that code can use this
3306word as an identifier. You can use the keyword @code{__typeof__} instead.
3307This option is implied by the strict ISO C++ dialects: @option{-ansi},
3308@option{-std=c++98}, @option{-std=c++11}, etc.
3309
d77de738 3310@opindex fimplicit-constexpr
ddf6fe37 3311@item -fimplicit-constexpr
d77de738
ML
3312Make inline functions implicitly constexpr, if they satisfy the
3313requirements for a constexpr function. This option can be used in
3314C++14 mode or later. This can result in initialization changing from
3315dynamic to static and other optimizations.
3316
d77de738
ML
3317@opindex fno-implicit-templates
3318@opindex fimplicit-templates
ddf6fe37 3319@item -fno-implicit-templates
d77de738
ML
3320Never emit code for non-inline templates that are instantiated
3321implicitly (i.e.@: by use); only emit code for explicit instantiations.
3322If you use this option, you must take care to structure your code to
3323include all the necessary explicit instantiations to avoid getting
3324undefined symbols at link time.
3325@xref{Template Instantiation}, for more information.
3326
d77de738
ML
3327@opindex fno-implicit-inline-templates
3328@opindex fimplicit-inline-templates
ddf6fe37 3329@item -fno-implicit-inline-templates
d77de738
ML
3330Don't emit code for implicit instantiations of inline templates, either.
3331The default is to handle inlines differently so that compiles with and
3332without optimization need the same set of explicit instantiations.
3333
d77de738
ML
3334@opindex fno-implement-inlines
3335@opindex fimplement-inlines
ddf6fe37 3336@item -fno-implement-inlines
d77de738
ML
3337To save space, do not emit out-of-line copies of inline functions
3338controlled by @code{#pragma implementation}. This causes linker
3339errors if these functions are not inlined everywhere they are called.
3340
d77de738
ML
3341@opindex fmodules-ts
3342@opindex fno-modules-ts
ddf6fe37
AA
3343@item -fmodules-ts
3344@itemx -fno-modules-ts
d77de738
ML
3345Enable support for C++20 modules (@pxref{C++ Modules}). The
3346@option{-fno-modules-ts} is usually not needed, as that is the
3347default. Even though this is a C++20 feature, it is not currently
3348implicitly enabled by selecting that standard version.
3349
ddf6fe37 3350@opindex fmodule-header
d77de738
ML
3351@item -fmodule-header
3352@itemx -fmodule-header=user
3353@itemx -fmodule-header=system
d77de738
ML
3354Compile a header file to create an importable header unit.
3355
d77de738 3356@opindex fmodule-implicit-inline
ddf6fe37 3357@item -fmodule-implicit-inline
d77de738
ML
3358Member functions defined in their class definitions are not implicitly
3359inline for modular code. This is different to traditional C++
3360behavior, for good reasons. However, it may result in a difficulty
3361during code porting. This option makes such function definitions
3362implicitly inline. It does however generate an ABI incompatibility,
3363so you must use it everywhere or nowhere. (Such definitions outside
3364of a named module remain implicitly inline, regardless.)
3365
d77de738
ML
3366@opindex fno-module-lazy
3367@opindex fmodule-lazy
ddf6fe37 3368@item -fno-module-lazy
d77de738
ML
3369Disable lazy module importing and module mapper creation.
3370
f33d7a88
AA
3371@vindex CXX_MODULE_MAPPER @r{environment variable}
3372@opindex fmodule-mapper
d77de738
ML
3373@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3374@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3375@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3376@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3377@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3378@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
d77de738
ML
3379An oracle to query for module name to filename mappings. If
3380unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3381and if that is unset, an in-process default is provided.
3382
d77de738 3383@opindex fmodule-only
ddf6fe37 3384@item -fmodule-only
d77de738
ML
3385Only emit the Compiled Module Interface, inhibiting any object file.
3386
d77de738 3387@opindex fms-extensions
ddf6fe37 3388@item -fms-extensions
d77de738
ML
3389Disable Wpedantic warnings about constructs used in MFC, such as implicit
3390int and getting a pointer to member function via non-standard syntax.
3391
d77de738 3392@opindex fnew-inheriting-ctors
ddf6fe37 3393@item -fnew-inheriting-ctors
d77de738
ML
3394Enable the P0136 adjustment to the semantics of C++11 constructor
3395inheritance. This is part of C++17 but also considered to be a Defect
3396Report against C++11 and C++14. This flag is enabled by default
3397unless @option{-fabi-version=10} or lower is specified.
3398
d77de738 3399@opindex fnew-ttp-matching
ddf6fe37 3400@item -fnew-ttp-matching
d77de738
ML
3401Enable the P0522 resolution to Core issue 150, template template
3402parameters and default arguments: this allows a template with default
3403template arguments as an argument for a template template parameter
3404with fewer template parameters. This flag is enabled by default for
3405@option{-std=c++17}.
3406
d77de738
ML
3407@opindex fno-nonansi-builtins
3408@opindex fnonansi-builtins
ddf6fe37 3409@item -fno-nonansi-builtins
d77de738
ML
3410Disable built-in declarations of functions that are not mandated by
3411ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3412@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3413
d77de738 3414@opindex fnothrow-opt
ddf6fe37 3415@item -fnothrow-opt
d77de738
ML
3416Treat a @code{throw()} exception specification as if it were a
3417@code{noexcept} specification to reduce or eliminate the text size
3418overhead relative to a function with no exception specification. If
3419the function has local variables of types with non-trivial
3420destructors, the exception specification actually makes the
3421function smaller because the EH cleanups for those variables can be
3422optimized away. The semantic effect is that an exception thrown out of
3423a function with such an exception specification results in a call
3424to @code{terminate} rather than @code{unexpected}.
3425
d77de738
ML
3426@opindex fno-operator-names
3427@opindex foperator-names
ddf6fe37 3428@item -fno-operator-names
d77de738
ML
3429Do not treat the operator name keywords @code{and}, @code{bitand},
3430@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3431synonyms as keywords.
3432
d77de738
ML
3433@opindex fno-optional-diags
3434@opindex foptional-diags
ddf6fe37 3435@item -fno-optional-diags
d77de738
ML
3436Disable diagnostics that the standard says a compiler does not need to
3437issue. Currently, the only such diagnostic issued by G++ is the one for
3438a name having multiple meanings within a class.
3439
d77de738 3440@opindex fpermissive
ddf6fe37 3441@item -fpermissive
d77de738
ML
3442Downgrade some diagnostics about nonconformant code from errors to
3443warnings. Thus, using @option{-fpermissive} allows some
3444nonconforming code to compile.
3445
d77de738
ML
3446@opindex fno-pretty-templates
3447@opindex fpretty-templates
ddf6fe37 3448@item -fno-pretty-templates
d77de738
ML
3449When an error message refers to a specialization of a function
3450template, the compiler normally prints the signature of the
3451template followed by the template arguments and any typedefs or
3452typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3453rather than @code{void f(int)}) so that it's clear which template is
3454involved. When an error message refers to a specialization of a class
3455template, the compiler omits any template arguments that match
3456the default template arguments for that template. If either of these
3457behaviors make it harder to understand the error message rather than
3458easier, you can use @option{-fno-pretty-templates} to disable them.
3459
d77de738
ML
3460@opindex fno-rtti
3461@opindex frtti
ddf6fe37 3462@item -fno-rtti
d77de738
ML
3463Disable generation of information about every class with virtual
3464functions for use by the C++ run-time type identification features
3465(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3466of the language, you can save some space by using this flag. Note that
3467exception handling uses the same information, but G++ generates it as
3468needed. The @code{dynamic_cast} operator can still be used for casts that
3469do not require run-time type information, i.e.@: casts to @code{void *} or to
3470unambiguous base classes.
3471
3472Mixing code compiled with @option{-frtti} with that compiled with
3473@option{-fno-rtti} may not work. For example, programs may
3474fail to link if a class compiled with @option{-fno-rtti} is used as a base
3475for a class compiled with @option{-frtti}.
3476
d77de738 3477@opindex fsized-deallocation
ddf6fe37 3478@item -fsized-deallocation
d77de738
ML
3479Enable the built-in global declarations
3480@smallexample
3481void operator delete (void *, std::size_t) noexcept;
3482void operator delete[] (void *, std::size_t) noexcept;
3483@end smallexample
3484as introduced in C++14. This is useful for user-defined replacement
3485deallocation functions that, for example, use the size of the object
3486to make deallocation faster. Enabled by default under
3487@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3488warns about places that might want to add a definition.
3489
d77de738 3490@opindex fstrict-enums
ddf6fe37 3491@item -fstrict-enums
d77de738
ML
3492Allow the compiler to optimize using the assumption that a value of
3493enumerated type can only be one of the values of the enumeration (as
3494defined in the C++ standard; basically, a value that can be
3495represented in the minimum number of bits needed to represent all the
3496enumerators). This assumption may not be valid if the program uses a
3497cast to convert an arbitrary integer value to the enumerated type.
d8a656d5
JW
3498This option has no effect for an enumeration type with a fixed underlying
3499type.
d77de738 3500
d77de738 3501@opindex fstrong-eval-order
ddf6fe37 3502@item -fstrong-eval-order
d77de738
ML
3503Evaluate member access, array subscripting, and shift expressions in
3504left-to-right order, and evaluate assignment in right-to-left order,
3505as adopted for C++17. Enabled by default with @option{-std=c++17}.
3506@option{-fstrong-eval-order=some} enables just the ordering of member
3507access and shift expressions, and is the default without
3508@option{-std=c++17}.
3509
d77de738 3510@opindex ftemplate-backtrace-limit
ddf6fe37 3511@item -ftemplate-backtrace-limit=@var{n}
d77de738
ML
3512Set the maximum number of template instantiation notes for a single
3513warning or error to @var{n}. The default value is 10.
3514
d77de738 3515@opindex ftemplate-depth
ddf6fe37 3516@item -ftemplate-depth=@var{n}
d77de738
ML
3517Set the maximum instantiation depth for template classes to @var{n}.
3518A limit on the template instantiation depth is needed to detect
3519endless recursions during template class instantiation. ANSI/ISO C++
3520conforming programs must not rely on a maximum depth greater than 17
3521(changed to 1024 in C++11). The default value is 900, as the compiler
3522can run out of stack space before hitting 1024 in some situations.
3523
d77de738
ML
3524@opindex fno-threadsafe-statics
3525@opindex fthreadsafe-statics
ddf6fe37 3526@item -fno-threadsafe-statics
d77de738
ML
3527Do not emit the extra code to use the routines specified in the C++
3528ABI for thread-safe initialization of local statics. You can use this
3529option to reduce code size slightly in code that doesn't need to be
3530thread-safe.
3531
d77de738 3532@opindex fuse-cxa-atexit
ddf6fe37 3533@item -fuse-cxa-atexit
d77de738
ML
3534Register destructors for objects with static storage duration with the
3535@code{__cxa_atexit} function rather than the @code{atexit} function.
3536This option is required for fully standards-compliant handling of static
3537destructors, but only works if your C library supports
3538@code{__cxa_atexit}.
3539
d77de738
ML
3540@opindex fno-use-cxa-get-exception-ptr
3541@opindex fuse-cxa-get-exception-ptr
ddf6fe37 3542@item -fno-use-cxa-get-exception-ptr
d77de738
ML
3543Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3544causes @code{std::uncaught_exception} to be incorrect, but is necessary
3545if the runtime routine is not available.
3546
d77de738 3547@opindex fvisibility-inlines-hidden
ddf6fe37 3548@item -fvisibility-inlines-hidden
d77de738
ML
3549This switch declares that the user does not attempt to compare
3550pointers to inline functions or methods where the addresses of the two functions
3551are taken in different shared objects.
3552
3553The effect of this is that GCC may, effectively, mark inline methods with
3554@code{__attribute__ ((visibility ("hidden")))} so that they do not
3555appear in the export table of a DSO and do not require a PLT indirection
3556when used within the DSO@. Enabling this option can have a dramatic effect
3557on load and link times of a DSO as it massively reduces the size of the
3558dynamic export table when the library makes heavy use of templates.
3559
3560The behavior of this switch is not quite the same as marking the
3561methods as hidden directly, because it does not affect static variables
3562local to the function or cause the compiler to deduce that
3563the function is defined in only one shared object.
3564
3565You may mark a method as having a visibility explicitly to negate the
3566effect of the switch for that method. For example, if you do want to
3567compare pointers to a particular inline method, you might mark it as
3568having default visibility. Marking the enclosing class with explicit
3569visibility has no effect.
3570
3571Explicitly instantiated inline methods are unaffected by this option
3572as their linkage might otherwise cross a shared library boundary.
3573@xref{Template Instantiation}.
3574
d77de738 3575@opindex fvisibility-ms-compat
ddf6fe37 3576@item -fvisibility-ms-compat
d77de738
ML
3577This flag attempts to use visibility settings to make GCC's C++
3578linkage model compatible with that of Microsoft Visual Studio.
3579
3580The flag makes these changes to GCC's linkage model:
3581
3582@enumerate
3583@item
3584It sets the default visibility to @code{hidden}, like
3585@option{-fvisibility=hidden}.
3586
3587@item
3588Types, but not their members, are not hidden by default.
3589
3590@item
3591The One Definition Rule is relaxed for types without explicit
3592visibility specifications that are defined in more than one
3593shared object: those declarations are permitted if they are
3594permitted when this option is not used.
3595@end enumerate
3596
3597In new code it is better to use @option{-fvisibility=hidden} and
3598export those classes that are intended to be externally visible.
3599Unfortunately it is possible for code to rely, perhaps accidentally,
3600on the Visual Studio behavior.
3601
3602Among the consequences of these changes are that static data members
3603of the same type with the same name but defined in different shared
3604objects are different, so changing one does not change the other;
3605and that pointers to function members defined in different shared
3606objects may not compare equal. When this flag is given, it is a
3607violation of the ODR to define types with the same name differently.
3608
d77de738
ML
3609@opindex fno-weak
3610@opindex fweak
ddf6fe37 3611@item -fno-weak
d77de738
ML
3612Do not use weak symbol support, even if it is provided by the linker.
3613By default, G++ uses weak symbols if they are available. This
3614option exists only for testing, and should not be used by end-users;
3615it results in inferior code and has no benefits. This option may
3616be removed in a future release of G++.
3617
d77de738
ML
3618@opindex fext-numeric-literals
3619@opindex fno-ext-numeric-literals
ddf6fe37 3620@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
d77de738
ML
3621Accept imaginary, fixed-point, or machine-defined
3622literal number suffixes as GNU extensions.
3623When this option is turned off these suffixes are treated
3624as C++11 user-defined literal numeric suffixes.
3625This is on by default for all pre-C++11 dialects and all GNU dialects:
3626@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3627@option{-std=gnu++14}.
3628This option is off by default
3629for ISO C++11 onwards (@option{-std=c++11}, ...).
3630
d77de738 3631@opindex nostdinc++
ddf6fe37 3632@item -nostdinc++
d77de738
ML
3633Do not search for header files in the standard directories specific to
3634C++, but do still search the other standard directories. (This option
3635is used when building the C++ library.)
3636
ddf6fe37
AA
3637@opindex flang-info-include-translate
3638@opindex flang-info-include-translate-not
d77de738
ML
3639@item -flang-info-include-translate
3640@itemx -flang-info-include-translate-not
3641@itemx -flang-info-include-translate=@var{header}
d77de738
ML
3642Inform of include translation events. The first will note accepted
3643include translations, the second will note declined include
3644translations. The @var{header} form will inform of include
3645translations relating to that specific header. If @var{header} is of
3646the form @code{"user"} or @code{<system>} it will be resolved to a
3647specific user or system header using the include path.
3648
ddf6fe37 3649@opindex flang-info-module-cmi
d77de738
ML
3650@item -flang-info-module-cmi
3651@itemx -flang-info-module-cmi=@var{module}
d77de738
ML
3652Inform of Compiled Module Interface pathnames. The first will note
3653all read CMI pathnames. The @var{module} form will not reading a
3654specific module's CMI. @var{module} may be a named module or a
3655header-unit (the latter indicated by either being a pathname containing
3656directory separators or enclosed in @code{<>} or @code{""}).
3657
d77de738 3658@opindex stdlib
ddf6fe37 3659@item -stdlib=@var{libstdc++,libc++}
d77de738
ML
3660When G++ is configured to support this option, it allows specification of
3661alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3662(the default, native C++ runtime for G++) and @var{libc++} which is the
3663C++ runtime installed on some operating systems (e.g. Darwin versions from
3664Darwin11 onwards). The option switches G++ to use the headers from the
3665specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3666when a C++ runtime is required for linking.
3667@end table
3668
3669In addition, these warning options have meanings only for C++ programs:
3670
3671@table @gcctabopt
d77de738 3672@opindex Wabi-tag
ddf6fe37 3673@item -Wabi-tag @r{(C++ and Objective-C++ only)}
d77de738
ML
3674Warn when a type with an ABI tag is used in a context that does not
3675have that ABI tag. See @ref{C++ Attributes} for more information
3676about ABI tags.
3677
d77de738
ML
3678@opindex Wcomma-subscript
3679@opindex Wno-comma-subscript
ddf6fe37 3680@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
d77de738
ML
3681Warn about uses of a comma expression within a subscripting expression.
3682This usage was deprecated in C++20 and is going to be removed in C++23.
3683However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3684
3685@smallexample
3686@group
3687void f(int *a, int b, int c) @{
3688 a[b,c]; // deprecated in C++20, invalid in C++23
3689 a[(b,c)]; // OK
3690@}
3691@end group
3692@end smallexample
3693
3694In C++23 it is valid to have comma separated expressions in a subscript
3695when an overloaded subscript operator is found and supports the right
3696number and types of arguments. G++ will accept the formerly valid syntax
3697for code that is not valid in C++23 but used to be valid but deprecated
3698in C++20 with a pedantic warning that can be disabled with
3699@option{-Wno-comma-subscript}.
3700
3701Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3702and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3703
5fccebdb
JM
3704This warning is upgraded to an error by @option{-pedantic-errors} in
3705C++23 mode or later.
3706
d77de738
ML
3707@opindex Wctad-maybe-unsupported
3708@opindex Wno-ctad-maybe-unsupported
ddf6fe37 3709@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
d77de738
ML
3710Warn when performing class template argument deduction (CTAD) on a type with
3711no explicitly written deduction guides. This warning will point out cases
3712where CTAD succeeded only because the compiler synthesized the implicit
3713deduction guides, which might not be what the programmer intended. Certain
3714style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3715types that are designed to support CTAD. This warning can be suppressed with
3716the following pattern:
3717
3718@smallexample
3719struct allow_ctad_t; // any name works
3720template <typename T> struct S @{
3721 S(T) @{ @}
3722@};
4ace81b6
SL
3723// Guide with incomplete parameter type will never be considered.
3724S(allow_ctad_t) -> S<void>;
d77de738
ML
3725@end smallexample
3726
d77de738
ML
3727@opindex Wctor-dtor-privacy
3728@opindex Wno-ctor-dtor-privacy
ddf6fe37 3729@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
d77de738
ML
3730Warn when a class seems unusable because all the constructors or
3731destructors in that class are private, and it has neither friends nor
3732public static member functions. Also warn if there are no non-private
3733methods, and there's at least one private member function that isn't
3734a constructor or destructor.
3735
d77de738
ML
3736@opindex Wdangling-reference
3737@opindex Wno-dangling-reference
ddf6fe37 3738@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
d77de738
ML
3739Warn when a reference is bound to a temporary whose lifetime has ended.
3740For example:
3741
3742@smallexample
3743int n = 1;
3744const int& r = std::max(n - 1, n + 1); // r is dangling
3745@end smallexample
3746
3747In the example above, two temporaries are created, one for each
3748argument, and a reference to one of the temporaries is returned.
3749However, both temporaries are destroyed at the end of the full
3750expression, so the reference @code{r} is dangling. This warning
3751also detects dangling references in member initializer lists:
3752
3753@smallexample
3754const int& f(const int& i) @{ return i; @}
3755struct S @{
3756 const int &r; // r is dangling
3757 S() : r(f(10)) @{ @}
3758@};
3759@end smallexample
3760
3761Member functions are checked as well, but only their object argument:
3762
3763@smallexample
3764struct S @{
3765 const S& self () @{ return *this; @}
3766@};
3767const S& s = S().self(); // s is dangling
3768@end smallexample
3769
3770Certain functions are safe in this respect, for example @code{std::use_facet}:
3771they take and return a reference, but they don't return one of its arguments,
3772which can fool the warning. Such functions can be excluded from the warning
3773by wrapping them in a @code{#pragma}:
3774
3775@smallexample
3776#pragma GCC diagnostic push
3777#pragma GCC diagnostic ignored "-Wdangling-reference"
3778const T& foo (const T&) @{ @dots{} @}
3779#pragma GCC diagnostic pop
3780@end smallexample
3781
ce51e843
ML
3782@option{-Wdangling-reference} also warns about code like
3783
3784@smallexample
3785auto p = std::minmax(1, 2);
3786@end smallexample
3787
3788where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3789both references dangle after the end of the full expression that contains
3790the call to @code{std::minmax}.
3791
d77de738
ML
3792This warning is enabled by @option{-Wall}.
3793
d77de738
ML
3794@opindex Wdelete-non-virtual-dtor
3795@opindex Wno-delete-non-virtual-dtor
ddf6fe37 3796@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
3797Warn when @code{delete} is used to destroy an instance of a class that
3798has virtual functions and non-virtual destructor. It is unsafe to delete
3799an instance of a derived class through a pointer to a base class if the
3800base class does not have a virtual destructor. This warning is enabled
3801by @option{-Wall}.
3802
d77de738
ML
3803@opindex Wdeprecated-copy
3804@opindex Wno-deprecated-copy
ddf6fe37 3805@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
d77de738
ML
3806Warn that the implicit declaration of a copy constructor or copy
3807assignment operator is deprecated if the class has a user-provided
3808copy constructor or copy assignment operator, in C++11 and up. This
3809warning is enabled by @option{-Wextra}. With
3810@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3811user-provided destructor.
3812
d77de738
ML
3813@opindex Wdeprecated-enum-enum-conversion
3814@opindex Wno-deprecated-enum-enum-conversion
ddf6fe37 3815@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3816Disable the warning about the case when the usual arithmetic conversions
3817are applied on operands where one is of enumeration type and the other is
3818of a different enumeration type. This conversion was deprecated in C++20.
3819For example:
3820
3821@smallexample
3822enum E1 @{ e @};
3823enum E2 @{ f @};
3824int k = f - e;
3825@end smallexample
3826
3827@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3828@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3829by @option{-Wenum-conversion}.
3830
d77de738
ML
3831@opindex Wdeprecated-enum-float-conversion
3832@opindex Wno-deprecated-enum-float-conversion
ddf6fe37 3833@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3834Disable the warning about the case when the usual arithmetic conversions
3835are applied on operands where one is of enumeration type and the other is
3836of a floating-point type. This conversion was deprecated in C++20. For
3837example:
3838
3839@smallexample
3840enum E1 @{ e @};
3841enum E2 @{ f @};
3842bool b = e <= 3.7;
3843@end smallexample
3844
3845@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3846@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3847by @option{-Wenum-conversion}.
3848
d77de738
ML
3849@opindex Winit-list-lifetime
3850@opindex Wno-init-list-lifetime
ddf6fe37 3851@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
d77de738
ML
3852Do not warn about uses of @code{std::initializer_list} that are likely
3853to result in dangling pointers. Since the underlying array for an
3854@code{initializer_list} is handled like a normal C++ temporary object,
3855it is easy to inadvertently keep a pointer to the array past the end
3856of the array's lifetime. For example:
3857
3858@itemize @bullet
3859@item
3860If a function returns a temporary @code{initializer_list}, or a local
3861@code{initializer_list} variable, the array's lifetime ends at the end
3862of the return statement, so the value returned has a dangling pointer.
3863
3864@item
3865If a new-expression creates an @code{initializer_list}, the array only
3866lives until the end of the enclosing full-expression, so the
3867@code{initializer_list} in the heap has a dangling pointer.
3868
3869@item
3870When an @code{initializer_list} variable is assigned from a
3871brace-enclosed initializer list, the temporary array created for the
3872right side of the assignment only lives until the end of the
3873full-expression, so at the next statement the @code{initializer_list}
3874variable has a dangling pointer.
3875
3876@smallexample
3877// li's initial underlying array lives as long as li
3878std::initializer_list<int> li = @{ 1,2,3 @};
3879// assignment changes li to point to a temporary array
3880li = @{ 4, 5 @};
3881// now the temporary is gone and li has a dangling pointer
3882int i = li.begin()[0] // undefined behavior
3883@end smallexample
3884
3885@item
3886When a list constructor stores the @code{begin} pointer from the
3887@code{initializer_list} argument, this doesn't extend the lifetime of
3888the array, so if a class variable is constructed from a temporary
3889@code{initializer_list}, the pointer is left dangling by the end of
3890the variable declaration statement.
3891
3892@end itemize
3893
c85f8dbb
MP
3894@opindex Winvalid-constexpr
3895@opindex Wno-invalid-constexpr
ddf6fe37 3896@item -Winvalid-constexpr
c85f8dbb
MP
3897
3898Warn when a function never produces a constant expression. In C++20
3899and earlier, for every @code{constexpr} function and function template,
3900there must be at least one set of function arguments in at least one
3901instantiation such that an invocation of the function or constructor
3902could be an evaluated subexpression of a core constant expression.
3903C++23 removed this restriction, so it's possible to have a function
3904or a function template marked @code{constexpr} for which no invocation
3905satisfies the requirements of a core constant expression.
3906
3907This warning is enabled as a pedantic warning by default in C++20 and
3908earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3909which case it will be an ordinary warning. For example:
3910
3911@smallexample
3912void f (int& i);
3913constexpr void
3914g (int& i)
3915@{
4ace81b6
SL
3916 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
3917 f(i);
c85f8dbb
MP
3918@}
3919@end smallexample
3920
d77de738
ML
3921@opindex Winvalid-imported-macros
3922@opindex Wno-invalid-imported-macros
ddf6fe37 3923@item -Winvalid-imported-macros
d77de738
ML
3924Verify all imported macro definitions are valid at the end of
3925compilation. This is not enabled by default, as it requires
3926additional processing to determine. It may be useful when preparing
3927sets of header-units to ensure consistent macros.
3928
d77de738
ML
3929@opindex Wliteral-suffix
3930@opindex Wno-literal-suffix
ddf6fe37 3931@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
d77de738
ML
3932Do not warn when a string or character literal is followed by a
3933ud-suffix which does not begin with an underscore. As a conforming
3934extension, GCC treats such suffixes as separate preprocessing tokens
3935in order to maintain backwards compatibility with code that uses
3936formatting macros from @code{<inttypes.h>}. For example:
3937
3938@smallexample
3939#define __STDC_FORMAT_MACROS
3940#include <inttypes.h>
3941#include <stdio.h>
3942
3943int main() @{
3944 int64_t i64 = 123;
3945 printf("My int64: %" PRId64"\n", i64);
3946@}
3947@end smallexample
3948
3949In this case, @code{PRId64} is treated as a separate preprocessing token.
3950
3951This option also controls warnings when a user-defined literal
3952operator is declared with a literal suffix identifier that doesn't
3953begin with an underscore. Literal suffix identifiers that don't begin
3954with an underscore are reserved for future standardization.
3955
3956These warnings are enabled by default.
3957
d77de738
ML
3958@opindex Wnarrowing
3959@opindex Wno-narrowing
ddf6fe37 3960@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
d77de738
ML
3961For C++11 and later standards, narrowing conversions are diagnosed by default,
3962as required by the standard. A narrowing conversion from a constant produces
3963an error, and a narrowing conversion from a non-constant produces a warning,
3964but @option{-Wno-narrowing} suppresses the diagnostic.
3965Note that this does not affect the meaning of well-formed code;
3966narrowing conversions are still considered ill-formed in SFINAE contexts.
3967
3968With @option{-Wnarrowing} in C++98, warn when a narrowing
3969conversion prohibited by C++11 occurs within
3970@samp{@{ @}}, e.g.
3971
3972@smallexample
3973int i = @{ 2.2 @}; // error: narrowing from double to int
3974@end smallexample
3975
3976This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3977
d77de738
ML
3978@opindex Wnoexcept
3979@opindex Wno-noexcept
ddf6fe37 3980@item -Wnoexcept @r{(C++ and Objective-C++ only)}
d77de738
ML
3981Warn when a noexcept-expression evaluates to false because of a call
3982to a function that does not have a non-throwing exception
3983specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3984the compiler to never throw an exception.
3985
d77de738
ML
3986@opindex Wnoexcept-type
3987@opindex Wno-noexcept-type
ddf6fe37 3988@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
d77de738
ML
3989Warn if the C++17 feature making @code{noexcept} part of a function
3990type changes the mangled name of a symbol relative to C++14. Enabled
3991by @option{-Wabi} and @option{-Wc++17-compat}.
3992
3993As an example:
3994
3995@smallexample
3996template <class T> void f(T t) @{ t(); @};
3997void g() noexcept;
3998void h() @{ f(g); @}
3999@end smallexample
4000
4001@noindent
4002In C++14, @code{f} calls @code{f<void(*)()>}, but in
4003C++17 it calls @code{f<void(*)()noexcept>}.
4004
d77de738
ML
4005@opindex Wclass-memaccess
4006@opindex Wno-class-memaccess
ddf6fe37 4007@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
d77de738
ML
4008Warn when the destination of a call to a raw memory function such as
4009@code{memset} or @code{memcpy} is an object of class type, and when writing
4010into such an object might bypass the class non-trivial or deleted constructor
4011or copy assignment, violate const-correctness or encapsulation, or corrupt
4012virtual table pointers. Modifying the representation of such objects may
4013violate invariants maintained by member functions of the class. For example,
4014the call to @code{memset} below is undefined because it modifies a non-trivial
4015class object and is, therefore, diagnosed. The safe way to either initialize
4016or clear the storage of objects of such types is by using the appropriate
4017constructor or assignment operator, if one is available.
4018@smallexample
4019std::string str = "abc";
4020memset (&str, 0, sizeof str);
4021@end smallexample
4022The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4023Explicitly casting the pointer to the class object to @code{void *} or
4024to a type that can be safely accessed by the raw memory function suppresses
4025the warning.
4026
d77de738
ML
4027@opindex Wnon-virtual-dtor
4028@opindex Wno-non-virtual-dtor
ddf6fe37 4029@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
4030Warn when a class has virtual functions and an accessible non-virtual
4031destructor itself or in an accessible polymorphic base class, in which
4032case it is possible but unsafe to delete an instance of a derived
4033class through a pointer to the class itself or base class. This
4034warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4035The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4036should be preferred because it warns about the unsafe cases without false
4037positives.
d77de738 4038
d77de738
ML
4039@opindex Wregister
4040@opindex Wno-register
ddf6fe37 4041@item -Wregister @r{(C++ and Objective-C++ only)}
d77de738
ML
4042Warn on uses of the @code{register} storage class specifier, except
4043when it is part of the GNU @ref{Explicit Register Variables} extension.
4044The use of the @code{register} keyword as storage class specifier has
4045been deprecated in C++11 and removed in C++17.
4046Enabled by default with @option{-std=c++17}.
4047
d77de738
ML
4048@opindex Wreorder
4049@opindex Wno-reorder
4050@cindex reordering, warning
4051@cindex warning for reordering of member initializers
f33d7a88 4052@item -Wreorder @r{(C++ and Objective-C++ only)}
d77de738
ML
4053Warn when the order of member initializers given in the code does not
4054match the order in which they must be executed. For instance:
4055
4056@smallexample
4057struct A @{
4058 int i;
4059 int j;
4060 A(): j (0), i (1) @{ @}
4061@};
4062@end smallexample
4063
4064@noindent
4065The compiler rearranges the member initializers for @code{i}
4066and @code{j} to match the declaration order of the members, emitting
4067a warning to that effect. This warning is enabled by @option{-Wall}.
4068
d77de738
ML
4069@opindex Wpessimizing-move
4070@opindex Wno-pessimizing-move
ddf6fe37 4071@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4072This warning warns when a call to @code{std::move} prevents copy
4073elision. A typical scenario when copy elision can occur is when returning in
4074a function with a class return type, when the expression being returned is the
4075name of a non-volatile automatic object, and is not a function parameter, and
4076has the same type as the function return type.
4077
4078@smallexample
4079struct T @{
4080@dots{}
4081@};
4082T fn()
4083@{
4084 T t;
4085 @dots{}
4086 return std::move (t);
4087@}
4088@end smallexample
4089
4090But in this example, the @code{std::move} call prevents copy elision.
4091
4092This warning is enabled by @option{-Wall}.
4093
d77de738
ML
4094@opindex Wredundant-move
4095@opindex Wno-redundant-move
ddf6fe37 4096@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4097This warning warns about redundant calls to @code{std::move}; that is, when
4098a move operation would have been performed even without the @code{std::move}
4099call. This happens because the compiler is forced to treat the object as if
4100it were an rvalue in certain situations such as returning a local variable,
4101where copy elision isn't applicable. Consider:
4102
4103@smallexample
4104struct T @{
4105@dots{}
4106@};
4107T fn(T t)
4108@{
4109 @dots{}
4110 return std::move (t);
4111@}
4112@end smallexample
4113
4114Here, the @code{std::move} call is redundant. Because G++ implements Core
4115Issue 1579, another example is:
4116
4117@smallexample
4118struct T @{ // convertible to U
4119@dots{}
4120@};
4121struct U @{
4122@dots{}
4123@};
4124U fn()
4125@{
4126 T t;
4127 @dots{}
4128 return std::move (t);
4129@}
4130@end smallexample
4131In this example, copy elision isn't applicable because the type of the
4132expression being returned and the function return type differ, yet G++
4133treats the return value as if it were designated by an rvalue.
4134
4135This warning is enabled by @option{-Wextra}.
4136
d77de738
ML
4137@opindex Wrange-loop-construct
4138@opindex Wno-range-loop-construct
ddf6fe37 4139@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
d77de738
ML
4140This warning warns when a C++ range-based for-loop is creating an unnecessary
4141copy. This can happen when the range declaration is not a reference, but
4142probably should be. For example:
4143
4144@smallexample
4145struct S @{ char arr[128]; @};
4146void fn () @{
4147 S arr[5];
4148 for (const auto x : arr) @{ @dots{} @}
4149@}
4150@end smallexample
4151
4152It does not warn when the type being copied is a trivially-copyable type whose
4153size is less than 64 bytes.
4154
4155This warning also warns when a loop variable in a range-based for-loop is
4156initialized with a value of a different type resulting in a copy. For example:
4157
4158@smallexample
4159void fn() @{
4160 int arr[10];
4161 for (const double &x : arr) @{ @dots{} @}
4162@}
4163@end smallexample
4164
4165In the example above, in every iteration of the loop a temporary value of
4166type @code{double} is created and destroyed, to which the reference
4167@code{const double &} is bound.
4168
4169This warning is enabled by @option{-Wall}.
4170
d77de738
ML
4171@opindex Wredundant-tags
4172@opindex Wno-redundant-tags
ddf6fe37 4173@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4174Warn about redundant class-key and enum-key in references to class types
4175and enumerated types in contexts where the key can be eliminated without
4176causing an ambiguity. For example:
4177
4178@smallexample
4179struct foo;
4180struct foo *p; // warn that keyword struct can be eliminated
4181@end smallexample
4182
4183@noindent
4184On the other hand, in this example there is no warning:
4185
4186@smallexample
4187struct foo;
4188void foo (); // "hides" struct foo
4189void bar (struct foo&); // no warning, keyword struct is necessary
4190@end smallexample
4191
d77de738
ML
4192@opindex Wsubobject-linkage
4193@opindex Wno-subobject-linkage
ddf6fe37 4194@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
d77de738
ML
4195Do not warn
4196if a class type has a base or a field whose type uses the anonymous
4197namespace or depends on a type with no linkage. If a type A depends on
4198a type B with no or internal linkage, defining it in multiple
4199translation units would be an ODR violation because the meaning of B
4200is different in each translation unit. If A only appears in a single
4201translation unit, the best way to silence the warning is to give it
4202internal linkage by putting it in an anonymous namespace as well. The
4203compiler doesn't give this warning for types defined in the main .C
4204file, as those are unlikely to have multiple definitions.
4205@option{-Wsubobject-linkage} is enabled by default.
4206
d77de738
ML
4207@opindex Weffc++
4208@opindex Wno-effc++
ddf6fe37 4209@item -Weffc++ @r{(C++ and Objective-C++ only)}
d77de738
ML
4210Warn about violations of the following style guidelines from Scott Meyers'
4211@cite{Effective C++} series of books:
4212
4213@itemize @bullet
4214@item
4215Define a copy constructor and an assignment operator for classes
4216with dynamically-allocated memory.
4217
4218@item
4219Prefer initialization to assignment in constructors.
4220
4221@item
4222Have @code{operator=} return a reference to @code{*this}.
4223
4224@item
4225Don't try to return a reference when you must return an object.
4226
4227@item
4228Distinguish between prefix and postfix forms of increment and
4229decrement operators.
4230
4231@item
4232Never overload @code{&&}, @code{||}, or @code{,}.
4233
4234@end itemize
4235
4236This option also enables @option{-Wnon-virtual-dtor}, which is also
4237one of the effective C++ recommendations. However, the check is
4238extended to warn about the lack of virtual destructor in accessible
4239non-polymorphic bases classes too.
4240
4241When selecting this option, be aware that the standard library
4242headers do not obey all of these guidelines; use @samp{grep -v}
4243to filter out those warnings.
4244
d77de738
ML
4245@opindex Wexceptions
4246@opindex Wno-exceptions
ddf6fe37 4247@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
d77de738
ML
4248Disable the warning about the case when an exception handler is shadowed by
4249another handler, which can point out a wrong ordering of exception handlers.
4250
d77de738
ML
4251@opindex Wstrict-null-sentinel
4252@opindex Wno-strict-null-sentinel
ddf6fe37 4253@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
d77de738
ML
4254Warn about the use of an uncasted @code{NULL} as sentinel. When
4255compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4256to @code{__null}. Although it is a null pointer constant rather than a
4257null pointer, it is guaranteed to be of the same size as a pointer.
4258But this use is not portable across different compilers.
4259
d77de738
ML
4260@opindex Wno-non-template-friend
4261@opindex Wnon-template-friend
ddf6fe37 4262@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
d77de738
ML
4263Disable warnings when non-template friend functions are declared
4264within a template. In very old versions of GCC that predate implementation
4265of the ISO standard, declarations such as
4266@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4267could be interpreted as a particular specialization of a template
4268function; the warning exists to diagnose compatibility problems,
4269and is enabled by default.
4270
d77de738
ML
4271@opindex Wold-style-cast
4272@opindex Wno-old-style-cast
ddf6fe37 4273@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4274Warn if an old-style (C-style) cast to a non-void type is used within
4275a C++ program. The new-style casts (@code{dynamic_cast},
4276@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4277less vulnerable to unintended effects and much easier to search for.
4278
d77de738
ML
4279@opindex Woverloaded-virtual
4280@opindex Wno-overloaded-virtual
4281@cindex overloaded virtual function, warning
4282@cindex warning for overloaded virtual function
f33d7a88
AA
4283@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4284@itemx -Woverloaded-virtual=@var{n}
d77de738
ML
4285Warn when a function declaration hides virtual functions from a
4286base class. For example, in:
4287
4288@smallexample
4289struct A @{
4290 virtual void f();
4291@};
4292
4293struct B: public A @{
4294 void f(int); // does not override
4295@};
4296@end smallexample
4297
4298the @code{A} class version of @code{f} is hidden in @code{B}, and code
4299like:
4300
4301@smallexample
4302B* b;
4303b->f();
4304@end smallexample
4305
4306@noindent
4307fails to compile.
4308
d82490d5
JW
4309In cases where the different signatures are not an accident, the
4310simplest solution is to add a using-declaration to the derived class
4311to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4312
d77de738
ML
4313The optional level suffix controls the behavior when all the
4314declarations in the derived class override virtual functions in the
4315base class, even if not all of the base functions are overridden:
4316
4317@smallexample
4318struct C @{
4319 virtual void f();
4320 virtual void f(int);
4321@};
4322
4323struct D: public C @{
4324 void f(int); // does override
4325@}
4326@end smallexample
4327
4328This pattern is less likely to be a mistake; if D is only used
4329virtually, the user might have decided that the base class semantics
4330for some of the overloads are fine.
4331
4332At level 1, this case does not warn; at level 2, it does.
4333@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4334included in @option{-Wall}.
4335
d77de738
ML
4336@opindex Wno-pmf-conversions
4337@opindex Wpmf-conversions
ddf6fe37 4338@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
d77de738
ML
4339Disable the diagnostic for converting a bound pointer to member function
4340to a plain pointer.
4341
d77de738
ML
4342@opindex Wsign-promo
4343@opindex Wno-sign-promo
ddf6fe37 4344@item -Wsign-promo @r{(C++ and Objective-C++ only)}
d77de738
ML
4345Warn when overload resolution chooses a promotion from unsigned or
4346enumerated type to a signed type, over a conversion to an unsigned type of
4347the same size. Previous versions of G++ tried to preserve
4348unsignedness, but the standard mandates the current behavior.
4349
d77de738
ML
4350@opindex Wtemplates
4351@opindex Wno-templates
ddf6fe37 4352@item -Wtemplates @r{(C++ and Objective-C++ only)}
d77de738
ML
4353Warn when a primary template declaration is encountered. Some coding
4354rules disallow templates, and this may be used to enforce that rule.
4355The warning is inactive inside a system header file, such as the STL, so
4356one can still use the STL. One may also instantiate or specialize
4357templates.
4358
d77de738
ML
4359@opindex Wmismatched-new-delete
4360@opindex Wno-mismatched-new-delete
ddf6fe37 4361@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
d77de738
ML
4362Warn for mismatches between calls to @code{operator new} or @code{operator
4363delete} and the corresponding call to the allocation or deallocation function.
4364This includes invocations of C++ @code{operator delete} with pointers
4365returned from either mismatched forms of @code{operator new}, or from other
4366functions that allocate objects for which the @code{operator delete} isn't
4367a suitable deallocator, as well as calls to other deallocation functions
4368with pointers returned from @code{operator new} for which the deallocation
4369function isn't suitable.
4370
4371For example, the @code{delete} expression in the function below is diagnosed
4372because it doesn't match the array form of the @code{new} expression
4373the pointer argument was returned from. Similarly, the call to @code{free}
4374is also diagnosed.
4375
4376@smallexample
4377void f ()
4378@{
4379 int *a = new int[n];
4380 delete a; // warning: mismatch in array forms of expressions
4381
4382 char *p = new char[n];
4383 free (p); // warning: mismatch between new and free
4384@}
4385@end smallexample
4386
4387The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4388involving allocation and deallocation functions other than @code{operator
4389new} and @code{operator delete}.
4390
4391@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4392
d77de738
ML
4393@opindex Wmismatched-tags
4394@opindex Wno-mismatched-tags
ddf6fe37 4395@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4396Warn for declarations of structs, classes, and class templates and their
4397specializations with a class-key that does not match either the definition
4398or the first declaration if no definition is provided.
4399
4400For example, the declaration of @code{struct Object} in the argument list
4401of @code{draw} triggers the warning. To avoid it, either remove the redundant
4402class-key @code{struct} or replace it with @code{class} to match its definition.
4403@smallexample
4404class Object @{
4405public:
4406 virtual ~Object () = 0;
4407@};
4408void draw (struct Object*);
4409@end smallexample
4410
4411It is not wrong to declare a class with the class-key @code{struct} as
4412the example above shows. The @option{-Wmismatched-tags} option is intended
4413to help achieve a consistent style of class declarations. In code that is
4414intended to be portable to Windows-based compilers the warning helps prevent
4415unresolved references due to the difference in the mangling of symbols
4416declared with different class-keys. The option can be used either on its
4417own or in conjunction with @option{-Wredundant-tags}.
4418
d77de738
ML
4419@opindex Wmultiple-inheritance
4420@opindex Wno-multiple-inheritance
ddf6fe37 4421@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
d77de738
ML
4422Warn when a class is defined with multiple direct base classes. Some
4423coding rules disallow multiple inheritance, and this may be used to
4424enforce that rule. The warning is inactive inside a system header file,
4425such as the STL, so one can still use the STL. One may also define
4426classes that indirectly use multiple inheritance.
4427
d77de738
ML
4428@opindex Wvirtual-inheritance
4429@opindex Wno-virtual-inheritance
ddf6fe37 4430@item -Wvirtual-inheritance
d77de738
ML
4431Warn when a class is defined with a virtual direct base class. Some
4432coding rules disallow multiple inheritance, and this may be used to
4433enforce that rule. The warning is inactive inside a system header file,
4434such as the STL, so one can still use the STL. One may also define
4435classes that indirectly use virtual inheritance.
4436
d77de738
ML
4437@opindex Wvirtual-move-assign
4438@opindex Wno-virtual-move-assign
ddf6fe37 4439@item -Wno-virtual-move-assign
d77de738
ML
4440Suppress warnings about inheriting from a virtual base with a
4441non-trivial C++11 move assignment operator. This is dangerous because
4442if the virtual base is reachable along more than one path, it is
4443moved multiple times, which can mean both objects end up in the
4444moved-from state. If the move assignment operator is written to avoid
4445moving from a moved-from object, this warning can be disabled.
4446
d77de738
ML
4447@opindex Wnamespaces
4448@opindex Wno-namespaces
ddf6fe37 4449@item -Wnamespaces
d77de738
ML
4450Warn when a namespace definition is opened. Some coding rules disallow
4451namespaces, and this may be used to enforce that rule. The warning is
4452inactive inside a system header file, such as the STL, so one can still
4453use the STL. One may also use using directives and qualified names.
4454
d77de738
ML
4455@opindex Wterminate
4456@opindex Wno-terminate
ddf6fe37 4457@item -Wno-terminate @r{(C++ and Objective-C++ only)}
d77de738
ML
4458Disable the warning about a throw-expression that will immediately
4459result in a call to @code{terminate}.
4460
d77de738
ML
4461@opindex Wvexing-parse
4462@opindex Wno-vexing-parse
ddf6fe37 4463@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
d77de738
ML
4464Warn about the most vexing parse syntactic ambiguity. This warns about
4465the cases when a declaration looks like a variable definition, but the
4466C++ language requires it to be interpreted as a function declaration.
4467For instance:
4468
4469@smallexample
4470void f(double a) @{
4471 int i(); // extern int i (void);
4472 int n(int(a)); // extern int n (int);
4473@}
4474@end smallexample
4475
4476Another example:
4477
4478@smallexample
4479struct S @{ S(int); @};
4480void f(double a) @{
4481 S x(int(a)); // extern struct S x (int);
4482 S y(int()); // extern struct S y (int (*) (void));
4483 S z(); // extern struct S z (void);
4484@}
4485@end smallexample
4486
4487The warning will suggest options how to deal with such an ambiguity; e.g.,
4488it can suggest removing the parentheses or using braces instead.
4489
4490This warning is enabled by default.
4491
d77de738
ML
4492@opindex Wno-class-conversion
4493@opindex Wclass-conversion
ddf6fe37 4494@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
4495Do not warn when a conversion function converts an
4496object to the same type, to a base class of that type, or to void; such
4497a conversion function will never be called.
4498
d77de738
ML
4499@opindex Wvolatile
4500@opindex Wno-volatile
ddf6fe37 4501@item -Wvolatile @r{(C++ and Objective-C++ only)}
d77de738
ML
4502Warn about deprecated uses of the @code{volatile} qualifier. This includes
4503postfix and prefix @code{++} and @code{--} expressions of
4504@code{volatile}-qualified types, using simple assignments where the left
4505operand is a @code{volatile}-qualified non-class type for their value,
4506compound assignments where the left operand is a @code{volatile}-qualified
4507non-class type, @code{volatile}-qualified function return type,
4508@code{volatile}-qualified parameter type, and structured bindings of a
4509@code{volatile}-qualified type. This usage was deprecated in C++20.
4510
4511Enabled by default with @option{-std=c++20}.
4512
d77de738
ML
4513@opindex Wzero-as-null-pointer-constant
4514@opindex Wno-zero-as-null-pointer-constant
ddf6fe37 4515@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
d77de738
ML
4516Warn when a literal @samp{0} is used as null pointer constant. This can
4517be useful to facilitate the conversion to @code{nullptr} in C++11.
4518
d77de738
ML
4519@opindex Waligned-new
4520@opindex Wno-aligned-new
ddf6fe37 4521@item -Waligned-new
d77de738
ML
4522Warn about a new-expression of a type that requires greater alignment
4523than the @code{alignof(std::max_align_t)} but uses an allocation
4524function without an explicit alignment parameter. This option is
4525enabled by @option{-Wall}.
4526
4527Normally this only warns about global allocation functions, but
4528@option{-Waligned-new=all} also warns about class member allocation
4529functions.
4530
d77de738
ML
4531@opindex Wplacement-new
4532@opindex Wno-placement-new
ddf6fe37
AA
4533@item -Wno-placement-new
4534@itemx -Wplacement-new=@var{n}
d77de738
ML
4535Warn about placement new expressions with undefined behavior, such as
4536constructing an object in a buffer that is smaller than the type of
4537the object. For example, the placement new expression below is diagnosed
4538because it attempts to construct an array of 64 integers in a buffer only
453964 bytes large.
4540@smallexample
4541char buf [64];
4542new (buf) int[64];
4543@end smallexample
4544This warning is enabled by default.
4545
4546@table @gcctabopt
4547@item -Wplacement-new=1
4548This is the default warning level of @option{-Wplacement-new}. At this
4549level the warning is not issued for some strictly undefined constructs that
4550GCC allows as extensions for compatibility with legacy code. For example,
4551the following @code{new} expression is not diagnosed at this level even
4552though it has undefined behavior according to the C++ standard because
4553it writes past the end of the one-element array.
4554@smallexample
4555struct S @{ int n, a[1]; @};
4556S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4557new (s->a)int [32]();
4558@end smallexample
4559
4560@item -Wplacement-new=2
4561At this level, in addition to diagnosing all the same constructs as at level
45621, a diagnostic is also issued for placement new expressions that construct
4563an object in the last member of structure whose type is an array of a single
4564element and whose size is less than the size of the object being constructed.
4565While the previous example would be diagnosed, the following construct makes
4566use of the flexible member array extension to avoid the warning at level 2.
4567@smallexample
4568struct S @{ int n, a[]; @};
4569S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4570new (s->a)int [32]();
4571@end smallexample
4572
4573@end table
4574
d77de738
ML
4575@opindex Wcatch-value
4576@opindex Wno-catch-value
ddf6fe37
AA
4577@item -Wcatch-value
4578@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
d77de738
ML
4579Warn about catch handlers that do not catch via reference.
4580With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4581warn about polymorphic class types that are caught by value.
4582With @option{-Wcatch-value=2} warn about all class types that are caught
4583by value. With @option{-Wcatch-value=3} warn about all types that are
4584not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4585
d77de738
ML
4586@opindex Wconditionally-supported
4587@opindex Wno-conditionally-supported
ddf6fe37 4588@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
d77de738
ML
4589Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4590
d77de738
ML
4591@opindex Wdelete-incomplete
4592@opindex Wno-delete-incomplete
ddf6fe37 4593@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
d77de738
ML
4594Do not warn when deleting a pointer to incomplete type, which may cause
4595undefined behavior at runtime. This warning is enabled by default.
4596
d77de738
ML
4597@opindex Wextra-semi
4598@opindex Wno-extra-semi
ddf6fe37 4599@item -Wextra-semi @r{(C++, Objective-C++ only)}
d77de738
ML
4600Warn about redundant semicolons after in-class function definitions.
4601
d77de738
ML
4602@opindex Winaccessible-base
4603@opindex Wno-inaccessible-base
ddf6fe37 4604@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
d77de738
ML
4605This option controls warnings
4606when a base class is inaccessible in a class derived from it due to
4607ambiguity. The warning is enabled by default.
4608Note that the warning for ambiguous virtual
4609bases is enabled by the @option{-Wextra} option.
4610@smallexample
4611@group
4612struct A @{ int a; @};
4613
4614struct B : A @{ @};
4615
4616struct C : B, A @{ @};
4617@end group
4618@end smallexample
4619
d77de738
ML
4620@opindex Winherited-variadic-ctor
4621@opindex Wno-inherited-variadic-ctor
ddf6fe37 4622@item -Wno-inherited-variadic-ctor
d77de738
ML
4623Suppress warnings about use of C++11 inheriting constructors when the
4624base class inherited from has a C variadic constructor; the warning is
4625on by default because the ellipsis is not inherited.
4626
d77de738
ML
4627@opindex Wno-invalid-offsetof
4628@opindex Winvalid-offsetof
ddf6fe37 4629@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
d77de738
ML
4630Suppress warnings from applying the @code{offsetof} macro to a non-POD
4631type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4632to a non-standard-layout type is undefined. In existing C++ implementations,
4633however, @code{offsetof} typically gives meaningful results.
4634This flag is for users who are aware that they are
4635writing nonportable code and who have deliberately chosen to ignore the
4636warning about it.
4637
4638The restrictions on @code{offsetof} may be relaxed in a future version
4639of the C++ standard.
4640
d77de738
ML
4641@opindex Wsized-deallocation
4642@opindex Wno-sized-deallocation
ddf6fe37 4643@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
d77de738
ML
4644Warn about a definition of an unsized deallocation function
4645@smallexample
4646void operator delete (void *) noexcept;
4647void operator delete[] (void *) noexcept;
4648@end smallexample
4649without a definition of the corresponding sized deallocation function
4650@smallexample
4651void operator delete (void *, std::size_t) noexcept;
4652void operator delete[] (void *, std::size_t) noexcept;
4653@end smallexample
4654or vice versa. Enabled by @option{-Wextra} along with
4655@option{-fsized-deallocation}.
4656
d77de738
ML
4657@opindex Wno-suggest-final-types
4658@opindex Wsuggest-final-types
ddf6fe37 4659@item -Wsuggest-final-types
d77de738
ML
4660Warn about types with virtual methods where code quality would be improved
4661if the type were declared with the C++11 @code{final} specifier,
4662or, if possible,
4663declared in an anonymous namespace. This allows GCC to more aggressively
4664devirtualize the polymorphic calls. This warning is more effective with
4665link-time optimization,
4666where the information about the class hierarchy graph is
4667more complete.
4668
d77de738
ML
4669@opindex Wno-suggest-final-methods
4670@opindex Wsuggest-final-methods
ddf6fe37 4671@item -Wsuggest-final-methods
d77de738
ML
4672Warn about virtual methods where code quality would be improved if the method
4673were declared with the C++11 @code{final} specifier,
4674or, if possible, its type were
4675declared in an anonymous namespace or with the @code{final} specifier.
4676This warning is
4677more effective with link-time optimization, where the information about the
4678class hierarchy graph is more complete. It is recommended to first consider
4679suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4680annotations.
4681
d77de738
ML
4682@opindex Wsuggest-override
4683@opindex Wno-suggest-override
ddf6fe37 4684@item -Wsuggest-override
d77de738
ML
4685Warn about overriding virtual functions that are not marked with the
4686@code{override} keyword.
4687
d77de738
ML
4688@opindex Wuse-after-free
4689@opindex Wno-use-after-free
ddf6fe37
AA
4690@item -Wuse-after-free
4691@itemx -Wuse-after-free=@var{n}
d77de738
ML
4692Warn about uses of pointers to dynamically allocated objects that have
4693been rendered indeterminate by a call to a deallocation function.
4694The warning is enabled at all optimization levels but may yield different
4695results with optimization than without.
4696
4697@table @gcctabopt
4698@item -Wuse-after-free=1
4699At level 1 the warning attempts to diagnose only unconditional uses
4700of pointers made indeterminate by a deallocation call or a successful
4701call to @code{realloc}, regardless of whether or not the call resulted
4702in an actual reallocatio of memory. This includes double-@code{free}
4703calls as well as uses in arithmetic and relational expressions. Although
4704undefined, uses of indeterminate pointers in equality (or inequality)
4705expressions are not diagnosed at this level.
4706@item -Wuse-after-free=2
4707At level 2, in addition to unconditional uses, the warning also diagnoses
4708conditional uses of pointers made indeterminate by a deallocation call.
4709As at level 2, uses in equality (or inequality) expressions are not
4710diagnosed. For example, the second call to @code{free} in the following
4711function is diagnosed at this level:
4712@smallexample
4713struct A @{ int refcount; void *data; @};
4714
4715void release (struct A *p)
4716@{
4717 int refcount = --p->refcount;
4718 free (p);
4719 if (refcount == 0)
4720 free (p->data); // warning: p may be used after free
4721@}
4722@end smallexample
4723@item -Wuse-after-free=3
4724At level 3, the warning also diagnoses uses of indeterminate pointers in
4725equality expressions. All uses of indeterminate pointers are undefined
4726but equality tests sometimes appear after calls to @code{realloc} as
4727an attempt to determine whether the call resulted in relocating the object
4728to a different address. They are diagnosed at a separate level to aid
4729legacy code gradually transition to safe alternatives. For example,
4730the equality test in the function below is diagnosed at this level:
4731@smallexample
4732void adjust_pointers (int**, int);
4733
4734void grow (int **p, int n)
4735@{
4736 int **q = (int**)realloc (p, n *= 2);
4737 if (q == p)
4738 return;
4739 adjust_pointers ((int**)q, n);
4740@}
4741@end smallexample
4742To avoid the warning at this level, store offsets into allocated memory
4743instead of pointers. This approach obviates needing to adjust the stored
4744pointers after reallocation.
4745@end table
4746
4747@option{-Wuse-after-free=2} is included in @option{-Wall}.
4748
d77de738
ML
4749@opindex Wuseless-cast
4750@opindex Wno-useless-cast
ddf6fe37 4751@item -Wuseless-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4752Warn when an expression is cast to its own type. This warning does not
4753occur when a class object is converted to a non-reference type as that
4754is a way to create a temporary:
4755
4756@smallexample
4757struct S @{ @};
4758void g (S&&);
4759void f (S&& arg)
4760@{
4761 g (S(arg)); // make arg prvalue so that it can bind to S&&
4762@}
4763@end smallexample
4764
d77de738
ML
4765@opindex Wconversion-null
4766@opindex Wno-conversion-null
ddf6fe37 4767@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
d77de738
ML
4768Do not warn for conversions between @code{NULL} and non-pointer
4769types. @option{-Wconversion-null} is enabled by default.
4770
4771@end table
4772
4773@node Objective-C and Objective-C++ Dialect Options
4774@section Options Controlling Objective-C and Objective-C++ Dialects
4775
4776@cindex compiler options, Objective-C and Objective-C++
4777@cindex Objective-C and Objective-C++ options, command-line
4778@cindex options, Objective-C and Objective-C++
4779(NOTE: This manual does not describe the Objective-C and Objective-C++
4780languages themselves. @xref{Standards,,Language Standards
4781Supported by GCC}, for references.)
4782
4783This section describes the command-line options that are only meaningful
4784for Objective-C and Objective-C++ programs. You can also use most of
4785the language-independent GNU compiler options.
4786For example, you might compile a file @file{some_class.m} like this:
4787
4788@smallexample
4789gcc -g -fgnu-runtime -O -c some_class.m
4790@end smallexample
4791
4792@noindent
4793In this example, @option{-fgnu-runtime} is an option meant only for
4794Objective-C and Objective-C++ programs; you can use the other options with
4795any language supported by GCC@.
4796
4797Note that since Objective-C is an extension of the C language, Objective-C
4798compilations may also use options specific to the C front-end (e.g.,
4799@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4800C++-specific options (e.g., @option{-Wabi}).
4801
4802Here is a list of options that are @emph{only} for compiling Objective-C
4803and Objective-C++ programs:
4804
4805@table @gcctabopt
d77de738 4806@opindex fconstant-string-class
ddf6fe37 4807@item -fconstant-string-class=@var{class-name}
d77de738
ML
4808Use @var{class-name} as the name of the class to instantiate for each
4809literal string specified with the syntax @code{@@"@dots{}"}. The default
4810class name is @code{NXConstantString} if the GNU runtime is being used, and
4811@code{NSConstantString} if the NeXT runtime is being used (see below). The
4812@option{-fconstant-cfstrings} option, if also present, overrides the
4813@option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4814to be laid out as constant CoreFoundation strings.
4815
d77de738 4816@opindex fgnu-runtime
ddf6fe37 4817@item -fgnu-runtime
d77de738
ML
4818Generate object code compatible with the standard GNU Objective-C
4819runtime. This is the default for most types of systems.
4820
d77de738 4821@opindex fnext-runtime
ddf6fe37 4822@item -fnext-runtime
d77de738
ML
4823Generate output compatible with the NeXT runtime. This is the default
4824for NeXT-based systems, including Darwin and Mac OS X@. The macro
4825@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4826used.
4827
d77de738
ML
4828@opindex fno-nil-receivers
4829@opindex fnil-receivers
ddf6fe37 4830@item -fno-nil-receivers
d77de738
ML
4831Assume that all Objective-C message dispatches (@code{[receiver
4832message:arg]}) in this translation unit ensure that the receiver is
4833not @code{nil}. This allows for more efficient entry points in the
4834runtime to be used. This option is only available in conjunction with
4835the NeXT runtime and ABI version 0 or 1.
4836
d77de738 4837@opindex fobjc-abi-version
ddf6fe37 4838@item -fobjc-abi-version=@var{n}
d77de738
ML
4839Use version @var{n} of the Objective-C ABI for the selected runtime.
4840This option is currently supported only for the NeXT runtime. In that
4841case, Version 0 is the traditional (32-bit) ABI without support for
4842properties and other Objective-C 2.0 additions. Version 1 is the
4843traditional (32-bit) ABI with support for properties and other
4844Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4845nothing is specified, the default is Version 0 on 32-bit target
4846machines, and Version 2 on 64-bit target machines.
4847
d77de738 4848@opindex fobjc-call-cxx-cdtors
ddf6fe37 4849@item -fobjc-call-cxx-cdtors
d77de738
ML
4850For each Objective-C class, check if any of its instance variables is a
4851C++ object with a non-trivial default constructor. If so, synthesize a
4852special @code{- (id) .cxx_construct} instance method which runs
4853non-trivial default constructors on any such instance variables, in order,
4854and then return @code{self}. Similarly, check if any instance variable
4855is a C++ object with a non-trivial destructor, and if so, synthesize a
4856special @code{- (void) .cxx_destruct} method which runs
4857all such default destructors, in reverse order.
4858
4859The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4860methods thusly generated only operate on instance variables
4861declared in the current Objective-C class, and not those inherited
4862from superclasses. It is the responsibility of the Objective-C
4863runtime to invoke all such methods in an object's inheritance
4864hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4865by the runtime immediately after a new object instance is allocated;
4866the @code{- (void) .cxx_destruct} methods are invoked immediately
4867before the runtime deallocates an object instance.
4868
4869As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4870support for invoking the @code{- (id) .cxx_construct} and
4871@code{- (void) .cxx_destruct} methods.
4872
d77de738 4873@opindex fobjc-direct-dispatch
ddf6fe37 4874@item -fobjc-direct-dispatch
d77de738
ML
4875Allow fast jumps to the message dispatcher. On Darwin this is
4876accomplished via the comm page.
4877
d77de738 4878@opindex fobjc-exceptions
ddf6fe37 4879@item -fobjc-exceptions
d77de738
ML
4880Enable syntactic support for structured exception handling in
4881Objective-C, similar to what is offered by C++. This option
4882is required to use the Objective-C keywords @code{@@try},
4883@code{@@throw}, @code{@@catch}, @code{@@finally} and
4884@code{@@synchronized}. This option is available with both the GNU
4885runtime and the NeXT runtime (but not available in conjunction with
4886the NeXT runtime on Mac OS X 10.2 and earlier).
4887
d77de738 4888@opindex fobjc-gc
ddf6fe37 4889@item -fobjc-gc
d77de738
ML
4890Enable garbage collection (GC) in Objective-C and Objective-C++
4891programs. This option is only available with the NeXT runtime; the
4892GNU runtime has a different garbage collection implementation that
4893does not require special compiler flags.
4894
d77de738 4895@opindex fobjc-nilcheck
ddf6fe37 4896@item -fobjc-nilcheck
d77de738
ML
4897For the NeXT runtime with version 2 of the ABI, check for a nil
4898receiver in method invocations before doing the actual method call.
4899This is the default and can be disabled using
4900@option{-fno-objc-nilcheck}. Class methods and super calls are never
4901checked for nil in this way no matter what this flag is set to.
4902Currently this flag does nothing when the GNU runtime, or an older
4903version of the NeXT runtime ABI, is used.
4904
d77de738 4905@opindex fobjc-std
ddf6fe37 4906@item -fobjc-std=objc1
d77de738
ML
4907Conform to the language syntax of Objective-C 1.0, the language
4908recognized by GCC 4.0. This only affects the Objective-C additions to
4909the C/C++ language; it does not affect conformance to C/C++ standards,
4910which is controlled by the separate C/C++ dialect option flags. When
4911this option is used with the Objective-C or Objective-C++ compiler,
4912any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4913This is useful if you need to make sure that your Objective-C code can
4914be compiled with older versions of GCC@.
4915
d77de738 4916@opindex freplace-objc-classes
ddf6fe37 4917@item -freplace-objc-classes
d77de738
ML
4918Emit a special marker instructing @command{ld(1)} not to statically link in
4919the resulting object file, and allow @command{dyld(1)} to load it in at
4920run time instead. This is used in conjunction with the Fix-and-Continue
4921debugging mode, where the object file in question may be recompiled and
4922dynamically reloaded in the course of program execution, without the need
4923to restart the program itself. Currently, Fix-and-Continue functionality
4924is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4925and later.
4926
d77de738 4927@opindex fzero-link
ddf6fe37 4928@item -fzero-link
d77de738
ML
4929When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4930to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4931compile time) with static class references that get initialized at load time,
4932which improves run-time performance. Specifying the @option{-fzero-link} flag
4933suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4934to be retained. This is useful in Zero-Link debugging mode, since it allows
4935for individual class implementations to be modified during program execution.
4936The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4937regardless of command-line options.
4938
d77de738
ML
4939@opindex fno-local-ivars
4940@opindex flocal-ivars
ddf6fe37 4941@item -fno-local-ivars
d77de738
ML
4942By default instance variables in Objective-C can be accessed as if
4943they were local variables from within the methods of the class they're
4944declared in. This can lead to shadowing between instance variables
4945and other variables declared either locally inside a class method or
4946globally with the same name. Specifying the @option{-fno-local-ivars}
4947flag disables this behavior thus avoiding variable shadowing issues.
4948
d77de738 4949@opindex fivar-visibility
ddf6fe37 4950@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
d77de738
ML
4951Set the default instance variable visibility to the specified option
4952so that instance variables declared outside the scope of any access
4953modifier directives default to the specified visibility.
4954
d77de738 4955@opindex gen-decls
ddf6fe37 4956@item -gen-decls
d77de738
ML
4957Dump interface declarations for all classes seen in the source file to a
4958file named @file{@var{sourcename}.decl}.
4959
d77de738
ML
4960@opindex Wassign-intercept
4961@opindex Wno-assign-intercept
ddf6fe37 4962@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4963Warn whenever an Objective-C assignment is being intercepted by the
4964garbage collector.
4965
d77de738
ML
4966@opindex Wproperty-assign-default
4967@opindex Wno-property-assign-default
ddf6fe37 4968@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4969Do not warn if a property for an Objective-C object has no assign
4970semantics specified.
4971
d77de738
ML
4972@opindex Wno-protocol
4973@opindex Wprotocol
ddf6fe37 4974@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4975If a class is declared to implement a protocol, a warning is issued for
4976every method in the protocol that is not implemented by the class. The
4977default behavior is to issue a warning for every method not explicitly
4978implemented in the class, even if a method implementation is inherited
4979from the superclass. If you use the @option{-Wno-protocol} option, then
4980methods inherited from the superclass are considered to be implemented,
4981and no warning is issued for them.
4982
d77de738 4983@opindex Wobjc-root-class
ddf6fe37 4984@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4985Warn if a class interface lacks a superclass. Most classes will inherit
4986from @code{NSObject} (or @code{Object}) for example. When declaring
4987classes intended to be root classes, the warning can be suppressed by
4988marking their interfaces with @code{__attribute__((objc_root_class))}.
4989
d77de738
ML
4990@opindex Wselector
4991@opindex Wno-selector
ddf6fe37 4992@item -Wselector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4993Warn if multiple methods of different types for the same selector are
4994found during compilation. The check is performed on the list of methods
4995in the final stage of compilation. Additionally, a check is performed
4996for each selector appearing in a @code{@@selector(@dots{})}
4997expression, and a corresponding method for that selector has been found
4998during compilation. Because these checks scan the method table only at
4999the end of compilation, these warnings are not produced if the final
5000stage of compilation is not reached, for example because an error is
5001found during compilation, or because the @option{-fsyntax-only} option is
5002being used.
5003
d77de738
ML
5004@opindex Wstrict-selector-match
5005@opindex Wno-strict-selector-match
ddf6fe37 5006@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5007Warn if multiple methods with differing argument and/or return types are
5008found for a given selector when attempting to send a message using this
5009selector to a receiver of type @code{id} or @code{Class}. When this flag
5010is off (which is the default behavior), the compiler omits such warnings
5011if any differences found are confined to types that share the same size
5012and alignment.
5013
d77de738
ML
5014@opindex Wundeclared-selector
5015@opindex Wno-undeclared-selector
ddf6fe37 5016@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5017Warn if a @code{@@selector(@dots{})} expression referring to an
5018undeclared selector is found. A selector is considered undeclared if no
5019method with that name has been declared before the
5020@code{@@selector(@dots{})} expression, either explicitly in an
5021@code{@@interface} or @code{@@protocol} declaration, or implicitly in
5022an @code{@@implementation} section. This option always performs its
5023checks as soon as a @code{@@selector(@dots{})} expression is found,
5024while @option{-Wselector} only performs its checks in the final stage of
5025compilation. This also enforces the coding style convention
5026that methods and selectors must be declared before being used.
5027
d77de738 5028@opindex print-objc-runtime-info
ddf6fe37 5029@item -print-objc-runtime-info
d77de738
ML
5030Generate C header describing the largest structure that is passed by
5031value, if any.
5032
5033@end table
5034
5035@node Diagnostic Message Formatting Options
5036@section Options to Control Diagnostic Messages Formatting
5037@cindex options to control diagnostics formatting
5038@cindex diagnostic messages
5039@cindex message formatting
5040
5041Traditionally, diagnostic messages have been formatted irrespective of
5042the output device's aspect (e.g.@: its width, @dots{}). You can use the
5043options described below
5044to control the formatting algorithm for diagnostic messages,
5045e.g.@: how many characters per line, how often source location
5046information should be reported. Note that some language front ends may not
5047honor these options.
5048
5049@table @gcctabopt
d77de738 5050@opindex fmessage-length
ddf6fe37 5051@item -fmessage-length=@var{n}
d77de738
ML
5052Try to format error messages so that they fit on lines of about
5053@var{n} characters. If @var{n} is zero, then no line-wrapping is
5054done; each error message appears on a single line. This is the
5055default for all front ends.
5056
5057Note - this option also affects the display of the @samp{#error} and
5058@samp{#warning} pre-processor directives, and the @samp{deprecated}
5059function/type/variable attribute. It does not however affect the
5060@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5061
5062@item -fdiagnostics-plain-output
5063This option requests that diagnostic output look as plain as possible, which
5064may be useful when running @command{dejagnu} or other utilities that need to
5065parse diagnostics output and prefer that it remain more stable over time.
5066@option{-fdiagnostics-plain-output} is currently equivalent to the following
5067options:
43b72ede
AA
5068@gccoptlist{-fno-diagnostics-show-caret
5069-fno-diagnostics-show-line-numbers
5070-fdiagnostics-color=never
5071-fdiagnostics-urls=never
d77de738
ML
5072-fdiagnostics-path-format=separate-events}
5073In the future, if GCC changes the default appearance of its diagnostics, the
5074corresponding option to disable the new behavior will be added to this list.
5075
d77de738 5076@opindex fdiagnostics-show-location
ddf6fe37 5077@item -fdiagnostics-show-location=once
d77de738
ML
5078Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5079reporter to emit source location information @emph{once}; that is, in
5080case the message is too long to fit on a single physical line and has to
5081be wrapped, the source location won't be emitted (as prefix) again,
5082over and over, in subsequent continuation lines. This is the default
5083behavior.
5084
5085@item -fdiagnostics-show-location=every-line
5086Only meaningful in line-wrapping mode. Instructs the diagnostic
5087messages reporter to emit the same source location information (as
5088prefix) for physical lines that result from the process of breaking
5089a message which is too long to fit on a single line.
5090
ddf6fe37 5091@opindex fdiagnostics-color
d77de738
ML
5092@cindex highlight, color
5093@vindex GCC_COLORS @r{environment variable}
f33d7a88
AA
5094@item -fdiagnostics-color[=@var{WHEN}]
5095@itemx -fno-diagnostics-color
d77de738
ML
5096Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5097or @samp{auto}. The default depends on how the compiler has been configured,
5098it can be any of the above @var{WHEN} options or also @samp{never}
5099if @env{GCC_COLORS} environment variable isn't present in the environment,
5100and @samp{auto} otherwise.
5101@samp{auto} makes GCC use color only when the standard error is a terminal,
5102and when not executing in an emacs shell.
5103The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5104aliases for @option{-fdiagnostics-color=always} and
5105@option{-fdiagnostics-color=never}, respectively.
5106
5107The colors are defined by the environment variable @env{GCC_COLORS}.
5108Its value is a colon-separated list of capabilities and Select Graphic
5109Rendition (SGR) substrings. SGR commands are interpreted by the
5110terminal or terminal emulator. (See the section in the documentation
5111of your text terminal for permitted values and their meanings as
5112character attributes.) These substring values are integers in decimal
5113representation and can be concatenated with semicolons.
5114Common values to concatenate include
5115@samp{1} for bold,
5116@samp{4} for underline,
5117@samp{5} for blink,
5118@samp{7} for inverse,
5119@samp{39} for default foreground color,
5120@samp{30} to @samp{37} for foreground colors,
5121@samp{90} to @samp{97} for 16-color mode foreground colors,
5122@samp{38;5;0} to @samp{38;5;255}
5123for 88-color and 256-color modes foreground colors,
5124@samp{49} for default background color,
5125@samp{40} to @samp{47} for background colors,
5126@samp{100} to @samp{107} for 16-color mode background colors,
5127and @samp{48;5;0} to @samp{48;5;255}
5128for 88-color and 256-color modes background colors.
5129
5130The default @env{GCC_COLORS} is
5131@smallexample
5132error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5133quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5134diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5135type-diff=01;32:fnname=01;32:targs=35
5136@end smallexample
5137@noindent
5138where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5139@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5140@samp{01} is bold, and @samp{31} is red.
5141Setting @env{GCC_COLORS} to the empty string disables colors.
5142Supported capabilities are as follows.
5143
5144@table @code
d77de738 5145@vindex error GCC_COLORS @r{capability}
f33d7a88 5146@item error=
d77de738
ML
5147SGR substring for error: markers.
5148
d77de738 5149@vindex warning GCC_COLORS @r{capability}
f33d7a88 5150@item warning=
d77de738
ML
5151SGR substring for warning: markers.
5152
d77de738 5153@vindex note GCC_COLORS @r{capability}
f33d7a88 5154@item note=
d77de738
ML
5155SGR substring for note: markers.
5156
d77de738 5157@vindex path GCC_COLORS @r{capability}
f33d7a88 5158@item path=
d77de738
ML
5159SGR substring for colorizing paths of control-flow events as printed
5160via @option{-fdiagnostics-path-format=}, such as the identifiers of
5161individual events and lines indicating interprocedural calls and returns.
5162
d77de738 5163@vindex range1 GCC_COLORS @r{capability}
f33d7a88 5164@item range1=
d77de738
ML
5165SGR substring for first additional range.
5166
d77de738 5167@vindex range2 GCC_COLORS @r{capability}
f33d7a88 5168@item range2=
d77de738
ML
5169SGR substring for second additional range.
5170
d77de738 5171@vindex locus GCC_COLORS @r{capability}
f33d7a88 5172@item locus=
d77de738
ML
5173SGR substring for location information, @samp{file:line} or
5174@samp{file:line:column} etc.
5175
d77de738 5176@vindex quote GCC_COLORS @r{capability}
f33d7a88 5177@item quote=
d77de738
ML
5178SGR substring for information printed within quotes.
5179
d77de738 5180@vindex fnname GCC_COLORS @r{capability}
f33d7a88 5181@item fnname=
d77de738
ML
5182SGR substring for names of C++ functions.
5183
d77de738 5184@vindex targs GCC_COLORS @r{capability}
f33d7a88 5185@item targs=
d77de738
ML
5186SGR substring for C++ function template parameter bindings.
5187
d77de738 5188@vindex fixit-insert GCC_COLORS @r{capability}
f33d7a88 5189@item fixit-insert=
d77de738
ML
5190SGR substring for fix-it hints suggesting text to
5191be inserted or replaced.
5192
d77de738 5193@vindex fixit-delete GCC_COLORS @r{capability}
f33d7a88 5194@item fixit-delete=
d77de738
ML
5195SGR substring for fix-it hints suggesting text to
5196be deleted.
5197
d77de738 5198@vindex diff-filename GCC_COLORS @r{capability}
f33d7a88 5199@item diff-filename=
d77de738
ML
5200SGR substring for filename headers within generated patches.
5201
d77de738 5202@vindex diff-hunk GCC_COLORS @r{capability}
f33d7a88 5203@item diff-hunk=
d77de738
ML
5204SGR substring for the starts of hunks within generated patches.
5205
d77de738 5206@vindex diff-delete GCC_COLORS @r{capability}
f33d7a88 5207@item diff-delete=
d77de738
ML
5208SGR substring for deleted lines within generated patches.
5209
d77de738 5210@vindex diff-insert GCC_COLORS @r{capability}
f33d7a88 5211@item diff-insert=
d77de738
ML
5212SGR substring for inserted lines within generated patches.
5213
d77de738 5214@vindex type-diff GCC_COLORS @r{capability}
f33d7a88 5215@item type-diff=
d77de738
ML
5216SGR substring for highlighting mismatching types within template
5217arguments in the C++ frontend.
5218@end table
5219
d77de738
ML
5220@opindex fdiagnostics-urls
5221@cindex urls
5222@vindex GCC_URLS @r{environment variable}
5223@vindex TERM_URLS @r{environment variable}
f33d7a88 5224@item -fdiagnostics-urls[=@var{WHEN}]
d77de738
ML
5225Use escape sequences to embed URLs in diagnostics. For example, when
5226@option{-fdiagnostics-show-option} emits text showing the command-line
5227option controlling a diagnostic, embed a URL for documentation of that
5228option.
5229
5230@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5231@samp{auto} makes GCC use URL escape sequences only when the standard error
5232is a terminal, and when not executing in an emacs shell or any graphical
5233terminal which is known to be incompatible with this feature, see below.
5234
5235The default depends on how the compiler has been configured.
5236It can be any of the above @var{WHEN} options.
5237
5238GCC can also be configured (via the
5239@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5240so that the default is affected by environment variables.
5241Under such a configuration, GCC defaults to using @samp{auto}
5242if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5243present and non-empty in the environment of the compiler, or @samp{never}
5244if neither are.
5245
5246However, even with @option{-fdiagnostics-urls=always} the behavior is
5247dependent on those environment variables:
5248If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5249diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5250If set to @samp{bel}, the default, URLs use BEL escape sequences.
5251Any other non-empty value enables the feature.
5252If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5253Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5254BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5255
5256At this time GCC tries to detect also a few terminals that are known to
5257not implement the URL feature, and have bugs or at least had bugs in
5258some versions that are still in use, where the URL escapes are likely
5259to misbehave, i.e. print garbage on the screen.
5260That list is currently xfce4-terminal, certain known to be buggy
5261gnome-terminal versions, the linux console, and mingw.
5262This check can be skipped with the @option{-fdiagnostics-urls=always}.
5263
d77de738
ML
5264@opindex fno-diagnostics-show-option
5265@opindex fdiagnostics-show-option
ddf6fe37 5266@item -fno-diagnostics-show-option
d77de738
ML
5267By default, each diagnostic emitted includes text indicating the
5268command-line option that directly controls the diagnostic (if such an
5269option is known to the diagnostic machinery). Specifying the
5270@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5271
d77de738
ML
5272@opindex fno-diagnostics-show-caret
5273@opindex fdiagnostics-show-caret
ddf6fe37 5274@item -fno-diagnostics-show-caret
d77de738
ML
5275By default, each diagnostic emitted includes the original source line
5276and a caret @samp{^} indicating the column. This option suppresses this
5277information. The source line is truncated to @var{n} characters, if
5278the @option{-fmessage-length=n} option is given. When the output is done
5279to the terminal, the width is limited to the width given by the
5280@env{COLUMNS} environment variable or, if not set, to the terminal width.
5281
d77de738
ML
5282@opindex fno-diagnostics-show-labels
5283@opindex fdiagnostics-show-labels
ddf6fe37 5284@item -fno-diagnostics-show-labels
d77de738
ML
5285By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5286diagnostics can label ranges of source code with pertinent information, such
5287as the types of expressions:
5288
5289@smallexample
5290 printf ("foo %s bar", long_i + long_j);
5291 ~^ ~~~~~~~~~~~~~~~
5292 | |
5293 char * long int
5294@end smallexample
5295
5296This option suppresses the printing of these labels (in the example above,
5297the vertical bars and the ``char *'' and ``long int'' text).
5298
d77de738
ML
5299@opindex fno-diagnostics-show-cwe
5300@opindex fdiagnostics-show-cwe
ddf6fe37 5301@item -fno-diagnostics-show-cwe
d77de738
ML
5302Diagnostic messages can optionally have an associated
5303@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5304GCC itself only provides such metadata for some of the @option{-fanalyzer}
5305diagnostics. GCC plugins may also provide diagnostics with such metadata.
5306By default, if this information is present, it will be printed with
5307the diagnostic. This option suppresses the printing of this metadata.
5308
d77de738
ML
5309@opindex fno-diagnostics-show-rules
5310@opindex fdiagnostics-show-rules
ddf6fe37 5311@item -fno-diagnostics-show-rules
d77de738
ML
5312Diagnostic messages can optionally have rules associated with them, such
5313as from a coding standard, or a specification.
5314GCC itself does not do this for any of its diagnostics, but plugins may do so.
5315By default, if this information is present, it will be printed with
5316the diagnostic. This option suppresses the printing of this metadata.
5317
d77de738
ML
5318@opindex fno-diagnostics-show-line-numbers
5319@opindex fdiagnostics-show-line-numbers
ddf6fe37 5320@item -fno-diagnostics-show-line-numbers
d77de738
ML
5321By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5322a left margin is printed, showing line numbers. This option suppresses this
5323left margin.
5324
d77de738 5325@opindex fdiagnostics-minimum-margin-width
ddf6fe37 5326@item -fdiagnostics-minimum-margin-width=@var{width}
d77de738
ML
5327This option controls the minimum width of the left margin printed by
5328@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5329
d77de738 5330@opindex fdiagnostics-parseable-fixits
ddf6fe37 5331@item -fdiagnostics-parseable-fixits
d77de738
ML
5332Emit fix-it hints in a machine-parseable format, suitable for consumption
5333by IDEs. For each fix-it, a line will be printed after the relevant
5334diagnostic, starting with the string ``fix-it:''. For example:
5335
5336@smallexample
5337fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5338@end smallexample
5339
5340The location is expressed as a half-open range, expressed as a count of
5341bytes, starting at byte 1 for the initial column. In the above example,
5342bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5343given string:
5344
5345@smallexample
534600000000011111111112222222222
534712345678901234567890123456789
5348 gtk_widget_showall (dlg);
5349 ^^^^^^^^^^^^^^^^^^
5350 gtk_widget_show_all
5351@end smallexample
5352
5353The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5354newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5355(e.g. vertical tab as ``\013'').
5356
5357An empty replacement string indicates that the given range is to be removed.
5358An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5359be inserted at the given position.
5360
d77de738 5361@opindex fdiagnostics-generate-patch
ddf6fe37 5362@item -fdiagnostics-generate-patch
d77de738
ML
5363Print fix-it hints to stderr in unified diff format, after any diagnostics
5364are printed. For example:
5365
5366@smallexample
5367--- test.c
5368+++ test.c
5369@@ -42,5 +42,5 @@
5370
5371 void show_cb(GtkDialog *dlg)
5372 @{
5373- gtk_widget_showall(dlg);
5374+ gtk_widget_show_all(dlg);
5375 @}
5376
5377@end smallexample
5378
5379The diff may or may not be colorized, following the same rules
5380as for diagnostics (see @option{-fdiagnostics-color}).
5381
d77de738 5382@opindex fdiagnostics-show-template-tree
ddf6fe37 5383@item -fdiagnostics-show-template-tree
d77de738
ML
5384
5385In the C++ frontend, when printing diagnostics showing mismatching
5386template types, such as:
5387
5388@smallexample
5389 could not convert 'std::map<int, std::vector<double> >()'
5390 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5391@end smallexample
5392
5393the @option{-fdiagnostics-show-template-tree} flag enables printing a
5394tree-like structure showing the common and differing parts of the types,
5395such as:
5396
5397@smallexample
5398 map<
5399 [...],
5400 vector<
5401 [double != float]>>
5402@end smallexample
5403
5404The parts that differ are highlighted with color (``double'' and
5405``float'' in this case).
5406
d77de738
ML
5407@opindex fno-elide-type
5408@opindex felide-type
ddf6fe37 5409@item -fno-elide-type
d77de738
ML
5410By default when the C++ frontend prints diagnostics showing mismatching
5411template types, common parts of the types are printed as ``[...]'' to
5412simplify the error message. For example:
5413
5414@smallexample
5415 could not convert 'std::map<int, std::vector<double> >()'
5416 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5417@end smallexample
5418
5419Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5420This flag also affects the output of the
5421@option{-fdiagnostics-show-template-tree} flag.
5422
d77de738 5423@opindex fdiagnostics-path-format
ddf6fe37 5424@item -fdiagnostics-path-format=@var{KIND}
d77de738
ML
5425Specify how to print paths of control-flow events for diagnostics that
5426have such a path associated with them.
5427
5428@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5429the default.
5430
5431@samp{none} means to not print diagnostic paths.
5432
5433@samp{separate-events} means to print a separate ``note'' diagnostic for
5434each event within the diagnostic. For example:
5435
5436@smallexample
5437test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5438test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5439test.c:27:3: note: (2) when 'i < count'
5440test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5441@end smallexample
5442
5443@samp{inline-events} means to print the events ``inline'' within the source
5444code. This view attempts to consolidate the events into runs of
5445sufficiently-close events, printing them as labelled ranges within the source.
5446
5447For example, the same events as above might be printed as:
5448
5449@smallexample
5450 'test': events 1-3
5451 |
5452 | 25 | list = PyList_New(0);
5453 | | ^~~~~~~~~~~~~
5454 | | |
5455 | | (1) when 'PyList_New' fails, returning NULL
5456 | 26 |
5457 | 27 | for (i = 0; i < count; i++) @{
5458 | | ~~~
5459 | | |
5460 | | (2) when 'i < count'
5461 | 28 | item = PyLong_FromLong(random());
5462 | 29 | PyList_Append(list, item);
5463 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5464 | | |
5465 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5466 |
5467@end smallexample
5468
5469Interprocedural control flow is shown by grouping the events by stack frame,
5470and using indentation to show how stack frames are nested, pushed, and popped.
5471
5472For example:
5473
5474@smallexample
5475 'test': events 1-2
5476 |
5477 | 133 | @{
5478 | | ^
5479 | | |
5480 | | (1) entering 'test'
5481 | 134 | boxed_int *obj = make_boxed_int (i);
5482 | | ~~~~~~~~~~~~~~~~~~
5483 | | |
5484 | | (2) calling 'make_boxed_int'
5485 |
5486 +--> 'make_boxed_int': events 3-4
5487 |
5488 | 120 | @{
5489 | | ^
5490 | | |
5491 | | (3) entering 'make_boxed_int'
5492 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5493 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5494 | | |
5495 | | (4) calling 'wrapped_malloc'
5496 |
5497 +--> 'wrapped_malloc': events 5-6
5498 |
5499 | 7 | @{
5500 | | ^
5501 | | |
5502 | | (5) entering 'wrapped_malloc'
5503 | 8 | return malloc (size);
5504 | | ~~~~~~~~~~~~~
5505 | | |
5506 | | (6) calling 'malloc'
5507 |
5508 <-------------+
5509 |
5510 'test': event 7
5511 |
5512 | 138 | free_boxed_int (obj);
5513 | | ^~~~~~~~~~~~~~~~~~~~
5514 | | |
5515 | | (7) calling 'free_boxed_int'
5516 |
5517(etc)
5518@end smallexample
5519
d77de738 5520@opindex fdiagnostics-show-path-depths
ddf6fe37 5521@item -fdiagnostics-show-path-depths
d77de738
ML
5522This option provides additional information when printing control-flow paths
5523associated with a diagnostic.
5524
5525If this is option is provided then the stack depth will be printed for
5526each run of events within @option{-fdiagnostics-path-format=inline-events}.
5527If provided with @option{-fdiagnostics-path-format=separate-events}, then
5528the stack depth and function declaration will be appended when printing
5529each event.
5530
5531This is intended for use by GCC developers and plugin developers when
5532debugging diagnostics that report interprocedural control flow.
5533
d77de738
ML
5534@opindex fno-show-column
5535@opindex fshow-column
ddf6fe37 5536@item -fno-show-column
d77de738
ML
5537Do not print column numbers in diagnostics. This may be necessary if
5538diagnostics are being scanned by a program that does not understand the
5539column numbers, such as @command{dejagnu}.
5540
d77de738 5541@opindex fdiagnostics-column-unit
ddf6fe37 5542@item -fdiagnostics-column-unit=@var{UNIT}
d77de738
ML
5543Select the units for the column number. This affects traditional diagnostics
5544(in the absence of @option{-fno-show-column}), as well as JSON format
5545diagnostics if requested.
5546
5547The default @var{UNIT}, @samp{display}, considers the number of display
5548columns occupied by each character. This may be larger than the number
5549of bytes required to encode the character, in the case of tab
5550characters, or it may be smaller, in the case of multibyte characters.
5551For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5552display column, and its UTF-8 encoding requires two bytes; the character
5553``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5554its UTF-8 encoding requires four bytes.
5555
5556Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5557count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5558
d77de738 5559@opindex fdiagnostics-column-origin
ddf6fe37 5560@item -fdiagnostics-column-origin=@var{ORIGIN}
d77de738
ML
5561Select the origin for column numbers, i.e. the column number assigned to the
5562first column. The default value of 1 corresponds to traditional GCC
5563behavior and to the GNU style guide. Some utilities may perform better with an
5564origin of 0; any non-negative value may be specified.
5565
d77de738 5566@opindex fdiagnostics-escape-format
ddf6fe37 5567@item -fdiagnostics-escape-format=@var{FORMAT}
d77de738
ML
5568When GCC prints pertinent source lines for a diagnostic it normally attempts
5569to print the source bytes directly. However, some diagnostics relate to encoding
5570issues in the source file, such as malformed UTF-8, or issues with Unicode
5571normalization. These diagnostics are flagged so that GCC will escape bytes
5572that are not printable ASCII when printing their pertinent source lines.
5573
5574This option controls how such bytes should be escaped.
5575
5576The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5577are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5578correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5579displayed as hexadecimal in the form @samp{<XX>}.
5580
5581For example, a source line containing the string @samp{before} followed by the
5582Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
55830xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5584the string @samp{after} will be printed for such a diagnostic as:
5585
5586@smallexample
5587 before<U+03C0><BF>after
5588@end smallexample
5589
5590Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5591in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5592Unicode characters. For the example above, the following will be printed:
5593
5594@smallexample
5595 before<CF><80><BF>after
5596@end smallexample
5597
d77de738 5598@opindex fdiagnostics-format
ddf6fe37 5599@item -fdiagnostics-format=@var{FORMAT}
d77de738
ML
5600Select a different format for printing diagnostics.
5601@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5602@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5603
5604The default is @samp{text}.
5605
5606The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5607diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5608named @file{@var{source}.sarif}, respectively.
5609
5610The @samp{json} format is a synonym for @samp{json-stderr}.
5611The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5612where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5613whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5614
5615The emitted JSON consists of a top-level JSON array containing JSON objects
5616representing the diagnostics. The JSON is emitted as one line, without
5617formatting; the examples below have been formatted for clarity.
5618
5619Diagnostics can have child diagnostics. For example, this error and note:
5620
5621@smallexample
5622misleading-indentation.c:15:3: warning: this 'if' clause does not
5623 guard... [-Wmisleading-indentation]
5624 15 | if (flag)
5625 | ^~
5626misleading-indentation.c:17:5: note: ...this statement, but the latter
5627 is misleadingly indented as if it were guarded by the 'if'
5628 17 | y = 2;
5629 | ^
5630@end smallexample
5631
5632@noindent
5633might be printed in JSON form (after formatting) like this:
5634
5635@smallexample
5636[
5637 @{
5638 "kind": "warning",
5639 "locations": [
5640 @{
5641 "caret": @{
5642 "display-column": 3,
5643 "byte-column": 3,
5644 "column": 3,
5645 "file": "misleading-indentation.c",
5646 "line": 15
5647 @},
5648 "finish": @{
5649 "display-column": 4,
5650 "byte-column": 4,
5651 "column": 4,
5652 "file": "misleading-indentation.c",
5653 "line": 15
5654 @}
5655 @}
5656 ],
5657 "message": "this \u2018if\u2019 clause does not guard...",
5658 "option": "-Wmisleading-indentation",
5659 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5660 "children": [
5661 @{
5662 "kind": "note",
5663 "locations": [
5664 @{
5665 "caret": @{
5666 "display-column": 5,
5667 "byte-column": 5,
5668 "column": 5,
5669 "file": "misleading-indentation.c",
5670 "line": 17
5671 @}
5672 @}
5673 ],
5674 "escape-source": false,
5675 "message": "...this statement, but the latter is @dots{}"
5676 @}
5677 ]
5678 "escape-source": false,
5679 "column-origin": 1,
5680 @}
5681]
5682@end smallexample
5683
5684@noindent
5685where the @code{note} is a child of the @code{warning}.
5686
5687A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5688an @code{option} key describing the command-line option controlling the
5689warning.
5690
5691A diagnostic can contain zero or more locations. Each location has an
5692optional @code{label} string and up to three positions within it: a
5693@code{caret} position and optional @code{start} and @code{finish} positions.
5694A position is described by a @code{file} name, a @code{line} number, and
5695three numbers indicating a column position:
5696@itemize @bullet
5697
5698@item
5699@code{display-column} counts display columns, accounting for tabs and
5700multibyte characters.
5701
5702@item
5703@code{byte-column} counts raw bytes.
5704
5705@item
5706@code{column} is equal to one of
5707the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5708option.
5709
5710@end itemize
5711All three columns are relative to the origin specified by
5712@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5713be set, for instance, to 0 for compatibility with other utilities that
5714number columns from 0. The column origin is recorded in the JSON output in
5715the @code{column-origin} tag. In the remaining examples below, the extra
5716column number outputs have been omitted for brevity.
5717
5718For example, this error:
5719
5720@smallexample
5721bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5722 'struct s'@} and 'T' @{aka 'struct t'@})
5723 64 | return callee_4a () + callee_4b ();
5724 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5725 | | |
5726 | | T @{aka struct t@}
5727 | S @{aka struct s@}
5728@end smallexample
5729
5730@noindent
5731has three locations. Its primary location is at the ``+'' token at column
573223. It has two secondary locations, describing the left and right-hand sides
5733of the expression, which have labels. It might be printed in JSON form as:
5734
5735@smallexample
5736 @{
5737 "children": [],
5738 "kind": "error",
5739 "locations": [
5740 @{
5741 "caret": @{
5742 "column": 23, "file": "bad-binary-ops.c", "line": 64
5743 @}
5744 @},
5745 @{
5746 "caret": @{
5747 "column": 10, "file": "bad-binary-ops.c", "line": 64
5748 @},
5749 "finish": @{
5750 "column": 21, "file": "bad-binary-ops.c", "line": 64
5751 @},
5752 "label": "S @{aka struct s@}"
5753 @},
5754 @{
5755 "caret": @{
5756 "column": 25, "file": "bad-binary-ops.c", "line": 64
5757 @},
5758 "finish": @{
5759 "column": 36, "file": "bad-binary-ops.c", "line": 64
5760 @},
5761 "label": "T @{aka struct t@}"
5762 @}
5763 ],
5764 "escape-source": false,
5765 "message": "invalid operands to binary + @dots{}"
5766 @}
5767@end smallexample
5768
5769If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5770consisting of half-open intervals, similar to the output of
5771@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5772with a replacement fix-it hint:
5773
5774@smallexample
5775demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5776 mean 'color'?
5777 8 | return ptr->colour;
5778 | ^~~~~~
5779 | color
5780@end smallexample
5781
5782@noindent
5783might be printed in JSON form as:
5784
5785@smallexample
5786 @{
5787 "children": [],
5788 "fixits": [
5789 @{
5790 "next": @{
5791 "column": 21,
5792 "file": "demo.c",
5793 "line": 8
5794 @},
5795 "start": @{
5796 "column": 15,
5797 "file": "demo.c",
5798 "line": 8
5799 @},
5800 "string": "color"
5801 @}
5802 ],
5803 "kind": "error",
5804 "locations": [
5805 @{
5806 "caret": @{
5807 "column": 15,
5808 "file": "demo.c",
5809 "line": 8
5810 @},
5811 "finish": @{
5812 "column": 20,
5813 "file": "demo.c",
5814 "line": 8
5815 @}
5816 @}
5817 ],
5818 "escape-source": false,
5819 "message": "\u2018struct s\u2019 has no member named @dots{}"
5820 @}
5821@end smallexample
5822
5823@noindent
5824where the fix-it hint suggests replacing the text from @code{start} up
5825to but not including @code{next} with @code{string}'s value. Deletions
5826are expressed via an empty value for @code{string}, insertions by
5827having @code{start} equal @code{next}.
5828
5829If the diagnostic has a path of control-flow events associated with it,
5830it has a @code{path} array of objects representing the events. Each
5831event object has a @code{description} string, a @code{location} object,
5832along with a @code{function} string and a @code{depth} number for
5833representing interprocedural paths. The @code{function} represents the
5834current function at that event, and the @code{depth} represents the
5835stack depth relative to some baseline: the higher, the more frames are
5836within the stack.
5837
5838For example, the intraprocedural example shown for
5839@option{-fdiagnostics-path-format=} might have this JSON for its path:
5840
5841@smallexample
5842 "path": [
5843 @{
5844 "depth": 0,
5845 "description": "when 'PyList_New' fails, returning NULL",
5846 "function": "test",
5847 "location": @{
5848 "column": 10,
5849 "file": "test.c",
5850 "line": 25
5851 @}
5852 @},
5853 @{
5854 "depth": 0,
5855 "description": "when 'i < count'",
5856 "function": "test",
5857 "location": @{
5858 "column": 3,
5859 "file": "test.c",
5860 "line": 27
5861 @}
5862 @},
5863 @{
5864 "depth": 0,
5865 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5866 "function": "test",
5867 "location": @{
5868 "column": 5,
5869 "file": "test.c",
5870 "line": 29
5871 @}
5872 @}
5873 ]
5874@end smallexample
5875
5876Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5877non-ASCII bytes should be escaped when printing the pertinent lines of
5878source code (@code{true} for diagnostics involving source encoding issues).
5879
5880@end table
5881
5882@node Warning Options
5883@section Options to Request or Suppress Warnings
5884@cindex options to control warnings
5885@cindex warning messages
5886@cindex messages, warning
5887@cindex suppressing warnings
5888
5889Warnings are diagnostic messages that report constructions that
5890are not inherently erroneous but that are risky or suggest there
5891may have been an error.
5892
5893The following language-independent options do not enable specific
5894warnings but control the kinds of diagnostics produced by GCC@.
5895
5896@table @gcctabopt
5897@cindex syntax checking
d77de738 5898@opindex fsyntax-only
ddf6fe37 5899@item -fsyntax-only
d77de738
ML
5900Check the code for syntax errors, but don't do anything beyond that.
5901
d77de738 5902@opindex fmax-errors
ddf6fe37 5903@item -fmax-errors=@var{n}
d77de738
ML
5904Limits the maximum number of error messages to @var{n}, at which point
5905GCC bails out rather than attempting to continue processing the source
5906code. If @var{n} is 0 (the default), there is no limit on the number
5907of error messages produced. If @option{-Wfatal-errors} is also
5908specified, then @option{-Wfatal-errors} takes precedence over this
5909option.
5910
d77de738 5911@opindex w
ddf6fe37 5912@item -w
d77de738
ML
5913Inhibit all warning messages.
5914
d77de738
ML
5915@opindex Werror
5916@opindex Wno-error
ddf6fe37 5917@item -Werror
d77de738
ML
5918Make all warnings into errors.
5919
d77de738
ML
5920@opindex Werror=
5921@opindex Wno-error=
ddf6fe37 5922@item -Werror=
d77de738
ML
5923Make the specified warning into an error. The specifier for a warning
5924is appended; for example @option{-Werror=switch} turns the warnings
5925controlled by @option{-Wswitch} into errors. This switch takes a
5926negative form, to be used to negate @option{-Werror} for specific
5927warnings; for example @option{-Wno-error=switch} makes
5928@option{-Wswitch} warnings not be errors, even when @option{-Werror}
5929is in effect.
5930
5931The warning message for each controllable warning includes the
5932option that controls the warning. That option can then be used with
5933@option{-Werror=} and @option{-Wno-error=} as described above.
5934(Printing of the option in the warning message can be disabled using the
5935@option{-fno-diagnostics-show-option} flag.)
5936
5937Note that specifying @option{-Werror=}@var{foo} automatically implies
5938@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5939imply anything.
5940
d77de738
ML
5941@opindex Wfatal-errors
5942@opindex Wno-fatal-errors
ddf6fe37 5943@item -Wfatal-errors
d77de738
ML
5944This option causes the compiler to abort compilation on the first error
5945occurred rather than trying to keep going and printing further error
5946messages.
5947
5948@end table
5949
5950You can request many specific warnings with options beginning with
5951@samp{-W}, for example @option{-Wimplicit} to request warnings on
5952implicit declarations. Each of these specific warning options also
5953has a negative form beginning @samp{-Wno-} to turn off warnings; for
5954example, @option{-Wno-implicit}. This manual lists only one of the
5955two forms, whichever is not the default. For further
5956language-specific options also refer to @ref{C++ Dialect Options} and
5957@ref{Objective-C and Objective-C++ Dialect Options}.
5958Additional warnings can be produced by enabling the static analyzer;
5959@xref{Static Analyzer Options}.
5960
5961Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5962options, such as @option{-Wunused}, which may turn on further options,
5963such as @option{-Wunused-value}. The combined effect of positive and
5964negative forms is that more specific options have priority over less
5965specific ones, independently of their position in the command-line. For
5966options of the same specificity, the last one takes effect. Options
5967enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5968as if they appeared at the end of the command-line.
5969
5970When an unrecognized warning option is requested (e.g.,
5971@option{-Wunknown-warning}), GCC emits a diagnostic stating
5972that the option is not recognized. However, if the @option{-Wno-} form
5973is used, the behavior is slightly different: no diagnostic is
5974produced for @option{-Wno-unknown-warning} unless other diagnostics
5975are being produced. This allows the use of new @option{-Wno-} options
5976with old compilers, but if something goes wrong, the compiler
5977warns that an unrecognized option is present.
5978
5979The effectiveness of some warnings depends on optimizations also being
5980enabled. For example @option{-Wsuggest-final-types} is more effective
5981with link-time optimization and some instances of other warnings may
5982not be issued at all unless optimization is enabled. While optimization
5983in general improves the efficacy of control and data flow sensitive
5984warnings, in some cases it may also cause false positives.
5985
5986@table @gcctabopt
d77de738
ML
5987@opindex pedantic
5988@opindex Wpedantic
5989@opindex Wno-pedantic
ddf6fe37
AA
5990@item -Wpedantic
5991@itemx -pedantic
d77de738 5992Issue all the warnings demanded by strict ISO C and ISO C++;
5fccebdb
JM
5993diagnose all programs that use forbidden extensions, and some other
5994programs that do not follow ISO C and ISO C++. This follows the version
5995of the ISO C or C++ standard specified by any @option{-std} option used.
d77de738
ML
5996
5997Valid ISO C and ISO C++ programs should compile properly with or without
5998this option (though a rare few require @option{-ansi} or a
5fccebdb 5999@option{-std} option specifying the version of the standard)@. However,
d77de738 6000without this option, certain GNU extensions and traditional C and C++
5fccebdb
JM
6001features are supported as well. With this option, they are diagnosed
6002(or rejected with @option{-pedantic-errors}).
d77de738
ML
6003
6004@option{-Wpedantic} does not cause warning messages for use of the
6005alternate keywords whose names begin and end with @samp{__}. This alternate
6006format can also be used to disable warnings for non-ISO @samp{__intN} types,
6007i.e. @samp{__intN__}.
6008Pedantic warnings are also disabled in the expression that follows
6009@code{__extension__}. However, only system header files should use
6010these escape routes; application programs should avoid them.
6011@xref{Alternate Keywords}.
6012
5fccebdb
JM
6013Some warnings about non-conforming programs are controlled by options
6014other than @option{-Wpedantic}; in many cases they are implied by
6015@option{-Wpedantic} but can be disabled separately by their specific
6016option, e.g. @option{-Wpedantic -Wno-pointer-sign}.
d77de738
ML
6017
6018Where the standard specified with @option{-std} represents a GNU
6019extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6020corresponding @dfn{base standard}, the version of ISO C on which the GNU
6021extended dialect is based. Warnings from @option{-Wpedantic} are given
6022where they are required by the base standard. (It does not make sense
6023for such warnings to be given only for features not in the specified GNU
6024C dialect, since by definition the GNU dialects of C include all
6025features the compiler supports with the given option, and there would be
6026nothing to warn about.)
6027
d77de738 6028@opindex pedantic-errors
ddf6fe37 6029@item -pedantic-errors
d77de738
ML
6030Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6031requires a diagnostic, in some cases where there is undefined behavior
6032at compile-time and in some other cases that do not prevent compilation
6033of programs that are valid according to the standard. This is not
5fccebdb
JM
6034equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be
6035useful, as it only makes errors of the diagnostics that are controlled by
6036@option{-Wpedantic}, whereas this option also affects required diagnostics that
6037are always enabled or controlled by options other than @option{-Wpedantic}.
6038
6039If you want the required diagnostics that are warnings by default to
6040be errors instead, but don't also want to enable the @option{-Wpedantic}
6041diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic}
6042(or @option{-pedantic-errors -Wno-error=pedantic} to enable them but
6043only as warnings).
6044
6045Some required diagnostics are errors by default, but can be reduced to
6046warnings using @option{-fpermissive} or their specific warning option,
6047e.g. @option{-Wno-error=narrowing}.
6048
6049Some diagnostics for non-ISO practices are controlled by specific
6050warning options other than @option{-Wpedantic}, but are also made
6051errors by @option{-pedantic-errors}. For instance:
6052
6053@gccoptlist{
6054-Wattributes @r{(for standard attributes)}
6055-Wchanges-meaning @r{(C++)}
6056-Wcomma-subscript @r{(C++23 or later)}
6057-Wdeclaration-after-statement @r{(C90 or earlier)}
6058-Wimplicit-int @r{(C99 or later)}
6059-Wimplicit-function-declaration @r{(C99 or later)}
6060-Wincompatible-pointer-types
6061-Wint-conversion
6062-Wlong-long @r{(C90 or earlier)}
6063-Wmain
6064-Wnarrowing @r{(C++11 or later)}
6065-Wpointer-arith
6066-Wpointer-sign
6067-Wincompatible-pointer-types
6068-Wregister @r{(C++17 or later)}
6069-Wvla @r{(C90 or earlier)}
6070-Wwrite-strings @r{(C++11 or later)}
6071}
d77de738 6072
d77de738
ML
6073@opindex Wall
6074@opindex Wno-all
ddf6fe37 6075@item -Wall
d77de738
ML
6076This enables all the warnings about constructions that some users
6077consider questionable, and that are easy to avoid (or modify to
6078prevent the warning), even in conjunction with macros. This also
6079enables some language-specific warnings described in @ref{C++ Dialect
6080Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6081
6082@option{-Wall} turns on the following warning flags:
6083
43b72ede
AA
6084@gccoptlist{-Waddress
6085-Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6086-Warray-compare
6087-Warray-parameter=2 @r{(C and Objective-C only)}
6088-Wbool-compare
6089-Wbool-operation
6090-Wc++11-compat -Wc++14-compat
6091-Wcatch-value @r{(C++ and Objective-C++ only)}
6092-Wchar-subscripts
6093-Wcomment
6094-Wdangling-pointer=2
6095-Wduplicate-decl-specifier @r{(C and Objective-C only)}
6096-Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6097-Wenum-int-mismatch @r{(C and Objective-C only)}
6098-Wformat
6099-Wformat-overflow
6100-Wformat-truncation
6101-Wint-in-bool-context
6102-Wimplicit @r{(C and Objective-C only)}
6103-Wimplicit-int @r{(C and Objective-C only)}
6104-Wimplicit-function-declaration @r{(C and Objective-C only)}
6105-Winit-self @r{(only for C++)}
6106-Wlogical-not-parentheses
6107-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6108-Wmaybe-uninitialized
6109-Wmemset-elt-size
6110-Wmemset-transposed-args
6111-Wmisleading-indentation @r{(only for C/C++)}
6112-Wmismatched-dealloc
6113-Wmismatched-new-delete @r{(only for C/C++)}
6114-Wmissing-attributes
6115-Wmissing-braces @r{(only for C/ObjC)}
6116-Wmultistatement-macros
6117-Wnarrowing @r{(only for C++)}
6118-Wnonnull
6119-Wnonnull-compare
6120-Wopenmp-simd
6121-Wparentheses
6122-Wpessimizing-move @r{(only for C++)}
6123-Wpointer-sign
6124-Wrange-loop-construct @r{(only for C++)}
6125-Wreorder
6126-Wrestrict
6127-Wreturn-type
6128-Wself-move @r{(only for C++)}
6129-Wsequence-point
6130-Wsign-compare @r{(only in C++)}
6131-Wsizeof-array-div
6132-Wsizeof-pointer-div
6133-Wsizeof-pointer-memaccess
6134-Wstrict-aliasing
6135-Wstrict-overflow=1
6136-Wswitch
6137-Wtautological-compare
6138-Wtrigraphs
6139-Wuninitialized
6140-Wunknown-pragmas
6141-Wunused-function
6142-Wunused-label
6143-Wunused-value
6144-Wunused-variable
6145-Wuse-after-free=2
6146-Wvla-parameter @r{(C and Objective-C only)}
6147-Wvolatile-register-var
d77de738
ML
6148-Wzero-length-bounds}
6149
6150Note that some warning flags are not implied by @option{-Wall}. Some of
6151them warn about constructions that users generally do not consider
6152questionable, but which occasionally you might wish to check for;
6153others warn about constructions that are necessary or hard to avoid in
6154some cases, and there is no simple way to modify the code to suppress
6155the warning. Some of them are enabled by @option{-Wextra} but many of
6156them must be enabled individually.
6157
d77de738
ML
6158@opindex W
6159@opindex Wextra
6160@opindex Wno-extra
ddf6fe37 6161@item -Wextra
d77de738
ML
6162This enables some extra warning flags that are not enabled by
6163@option{-Wall}. (This option used to be called @option{-W}. The older
6164name is still supported, but the newer name is more descriptive.)
6165
43b72ede
AA
6166@gccoptlist{-Wclobbered
6167-Wcast-function-type
6168-Wdeprecated-copy @r{(C++ only)}
6169-Wempty-body
6170-Wenum-conversion @r{(C only)}
6171-Wignored-qualifiers
6172-Wimplicit-fallthrough=3
6173-Wmissing-field-initializers
6174-Wmissing-parameter-type @r{(C only)}
6175-Wold-style-declaration @r{(C only)}
6176-Woverride-init
6177-Wsign-compare @r{(C only)}
6178-Wstring-compare
6179-Wredundant-move @r{(only for C++)}
6180-Wtype-limits
6181-Wuninitialized
6182-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6183-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
d77de738
ML
6184-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6185
6186
6187The option @option{-Wextra} also prints warning messages for the
6188following cases:
6189
6190@itemize @bullet
6191
6192@item
6193A pointer is compared against integer zero with @code{<}, @code{<=},
6194@code{>}, or @code{>=}.
6195
6196@item
6197(C++ only) An enumerator and a non-enumerator both appear in a
6198conditional expression.
6199
6200@item
6201(C++ only) Ambiguous virtual bases.
6202
6203@item
6204(C++ only) Subscripting an array that has been declared @code{register}.
6205
6206@item
6207(C++ only) Taking the address of a variable that has been declared
6208@code{register}.
6209
6210@item
6211(C++ only) A base class is not initialized in the copy constructor
6212of a derived class.
6213
6214@end itemize
6215
d77de738
ML
6216@opindex Wabi
6217@opindex Wno-abi
ddf6fe37 6218@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
6219
6220Warn about code affected by ABI changes. This includes code that may
6221not be compatible with the vendor-neutral C++ ABI as well as the psABI
6222for the particular target.
6223
6224Since G++ now defaults to updating the ABI with each major release,
6225normally @option{-Wabi} warns only about C++ ABI compatibility
6226problems if there is a check added later in a release series for an
6227ABI issue discovered since the initial release. @option{-Wabi} warns
6228about more things if an older ABI version is selected (with
6229@option{-fabi-version=@var{n}}).
6230
6231@option{-Wabi} can also be used with an explicit version number to
6232warn about C++ ABI compatibility with a particular @option{-fabi-version}
6233level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6234@option{-fabi-version=2}.
6235
6236If an explicit version number is provided and
6237@option{-fabi-compat-version} is not specified, the version number
6238from this option is used for compatibility aliases. If no explicit
6239version number is provided with this option, but
6240@option{-fabi-compat-version} is specified, that version number is
6241used for C++ ABI warnings.
6242
6243Although an effort has been made to warn about
6244all such cases, there are probably some cases that are not warned about,
6245even though G++ is generating incompatible code. There may also be
6246cases where warnings are emitted even though the code that is generated
6247is compatible.
6248
6249You should rewrite your code to avoid these warnings if you are
6250concerned about the fact that code generated by G++ may not be binary
6251compatible with code generated by other compilers.
6252
6253Known incompatibilities in @option{-fabi-version=2} (which was the
6254default from GCC 3.4 to 4.9) include:
6255
6256@itemize @bullet
6257
6258@item
6259A template with a non-type template parameter of reference type was
6260mangled incorrectly:
6261@smallexample
6262extern int N;
6263template <int &> struct S @{@};
6264void n (S<N>) @{2@}
6265@end smallexample
6266
6267This was fixed in @option{-fabi-version=3}.
6268
6269@item
6270SIMD vector types declared using @code{__attribute ((vector_size))} were
6271mangled in a non-standard way that does not allow for overloading of
6272functions taking vectors of different sizes.
6273
6274The mangling was changed in @option{-fabi-version=4}.
6275
6276@item
6277@code{__attribute ((const))} and @code{noreturn} were mangled as type
6278qualifiers, and @code{decltype} of a plain declaration was folded away.
6279
6280These mangling issues were fixed in @option{-fabi-version=5}.
6281
6282@item
6283Scoped enumerators passed as arguments to a variadic function are
6284promoted like unscoped enumerators, causing @code{va_arg} to complain.
6285On most targets this does not actually affect the parameter passing
6286ABI, as there is no way to pass an argument smaller than @code{int}.
6287
6288Also, the ABI changed the mangling of template argument packs,
6289@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6290a class scope function used as a template argument.
6291
6292These issues were corrected in @option{-fabi-version=6}.
6293
6294@item
6295Lambdas in default argument scope were mangled incorrectly, and the
6296ABI changed the mangling of @code{nullptr_t}.
6297
6298These issues were corrected in @option{-fabi-version=7}.
6299
6300@item
6301When mangling a function type with function-cv-qualifiers, the
6302un-qualified function type was incorrectly treated as a substitution
6303candidate.
6304
6305This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6306
6307@item
6308@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6309unaligned accesses. Note that this did not affect the ABI of a
6310function with a @code{nullptr_t} parameter, as parameters have a
6311minimum alignment.
6312
6313This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6314
6315@item
6316Target-specific attributes that affect the identity of a type, such as
6317ia32 calling conventions on a function type (stdcall, regparm, etc.),
6318did not affect the mangled name, leading to name collisions when
6319function pointers were used as template arguments.
6320
6321This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6322
6323@end itemize
6324
6325This option also enables warnings about psABI-related changes.
6326The known psABI changes at this point include:
6327
6328@itemize @bullet
6329
6330@item
6331For SysV/x86-64, unions with @code{long double} members are
6332passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6333the case. For example:
6334
6335@smallexample
6336union U @{
6337 long double ld;
6338 int i;
6339@};
6340@end smallexample
6341
6342@noindent
6343@code{union U} is now always passed in memory.
6344
6345@end itemize
6346
e2f939d3
JM
6347@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6348C++ requires that unqualified uses of a name within a class have the
6349same meaning in the complete scope of the class, so declaring the name
6350after using it is ill-formed:
6351@smallexample
6352struct A;
6353struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6354struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6355@end smallexample
6356By default, the B1 case is only a warning because the two declarations
6357have the same type, while the B2 case is an error. Both diagnostics
6358can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6359error case can be reduced to a warning with
6360@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6361
6362Both diagnostics are also suppressed by @option{-fms-extensions}.
6363
d77de738
ML
6364@opindex Wchar-subscripts
6365@opindex Wno-char-subscripts
ddf6fe37 6366@item -Wchar-subscripts
d77de738
ML
6367Warn if an array subscript has type @code{char}. This is a common cause
6368of error, as programmers often forget that this type is signed on some
6369machines.
6370This warning is enabled by @option{-Wall}.
6371
d77de738
ML
6372@opindex Wno-coverage-mismatch
6373@opindex Wcoverage-mismatch
ddf6fe37 6374@item -Wno-coverage-mismatch
d77de738
ML
6375Warn if feedback profiles do not match when using the
6376@option{-fprofile-use} option.
6377If a source file is changed between compiling with @option{-fprofile-generate}
6378and with @option{-fprofile-use}, the files with the profile feedback can fail
6379to match the source file and GCC cannot use the profile feedback
6380information. By default, this warning is enabled and is treated as an
6381error. @option{-Wno-coverage-mismatch} can be used to disable the
6382warning or @option{-Wno-error=coverage-mismatch} can be used to
6383disable the error. Disabling the error for this warning can result in
6384poorly optimized code and is useful only in the
6385case of very minor changes such as bug fixes to an existing code-base.
6386Completely disabling the warning is not recommended.
6387
d77de738
ML
6388@opindex Wno-coverage-invalid-line-number
6389@opindex Wcoverage-invalid-line-number
ddf6fe37 6390@item -Wno-coverage-invalid-line-number
d77de738
ML
6391Warn in case a function ends earlier than it begins due
6392to an invalid linenum macros. The warning is emitted only
6393with @option{--coverage} enabled.
6394
6395By default, this warning is enabled and is treated as an
6396error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6397warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6398disable the error.
6399
d77de738
ML
6400@opindex Wno-cpp
6401@opindex Wcpp
ddf6fe37 6402@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
d77de738
ML
6403Suppress warning messages emitted by @code{#warning} directives.
6404
d77de738
ML
6405@opindex Wdouble-promotion
6406@opindex Wno-double-promotion
ddf6fe37 6407@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6408Give a warning when a value of type @code{float} is implicitly
6409promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6410floating-point unit implement @code{float} in hardware, but emulate
6411@code{double} in software. On such a machine, doing computations
6412using @code{double} values is much more expensive because of the
6413overhead required for software emulation.
6414
6415It is easy to accidentally do computations with @code{double} because
6416floating-point literals are implicitly of type @code{double}. For
6417example, in:
6418@smallexample
6419@group
6420float area(float radius)
6421@{
6422 return 3.14159 * radius * radius;
6423@}
6424@end group
6425@end smallexample
6426the compiler performs the entire computation with @code{double}
6427because the floating-point literal is a @code{double}.
6428
d77de738
ML
6429@opindex Wduplicate-decl-specifier
6430@opindex Wno-duplicate-decl-specifier
ddf6fe37 6431@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
d77de738
ML
6432Warn if a declaration has duplicate @code{const}, @code{volatile},
6433@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6434@option{-Wall}.
6435
d77de738
ML
6436@opindex Wformat
6437@opindex Wno-format
6438@opindex ffreestanding
6439@opindex fno-builtin
6440@opindex Wformat=
ddf6fe37
AA
6441@item -Wformat
6442@itemx -Wformat=@var{n}
d77de738
ML
6443Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6444the arguments supplied have types appropriate to the format string
6445specified, and that the conversions specified in the format string make
6446sense. This includes standard functions, and others specified by format
6447attributes (@pxref{Function Attributes}), in the @code{printf},
6448@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6449not in the C standard) families (or other target-specific families).
6450Which functions are checked without format attributes having been
6451specified depends on the standard version selected, and such checks of
6452functions without the attribute specified are disabled by
6453@option{-ffreestanding} or @option{-fno-builtin}.
6454
6455The formats are checked against the format features supported by GNU
6456libc version 2.2. These include all ISO C90 and C99 features, as well
6457as features from the Single Unix Specification and some BSD and GNU
6458extensions. Other library implementations may not support all these
6459features; GCC does not support warning about features that go beyond a
6460particular library's limitations. However, if @option{-Wpedantic} is used
6461with @option{-Wformat}, warnings are given about format features not
6462in the selected standard version (but not for @code{strfmon} formats,
6463since those are not in any version of the C standard). @xref{C Dialect
6464Options,,Options Controlling C Dialect}.
6465
6466@table @gcctabopt
d77de738
ML
6467@opindex Wformat
6468@opindex Wformat=1
ddf6fe37
AA
6469@item -Wformat=1
6470@itemx -Wformat
d77de738
ML
6471Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6472@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6473@option{-Wformat} also checks for null format arguments for several
6474functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6475aspects of this level of format checking can be disabled by the
6476options: @option{-Wno-format-contains-nul},
6477@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6478@option{-Wformat} is enabled by @option{-Wall}.
6479
d77de738 6480@opindex Wformat=2
ddf6fe37 6481@item -Wformat=2
d77de738
ML
6482Enable @option{-Wformat} plus additional format checks. Currently
6483equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6484-Wformat-y2k}.
6485@end table
6486
d77de738
ML
6487@opindex Wno-format-contains-nul
6488@opindex Wformat-contains-nul
ddf6fe37 6489@item -Wno-format-contains-nul
d77de738
ML
6490If @option{-Wformat} is specified, do not warn about format strings that
6491contain NUL bytes.
6492
d77de738
ML
6493@opindex Wno-format-extra-args
6494@opindex Wformat-extra-args
ddf6fe37 6495@item -Wno-format-extra-args
d77de738
ML
6496If @option{-Wformat} is specified, do not warn about excess arguments to a
6497@code{printf} or @code{scanf} format function. The C standard specifies
6498that such arguments are ignored.
6499
6500Where the unused arguments lie between used arguments that are
6501specified with @samp{$} operand number specifications, normally
6502warnings are still given, since the implementation could not know what
6503type to pass to @code{va_arg} to skip the unused arguments. However,
6504in the case of @code{scanf} formats, this option suppresses the
6505warning if the unused arguments are all pointers, since the Single
6506Unix Specification says that such unused arguments are allowed.
6507
d77de738
ML
6508@opindex Wformat-overflow
6509@opindex Wno-format-overflow
ddf6fe37
AA
6510@item -Wformat-overflow
6511@itemx -Wformat-overflow=@var{level}
d77de738
ML
6512Warn about calls to formatted input/output functions such as @code{sprintf}
6513and @code{vsprintf} that might overflow the destination buffer. When the
6514exact number of bytes written by a format directive cannot be determined
6515at compile-time it is estimated based on heuristics that depend on the
6516@var{level} argument and on optimization. While enabling optimization
6517will in most cases improve the accuracy of the warning, it may also
6518result in false positives.
6519
6520@table @gcctabopt
d77de738
ML
6521@opindex Wformat-overflow
6522@opindex Wno-format-overflow
ddf6fe37
AA
6523@item -Wformat-overflow
6524@itemx -Wformat-overflow=1
d77de738
ML
6525Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6526employs a conservative approach that warns only about calls that most
6527likely overflow the buffer. At this level, numeric arguments to format
6528directives with unknown values are assumed to have the value of one, and
6529strings of unknown length to be empty. Numeric arguments that are known
6530to be bounded to a subrange of their type, or string arguments whose output
6531is bounded either by their directive's precision or by a finite set of
6532string literals, are assumed to take on the value within the range that
6533results in the most bytes on output. For example, the call to @code{sprintf}
6534below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6535the terminating NUL character (@code{'\0'}) appended by the function
6536to the destination buffer will be written past its end. Increasing
6537the size of the buffer by a single byte is sufficient to avoid the
6538warning, though it may not be sufficient to avoid the overflow.
6539
6540@smallexample
6541void f (int a, int b)
6542@{
6543 char buf [13];
6544 sprintf (buf, "a = %i, b = %i\n", a, b);
6545@}
6546@end smallexample
6547
6548@item -Wformat-overflow=2
6549Level @var{2} warns also about calls that might overflow the destination
6550buffer given an argument of sufficient length or magnitude. At level
6551@var{2}, unknown numeric arguments are assumed to have the minimum
6552representable value for signed types with a precision greater than 1, and
6553the maximum representable value otherwise. Unknown string arguments whose
6554length cannot be assumed to be bounded either by the directive's precision,
6555or by a finite set of string literals they may evaluate to, or the character
6556array they may point to, are assumed to be 1 character long.
6557
6558At level @var{2}, the call in the example above is again diagnosed, but
6559this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6560@code{%i} directive will write some of its digits beyond the end of
6561the destination buffer. To make the call safe regardless of the values
6562of the two variables, the size of the destination buffer must be increased
6563to at least 34 bytes. GCC includes the minimum size of the buffer in
6564an informational note following the warning.
6565
6566An alternative to increasing the size of the destination buffer is to
6567constrain the range of formatted values. The maximum length of string
6568arguments can be bounded by specifying the precision in the format
6569directive. When numeric arguments of format directives can be assumed
6570to be bounded by less than the precision of their type, choosing
6571an appropriate length modifier to the format specifier will reduce
6572the required buffer size. For example, if @var{a} and @var{b} in the
6573example above can be assumed to be within the precision of
6574the @code{short int} type then using either the @code{%hi} format
6575directive or casting the argument to @code{short} reduces the maximum
6576required size of the buffer to 24 bytes.
6577
6578@smallexample
6579void f (int a, int b)
6580@{
6581 char buf [23];
6582 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6583@}
6584@end smallexample
6585@end table
6586
d77de738
ML
6587@opindex Wno-format-zero-length
6588@opindex Wformat-zero-length
ddf6fe37 6589@item -Wno-format-zero-length
d77de738
ML
6590If @option{-Wformat} is specified, do not warn about zero-length formats.
6591The C standard specifies that zero-length formats are allowed.
6592
d77de738
ML
6593@opindex Wformat-nonliteral
6594@opindex Wno-format-nonliteral
ddf6fe37 6595@item -Wformat-nonliteral
d77de738
ML
6596If @option{-Wformat} is specified, also warn if the format string is not a
6597string literal and so cannot be checked, unless the format function
6598takes its format arguments as a @code{va_list}.
6599
d77de738
ML
6600@opindex Wformat-security
6601@opindex Wno-format-security
ddf6fe37 6602@item -Wformat-security
d77de738
ML
6603If @option{-Wformat} is specified, also warn about uses of format
6604functions that represent possible security problems. At present, this
6605warns about calls to @code{printf} and @code{scanf} functions where the
6606format string is not a string literal and there are no format arguments,
6607as in @code{printf (foo);}. This may be a security hole if the format
6608string came from untrusted input and contains @samp{%n}. (This is
6609currently a subset of what @option{-Wformat-nonliteral} warns about, but
6610in future warnings may be added to @option{-Wformat-security} that are not
6611included in @option{-Wformat-nonliteral}.)
6612
d77de738
ML
6613@opindex Wformat-signedness
6614@opindex Wno-format-signedness
ddf6fe37 6615@item -Wformat-signedness
d77de738
ML
6616If @option{-Wformat} is specified, also warn if the format string
6617requires an unsigned argument and the argument is signed and vice versa.
6618
d77de738
ML
6619@opindex Wformat-truncation
6620@opindex Wno-format-truncation
ddf6fe37
AA
6621@item -Wformat-truncation
6622@itemx -Wformat-truncation=@var{level}
d77de738
ML
6623Warn about calls to formatted input/output functions such as @code{snprintf}
6624and @code{vsnprintf} that might result in output truncation. When the exact
6625number of bytes written by a format directive cannot be determined at
6626compile-time it is estimated based on heuristics that depend on
6627the @var{level} argument and on optimization. While enabling optimization
6628will in most cases improve the accuracy of the warning, it may also result
6629in false positives. Except as noted otherwise, the option uses the same
6630logic @option{-Wformat-overflow}.
6631
6632@table @gcctabopt
d77de738
ML
6633@opindex Wformat-truncation
6634@opindex Wno-format-truncation
ddf6fe37
AA
6635@item -Wformat-truncation
6636@itemx -Wformat-truncation=1
d77de738
ML
6637Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6638employs a conservative approach that warns only about calls to bounded
6639functions whose return value is unused and that will most likely result
6640in output truncation.
6641
6642@item -Wformat-truncation=2
6643Level @var{2} warns also about calls to bounded functions whose return
6644value is used and that might result in truncation given an argument of
6645sufficient length or magnitude.
6646@end table
6647
d77de738
ML
6648@opindex Wformat-y2k
6649@opindex Wno-format-y2k
ddf6fe37 6650@item -Wformat-y2k
d77de738
ML
6651If @option{-Wformat} is specified, also warn about @code{strftime}
6652formats that may yield only a two-digit year.
6653
d77de738
ML
6654@opindex Wnonnull
6655@opindex Wno-nonnull
ddf6fe37 6656@item -Wnonnull
d77de738
ML
6657Warn about passing a null pointer for arguments marked as
6658requiring a non-null value by the @code{nonnull} function attribute.
6659
6660@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6661can be disabled with the @option{-Wno-nonnull} option.
6662
d77de738
ML
6663@opindex Wnonnull-compare
6664@opindex Wno-nonnull-compare
ddf6fe37 6665@item -Wnonnull-compare
d77de738
ML
6666Warn when comparing an argument marked with the @code{nonnull}
6667function attribute against null inside the function.
6668
6669@option{-Wnonnull-compare} is included in @option{-Wall}. It
6670can be disabled with the @option{-Wno-nonnull-compare} option.
6671
d77de738
ML
6672@opindex Wnull-dereference
6673@opindex Wno-null-dereference
ddf6fe37 6674@item -Wnull-dereference
d77de738
ML
6675Warn if the compiler detects paths that trigger erroneous or
6676undefined behavior due to dereferencing a null pointer. This option
6677is only active when @option{-fdelete-null-pointer-checks} is active,
6678which is enabled by optimizations in most targets. The precision of
6679the warnings depends on the optimization options used.
6680
2ae5384d
JM
6681@opindex Wnrvo
6682@opindex Wno-nrvo
6683@item -Wnrvo @r{(C++ and Objective-C++ only)}
6684Warn if the compiler does not elide the copy from a local variable to
6685the return value of a function in a context where it is allowed by
6686[class.copy.elision]. This elision is commonly known as the Named
6687Return Value Optimization. For instance, in the example below the
6688compiler cannot elide copies from both v1 and b2, so it elides neither.
6689
6690@smallexample
6691std::vector<int> f()
6692@{
6693 std::vector<int> v1, v2;
6694 // ...
6695 if (cond) return v1;
6696 else return v2; // warning: not eliding copy
6697@}
6698@end smallexample
6699
d77de738
ML
6700@opindex Winfinite-recursion
6701@opindex Wno-infinite-recursion
ddf6fe37 6702@item -Winfinite-recursion
d77de738
ML
6703Warn about infinitely recursive calls. The warning is effective at all
6704optimization levels but requires optimization in order to detect infinite
6705recursion in calls between two or more functions.
6706@option{-Winfinite-recursion} is included in @option{-Wall}.
6707
ce51e843
ML
6708Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6709similar diagnostic, but is implemented in a different way (as part of
6710@option{-fanalyzer}).
6711
d77de738
ML
6712@opindex Winit-self
6713@opindex Wno-init-self
ddf6fe37 6714@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6715Warn about uninitialized variables that are initialized with themselves.
6716Note this option can only be used with the @option{-Wuninitialized} option.
6717
6718For example, GCC warns about @code{i} being uninitialized in the
6719following snippet only when @option{-Winit-self} has been specified:
6720@smallexample
6721@group
6722int f()
6723@{
6724 int i = i;
6725 return i;
6726@}
6727@end group
6728@end smallexample
6729
6730This warning is enabled by @option{-Wall} in C++.
6731
d77de738
ML
6732@opindex Wimplicit-int
6733@opindex Wno-implicit-int
ddf6fe37 6734@item -Wno-implicit-int @r{(C and Objective-C only)}
d77de738
ML
6735This option controls warnings when a declaration does not specify a type.
6736This warning is enabled by default in C99 and later dialects of C,
6737and also by @option{-Wall}.
6738
5fccebdb
JM
6739This warning is upgraded to an error by @option{-pedantic-errors}.
6740
d77de738
ML
6741@opindex Wimplicit-function-declaration
6742@opindex Wno-implicit-function-declaration
ddf6fe37 6743@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
d77de738
ML
6744This option controls warnings when a function is used before being declared.
6745This warning is enabled by default in C99 and later dialects of C,
6746and also by @option{-Wall}.
5fccebdb
JM
6747
6748This warning is upgraded to an error by @option{-pedantic-errors}.
d77de738 6749
d77de738
ML
6750@opindex Wimplicit
6751@opindex Wno-implicit
ddf6fe37 6752@item -Wimplicit @r{(C and Objective-C only)}
d77de738
ML
6753Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6754This warning is enabled by @option{-Wall}.
6755
d77de738
ML
6756@opindex Wimplicit-fallthrough
6757@opindex Wno-implicit-fallthrough
ddf6fe37 6758@item -Wimplicit-fallthrough
d77de738
ML
6759@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6760and @option{-Wno-implicit-fallthrough} is the same as
6761@option{-Wimplicit-fallthrough=0}.
6762
d77de738 6763@opindex Wimplicit-fallthrough=
ddf6fe37 6764@item -Wimplicit-fallthrough=@var{n}
d77de738
ML
6765Warn when a switch case falls through. For example:
6766
6767@smallexample
6768@group
6769switch (cond)
6770 @{
6771 case 1:
6772 a = 1;
6773 break;
6774 case 2:
6775 a = 2;
6776 case 3:
6777 a = 3;
6778 break;
6779 @}
6780@end group
6781@end smallexample
6782
6783This warning does not warn when the last statement of a case cannot
6784fall through, e.g. when there is a return statement or a call to function
6785declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6786also takes into account control flow statements, such as ifs, and only
6787warns when appropriate. E.g.@:
6788
6789@smallexample
6790@group
6791switch (cond)
6792 @{
6793 case 1:
6794 if (i > 3) @{
6795 bar (5);
6796 break;
6797 @} else if (i < 1) @{
6798 bar (0);
6799 @} else
6800 return;
6801 default:
6802 @dots{}
6803 @}
6804@end group
6805@end smallexample
6806
6807Since there are occasions where a switch case fall through is desirable,
6808GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6809to be used along with a null statement to suppress this warning that
6810would normally occur:
6811
6812@smallexample
6813@group
6814switch (cond)
6815 @{
6816 case 1:
6817 bar (0);
6818 __attribute__ ((fallthrough));
6819 default:
6820 @dots{}
6821 @}
6822@end group
6823@end smallexample
6824
6825C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6826warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6827or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6828Instead of these attributes, it is also possible to add a fallthrough comment
6829to silence the warning. The whole body of the C or C++ style comment should
6830match the given regular expressions listed below. The option argument @var{n}
6831specifies what kind of comments are accepted:
6832
6833@itemize @bullet
6834
6835@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6836
6837@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6838expression, any comment is used as fallthrough comment.
6839
6840@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6841@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6842
6843@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6844following regular expressions:
6845
6846@itemize @bullet
6847
6848@item @code{-fallthrough}
6849
6850@item @code{@@fallthrough@@}
6851
6852@item @code{lint -fallthrough[ \t]*}
6853
6854@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6855
6856@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6857
6858@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6859
6860@end itemize
6861
6862@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6863following regular expressions:
6864
6865@itemize @bullet
6866
6867@item @code{-fallthrough}
6868
6869@item @code{@@fallthrough@@}
6870
6871@item @code{lint -fallthrough[ \t]*}
6872
6873@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6874
6875@end itemize
6876
6877@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6878fallthrough comments, only attributes disable the warning.
6879
6880@end itemize
6881
6882The comment needs to be followed after optional whitespace and other comments
6883by @code{case} or @code{default} keywords or by a user label that precedes some
6884@code{case} or @code{default} label.
6885
6886@smallexample
6887@group
6888switch (cond)
6889 @{
6890 case 1:
6891 bar (0);
6892 /* FALLTHRU */
6893 default:
6894 @dots{}
6895 @}
6896@end group
6897@end smallexample
6898
6899The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6900
d77de738
ML
6901@opindex Wif-not-aligned
6902@opindex Wno-if-not-aligned
ddf6fe37 6903@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6904Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6905should be issued. These warnings are enabled by default.
6906
d77de738
ML
6907@opindex Wignored-qualifiers
6908@opindex Wno-ignored-qualifiers
ddf6fe37 6909@item -Wignored-qualifiers @r{(C and C++ only)}
d77de738
ML
6910Warn if the return type of a function has a type qualifier
6911such as @code{const}. For ISO C such a type qualifier has no effect,
6912since the value returned by a function is not an lvalue.
6913For C++, the warning is only emitted for scalar types or @code{void}.
6914ISO C prohibits qualified @code{void} return types on function
6915definitions, so such return types always receive a warning
6916even without this option.
6917
6918This warning is also enabled by @option{-Wextra}.
6919
d77de738
ML
6920@opindex Wignored-attributes
6921@opindex Wno-ignored-attributes
ddf6fe37 6922@item -Wno-ignored-attributes @r{(C and C++ only)}
d77de738
ML
6923This option controls warnings when an attribute is ignored.
6924This is different from the
6925@option{-Wattributes} option in that it warns whenever the compiler decides
6926to drop an attribute, not that the attribute is either unknown, used in a
6927wrong place, etc. This warning is enabled by default.
6928
d77de738
ML
6929@opindex Wmain
6930@opindex Wno-main
ddf6fe37 6931@item -Wmain
d77de738
ML
6932Warn if the type of @code{main} is suspicious. @code{main} should be
6933a function with external linkage, returning int, taking either zero
6934arguments, two, or three arguments of appropriate types. This warning
6935is enabled by default in C++ and is enabled by either @option{-Wall}
6936or @option{-Wpedantic}.
6937
5fccebdb
JM
6938This warning is upgraded to an error by @option{-pedantic-errors}.
6939
d77de738
ML
6940@opindex Wmisleading-indentation
6941@opindex Wno-misleading-indentation
ddf6fe37 6942@item -Wmisleading-indentation @r{(C and C++ only)}
d77de738
ML
6943Warn when the indentation of the code does not reflect the block structure.
6944Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6945@code{for} clauses with a guarded statement that does not use braces,
6946followed by an unguarded statement with the same indentation.
6947
6948In the following example, the call to ``bar'' is misleadingly indented as
6949if it were guarded by the ``if'' conditional.
6950
6951@smallexample
6952 if (some_condition ())
6953 foo ();
6954 bar (); /* Gotcha: this is not guarded by the "if". */
6955@end smallexample
6956
6957In the case of mixed tabs and spaces, the warning uses the
6958@option{-ftabstop=} option to determine if the statements line up
6959(defaulting to 8).
6960
6961The warning is not issued for code involving multiline preprocessor logic
6962such as the following example.
6963
6964@smallexample
6965 if (flagA)
6966 foo (0);
6967#if SOME_CONDITION_THAT_DOES_NOT_HOLD
6968 if (flagB)
6969#endif
6970 foo (1);
6971@end smallexample
6972
6973The warning is not issued after a @code{#line} directive, since this
6974typically indicates autogenerated code, and no assumptions can be made
6975about the layout of the file that the directive references.
6976
6977This warning is enabled by @option{-Wall} in C and C++.
6978
d77de738
ML
6979@opindex Wmissing-attributes
6980@opindex Wno-missing-attributes
ddf6fe37 6981@item -Wmissing-attributes
d77de738
ML
6982Warn when a declaration of a function is missing one or more attributes
6983that a related function is declared with and whose absence may adversely
6984affect the correctness or efficiency of generated code. For example,
6985the warning is issued for declarations of aliases that use attributes
6986to specify less restrictive requirements than those of their targets.
6987This typically represents a potential optimization opportunity.
6988By contrast, the @option{-Wattribute-alias=2} option controls warnings
6989issued when the alias is more restrictive than the target, which could
6990lead to incorrect code generation.
6991Attributes considered include @code{alloc_align}, @code{alloc_size},
6992@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6993@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6994@code{returns_nonnull}, and @code{returns_twice}.
6995
6996In C++, the warning is issued when an explicit specialization of a primary
6997template declared with attribute @code{alloc_align}, @code{alloc_size},
6998@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6999or @code{nonnull} is declared without it. Attributes @code{deprecated},
7000@code{error}, and @code{warning} suppress the warning.
7001(@pxref{Function Attributes}).
7002
7003You can use the @code{copy} attribute to apply the same
7004set of attributes to a declaration as that on another declaration without
7005explicitly enumerating the attributes. This attribute can be applied
7006to declarations of functions (@pxref{Common Function Attributes}),
7007variables (@pxref{Common Variable Attributes}), or types
7008(@pxref{Common Type Attributes}).
7009
7010@option{-Wmissing-attributes} is enabled by @option{-Wall}.
7011
7012For example, since the declaration of the primary function template
7013below makes use of both attribute @code{malloc} and @code{alloc_size}
7014the declaration of the explicit specialization of the template is
7015diagnosed because it is missing one of the attributes.
7016
7017@smallexample
7018template <class T>
7019T* __attribute__ ((malloc, alloc_size (1)))
7020allocate (size_t);
7021
7022template <>
7023void* __attribute__ ((malloc)) // missing alloc_size
7024allocate<void> (size_t);
7025@end smallexample
7026
d77de738
ML
7027@opindex Wmissing-braces
7028@opindex Wno-missing-braces
ddf6fe37 7029@item -Wmissing-braces
d77de738
ML
7030Warn if an aggregate or union initializer is not fully bracketed. In
7031the following example, the initializer for @code{a} is not fully
7032bracketed, but that for @code{b} is fully bracketed.
7033
7034@smallexample
7035int a[2][2] = @{ 0, 1, 2, 3 @};
7036int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
7037@end smallexample
7038
7039This warning is enabled by @option{-Wall}.
7040
d77de738
ML
7041@opindex Wmissing-include-dirs
7042@opindex Wno-missing-include-dirs
ddf6fe37 7043@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
d77de738
ML
7044Warn if a user-supplied include directory does not exist. This opions is disabled
7045by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
7046enabled by default by warning for -I and -J, only.
7047
d77de738
ML
7048@opindex Wmissing-profile
7049@opindex Wno-missing-profile
ddf6fe37 7050@item -Wno-missing-profile
d77de738
ML
7051This option controls warnings if feedback profiles are missing when using the
7052@option{-fprofile-use} option.
7053This option diagnoses those cases where a new function or a new file is added
7054between compiling with @option{-fprofile-generate} and with
7055@option{-fprofile-use}, without regenerating the profiles.
7056In these cases, the profile feedback data files do not contain any
7057profile feedback information for
7058the newly added function or file respectively. Also, in the case when profile
7059count data (.gcda) files are removed, GCC cannot use any profile feedback
7060information. In all these cases, warnings are issued to inform you that a
7061profile generation step is due.
7062Ignoring the warning can result in poorly optimized code.
7063@option{-Wno-missing-profile} can be used to
7064disable the warning, but this is not recommended and should be done only
7065when non-existent profile data is justified.
7066
d77de738
ML
7067@opindex Wmismatched-dealloc
7068@opindex Wno-mismatched-dealloc
ddf6fe37 7069@item -Wmismatched-dealloc
d77de738
ML
7070
7071Warn for calls to deallocation functions with pointer arguments returned
7072from from allocations functions for which the former isn't a suitable
7073deallocator. A pair of functions can be associated as matching allocators
7074and deallocators by use of attribute @code{malloc}. Unless disabled by
7075the @option{-fno-builtin} option the standard functions @code{calloc},
7076@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7077forms of C++ @code{operator new} and @code{operator delete} are implicitly
7078associated as matching allocators and deallocators. In the following
7079example @code{mydealloc} is the deallocator for pointers returned from
7080@code{myalloc}.
7081
7082@smallexample
7083void mydealloc (void*);
7084
7085__attribute__ ((malloc (mydealloc, 1))) void*
7086myalloc (size_t);
7087
7088void f (void)
7089@{
7090 void *p = myalloc (32);
7091 // @dots{}use p@dots{}
7092 free (p); // warning: not a matching deallocator for myalloc
7093 mydealloc (p); // ok
7094@}
7095@end smallexample
7096
7097In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7098mismatches involving either @code{operator new} or @code{operator delete}.
7099
7100Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7101
d77de738
ML
7102@opindex Wmultistatement-macros
7103@opindex Wno-multistatement-macros
ddf6fe37 7104@item -Wmultistatement-macros
d77de738
ML
7105Warn about unsafe multiple statement macros that appear to be guarded
7106by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7107@code{while}, in which only the first statement is actually guarded after
7108the macro is expanded.
7109
7110For example:
7111
7112@smallexample
7113#define DOIT x++; y++
7114if (c)
7115 DOIT;
7116@end smallexample
7117
7118will increment @code{y} unconditionally, not just when @code{c} holds.
7119The can usually be fixed by wrapping the macro in a do-while loop:
7120@smallexample
7121#define DOIT do @{ x++; y++; @} while (0)
7122if (c)
7123 DOIT;
7124@end smallexample
7125
7126This warning is enabled by @option{-Wall} in C and C++.
7127
d77de738
ML
7128@opindex Wparentheses
7129@opindex Wno-parentheses
ddf6fe37 7130@item -Wparentheses
d77de738
ML
7131Warn if parentheses are omitted in certain contexts, such
7132as when there is an assignment in a context where a truth value
7133is expected, or when operators are nested whose precedence people
7134often get confused about.
7135
7136Also warn if a comparison like @code{x<=y<=z} appears; this is
7137equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7138interpretation from that of ordinary mathematical notation.
7139
7140Also warn for dangerous uses of the GNU extension to
7141@code{?:} with omitted middle operand. When the condition
7142in the @code{?}: operator is a boolean expression, the omitted value is
7143always 1. Often programmers expect it to be a value computed
7144inside the conditional expression instead.
7145
7146For C++ this also warns for some cases of unnecessary parentheses in
7147declarations, which can indicate an attempt at a function call instead
7148of a declaration:
7149@smallexample
7150@{
7151 // Declares a local variable called mymutex.
7152 std::unique_lock<std::mutex> (mymutex);
7153 // User meant std::unique_lock<std::mutex> lock (mymutex);
7154@}
7155@end smallexample
7156
7157This warning is enabled by @option{-Wall}.
7158
d77de738
ML
7159@opindex Wself-move
7160@opindex Wno-self-move
ddf6fe37 7161@item -Wno-self-move @r{(C++ and Objective-C++ only)}
d77de738
ML
7162This warning warns when a value is moved to itself with @code{std::move}.
7163Such a @code{std::move} typically has no effect.
7164
7165@smallexample
7166struct T @{
7167@dots{}
7168@};
7169void fn()
7170@{
7171 T t;
7172 @dots{}
7173 t = std::move (t);
7174@}
7175@end smallexample
7176
7177This warning is enabled by @option{-Wall}.
7178
d77de738
ML
7179@opindex Wsequence-point
7180@opindex Wno-sequence-point
ddf6fe37 7181@item -Wsequence-point
d77de738
ML
7182Warn about code that may have undefined semantics because of violations
7183of sequence point rules in the C and C++ standards.
7184
7185The C and C++ standards define the order in which expressions in a C/C++
7186program are evaluated in terms of @dfn{sequence points}, which represent
7187a partial ordering between the execution of parts of the program: those
7188executed before the sequence point, and those executed after it. These
7189occur after the evaluation of a full expression (one which is not part
7190of a larger expression), after the evaluation of the first operand of a
7191@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7192function is called (but after the evaluation of its arguments and the
7193expression denoting the called function), and in certain other places.
7194Other than as expressed by the sequence point rules, the order of
7195evaluation of subexpressions of an expression is not specified. All
7196these rules describe only a partial order rather than a total order,
7197since, for example, if two functions are called within one expression
7198with no sequence point between them, the order in which the functions
7199are called is not specified. However, the standards committee have
7200ruled that function calls do not overlap.
7201
7202It is not specified when between sequence points modifications to the
7203values of objects take effect. Programs whose behavior depends on this
7204have undefined behavior; the C and C++ standards specify that ``Between
7205the previous and next sequence point an object shall have its stored
7206value modified at most once by the evaluation of an expression.
7207Furthermore, the prior value shall be read only to determine the value
7208to be stored.''. If a program breaks these rules, the results on any
7209particular implementation are entirely unpredictable.
7210
7211Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7212= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7213diagnosed by this option, and it may give an occasional false positive
7214result, but in general it has been found fairly effective at detecting
7215this sort of problem in programs.
7216
7217The C++17 standard will define the order of evaluation of operands in
7218more cases: in particular it requires that the right-hand side of an
7219assignment be evaluated before the left-hand side, so the above
7220examples are no longer undefined. But this option will still warn
7221about them, to help people avoid writing code that is undefined in C
7222and earlier revisions of C++.
7223
7224The standard is worded confusingly, therefore there is some debate
7225over the precise meaning of the sequence point rules in subtle cases.
7226Links to discussions of the problem, including proposed formal
7227definitions, may be found on the GCC readings page, at
7228@uref{https://gcc.gnu.org/@/readings.html}.
7229
7230This warning is enabled by @option{-Wall} for C and C++.
7231
d77de738
ML
7232@opindex Wno-return-local-addr
7233@opindex Wreturn-local-addr
ddf6fe37 7234@item -Wno-return-local-addr
d77de738
ML
7235Do not warn about returning a pointer (or in C++, a reference) to a
7236variable that goes out of scope after the function returns.
7237
d77de738
ML
7238@opindex Wreturn-type
7239@opindex Wno-return-type
ddf6fe37 7240@item -Wreturn-type
d77de738
ML
7241Warn whenever a function is defined with a return type that defaults
7242to @code{int}. Also warn about any @code{return} statement with no
7243return value in a function whose return type is not @code{void}
7244(falling off the end of the function body is considered returning
7245without a value).
7246
7247For C only, warn about a @code{return} statement with an expression in a
7248function whose return type is @code{void}, unless the expression type is
7249also @code{void}. As a GNU extension, the latter case is accepted
7250without a warning unless @option{-Wpedantic} is used. Attempting
7251to use the return value of a non-@code{void} function other than @code{main}
7252that flows off the end by reaching the closing curly brace that terminates
7253the function is undefined.
7254
7255Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7256than @code{main} results in undefined behavior even when the value of
7257the function is not used.
7258
7259This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7260
d77de738
ML
7261@opindex Wshift-count-negative
7262@opindex Wno-shift-count-negative
ddf6fe37 7263@item -Wno-shift-count-negative
d77de738
ML
7264Controls warnings if a shift count is negative.
7265This warning is enabled by default.
7266
d77de738
ML
7267@opindex Wshift-count-overflow
7268@opindex Wno-shift-count-overflow
ddf6fe37 7269@item -Wno-shift-count-overflow
d77de738
ML
7270Controls warnings if a shift count is greater than or equal to the bit width
7271of the type. This warning is enabled by default.
7272
d77de738
ML
7273@opindex Wshift-negative-value
7274@opindex Wno-shift-negative-value
ddf6fe37 7275@item -Wshift-negative-value
d77de738
ML
7276Warn if left shifting a negative value. This warning is enabled by
7277@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7278
d77de738
ML
7279@opindex Wshift-overflow
7280@opindex Wno-shift-overflow
ddf6fe37
AA
7281@item -Wno-shift-overflow
7282@itemx -Wshift-overflow=@var{n}
d77de738
ML
7283These options control warnings about left shift overflows.
7284
7285@table @gcctabopt
7286@item -Wshift-overflow=1
7287This is the warning level of @option{-Wshift-overflow} and is enabled
7288by default in C99 and C++11 modes (and newer). This warning level does
7289not warn about left-shifting 1 into the sign bit. (However, in C, such
7290an overflow is still rejected in contexts where an integer constant expression
7291is required.) No warning is emitted in C++20 mode (and newer), as signed left
7292shifts always wrap.
7293
7294@item -Wshift-overflow=2
7295This warning level also warns about left-shifting 1 into the sign bit,
7296unless C++14 mode (or newer) is active.
7297@end table
7298
d77de738
ML
7299@opindex Wswitch
7300@opindex Wno-switch
ddf6fe37 7301@item -Wswitch
d77de738
ML
7302Warn whenever a @code{switch} statement has an index of enumerated type
7303and lacks a @code{case} for one or more of the named codes of that
7304enumeration. (The presence of a @code{default} label prevents this
7305warning.) @code{case} labels outside the enumeration range also
7306provoke warnings when this option is used (even if there is a
7307@code{default} label).
7308This warning is enabled by @option{-Wall}.
7309
d77de738
ML
7310@opindex Wswitch-default
7311@opindex Wno-switch-default
ddf6fe37 7312@item -Wswitch-default
d77de738
ML
7313Warn whenever a @code{switch} statement does not have a @code{default}
7314case.
7315
d77de738
ML
7316@opindex Wswitch-enum
7317@opindex Wno-switch-enum
ddf6fe37 7318@item -Wswitch-enum
d77de738
ML
7319Warn whenever a @code{switch} statement has an index of enumerated type
7320and lacks a @code{case} for one or more of the named codes of that
7321enumeration. @code{case} labels outside the enumeration range also
7322provoke warnings when this option is used. The only difference
7323between @option{-Wswitch} and this option is that this option gives a
7324warning about an omitted enumeration code even if there is a
7325@code{default} label.
7326
d77de738
ML
7327@opindex Wswitch-bool
7328@opindex Wno-switch-bool
ddf6fe37 7329@item -Wno-switch-bool
d77de738
ML
7330Do not warn when a @code{switch} statement has an index of boolean type
7331and the case values are outside the range of a boolean type.
7332It is possible to suppress this warning by casting the controlling
7333expression to a type other than @code{bool}. For example:
7334@smallexample
7335@group
7336switch ((int) (a == 4))
7337 @{
7338 @dots{}
7339 @}
7340@end group
7341@end smallexample
7342This warning is enabled by default for C and C++ programs.
7343
d77de738
ML
7344@opindex Wswitch-outside-range
7345@opindex Wno-switch-outside-range
ddf6fe37 7346@item -Wno-switch-outside-range
d77de738
ML
7347This option controls warnings when a @code{switch} case has a value
7348that is outside of its
7349respective type range. This warning is enabled by default for
7350C and C++ programs.
7351
d77de738
ML
7352@opindex Wswitch-unreachable
7353@opindex Wno-switch-unreachable
ddf6fe37 7354@item -Wno-switch-unreachable
d77de738
ML
7355Do not warn when a @code{switch} statement contains statements between the
7356controlling expression and the first case label, which will never be
7357executed. For example:
7358@smallexample
7359@group
7360switch (cond)
7361 @{
7362 i = 15;
7363 @dots{}
7364 case 5:
7365 @dots{}
7366 @}
7367@end group
7368@end smallexample
7369@option{-Wswitch-unreachable} does not warn if the statement between the
7370controlling expression and the first case label is just a declaration:
7371@smallexample
7372@group
7373switch (cond)
7374 @{
7375 int i;
7376 @dots{}
7377 case 5:
7378 i = 5;
7379 @dots{}
7380 @}
7381@end group
7382@end smallexample
7383This warning is enabled by default for C and C++ programs.
7384
d77de738
ML
7385@opindex Wsync-nand
7386@opindex Wno-sync-nand
ddf6fe37 7387@item -Wsync-nand @r{(C and C++ only)}
d77de738
ML
7388Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7389built-in functions are used. These functions changed semantics in GCC 4.4.
7390
d77de738
ML
7391@opindex Wtrivial-auto-var-init
7392@opindex Wno-trivial-auto-var-init
ddf6fe37 7393@item -Wtrivial-auto-var-init
d77de738
ML
7394Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7395variable. A common situation is an automatic variable that is declared
7396between the controlling expression and the first case label of a @code{switch}
7397statement.
7398
d77de738
ML
7399@opindex Wunused-but-set-parameter
7400@opindex Wno-unused-but-set-parameter
ddf6fe37 7401@item -Wunused-but-set-parameter
d77de738
ML
7402Warn whenever a function parameter is assigned to, but otherwise unused
7403(aside from its declaration).
7404
7405To suppress this warning use the @code{unused} attribute
7406(@pxref{Variable Attributes}).
7407
7408This warning is also enabled by @option{-Wunused} together with
7409@option{-Wextra}.
7410
d77de738
ML
7411@opindex Wunused-but-set-variable
7412@opindex Wno-unused-but-set-variable
ddf6fe37 7413@item -Wunused-but-set-variable
d77de738
ML
7414Warn whenever a local variable is assigned to, but otherwise unused
7415(aside from its declaration).
7416This warning is enabled by @option{-Wall}.
7417
7418To suppress this warning use the @code{unused} attribute
7419(@pxref{Variable Attributes}).
7420
7421This warning is also enabled by @option{-Wunused}, which is enabled
7422by @option{-Wall}.
7423
d77de738
ML
7424@opindex Wunused-function
7425@opindex Wno-unused-function
ddf6fe37 7426@item -Wunused-function
d77de738
ML
7427Warn whenever a static function is declared but not defined or a
7428non-inline static function is unused.
7429This warning is enabled by @option{-Wall}.
7430
d77de738
ML
7431@opindex Wunused-label
7432@opindex Wno-unused-label
ddf6fe37 7433@item -Wunused-label
d77de738
ML
7434Warn whenever a label is declared but not used.
7435This warning is enabled by @option{-Wall}.
7436
7437To suppress this warning use the @code{unused} attribute
7438(@pxref{Variable Attributes}).
7439
d77de738
ML
7440@opindex Wunused-local-typedefs
7441@opindex Wno-unused-local-typedefs
ddf6fe37 7442@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
7443Warn when a typedef locally defined in a function is not used.
7444This warning is enabled by @option{-Wall}.
7445
d77de738
ML
7446@opindex Wunused-parameter
7447@opindex Wno-unused-parameter
ddf6fe37 7448@item -Wunused-parameter
d77de738
ML
7449Warn whenever a function parameter is unused aside from its declaration.
7450
7451To suppress this warning use the @code{unused} attribute
7452(@pxref{Variable Attributes}).
7453
d77de738
ML
7454@opindex Wunused-result
7455@opindex Wno-unused-result
ddf6fe37 7456@item -Wno-unused-result
d77de738
ML
7457Do not warn if a caller of a function marked with attribute
7458@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7459its return value. The default is @option{-Wunused-result}.
7460
d77de738
ML
7461@opindex Wunused-variable
7462@opindex Wno-unused-variable
ddf6fe37 7463@item -Wunused-variable
d77de738
ML
7464Warn whenever a local or static variable is unused aside from its
7465declaration. This option implies @option{-Wunused-const-variable=1} for C,
7466but not for C++. This warning is enabled by @option{-Wall}.
7467
7468To suppress this warning use the @code{unused} attribute
7469(@pxref{Variable Attributes}).
7470
d77de738
ML
7471@opindex Wunused-const-variable
7472@opindex Wno-unused-const-variable
ddf6fe37
AA
7473@item -Wunused-const-variable
7474@itemx -Wunused-const-variable=@var{n}
d77de738
ML
7475Warn whenever a constant static variable is unused aside from its declaration.
7476@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7477for C, but not for C++. In C this declares variable storage, but in C++ this
7478is not an error since const variables take the place of @code{#define}s.
7479
7480To suppress this warning use the @code{unused} attribute
7481(@pxref{Variable Attributes}).
7482
7483@table @gcctabopt
7484@item -Wunused-const-variable=1
7485This is the warning level that is enabled by @option{-Wunused-variable} for
7486C. It warns only about unused static const variables defined in the main
7487compilation unit, but not about static const variables declared in any
7488header included.
7489
7490@item -Wunused-const-variable=2
7491This warning level also warns for unused constant static variables in
7492headers (excluding system headers). This is the warning level of
7493@option{-Wunused-const-variable} and must be explicitly requested since
7494in C++ this isn't an error and in C it might be harder to clean up all
7495headers included.
7496@end table
7497
d77de738
ML
7498@opindex Wunused-value
7499@opindex Wno-unused-value
ddf6fe37 7500@item -Wunused-value
d77de738
ML
7501Warn whenever a statement computes a result that is explicitly not
7502used. To suppress this warning cast the unused expression to
7503@code{void}. This includes an expression-statement or the left-hand
7504side of a comma expression that contains no side effects. For example,
7505an expression such as @code{x[i,j]} causes a warning, while
7506@code{x[(void)i,j]} does not.
7507
7508This warning is enabled by @option{-Wall}.
7509
d77de738
ML
7510@opindex Wunused
7511@opindex Wno-unused
ddf6fe37 7512@item -Wunused
d77de738
ML
7513All the above @option{-Wunused} options combined.
7514
7515In order to get a warning about an unused function parameter, you must
7516either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7517@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7518
d77de738
ML
7519@opindex Wuninitialized
7520@opindex Wno-uninitialized
ddf6fe37 7521@item -Wuninitialized
d77de738
ML
7522Warn if an object with automatic or allocated storage duration is used
7523without having been initialized. In C++, also warn if a non-static
7524reference or non-static @code{const} member appears in a class without
7525constructors.
7526
7527In addition, passing a pointer (or in C++, a reference) to an uninitialized
7528object to a @code{const}-qualified argument of a built-in function known to
7529read the object is also diagnosed by this warning.
7530(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7531
7532If you want to warn about code that uses the uninitialized value of the
7533variable in its own initializer, use the @option{-Winit-self} option.
7534
7535These warnings occur for individual uninitialized elements of
7536structure, union or array variables as well as for variables that are
7537uninitialized as a whole. They do not occur for variables or elements
7538declared @code{volatile}. Because these warnings depend on
7539optimization, the exact variables or elements for which there are
7540warnings depend on the precise optimization options and version of GCC
7541used.
7542
7543Note that there may be no warning about a variable that is used only
7544to compute a value that itself is never used, because such
7545computations may be deleted by data flow analysis before the warnings
7546are printed.
7547
7548In C++, this warning also warns about using uninitialized objects in
7549member-initializer-lists. For example, GCC warns about @code{b} being
7550uninitialized in the following snippet:
7551
7552@smallexample
7553struct A @{
7554 int a;
7555 int b;
7556 A() : a(b) @{ @}
7557@};
7558@end smallexample
7559
d77de738
ML
7560@opindex Winvalid-memory-model
7561@opindex Wno-invalid-memory-model
ddf6fe37 7562@item -Wno-invalid-memory-model
d77de738
ML
7563This option controls warnings
7564for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7565and the C11 atomic generic functions with a memory consistency argument
7566that is either invalid for the operation or outside the range of values
7567of the @code{memory_order} enumeration. For example, since the
7568@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7569defined for the relaxed, release, and sequentially consistent memory
7570orders the following code is diagnosed:
7571
7572@smallexample
7573void store (int *i)
7574@{
7575 __atomic_store_n (i, 0, memory_order_consume);
7576@}
7577@end smallexample
7578
7579@option{-Winvalid-memory-model} is enabled by default.
7580
d77de738
ML
7581@opindex Wmaybe-uninitialized
7582@opindex Wno-maybe-uninitialized
ddf6fe37 7583@item -Wmaybe-uninitialized
d77de738
ML
7584For an object with automatic or allocated storage duration, if there exists
7585a path from the function entry to a use of the object that is initialized,
7586but there exist some other paths for which the object is not initialized,
7587the compiler emits a warning if it cannot prove the uninitialized paths
7588are not executed at run time.
7589
7590In addition, passing a pointer (or in C++, a reference) to an uninitialized
7591object to a @code{const}-qualified function argument is also diagnosed by
7592this warning. (@option{-Wuninitialized} is issued for built-in functions
7593known to read the object.) Annotating the function with attribute
7594@code{access (none)} indicates that the argument isn't used to access
7595the object and avoids the warning (@pxref{Common Function Attributes}).
7596
7597These warnings are only possible in optimizing compilation, because otherwise
7598GCC does not keep track of the state of variables.
7599
7600These warnings are made optional because GCC may not be able to determine when
7601the code is correct in spite of appearing to have an error. Here is one
7602example of how this can happen:
7603
7604@smallexample
7605@group
7606@{
7607 int x;
7608 switch (y)
7609 @{
7610 case 1: x = 1;
7611 break;
7612 case 2: x = 4;
7613 break;
7614 case 3: x = 5;
7615 @}
7616 foo (x);
7617@}
7618@end group
7619@end smallexample
7620
7621@noindent
7622If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7623always initialized, but GCC doesn't know this. To suppress the
7624warning, you need to provide a default case with assert(0) or
7625similar code.
7626
7627@cindex @code{longjmp} warnings
7628This option also warns when a non-volatile automatic variable might be
7629changed by a call to @code{longjmp}.
7630The compiler sees only the calls to @code{setjmp}. It cannot know
7631where @code{longjmp} will be called; in fact, a signal handler could
7632call it at any point in the code. As a result, you may get a warning
7633even when there is in fact no problem because @code{longjmp} cannot
7634in fact be called at the place that would cause a problem.
7635
7636Some spurious warnings can be avoided if you declare all the functions
7637you use that never return as @code{noreturn}. @xref{Function
7638Attributes}.
7639
7640This warning is enabled by @option{-Wall} or @option{-Wextra}.
7641
d77de738
ML
7642@opindex Wunknown-pragmas
7643@opindex Wno-unknown-pragmas
7644@cindex warning for unknown pragmas
7645@cindex unknown pragmas, warning
7646@cindex pragmas, warning of unknown
f33d7a88 7647@item -Wunknown-pragmas
d77de738
ML
7648Warn when a @code{#pragma} directive is encountered that is not understood by
7649GCC@. If this command-line option is used, warnings are even issued
7650for unknown pragmas in system header files. This is not the case if
7651the warnings are only enabled by the @option{-Wall} command-line option.
7652
d77de738
ML
7653@opindex Wno-pragmas
7654@opindex Wpragmas
ddf6fe37 7655@item -Wno-pragmas
d77de738
ML
7656Do not warn about misuses of pragmas, such as incorrect parameters,
7657invalid syntax, or conflicts between pragmas. See also
7658@option{-Wunknown-pragmas}.
7659
d77de738
ML
7660@opindex Wno-prio-ctor-dtor
7661@opindex Wprio-ctor-dtor
ddf6fe37 7662@item -Wno-prio-ctor-dtor
d77de738
ML
7663Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7664The use of constructor and destructor attributes allow you to assign a
7665priority to the constructor/destructor to control its order of execution
7666before @code{main} is called or after it returns. The priority values must be
7667greater than 100 as the compiler reserves priority values between 0--100 for
7668the implementation.
7669
d77de738
ML
7670@opindex Wstrict-aliasing
7671@opindex Wno-strict-aliasing
ddf6fe37 7672@item -Wstrict-aliasing
d77de738
ML
7673This option is only active when @option{-fstrict-aliasing} is active.
7674It warns about code that might break the strict aliasing rules that the
7675compiler is using for optimization. The warning does not catch all
7676cases, but does attempt to catch the more common pitfalls. It is
7677included in @option{-Wall}.
7678It is equivalent to @option{-Wstrict-aliasing=3}
7679
d77de738 7680@opindex Wstrict-aliasing=n
ddf6fe37 7681@item -Wstrict-aliasing=n
d77de738
ML
7682This option is only active when @option{-fstrict-aliasing} is active.
7683It warns about code that might break the strict aliasing rules that the
7684compiler is using for optimization.
7685Higher levels correspond to higher accuracy (fewer false positives).
7686Higher levels also correspond to more effort, similar to the way @option{-O}
7687works.
7688@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7689
7690Level 1: Most aggressive, quick, least accurate.
7691Possibly useful when higher levels
7692do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7693false negatives. However, it has many false positives.
7694Warns for all pointer conversions between possibly incompatible types,
7695even if never dereferenced. Runs in the front end only.
7696
7697Level 2: Aggressive, quick, not too precise.
7698May still have many false positives (not as many as level 1 though),
7699and few false negatives (but possibly more than level 1).
7700Unlike level 1, it only warns when an address is taken. Warns about
7701incomplete types. Runs in the front end only.
7702
7703Level 3 (default for @option{-Wstrict-aliasing}):
7704Should have very few false positives and few false
7705negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7706Takes care of the common pun+dereference pattern in the front end:
7707@code{*(int*)&some_float}.
7708If optimization is enabled, it also runs in the back end, where it deals
7709with multiple statement cases using flow-sensitive points-to information.
7710Only warns when the converted pointer is dereferenced.
7711Does not warn about incomplete types.
7712
d77de738
ML
7713@opindex Wstrict-overflow
7714@opindex Wno-strict-overflow
ddf6fe37
AA
7715@item -Wstrict-overflow
7716@itemx -Wstrict-overflow=@var{n}
d77de738
ML
7717This option is only active when signed overflow is undefined.
7718It warns about cases where the compiler optimizes based on the
7719assumption that signed overflow does not occur. Note that it does not
7720warn about all cases where the code might overflow: it only warns
7721about cases where the compiler implements some optimization. Thus
7722this warning depends on the optimization level.
7723
7724An optimization that assumes that signed overflow does not occur is
7725perfectly safe if the values of the variables involved are such that
7726overflow never does, in fact, occur. Therefore this warning can
7727easily give a false positive: a warning about code that is not
7728actually a problem. To help focus on important issues, several
7729warning levels are defined. No warnings are issued for the use of
7730undefined signed overflow when estimating how many iterations a loop
7731requires, in particular when determining whether a loop will be
7732executed at all.
7733
7734@table @gcctabopt
7735@item -Wstrict-overflow=1
7736Warn about cases that are both questionable and easy to avoid. For
7737example the compiler simplifies
7738@code{x + 1 > x} to @code{1}. This level of
7739@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7740are not, and must be explicitly requested.
7741
7742@item -Wstrict-overflow=2
7743Also warn about other cases where a comparison is simplified to a
7744constant. For example: @code{abs (x) >= 0}. This can only be
7745simplified when signed integer overflow is undefined, because
7746@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7747zero. @option{-Wstrict-overflow} (with no level) is the same as
7748@option{-Wstrict-overflow=2}.
7749
7750@item -Wstrict-overflow=3
7751Also warn about other cases where a comparison is simplified. For
7752example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7753
7754@item -Wstrict-overflow=4
7755Also warn about other simplifications not covered by the above cases.
7756For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7757
7758@item -Wstrict-overflow=5
7759Also warn about cases where the compiler reduces the magnitude of a
7760constant involved in a comparison. For example: @code{x + 2 > y} is
7761simplified to @code{x + 1 >= y}. This is reported only at the
7762highest warning level because this simplification applies to many
7763comparisons, so this warning level gives a very large number of
7764false positives.
7765@end table
7766
d77de738
ML
7767@opindex Wstring-compare
7768@opindex Wno-string-compare
ddf6fe37 7769@item -Wstring-compare
d77de738
ML
7770Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7771determined to be either zero or non-zero in tests for such equality
7772owing to the length of one argument being greater than the size of
7773the array the other argument is stored in (or the bound in the case
7774of @code{strncmp}). Such calls could be mistakes. For example,
7775the call to @code{strcmp} below is diagnosed because its result is
7776necessarily non-zero irrespective of the contents of the array @code{a}.
7777
7778@smallexample
7779extern char a[4];
7780void f (char *d)
7781@{
7782 strcpy (d, "string");
7783 @dots{}
7784 if (0 == strcmp (a, d)) // cannot be true
7785 puts ("a and d are the same");
7786@}
7787@end smallexample
7788
7789@option{-Wstring-compare} is enabled by @option{-Wextra}.
7790
ddf6fe37
AA
7791@opindex Wstringop-overflow
7792@opindex Wno-stringop-overflow
d77de738
ML
7793@item -Wno-stringop-overflow
7794@item -Wstringop-overflow
7795@itemx -Wstringop-overflow=@var{type}
d77de738
ML
7796Warn for calls to string manipulation functions such as @code{memcpy} and
7797@code{strcpy} that are determined to overflow the destination buffer. The
7798optional argument is one greater than the type of Object Size Checking to
7799perform to determine the size of the destination. @xref{Object Size Checking}.
7800The argument is meaningful only for functions that operate on character arrays
7801but not for raw memory functions like @code{memcpy} which always make use
7802of Object Size type-0. The option also warns for calls that specify a size
7803in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7804The option produces the best results with optimization enabled but can detect
7805a small subset of simple buffer overflows even without optimization in
7806calls to the GCC built-in functions like @code{__builtin_memcpy} that
7807correspond to the standard functions. In any case, the option warns about
7808just a subset of buffer overflows detected by the corresponding overflow
7809checking built-ins. For example, the option issues a warning for
7810the @code{strcpy} call below because it copies at least 5 characters
7811(the string @code{"blue"} including the terminating NUL) into the buffer
7812of size 4.
7813
7814@smallexample
7815enum Color @{ blue, purple, yellow @};
7816const char* f (enum Color clr)
7817@{
7818 static char buf [4];
7819 const char *str;
7820 switch (clr)
7821 @{
7822 case blue: str = "blue"; break;
7823 case purple: str = "purple"; break;
7824 case yellow: str = "yellow"; break;
7825 @}
7826
7827 return strcpy (buf, str); // warning here
7828@}
7829@end smallexample
7830
7831Option @option{-Wstringop-overflow=2} is enabled by default.
7832
7833@table @gcctabopt
d77de738
ML
7834@opindex Wstringop-overflow
7835@opindex Wno-stringop-overflow
ddf6fe37
AA
7836@item -Wstringop-overflow
7837@itemx -Wstringop-overflow=1
d77de738
ML
7838The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7839to determine the sizes of destination objects. At this setting the option
7840does not warn for writes past the end of subobjects of larger objects accessed
7841by pointers unless the size of the largest surrounding object is known. When
7842the destination may be one of several objects it is assumed to be the largest
7843one of them. On Linux systems, when optimization is enabled at this setting
7844the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7845is defined to a non-zero value.
7846
7847@item -Wstringop-overflow=2
7848The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7849to determine the sizes of destination objects. At this setting the option
7850warns about overflows when writing to members of the largest complete
7851objects whose exact size is known. However, it does not warn for excessive
7852writes to the same members of unknown objects referenced by pointers since
7853they may point to arrays containing unknown numbers of elements. This is
7854the default setting of the option.
7855
7856@item -Wstringop-overflow=3
7857The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7858to determine the sizes of destination objects. At this setting the option
7859warns about overflowing the smallest object or data member. This is the
7860most restrictive setting of the option that may result in warnings for safe
7861code.
7862
7863@item -Wstringop-overflow=4
7864The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7865to determine the sizes of destination objects. At this setting the option
7866warns about overflowing any data members, and when the destination is
7867one of several objects it uses the size of the largest of them to decide
7868whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7869setting of the option may result in warnings for benign code.
7870@end table
7871
d77de738
ML
7872@opindex Wstringop-overread
7873@opindex Wno-stringop-overread
ddf6fe37 7874@item -Wno-stringop-overread
d77de738
ML
7875Warn for calls to string manipulation functions such as @code{memchr}, or
7876@code{strcpy} that are determined to read past the end of the source
7877sequence.
7878
7879Option @option{-Wstringop-overread} is enabled by default.
7880
d77de738
ML
7881@opindex Wstringop-truncation
7882@opindex Wno-stringop-truncation
ddf6fe37 7883@item -Wno-stringop-truncation
d77de738
ML
7884Do not warn for calls to bounded string manipulation functions
7885such as @code{strncat},
7886@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7887or leave the destination unchanged.
7888
7889In the following example, the call to @code{strncat} specifies a bound that
7890is less than the length of the source string. As a result, the copy of
7891the source will be truncated and so the call is diagnosed. To avoid the
7892warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7893
7894@smallexample
7895void append (char *buf, size_t bufsize)
7896@{
7897 strncat (buf, ".txt", 3);
7898@}
7899@end smallexample
7900
7901As another example, the following call to @code{strncpy} results in copying
7902to @code{d} just the characters preceding the terminating NUL, without
7903appending the NUL to the end. Assuming the result of @code{strncpy} is
7904necessarily a NUL-terminated string is a common mistake, and so the call
7905is diagnosed. To avoid the warning when the result is not expected to be
7906NUL-terminated, call @code{memcpy} instead.
7907
7908@smallexample
7909void copy (char *d, const char *s)
7910@{
7911 strncpy (d, s, strlen (s));
7912@}
7913@end smallexample
7914
7915In the following example, the call to @code{strncpy} specifies the size
7916of the destination buffer as the bound. If the length of the source
7917string is equal to or greater than this size the result of the copy will
7918not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7919the warning, specify @code{sizeof buf - 1} as the bound and set the last
7920element of the buffer to @code{NUL}.
7921
7922@smallexample
7923void copy (const char *s)
7924@{
7925 char buf[80];
7926 strncpy (buf, s, sizeof buf);
7927 @dots{}
7928@}
7929@end smallexample
7930
7931In situations where a character array is intended to store a sequence
7932of bytes with no terminating @code{NUL} such an array may be annotated
7933with attribute @code{nonstring} to avoid this warning. Such arrays,
7934however, are not suitable arguments to functions that expect
7935@code{NUL}-terminated strings. To help detect accidental misuses of
7936such arrays GCC issues warnings unless it can prove that the use is
7937safe. @xref{Common Variable Attributes}.
7938
2a27ae32
QZ
7939@opindex Wstrict-flex-arrays
7940@opindex Wno-strict-flex-arrays
ddf6fe37 7941@item -Wstrict-flex-arrays
2a27ae32
QZ
7942Warn about inproper usages of flexible array members
7943according to the @var{level} of the @code{strict_flex_array (@var{level})}
7944attribute attached to the trailing array field of a structure if it's
7945available, otherwise according to the @var{level} of the option
7946@option{-fstrict-flex-arrays=@var{level}}.
7947
7948This option is effective only when @var{level} is bigger than 0. Otherwise,
7949it will be ignored with a warning.
7950
7951when @var{level}=1, warnings will be issued for a trailing array reference
7952of a structure that have 2 or more elements if the trailing array is referenced
7953as a flexible array member.
7954
7955when @var{level}=2, in addition to @var{level}=1, additional warnings will be
7956issued for a trailing one-element array reference of a structure
7957if the array is referenced as a flexible array member.
7958
7959when @var{level}=3, in addition to @var{level}=2, additional warnings will be
7960issued for a trailing zero-length array reference of a structure
7961if the array is referenced as a flexible array member.
7962
7963
d77de738
ML
7964@opindex Wsuggest-attribute=
7965@opindex Wno-suggest-attribute=
ddf6fe37 7966@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
d77de738
ML
7967Warn for cases where adding an attribute may be beneficial. The
7968attributes currently supported are listed below.
7969
7970@table @gcctabopt
d77de738
ML
7971@opindex Wsuggest-attribute=pure
7972@opindex Wno-suggest-attribute=pure
7973@opindex Wsuggest-attribute=const
7974@opindex Wno-suggest-attribute=const
7975@opindex Wsuggest-attribute=noreturn
7976@opindex Wno-suggest-attribute=noreturn
7977@opindex Wmissing-noreturn
7978@opindex Wno-missing-noreturn
7979@opindex Wsuggest-attribute=malloc
7980@opindex Wno-suggest-attribute=malloc
ddf6fe37
AA
7981@item -Wsuggest-attribute=pure
7982@itemx -Wsuggest-attribute=const
7983@itemx -Wsuggest-attribute=noreturn
7984@itemx -Wmissing-noreturn
7985@itemx -Wsuggest-attribute=malloc
d77de738
ML
7986
7987Warn about functions that might be candidates for attributes
7988@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7989only warns for functions visible in other compilation units or (in the case of
7990@code{pure} and @code{const}) if it cannot prove that the function returns
7991normally. A function returns normally if it doesn't contain an infinite loop or
7992return abnormally by throwing, calling @code{abort} or trapping. This analysis
7993requires option @option{-fipa-pure-const}, which is enabled by default at
7994@option{-O} and higher. Higher optimization levels improve the accuracy
7995of the analysis.
7996
d77de738
ML
7997@opindex Wsuggest-attribute=format
7998@opindex Wmissing-format-attribute
7999@opindex Wno-suggest-attribute=format
8000@opindex Wno-missing-format-attribute
8001@opindex Wformat
8002@opindex Wno-format
ddf6fe37
AA
8003@item -Wsuggest-attribute=format
8004@itemx -Wmissing-format-attribute
d77de738
ML
8005
8006Warn about function pointers that might be candidates for @code{format}
8007attributes. Note these are only possible candidates, not absolute ones.
8008GCC guesses that function pointers with @code{format} attributes that
8009are used in assignment, initialization, parameter passing or return
8010statements should have a corresponding @code{format} attribute in the
8011resulting type. I.e.@: the left-hand side of the assignment or
8012initialization, the type of the parameter variable, or the return type
8013of the containing function respectively should also have a @code{format}
8014attribute to avoid the warning.
8015
8016GCC also warns about function definitions that might be
8017candidates for @code{format} attributes. Again, these are only
8018possible candidates. GCC guesses that @code{format} attributes
8019might be appropriate for any function that calls a function like
8020@code{vprintf} or @code{vscanf}, but this might not always be the
8021case, and some functions for which @code{format} attributes are
8022appropriate may not be detected.
8023
d77de738
ML
8024@opindex Wsuggest-attribute=cold
8025@opindex Wno-suggest-attribute=cold
ddf6fe37 8026@item -Wsuggest-attribute=cold
d77de738
ML
8027
8028Warn about functions that might be candidates for @code{cold} attribute. This
8029is based on static detection and generally only warns about functions which
8030always leads to a call to another @code{cold} function such as wrappers of
8031C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
8032@end table
8033
d77de738
ML
8034@opindex Wno-alloc-zero
8035@opindex Walloc-zero
ddf6fe37 8036@item -Walloc-zero
d77de738
ML
8037Warn about calls to allocation functions decorated with attribute
8038@code{alloc_size} that specify zero bytes, including those to the built-in
8039forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
8040@code{malloc}, and @code{realloc}. Because the behavior of these functions
8041when called with a zero size differs among implementations (and in the case
8042of @code{realloc} has been deprecated) relying on it may result in subtle
8043portability bugs and should be avoided.
8044
d77de738
ML
8045@opindex Walloc-size-larger-than=
8046@opindex Wno-alloc-size-larger-than
ddf6fe37 8047@item -Walloc-size-larger-than=@var{byte-size}
d77de738
ML
8048Warn about calls to functions decorated with attribute @code{alloc_size}
8049that attempt to allocate objects larger than the specified number of bytes,
8050or where the result of the size computation in an integer type with infinite
8051precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
8052@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8053Warnings controlled by the option can be disabled either by specifying
8054@var{byte-size} of @samp{SIZE_MAX} or more or by
8055@option{-Wno-alloc-size-larger-than}.
8056@xref{Function Attributes}.
8057
d77de738 8058@opindex Wno-alloc-size-larger-than
ddf6fe37 8059@item -Wno-alloc-size-larger-than
d77de738
ML
8060Disable @option{-Walloc-size-larger-than=} warnings. The option is
8061equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8062larger.
8063
d77de738
ML
8064@opindex Wno-alloca
8065@opindex Walloca
ddf6fe37 8066@item -Walloca
d77de738
ML
8067This option warns on all uses of @code{alloca} in the source.
8068
d77de738
ML
8069@opindex Walloca-larger-than=
8070@opindex Wno-alloca-larger-than
ddf6fe37 8071@item -Walloca-larger-than=@var{byte-size}
d77de738
ML
8072This option warns on calls to @code{alloca} with an integer argument whose
8073value is either zero, or that is not bounded by a controlling predicate
8074that limits its value to at most @var{byte-size}. It also warns for calls
8075to @code{alloca} where the bound value is unknown. Arguments of non-integer
8076types are considered unbounded even if they appear to be constrained to
8077the expected range.
8078
8079For example, a bounded case of @code{alloca} could be:
8080
8081@smallexample
8082void func (size_t n)
8083@{
8084 void *p;
8085 if (n <= 1000)
8086 p = alloca (n);
8087 else
8088 p = malloc (n);
8089 f (p);
8090@}
8091@end smallexample
8092
8093In the above example, passing @code{-Walloca-larger-than=1000} would not
8094issue a warning because the call to @code{alloca} is known to be at most
80951000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8096the compiler would emit a warning.
8097
8098Unbounded uses, on the other hand, are uses of @code{alloca} with no
8099controlling predicate constraining its integer argument. For example:
8100
8101@smallexample
8102void func ()
8103@{
8104 void *p = alloca (n);
8105 f (p);
8106@}
8107@end smallexample
8108
8109If @code{-Walloca-larger-than=500} were passed, the above would trigger
8110a warning, but this time because of the lack of bounds checking.
8111
8112Note, that even seemingly correct code involving signed integers could
8113cause a warning:
8114
8115@smallexample
8116void func (signed int n)
8117@{
8118 if (n < 500)
8119 @{
8120 p = alloca (n);
8121 f (p);
8122 @}
8123@}
8124@end smallexample
8125
8126In the above example, @var{n} could be negative, causing a larger than
8127expected argument to be implicitly cast into the @code{alloca} call.
8128
8129This option also warns when @code{alloca} is used in a loop.
8130
8131@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8132but is usually only effective when @option{-ftree-vrp} is active (default
8133for @option{-O2} and above).
8134
8135See also @option{-Wvla-larger-than=}@samp{byte-size}.
8136
d77de738 8137@opindex Wno-alloca-larger-than
ddf6fe37 8138@item -Wno-alloca-larger-than
d77de738
ML
8139Disable @option{-Walloca-larger-than=} warnings. The option is
8140equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8141
d77de738
ML
8142@opindex Warith-conversion
8143@opindex Wno-arith-conversion
ddf6fe37 8144@item -Warith-conversion
d77de738
ML
8145Do warn about implicit conversions from arithmetic operations even
8146when conversion of the operands to the same type cannot change their
8147values. This affects warnings from @option{-Wconversion},
8148@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8149
8150@smallexample
8151@group
8152void f (char c, int i)
8153@{
8154 c = c + i; // warns with @option{-Wconversion}
8155 c = c + 1; // only warns with @option{-Warith-conversion}
8156@}
8157@end group
8158@end smallexample
8159
d77de738
ML
8160@opindex Wno-array-bounds
8161@opindex Warray-bounds
ddf6fe37
AA
8162@item -Warray-bounds
8163@itemx -Warray-bounds=@var{n}
d77de738
ML
8164Warn about out of bounds subscripts or offsets into arrays. This warning
8165is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8166is active (the default for @option{-O2} and above) but a subset of instances
8167are issued even without optimization.
8168
710c9676
QZ
8169By default, the trailing array of a structure will be treated as a flexible
8170array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8171if it is declared as either a flexible array member per C99 standard onwards
8172(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8173array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8174zero-length arrays or one-element arrays are not warned by default.
8175
8176You can add the option @option{-fstrict-flex-arrays} or
8177@option{-fstrict-flex-arrays=@var{level}} to control how this
8178option treat trailing array of a structure as a flexible array member:
8179
8180when @var{level}<=1, no change to the default behavior.
8181
8182when @var{level}=2, additional warnings will be issued for out of bounds
8183subscripts or offsets into one-element arrays;
8184
8185when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8186issued for out of bounds subscripts or offsets into zero-length arrays.
8187
d77de738
ML
8188@table @gcctabopt
8189@item -Warray-bounds=1
8190This is the default warning level of @option{-Warray-bounds} and is enabled
8191by @option{-Wall}; higher levels are not, and must be explicitly requested.
8192
8193@item -Warray-bounds=2
710c9676
QZ
8194This warning level also warns about the intermediate results of pointer
8195arithmetic that may yield out of bounds values. This warning level may
8196give a larger number of false positives and is deactivated by default.
d77de738
ML
8197@end table
8198
d77de738
ML
8199@opindex Warray-compare
8200@opindex Wno-array-compare
ddf6fe37 8201@item -Warray-compare
d77de738
ML
8202Warn about equality and relational comparisons between two operands of array
8203type. This comparison was deprecated in C++20. For example:
8204
8205@smallexample
8206int arr1[5];
8207int arr2[5];
8208bool same = arr1 == arr2;
8209@end smallexample
8210
8211@option{-Warray-compare} is enabled by @option{-Wall}.
8212
ddf6fe37 8213@opindex Wno-array-parameter
d77de738
ML
8214@item -Warray-parameter
8215@itemx -Warray-parameter=@var{n}
d77de738
ML
8216Warn about redeclarations of functions involving arguments of array or
8217pointer types of inconsistent kinds or forms, and enable the detection
8218of out-of-bounds accesses to such parameters by warnings such as
8219@option{-Warray-bounds}.
8220
8221If the first function declaration uses the array form the bound specified
8222in the array is assumed to be the minimum number of elements expected to
8223be provided in calls to the function and the maximum number of elements
8224accessed by it. Failing to provide arguments of sufficient size or accessing
8225more than the maximum number of elements may be diagnosed by warnings such
8226as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8227involving array parameters declared using the @code{T[static N]} form.
8228
8229For example, the warning triggers for the following redeclarations because
8230the first one allows an array of any size to be passed to @code{f} while
8231the second one with the keyword @code{static} specifies that the array
8232argument must have at least four elements.
8233
8234@smallexample
8235void f (int[static 4]);
8236void f (int[]); // warning (inconsistent array form)
8237
8238void g (void)
8239@{
8240 int *p = (int *)malloc (4);
8241 f (p); // warning (array too small)
8242 @dots{}
8243@}
8244@end smallexample
8245
8246At level 2 the warning also triggers for redeclarations involving any other
8247inconsistency in array or pointer argument forms denoting array sizes.
8248Pointers and arrays of unspecified bound are considered equivalent and do
8249not trigger a warning.
8250
8251@smallexample
8252void g (int*);
8253void g (int[]); // no warning
8254void g (int[8]); // warning (inconsistent array bound)
8255@end smallexample
8256
8257@option{-Warray-parameter=2} is included in @option{-Wall}. The
8258@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8259involving Variable Length Array arguments.
8260
d77de738
ML
8261@opindex Wattribute-alias
8262@opindex Wno-attribute-alias
ddf6fe37
AA
8263@item -Wattribute-alias=@var{n}
8264@itemx -Wno-attribute-alias
d77de738
ML
8265Warn about declarations using the @code{alias} and similar attributes whose
8266target is incompatible with the type of the alias.
8267@xref{Function Attributes,,Declaring Attributes of Functions}.
8268
8269@table @gcctabopt
8270@item -Wattribute-alias=1
8271The default warning level of the @option{-Wattribute-alias} option diagnoses
8272incompatibilities between the type of the alias declaration and that of its
8273target. Such incompatibilities are typically indicative of bugs.
8274
8275@item -Wattribute-alias=2
8276
8277At this level @option{-Wattribute-alias} also diagnoses cases where
8278the attributes of the alias declaration are more restrictive than the
8279attributes applied to its target. These mismatches can potentially
8280result in incorrect code generation. In other cases they may be
8281benign and could be resolved simply by adding the missing attribute to
8282the target. For comparison, see the @option{-Wmissing-attributes}
8283option, which controls diagnostics when the alias declaration is less
8284restrictive than the target, rather than more restrictive.
8285
8286Attributes considered include @code{alloc_align}, @code{alloc_size},
8287@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8288@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8289@code{returns_nonnull}, and @code{returns_twice}.
8290@end table
8291
8292@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8293This is the default. You can disable these warnings with either
8294@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8295
d77de738
ML
8296@opindex Wbidi-chars=
8297@opindex Wbidi-chars
8298@opindex Wno-bidi-chars
ddf6fe37 8299@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
d77de738
ML
8300Warn about possibly misleading UTF-8 bidirectional control characters in
8301comments, string literals, character constants, and identifiers. Such
8302characters can change left-to-right writing direction into right-to-left
8303(and vice versa), which can cause confusion between the logical order and
8304visual order. This may be dangerous; for instance, it may seem that a piece
8305of code is not commented out, whereas it in fact is.
8306
8307There are three levels of warning supported by GCC@. The default is
8308@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8309bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8310@option{-Wbidi-chars=any} warns about any use of bidirectional control
8311characters.
8312
8313By default, this warning does not warn about UCNs. It is, however, possible
8314to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8315@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8316and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8317@option{-Wbidi-chars=any} was specified.
8318
d77de738
ML
8319@opindex Wno-bool-compare
8320@opindex Wbool-compare
ddf6fe37 8321@item -Wbool-compare
d77de738
ML
8322Warn about boolean expression compared with an integer value different from
8323@code{true}/@code{false}. For instance, the following comparison is
8324always false:
8325@smallexample
8326int n = 5;
8327@dots{}
8328if ((n > 1) == 2) @{ @dots{} @}
8329@end smallexample
8330This warning is enabled by @option{-Wall}.
8331
d77de738
ML
8332@opindex Wno-bool-operation
8333@opindex Wbool-operation
ddf6fe37 8334@item -Wbool-operation
d77de738
ML
8335Warn about suspicious operations on expressions of a boolean type. For
8336instance, bitwise negation of a boolean is very likely a bug in the program.
8337For C, this warning also warns about incrementing or decrementing a boolean,
8338which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8339Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8340
8341This warning is enabled by @option{-Wall}.
8342
d77de738
ML
8343@opindex Wno-duplicated-branches
8344@opindex Wduplicated-branches
ddf6fe37 8345@item -Wduplicated-branches
d77de738
ML
8346Warn when an if-else has identical branches. This warning detects cases like
8347@smallexample
8348if (p != NULL)
8349 return 0;
8350else
8351 return 0;
8352@end smallexample
8353It doesn't warn when both branches contain just a null statement. This warning
8354also warn for conditional operators:
8355@smallexample
8356 int i = x ? *p : *p;
8357@end smallexample
8358
d77de738
ML
8359@opindex Wno-duplicated-cond
8360@opindex Wduplicated-cond
ddf6fe37 8361@item -Wduplicated-cond
d77de738
ML
8362Warn about duplicated conditions in an if-else-if chain. For instance,
8363warn for the following code:
8364@smallexample
8365if (p->q != NULL) @{ @dots{} @}
8366else if (p->q != NULL) @{ @dots{} @}
8367@end smallexample
8368
d77de738
ML
8369@opindex Wno-frame-address
8370@opindex Wframe-address
ddf6fe37 8371@item -Wframe-address
d77de738
ML
8372Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8373is called with an argument greater than 0. Such calls may return indeterminate
8374values or crash the program. The warning is included in @option{-Wall}.
8375
d77de738
ML
8376@opindex Wno-discarded-qualifiers
8377@opindex Wdiscarded-qualifiers
ddf6fe37 8378@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8379Do not warn if type qualifiers on pointers are being discarded.
8380Typically, the compiler warns if a @code{const char *} variable is
8381passed to a function that takes a @code{char *} parameter. This option
8382can be used to suppress such a warning.
8383
d77de738
ML
8384@opindex Wno-discarded-array-qualifiers
8385@opindex Wdiscarded-array-qualifiers
ddf6fe37 8386@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8387Do not warn if type qualifiers on arrays which are pointer targets
8388are being discarded. Typically, the compiler warns if a
8389@code{const int (*)[]} variable is passed to a function that
8390takes a @code{int (*)[]} parameter. This option can be used to
8391suppress such a warning.
8392
d77de738
ML
8393@opindex Wno-incompatible-pointer-types
8394@opindex Wincompatible-pointer-types
ddf6fe37 8395@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
d77de738
ML
8396Do not warn when there is a conversion between pointers that have incompatible
8397types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8398which warns for pointer argument passing or assignment with different
8399signedness.
8400
5fccebdb
JM
8401This warning is upgraded to an error by @option{-pedantic-errors}.
8402
d77de738
ML
8403@opindex Wno-int-conversion
8404@opindex Wint-conversion
ddf6fe37 8405@item -Wno-int-conversion @r{(C and Objective-C only)}
d77de738
ML
8406Do not warn about incompatible integer to pointer and pointer to integer
8407conversions. This warning is about implicit conversions; for explicit
8408conversions the warnings @option{-Wno-int-to-pointer-cast} and
8409@option{-Wno-pointer-to-int-cast} may be used.
8410
5fccebdb
JM
8411This warning is upgraded to an error by @option{-pedantic-errors}.
8412
d77de738
ML
8413@opindex Wzero-length-bounds
8414@opindex Wzero-length-bounds
ddf6fe37 8415@item -Wzero-length-bounds
d77de738
ML
8416Warn about accesses to elements of zero-length array members that might
8417overlap other members of the same object. Declaring interior zero-length
8e9c65d3 8418arrays is discouraged because accesses to them are undefined.
d77de738
ML
8419@xref{Zero Length}.
8420
8421For example, the first two stores in function @code{bad} are diagnosed
8422because the array elements overlap the subsequent members @code{b} and
8423@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8424because it is beyond the bounds of the enclosing object.
8425
8426@smallexample
8427struct X @{ int a[0]; int b, c; @};
8428struct X x;
8429
8430void bad (void)
8431@{
8432 x.a[0] = 0; // -Wzero-length-bounds
8433 x.a[1] = 1; // -Wzero-length-bounds
8434 x.a[2] = 2; // -Warray-bounds
8435@}
8436@end smallexample
8437
8438Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8439
d77de738
ML
8440@opindex Wno-div-by-zero
8441@opindex Wdiv-by-zero
ddf6fe37 8442@item -Wno-div-by-zero
d77de738
ML
8443Do not warn about compile-time integer division by zero. Floating-point
8444division by zero is not warned about, as it can be a legitimate way of
8445obtaining infinities and NaNs.
8446
d77de738
ML
8447@opindex Wsystem-headers
8448@opindex Wno-system-headers
8449@cindex warnings from system headers
8450@cindex system headers, warnings from
f33d7a88 8451@item -Wsystem-headers
d77de738
ML
8452Print warning messages for constructs found in system header files.
8453Warnings from system headers are normally suppressed, on the assumption
8454that they usually do not indicate real problems and would only make the
8455compiler output harder to read. Using this command-line option tells
8456GCC to emit warnings from system headers as if they occurred in user
8457code. However, note that using @option{-Wall} in conjunction with this
8458option does @emph{not} warn about unknown pragmas in system
8459headers---for that, @option{-Wunknown-pragmas} must also be used.
8460
d77de738
ML
8461@opindex Wtautological-compare
8462@opindex Wno-tautological-compare
ddf6fe37 8463@item -Wtautological-compare
d77de738
ML
8464Warn if a self-comparison always evaluates to true or false. This
8465warning detects various mistakes such as:
8466@smallexample
8467int i = 1;
8468@dots{}
8469if (i > i) @{ @dots{} @}
8470@end smallexample
8471
8472This warning also warns about bitwise comparisons that always evaluate
8473to true or false, for instance:
8474@smallexample
8475if ((a & 16) == 10) @{ @dots{} @}
8476@end smallexample
8477will always be false.
8478
8479This warning is enabled by @option{-Wall}.
8480
d77de738
ML
8481@opindex Wtrampolines
8482@opindex Wno-trampolines
ddf6fe37 8483@item -Wtrampolines
d77de738
ML
8484Warn about trampolines generated for pointers to nested functions.
8485A trampoline is a small piece of data or code that is created at run
8486time on the stack when the address of a nested function is taken, and is
8487used to call the nested function indirectly. For some targets, it is
8488made up of data only and thus requires no special treatment. But, for
8489most targets, it is made up of code and thus requires the stack to be
8490made executable in order for the program to work properly.
8491
d77de738
ML
8492@opindex Wfloat-equal
8493@opindex Wno-float-equal
ddf6fe37 8494@item -Wfloat-equal
d77de738
ML
8495Warn if floating-point values are used in equality comparisons.
8496
8497The idea behind this is that sometimes it is convenient (for the
8498programmer) to consider floating-point values as approximations to
8499infinitely precise real numbers. If you are doing this, then you need
8500to compute (by analyzing the code, or in some other way) the maximum or
8501likely maximum error that the computation introduces, and allow for it
8502when performing comparisons (and when producing output, but that's a
8503different problem). In particular, instead of testing for equality, you
8504should check to see whether the two values have ranges that overlap; and
8505this is done with the relational operators, so equality comparisons are
8506probably mistaken.
8507
d77de738
ML
8508@opindex Wtraditional
8509@opindex Wno-traditional
ddf6fe37 8510@item -Wtraditional @r{(C and Objective-C only)}
d77de738
ML
8511Warn about certain constructs that behave differently in traditional and
8512ISO C@. Also warn about ISO C constructs that have no traditional C
8513equivalent, and/or problematic constructs that should be avoided.
8514
8515@itemize @bullet
8516@item
8517Macro parameters that appear within string literals in the macro body.
8518In traditional C macro replacement takes place within string literals,
8519but in ISO C it does not.
8520
8521@item
8522In traditional C, some preprocessor directives did not exist.
8523Traditional preprocessors only considered a line to be a directive
8524if the @samp{#} appeared in column 1 on the line. Therefore
8525@option{-Wtraditional} warns about directives that traditional C
8526understands but ignores because the @samp{#} does not appear as the
8527first character on the line. It also suggests you hide directives like
8528@code{#pragma} not understood by traditional C by indenting them. Some
8529traditional implementations do not recognize @code{#elif}, so this option
8530suggests avoiding it altogether.
8531
8532@item
8533A function-like macro that appears without arguments.
8534
8535@item
8536The unary plus operator.
8537
8538@item
8539The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8540constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8541constants.) Note, these suffixes appear in macros defined in the system
8542headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8543Use of these macros in user code might normally lead to spurious
8544warnings, however GCC's integrated preprocessor has enough context to
8545avoid warning in these cases.
8546
8547@item
8548A function declared external in one block and then used after the end of
8549the block.
8550
8551@item
8552A @code{switch} statement has an operand of type @code{long}.
8553
8554@item
8555A non-@code{static} function declaration follows a @code{static} one.
8556This construct is not accepted by some traditional C compilers.
8557
8558@item
8559The ISO type of an integer constant has a different width or
8560signedness from its traditional type. This warning is only issued if
8561the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8562typically represent bit patterns, are not warned about.
8563
8564@item
8565Usage of ISO string concatenation is detected.
8566
8567@item
8568Initialization of automatic aggregates.
8569
8570@item
8571Identifier conflicts with labels. Traditional C lacks a separate
8572namespace for labels.
8573
8574@item
8575Initialization of unions. If the initializer is zero, the warning is
8576omitted. This is done under the assumption that the zero initializer in
8577user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8578initializer warnings and relies on default initialization to zero in the
8579traditional C case.
8580
8581@item
8582Conversions by prototypes between fixed/floating-point values and vice
8583versa. The absence of these prototypes when compiling with traditional
8584C causes serious problems. This is a subset of the possible
8585conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8586
8587@item
8588Use of ISO C style function definitions. This warning intentionally is
8589@emph{not} issued for prototype declarations or variadic functions
8590because these ISO C features appear in your code when using
8591libiberty's traditional C compatibility macros, @code{PARAMS} and
8592@code{VPARAMS}. This warning is also bypassed for nested functions
8593because that feature is already a GCC extension and thus not relevant to
8594traditional C compatibility.
8595@end itemize
8596
d77de738
ML
8597@opindex Wtraditional-conversion
8598@opindex Wno-traditional-conversion
ddf6fe37 8599@item -Wtraditional-conversion @r{(C and Objective-C only)}
d77de738
ML
8600Warn if a prototype causes a type conversion that is different from what
8601would happen to the same argument in the absence of a prototype. This
8602includes conversions of fixed point to floating and vice versa, and
8603conversions changing the width or signedness of a fixed-point argument
8604except when the same as the default promotion.
8605
d77de738
ML
8606@opindex Wdeclaration-after-statement
8607@opindex Wno-declaration-after-statement
ddf6fe37 8608@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
d77de738
ML
8609Warn when a declaration is found after a statement in a block. This
8610construct, known from C++, was introduced with ISO C99 and is by default
8611allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8612
5fccebdb
JM
8613This warning is upgraded to an error by @option{-pedantic-errors}.
8614
d77de738
ML
8615@opindex Wshadow
8616@opindex Wno-shadow
ddf6fe37 8617@item -Wshadow
d77de738
ML
8618Warn whenever a local variable or type declaration shadows another
8619variable, parameter, type, class member (in C++), or instance variable
8620(in Objective-C) or whenever a built-in function is shadowed. Note
8621that in C++, the compiler warns if a local variable shadows an
8622explicit typedef, but not if it shadows a struct/class/enum.
8623If this warning is enabled, it includes also all instances of
8624local shadowing. This means that @option{-Wno-shadow=local}
8625and @option{-Wno-shadow=compatible-local} are ignored when
8626@option{-Wshadow} is used.
8627Same as @option{-Wshadow=global}.
8628
d77de738
ML
8629@opindex Wno-shadow-ivar
8630@opindex Wshadow-ivar
ddf6fe37 8631@item -Wno-shadow-ivar @r{(Objective-C only)}
d77de738
ML
8632Do not warn whenever a local variable shadows an instance variable in an
8633Objective-C method.
8634
d77de738 8635@opindex Wshadow=global
ddf6fe37 8636@item -Wshadow=global
d77de738
ML
8637Warn for any shadowing.
8638Same as @option{-Wshadow}.
8639
d77de738 8640@opindex Wshadow=local
ddf6fe37 8641@item -Wshadow=local
d77de738
ML
8642Warn when a local variable shadows another local variable or parameter.
8643
d77de738 8644@opindex Wshadow=compatible-local
ddf6fe37 8645@item -Wshadow=compatible-local
d77de738
ML
8646Warn when a local variable shadows another local variable or parameter
8647whose type is compatible with that of the shadowing variable. In C++,
8648type compatibility here means the type of the shadowing variable can be
8649converted to that of the shadowed variable. The creation of this flag
8650(in addition to @option{-Wshadow=local}) is based on the idea that when
8651a local variable shadows another one of incompatible type, it is most
8652likely intentional, not a bug or typo, as shown in the following example:
8653
8654@smallexample
8655@group
8656for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8657@{
8658 for (int i = 0; i < N; ++i)
8659 @{
8660 ...
8661 @}
8662 ...
8663@}
8664@end group
8665@end smallexample
8666
8667Since the two variable @code{i} in the example above have incompatible types,
8668enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8669Because their types are incompatible, if a programmer accidentally uses one
8670in place of the other, type checking is expected to catch that and emit an
8671error or warning. Use of this flag instead of @option{-Wshadow=local} can
8672possibly reduce the number of warnings triggered by intentional shadowing.
8673Note that this also means that shadowing @code{const char *i} by
8674@code{char *i} does not emit a warning.
8675
8676This warning is also enabled by @option{-Wshadow=local}.
8677
d77de738
ML
8678@opindex Wlarger-than=
8679@opindex Wlarger-than-@var{byte-size}
ddf6fe37 8680@item -Wlarger-than=@var{byte-size}
d77de738
ML
8681Warn whenever an object is defined whose size exceeds @var{byte-size}.
8682@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8683Warnings controlled by the option can be disabled either by specifying
8684@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8685
8686Also warn for calls to bounded functions such as @code{memchr} or
8687@code{strnlen} that specify a bound greater than the largest possible
8688object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8689can only be disabled by @option{-Wno-larger-than}.
8690
d77de738 8691@opindex Wno-larger-than
ddf6fe37 8692@item -Wno-larger-than
d77de738
ML
8693Disable @option{-Wlarger-than=} warnings. The option is equivalent
8694to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8695
d77de738
ML
8696@opindex Wframe-larger-than=
8697@opindex Wno-frame-larger-than
ddf6fe37 8698@item -Wframe-larger-than=@var{byte-size}
d77de738
ML
8699Warn if the size of a function frame exceeds @var{byte-size}.
8700The computation done to determine the stack frame size is approximate
8701and not conservative.
8702The actual requirements may be somewhat greater than @var{byte-size}
8703even if you do not get a warning. In addition, any space allocated
8704via @code{alloca}, variable-length arrays, or related constructs
8705is not included by the compiler when determining
8706whether or not to issue a warning.
8707@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8708Warnings controlled by the option can be disabled either by specifying
8709@var{byte-size} of @samp{SIZE_MAX} or more or by
8710@option{-Wno-frame-larger-than}.
8711
d77de738 8712@opindex Wno-frame-larger-than
ddf6fe37 8713@item -Wno-frame-larger-than
d77de738
ML
8714Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8715to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8716
d77de738
ML
8717@opindex Wfree-nonheap-object
8718@opindex Wno-free-nonheap-object
ddf6fe37 8719@item -Wfree-nonheap-object
d77de738
ML
8720Warn when attempting to deallocate an object that was either not allocated
8721on the heap, or by using a pointer that was not returned from a prior call
8722to the corresponding allocation function. For example, because the call
8723to @code{stpcpy} returns a pointer to the terminating nul character and
8724not to the beginning of the object, the call to @code{free} below is
8725diagnosed.
8726
8727@smallexample
8728void f (char *p)
8729@{
8730 p = stpcpy (p, "abc");
8731 // ...
8732 free (p); // warning
8733@}
8734@end smallexample
8735
8736@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8737
d77de738
ML
8738@opindex Wstack-usage
8739@opindex Wno-stack-usage
ddf6fe37 8740@item -Wstack-usage=@var{byte-size}
d77de738
ML
8741Warn if the stack usage of a function might exceed @var{byte-size}.
8742The computation done to determine the stack usage is conservative.
8743Any space allocated via @code{alloca}, variable-length arrays, or related
8744constructs is included by the compiler when determining whether or not to
8745issue a warning.
8746
8747The message is in keeping with the output of @option{-fstack-usage}.
8748
8749@itemize
8750@item
8751If the stack usage is fully static but exceeds the specified amount, it's:
8752
8753@smallexample
8754 warning: stack usage is 1120 bytes
8755@end smallexample
8756@item
8757If the stack usage is (partly) dynamic but bounded, it's:
8758
8759@smallexample
8760 warning: stack usage might be 1648 bytes
8761@end smallexample
8762@item
8763If the stack usage is (partly) dynamic and not bounded, it's:
8764
8765@smallexample
8766 warning: stack usage might be unbounded
8767@end smallexample
8768@end itemize
8769
8770@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8771Warnings controlled by the option can be disabled either by specifying
8772@var{byte-size} of @samp{SIZE_MAX} or more or by
8773@option{-Wno-stack-usage}.
8774
d77de738 8775@opindex Wno-stack-usage
ddf6fe37 8776@item -Wno-stack-usage
d77de738
ML
8777Disable @option{-Wstack-usage=} warnings. The option is equivalent
8778to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8779
d77de738
ML
8780@opindex Wunsafe-loop-optimizations
8781@opindex Wno-unsafe-loop-optimizations
ddf6fe37 8782@item -Wunsafe-loop-optimizations
d77de738
ML
8783Warn if the loop cannot be optimized because the compiler cannot
8784assume anything on the bounds of the loop indices. With
8785@option{-funsafe-loop-optimizations} warn if the compiler makes
8786such assumptions.
8787
d77de738
ML
8788@opindex Wno-pedantic-ms-format
8789@opindex Wpedantic-ms-format
ddf6fe37 8790@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
d77de738
ML
8791When used in combination with @option{-Wformat}
8792and @option{-pedantic} without GNU extensions, this option
8793disables the warnings about non-ISO @code{printf} / @code{scanf} format
8794width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8795which depend on the MS runtime.
8796
d77de738
ML
8797@opindex Wpointer-arith
8798@opindex Wno-pointer-arith
ddf6fe37 8799@item -Wpointer-arith
d77de738
ML
8800Warn about anything that depends on the ``size of'' a function type or
8801of @code{void}. GNU C assigns these types a size of 1, for
8802convenience in calculations with @code{void *} pointers and pointers
8803to functions. In C++, warn also when an arithmetic operation involves
8804@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8805
5fccebdb
JM
8806This warning is upgraded to an error by @option{-pedantic-errors}.
8807
d77de738
ML
8808@opindex Wpointer-compare
8809@opindex Wno-pointer-compare
ddf6fe37 8810@item -Wno-pointer-compare
d77de738
ML
8811Do not warn if a pointer is compared with a zero character constant.
8812This usually
8813means that the pointer was meant to be dereferenced. For example:
8814
8815@smallexample
8816const char *p = foo ();
8817if (p == '\0')
8818 return 42;
8819@end smallexample
8820
8821Note that the code above is invalid in C++11.
8822
8823This warning is enabled by default.
8824
d77de738
ML
8825@opindex Wtsan
8826@opindex Wno-tsan
ddf6fe37 8827@item -Wtsan
d77de738
ML
8828Warn about unsupported features in ThreadSanitizer.
8829
8830ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8831can report false positives.
8832
8833This warning is enabled by default.
8834
d77de738
ML
8835@opindex Wtype-limits
8836@opindex Wno-type-limits
ddf6fe37 8837@item -Wtype-limits
d77de738
ML
8838Warn if a comparison is always true or always false due to the limited
8839range of the data type, but do not warn for constant expressions. For
8840example, warn if an unsigned variable is compared against zero with
8841@code{<} or @code{>=}. This warning is also enabled by
8842@option{-Wextra}.
8843
d77de738
ML
8844@opindex Wabsolute-value
8845@opindex Wno-absolute-value
ddf6fe37 8846@item -Wabsolute-value @r{(C and Objective-C only)}
d77de738
ML
8847Warn for calls to standard functions that compute the absolute value
8848of an argument when a more appropriate standard function is available.
8849For example, calling @code{abs(3.14)} triggers the warning because the
8850appropriate function to call to compute the absolute value of a double
8851argument is @code{fabs}. The option also triggers warnings when the
8852argument in a call to such a function has an unsigned type. This
8853warning can be suppressed with an explicit type cast and it is also
8854enabled by @option{-Wextra}.
8855
8856@include cppwarnopts.texi
8857
d77de738
ML
8858@opindex Wbad-function-cast
8859@opindex Wno-bad-function-cast
ddf6fe37 8860@item -Wbad-function-cast @r{(C and Objective-C only)}
d77de738
ML
8861Warn when a function call is cast to a non-matching type.
8862For example, warn if a call to a function returning an integer type
8863is cast to a pointer type.
8864
d77de738
ML
8865@opindex Wc90-c99-compat
8866@opindex Wno-c90-c99-compat
ddf6fe37 8867@item -Wc90-c99-compat @r{(C and Objective-C only)}
d77de738
ML
8868Warn about features not present in ISO C90, but present in ISO C99.
8869For instance, warn about use of variable length arrays, @code{long long}
8870type, @code{bool} type, compound literals, designated initializers, and so
8871on. This option is independent of the standards mode. Warnings are disabled
8872in the expression that follows @code{__extension__}.
8873
d77de738
ML
8874@opindex Wc99-c11-compat
8875@opindex Wno-c99-c11-compat
ddf6fe37 8876@item -Wc99-c11-compat @r{(C and Objective-C only)}
d77de738
ML
8877Warn about features not present in ISO C99, but present in ISO C11.
8878For instance, warn about use of anonymous structures and unions,
8879@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8880@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8881and so on. This option is independent of the standards mode. Warnings are
8882disabled in the expression that follows @code{__extension__}.
8883
d77de738
ML
8884@opindex Wc11-c2x-compat
8885@opindex Wno-c11-c2x-compat
ddf6fe37 8886@item -Wc11-c2x-compat @r{(C and Objective-C only)}
d77de738
ML
8887Warn about features not present in ISO C11, but present in ISO C2X.
8888For instance, warn about omitting the string in @code{_Static_assert},
8889use of @samp{[[]]} syntax for attributes, use of decimal
8890floating-point types, and so on. This option is independent of the
8891standards mode. Warnings are disabled in the expression that follows
8892@code{__extension__}.
8893
5fccebdb
JM
8894When not compiling in C2X mode, these warnings are upgraded to errors
8895by @option{-pedantic-errors}.
8896
d77de738
ML
8897@opindex Wc++-compat
8898@opindex Wno-c++-compat
ddf6fe37 8899@item -Wc++-compat @r{(C and Objective-C only)}
d77de738
ML
8900Warn about ISO C constructs that are outside of the common subset of
8901ISO C and ISO C++, e.g.@: request for implicit conversion from
8902@code{void *} to a pointer to non-@code{void} type.
8903
d77de738
ML
8904@opindex Wc++11-compat
8905@opindex Wno-c++11-compat
ddf6fe37 8906@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8907Warn about C++ constructs whose meaning differs between ISO C++ 1998
8908and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8909in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8910enabled by @option{-Wall}.
8911
d77de738
ML
8912@opindex Wc++14-compat
8913@opindex Wno-c++14-compat
ddf6fe37 8914@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8915Warn about C++ constructs whose meaning differs between ISO C++ 2011
8916and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8917
d77de738
ML
8918@opindex Wc++17-compat
8919@opindex Wno-c++17-compat
ddf6fe37 8920@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8921Warn about C++ constructs whose meaning differs between ISO C++ 2014
8922and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8923
d77de738
ML
8924@opindex Wc++20-compat
8925@opindex Wno-c++20-compat
ddf6fe37 8926@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8927Warn about C++ constructs whose meaning differs between ISO C++ 2017
8928and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8929
d77de738
ML
8930@opindex Wc++11-extensions
8931@opindex Wno-c++11-extensions
ddf6fe37 8932@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8933Do not warn about C++11 constructs in code being compiled using
8934an older C++ standard. Even without this option, some C++11 constructs
8935will only be diagnosed if @option{-Wpedantic} is used.
8936
d77de738
ML
8937@opindex Wc++14-extensions
8938@opindex Wno-c++14-extensions
ddf6fe37 8939@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8940Do not warn about C++14 constructs in code being compiled using
8941an older C++ standard. Even without this option, some C++14 constructs
8942will only be diagnosed if @option{-Wpedantic} is used.
8943
d77de738
ML
8944@opindex Wc++17-extensions
8945@opindex Wno-c++17-extensions
ddf6fe37 8946@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8947Do not warn about C++17 constructs in code being compiled using
8948an older C++ standard. Even without this option, some C++17 constructs
8949will only be diagnosed if @option{-Wpedantic} is used.
8950
d77de738
ML
8951@opindex Wc++20-extensions
8952@opindex Wno-c++20-extensions
ddf6fe37 8953@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8954Do not warn about C++20 constructs in code being compiled using
8955an older C++ standard. Even without this option, some C++20 constructs
8956will only be diagnosed if @option{-Wpedantic} is used.
8957
d77de738
ML
8958@opindex Wc++23-extensions
8959@opindex Wno-c++23-extensions
ddf6fe37 8960@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8961Do not warn about C++23 constructs in code being compiled using
8962an older C++ standard. Even without this option, some C++23 constructs
8963will only be diagnosed if @option{-Wpedantic} is used.
8964
d77de738
ML
8965@opindex Wcast-qual
8966@opindex Wno-cast-qual
ddf6fe37 8967@item -Wcast-qual
d77de738
ML
8968Warn whenever a pointer is cast so as to remove a type qualifier from
8969the target type. For example, warn if a @code{const char *} is cast
8970to an ordinary @code{char *}.
8971
8972Also warn when making a cast that introduces a type qualifier in an
8973unsafe way. For example, casting @code{char **} to @code{const char **}
8974is unsafe, as in this example:
8975
8976@smallexample
8977 /* p is char ** value. */
8978 const char **q = (const char **) p;
8979 /* Assignment of readonly string to const char * is OK. */
8980 *q = "string";
8981 /* Now char** pointer points to read-only memory. */
8982 **p = 'b';
8983@end smallexample
8984
d77de738
ML
8985@opindex Wcast-align
8986@opindex Wno-cast-align
ddf6fe37 8987@item -Wcast-align
d77de738
ML
8988Warn whenever a pointer is cast such that the required alignment of the
8989target is increased. For example, warn if a @code{char *} is cast to
8990an @code{int *} on machines where integers can only be accessed at
8991two- or four-byte boundaries.
8992
d77de738 8993@opindex Wcast-align=strict
ddf6fe37 8994@item -Wcast-align=strict
d77de738
ML
8995Warn whenever a pointer is cast such that the required alignment of the
8996target is increased. For example, warn if a @code{char *} is cast to
8997an @code{int *} regardless of the target machine.
8998
d77de738
ML
8999@opindex Wcast-function-type
9000@opindex Wno-cast-function-type
ddf6fe37 9001@item -Wcast-function-type
d77de738
ML
9002Warn when a function pointer is cast to an incompatible function pointer.
9003In a cast involving function types with a variable argument list only
9004the types of initial arguments that are provided are considered.
9005Any parameter of pointer-type matches any other pointer-type. Any benign
9006differences in integral types are ignored, like @code{int} vs.@: @code{long}
9007on ILP32 targets. Likewise type qualifiers are ignored. The function
9008type @code{void (*) (void)} is special and matches everything, which can
9009be used to suppress this warning.
9010In a cast involving pointer to member types this warning warns whenever
9011the type cast is changing the pointer to member type.
9012This warning is enabled by @option{-Wextra}.
9013
d77de738
ML
9014@opindex Wwrite-strings
9015@opindex Wno-write-strings
ddf6fe37 9016@item -Wwrite-strings
d77de738
ML
9017When compiling C, give string constants the type @code{const
9018char[@var{length}]} so that copying the address of one into a
9019non-@code{const} @code{char *} pointer produces a warning. These
9020warnings help you find at compile time code that can try to write
9021into a string constant, but only if you have been very careful about
9022using @code{const} in declarations and prototypes. Otherwise, it is
9023just a nuisance. This is why we did not make @option{-Wall} request
9024these warnings.
9025
9026When compiling C++, warn about the deprecated conversion from string
9027literals to @code{char *}. This warning is enabled by default for C++
9028programs.
9029
5fccebdb
JM
9030This warning is upgraded to an error by @option{-pedantic-errors} in
9031C++11 mode or later.
9032
d77de738
ML
9033@opindex Wclobbered
9034@opindex Wno-clobbered
f33d7a88 9035@item -Wclobbered
d77de738
ML
9036Warn for variables that might be changed by @code{longjmp} or
9037@code{vfork}. This warning is also enabled by @option{-Wextra}.
9038
320dc51c
TS
9039@opindex Wcomplain-wrong-lang
9040@opindex Wno-complain-wrong-lang
f33d7a88 9041@item -Wno-complain-wrong-lang
320dc51c
TS
9042By default, language front ends complain when a command-line option is
9043valid, but not applicable to that front end.
9044This may be disabled with @option{-Wno-complain-wrong-lang},
9045which is mostly useful when invoking a single compiler driver for
9046multiple source files written in different languages, for example:
9047
9048@smallexample
9049$ g++ -fno-rtti a.cc b.f90
9050@end smallexample
9051
9052The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
9053and the Fortran front end to compile @file{b.f90}.
9054The latter front end diagnoses
9055@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
9056which may be disabled with @option{-Wno-complain-wrong-lang}.
9057
d77de738
ML
9058@opindex Wconversion
9059@opindex Wno-conversion
f33d7a88 9060@item -Wconversion
d77de738
ML
9061Warn for implicit conversions that may alter a value. This includes
9062conversions between real and integer, like @code{abs (x)} when
9063@code{x} is @code{double}; conversions between signed and unsigned,
9064like @code{unsigned ui = -1}; and conversions to smaller types, like
9065@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
9066((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
9067changed by the conversion like in @code{abs (2.0)}. Warnings about
9068conversions between signed and unsigned integers can be disabled by
9069using @option{-Wno-sign-conversion}.
9070
9071For C++, also warn for confusing overload resolution for user-defined
9072conversions; and conversions that never use a type conversion
9073operator: conversions to @code{void}, the same type, a base class or a
9074reference to them. Warnings about conversions between signed and
9075unsigned integers are disabled by default in C++ unless
9076@option{-Wsign-conversion} is explicitly enabled.
9077
9078Warnings about conversion from arithmetic on a small type back to that
9079type are only given with @option{-Warith-conversion}.
9080
d77de738
ML
9081@opindex Wdangling-else
9082@opindex Wno-dangling-else
ddf6fe37 9083@item -Wdangling-else
d77de738
ML
9084Warn about constructions where there may be confusion to which
9085@code{if} statement an @code{else} branch belongs. Here is an example of
9086such a case:
9087
9088@smallexample
9089@group
9090@{
9091 if (a)
9092 if (b)
9093 foo ();
9094 else
9095 bar ();
9096@}
9097@end group
9098@end smallexample
9099
9100In C/C++, every @code{else} branch belongs to the innermost possible
9101@code{if} statement, which in this example is @code{if (b)}. This is
9102often not what the programmer expected, as illustrated in the above
9103example by indentation the programmer chose. When there is the
9104potential for this confusion, GCC issues a warning when this flag
9105is specified. To eliminate the warning, add explicit braces around
9106the innermost @code{if} statement so there is no way the @code{else}
9107can belong to the enclosing @code{if}. The resulting code
9108looks like this:
9109
9110@smallexample
9111@group
9112@{
9113 if (a)
9114 @{
9115 if (b)
9116 foo ();
9117 else
9118 bar ();
9119 @}
9120@}
9121@end group
9122@end smallexample
9123
9124This warning is enabled by @option{-Wparentheses}.
9125
d77de738
ML
9126@opindex Wdangling-pointer
9127@opindex Wno-dangling-pointer
ddf6fe37
AA
9128@item -Wdangling-pointer
9129@itemx -Wdangling-pointer=@var{n}
d77de738
ML
9130Warn about uses of pointers (or C++ references) to objects with automatic
9131storage duration after their lifetime has ended. This includes local
9132variables declared in nested blocks, compound literals and other unnamed
9133temporary objects. In addition, warn about storing the address of such
9134objects in escaped pointers. The warning is enabled at all optimization
9135levels but may yield different results with optimization than without.
9136
9137@table @gcctabopt
9138@item -Wdangling-pointer=1
9139At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9140For example
9141@smallexample
9142int f (int c1, int c2, x)
9143@{
9144 char *p = strchr ((char[])@{ c1, c2 @}, c3);
4ace81b6
SL
9145 // warning: dangling pointer to a compound literal
9146 return p ? *p : 'x';
d77de738
ML
9147@}
9148@end smallexample
9149In the following function the store of the address of the local variable
9150@code{x} in the escaped pointer @code{*p} also triggers the warning.
9151@smallexample
9152void g (int **p)
9153@{
9154 int x = 7;
4ace81b6
SL
9155 // warning: storing the address of a local variable in *p
9156 *p = &x;
d77de738
ML
9157@}
9158@end smallexample
9159
9160@item -Wdangling-pointer=2
9161At level 2, in addition to unconditional uses the warning also diagnoses
9162conditional uses of dangling pointers.
9163
9164For example, because the array @var{a} in the following function is out of
9165scope when the pointer @var{s} that was set to point is used, the warning
9166triggers at this level.
9167
9168@smallexample
9169void f (char *s)
9170@{
9171 if (!s)
9172 @{
9173 char a[12] = "tmpname";
9174 s = a;
9175 @}
4ace81b6
SL
9176 // warning: dangling pointer to a may be used
9177 strcat (s, ".tmp");
d77de738
ML
9178 ...
9179@}
9180@end smallexample
9181@end table
9182
9183@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9184
d77de738
ML
9185@opindex Wdate-time
9186@opindex Wno-date-time
ddf6fe37 9187@item -Wdate-time
d77de738
ML
9188Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9189are encountered as they might prevent bit-wise-identical reproducible
9190compilations.
9191
d77de738
ML
9192@opindex Wempty-body
9193@opindex Wno-empty-body
ddf6fe37 9194@item -Wempty-body
d77de738
ML
9195Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9196while} statement. This warning is also enabled by @option{-Wextra}.
9197
d77de738
ML
9198@opindex Wendif-labels
9199@opindex Wno-endif-labels
ddf6fe37 9200@item -Wno-endif-labels
d77de738
ML
9201Do not warn about stray tokens after @code{#else} and @code{#endif}.
9202
d77de738
ML
9203@opindex Wenum-compare
9204@opindex Wno-enum-compare
ddf6fe37 9205@item -Wenum-compare
d77de738
ML
9206Warn about a comparison between values of different enumerated types.
9207In C++ enumerated type mismatches in conditional expressions are also
9208diagnosed and the warning is enabled by default. In C this warning is
9209enabled by @option{-Wall}.
9210
d77de738
ML
9211@opindex Wenum-conversion
9212@opindex Wno-enum-conversion
ddf6fe37 9213@item -Wenum-conversion
d77de738
ML
9214Warn when a value of enumerated type is implicitly converted to a
9215different enumerated type. This warning is enabled by @option{-Wextra}
9216in C@.
9217
d77de738
ML
9218@opindex Wenum-int-mismatch
9219@opindex Wno-enum-int-mismatch
ddf6fe37 9220@item -Wenum-int-mismatch @r{(C and Objective-C only)}
d77de738
ML
9221Warn about mismatches between an enumerated type and an integer type in
9222declarations. For example:
9223
9224@smallexample
9225enum E @{ l = -1, z = 0, g = 1 @};
9226int foo(void);
9227enum E foo(void);
9228@end smallexample
9229
9230In C, an enumerated type is compatible with @code{char}, a signed
9231integer type, or an unsigned integer type. However, since the choice
9232of the underlying type of an enumerated type is implementation-defined,
9233such mismatches may cause portability issues. In C++, such mismatches
9234are an error. In C, this warning is enabled by @option{-Wall} and
9235@option{-Wc++-compat}.
9236
d77de738
ML
9237@opindex Wjump-misses-init
9238@opindex Wno-jump-misses-init
ddf6fe37 9239@item -Wjump-misses-init @r{(C, Objective-C only)}
d77de738
ML
9240Warn if a @code{goto} statement or a @code{switch} statement jumps
9241forward across the initialization of a variable, or jumps backward to a
9242label after the variable has been initialized. This only warns about
9243variables that are initialized when they are declared. This warning is
9244only supported for C and Objective-C; in C++ this sort of branch is an
9245error in any case.
9246
9247@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9248can be disabled with the @option{-Wno-jump-misses-init} option.
9249
d77de738
ML
9250@opindex Wsign-compare
9251@opindex Wno-sign-compare
9252@cindex warning for comparison of signed and unsigned values
9253@cindex comparison of signed and unsigned values, warning
9254@cindex signed and unsigned values, comparison warning
f33d7a88 9255@item -Wsign-compare
d77de738
ML
9256Warn when a comparison between signed and unsigned values could produce
9257an incorrect result when the signed value is converted to unsigned.
9258In C++, this warning is also enabled by @option{-Wall}. In C, it is
9259also enabled by @option{-Wextra}.
9260
d77de738
ML
9261@opindex Wsign-conversion
9262@opindex Wno-sign-conversion
ddf6fe37 9263@item -Wsign-conversion
d77de738
ML
9264Warn for implicit conversions that may change the sign of an integer
9265value, like assigning a signed integer expression to an unsigned
9266integer variable. An explicit cast silences the warning. In C, this
9267option is enabled also by @option{-Wconversion}.
9268
d77de738
ML
9269@opindex Wfloat-conversion
9270@opindex Wno-float-conversion
ddf6fe37 9271@item -Wfloat-conversion
d77de738
ML
9272Warn for implicit conversions that reduce the precision of a real value.
9273This includes conversions from real to integer, and from higher precision
9274real to lower precision real values. This option is also enabled by
9275@option{-Wconversion}.
9276
d77de738
ML
9277@opindex Wno-scalar-storage-order
9278@opindex Wscalar-storage-order
ddf6fe37 9279@item -Wno-scalar-storage-order
d77de738
ML
9280Do not warn on suspicious constructs involving reverse scalar storage order.
9281
d77de738
ML
9282@opindex Wsizeof-array-div
9283@opindex Wno-sizeof-array-div
ddf6fe37 9284@item -Wsizeof-array-div
d77de738
ML
9285Warn about divisions of two sizeof operators when the first one is applied
9286to an array and the divisor does not equal the size of the array element.
9287In such a case, the computation will not yield the number of elements in the
9288array, which is likely what the user intended. This warning warns e.g. about
9289@smallexample
9290int fn ()
9291@{
9292 int arr[10];
9293 return sizeof (arr) / sizeof (short);
9294@}
9295@end smallexample
9296
9297This warning is enabled by @option{-Wall}.
9298
d77de738
ML
9299@opindex Wsizeof-pointer-div
9300@opindex Wno-sizeof-pointer-div
ddf6fe37 9301@item -Wsizeof-pointer-div
d77de738
ML
9302Warn for suspicious divisions of two sizeof expressions that divide
9303the pointer size by the element size, which is the usual way to compute
9304the array size but won't work out correctly with pointers. This warning
9305warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9306not an array, but a pointer. This warning is enabled by @option{-Wall}.
9307
d77de738
ML
9308@opindex Wsizeof-pointer-memaccess
9309@opindex Wno-sizeof-pointer-memaccess
ddf6fe37 9310@item -Wsizeof-pointer-memaccess
d77de738
ML
9311Warn for suspicious length parameters to certain string and memory built-in
9312functions if the argument uses @code{sizeof}. This warning triggers for
9313example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9314an array, but a pointer, and suggests a possible fix, or about
9315@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9316also warns about calls to bounded string copy functions like @code{strncat}
9317or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9318the source array. For example, in the following function the call to
9319@code{strncat} specifies the size of the source string as the bound. That
9320is almost certainly a mistake and so the call is diagnosed.
9321@smallexample
9322void make_file (const char *name)
9323@{
9324 char path[PATH_MAX];
9325 strncpy (path, name, sizeof path - 1);
9326 strncat (path, ".text", sizeof ".text");
9327 @dots{}
9328@}
9329@end smallexample
9330
9331The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9332
d77de738
ML
9333@opindex Wsizeof-array-argument
9334@opindex Wno-sizeof-array-argument
ddf6fe37 9335@item -Wno-sizeof-array-argument
d77de738
ML
9336Do not warn when the @code{sizeof} operator is applied to a parameter that is
9337declared as an array in a function definition. This warning is enabled by
9338default for C and C++ programs.
9339
d77de738
ML
9340@opindex Wmemset-elt-size
9341@opindex Wno-memset-elt-size
ddf6fe37 9342@item -Wmemset-elt-size
d77de738
ML
9343Warn for suspicious calls to the @code{memset} built-in function, if the
9344first argument references an array, and the third argument is a number
9345equal to the number of elements, but not equal to the size of the array
9346in memory. This indicates that the user has omitted a multiplication by
9347the element size. This warning is enabled by @option{-Wall}.
9348
d77de738
ML
9349@opindex Wmemset-transposed-args
9350@opindex Wno-memset-transposed-args
ddf6fe37 9351@item -Wmemset-transposed-args
d77de738
ML
9352Warn for suspicious calls to the @code{memset} built-in function where
9353the second argument is not zero and the third argument is zero. For
9354example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9355@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9356is only emitted if the third argument is a literal zero. Otherwise, if
9357it is an expression that is folded to zero, or a cast of zero to some
9358type, it is far less likely that the arguments have been mistakenly
9359transposed and no warning is emitted. This warning is enabled
9360by @option{-Wall}.
9361
d77de738
ML
9362@opindex Waddress
9363@opindex Wno-address
ddf6fe37 9364@item -Waddress
d77de738
ML
9365Warn about suspicious uses of address expressions. These include comparing
9366the address of a function or a declared object to the null pointer constant
9367such as in
9368@smallexample
9369void f (void);
9370void g (void)
9371@{
9372 if (!f) // warning: expression evaluates to false
9373 abort ();
9374@}
9375@end smallexample
9376comparisons of a pointer to a string literal, such as in
9377@smallexample
9378void f (const char *x)
9379@{
9380 if (x == "abc") // warning: expression evaluates to false
9381 puts ("equal");
9382@}
9383@end smallexample
9384and tests of the results of pointer addition or subtraction for equality
9385to null, such as in
9386@smallexample
9387void f (const int *p, int i)
9388@{
9389 return p + i == NULL;
9390@}
9391@end smallexample
9392Such uses typically indicate a programmer error: the address of most
9393functions and objects necessarily evaluates to true (the exception are
9394weak symbols), so their use in a conditional might indicate missing
9395parentheses in a function call or a missing dereference in an array
9396expression. The subset of the warning for object pointers can be
9397suppressed by casting the pointer operand to an integer type such
9398as @code{intptr_t} or @code{uintptr_t}.
9399Comparisons against string literals result in unspecified behavior
9400and are not portable, and suggest the intent was to call @code{strcmp}.
9401The warning is suppressed if the suspicious expression is the result
9402of macro expansion.
9403@option{-Waddress} warning is enabled by @option{-Wall}.
9404
d77de738
ML
9405@opindex Waddress-of-packed-member
9406@opindex Wno-address-of-packed-member
ddf6fe37 9407@item -Wno-address-of-packed-member
d77de738
ML
9408Do not warn when the address of packed member of struct or union is taken,
9409which usually results in an unaligned pointer value. This is
9410enabled by default.
9411
d77de738
ML
9412@opindex Wlogical-op
9413@opindex Wno-logical-op
ddf6fe37 9414@item -Wlogical-op
d77de738
ML
9415Warn about suspicious uses of logical operators in expressions.
9416This includes using logical operators in contexts where a
9417bit-wise operator is likely to be expected. Also warns when
9418the operands of a logical operator are the same:
9419@smallexample
9420extern int a;
9421if (a < 0 && a < 0) @{ @dots{} @}
9422@end smallexample
9423
d77de738
ML
9424@opindex Wlogical-not-parentheses
9425@opindex Wno-logical-not-parentheses
ddf6fe37 9426@item -Wlogical-not-parentheses
d77de738
ML
9427Warn about logical not used on the left hand side operand of a comparison.
9428This option does not warn if the right operand is considered to be a boolean
9429expression. Its purpose is to detect suspicious code like the following:
9430@smallexample
9431int a;
9432@dots{}
9433if (!a > 1) @{ @dots{} @}
9434@end smallexample
9435
9436It is possible to suppress the warning by wrapping the LHS into
9437parentheses:
9438@smallexample
9439if ((!a) > 1) @{ @dots{} @}
9440@end smallexample
9441
9442This warning is enabled by @option{-Wall}.
9443
d77de738
ML
9444@opindex Waggregate-return
9445@opindex Wno-aggregate-return
ddf6fe37 9446@item -Waggregate-return
d77de738
ML
9447Warn if any functions that return structures or unions are defined or
9448called. (In languages where you can return an array, this also elicits
9449a warning.)
9450
d77de738
ML
9451@opindex Wno-aggressive-loop-optimizations
9452@opindex Waggressive-loop-optimizations
ddf6fe37 9453@item -Wno-aggressive-loop-optimizations
d77de738
ML
9454Warn if in a loop with constant number of iterations the compiler detects
9455undefined behavior in some statement during one or more of the iterations.
9456
d77de738
ML
9457@opindex Wno-attributes
9458@opindex Wattributes
ddf6fe37 9459@item -Wno-attributes
d77de738
ML
9460Do not warn if an unexpected @code{__attribute__} is used, such as
9461unrecognized attributes, function attributes applied to variables,
9462etc. This does not stop errors for incorrect use of supported
9463attributes.
9464
5fccebdb
JM
9465Warnings about ill-formed uses of standard attributes are upgraded to
9466errors by @option{-pedantic-errors}.
9467
d77de738
ML
9468Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9469warnings about unknown scoped attributes (in C++11 and C2X). For example,
9470@option{-Wno-attributes=vendor::attr} disables warning about the following
9471declaration:
9472
9473@smallexample
9474[[vendor::attr]] void f();
9475@end smallexample
9476
9477It is also possible to disable warning about all attributes in a namespace
9478using @option{-Wno-attributes=vendor::} which prevents warning about both
9479of these declarations:
9480
9481@smallexample
9482[[vendor::safe]] void f();
9483[[vendor::unsafe]] void f2();
9484@end smallexample
9485
9486Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9487
d77de738
ML
9488@opindex Wno-builtin-declaration-mismatch
9489@opindex Wbuiltin-declaration-mismatch
ddf6fe37 9490@item -Wno-builtin-declaration-mismatch
d77de738
ML
9491Warn if a built-in function is declared with an incompatible signature
9492or as a non-function, or when a built-in function declared with a type
9493that does not include a prototype is called with arguments whose promoted
9494types do not match those expected by the function. When @option{-Wextra}
9495is specified, also warn when a built-in function that takes arguments is
9496declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9497warning is enabled by default. To avoid the warning include the appropriate
9498header to bring the prototypes of built-in functions into scope.
9499
9500For example, the call to @code{memset} below is diagnosed by the warning
9501because the function expects a value of type @code{size_t} as its argument
9502but the type of @code{32} is @code{int}. With @option{-Wextra},
9503the declaration of the function is diagnosed as well.
9504@smallexample
9505extern void* memset ();
9506void f (void *d)
9507@{
9508 memset (d, '\0', 32);
9509@}
9510@end smallexample
9511
d77de738
ML
9512@opindex Wno-builtin-macro-redefined
9513@opindex Wbuiltin-macro-redefined
ddf6fe37 9514@item -Wno-builtin-macro-redefined
d77de738
ML
9515Do not warn if certain built-in macros are redefined. This suppresses
9516warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9517@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9518
d77de738
ML
9519@opindex Wstrict-prototypes
9520@opindex Wno-strict-prototypes
ddf6fe37 9521@item -Wstrict-prototypes @r{(C and Objective-C only)}
d77de738
ML
9522Warn if a function is declared or defined without specifying the
9523argument types. (An old-style function definition is permitted without
9524a warning if preceded by a declaration that specifies the argument
9525types.)
9526
d77de738
ML
9527@opindex Wold-style-declaration
9528@opindex Wno-old-style-declaration
ddf6fe37 9529@item -Wold-style-declaration @r{(C and Objective-C only)}
d77de738
ML
9530Warn for obsolescent usages, according to the C Standard, in a
9531declaration. For example, warn if storage-class specifiers like
9532@code{static} are not the first things in a declaration. This warning
9533is also enabled by @option{-Wextra}.
9534
d77de738
ML
9535@opindex Wold-style-definition
9536@opindex Wno-old-style-definition
ddf6fe37 9537@item -Wold-style-definition @r{(C and Objective-C only)}
d77de738
ML
9538Warn if an old-style function definition is used. A warning is given
9539even if there is a previous prototype. A definition using @samp{()}
9540is not considered an old-style definition in C2X mode, because it is
9541equivalent to @samp{(void)} in that case, but is considered an
9542old-style definition for older standards.
9543
d77de738
ML
9544@opindex Wmissing-parameter-type
9545@opindex Wno-missing-parameter-type
ddf6fe37 9546@item -Wmissing-parameter-type @r{(C and Objective-C only)}
d77de738
ML
9547A function parameter is declared without a type specifier in K&R-style
9548functions:
9549
9550@smallexample
9551void foo(bar) @{ @}
9552@end smallexample
9553
9554This warning is also enabled by @option{-Wextra}.
9555
d77de738
ML
9556@opindex Wmissing-prototypes
9557@opindex Wno-missing-prototypes
ddf6fe37 9558@item -Wmissing-prototypes @r{(C and Objective-C only)}
d77de738
ML
9559Warn if a global function is defined without a previous prototype
9560declaration. This warning is issued even if the definition itself
9561provides a prototype. Use this option to detect global functions
9562that do not have a matching prototype declaration in a header file.
9563This option is not valid for C++ because all function declarations
9564provide prototypes and a non-matching declaration declares an
9565overload rather than conflict with an earlier declaration.
9566Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9567
d77de738
ML
9568@opindex Wmissing-declarations
9569@opindex Wno-missing-declarations
ddf6fe37 9570@item -Wmissing-declarations
d77de738
ML
9571Warn if a global function is defined without a previous declaration.
9572Do so even if the definition itself provides a prototype.
9573Use this option to detect global functions that are not declared in
9574header files. In C, no warnings are issued for functions with previous
9575non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9576missing prototypes. In C++, no warnings are issued for function templates,
9577or for inline functions, or for functions in anonymous namespaces.
9578
d77de738
ML
9579@opindex Wmissing-field-initializers
9580@opindex Wno-missing-field-initializers
9581@opindex W
9582@opindex Wextra
9583@opindex Wno-extra
ddf6fe37 9584@item -Wmissing-field-initializers
d77de738
ML
9585Warn if a structure's initializer has some fields missing. For
9586example, the following code causes such a warning, because
9587@code{x.h} is implicitly zero:
9588
9589@smallexample
9590struct s @{ int f, g, h; @};
9591struct s x = @{ 3, 4 @};
9592@end smallexample
9593
0f8f1dee
MP
9594@c It's unclear if this behavior is desirable. See PR39589 and PR96868.
9595In C this option does not warn about designated initializers, so the
9596following modification does not trigger a warning:
d77de738
ML
9597
9598@smallexample
9599struct s @{ int f, g, h; @};
9600struct s x = @{ .f = 3, .g = 4 @};
9601@end smallexample
9602
9603In C this option does not warn about the universal zero initializer
9604@samp{@{ 0 @}}:
9605
9606@smallexample
9607struct s @{ int f, g, h; @};
9608struct s x = @{ 0 @};
9609@end smallexample
9610
9611Likewise, in C++ this option does not warn about the empty @{ @}
9612initializer, for example:
9613
9614@smallexample
9615struct s @{ int f, g, h; @};
9616s x = @{ @};
9617@end smallexample
9618
9619This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9620warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9621
d77de738
ML
9622@opindex Wmissing-requires
9623@opindex Wno-missing-requires
ddf6fe37 9624@item -Wno-missing-requires
d77de738
ML
9625
9626By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9627
9628@smallexample
9629bool satisfied = requires @{ C<T> @};
9630@end smallexample
9631
9632Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9633expression, which it is for all T. Presumably the user meant to write
9634
9635@smallexample
9636bool satisfied = requires @{ requires C<T> @};
9637@end smallexample
9638
9639so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9640type @samp{T}.
9641
9642This warning can be disabled with @option{-Wno-missing-requires}.
9643
d77de738
ML
9644@opindex Wmissing-template-keyword
9645@opindex Wno-missing-template-keyword
ddf6fe37 9646@item -Wno-missing-template-keyword
d77de738
ML
9647
9648The member access tokens ., -> and :: must be followed by the @code{template}
9649keyword if the parent object is dependent and the member being named is a
9650template.
9651
9652@smallexample
9653template <class X>
9654void DoStuff (X x)
9655@{
9656 x.template DoSomeOtherStuff<X>(); // Good.
9657 x.DoMoreStuff<X>(); // Warning, x is dependent.
9658@}
9659@end smallexample
9660
9661In rare cases it is possible to get false positives. To silence this, wrap
9662the expression in parentheses. For example, the following is treated as a
9663template, even where m and N are integers:
9664
9665@smallexample
9666void NotATemplate (my_class t)
9667@{
9668 int N = 5;
9669
9670 bool test = t.m < N > (0); // Treated as a template.
9671 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9672@}
9673@end smallexample
9674
9675This warning can be disabled with @option{-Wno-missing-template-keyword}.
9676
d77de738
ML
9677@opindex Wno-multichar
9678@opindex Wmultichar
ddf6fe37 9679@item -Wno-multichar
d77de738
ML
9680Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9681Usually they indicate a typo in the user's code, as they have
9682implementation-defined values, and should not be used in portable code.
9683
d77de738
ML
9684@opindex Wnormalized=
9685@opindex Wnormalized
9686@opindex Wno-normalized
9687@cindex NFC
9688@cindex NFKC
9689@cindex character set, input normalization
f33d7a88 9690@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
d77de738
ML
9691In ISO C and ISO C++, two identifiers are different if they are
9692different sequences of characters. However, sometimes when characters
9693outside the basic ASCII character set are used, you can have two
9694different character sequences that look the same. To avoid confusion,
9695the ISO 10646 standard sets out some @dfn{normalization rules} which
9696when applied ensure that two sequences that look the same are turned into
9697the same sequence. GCC can warn you if you are using identifiers that
9698have not been normalized; this option controls that warning.
9699
9700There are four levels of warning supported by GCC@. The default is
9701@option{-Wnormalized=nfc}, which warns about any identifier that is
9702not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9703recommended form for most uses. It is equivalent to
9704@option{-Wnormalized}.
9705
9706Unfortunately, there are some characters allowed in identifiers by
9707ISO C and ISO C++ that, when turned into NFC, are not allowed in
9708identifiers. That is, there's no way to use these symbols in portable
9709ISO C or C++ and have all your identifiers in NFC@.
9710@option{-Wnormalized=id} suppresses the warning for these characters.
9711It is hoped that future versions of the standards involved will correct
9712this, which is why this option is not the default.
9713
9714You can switch the warning off for all characters by writing
9715@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9716only do this if you are using some other normalization scheme (like
9717``D''), because otherwise you can easily create bugs that are
9718literally impossible to see.
9719
9720Some characters in ISO 10646 have distinct meanings but look identical
9721in some fonts or display methodologies, especially once formatting has
9722been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9723LETTER N'', displays just like a regular @code{n} that has been
9724placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9725normalization scheme to convert all these into a standard form as
9726well, and GCC warns if your code is not in NFKC if you use
9727@option{-Wnormalized=nfkc}. This warning is comparable to warning
9728about every identifier that contains the letter O because it might be
9729confused with the digit 0, and so is not the default, but may be
9730useful as a local coding convention if the programming environment
9731cannot be fixed to display these characters distinctly.
9732
d77de738
ML
9733@opindex Wno-attribute-warning
9734@opindex Wattribute-warning
ddf6fe37 9735@item -Wno-attribute-warning
d77de738
ML
9736Do not warn about usage of functions (@pxref{Function Attributes})
9737declared with @code{warning} attribute. By default, this warning is
9738enabled. @option{-Wno-attribute-warning} can be used to disable the
9739warning or @option{-Wno-error=attribute-warning} can be used to
9740disable the error when compiled with @option{-Werror} flag.
9741
d77de738
ML
9742@opindex Wno-deprecated
9743@opindex Wdeprecated
ddf6fe37 9744@item -Wno-deprecated
d77de738
ML
9745Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9746
d77de738
ML
9747@opindex Wno-deprecated-declarations
9748@opindex Wdeprecated-declarations
ddf6fe37 9749@item -Wno-deprecated-declarations
d77de738
ML
9750Do not warn about uses of functions (@pxref{Function Attributes}),
9751variables (@pxref{Variable Attributes}), and types (@pxref{Type
9752Attributes}) marked as deprecated by using the @code{deprecated}
9753attribute.
9754
d77de738
ML
9755@opindex Wno-overflow
9756@opindex Woverflow
ddf6fe37 9757@item -Wno-overflow
d77de738
ML
9758Do not warn about compile-time overflow in constant expressions.
9759
d77de738
ML
9760@opindex Wno-odr
9761@opindex Wodr
ddf6fe37 9762@item -Wno-odr
d77de738
ML
9763Warn about One Definition Rule violations during link-time optimization.
9764Enabled by default.
9765
d77de738
ML
9766@opindex Wopenacc-parallelism
9767@opindex Wno-openacc-parallelism
9768@cindex OpenACC accelerator programming
f33d7a88 9769@item -Wopenacc-parallelism
d77de738
ML
9770Warn about potentially suboptimal choices related to OpenACC parallelism.
9771
d77de738
ML
9772@opindex Wopenmp-simd
9773@opindex Wno-openmp-simd
ddf6fe37 9774@item -Wopenmp-simd
d77de738
ML
9775Warn if the vectorizer cost model overrides the OpenMP
9776simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9777option can be used to relax the cost model.
9778
d77de738
ML
9779@opindex Woverride-init
9780@opindex Wno-override-init
9781@opindex W
9782@opindex Wextra
9783@opindex Wno-extra
ddf6fe37 9784@item -Woverride-init @r{(C and Objective-C only)}
d77de738
ML
9785Warn if an initialized field without side effects is overridden when
9786using designated initializers (@pxref{Designated Inits, , Designated
9787Initializers}).
9788
9789This warning is included in @option{-Wextra}. To get other
9790@option{-Wextra} warnings without this one, use @option{-Wextra
9791-Wno-override-init}.
9792
d77de738
ML
9793@opindex Woverride-init-side-effects
9794@opindex Wno-override-init-side-effects
ddf6fe37 9795@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
d77de738
ML
9796Do not warn if an initialized field with side effects is overridden when
9797using designated initializers (@pxref{Designated Inits, , Designated
9798Initializers}). This warning is enabled by default.
9799
d77de738
ML
9800@opindex Wpacked
9801@opindex Wno-packed
ddf6fe37 9802@item -Wpacked
d77de738
ML
9803Warn if a structure is given the packed attribute, but the packed
9804attribute has no effect on the layout or size of the structure.
9805Such structures may be mis-aligned for little benefit. For
9806instance, in this code, the variable @code{f.x} in @code{struct bar}
9807is misaligned even though @code{struct bar} does not itself
9808have the packed attribute:
9809
9810@smallexample
9811@group
9812struct foo @{
9813 int x;
9814 char a, b, c, d;
9815@} __attribute__((packed));
9816struct bar @{
9817 char z;
9818 struct foo f;
9819@};
9820@end group
9821@end smallexample
9822
d77de738
ML
9823@opindex Wpacked-bitfield-compat
9824@opindex Wno-packed-bitfield-compat
ddf6fe37 9825@item -Wnopacked-bitfield-compat
d77de738
ML
9826The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9827on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9828the change can lead to differences in the structure layout. GCC
9829informs you when the offset of such a field has changed in GCC 4.4.
9830For example there is no longer a 4-bit padding between field @code{a}
9831and @code{b} in this structure:
9832
9833@smallexample
9834struct foo
9835@{
9836 char a:4;
9837 char b:8;
9838@} __attribute__ ((packed));
9839@end smallexample
9840
9841This warning is enabled by default. Use
9842@option{-Wno-packed-bitfield-compat} to disable this warning.
9843
d77de738
ML
9844@opindex Wpacked-not-aligned
9845@opindex Wno-packed-not-aligned
ddf6fe37 9846@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
9847Warn if a structure field with explicitly specified alignment in a
9848packed struct or union is misaligned. For example, a warning will
9849be issued on @code{struct S}, like, @code{warning: alignment 1 of
9850'struct S' is less than 8}, in this code:
9851
9852@smallexample
9853@group
9854struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9855struct __attribute__ ((packed)) S @{
9856 struct S8 s8;
9857@};
9858@end group
9859@end smallexample
9860
9861This warning is enabled by @option{-Wall}.
9862
d77de738
ML
9863@opindex Wpadded
9864@opindex Wno-padded
ddf6fe37 9865@item -Wpadded
d77de738
ML
9866Warn if padding is included in a structure, either to align an element
9867of the structure or to align the whole structure. Sometimes when this
9868happens it is possible to rearrange the fields of the structure to
9869reduce the padding and so make the structure smaller.
9870
d77de738
ML
9871@opindex Wredundant-decls
9872@opindex Wno-redundant-decls
ddf6fe37 9873@item -Wredundant-decls
d77de738
ML
9874Warn if anything is declared more than once in the same scope, even in
9875cases where multiple declaration is valid and changes nothing.
9876
d77de738
ML
9877@opindex Wrestrict
9878@opindex Wno-restrict
ddf6fe37 9879@item -Wrestrict
d77de738
ML
9880Warn when an object referenced by a @code{restrict}-qualified parameter
9881(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9882argument, or when copies between such objects overlap. For example,
9883the call to the @code{strcpy} function below attempts to truncate the string
9884by replacing its initial characters with the last four. However, because
9885the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9886the call is diagnosed.
9887
9888@smallexample
9889void foo (void)
9890@{
9891 char a[] = "abcd1234";
9892 strcpy (a, a + 4);
9893 @dots{}
9894@}
9895@end smallexample
9896The @option{-Wrestrict} option detects some instances of simple overlap
9897even without optimization but works best at @option{-O2} and above. It
9898is included in @option{-Wall}.
9899
d77de738
ML
9900@opindex Wnested-externs
9901@opindex Wno-nested-externs
ddf6fe37 9902@item -Wnested-externs @r{(C and Objective-C only)}
d77de738
ML
9903Warn if an @code{extern} declaration is encountered within a function.
9904
d77de738
ML
9905@opindex Winline
9906@opindex Wno-inline
ddf6fe37 9907@item -Winline
d77de738
ML
9908Warn if a function that is declared as inline cannot be inlined.
9909Even with this option, the compiler does not warn about failures to
9910inline functions declared in system headers.
9911
9912The compiler uses a variety of heuristics to determine whether or not
9913to inline a function. For example, the compiler takes into account
9914the size of the function being inlined and the amount of inlining
9915that has already been done in the current function. Therefore,
9916seemingly insignificant changes in the source program can cause the
9917warnings produced by @option{-Winline} to appear or disappear.
9918
d77de738 9919@opindex Winterference-size
ddf6fe37 9920@item -Winterference-size
d77de738
ML
9921Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9922without specifying its value with @option{--param destructive-interference-size}.
9923Also warn about questionable values for that option.
9924
9925This variable is intended to be used for controlling class layout, to
9926avoid false sharing in concurrent code:
9927
9928@smallexample
9929struct independent_fields @{
4ace81b6
SL
9930 alignas(std::hardware_destructive_interference_size)
9931 std::atomic<int> one;
9932 alignas(std::hardware_destructive_interference_size)
9933 std::atomic<int> two;
d77de738
ML
9934@};
9935@end smallexample
9936
9937Here @samp{one} and @samp{two} are intended to be far enough apart
9938that stores to one won't require accesses to the other to reload the
9939cache line.
9940
9941By default, @option{--param destructive-interference-size} and
9942@option{--param constructive-interference-size} are set based on the
9943current @option{-mtune} option, typically to the L1 cache line size
9944for the particular target CPU, sometimes to a range if tuning for a
9945generic target. So all translation units that depend on ABI
9946compatibility for the use of these variables must be compiled with
9947the same @option{-mtune} (or @option{-mcpu}).
9948
9949If ABI stability is important, such as if the use is in a header for a
9950library, you should probably not use the hardware interference size
9951variables at all. Alternatively, you can force a particular value
9952with @option{--param}.
9953
9954If you are confident that your use of the variable does not affect ABI
9955outside a single build of your project, you can turn off the warning
9956with @option{-Wno-interference-size}.
9957
d77de738
ML
9958@opindex Wint-in-bool-context
9959@opindex Wno-int-in-bool-context
ddf6fe37 9960@item -Wint-in-bool-context
d77de738
ML
9961Warn for suspicious use of integer values where boolean values are expected,
9962such as conditional expressions (?:) using non-boolean integer constants in
9963boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9964integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9965for all kinds of multiplications regardless of the data type.
9966This warning is enabled by @option{-Wall}.
9967
d77de738
ML
9968@opindex Wno-int-to-pointer-cast
9969@opindex Wint-to-pointer-cast
ddf6fe37 9970@item -Wno-int-to-pointer-cast
d77de738
ML
9971Suppress warnings from casts to pointer type of an integer of a
9972different size. In C++, casting to a pointer type of smaller size is
9973an error. @option{Wint-to-pointer-cast} is enabled by default.
9974
9975
d77de738
ML
9976@opindex Wno-pointer-to-int-cast
9977@opindex Wpointer-to-int-cast
ddf6fe37 9978@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
d77de738
ML
9979Suppress warnings from casts from a pointer to an integer type of a
9980different size.
9981
d77de738
ML
9982@opindex Winvalid-pch
9983@opindex Wno-invalid-pch
ddf6fe37 9984@item -Winvalid-pch
d77de738
ML
9985Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9986the search path but cannot be used.
9987
d77de738
ML
9988@opindex Winvalid-utf8
9989@opindex Wno-invalid-utf8
ddf6fe37 9990@item -Winvalid-utf8
d77de738
ML
9991Warn if an invalid UTF-8 character is found.
9992This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
9993is used and turned into error with @option{-pedantic-errors}.
9994
d77de738
ML
9995@opindex Wunicode
9996@opindex Wno-unicode
ddf6fe37 9997@item -Wno-unicode
d77de738
ML
9998Don't diagnose invalid forms of delimited or named escape sequences which are
9999treated as separate tokens. @option{Wunicode} is enabled by default.
10000
d77de738
ML
10001@opindex Wlong-long
10002@opindex Wno-long-long
ddf6fe37 10003@item -Wlong-long
d77de738
ML
10004Warn if @code{long long} type is used. This is enabled by either
10005@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
10006modes. To inhibit the warning messages, use @option{-Wno-long-long}.
10007
5fccebdb
JM
10008This warning is upgraded to an error by @option{-pedantic-errors}.
10009
d77de738
ML
10010@opindex Wvariadic-macros
10011@opindex Wno-variadic-macros
ddf6fe37 10012@item -Wvariadic-macros
d77de738
ML
10013Warn if variadic macros are used in ISO C90 mode, or if the GNU
10014alternate syntax is used in ISO C99 mode. This is enabled by either
10015@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
10016messages, use @option{-Wno-variadic-macros}.
10017
d77de738
ML
10018@opindex Wvarargs
10019@opindex Wno-varargs
ddf6fe37 10020@item -Wno-varargs
d77de738
ML
10021Do not warn upon questionable usage of the macros used to handle variable
10022arguments like @code{va_start}. These warnings are enabled by default.
10023
d77de738
ML
10024@opindex Wvector-operation-performance
10025@opindex Wno-vector-operation-performance
ddf6fe37 10026@item -Wvector-operation-performance
d77de738
ML
10027Warn if vector operation is not implemented via SIMD capabilities of the
10028architecture. Mainly useful for the performance tuning.
10029Vector operation can be implemented @code{piecewise}, which means that the
10030scalar operation is performed on every vector element;
10031@code{in parallel}, which means that the vector operation is implemented
10032using scalars of wider type, which normally is more performance efficient;
10033and @code{as a single scalar}, which means that vector fits into a
10034scalar type.
10035
d77de738
ML
10036@opindex Wvla
10037@opindex Wno-vla
ddf6fe37 10038@item -Wvla
d77de738
ML
10039Warn if a variable-length array is used in the code.
10040@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
10041the variable-length array.
10042
5fccebdb
JM
10043This warning is upgraded to an error by @option{-pedantic-errors}.
10044
d77de738
ML
10045@opindex Wvla-larger-than=
10046@opindex Wno-vla-larger-than
ddf6fe37 10047@item -Wvla-larger-than=@var{byte-size}
d77de738
ML
10048If this option is used, the compiler warns for declarations of
10049variable-length arrays whose size is either unbounded, or bounded
10050by an argument that allows the array size to exceed @var{byte-size}
10051bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
10052works, but with variable-length arrays.
10053
10054Note that GCC may optimize small variable-length arrays of a known
10055value into plain arrays, so this warning may not get triggered for
10056such arrays.
10057
10058@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
10059is typically only effective when @option{-ftree-vrp} is active (default
10060for @option{-O2} and above).
10061
10062See also @option{-Walloca-larger-than=@var{byte-size}}.
10063
d77de738 10064@opindex Wno-vla-larger-than
ddf6fe37 10065@item -Wno-vla-larger-than
d77de738
ML
10066Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
10067to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
10068
d77de738 10069@opindex Wno-vla-parameter
ddf6fe37 10070@item -Wvla-parameter
d77de738
ML
10071Warn about redeclarations of functions involving arguments of Variable
10072Length Array types of inconsistent kinds or forms, and enable the detection
10073of out-of-bounds accesses to such parameters by warnings such as
10074@option{-Warray-bounds}.
10075
10076If the first function declaration uses the VLA form the bound specified
10077in the array is assumed to be the minimum number of elements expected to
10078be provided in calls to the function and the maximum number of elements
10079accessed by it. Failing to provide arguments of sufficient size or
10080accessing more than the maximum number of elements may be diagnosed.
10081
10082For example, the warning triggers for the following redeclarations because
10083the first one allows an array of any size to be passed to @code{f} while
10084the second one specifies that the array argument must have at least @code{n}
10085elements. In addition, calling @code{f} with the associated VLA bound
10086parameter in excess of the actual VLA bound triggers a warning as well.
10087
10088@smallexample
10089void f (int n, int[n]);
4ace81b6
SL
10090// warning: argument 2 previously declared as a VLA
10091void f (int, int[]);
d77de738
ML
10092
10093void g (int n)
10094@{
10095 if (n > 4)
10096 return;
10097 int a[n];
4ace81b6
SL
10098 // warning: access to a by f may be out of bounds
10099 f (sizeof a, a);
d77de738
ML
10100 @dots{}
10101@}
10102
10103@end smallexample
10104
10105@option{-Wvla-parameter} is included in @option{-Wall}. The
10106@option{-Warray-parameter} option triggers warnings for similar problems
10107involving ordinary array arguments.
10108
d77de738
ML
10109@opindex Wvolatile-register-var
10110@opindex Wno-volatile-register-var
ddf6fe37 10111@item -Wvolatile-register-var
d77de738
ML
10112Warn if a register variable is declared volatile. The volatile
10113modifier does not inhibit all optimizations that may eliminate reads
10114and/or writes to register variables. This warning is enabled by
10115@option{-Wall}.
10116
d77de738
ML
10117@opindex Wxor-used-as-pow
10118@opindex Wno-xor-used-as-pow
ddf6fe37 10119@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10120Warn about uses of @code{^}, the exclusive or operator, where it appears
10121the user meant exponentiation. Specifically, the warning occurs when the
10122left-hand side is the decimal constant 2 or 10 and the right-hand side
10123is also a decimal constant.
10124
10125In C and C++, @code{^} means exclusive or, whereas in some other languages
10126(e.g. TeX and some versions of BASIC) it means exponentiation.
10127
10128This warning is enabled by default. It can be silenced by converting one
10129of the operands to hexadecimal.
10130
d77de738
ML
10131@opindex Wdisabled-optimization
10132@opindex Wno-disabled-optimization
ddf6fe37 10133@item -Wdisabled-optimization
d77de738
ML
10134Warn if a requested optimization pass is disabled. This warning does
10135not generally indicate that there is anything wrong with your code; it
10136merely indicates that GCC's optimizers are unable to handle the code
10137effectively. Often, the problem is that your code is too big or too
10138complex; GCC refuses to optimize programs when the optimization
10139itself is likely to take inordinate amounts of time.
10140
d77de738
ML
10141@opindex Wpointer-sign
10142@opindex Wno-pointer-sign
ddf6fe37 10143@item -Wpointer-sign @r{(C and Objective-C only)}
d77de738
ML
10144Warn for pointer argument passing or assignment with different signedness.
10145This option is only supported for C and Objective-C@. It is implied by
10146@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10147@option{-Wno-pointer-sign}.
10148
5fccebdb
JM
10149This warning is upgraded to an error by @option{-pedantic-errors}.
10150
d77de738
ML
10151@opindex Wstack-protector
10152@opindex Wno-stack-protector
ddf6fe37 10153@item -Wstack-protector
d77de738
ML
10154This option is only active when @option{-fstack-protector} is active. It
10155warns about functions that are not protected against stack smashing.
10156
d77de738
ML
10157@opindex Woverlength-strings
10158@opindex Wno-overlength-strings
ddf6fe37 10159@item -Woverlength-strings
d77de738
ML
10160Warn about string constants that are longer than the ``minimum
10161maximum'' length specified in the C standard. Modern compilers
10162generally allow string constants that are much longer than the
10163standard's minimum limit, but very portable programs should avoid
10164using longer strings.
10165
10166The limit applies @emph{after} string constant concatenation, and does
10167not count the trailing NUL@. In C90, the limit was 509 characters; in
10168C99, it was raised to 4095. C++98 does not specify a normative
10169minimum maximum, so we do not diagnose overlength strings in C++@.
10170
10171This option is implied by @option{-Wpedantic}, and can be disabled with
10172@option{-Wno-overlength-strings}.
10173
d77de738
ML
10174@opindex Wunsuffixed-float-constants
10175@opindex Wno-unsuffixed-float-constants
ddf6fe37 10176@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
d77de738
ML
10177
10178Issue a warning for any floating constant that does not have
10179a suffix. When used together with @option{-Wsystem-headers} it
10180warns about such constants in system header files. This can be useful
10181when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10182from the decimal floating-point extension to C99.
10183
d77de738
ML
10184@opindex Wlto-type-mismatch
10185@opindex Wno-lto-type-mismatch
ddf6fe37 10186@item -Wno-lto-type-mismatch
d77de738
ML
10187
10188During the link-time optimization, do not warn about type mismatches in
10189global declarations from different compilation units.
10190Requires @option{-flto} to be enabled. Enabled by default.
10191
d77de738
ML
10192@opindex Wdesignated-init
10193@opindex Wno-designated-init
ddf6fe37 10194@item -Wno-designated-init @r{(C and Objective-C only)}
d77de738
ML
10195Suppress warnings when a positional initializer is used to initialize
10196a structure that has been marked with the @code{designated_init}
10197attribute.
10198
10199@end table
10200
10201@node Static Analyzer Options
10202@section Options That Control Static Analysis
10203
10204@table @gcctabopt
d77de738
ML
10205@opindex analyzer
10206@opindex fanalyzer
10207@opindex fno-analyzer
ddf6fe37 10208@item -fanalyzer
d77de738
ML
10209This option enables an static analysis of program flow which looks
10210for ``interesting'' interprocedural paths through the
10211code, and issues warnings for problems found on them.
10212
10213This analysis is much more expensive than other GCC warnings.
10214
a90316c6
DM
10215In technical terms, it performs coverage-guided symbolic execution of
10216the code being compiled. It is neither sound nor complete: it can
10217have false positives and false negatives. It is a bug-finding tool,
10218rather than a tool for proving program correctness.
10219
10220The analyzer is only suitable for use on C code in this release.
10221
d77de738
ML
10222Enabling this option effectively enables the following warnings:
10223
43b72ede
AA
10224@gccoptlist{
10225-Wanalyzer-allocation-size
10226-Wanalyzer-deref-before-check
10227-Wanalyzer-double-fclose
10228-Wanalyzer-double-free
10229-Wanalyzer-exposure-through-output-file
10230-Wanalyzer-exposure-through-uninit-copy
10231-Wanalyzer-fd-access-mode-mismatch
10232-Wanalyzer-fd-double-close
10233-Wanalyzer-fd-leak
10234-Wanalyzer-fd-phase-mismatch
10235-Wanalyzer-fd-type-mismatch
10236-Wanalyzer-fd-use-after-close
10237-Wanalyzer-fd-use-without-check
10238-Wanalyzer-file-leak
10239-Wanalyzer-free-of-non-heap
10240-Wanalyzer-imprecise-fp-arithmetic
10241-Wanalyzer-infinite-recursion
10242-Wanalyzer-jump-through-null
10243-Wanalyzer-malloc-leak
10244-Wanalyzer-mismatching-deallocation
10245-Wanalyzer-null-argument
10246-Wanalyzer-null-dereference
10247-Wanalyzer-out-of-bounds
10248-Wanalyzer-possible-null-argument
10249-Wanalyzer-possible-null-dereference
10250-Wanalyzer-putenv-of-auto-var
10251-Wanalyzer-shift-count-negative
10252-Wanalyzer-shift-count-overflow
10253-Wanalyzer-stale-setjmp-buffer
10254-Wanalyzer-unsafe-call-within-signal-handler
10255-Wanalyzer-use-after-free
10256-Wanalyzer-use-of-pointer-in-stale-stack-frame
10257-Wanalyzer-use-of-uninitialized-value
10258-Wanalyzer-va-arg-type-mismatch
10259-Wanalyzer-va-list-exhausted
10260-Wanalyzer-va-list-leak
10261-Wanalyzer-va-list-use-after-va-end
10262-Wanalyzer-write-to-const
10263-Wanalyzer-write-to-string-literal
d77de738
ML
10264}
10265@ignore
43b72ede
AA
10266-Wanalyzer-tainted-allocation-size
10267-Wanalyzer-tainted-array-index
10268-Wanalyzer-tainted-divisor
10269-Wanalyzer-tainted-offset
10270-Wanalyzer-tainted-size
d77de738
ML
10271@end ignore
10272
10273This option is only available if GCC was configured with analyzer
10274support enabled.
10275
d77de738
ML
10276@opindex Wanalyzer-too-complex
10277@opindex Wno-analyzer-too-complex
ddf6fe37 10278@item -Wanalyzer-too-complex
d77de738
ML
10279If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10280to attempt to explore the control flow and data flow in the program,
10281but these can be defeated by sufficiently complicated code.
10282
10283By default, the analysis silently stops if the code is too
10284complicated for the analyzer to fully explore and it reaches an internal
10285limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10286
d77de738
ML
10287@opindex Wanalyzer-allocation-size
10288@opindex Wno-analyzer-allocation-size
ddf6fe37 10289@item -Wno-analyzer-allocation-size
4ace81b6
SL
10290This warning requires @option{-fanalyzer}, which enables it;
10291to disable it, use @option{-Wno-analyzer-allocation-size}.
d77de738
ML
10292
10293This diagnostic warns for paths through the code in which a pointer to
10294a buffer is assigned to point at a buffer with a size that is not a
10295multiple of @code{sizeof (*pointer)}.
10296
10297See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10298
ce51e843
ML
10299@opindex Wanalyzer-deref-before-check
10300@opindex Wno-analyzer-deref-before-check
ddf6fe37 10301@item -Wno-analyzer-deref-before-check
ce51e843
ML
10302This warning requires @option{-fanalyzer}, which enables it; use
10303@option{-Wno-analyzer-deref-before-check}
10304to disable it.
10305
10306This diagnostic warns for paths through the code in which a pointer
10307is checked for @code{NULL} *after* it has already been
10308dereferenced, suggesting that the pointer could have been NULL.
10309Such cases suggest that the check for NULL is either redundant,
10310or that it needs to be moved to before the pointer is dereferenced.
10311
10312This diagnostic also considers values passed to a function argument
10313marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10314value, and thus will complain if such values are checked for @code{NULL}
10315after returning from such a function call.
10316
10317This diagnostic is unlikely to be reported when any level of optimization
10318is enabled, as GCC's optimization logic will typically consider such
10319checks for NULL as being redundant, and optimize them away before the
10320analyzer "sees" them. Hence optimization should be disabled when
10321attempting to trigger this diagnostic.
10322
d77de738
ML
10323@opindex Wanalyzer-double-fclose
10324@opindex Wno-analyzer-double-fclose
ddf6fe37 10325@item -Wno-analyzer-double-fclose
d77de738
ML
10326This warning requires @option{-fanalyzer}, which enables it; use
10327@option{-Wno-analyzer-double-fclose} to disable it.
10328
10329This diagnostic warns for paths through the code in which a @code{FILE *}
10330can have @code{fclose} called on it more than once.
10331
10332See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10333
d77de738
ML
10334@opindex Wanalyzer-double-free
10335@opindex Wno-analyzer-double-free
ddf6fe37 10336@item -Wno-analyzer-double-free
d77de738
ML
10337This warning requires @option{-fanalyzer}, which enables it; use
10338@option{-Wno-analyzer-double-free} to disable it.
10339
10340This diagnostic warns for paths through the code in which a pointer
10341can have a deallocator called on it more than once, either @code{free},
10342or a deallocator referenced by attribute @code{malloc}.
10343
10344See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10345
d77de738
ML
10346@opindex Wanalyzer-exposure-through-output-file
10347@opindex Wno-analyzer-exposure-through-output-file
ddf6fe37 10348@item -Wno-analyzer-exposure-through-output-file
d77de738
ML
10349This warning requires @option{-fanalyzer}, which enables it; use
10350@option{-Wno-analyzer-exposure-through-output-file}
10351to disable it.
10352
10353This diagnostic warns for paths through the code in which a
10354security-sensitive value is written to an output file
10355(such as writing a password to a log file).
10356
10357See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10358
d77de738
ML
10359@opindex Wanalyzer-exposure-through-uninit-copy
10360@opindex Wno-analyzer-exposure-through-uninit-copy
ddf6fe37 10361@item -Wanalyzer-exposure-through-uninit-copy
d77de738
ML
10362This warning requires both @option{-fanalyzer} and the use of a plugin
10363to specify a function that copies across a ``trust boundary''. Use
10364@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10365
10366This diagnostic warns for ``infoleaks'' - paths through the code in which
10367uninitialized values are copied across a security boundary
10368(such as code within an OS kernel that copies a partially-initialized
10369struct on the stack to user space).
10370
10371See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10372
d77de738
ML
10373@opindex Wanalyzer-fd-access-mode-mismatch
10374@opindex Wno-analyzer-fd-access-mode-mismatch
ddf6fe37 10375@item -Wno-analyzer-fd-access-mode-mismatch
d77de738
ML
10376This warning requires @option{-fanalyzer}, which enables it; use
10377@option{-Wno-analyzer-fd-access-mode-mismatch}
10378to disable it.
10379
10380This diagnostic warns for paths through code in which a
10381@code{read} on a write-only file descriptor is attempted, or vice versa.
10382
10383This diagnostic also warns for code paths in a which a function with attribute
10384@code{fd_arg_read (N)} is called with a file descriptor opened with
10385@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10386@code{fd_arg_write (N)} is called with a file descriptor opened with
10387@code{O_RDONLY} at referenced argument @var{N}.
10388
d77de738
ML
10389@opindex Wanalyzer-fd-double-close
10390@opindex Wno-analyzer-fd-double-close
ddf6fe37 10391@item -Wno-analyzer-fd-double-close
d77de738
ML
10392This warning requires @option{-fanalyzer}, which enables it; use
10393@option{-Wno-analyzer-fd-double-close}
10394to disable it.
10395
10396This diagnostic warns for paths through code in which a
10397file descriptor can be closed more than once.
10398
10399See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10400
d77de738
ML
10401@opindex Wanalyzer-fd-leak
10402@opindex Wno-analyzer-fd-leak
ddf6fe37 10403@item -Wno-analyzer-fd-leak
d77de738
ML
10404This warning requires @option{-fanalyzer}, which enables it; use
10405@option{-Wno-analyzer-fd-leak}
10406to disable it.
10407
10408This diagnostic warns for paths through code in which an
10409open file descriptor is leaked.
10410
10411See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10412
86a90006
DM
10413@opindex Wanalyzer-fd-phase-mismatch
10414@opindex Wno-analyzer-fd-phase-mismatch
ddf6fe37 10415@item -Wno-analyzer-fd-phase-mismatch
86a90006
DM
10416This warning requires @option{-fanalyzer}, which enables it; use
10417@option{-Wno-analyzer-fd-phase-mismatch}
10418to disable it.
10419
10420This diagnostic warns for paths through code in which an operation is
10421attempted in the wrong phase of a file descriptor's lifetime.
10422For example, it will warn on attempts to call @code{accept} on a stream
10423socket that has not yet had @code{listen} successfully called on it.
10424
10425See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10426
86a90006
DM
10427@opindex Wanalyzer-fd-type-mismatch
10428@opindex Wno-analyzer-fd-type-mismatch
ddf6fe37 10429@item -Wno-analyzer-fd-type-mismatch
86a90006
DM
10430This warning requires @option{-fanalyzer}, which enables it; use
10431@option{-Wno-analyzer-fd-type-mismatch}
10432to disable it.
10433
10434This diagnostic warns for paths through code in which an
10435operation is attempted on the wrong type of file descriptor.
10436For example, it will warn on attempts to use socket operations
10437on a file descriptor obtained via @code{open}, or when attempting
10438to use a stream socket operation on a datagram socket.
10439
d77de738
ML
10440@opindex Wanalyzer-fd-use-after-close
10441@opindex Wno-analyzer-fd-use-after-close
ddf6fe37 10442@item -Wno-analyzer-fd-use-after-close
d77de738
ML
10443This warning requires @option{-fanalyzer}, which enables it; use
10444@option{-Wno-analyzer-fd-use-after-close}
10445to disable it.
10446
10447This diagnostic warns for paths through code in which a
10448read or write is called on a closed file descriptor.
10449
10450This diagnostic also warns for paths through code in which
10451a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10452or @code{fd_arg_write (N)} is called with a closed file descriptor at
10453referenced argument @code{N}.
10454
d77de738
ML
10455@opindex Wanalyzer-fd-use-without-check
10456@opindex Wno-analyzer-fd-use-without-check
ddf6fe37 10457@item -Wno-analyzer-fd-use-without-check
d77de738
ML
10458This warning requires @option{-fanalyzer}, which enables it; use
10459@option{-Wno-analyzer-fd-use-without-check}
10460to disable it.
10461
10462This diagnostic warns for paths through code in which a
10463file descriptor is used without being checked for validity.
10464
10465This diagnostic also warns for paths through code in which
10466a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10467or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10468argument @code{N}, without being checked for validity.
10469
d77de738
ML
10470@opindex Wanalyzer-file-leak
10471@opindex Wno-analyzer-file-leak
ddf6fe37 10472@item -Wno-analyzer-file-leak
d77de738
ML
10473This warning requires @option{-fanalyzer}, which enables it; use
10474@option{-Wno-analyzer-file-leak}
10475to disable it.
10476
10477This diagnostic warns for paths through the code in which a
10478@code{<stdio.h>} @code{FILE *} stream object is leaked.
10479
10480See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10481
d77de738
ML
10482@opindex Wanalyzer-free-of-non-heap
10483@opindex Wno-analyzer-free-of-non-heap
ddf6fe37 10484@item -Wno-analyzer-free-of-non-heap
d77de738
ML
10485This warning requires @option{-fanalyzer}, which enables it; use
10486@option{-Wno-analyzer-free-of-non-heap}
10487to disable it.
10488
10489This diagnostic warns for paths through the code in which @code{free}
10490is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10491
10492See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10493
d77de738
ML
10494@opindex Wanalyzer-imprecise-fp-arithmetic
10495@opindex Wno-analyzer-imprecise-fp-arithmetic
ddf6fe37 10496@item -Wno-analyzer-imprecise-fp-arithmetic
d77de738
ML
10497This warning requires @option{-fanalyzer}, which enables it; use
10498@option{-Wno-analyzer-imprecise-fp-arithmetic}
10499to disable it.
10500
10501This diagnostic warns for paths through the code in which floating-point
10502arithmetic is used in locations where precise computation is needed. This
10503diagnostic only warns on use of floating-point operands inside the
10504calculation of an allocation size at the moment.
10505
ce51e843
ML
10506@opindex Wanalyzer-infinite-recursion
10507@opindex Wno-analyzer-infinite-recursion
ddf6fe37 10508@item -Wno-analyzer-infinite-recursion
ce51e843
ML
10509This warning requires @option{-fanalyzer}, which enables it; use
10510@option{-Wno-analyzer-infinite-recursion} to disable it.
10511
10512This diagnostics warns for paths through the code which appear to
10513lead to infinite recursion.
10514
10515Specifically, when the analyzer "sees" a recursive call, it will compare
10516the state of memory at the entry to the new frame with that at the entry
10517to the previous frame of that function on the stack. The warning is
10518issued if nothing in memory appears to be changing; any changes observed
10519to parameters or globals are assumed to lead to termination of the
10520recursion and thus suppress the warning.
10521
10522This diagnostic is likely to miss cases of infinite recursion that
10523are convered to iteration by the optimizer before the analyzer "sees"
10524them. Hence optimization should be disabled when attempting to trigger
10525this diagnostic.
10526
10527Compare with @option{-Winfinite-recursion}, which provides a similar
10528diagnostic, but is implemented in a different way.
10529
d77de738
ML
10530@opindex Wanalyzer-jump-through-null
10531@opindex Wno-analyzer-jump-through-null
ddf6fe37 10532@item -Wno-analyzer-jump-through-null
d77de738
ML
10533This warning requires @option{-fanalyzer}, which enables it; use
10534@option{-Wno-analyzer-jump-through-null}
10535to disable it.
10536
10537This diagnostic warns for paths through the code in which a @code{NULL}
10538function pointer is called.
10539
d77de738
ML
10540@opindex Wanalyzer-malloc-leak
10541@opindex Wno-analyzer-malloc-leak
ddf6fe37 10542@item -Wno-analyzer-malloc-leak
d77de738
ML
10543This warning requires @option{-fanalyzer}, which enables it; use
10544@option{-Wno-analyzer-malloc-leak}
10545to disable it.
10546
10547This diagnostic warns for paths through the code in which a
10548pointer allocated via an allocator is leaked: either @code{malloc},
10549or a function marked with attribute @code{malloc}.
10550
10551See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10552
d77de738
ML
10553@opindex Wanalyzer-mismatching-deallocation
10554@opindex Wno-analyzer-mismatching-deallocation
ddf6fe37 10555@item -Wno-analyzer-mismatching-deallocation
d77de738
ML
10556This warning requires @option{-fanalyzer}, which enables it; use
10557@option{-Wno-analyzer-mismatching-deallocation}
10558to disable it.
10559
10560This diagnostic warns for paths through the code in which the
10561wrong deallocation function is called on a pointer value, based on
10562which function was used to allocate the pointer value. The diagnostic
10563will warn about mismatches between @code{free}, scalar @code{delete}
10564and vector @code{delete[]}, and those marked as allocator/deallocator
10565pairs using attribute @code{malloc}.
10566
10567See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10568
d77de738
ML
10569@opindex Wanalyzer-out-of-bounds
10570@opindex Wno-analyzer-out-of-bounds
ddf6fe37 10571@item -Wno-analyzer-out-of-bounds
4ace81b6 10572This warning requires @option{-fanalyzer}, which enables it; use
d77de738
ML
10573@option{-Wno-analyzer-out-of-bounds} to disable it.
10574
4ace81b6 10575This diagnostic warns for paths through the code in which a buffer is
d77de738
ML
10576definitely read or written out-of-bounds. The diagnostic applies for
10577cases where the analyzer is able to determine a constant offset and for
10578accesses past the end of a buffer, also a constant capacity. Further,
10579the diagnostic does limited checking for accesses past the end when the
10580offset as well as the capacity is symbolic.
10581
10582See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10583
d77de738
ML
10584@opindex Wanalyzer-possible-null-argument
10585@opindex Wno-analyzer-possible-null-argument
ddf6fe37 10586@item -Wno-analyzer-possible-null-argument
d77de738
ML
10587This warning requires @option{-fanalyzer}, which enables it; use
10588@option{-Wno-analyzer-possible-null-argument} to disable it.
10589
10590This diagnostic warns for paths through the code in which a
10591possibly-NULL value is passed to a function argument marked
10592with @code{__attribute__((nonnull))} as requiring a non-NULL
10593value.
10594
10595See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10596
d77de738
ML
10597@opindex Wanalyzer-possible-null-dereference
10598@opindex Wno-analyzer-possible-null-dereference
ddf6fe37 10599@item -Wno-analyzer-possible-null-dereference
d77de738
ML
10600This warning requires @option{-fanalyzer}, which enables it; use
10601@option{-Wno-analyzer-possible-null-dereference} to disable it.
10602
10603This diagnostic warns for paths through the code in which a
10604possibly-NULL value is dereferenced.
10605
10606See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10607
d77de738
ML
10608@opindex Wanalyzer-null-argument
10609@opindex Wno-analyzer-null-argument
ddf6fe37 10610@item -Wno-analyzer-null-argument
d77de738
ML
10611This warning requires @option{-fanalyzer}, which enables it; use
10612@option{-Wno-analyzer-null-argument} to disable it.
10613
10614This diagnostic warns for paths through the code in which a
10615value known to be NULL is passed to a function argument marked
10616with @code{__attribute__((nonnull))} as requiring a non-NULL
10617value.
10618
10619See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10620
d77de738
ML
10621@opindex Wanalyzer-null-dereference
10622@opindex Wno-analyzer-null-dereference
ddf6fe37 10623@item -Wno-analyzer-null-dereference
d77de738
ML
10624This warning requires @option{-fanalyzer}, which enables it; use
10625@option{-Wno-analyzer-null-dereference} to disable it.
10626
10627This diagnostic warns for paths through the code in which a
10628value known to be NULL is dereferenced.
10629
10630See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10631
d77de738
ML
10632@opindex Wanalyzer-putenv-of-auto-var
10633@opindex Wno-analyzer-putenv-of-auto-var
ddf6fe37 10634@item -Wno-analyzer-putenv-of-auto-var
d77de738
ML
10635This warning requires @option{-fanalyzer}, which enables it; use
10636@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10637
10638This diagnostic warns for paths through the code in which a
10639call to @code{putenv} is passed a pointer to an automatic variable
10640or an on-stack buffer.
10641
10642See @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}.
10643
d77de738
ML
10644@opindex Wanalyzer-shift-count-negative
10645@opindex Wno-analyzer-shift-count-negative
ddf6fe37 10646@item -Wno-analyzer-shift-count-negative
d77de738
ML
10647This warning requires @option{-fanalyzer}, which enables it; use
10648@option{-Wno-analyzer-shift-count-negative} to disable it.
10649
10650This diagnostic warns for paths through the code in which a
10651shift is attempted with a negative count. It is analogous to
10652the @option{-Wshift-count-negative} diagnostic implemented in
10653the C/C++ front ends, but is implemented based on analyzing
10654interprocedural paths, rather than merely parsing the syntax tree.
10655However, the analyzer does not prioritize detection of such paths, so
10656false negatives are more likely relative to other warnings.
10657
d77de738
ML
10658@opindex Wanalyzer-shift-count-overflow
10659@opindex Wno-analyzer-shift-count-overflow
ddf6fe37 10660@item -Wno-analyzer-shift-count-overflow
d77de738
ML
10661This warning requires @option{-fanalyzer}, which enables it; use
10662@option{-Wno-analyzer-shift-count-overflow} to disable it.
10663
10664This diagnostic warns for paths through the code in which a
10665shift is attempted with a count greater than or equal to the
10666precision of the operand's type. It is analogous to
10667the @option{-Wshift-count-overflow} diagnostic implemented in
10668the C/C++ front ends, but is implemented based on analyzing
10669interprocedural paths, rather than merely parsing the syntax tree.
10670However, the analyzer does not prioritize detection of such paths, so
10671false negatives are more likely relative to other warnings.
10672
d77de738
ML
10673@opindex Wanalyzer-stale-setjmp-buffer
10674@opindex Wno-analyzer-stale-setjmp-buffer
ddf6fe37 10675@item -Wno-analyzer-stale-setjmp-buffer
d77de738
ML
10676This warning requires @option{-fanalyzer}, which enables it; use
10677@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10678
10679This diagnostic warns for paths through the code in which
10680@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10681to a @code{setjmp} call in a function that has returned.
10682
10683When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10684location, it records the stack frame. The stack frame becomes invalid
10685when the function containing the @code{setjmp} call returns. Attempting
10686to rewind to it via @code{longjmp} would reference a stack frame that
10687no longer exists, and likely lead to a crash (or worse).
10688
d77de738
ML
10689@opindex Wanalyzer-tainted-allocation-size
10690@opindex Wno-analyzer-tainted-allocation-size
ddf6fe37 10691@item -Wno-analyzer-tainted-allocation-size
d77de738
ML
10692This warning requires both @option{-fanalyzer} and
10693@option{-fanalyzer-checker=taint} to enable it;
10694use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10695
10696This diagnostic warns for paths through the code in which a value
10697that could be under an attacker's control is used as the size
10698of an allocation without being sanitized, so that an attacker could
10699inject an excessively large allocation and potentially cause a denial
10700of service attack.
10701
10702See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10703
ce51e843
ML
10704@opindex Wanalyzer-tainted-assertion
10705@opindex Wno-analyzer-tainted-assertion
ddf6fe37 10706@item -Wno-analyzer-tainted-assertion
ce51e843
ML
10707
10708This warning requires both @option{-fanalyzer} and
10709@option{-fanalyzer-checker=taint} to enable it;
10710use @option{-Wno-analyzer-tainted-assertion} to disable it.
10711
10712This diagnostic warns for paths through the code in which a value
10713that could be under an attacker's control is used as part of a
10714condition without being first sanitized, and that condition guards a
10715call to a function marked with attribute @code{noreturn}
10716(such as the function @code{__builtin_unreachable}). Such functions
10717typically indicate abnormal termination of the program, such as for
10718assertion failure handlers. For example:
10719
10720@smallexample
10721assert (some_tainted_value < SOME_LIMIT);
10722@end smallexample
10723
10724In such cases:
10725
10726@itemize
10727@item
10728when assertion-checking is enabled: an attacker could trigger
10729a denial of service by injecting an assertion failure
10730
10731@item
10732when assertion-checking is disabled, such as by defining @code{NDEBUG},
10733an attacker could inject data that subverts the process, since it
10734presumably violates a precondition that is being assumed by the code.
10735
10736@end itemize
10737
10738Note that when assertion-checking is disabled, the assertions are
10739typically removed by the preprocessor before the analyzer has a chance
10740to "see" them, so this diagnostic can only generate warnings on builds
10741in which assertion-checking is enabled.
10742
10743For the purpose of this warning, any function marked with attribute
10744@code{noreturn} is considered as a possible assertion failure
10745handler, including @code{__builtin_unreachable}. Note that these functions
10746are sometimes removed by the optimizer before the analyzer "sees" them.
10747Hence optimization should be disabled when attempting to trigger this
10748diagnostic.
10749
10750See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10751
10752The warning can also report problematic constructions such as
10753
10754@smallexample
10755switch (some_tainted_value) @{
10756case 0:
10757 /* [...etc; various valid cases omitted...] */
10758 break;
10759
10760default:
10761 __builtin_unreachable (); /* BUG: attacker can trigger this */
10762@}
10763@end smallexample
10764
10765despite the above not being an assertion failure, strictly speaking.
10766
d77de738
ML
10767@opindex Wanalyzer-tainted-array-index
10768@opindex Wno-analyzer-tainted-array-index
ddf6fe37 10769@item -Wno-analyzer-tainted-array-index
d77de738
ML
10770This warning requires both @option{-fanalyzer} and
10771@option{-fanalyzer-checker=taint} to enable it;
10772use @option{-Wno-analyzer-tainted-array-index} to disable it.
10773
10774This diagnostic warns for paths through the code in which a value
10775that could be under an attacker's control is used as the index
10776of an array access without being sanitized, so that an attacker
10777could inject an out-of-bounds access.
10778
10779See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10780
d77de738
ML
10781@opindex Wanalyzer-tainted-divisor
10782@opindex Wno-analyzer-tainted-divisor
ddf6fe37 10783@item -Wno-analyzer-tainted-divisor
d77de738
ML
10784This warning requires both @option{-fanalyzer} and
10785@option{-fanalyzer-checker=taint} to enable it;
10786use @option{-Wno-analyzer-tainted-divisor} to disable it.
10787
10788This diagnostic warns for paths through the code in which a value
10789that could be under an attacker's control is used as the divisor
10790in a division or modulus operation without being sanitized, so that
10791an attacker could inject a division-by-zero.
10792
10793See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10794
d77de738
ML
10795@opindex Wanalyzer-tainted-offset
10796@opindex Wno-analyzer-tainted-offset
ddf6fe37 10797@item -Wno-analyzer-tainted-offset
d77de738
ML
10798This warning requires both @option{-fanalyzer} and
10799@option{-fanalyzer-checker=taint} to enable it;
10800use @option{-Wno-analyzer-tainted-offset} to disable it.
10801
10802This diagnostic warns for paths through the code in which a value
10803that could be under an attacker's control is used as a pointer offset
10804without being sanitized, so that an attacker could inject an out-of-bounds
10805access.
10806
10807See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10808
d77de738
ML
10809@opindex Wanalyzer-tainted-size
10810@opindex Wno-analyzer-tainted-size
ddf6fe37 10811@item -Wno-analyzer-tainted-size
d77de738
ML
10812This warning requires both @option{-fanalyzer} and
10813@option{-fanalyzer-checker=taint} to enable it;
10814use @option{-Wno-analyzer-tainted-size} to disable it.
10815
10816This diagnostic warns for paths through the code in which a value
10817that could be under an attacker's control is used as the size of
10818an operation such as @code{memset} without being sanitized, so that an
10819attacker could inject an out-of-bounds access.
10820
10821See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10822
d77de738
ML
10823@opindex Wanalyzer-unsafe-call-within-signal-handler
10824@opindex Wno-analyzer-unsafe-call-within-signal-handler
ddf6fe37 10825@item -Wno-analyzer-unsafe-call-within-signal-handler
d77de738
ML
10826This warning requires @option{-fanalyzer}, which enables it; use
10827@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10828
10829This diagnostic warns for paths through the code in which a
10830function known to be async-signal-unsafe (such as @code{fprintf}) is
10831called from a signal handler.
10832
10833See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10834
d77de738
ML
10835@opindex Wanalyzer-use-after-free
10836@opindex Wno-analyzer-use-after-free
ddf6fe37 10837@item -Wno-analyzer-use-after-free
d77de738
ML
10838This warning requires @option{-fanalyzer}, which enables it; use
10839@option{-Wno-analyzer-use-after-free} to disable it.
10840
10841This diagnostic warns for paths through the code in which a
10842pointer is used after a deallocator is called on it: either @code{free},
10843or a deallocator referenced by attribute @code{malloc}.
10844
10845See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
10846
d77de738
ML
10847@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
10848@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
ddf6fe37 10849@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
d77de738
ML
10850This warning requires @option{-fanalyzer}, which enables it; use
10851@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
10852to disable it.
10853
10854This diagnostic warns for paths through the code in which a pointer
10855is dereferenced that points to a variable in a stale stack frame.
10856
d77de738
ML
10857@opindex Wanalyzer-va-arg-type-mismatch
10858@opindex Wno-analyzer-va-arg-type-mismatch
ddf6fe37 10859@item -Wno-analyzer-va-arg-type-mismatch
d77de738
ML
10860This warning requires @option{-fanalyzer}, which enables it; use
10861@option{-Wno-analyzer-va-arg-type-mismatch}
10862to disable it.
10863
10864This diagnostic warns for interprocedural paths through the code for which
10865the analyzer detects an attempt to use @code{va_arg} to extract a value
10866passed to a variadic call, but uses a type that does not match that of
10867the expression passed to the call.
10868
10869See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
10870
d77de738
ML
10871@opindex Wanalyzer-va-list-exhausted
10872@opindex Wno-analyzer-va-list-exhausted
ddf6fe37 10873@item -Wno-analyzer-va-list-exhausted
d77de738
ML
10874This warning requires @option{-fanalyzer}, which enables it; use
10875@option{-Wno-analyzer-va-list-exhausted}
10876to disable it.
10877
10878This diagnostic warns for interprocedural paths through the code for which
10879the analyzer detects an attempt to use @code{va_arg} to access the next
10880value passed to a variadic call, but all of the values in the
10881@code{va_list} have already been consumed.
10882
10883See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
10884
d77de738
ML
10885@opindex Wanalyzer-va-list-leak
10886@opindex Wno-analyzer-va-list-leak
ddf6fe37 10887@item -Wno-analyzer-va-list-leak
d77de738
ML
10888This warning requires @option{-fanalyzer}, which enables it; use
10889@option{-Wno-analyzer-va-list-leak}
10890to disable it.
10891
10892This diagnostic warns for interprocedural paths through the code for which
10893the analyzer detects that @code{va_start} or @code{va_copy} has been called
10894on a @code{va_list} without a corresponding call to @code{va_end}.
10895
d77de738
ML
10896@opindex Wanalyzer-va-list-use-after-va-end
10897@opindex Wno-analyzer-va-list-use-after-va-end
ddf6fe37 10898@item -Wno-analyzer-va-list-use-after-va-end
d77de738
ML
10899This warning requires @option{-fanalyzer}, which enables it; use
10900@option{-Wno-analyzer-va-list-use-after-va-end}
10901to disable it.
10902
10903This diagnostic warns for interprocedural paths through the code for which
10904the analyzer detects an attempt to use a @code{va_list} after
10905@code{va_end} has been called on it.
10906@code{va_list}.
10907
d77de738
ML
10908@opindex Wanalyzer-write-to-const
10909@opindex Wno-analyzer-write-to-const
ddf6fe37 10910@item -Wno-analyzer-write-to-const
d77de738
ML
10911This warning requires @option{-fanalyzer}, which enables it; use
10912@option{-Wno-analyzer-write-to-const}
10913to disable it.
10914
10915This diagnostic warns for paths through the code in which the analyzer
10916detects an attempt to write through a pointer to a @code{const} object.
10917However, the analyzer does not prioritize detection of such paths, so
10918false negatives are more likely relative to other warnings.
10919
d77de738
ML
10920@opindex Wanalyzer-write-to-string-literal
10921@opindex Wno-analyzer-write-to-string-literal
ddf6fe37 10922@item -Wno-analyzer-write-to-string-literal
d77de738
ML
10923This warning requires @option{-fanalyzer}, which enables it; use
10924@option{-Wno-analyzer-write-to-string-literal}
10925to disable it.
10926
10927This diagnostic warns for paths through the code in which the analyzer
10928detects an attempt to write through a pointer to a string literal.
10929However, the analyzer does not prioritize detection of such paths, so
10930false negatives are more likely relative to other warnings.
10931
d77de738
ML
10932@opindex Wanalyzer-use-of-uninitialized-value
10933@opindex Wno-analyzer-use-of-uninitialized-value
ddf6fe37 10934@item -Wno-analyzer-use-of-uninitialized-value
d77de738
ML
10935This warning requires @option{-fanalyzer}, which enables it; use
10936@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
10937
10938This diagnostic warns for paths through the code in which an uninitialized
10939value is used.
10940
10941See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
10942
10943@end table
10944
10945The analyzer has hardcoded knowledge about the behavior of the following
10946memory-management functions:
10947
10948@itemize @bullet
10949@item @code{alloca}
10950@item The built-in functions @code{__builtin_alloc},
10951@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
10952@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
10953@code{__builtin_memcpy_chk}, @code{__builtin_memset},
10954@code{__builtin_memset_chk}, @code{__builtin_realloc},
10955@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
10956@item @code{calloc}
10957@item @code{free}
10958@item @code{malloc}
10959@item @code{memset}
10960@item @code{operator delete}
10961@item @code{operator delete []}
10962@item @code{operator new}
10963@item @code{operator new []}
10964@item @code{realloc}
10965@item @code{strdup}
10966@item @code{strndup}
10967@end itemize
10968
4ace81b6 10969@noindent
d77de738
ML
10970of the following functions for working with file descriptors:
10971
10972@itemize @bullet
10973@item @code{open}
10974@item @code{close}
10975@item @code{creat}
10976@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 10977@item @code{isatty}
d77de738
ML
10978@item @code{pipe}, and @code{pipe2}
10979@item @code{read}
10980@item @code{write}
86a90006 10981@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
10982@end itemize
10983
4ace81b6 10984@noindent
d77de738
ML
10985of the following functions for working with @code{<stdio.h>} streams:
10986@itemize @bullet
10987@item The built-in functions @code{__builtin_fprintf},
10988@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
10989@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
10990@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
10991@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
10992@code{__builtin_printf_unlocked}, @code{__builtin_putc},
10993@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
10994@code{__builtin_putc_unlocked}, @code{__builtin_puts},
10995@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
10996@code{__builtin_vprintf}
10997@item @code{fopen}
10998@item @code{fclose}
78a17f44 10999@item @code{ferror}
d77de738
ML
11000@item @code{fgets}
11001@item @code{fgets_unlocked}
78a17f44 11002@item @code{fileno}
d77de738 11003@item @code{fread}
78a17f44 11004@item @code{getc}
d77de738
ML
11005@item @code{getchar}
11006@item @code{fprintf}
11007@item @code{printf}
11008@item @code{fwrite}
11009@end itemize
11010
4ace81b6 11011@noindent
d77de738
ML
11012and of the following functions:
11013
11014@itemize @bullet
11015@item The built-in functions @code{__builtin_expect},
11016@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
11017@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
11018@code{__builtin_strlen}, @code{__builtin_va_copy}, and
11019@code{__builtin_va_start}
11020@item The GNU extensions @code{error} and @code{error_at_line}
11021@item @code{getpass}
11022@item @code{longjmp}
11023@item @code{putenv}
11024@item @code{setjmp}
11025@item @code{siglongjmp}
11026@item @code{signal}
11027@item @code{sigsetjmp}
11028@item @code{strchr}
11029@item @code{strlen}
11030@end itemize
11031
11032In addition, various functions with an @code{__analyzer_} prefix have
11033special meaning to the analyzer, described in the GCC Internals manual.
11034
11035Pertinent parameters for controlling the exploration are:
4ace81b6
SL
11036@itemize @bullet
11037@item @option{--param analyzer-bb-explosion-factor=@var{value}}
11038@item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
11039@item @option{--param analyzer-max-recursion-depth=@var{value}}
11040@item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
11041@end itemize
d77de738
ML
11042
11043The following options control the analyzer.
11044
11045@table @gcctabopt
11046
d77de738
ML
11047@opindex fanalyzer-call-summaries
11048@opindex fno-analyzer-call-summaries
ddf6fe37 11049@item -fanalyzer-call-summaries
d77de738
ML
11050Simplify interprocedural analysis by computing the effect of certain calls,
11051rather than exploring all paths through the function from callsite to each
11052possible return.
11053
11054If enabled, call summaries are only used for functions with more than one
11055call site, and that are sufficiently complicated (as per
11056@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
11057
d77de738 11058@opindex fanalyzer-checker
ddf6fe37 11059@item -fanalyzer-checker=@var{name}
d77de738
ML
11060Restrict the analyzer to run just the named checker, and enable it.
11061
11062Some checkers are disabled by default (even with @option{-fanalyzer}),
11063such as the @code{taint} checker that implements
11064@option{-Wanalyzer-tainted-array-index}, and this option is required
11065to enable them.
11066
11067@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
11068following warnings from @option{-fanalyzer}:
11069
43b72ede
AA
11070@gccoptlist{
11071-Wanalyzer-deref-before-check
11072-Wanalyzer-double-fclose
11073-Wanalyzer-double-free
11074-Wanalyzer-exposure-through-output-file
11075-Wanalyzer-fd-access-mode-mismatch
11076-Wanalyzer-fd-double-close
11077-Wanalyzer-fd-leak
11078-Wanalyzer-fd-use-after-close
11079-Wanalyzer-fd-use-without-check
11080-Wanalyzer-file-leak
11081-Wanalyzer-free-of-non-heap
11082-Wanalyzer-malloc-leak
11083-Wanalyzer-mismatching-deallocation
11084-Wanalyzer-null-argument
11085-Wanalyzer-null-dereference
11086-Wanalyzer-possible-null-argument
11087-Wanalyzer-possible-null-dereference
11088-Wanalyzer-unsafe-call-within-signal-handler
11089-Wanalyzer-use-after-free
11090-Wanalyzer-va-list-leak
11091-Wanalyzer-va-list-use-after-va-end
d77de738
ML
11092}
11093
d77de738
ML
11094@opindex fanalyzer-feasibility
11095@opindex fno-analyzer-feasibility
ddf6fe37 11096@item -fno-analyzer-feasibility
d77de738
ML
11097This option is intended for analyzer developers.
11098
11099By default the analyzer verifies that there is a feasible control flow path
11100for each diagnostic it emits: that the conditions that hold are not mutually
11101exclusive. Diagnostics for which no feasible path can be found are rejected.
11102This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
11103debugging issues in this code.
11104
d77de738
ML
11105@opindex fanalyzer-fine-grained
11106@opindex fno-analyzer-fine-grained
ddf6fe37 11107@item -fanalyzer-fine-grained
d77de738
ML
11108This option is intended for analyzer developers.
11109
11110Internally the analyzer builds an ``exploded graph'' that combines
11111control flow graphs with data flow information.
11112
11113By default, an edge in this graph can contain the effects of a run
11114of multiple statements within a basic block. With
11115@option{-fanalyzer-fine-grained}, each statement gets its own edge.
11116
d77de738
ML
11117@opindex fanalyzer-show-duplicate-count
11118@opindex fno-analyzer-show-duplicate-count
ddf6fe37 11119@item -fanalyzer-show-duplicate-count
d77de738
ML
11120This option is intended for analyzer developers: if multiple diagnostics
11121have been detected as being duplicates of each other, it emits a note when
11122reporting the best diagnostic, giving the number of additional diagnostics
11123that were suppressed by the deduplication logic.
11124
d77de738
ML
11125@opindex fanalyzer-state-merge
11126@opindex fno-analyzer-state-merge
ddf6fe37 11127@item -fno-analyzer-state-merge
d77de738
ML
11128This option is intended for analyzer developers.
11129
11130By default the analyzer attempts to simplify analysis by merging
11131sufficiently similar states at each program point as it builds its
11132``exploded graph''. With @option{-fno-analyzer-state-merge} this
11133merging can be suppressed, for debugging state-handling issues.
11134
d77de738
ML
11135@opindex fanalyzer-state-purge
11136@opindex fno-analyzer-state-purge
ddf6fe37 11137@item -fno-analyzer-state-purge
d77de738
ML
11138This option is intended for analyzer developers.
11139
11140By default the analyzer attempts to simplify analysis by purging
11141aspects of state at a program point that appear to no longer be relevant
11142e.g. the values of locals that aren't accessed later in the function
11143and which aren't relevant to leak analysis.
11144
11145With @option{-fno-analyzer-state-purge} this purging of state can
11146be suppressed, for debugging state-handling issues.
11147
8f636915
DM
11148@opindex fanalyzer-suppress-followups
11149@opindex fno-analyzer-suppress-followups
f33d7a88 11150@item -fno-analyzer-suppress-followups
8f636915
DM
11151This option is intended for analyzer developers.
11152
11153By default the analyzer will stop exploring an execution path after
11154encountering certain diagnostics, in order to avoid potentially issuing a
11155cascade of follow-up diagnostics.
11156
11157The diagnostics that terminate analysis along a path are:
11158
11159@itemize
11160@item @option{-Wanalyzer-null-argument}
11161@item @option{-Wanalyzer-null-dereference}
11162@item @option{-Wanalyzer-use-after-free}
11163@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11164@item @option{-Wanalyzer-use-of-uninitialized-value}
11165@end itemize
11166
11167With @option{-fno-analyzer-suppress-followups} the analyzer will
11168continue to explore such paths even after such diagnostics, which may
11169be helpful for debugging issues in the analyzer, or for microbenchmarks
11170for detecting undefined behavior.
11171
d77de738
ML
11172@opindex fanalyzer-transitivity
11173@opindex fno-analyzer-transitivity
ddf6fe37 11174@item -fanalyzer-transitivity
d77de738
ML
11175This option enables transitivity of constraints within the analyzer.
11176
d77de738
ML
11177@opindex fanalyzer-undo-inlining
11178@opindex fno-analyzer-undo-inlining
ddf6fe37 11179@item -fno-analyzer-undo-inlining
d77de738
ML
11180This option is intended for analyzer developers.
11181
11182@option{-fanalyzer} runs relatively late compared to other code analysis
11183tools, and some optimizations have already been applied to the code. In
11184particular function inlining may have occurred, leading to the
11185interprocedural execution paths emitted by the analyzer containing
11186function frames that don't correspond to those in the original source
11187code.
11188
11189By default the analyzer attempts to reconstruct the original function
11190frames, and to emit events showing the inlined calls.
11191
11192With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11193the original frame information can be be disabled, which may be of help
11194when debugging issues in the analyzer.
11195
11196@item -fanalyzer-verbose-edges
11197This option is intended for analyzer developers. It enables more
11198verbose, lower-level detail in the descriptions of control flow
11199within diagnostic paths.
11200
11201@item -fanalyzer-verbose-state-changes
11202This option is intended for analyzer developers. It enables more
11203verbose, lower-level detail in the descriptions of events relating
11204to state machines within diagnostic paths.
11205
11206@item -fanalyzer-verbosity=@var{level}
11207This option controls the complexity of the control flow paths that are
11208emitted for analyzer diagnostics.
11209
11210The @var{level} can be one of:
11211
11212@table @samp
11213@item 0
11214At this level, interprocedural call and return events are displayed,
11215along with the most pertinent state-change events relating to
11216a diagnostic. For example, for a double-@code{free} diagnostic,
11217both calls to @code{free} will be shown.
11218
11219@item 1
11220As per the previous level, but also show events for the entry
11221to each function.
11222
11223@item 2
11224As per the previous level, but also show events relating to
11225control flow that are significant to triggering the issue
11226(e.g. ``true path taken'' at a conditional).
11227
11228This level is the default.
11229
11230@item 3
11231As per the previous level, but show all control flow events, not
11232just significant ones.
11233
11234@item 4
11235This level is intended for analyzer developers; it adds various
11236other events intended for debugging the analyzer.
11237
11238@end table
11239
d77de738 11240@opindex fdump-analyzer
ddf6fe37 11241@item -fdump-analyzer
d77de738
ML
11242Dump internal details about what the analyzer is doing to
11243@file{@var{file}.analyzer.txt}.
4ace81b6 11244@option{-fdump-analyzer-stderr} overrides this option.
d77de738 11245
d77de738 11246@opindex fdump-analyzer-stderr
ddf6fe37 11247@item -fdump-analyzer-stderr
d77de738
ML
11248Dump internal details about what the analyzer is doing to stderr.
11249This option overrides @option{-fdump-analyzer}.
11250
d77de738 11251@opindex fdump-analyzer-callgraph
ddf6fe37 11252@item -fdump-analyzer-callgraph
d77de738
ML
11253Dump a representation of the call graph suitable for viewing with
11254GraphViz to @file{@var{file}.callgraph.dot}.
11255
d77de738 11256@opindex fdump-analyzer-exploded-graph
ddf6fe37 11257@item -fdump-analyzer-exploded-graph
d77de738
ML
11258Dump a representation of the ``exploded graph'' suitable for viewing with
11259GraphViz to @file{@var{file}.eg.dot}.
11260Nodes are color-coded based on state-machine states to emphasize
11261state changes.
11262
d77de738 11263@opindex dump-analyzer-exploded-nodes
ddf6fe37 11264@item -fdump-analyzer-exploded-nodes
d77de738
ML
11265Emit diagnostics showing where nodes in the ``exploded graph'' are
11266in relation to the program source.
11267
d77de738 11268@opindex dump-analyzer-exploded-nodes-2
ddf6fe37 11269@item -fdump-analyzer-exploded-nodes-2
d77de738
ML
11270Dump a textual representation of the ``exploded graph'' to
11271@file{@var{file}.eg.txt}.
11272
d77de738 11273@opindex dump-analyzer-exploded-nodes-3
ddf6fe37 11274@item -fdump-analyzer-exploded-nodes-3
d77de738
ML
11275Dump a textual representation of the ``exploded graph'' to
11276one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11277This is typically a large number of dump files.
11278
d77de738 11279@opindex fdump-analyzer-exploded-paths
ddf6fe37 11280@item -fdump-analyzer-exploded-paths
d77de738
ML
11281Dump a textual representation of the ``exploded path'' for each
11282diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11283
d77de738 11284@opindex dump-analyzer-feasibility
ddf6fe37 11285@item -fdump-analyzer-feasibility
d77de738
ML
11286Dump internal details about the analyzer's search for feasible paths.
11287The details are written in a form suitable for viewing with GraphViz
11288to filenames of the form @file{@var{file}.*.fg.dot},
11289@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11290
d77de738 11291@opindex fdump-analyzer-json
ddf6fe37 11292@item -fdump-analyzer-json
d77de738
ML
11293Dump a compressed JSON representation of analyzer internals to
11294@file{@var{file}.analyzer.json.gz}. The precise format is subject
11295to change.
11296
d77de738 11297@opindex fdump-analyzer-state-purge
ddf6fe37 11298@item -fdump-analyzer-state-purge
d77de738
ML
11299As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11300``supergraph'' suitable for viewing with GraphViz, but annotate the
11301graph with information on what state will be purged at each node.
11302The graph is written to @file{@var{file}.state-purge.dot}.
11303
d77de738 11304@opindex fdump-analyzer-supergraph
ddf6fe37 11305@item -fdump-analyzer-supergraph
d77de738
ML
11306Dump representations of the ``supergraph'' suitable for viewing with
11307GraphViz to @file{@var{file}.supergraph.dot} and to
11308@file{@var{file}.supergraph-eg.dot}. These show all of the
11309control flow graphs in the program, with interprocedural edges for
11310calls and returns. The second dump contains annotations showing nodes
11311in the ``exploded graph'' and diagnostics associated with them.
11312
d77de738 11313@opindex fdump-analyzer-untracked
ddf6fe37 11314@item -fdump-analyzer-untracked
d77de738
ML
11315Emit custom warnings with internal details intended for analyzer developers.
11316
11317@end table
11318
11319@node Debugging Options
11320@section Options for Debugging Your Program
11321@cindex options, debugging
11322@cindex debugging information options
11323
11324To tell GCC to emit extra information for use by a debugger, in almost
11325all cases you need only to add @option{-g} to your other options. Some debug
11326formats can co-exist (like DWARF with CTF) when each of them is enabled
11327explicitly by adding the respective command line option to your other options.
11328
11329GCC allows you to use @option{-g} with
11330@option{-O}. The shortcuts taken by optimized code may occasionally
11331be surprising: some variables you declared may not exist
11332at all; flow of control may briefly move where you did not expect it;
11333some statements may not be executed because they compute constant
11334results or their values are already at hand; some statements may
11335execute in different places because they have been moved out of loops.
11336Nevertheless it is possible to debug optimized output. This makes
11337it reasonable to use the optimizer for programs that might have bugs.
11338
11339If you are not using some other optimization option, consider
11340using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11341With no @option{-O} option at all, some compiler passes that collect
11342information useful for debugging do not run at all, so that
11343@option{-Og} may result in a better debugging experience.
11344
11345@table @gcctabopt
d77de738 11346@opindex g
ddf6fe37 11347@item -g
d77de738
ML
11348Produce debugging information in the operating system's native format
11349(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11350information.
11351
11352On most systems that use stabs format, @option{-g} enables use of extra
11353debugging information that only GDB can use; this extra information
11354makes debugging work better in GDB but probably makes other debuggers
11355crash or refuse to read the program. If you want to control for certain whether
11356to generate the extra information, use @option{-gvms} (see below).
11357
d77de738 11358@opindex ggdb
ddf6fe37 11359@item -ggdb
d77de738
ML
11360Produce debugging information for use by GDB@. This means to use the
11361most expressive format available (DWARF, stabs, or the native format
11362if neither of those are supported), including GDB extensions if at all
11363possible.
11364
ddf6fe37 11365@opindex gdwarf
d77de738
ML
11366@item -gdwarf
11367@itemx -gdwarf-@var{version}
d77de738
ML
11368Produce debugging information in DWARF format (if that is supported).
11369The value of @var{version} may be either 2, 3, 4 or 5; the default
11370version for most targets is 5 (with the exception of VxWorks, TPF and
11371Darwin/Mac OS X, which default to version 2, and AIX, which defaults
11372to version 4).
11373
11374Note that with DWARF Version 2, some ports require and always
11375use some non-conflicting DWARF 3 extensions in the unwind tables.
11376
11377Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11378for maximum benefit. Version 5 requires GDB 8.0 or higher.
11379
11380GCC no longer supports DWARF Version 1, which is substantially
11381different than Version 2 and later. For historical reasons, some
11382other DWARF-related options such as
11383@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11384in their names, but apply to all currently-supported versions of DWARF.
11385
d77de738 11386@opindex gbtf
ddf6fe37 11387@item -gbtf
d77de738
ML
11388Request BTF debug information. BTF is the default debugging format for the
11389eBPF target. On other targets, like x86, BTF debug information can be
11390generated along with DWARF debug information when both of the debug formats are
11391enabled explicitly via their respective command line options.
11392
ddf6fe37 11393@opindex gctf
d77de738
ML
11394@item -gctf
11395@itemx -gctf@var{level}
d77de738
ML
11396Request CTF debug information and use level to specify how much CTF debug
11397information should be produced. If @option{-gctf} is specified
11398without a value for level, the default level of CTF debug information is 2.
11399
11400CTF debug information can be generated along with DWARF debug information when
11401both of the debug formats are enabled explicitly via their respective command
11402line options.
11403
11404Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11405negates @option{-gctf}.
11406
11407Level 1 produces CTF information for tracebacks only. This includes callsite
11408information, but does not include type information.
11409
11410Level 2 produces type information for entities (functions, data objects etc.)
11411at file-scope or global-scope only.
11412
d77de738 11413@opindex gvms
ddf6fe37 11414@item -gvms
d77de738
ML
11415Produce debugging information in Alpha/VMS debug format (if that is
11416supported). This is the format used by DEBUG on Alpha/VMS systems.
11417
2f7e7bfa
MH
11418@item -gcodeview
11419@opindex gcodeview
11420Produce debugging information in CodeView debug format (if that is
11421supported). This is the format used by Microsoft Visual C++ on
11422Windows.
11423
d77de738
ML
11424@item -g@var{level}
11425@itemx -ggdb@var{level}
11426@itemx -gvms@var{level}
11427Request debugging information and also use @var{level} to specify how
11428much information. The default level is 2.
11429
11430Level 0 produces no debug information at all. Thus, @option{-g0} negates
11431@option{-g}.
11432
11433Level 1 produces minimal information, enough for making backtraces in
11434parts of the program that you don't plan to debug. This includes
11435descriptions of functions and external variables, and line number
11436tables, but no information about local variables.
11437
11438Level 3 includes extra information, such as all the macro definitions
11439present in the program. Some debuggers support macro expansion when
11440you use @option{-g3}.
11441
11442If you use multiple @option{-g} options, with or without level numbers,
11443the last such option is the one that is effective.
11444
11445@option{-gdwarf} does not accept a concatenated debug level, to avoid
11446confusion with @option{-gdwarf-@var{level}}.
11447Instead use an additional @option{-g@var{level}} option to change the
11448debug level for DWARF.
11449
d77de738
ML
11450@opindex feliminate-unused-debug-symbols
11451@opindex fno-eliminate-unused-debug-symbols
ddf6fe37 11452@item -fno-eliminate-unused-debug-symbols
d77de738
ML
11453By default, no debug information is produced for symbols that are not actually
11454used. Use this option if you want debug information for all symbols.
11455
d77de738 11456@opindex femit-class-debug-always
ddf6fe37 11457@item -femit-class-debug-always
d77de738
ML
11458Instead of emitting debugging information for a C++ class in only one
11459object file, emit it in all object files using the class. This option
11460should be used only with debuggers that are unable to handle the way GCC
11461normally emits debugging information for classes because using this
11462option increases the size of debugging information by as much as a
11463factor of two.
11464
d77de738
ML
11465@opindex fmerge-debug-strings
11466@opindex fno-merge-debug-strings
ddf6fe37 11467@item -fno-merge-debug-strings
d77de738
ML
11468Direct the linker to not merge together strings in the debugging
11469information that are identical in different object files. Merging is
11470not supported by all assemblers or linkers. Merging decreases the size
11471of the debug information in the output file at the cost of increasing
11472link processing time. Merging is enabled by default.
11473
d77de738 11474@opindex fdebug-prefix-map
ddf6fe37 11475@item -fdebug-prefix-map=@var{old}=@var{new}
d77de738
ML
11476When compiling files residing in directory @file{@var{old}}, record
11477debugging information describing them as if the files resided in
11478directory @file{@var{new}} instead. This can be used to replace a
11479build-time path with an install-time path in the debug info. It can
11480also be used to change an absolute path to a relative path by using
11481@file{.} for @var{new}. This can give more reproducible builds, which
11482are location independent, but may require an extra command to tell GDB
2eb0191a
JJ
11483where to find the source files. See also @option{-ffile-prefix-map}
11484and @option{-fcanon-prefix-map}.
d77de738 11485
d77de738 11486@opindex fvar-tracking
ddf6fe37 11487@item -fvar-tracking
d77de738
ML
11488Run variable tracking pass. It computes where variables are stored at each
11489position in code. Better debugging information is then generated
11490(if the debugging information format supports this information).
11491
11492It is enabled by default when compiling with optimization (@option{-Os},
11493@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11494the debug info format supports it.
11495
d77de738
ML
11496@opindex fvar-tracking-assignments
11497@opindex fno-var-tracking-assignments
ddf6fe37 11498@item -fvar-tracking-assignments
d77de738
ML
11499Annotate assignments to user variables early in the compilation and
11500attempt to carry the annotations over throughout the compilation all the
11501way to the end, in an attempt to improve debug information while
11502optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11503
11504It can be enabled even if var-tracking is disabled, in which case
11505annotations are created and maintained, but discarded at the end.
11506By default, this flag is enabled together with @option{-fvar-tracking},
11507except when selective scheduling is enabled.
11508
d77de738 11509@opindex gsplit-dwarf
ddf6fe37 11510@item -gsplit-dwarf
d77de738
ML
11511If DWARF debugging information is enabled, separate as much debugging
11512information as possible into a separate output file with the extension
11513@file{.dwo}. This option allows the build system to avoid linking files with
11514debug information. To be useful, this option requires a debugger capable of
11515reading @file{.dwo} files.
11516
d77de738
ML
11517@opindex gdwarf32
11518@opindex gdwarf64
ddf6fe37
AA
11519@item -gdwarf32
11520@itemx -gdwarf64
d77de738
ML
11521If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11522the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11523DWARF format. The default is target specific, on most targets it is
11524@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11525can't support more than 2GiB of debug information in any of the DWARF
11526debug information sections. The 64-bit DWARF format allows larger debug
11527information and might not be well supported by all consumers yet.
11528
d77de738 11529@opindex gdescribe-dies
ddf6fe37 11530@item -gdescribe-dies
d77de738
ML
11531Add description attributes to some DWARF DIEs that have no name attribute,
11532such as artificial variables, external references and call site
11533parameter DIEs.
11534
d77de738 11535@opindex gpubnames
ddf6fe37 11536@item -gpubnames
d77de738
ML
11537Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11538
d77de738 11539@opindex ggnu-pubnames
ddf6fe37 11540@item -ggnu-pubnames
d77de738
ML
11541Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11542suitable for conversion into a GDB@ index. This option is only useful
11543with a linker that can produce GDB@ index version 7.
11544
d77de738
ML
11545@opindex fdebug-types-section
11546@opindex fno-debug-types-section
ddf6fe37 11547@item -fdebug-types-section
d77de738
ML
11548When using DWARF Version 4 or higher, type DIEs can be put into
11549their own @code{.debug_types} section instead of making them part of the
11550@code{.debug_info} section. It is more efficient to put them in a separate
11551comdat section since the linker can then remove duplicates.
11552But not all DWARF consumers support @code{.debug_types} sections yet
11553and on some objects @code{.debug_types} produces larger instead of smaller
11554debugging information.
11555
d77de738
ML
11556@opindex grecord-gcc-switches
11557@opindex gno-record-gcc-switches
ddf6fe37
AA
11558@item -grecord-gcc-switches
11559@itemx -gno-record-gcc-switches
d77de738
ML
11560This switch causes the command-line options used to invoke the
11561compiler that may affect code generation to be appended to the
11562DW_AT_producer attribute in DWARF debugging information. The options
11563are concatenated with spaces separating them from each other and from
11564the compiler version.
11565It is enabled by default.
11566See also @option{-frecord-gcc-switches} for another
11567way of storing compiler options into the object file.
11568
d77de738 11569@opindex gstrict-dwarf
ddf6fe37 11570@item -gstrict-dwarf
d77de738
ML
11571Disallow using extensions of later DWARF standard version than selected
11572with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11573DWARF extensions from later standard versions is allowed.
11574
d77de738 11575@opindex gno-strict-dwarf
ddf6fe37 11576@item -gno-strict-dwarf
d77de738
ML
11577Allow using extensions of later DWARF standard version than selected with
11578@option{-gdwarf-@var{version}}.
11579
d77de738 11580@opindex gas-loc-support
ddf6fe37 11581@item -gas-loc-support
d77de738
ML
11582Inform the compiler that the assembler supports @code{.loc} directives.
11583It may then use them for the assembler to generate DWARF2+ line number
11584tables.
11585
11586This is generally desirable, because assembler-generated line-number
11587tables are a lot more compact than those the compiler can generate
11588itself.
11589
11590This option will be enabled by default if, at GCC configure time, the
11591assembler was found to support such directives.
11592
d77de738 11593@opindex gno-as-loc-support
ddf6fe37 11594@item -gno-as-loc-support
d77de738
ML
11595Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11596line number tables are to be generated.
11597
d77de738 11598@opindex gas-locview-support
ddf6fe37 11599@item -gas-locview-support
d77de738
ML
11600Inform the compiler that the assembler supports @code{view} assignment
11601and reset assertion checking in @code{.loc} directives.
11602
11603This option will be enabled by default if, at GCC configure time, the
11604assembler was found to support them.
11605
11606@item -gno-as-locview-support
11607Force GCC to assign view numbers internally, if
11608@option{-gvariable-location-views} are explicitly requested.
11609
d77de738
ML
11610@opindex gcolumn-info
11611@opindex gno-column-info
ddf6fe37
AA
11612@item -gcolumn-info
11613@itemx -gno-column-info
d77de738
ML
11614Emit location column information into DWARF debugging information, rather
11615than just file and line.
11616This option is enabled by default.
11617
d77de738
ML
11618@opindex gstatement-frontiers
11619@opindex gno-statement-frontiers
ddf6fe37
AA
11620@item -gstatement-frontiers
11621@itemx -gno-statement-frontiers
d77de738
ML
11622This option causes GCC to create markers in the internal representation
11623at the beginning of statements, and to keep them roughly in place
11624throughout compilation, using them to guide the output of @code{is_stmt}
11625markers in the line number table. This is enabled by default when
11626compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11627@dots{}), and outputting DWARF 2 debug information at the normal level.
11628
d77de738
ML
11629@opindex gvariable-location-views
11630@opindex gvariable-location-views=incompat5
11631@opindex gno-variable-location-views
ddf6fe37
AA
11632@item -gvariable-location-views
11633@itemx -gvariable-location-views=incompat5
11634@itemx -gno-variable-location-views
d77de738
ML
11635Augment variable location lists with progressive view numbers implied
11636from the line number table. This enables debug information consumers to
11637inspect state at certain points of the program, even if no instructions
11638associated with the corresponding source locations are present at that
11639point. If the assembler lacks support for view numbers in line number
11640tables, this will cause the compiler to emit the line number table,
11641which generally makes them somewhat less compact. The augmented line
11642number tables and location lists are fully backward-compatible, so they
11643can be consumed by debug information consumers that are not aware of
11644these augmentations, but they won't derive any benefit from them either.
11645
11646This is enabled by default when outputting DWARF 2 debug information at
11647the normal level, as long as there is assembler support,
11648@option{-fvar-tracking-assignments} is enabled and
11649@option{-gstrict-dwarf} is not. When assembler support is not
11650available, this may still be enabled, but it will force GCC to output
11651internal line number tables, and if
11652@option{-ginternal-reset-location-views} is not enabled, that will most
11653certainly lead to silently mismatching location views.
11654
11655There is a proposed representation for view numbers that is not backward
11656compatible with the location list format introduced in DWARF 5, that can
11657be enabled with @option{-gvariable-location-views=incompat5}. This
11658option may be removed in the future, is only provided as a reference
11659implementation of the proposed representation. Debug information
11660consumers are not expected to support this extended format, and they
11661would be rendered unable to decode location lists using it.
11662
d77de738
ML
11663@opindex ginternal-reset-location-views
11664@opindex gno-internal-reset-location-views
ddf6fe37
AA
11665@item -ginternal-reset-location-views
11666@itemx -gno-internal-reset-location-views
d77de738
ML
11667Attempt to determine location views that can be omitted from location
11668view lists. This requires the compiler to have very accurate insn
11669length estimates, which isn't always the case, and it may cause
11670incorrect view lists to be generated silently when using an assembler
11671that does not support location view lists. The GNU assembler will flag
11672any such error as a @code{view number mismatch}. This is only enabled
11673on ports that define a reliable estimation function.
11674
d77de738
ML
11675@opindex ginline-points
11676@opindex gno-inline-points
ddf6fe37
AA
11677@item -ginline-points
11678@itemx -gno-inline-points
d77de738
ML
11679Generate extended debug information for inlined functions. Location
11680view tracking markers are inserted at inlined entry points, so that
11681address and view numbers can be computed and output in debug
11682information. This can be enabled independently of location views, in
11683which case the view numbers won't be output, but it can only be enabled
11684along with statement frontiers, and it is only enabled by default if
11685location views are enabled.
11686
d77de738 11687@opindex gz
ddf6fe37 11688@item -gz@r{[}=@var{type}@r{]}
d77de738
ML
11689Produce compressed debug sections in DWARF format, if that is supported.
11690If @var{type} is not given, the default type depends on the capabilities
11691of the assembler and linker used. @var{type} may be one of
11692@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11693compression in ELF gABI format). If the linker doesn't support writing
11694compressed debug sections, the option is rejected. Otherwise, if the
11695assembler does not support them, @option{-gz} is silently ignored when
11696producing object files.
11697
d77de738 11698@opindex femit-struct-debug-baseonly
ddf6fe37 11699@item -femit-struct-debug-baseonly
d77de738
ML
11700Emit debug information for struct-like types
11701only when the base name of the compilation source file
11702matches the base name of file in which the struct is defined.
11703
11704This option substantially reduces the size of debugging information,
11705but at significant potential loss in type information to the debugger.
11706See @option{-femit-struct-debug-reduced} for a less aggressive option.
11707See @option{-femit-struct-debug-detailed} for more detailed control.
11708
11709This option works only with DWARF debug output.
11710
d77de738 11711@opindex femit-struct-debug-reduced
ddf6fe37 11712@item -femit-struct-debug-reduced
d77de738
ML
11713Emit debug information for struct-like types
11714only when the base name of the compilation source file
11715matches the base name of file in which the type is defined,
11716unless the struct is a template or defined in a system header.
11717
11718This option significantly reduces the size of debugging information,
11719with some potential loss in type information to the debugger.
11720See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11721See @option{-femit-struct-debug-detailed} for more detailed control.
11722
11723This option works only with DWARF debug output.
11724
d77de738 11725@opindex femit-struct-debug-detailed
ddf6fe37 11726@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
d77de738
ML
11727Specify the struct-like types
11728for which the compiler generates debug information.
11729The intent is to reduce duplicate struct debug information
11730between different object files within the same program.
11731
11732This option is a detailed version of
11733@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11734which serves for most needs.
11735
11736A specification has the syntax@*
11737[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11738
11739The optional first word limits the specification to
11740structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11741A struct type is used directly when it is the type of a variable, member.
11742Indirect uses arise through pointers to structs.
11743That is, when use of an incomplete struct is valid, the use is indirect.
11744An example is
11745@samp{struct one direct; struct two * indirect;}.
11746
11747The optional second word limits the specification to
11748ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11749Generic structs are a bit complicated to explain.
11750For C++, these are non-explicit specializations of template classes,
11751or non-template classes within the above.
11752Other programming languages have generics,
11753but @option{-femit-struct-debug-detailed} does not yet implement them.
11754
11755The third word specifies the source files for those
11756structs for which the compiler should emit debug information.
11757The values @samp{none} and @samp{any} have the normal meaning.
11758The value @samp{base} means that
11759the base of name of the file in which the type declaration appears
11760must match the base of the name of the main compilation file.
11761In practice, this means that when compiling @file{foo.c}, debug information
11762is generated for types declared in that file and @file{foo.h},
11763but not other header files.
11764The value @samp{sys} means those types satisfying @samp{base}
11765or declared in system or compiler headers.
11766
11767You may need to experiment to determine the best settings for your application.
11768
11769The default is @option{-femit-struct-debug-detailed=all}.
11770
11771This option works only with DWARF debug output.
11772
d77de738
ML
11773@opindex fdwarf2-cfi-asm
11774@opindex fno-dwarf2-cfi-asm
ddf6fe37 11775@item -fno-dwarf2-cfi-asm
d77de738
ML
11776Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11777instead of using GAS @code{.cfi_*} directives.
11778
d77de738
ML
11779@opindex feliminate-unused-debug-types
11780@opindex fno-eliminate-unused-debug-types
ddf6fe37 11781@item -fno-eliminate-unused-debug-types
d77de738
ML
11782Normally, when producing DWARF output, GCC avoids producing debug symbol
11783output for types that are nowhere used in the source file being compiled.
11784Sometimes it is useful to have GCC emit debugging
11785information for all types declared in a compilation
11786unit, regardless of whether or not they are actually used
11787in that compilation unit, for example
11788if, in the debugger, you want to cast a value to a type that is
11789not actually used in your program (but is declared). More often,
11790however, this results in a significant amount of wasted space.
11791@end table
11792
11793@node Optimize Options
11794@section Options That Control Optimization
11795@cindex optimize options
11796@cindex options, optimization
11797
11798These options control various sorts of optimizations.
11799
11800Without any optimization option, the compiler's goal is to reduce the
11801cost of compilation and to make debugging produce the expected
11802results. Statements are independent: if you stop the program with a
11803breakpoint between statements, you can then assign a new value to any
11804variable or change the program counter to any other statement in the
11805function and get exactly the results you expect from the source
11806code.
11807
11808Turning on optimization flags makes the compiler attempt to improve
11809the performance and/or code size at the expense of compilation time
11810and possibly the ability to debug the program.
11811
11812The compiler performs optimization based on the knowledge it has of the
11813program. Compiling multiple files at once to a single output file mode allows
11814the compiler to use information gained from all of the files when compiling
11815each of them.
11816
11817Not all optimizations are controlled directly by a flag. Only
11818optimizations that have a flag are listed in this section.
11819
11820Most optimizations are completely disabled at @option{-O0} or if an
11821@option{-O} level is not set on the command line, even if individual
11822optimization flags are specified. Similarly, @option{-Og} suppresses
11823many optimization passes.
11824
11825Depending on the target and how GCC was configured, a slightly different
11826set of optimizations may be enabled at each @option{-O} level than
11827those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11828to find out the exact set of optimizations that are enabled at each level.
11829@xref{Overall Options}, for examples.
11830
11831@table @gcctabopt
d77de738
ML
11832@opindex O
11833@opindex O1
ddf6fe37
AA
11834@item -O
11835@itemx -O1
d77de738
ML
11836Optimize. Optimizing compilation takes somewhat more time, and a lot
11837more memory for a large function.
11838
11839With @option{-O}, the compiler tries to reduce code size and execution
11840time, without performing any optimizations that take a great deal of
11841compilation time.
11842
11843@c Note that in addition to the default_options_table list in opts.cc,
11844@c several optimization flags default to true but control optimization
11845@c passes that are explicitly disabled at -O0.
11846
11847@option{-O} turns on the following optimization flags:
11848
11849@c Please keep the following list alphabetized.
43b72ede
AA
11850@gccoptlist{-fauto-inc-dec
11851-fbranch-count-reg
11852-fcombine-stack-adjustments
11853-fcompare-elim
11854-fcprop-registers
11855-fdce
11856-fdefer-pop
11857-fdelayed-branch
11858-fdse
11859-fforward-propagate
11860-fguess-branch-probability
11861-fif-conversion
11862-fif-conversion2
11863-finline-functions-called-once
11864-fipa-modref
11865-fipa-profile
11866-fipa-pure-const
11867-fipa-reference
11868-fipa-reference-addressable
11869-fmerge-constants
11870-fmove-loop-invariants
11871-fmove-loop-stores
11872-fomit-frame-pointer
11873-freorder-blocks
11874-fshrink-wrap
11875-fshrink-wrap-separate
11876-fsplit-wide-types
11877-fssa-backprop
11878-fssa-phiopt
11879-ftree-bit-ccp
11880-ftree-ccp
11881-ftree-ch
11882-ftree-coalesce-vars
11883-ftree-copy-prop
11884-ftree-dce
11885-ftree-dominator-opts
11886-ftree-dse
11887-ftree-forwprop
11888-ftree-fre
11889-ftree-phiprop
11890-ftree-pta
11891-ftree-scev-cprop
11892-ftree-sink
11893-ftree-slsr
11894-ftree-sra
11895-ftree-ter
d77de738
ML
11896-funit-at-a-time}
11897
d77de738 11898@opindex O2
ddf6fe37 11899@item -O2
d77de738
ML
11900Optimize even more. GCC performs nearly all supported optimizations
11901that do not involve a space-speed tradeoff.
11902As compared to @option{-O}, this option increases both compilation time
11903and the performance of the generated code.
11904
11905@option{-O2} turns on all optimization flags specified by @option{-O1}. It
11906also turns on the following optimization flags:
11907
11908@c Please keep the following list alphabetized!
43b72ede
AA
11909@gccoptlist{-falign-functions -falign-jumps
11910-falign-labels -falign-loops
11911-fcaller-saves
11912-fcode-hoisting
11913-fcrossjumping
11914-fcse-follow-jumps -fcse-skip-blocks
11915-fdelete-null-pointer-checks
11916-fdevirtualize -fdevirtualize-speculatively
11917-fexpensive-optimizations
11918-ffinite-loops
11919-fgcse -fgcse-lm
11920-fhoist-adjacent-loads
11921-finline-functions
11922-finline-small-functions
11923-findirect-inlining
11924-fipa-bit-cp -fipa-cp -fipa-icf
11925-fipa-ra -fipa-sra -fipa-vrp
11926-fisolate-erroneous-paths-dereference
11927-flra-remat
11928-foptimize-sibling-calls
11929-foptimize-strlen
11930-fpartial-inlining
11931-fpeephole2
11932-freorder-blocks-algorithm=stc
11933-freorder-blocks-and-partition -freorder-functions
11934-frerun-cse-after-loop
11935-fschedule-insns -fschedule-insns2
11936-fsched-interblock -fsched-spec
11937-fstore-merging
11938-fstrict-aliasing
11939-fthread-jumps
11940-ftree-builtin-call-dce
11941-ftree-loop-vectorize
11942-ftree-pre
11943-ftree-slp-vectorize
11944-ftree-switch-conversion -ftree-tail-merge
11945-ftree-vrp
d77de738
ML
11946-fvect-cost-model=very-cheap}
11947
11948Please note the warning under @option{-fgcse} about
11949invoking @option{-O2} on programs that use computed gotos.
11950
d77de738 11951@opindex O3
ddf6fe37 11952@item -O3
d77de738
ML
11953Optimize yet more. @option{-O3} turns on all optimizations specified
11954by @option{-O2} and also turns on the following optimization flags:
11955
11956@c Please keep the following list alphabetized!
43b72ede 11957@gccoptlist{-fgcse-after-reload
d77de738 11958-fipa-cp-clone
43b72ede
AA
11959-floop-interchange
11960-floop-unroll-and-jam
11961-fpeel-loops
11962-fpredictive-commoning
11963-fsplit-loops
11964-fsplit-paths
11965-ftree-loop-distribution
11966-ftree-partial-pre
11967-funswitch-loops
11968-fvect-cost-model=dynamic
d77de738
ML
11969-fversion-loops-for-strides}
11970
d77de738 11971@opindex O0
ddf6fe37 11972@item -O0
d77de738
ML
11973Reduce compilation time and make debugging produce the expected
11974results. This is the default.
11975
d77de738 11976@opindex Os
ddf6fe37 11977@item -Os
d77de738
ML
11978Optimize for size. @option{-Os} enables all @option{-O2} optimizations
11979except those that often increase code size:
11980
43b72ede
AA
11981@gccoptlist{-falign-functions -falign-jumps
11982-falign-labels -falign-loops
d77de738
ML
11983-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
11984
11985It also enables @option{-finline-functions}, causes the compiler to tune for
11986code size rather than execution speed, and performs further optimizations
11987designed to reduce code size.
11988
d77de738 11989@opindex Ofast
ddf6fe37 11990@item -Ofast
d77de738
ML
11991Disregard strict standards compliance. @option{-Ofast} enables all
11992@option{-O3} optimizations. It also enables optimizations that are not
11993valid for all standard-compliant programs.
11994It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
11995and the Fortran-specific @option{-fstack-arrays}, unless
11996@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
11997It turns off @option{-fsemantic-interposition}.
11998
d77de738 11999@opindex Og
ddf6fe37 12000@item -Og
d77de738
ML
12001Optimize debugging experience. @option{-Og} should be the optimization
12002level of choice for the standard edit-compile-debug cycle, offering
12003a reasonable level of optimization while maintaining fast compilation
12004and a good debugging experience. It is a better choice than @option{-O0}
12005for producing debuggable code because some compiler passes
12006that collect debug information are disabled at @option{-O0}.
12007
12008Like @option{-O0}, @option{-Og} completely disables a number of
12009optimization passes so that individual options controlling them have
12010no effect. Otherwise @option{-Og} enables all @option{-O1}
12011optimization flags except for those that may interfere with debugging:
12012
43b72ede
AA
12013@gccoptlist{-fbranch-count-reg -fdelayed-branch
12014-fdse -fif-conversion -fif-conversion2
12015-finline-functions-called-once
12016-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
d77de738
ML
12017-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
12018
d77de738 12019@opindex Oz
ddf6fe37 12020@item -Oz
d77de738
ML
12021Optimize aggressively for size rather than speed. This may increase
12022the number of instructions executed if those instructions require
12023fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
12024including enabling most @option{-O2} optimizations.
12025
12026@end table
12027
12028If you use multiple @option{-O} options, with or without level numbers,
12029the last such option is the one that is effective.
12030
12031Options of the form @option{-f@var{flag}} specify machine-independent
12032flags. Most flags have both positive and negative forms; the negative
12033form of @option{-ffoo} is @option{-fno-foo}. In the table
12034below, only one of the forms is listed---the one you typically
12035use. You can figure out the other form by either removing @samp{no-}
12036or adding it.
12037
12038The following options control specific optimizations. They are either
12039activated by @option{-O} options or are related to ones that are. You
12040can use the following flags in the rare cases when ``fine-tuning'' of
12041optimizations to be performed is desired.
12042
12043@table @gcctabopt
d77de738
ML
12044@opindex fno-defer-pop
12045@opindex fdefer-pop
ddf6fe37 12046@item -fno-defer-pop
d77de738
ML
12047For machines that must pop arguments after a function call, always pop
12048the arguments as soon as each function returns.
12049At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
12050this allows the compiler to let arguments accumulate on the stack for several
12051function calls and pop them all at once.
12052
d77de738 12053@opindex fforward-propagate
ddf6fe37 12054@item -fforward-propagate
d77de738
ML
12055Perform a forward propagation pass on RTL@. The pass tries to combine two
12056instructions and checks if the result can be simplified. If loop unrolling
12057is active, two passes are performed and the second is scheduled after
12058loop unrolling.
12059
12060This option is enabled by default at optimization levels @option{-O1},
12061@option{-O2}, @option{-O3}, @option{-Os}.
12062
d77de738 12063@opindex ffp-contract
ddf6fe37 12064@item -ffp-contract=@var{style}
d77de738
ML
12065@option{-ffp-contract=off} disables floating-point expression contraction.
12066@option{-ffp-contract=fast} enables floating-point expression contraction
12067such as forming of fused multiply-add operations if the target has
12068native support for them.
12069@option{-ffp-contract=on} enables floating-point expression contraction
12070if allowed by the language standard. This is currently not implemented
12071and treated equal to @option{-ffp-contract=off}.
12072
12073The default is @option{-ffp-contract=fast}.
12074
d77de738 12075@opindex fomit-frame-pointer
ddf6fe37 12076@item -fomit-frame-pointer
d77de738
ML
12077Omit the frame pointer in functions that don't need one. This avoids the
12078instructions to save, set up and restore the frame pointer; on many targets
12079it also makes an extra register available.
12080
12081On some targets this flag has no effect because the standard calling sequence
12082always uses a frame pointer, so it cannot be omitted.
12083
12084Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
12085is used in all functions. Several targets always omit the frame pointer in
12086leaf functions.
12087
12088Enabled by default at @option{-O1} and higher.
12089
d77de738 12090@opindex foptimize-sibling-calls
ddf6fe37 12091@item -foptimize-sibling-calls
d77de738
ML
12092Optimize sibling and tail recursive calls.
12093
12094Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12095
d77de738 12096@opindex foptimize-strlen
ddf6fe37 12097@item -foptimize-strlen
d77de738
ML
12098Optimize various standard C string functions (e.g.@: @code{strlen},
12099@code{strchr} or @code{strcpy}) and
12100their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
12101
12102Enabled at levels @option{-O2}, @option{-O3}.
12103
d77de738
ML
12104@opindex fno-inline
12105@opindex finline
ddf6fe37 12106@item -fno-inline
d77de738
ML
12107Do not expand any functions inline apart from those marked with
12108the @code{always_inline} attribute. This is the default when not
12109optimizing.
12110
12111Single functions can be exempted from inlining by marking them
12112with the @code{noinline} attribute.
12113
d77de738 12114@opindex finline-small-functions
ddf6fe37 12115@item -finline-small-functions
d77de738
ML
12116Integrate functions into their callers when their body is smaller than expected
12117function call code (so overall size of program gets smaller). The compiler
12118heuristically decides which functions are simple enough to be worth integrating
12119in this way. This inlining applies to all functions, even those not declared
12120inline.
12121
12122Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12123
d77de738 12124@opindex findirect-inlining
ddf6fe37 12125@item -findirect-inlining
d77de738
ML
12126Inline also indirect calls that are discovered to be known at compile
12127time thanks to previous inlining. This option has any effect only
12128when inlining itself is turned on by the @option{-finline-functions}
12129or @option{-finline-small-functions} options.
12130
12131Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12132
d77de738 12133@opindex finline-functions
ddf6fe37 12134@item -finline-functions
d77de738
ML
12135Consider all functions for inlining, even if they are not declared inline.
12136The compiler heuristically decides which functions are worth integrating
12137in this way.
12138
12139If all calls to a given function are integrated, and the function is
12140declared @code{static}, then the function is normally not output as
12141assembler code in its own right.
12142
12143Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12144by @option{-fprofile-use} and @option{-fauto-profile}.
12145
d77de738 12146@opindex finline-functions-called-once
ddf6fe37 12147@item -finline-functions-called-once
d77de738
ML
12148Consider all @code{static} functions called once for inlining into their
12149caller even if they are not marked @code{inline}. If a call to a given
12150function is integrated, then the function is not output as assembler code
12151in its own right.
12152
12153Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12154but not @option{-Og}.
12155
d77de738 12156@opindex fearly-inlining
ddf6fe37 12157@item -fearly-inlining
d77de738
ML
12158Inline functions marked by @code{always_inline} and functions whose body seems
12159smaller than the function call overhead early before doing
12160@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12161makes profiling significantly cheaper and usually inlining faster on programs
12162having large chains of nested wrapper functions.
12163
12164Enabled by default.
12165
d77de738 12166@opindex fipa-sra
ddf6fe37 12167@item -fipa-sra
d77de738
ML
12168Perform interprocedural scalar replacement of aggregates, removal of
12169unused parameters and replacement of parameters passed by reference
12170by parameters passed by value.
12171
12172Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12173
d77de738 12174@opindex finline-limit
ddf6fe37 12175@item -finline-limit=@var{n}
d77de738
ML
12176By default, GCC limits the size of functions that can be inlined. This flag
12177allows coarse control of this limit. @var{n} is the size of functions that
12178can be inlined in number of pseudo instructions.
12179
12180Inlining is actually controlled by a number of parameters, which may be
12181specified individually by using @option{--param @var{name}=@var{value}}.
12182The @option{-finline-limit=@var{n}} option sets some of these parameters
12183as follows:
12184
12185@table @gcctabopt
12186@item max-inline-insns-single
12187is set to @var{n}/2.
12188@item max-inline-insns-auto
12189is set to @var{n}/2.
12190@end table
12191
12192See below for a documentation of the individual
12193parameters controlling inlining and for the defaults of these parameters.
12194
12195@emph{Note:} there may be no value to @option{-finline-limit} that results
12196in default behavior.
12197
12198@emph{Note:} pseudo instruction represents, in this particular context, an
12199abstract measurement of function's size. In no way does it represent a count
12200of assembly instructions and as such its exact meaning might change from one
12201release to an another.
12202
d77de738
ML
12203@opindex fno-keep-inline-dllexport
12204@opindex fkeep-inline-dllexport
ddf6fe37 12205@item -fno-keep-inline-dllexport
d77de738
ML
12206This is a more fine-grained version of @option{-fkeep-inline-functions},
12207which applies only to functions that are declared using the @code{dllexport}
12208attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12209Functions}.
12210
d77de738 12211@opindex fkeep-inline-functions
ddf6fe37 12212@item -fkeep-inline-functions
d77de738
ML
12213In C, emit @code{static} functions that are declared @code{inline}
12214into the object file, even if the function has been inlined into all
12215of its callers. This switch does not affect functions using the
12216@code{extern inline} extension in GNU C90@. In C++, emit any and all
12217inline functions into the object file.
12218
d77de738 12219@opindex fkeep-static-functions
ddf6fe37 12220@item -fkeep-static-functions
d77de738
ML
12221Emit @code{static} functions into the object file, even if the function
12222is never used.
12223
d77de738 12224@opindex fkeep-static-consts
ddf6fe37 12225@item -fkeep-static-consts
d77de738
ML
12226Emit variables declared @code{static const} when optimization isn't turned
12227on, even if the variables aren't referenced.
12228
12229GCC enables this option by default. If you want to force the compiler to
12230check if a variable is referenced, regardless of whether or not
12231optimization is turned on, use the @option{-fno-keep-static-consts} option.
12232
d77de738 12233@opindex fmerge-constants
ddf6fe37 12234@item -fmerge-constants
d77de738
ML
12235Attempt to merge identical constants (string constants and floating-point
12236constants) across compilation units.
12237
12238This option is the default for optimized compilation if the assembler and
12239linker support it. Use @option{-fno-merge-constants} to inhibit this
12240behavior.
12241
12242Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12243
d77de738 12244@opindex fmerge-all-constants
ddf6fe37 12245@item -fmerge-all-constants
d77de738
ML
12246Attempt to merge identical constants and identical variables.
12247
12248This option implies @option{-fmerge-constants}. In addition to
12249@option{-fmerge-constants} this considers e.g.@: even constant initialized
12250arrays or initialized constant variables with integral or floating-point
12251types. Languages like C or C++ require each variable, including multiple
12252instances of the same variable in recursive calls, to have distinct locations,
12253so using this option results in non-conforming
12254behavior.
12255
d77de738 12256@opindex fmodulo-sched
ddf6fe37 12257@item -fmodulo-sched
d77de738
ML
12258Perform swing modulo scheduling immediately before the first scheduling
12259pass. This pass looks at innermost loops and reorders their
12260instructions by overlapping different iterations.
12261
d77de738 12262@opindex fmodulo-sched-allow-regmoves
ddf6fe37 12263@item -fmodulo-sched-allow-regmoves
d77de738
ML
12264Perform more aggressive SMS-based modulo scheduling with register moves
12265allowed. By setting this flag certain anti-dependences edges are
12266deleted, which triggers the generation of reg-moves based on the
12267life-range analysis. This option is effective only with
12268@option{-fmodulo-sched} enabled.
12269
d77de738
ML
12270@opindex fno-branch-count-reg
12271@opindex fbranch-count-reg
ddf6fe37 12272@item -fno-branch-count-reg
d77de738
ML
12273Disable the optimization pass that scans for opportunities to use
12274``decrement and branch'' instructions on a count register instead of
12275instruction sequences that decrement a register, compare it against zero, and
12276then branch based upon the result. This option is only meaningful on
12277architectures that support such instructions, which include x86, PowerPC,
12278IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12279doesn't remove the decrement and branch instructions from the generated
12280instruction stream introduced by other optimization passes.
12281
12282The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12283except for @option{-Og}.
12284
d77de738
ML
12285@opindex fno-function-cse
12286@opindex ffunction-cse
ddf6fe37 12287@item -fno-function-cse
d77de738
ML
12288Do not put function addresses in registers; make each instruction that
12289calls a constant function contain the function's address explicitly.
12290
12291This option results in less efficient code, but some strange hacks
12292that alter the assembler output may be confused by the optimizations
12293performed when this option is not used.
12294
12295The default is @option{-ffunction-cse}
12296
d77de738
ML
12297@opindex fno-zero-initialized-in-bss
12298@opindex fzero-initialized-in-bss
ddf6fe37 12299@item -fno-zero-initialized-in-bss
d77de738
ML
12300If the target supports a BSS section, GCC by default puts variables that
12301are initialized to zero into BSS@. This can save space in the resulting
12302code.
12303
12304This option turns off this behavior because some programs explicitly
12305rely on variables going to the data section---e.g., so that the
12306resulting executable can find the beginning of that section and/or make
12307assumptions based on that.
12308
12309The default is @option{-fzero-initialized-in-bss}.
12310
d77de738 12311@opindex fthread-jumps
ddf6fe37 12312@item -fthread-jumps
d77de738
ML
12313Perform optimizations that check to see if a jump branches to a
12314location where another comparison subsumed by the first is found. If
12315so, the first branch is redirected to either the destination of the
12316second branch or a point immediately following it, depending on whether
12317the condition is known to be true or false.
12318
12319Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12320
d77de738 12321@opindex fsplit-wide-types
ddf6fe37 12322@item -fsplit-wide-types
d77de738
ML
12323When using a type that occupies multiple registers, such as @code{long
12324long} on a 32-bit system, split the registers apart and allocate them
12325independently. This normally generates better code for those types,
12326but may make debugging more difficult.
12327
12328Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12329@option{-Os}.
12330
d77de738 12331@opindex fsplit-wide-types-early
ddf6fe37 12332@item -fsplit-wide-types-early
d77de738
ML
12333Fully split wide types early, instead of very late.
12334This option has no effect unless @option{-fsplit-wide-types} is turned on.
12335
12336This is the default on some targets.
12337
d77de738 12338@opindex fcse-follow-jumps
ddf6fe37 12339@item -fcse-follow-jumps
d77de738
ML
12340In common subexpression elimination (CSE), scan through jump instructions
12341when the target of the jump is not reached by any other path. For
12342example, when CSE encounters an @code{if} statement with an
12343@code{else} clause, CSE follows the jump when the condition
12344tested is false.
12345
12346Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12347
d77de738 12348@opindex fcse-skip-blocks
ddf6fe37 12349@item -fcse-skip-blocks
d77de738
ML
12350This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12351follow jumps that conditionally skip over blocks. When CSE
12352encounters a simple @code{if} statement with no else clause,
12353@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12354body of the @code{if}.
12355
12356Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12357
d77de738 12358@opindex frerun-cse-after-loop
ddf6fe37 12359@item -frerun-cse-after-loop
d77de738
ML
12360Re-run common subexpression elimination after loop optimizations are
12361performed.
12362
12363Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12364
d77de738 12365@opindex fgcse
ddf6fe37 12366@item -fgcse
d77de738
ML
12367Perform a global common subexpression elimination pass.
12368This pass also performs global constant and copy propagation.
12369
12370@emph{Note:} When compiling a program using computed gotos, a GCC
12371extension, you may get better run-time performance if you disable
12372the global common subexpression elimination pass by adding
12373@option{-fno-gcse} to the command line.
12374
12375Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12376
d77de738 12377@opindex fgcse-lm
ddf6fe37 12378@item -fgcse-lm
d77de738
ML
12379When @option{-fgcse-lm} is enabled, global common subexpression elimination
12380attempts to move loads that are only killed by stores into themselves. This
12381allows a loop containing a load/store sequence to be changed to a load outside
12382the loop, and a copy/store within the loop.
12383
12384Enabled by default when @option{-fgcse} is enabled.
12385
d77de738 12386@opindex fgcse-sm
ddf6fe37 12387@item -fgcse-sm
d77de738
ML
12388When @option{-fgcse-sm} is enabled, a store motion pass is run after
12389global common subexpression elimination. This pass attempts to move
12390stores out of loops. When used in conjunction with @option{-fgcse-lm},
12391loops containing a load/store sequence can be changed to a load before
12392the loop and a store after the loop.
12393
12394Not enabled at any optimization level.
12395
d77de738 12396@opindex fgcse-las
ddf6fe37 12397@item -fgcse-las
d77de738
ML
12398When @option{-fgcse-las} is enabled, the global common subexpression
12399elimination pass eliminates redundant loads that come after stores to the
12400same memory location (both partial and full redundancies).
12401
12402Not enabled at any optimization level.
12403
d77de738 12404@opindex fgcse-after-reload
ddf6fe37 12405@item -fgcse-after-reload
d77de738
ML
12406When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12407pass is performed after reload. The purpose of this pass is to clean up
12408redundant spilling.
12409
12410Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12411
d77de738 12412@opindex faggressive-loop-optimizations
ddf6fe37 12413@item -faggressive-loop-optimizations
d77de738
ML
12414This option tells the loop optimizer to use language constraints to
12415derive bounds for the number of iterations of a loop. This assumes that
12416loop code does not invoke undefined behavior by for example causing signed
12417integer overflows or out-of-bound array accesses. The bounds for the
12418number of iterations of a loop are used to guide loop unrolling and peeling
12419and loop exit test optimizations.
12420This option is enabled by default.
12421
d77de738 12422@opindex funconstrained-commons
ddf6fe37 12423@item -funconstrained-commons
d77de738
ML
12424This option tells the compiler that variables declared in common blocks
12425(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12426prevents certain optimizations that depend on knowing the array bounds.
12427
d77de738 12428@opindex fcrossjumping
ddf6fe37 12429@item -fcrossjumping
d77de738
ML
12430Perform cross-jumping transformation.
12431This transformation unifies equivalent code and saves code size. The
12432resulting code may or may not perform better than without cross-jumping.
12433
12434Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12435
d77de738 12436@opindex fauto-inc-dec
ddf6fe37 12437@item -fauto-inc-dec
d77de738
ML
12438Combine increments or decrements of addresses with memory accesses.
12439This pass is always skipped on architectures that do not have
12440instructions to support this. Enabled by default at @option{-O1} and
12441higher on architectures that support this.
12442
d77de738 12443@opindex fdce
ddf6fe37 12444@item -fdce
d77de738
ML
12445Perform dead code elimination (DCE) on RTL@.
12446Enabled by default at @option{-O1} and higher.
12447
d77de738 12448@opindex fdse
ddf6fe37 12449@item -fdse
d77de738
ML
12450Perform dead store elimination (DSE) on RTL@.
12451Enabled by default at @option{-O1} and higher.
12452
d77de738 12453@opindex fif-conversion
ddf6fe37 12454@item -fif-conversion
d77de738
ML
12455Attempt to transform conditional jumps into branch-less equivalents. This
12456includes use of conditional moves, min, max, set flags and abs instructions, and
12457some tricks doable by standard arithmetics. The use of conditional execution
12458on chips where it is available is controlled by @option{-fif-conversion2}.
12459
12460Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12461not with @option{-Og}.
12462
d77de738 12463@opindex fif-conversion2
ddf6fe37 12464@item -fif-conversion2
d77de738
ML
12465Use conditional execution (where available) to transform conditional jumps into
12466branch-less equivalents.
12467
12468Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12469not with @option{-Og}.
12470
d77de738 12471@opindex fdeclone-ctor-dtor
ddf6fe37 12472@item -fdeclone-ctor-dtor
d77de738
ML
12473The C++ ABI requires multiple entry points for constructors and
12474destructors: one for a base subobject, one for a complete object, and
12475one for a virtual destructor that calls operator delete afterwards.
12476For a hierarchy with virtual bases, the base and complete variants are
12477clones, which means two copies of the function. With this option, the
12478base and complete variants are changed to be thunks that call a common
12479implementation.
12480
12481Enabled by @option{-Os}.
12482
d77de738 12483@opindex fdelete-null-pointer-checks
ddf6fe37 12484@item -fdelete-null-pointer-checks
d77de738
ML
12485Assume that programs cannot safely dereference null pointers, and that
12486no code or data element resides at address zero.
12487This option enables simple constant
12488folding optimizations at all optimization levels. In addition, other
12489optimization passes in GCC use this flag to control global dataflow
12490analyses that eliminate useless checks for null pointers; these assume
12491that a memory access to address zero always results in a trap, so
12492that if a pointer is checked after it has already been dereferenced,
12493it cannot be null.
12494
12495Note however that in some environments this assumption is not true.
12496Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12497for programs that depend on that behavior.
12498
12499This option is enabled by default on most targets. On Nios II ELF, it
12500defaults to off. On AVR and MSP430, this option is completely disabled.
12501
12502Passes that use the dataflow information
12503are enabled independently at different optimization levels.
12504
d77de738 12505@opindex fdevirtualize
ddf6fe37 12506@item -fdevirtualize
d77de738
ML
12507Attempt to convert calls to virtual functions to direct calls. This
12508is done both within a procedure and interprocedurally as part of
12509indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12510propagation (@option{-fipa-cp}).
12511Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12512
d77de738 12513@opindex fdevirtualize-speculatively
ddf6fe37 12514@item -fdevirtualize-speculatively
d77de738
ML
12515Attempt to convert calls to virtual functions to speculative direct calls.
12516Based on the analysis of the type inheritance graph, determine for a given call
12517the set of likely targets. If the set is small, preferably of size 1, change
12518the call into a conditional deciding between direct and indirect calls. The
12519speculative calls enable more optimizations, such as inlining. When they seem
12520useless after further optimization, they are converted back into original form.
12521
d77de738 12522@opindex fdevirtualize-at-ltrans
ddf6fe37 12523@item -fdevirtualize-at-ltrans
d77de738
ML
12524Stream extra information needed for aggressive devirtualization when running
12525the link-time optimizer in local transformation mode.
12526This option enables more devirtualization but
12527significantly increases the size of streamed data. For this reason it is
12528disabled by default.
12529
d77de738 12530@opindex fexpensive-optimizations
ddf6fe37 12531@item -fexpensive-optimizations
d77de738
ML
12532Perform a number of minor optimizations that are relatively expensive.
12533
12534Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12535
d77de738 12536@opindex free
ddf6fe37 12537@item -free
d77de738
ML
12538Attempt to remove redundant extension instructions. This is especially
12539helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12540registers after writing to their lower 32-bit half.
12541
9417b304
AKA
12542Enabled for Alpha, AArch64, PowerPC, RISC-V, SPARC, h83000 and x86 at levels
12543@option{-O2}, @option{-O3}, @option{-Os}.
d77de738 12544
d77de738
ML
12545@opindex fno-lifetime-dse
12546@opindex flifetime-dse
ddf6fe37 12547@item -fno-lifetime-dse
d77de738
ML
12548In C++ the value of an object is only affected by changes within its
12549lifetime: when the constructor begins, the object has an indeterminate
12550value, and any changes during the lifetime of the object are dead when
12551the object is destroyed. Normally dead store elimination will take
12552advantage of this; if your code relies on the value of the object
12553storage persisting beyond the lifetime of the object, you can use this
12554flag to disable this optimization. To preserve stores before the
12555constructor starts (e.g.@: because your operator new clears the object
12556storage) but still treat the object as dead after the destructor, you
12557can use @option{-flifetime-dse=1}. The default behavior can be
12558explicitly selected with @option{-flifetime-dse=2}.
12559@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12560
d77de738 12561@opindex flive-range-shrinkage
ddf6fe37 12562@item -flive-range-shrinkage
d77de738
ML
12563Attempt to decrease register pressure through register live range
12564shrinkage. This is helpful for fast processors with small or moderate
12565size register sets.
12566
d77de738 12567@opindex fira-algorithm
ddf6fe37 12568@item -fira-algorithm=@var{algorithm}
d77de738
ML
12569Use the specified coloring algorithm for the integrated register
12570allocator. The @var{algorithm} argument can be @samp{priority}, which
12571specifies Chow's priority coloring, or @samp{CB}, which specifies
12572Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12573for all architectures, but for those targets that do support it, it is
12574the default because it generates better code.
12575
d77de738 12576@opindex fira-region
ddf6fe37 12577@item -fira-region=@var{region}
d77de738
ML
12578Use specified regions for the integrated register allocator. The
12579@var{region} argument should be one of the following:
12580
12581@table @samp
12582
12583@item all
12584Use all loops as register allocation regions.
12585This can give the best results for machines with a small and/or
12586irregular register set.
12587
12588@item mixed
12589Use all loops except for loops with small register pressure
12590as the regions. This value usually gives
12591the best results in most cases and for most architectures,
12592and is enabled by default when compiling with optimization for speed
12593(@option{-O}, @option{-O2}, @dots{}).
12594
12595@item one
12596Use all functions as a single region.
12597This typically results in the smallest code size, and is enabled by default for
12598@option{-Os} or @option{-O0}.
12599
12600@end table
12601
d77de738 12602@opindex fira-hoist-pressure
ddf6fe37 12603@item -fira-hoist-pressure
d77de738
ML
12604Use IRA to evaluate register pressure in the code hoisting pass for
12605decisions to hoist expressions. This option usually results in smaller
12606code, but it can slow the compiler down.
12607
12608This option is enabled at level @option{-Os} for all targets.
12609
d77de738 12610@opindex fira-loop-pressure
ddf6fe37 12611@item -fira-loop-pressure
d77de738
ML
12612Use IRA to evaluate register pressure in loops for decisions to move
12613loop invariants. This option usually results in generation
12614of faster and smaller code on machines with large register files (>= 32
12615registers), but it can slow the compiler down.
12616
12617This option is enabled at level @option{-O3} for some targets.
12618
d77de738
ML
12619@opindex fno-ira-share-save-slots
12620@opindex fira-share-save-slots
ddf6fe37 12621@item -fno-ira-share-save-slots
d77de738
ML
12622Disable sharing of stack slots used for saving call-used hard
12623registers living through a call. Each hard register gets a
12624separate stack slot, and as a result function stack frames are
12625larger.
12626
d77de738
ML
12627@opindex fno-ira-share-spill-slots
12628@opindex fira-share-spill-slots
ddf6fe37 12629@item -fno-ira-share-spill-slots
d77de738
ML
12630Disable sharing of stack slots allocated for pseudo-registers. Each
12631pseudo-register that does not get a hard register gets a separate
12632stack slot, and as a result function stack frames are larger.
12633
d77de738 12634@opindex flra-remat
ddf6fe37 12635@item -flra-remat
d77de738
ML
12636Enable CFG-sensitive rematerialization in LRA. Instead of loading
12637values of spilled pseudos, LRA tries to rematerialize (recalculate)
12638values if it is profitable.
12639
12640Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12641
d77de738 12642@opindex fdelayed-branch
ddf6fe37 12643@item -fdelayed-branch
d77de738
ML
12644If supported for the target machine, attempt to reorder instructions
12645to exploit instruction slots available after delayed branch
12646instructions.
12647
12648Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12649but not at @option{-Og}.
12650
d77de738 12651@opindex fschedule-insns
ddf6fe37 12652@item -fschedule-insns
d77de738
ML
12653If supported for the target machine, attempt to reorder instructions to
12654eliminate execution stalls due to required data being unavailable. This
12655helps machines that have slow floating point or memory load instructions
12656by allowing other instructions to be issued until the result of the load
12657or floating-point instruction is required.
12658
12659Enabled at levels @option{-O2}, @option{-O3}.
12660
d77de738 12661@opindex fschedule-insns2
ddf6fe37 12662@item -fschedule-insns2
d77de738
ML
12663Similar to @option{-fschedule-insns}, but requests an additional pass of
12664instruction scheduling after register allocation has been done. This is
12665especially useful on machines with a relatively small number of
12666registers and where memory load instructions take more than one cycle.
12667
12668Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12669
d77de738
ML
12670@opindex fno-sched-interblock
12671@opindex fsched-interblock
ddf6fe37 12672@item -fno-sched-interblock
d77de738
ML
12673Disable instruction scheduling across basic blocks, which
12674is normally enabled when scheduling before register allocation, i.e.@:
12675with @option{-fschedule-insns} or at @option{-O2} or higher.
12676
d77de738
ML
12677@opindex fno-sched-spec
12678@opindex fsched-spec
ddf6fe37 12679@item -fno-sched-spec
d77de738
ML
12680Disable speculative motion of non-load instructions, which
12681is normally enabled when scheduling before register allocation, i.e.@:
12682with @option{-fschedule-insns} or at @option{-O2} or higher.
12683
d77de738 12684@opindex fsched-pressure
ddf6fe37 12685@item -fsched-pressure
d77de738
ML
12686Enable register pressure sensitive insn scheduling before register
12687allocation. This only makes sense when scheduling before register
12688allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12689@option{-O2} or higher. Usage of this option can improve the
12690generated code and decrease its size by preventing register pressure
12691increase above the number of available hard registers and subsequent
12692spills in register allocation.
12693
d77de738 12694@opindex fsched-spec-load
ddf6fe37 12695@item -fsched-spec-load
d77de738
ML
12696Allow speculative motion of some load instructions. This only makes
12697sense when scheduling before register allocation, i.e.@: with
12698@option{-fschedule-insns} or at @option{-O2} or higher.
12699
d77de738 12700@opindex fsched-spec-load-dangerous
ddf6fe37 12701@item -fsched-spec-load-dangerous
d77de738
ML
12702Allow speculative motion of more load instructions. This only makes
12703sense when scheduling before register allocation, i.e.@: with
12704@option{-fschedule-insns} or at @option{-O2} or higher.
12705
ddf6fe37 12706@opindex fsched-stalled-insns
d77de738
ML
12707@item -fsched-stalled-insns
12708@itemx -fsched-stalled-insns=@var{n}
d77de738
ML
12709Define how many insns (if any) can be moved prematurely from the queue
12710of stalled insns into the ready list during the second scheduling pass.
12711@option{-fno-sched-stalled-insns} means that no insns are moved
12712prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12713on how many queued insns can be moved prematurely.
12714@option{-fsched-stalled-insns} without a value is equivalent to
12715@option{-fsched-stalled-insns=1}.
12716
ddf6fe37 12717@opindex fsched-stalled-insns-dep
d77de738
ML
12718@item -fsched-stalled-insns-dep
12719@itemx -fsched-stalled-insns-dep=@var{n}
d77de738
ML
12720Define how many insn groups (cycles) are examined for a dependency
12721on a stalled insn that is a candidate for premature removal from the queue
12722of stalled insns. This has an effect only during the second scheduling pass,
12723and only if @option{-fsched-stalled-insns} is used.
12724@option{-fno-sched-stalled-insns-dep} is equivalent to
12725@option{-fsched-stalled-insns-dep=0}.
12726@option{-fsched-stalled-insns-dep} without a value is equivalent to
12727@option{-fsched-stalled-insns-dep=1}.
12728
d77de738 12729@opindex fsched2-use-superblocks
ddf6fe37 12730@item -fsched2-use-superblocks
d77de738
ML
12731When scheduling after register allocation, use superblock scheduling.
12732This allows motion across basic block boundaries,
12733resulting in faster schedules. This option is experimental, as not all machine
12734descriptions used by GCC model the CPU closely enough to avoid unreliable
12735results from the algorithm.
12736
12737This only makes sense when scheduling after register allocation, i.e.@: with
12738@option{-fschedule-insns2} or at @option{-O2} or higher.
12739
d77de738 12740@opindex fsched-group-heuristic
ddf6fe37 12741@item -fsched-group-heuristic
d77de738
ML
12742Enable the group heuristic in the scheduler. This heuristic favors
12743the instruction that belongs to a schedule group. This is enabled
12744by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12745or @option{-fschedule-insns2} or at @option{-O2} or higher.
12746
d77de738 12747@opindex fsched-critical-path-heuristic
ddf6fe37 12748@item -fsched-critical-path-heuristic
d77de738
ML
12749Enable the critical-path heuristic in the scheduler. This heuristic favors
12750instructions on the critical path. This is enabled by default when
12751scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12752or @option{-fschedule-insns2} or at @option{-O2} or higher.
12753
d77de738 12754@opindex fsched-spec-insn-heuristic
ddf6fe37 12755@item -fsched-spec-insn-heuristic
d77de738
ML
12756Enable the speculative instruction heuristic in the scheduler. This
12757heuristic favors speculative instructions with greater dependency weakness.
12758This is enabled by default when scheduling is enabled, i.e.@:
12759with @option{-fschedule-insns} or @option{-fschedule-insns2}
12760or at @option{-O2} or higher.
12761
d77de738 12762@opindex fsched-rank-heuristic
ddf6fe37 12763@item -fsched-rank-heuristic
d77de738
ML
12764Enable the rank heuristic in the scheduler. This heuristic favors
12765the instruction belonging to a basic block with greater size or frequency.
12766This is enabled by default when scheduling is enabled, i.e.@:
12767with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12768at @option{-O2} or higher.
12769
d77de738 12770@opindex fsched-last-insn-heuristic
ddf6fe37 12771@item -fsched-last-insn-heuristic
d77de738
ML
12772Enable the last-instruction heuristic in the scheduler. This heuristic
12773favors the instruction that is less dependent on the last instruction
12774scheduled. This is enabled by default when scheduling is enabled,
12775i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12776at @option{-O2} or higher.
12777
d77de738 12778@opindex fsched-dep-count-heuristic
ddf6fe37 12779@item -fsched-dep-count-heuristic
d77de738
ML
12780Enable the dependent-count heuristic in the scheduler. This heuristic
12781favors the instruction that has more instructions depending on it.
12782This is enabled by default when scheduling is enabled, i.e.@:
12783with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12784at @option{-O2} or higher.
12785
d77de738 12786@opindex freschedule-modulo-scheduled-loops
ddf6fe37 12787@item -freschedule-modulo-scheduled-loops
d77de738
ML
12788Modulo scheduling is performed before traditional scheduling. If a loop
12789is modulo scheduled, later scheduling passes may change its schedule.
12790Use this option to control that behavior.
12791
d77de738 12792@opindex fselective-scheduling
ddf6fe37 12793@item -fselective-scheduling
d77de738
ML
12794Schedule instructions using selective scheduling algorithm. Selective
12795scheduling runs instead of the first scheduler pass.
12796
d77de738 12797@opindex fselective-scheduling2
ddf6fe37 12798@item -fselective-scheduling2
d77de738
ML
12799Schedule instructions using selective scheduling algorithm. Selective
12800scheduling runs instead of the second scheduler pass.
12801
d77de738 12802@opindex fsel-sched-pipelining
ddf6fe37 12803@item -fsel-sched-pipelining
d77de738
ML
12804Enable software pipelining of innermost loops during selective scheduling.
12805This option has no effect unless one of @option{-fselective-scheduling} or
12806@option{-fselective-scheduling2} is turned on.
12807
d77de738 12808@opindex fsel-sched-pipelining-outer-loops
ddf6fe37 12809@item -fsel-sched-pipelining-outer-loops
d77de738
ML
12810When pipelining loops during selective scheduling, also pipeline outer loops.
12811This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12812
d77de738 12813@opindex fsemantic-interposition
ddf6fe37 12814@item -fsemantic-interposition
d77de738
ML
12815Some object formats, like ELF, allow interposing of symbols by the
12816dynamic linker.
12817This means that for symbols exported from the DSO, the compiler cannot perform
12818interprocedural propagation, inlining and other optimizations in anticipation
12819that the function or variable in question may change. While this feature is
12820useful, for example, to rewrite memory allocation functions by a debugging
12821implementation, it is expensive in the terms of code quality.
12822With @option{-fno-semantic-interposition} the compiler assumes that
12823if interposition happens for functions the overwriting function will have
12824precisely the same semantics (and side effects).
12825Similarly if interposition happens
12826for variables, the constructor of the variable will be the same. The flag
12827has no effect for functions explicitly declared inline
12828(where it is never allowed for interposition to change semantics)
12829and for symbols explicitly declared weak.
12830
d77de738 12831@opindex fshrink-wrap
ddf6fe37 12832@item -fshrink-wrap
d77de738
ML
12833Emit function prologues only before parts of the function that need it,
12834rather than at the top of the function. This flag is enabled by default at
12835@option{-O} and higher.
12836
d77de738 12837@opindex fshrink-wrap-separate
ddf6fe37 12838@item -fshrink-wrap-separate
d77de738
ML
12839Shrink-wrap separate parts of the prologue and epilogue separately, so that
12840those parts are only executed when needed.
12841This option is on by default, but has no effect unless @option{-fshrink-wrap}
12842is also turned on and the target supports this.
12843
d77de738 12844@opindex fcaller-saves
ddf6fe37 12845@item -fcaller-saves
d77de738
ML
12846Enable allocation of values to registers that are clobbered by
12847function calls, by emitting extra instructions to save and restore the
12848registers around such calls. Such allocation is done only when it
12849seems to result in better code.
12850
12851This option is always enabled by default on certain machines, usually
12852those which have no call-preserved registers to use instead.
12853
12854Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12855
d77de738 12856@opindex fcombine-stack-adjustments
ddf6fe37 12857@item -fcombine-stack-adjustments
d77de738
ML
12858Tracks stack adjustments (pushes and pops) and stack memory references
12859and then tries to find ways to combine them.
12860
12861Enabled by default at @option{-O1} and higher.
12862
d77de738 12863@opindex fipa-ra
ddf6fe37 12864@item -fipa-ra
d77de738
ML
12865Use caller save registers for allocation if those registers are not used by
12866any called function. In that case it is not necessary to save and restore
12867them around calls. This is only possible if called functions are part of
12868same compilation unit as current function and they are compiled before it.
12869
12870Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
12871is disabled if generated code will be instrumented for profiling
12872(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
12873exactly (this happens on targets that do not expose prologues
12874and epilogues in RTL).
12875
d77de738 12876@opindex fconserve-stack
ddf6fe37 12877@item -fconserve-stack
d77de738
ML
12878Attempt to minimize stack usage. The compiler attempts to use less
12879stack space, even if that makes the program slower. This option
12880implies setting the @option{large-stack-frame} parameter to 100
12881and the @option{large-stack-frame-growth} parameter to 400.
12882
d77de738 12883@opindex ftree-reassoc
ddf6fe37 12884@item -ftree-reassoc
d77de738
ML
12885Perform reassociation on trees. This flag is enabled by default
12886at @option{-O1} and higher.
12887
d77de738 12888@opindex fcode-hoisting
ddf6fe37 12889@item -fcode-hoisting
d77de738
ML
12890Perform code hoisting. Code hoisting tries to move the
12891evaluation of expressions executed on all paths to the function exit
12892as early as possible. This is especially useful as a code size
12893optimization, but it often helps for code speed as well.
12894This flag is enabled by default at @option{-O2} and higher.
12895
d77de738 12896@opindex ftree-pre
ddf6fe37 12897@item -ftree-pre
d77de738
ML
12898Perform partial redundancy elimination (PRE) on trees. This flag is
12899enabled by default at @option{-O2} and @option{-O3}.
12900
d77de738 12901@opindex ftree-partial-pre
ddf6fe37 12902@item -ftree-partial-pre
d77de738
ML
12903Make partial redundancy elimination (PRE) more aggressive. This flag is
12904enabled by default at @option{-O3}.
12905
d77de738 12906@opindex ftree-forwprop
ddf6fe37 12907@item -ftree-forwprop
d77de738
ML
12908Perform forward propagation on trees. This flag is enabled by default
12909at @option{-O1} and higher.
12910
d77de738 12911@opindex ftree-fre
ddf6fe37 12912@item -ftree-fre
d77de738
ML
12913Perform full redundancy elimination (FRE) on trees. The difference
12914between FRE and PRE is that FRE only considers expressions
12915that are computed on all paths leading to the redundant computation.
12916This analysis is faster than PRE, though it exposes fewer redundancies.
12917This flag is enabled by default at @option{-O1} and higher.
12918
d77de738 12919@opindex ftree-phiprop
ddf6fe37 12920@item -ftree-phiprop
d77de738
ML
12921Perform hoisting of loads from conditional pointers on trees. This
12922pass is enabled by default at @option{-O1} and higher.
12923
d77de738 12924@opindex fhoist-adjacent-loads
ddf6fe37 12925@item -fhoist-adjacent-loads
d77de738
ML
12926Speculatively hoist loads from both branches of an if-then-else if the
12927loads are from adjacent locations in the same structure and the target
12928architecture has a conditional move instruction. This flag is enabled
12929by default at @option{-O2} and higher.
12930
d77de738 12931@opindex ftree-copy-prop
ddf6fe37 12932@item -ftree-copy-prop
d77de738
ML
12933Perform copy propagation on trees. This pass eliminates unnecessary
12934copy operations. This flag is enabled by default at @option{-O1} and
12935higher.
12936
d77de738 12937@opindex fipa-pure-const
ddf6fe37 12938@item -fipa-pure-const
d77de738
ML
12939Discover which functions are pure or constant.
12940Enabled by default at @option{-O1} and higher.
12941
d77de738 12942@opindex fipa-reference
ddf6fe37 12943@item -fipa-reference
d77de738
ML
12944Discover which static variables do not escape the
12945compilation unit.
12946Enabled by default at @option{-O1} and higher.
12947
d77de738 12948@opindex fipa-reference-addressable
ddf6fe37 12949@item -fipa-reference-addressable
d77de738
ML
12950Discover read-only, write-only and non-addressable static variables.
12951Enabled by default at @option{-O1} and higher.
12952
d77de738 12953@opindex fipa-stack-alignment
ddf6fe37 12954@item -fipa-stack-alignment
d77de738
ML
12955Reduce stack alignment on call sites if possible.
12956Enabled by default.
12957
d77de738 12958@opindex fipa-pta
ddf6fe37 12959@item -fipa-pta
d77de738
ML
12960Perform interprocedural pointer analysis and interprocedural modification
12961and reference analysis. This option can cause excessive memory and
12962compile-time usage on large compilation units. It is not enabled by
12963default at any optimization level.
12964
d77de738 12965@opindex fipa-profile
ddf6fe37 12966@item -fipa-profile
d77de738
ML
12967Perform interprocedural profile propagation. The functions called only from
12968cold functions are marked as cold. Also functions executed once (such as
12969@code{cold}, @code{noreturn}, static constructors or destructors) are
12970identified. Cold functions and loop less parts of functions executed once are
12971then optimized for size.
12972Enabled by default at @option{-O1} and higher.
12973
d77de738 12974@opindex fipa-modref
ddf6fe37 12975@item -fipa-modref
d77de738
ML
12976Perform interprocedural mod/ref analysis. This optimization analyzes the side
12977effects of functions (memory locations that are modified or referenced) and
12978enables better optimization across the function call boundary. This flag is
12979enabled by default at @option{-O1} and higher.
12980
d77de738 12981@opindex fipa-cp
ddf6fe37 12982@item -fipa-cp
d77de738
ML
12983Perform interprocedural constant propagation.
12984This optimization analyzes the program to determine when values passed
12985to functions are constants and then optimizes accordingly.
12986This optimization can substantially increase performance
12987if the application has constants passed to functions.
12988This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
12989It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12990
d77de738 12991@opindex fipa-cp-clone
ddf6fe37 12992@item -fipa-cp-clone
d77de738
ML
12993Perform function cloning to make interprocedural constant propagation stronger.
12994When enabled, interprocedural constant propagation performs function cloning
12995when externally visible function can be called with constant arguments.
12996Because this optimization can create multiple copies of functions,
12997it may significantly increase code size
12998(see @option{--param ipa-cp-unit-growth=@var{value}}).
12999This flag is enabled by default at @option{-O3}.
13000It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13001
d77de738 13002@opindex fipa-bit-cp
ddf6fe37 13003@item -fipa-bit-cp
d77de738
ML
13004When enabled, perform interprocedural bitwise constant
13005propagation. This flag is enabled by default at @option{-O2} and
13006by @option{-fprofile-use} and @option{-fauto-profile}.
13007It requires that @option{-fipa-cp} is enabled.
13008
d77de738 13009@opindex fipa-vrp
ddf6fe37 13010@item -fipa-vrp
d77de738
ML
13011When enabled, perform interprocedural propagation of value
13012ranges. This flag is enabled by default at @option{-O2}. It requires
13013that @option{-fipa-cp} is enabled.
13014
d77de738 13015@opindex fipa-icf
ddf6fe37 13016@item -fipa-icf
d77de738
ML
13017Perform Identical Code Folding for functions and read-only variables.
13018The optimization reduces code size and may disturb unwind stacks by replacing
13019a function by equivalent one with a different name. The optimization works
13020more effectively with link-time optimization enabled.
13021
13022Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
13023works on different levels and thus the optimizations are not same - there are
13024equivalences that are found only by GCC and equivalences found only by Gold.
13025
13026This flag is enabled by default at @option{-O2} and @option{-Os}.
13027
d77de738 13028@opindex flive-patching
ddf6fe37 13029@item -flive-patching=@var{level}
d77de738
ML
13030Control GCC's optimizations to produce output suitable for live-patching.
13031
13032If the compiler's optimization uses a function's body or information extracted
13033from its body to optimize/change another function, the latter is called an
13034impacted function of the former. If a function is patched, its impacted
13035functions should be patched too.
13036
13037The impacted functions are determined by the compiler's interprocedural
13038optimizations. For example, a caller is impacted when inlining a function
13039into its caller,
13040cloning a function and changing its caller to call this new clone,
13041or extracting a function's pureness/constness information to optimize
13042its direct or indirect callers, etc.
13043
13044Usually, the more IPA optimizations enabled, the larger the number of
13045impacted functions for each function. In order to control the number of
13046impacted functions and more easily compute the list of impacted function,
13047IPA optimizations can be partially enabled at two different levels.
13048
13049The @var{level} argument should be one of the following:
13050
13051@table @samp
13052
13053@item inline-clone
13054
13055Only enable inlining and cloning optimizations, which includes inlining,
13056cloning, interprocedural scalar replacement of aggregates and partial inlining.
13057As a result, when patching a function, all its callers and its clones'
13058callers are impacted, therefore need to be patched as well.
13059
13060@option{-flive-patching=inline-clone} disables the following optimization flags:
43b72ede
AA
13061@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
13062-fipa-icf -fipa-icf-functions -fipa-icf-variables
13063-fipa-bit-cp -fipa-vrp -fipa-pure-const
13064-fipa-reference-addressable
d77de738
ML
13065-fipa-stack-alignment -fipa-modref}
13066
13067@item inline-only-static
13068
13069Only enable inlining of static functions.
13070As a result, when patching a static function, all its callers are impacted
13071and so need to be patched as well.
13072
13073In addition to all the flags that @option{-flive-patching=inline-clone}
13074disables,
13075@option{-flive-patching=inline-only-static} disables the following additional
13076optimization flags:
13077@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
13078
13079@end table
13080
13081When @option{-flive-patching} is specified without any value, the default value
13082is @var{inline-clone}.
13083
13084This flag is disabled by default.
13085
13086Note that @option{-flive-patching} is not supported with link-time optimization
13087(@option{-flto}).
13088
d77de738 13089@opindex fisolate-erroneous-paths-dereference
ddf6fe37 13090@item -fisolate-erroneous-paths-dereference
d77de738
ML
13091Detect paths that trigger erroneous or undefined behavior due to
13092dereferencing a null pointer. Isolate those paths from the main control
13093flow and turn the statement with erroneous or undefined behavior into a trap.
13094This flag is enabled by default at @option{-O2} and higher and depends on
13095@option{-fdelete-null-pointer-checks} also being enabled.
13096
d77de738 13097@opindex fisolate-erroneous-paths-attribute
ddf6fe37 13098@item -fisolate-erroneous-paths-attribute
d77de738
ML
13099Detect paths that trigger erroneous or undefined behavior due to a null value
13100being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
13101attribute. Isolate those paths from the main control flow and turn the
13102statement with erroneous or undefined behavior into a trap. This is not
13103currently enabled, but may be enabled by @option{-O2} in the future.
13104
d77de738 13105@opindex ftree-sink
ddf6fe37 13106@item -ftree-sink
d77de738
ML
13107Perform forward store motion on trees. This flag is
13108enabled by default at @option{-O1} and higher.
13109
d77de738 13110@opindex ftree-bit-ccp
ddf6fe37 13111@item -ftree-bit-ccp
d77de738
ML
13112Perform sparse conditional bit constant propagation on trees and propagate
13113pointer alignment information.
13114This pass only operates on local scalar variables and is enabled by default
13115at @option{-O1} and higher, except for @option{-Og}.
13116It requires that @option{-ftree-ccp} is enabled.
13117
d77de738 13118@opindex ftree-ccp
ddf6fe37 13119@item -ftree-ccp
d77de738
ML
13120Perform sparse conditional constant propagation (CCP) on trees. This
13121pass only operates on local scalar variables and is enabled by default
13122at @option{-O1} and higher.
13123
d77de738 13124@opindex fssa-backprop
ddf6fe37 13125@item -fssa-backprop
d77de738
ML
13126Propagate information about uses of a value up the definition chain
13127in order to simplify the definitions. For example, this pass strips
13128sign operations if the sign of a value never matters. The flag is
13129enabled by default at @option{-O1} and higher.
13130
d77de738 13131@opindex fssa-phiopt
ddf6fe37 13132@item -fssa-phiopt
d77de738
ML
13133Perform pattern matching on SSA PHI nodes to optimize conditional
13134code. This pass is enabled by default at @option{-O1} and higher,
13135except for @option{-Og}.
13136
d77de738 13137@opindex ftree-switch-conversion
ddf6fe37 13138@item -ftree-switch-conversion
d77de738
ML
13139Perform conversion of simple initializations in a switch to
13140initializations from a scalar array. This flag is enabled by default
13141at @option{-O2} and higher.
13142
d77de738 13143@opindex ftree-tail-merge
ddf6fe37 13144@item -ftree-tail-merge
d77de738
ML
13145Look for identical code sequences. When found, replace one with a jump to the
13146other. This optimization is known as tail merging or cross jumping. This flag
13147is enabled by default at @option{-O2} and higher. The compilation time
13148in this pass can
13149be limited using @option{max-tail-merge-comparisons} parameter and
13150@option{max-tail-merge-iterations} parameter.
13151
d77de738 13152@opindex ftree-dce
ddf6fe37 13153@item -ftree-dce
d77de738
ML
13154Perform dead code elimination (DCE) on trees. This flag is enabled by
13155default at @option{-O1} and higher.
13156
d77de738 13157@opindex ftree-builtin-call-dce
ddf6fe37 13158@item -ftree-builtin-call-dce
d77de738
ML
13159Perform conditional dead code elimination (DCE) for calls to built-in functions
13160that may set @code{errno} but are otherwise free of side effects. This flag is
13161enabled by default at @option{-O2} and higher if @option{-Os} is not also
13162specified.
13163
d77de738
ML
13164@opindex ffinite-loops
13165@opindex fno-finite-loops
ddf6fe37 13166@item -ffinite-loops
d77de738
ML
13167Assume that a loop with an exit will eventually take the exit and not loop
13168indefinitely. This allows the compiler to remove loops that otherwise have
13169no side-effects, not considering eventual endless looping as such.
13170
13171This option is enabled by default at @option{-O2} for C++ with -std=c++11
13172or higher.
13173
d77de738 13174@opindex ftree-dominator-opts
ddf6fe37 13175@item -ftree-dominator-opts
d77de738
ML
13176Perform a variety of simple scalar cleanups (constant/copy
13177propagation, redundancy elimination, range propagation and expression
13178simplification) based on a dominator tree traversal. This also
13179performs jump threading (to reduce jumps to jumps). This flag is
13180enabled by default at @option{-O1} and higher.
13181
d77de738 13182@opindex ftree-dse
ddf6fe37 13183@item -ftree-dse
d77de738
ML
13184Perform dead store elimination (DSE) on trees. A dead store is a store into
13185a memory location that is later overwritten by another store without
13186any intervening loads. In this case the earlier store can be deleted. This
13187flag is enabled by default at @option{-O1} and higher.
13188
d77de738 13189@opindex ftree-ch
ddf6fe37 13190@item -ftree-ch
d77de738
ML
13191Perform loop header copying on trees. This is beneficial since it increases
13192effectiveness of code motion optimizations. It also saves one jump. This flag
13193is enabled by default at @option{-O1} and higher. It is not enabled
13194for @option{-Os}, since it usually increases code size.
13195
d77de738 13196@opindex ftree-loop-optimize
ddf6fe37 13197@item -ftree-loop-optimize
d77de738
ML
13198Perform loop optimizations on trees. This flag is enabled by default
13199at @option{-O1} and higher.
13200
d77de738
ML
13201@opindex ftree-loop-linear
13202@opindex floop-strip-mine
13203@opindex floop-block
ddf6fe37
AA
13204@item -ftree-loop-linear
13205@itemx -floop-strip-mine
13206@itemx -floop-block
d77de738
ML
13207Perform loop nest optimizations. Same as
13208@option{-floop-nest-optimize}. To use this code transformation, GCC has
13209to be configured with @option{--with-isl} to enable the Graphite loop
13210transformation infrastructure.
13211
d77de738 13212@opindex fgraphite-identity
ddf6fe37 13213@item -fgraphite-identity
d77de738
ML
13214Enable the identity transformation for graphite. For every SCoP we generate
13215the polyhedral representation and transform it back to gimple. Using
13216@option{-fgraphite-identity} we can check the costs or benefits of the
13217GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13218are also performed by the code generator isl, like index splitting and
13219dead code elimination in loops.
13220
d77de738 13221@opindex floop-nest-optimize
ddf6fe37 13222@item -floop-nest-optimize
d77de738
ML
13223Enable the isl based loop nest optimizer. This is a generic loop nest
13224optimizer based on the Pluto optimization algorithms. It calculates a loop
13225structure optimized for data-locality and parallelism. This option
13226is experimental.
13227
d77de738 13228@opindex floop-parallelize-all
ddf6fe37 13229@item -floop-parallelize-all
d77de738
ML
13230Use the Graphite data dependence analysis to identify loops that can
13231be parallelized. Parallelize all the loops that can be analyzed to
13232not contain loop carried dependences without checking that it is
13233profitable to parallelize the loops.
13234
d77de738 13235@opindex ftree-coalesce-vars
ddf6fe37 13236@item -ftree-coalesce-vars
d77de738
ML
13237While transforming the program out of the SSA representation, attempt to
13238reduce copying by coalescing versions of different user-defined
13239variables, instead of just compiler temporaries. This may severely
13240limit the ability to debug an optimized program compiled with
13241@option{-fno-var-tracking-assignments}. In the negated form, this flag
13242prevents SSA coalescing of user variables. This option is enabled by
13243default if optimization is enabled, and it does very little otherwise.
13244
d77de738 13245@opindex ftree-loop-if-convert
ddf6fe37 13246@item -ftree-loop-if-convert
d77de738
ML
13247Attempt to transform conditional jumps in the innermost loops to
13248branch-less equivalents. The intent is to remove control-flow from
13249the innermost loops in order to improve the ability of the
13250vectorization pass to handle these loops. This is enabled by default
13251if vectorization is enabled.
13252
d77de738 13253@opindex ftree-loop-distribution
ddf6fe37 13254@item -ftree-loop-distribution
d77de738
ML
13255Perform loop distribution. This flag can improve cache performance on
13256big loop bodies and allow further loop optimizations, like
13257parallelization or vectorization, to take place. For example, the loop
13258@smallexample
13259DO I = 1, N
13260 A(I) = B(I) + C
13261 D(I) = E(I) * F
13262ENDDO
13263@end smallexample
13264is transformed to
13265@smallexample
13266DO I = 1, N
13267 A(I) = B(I) + C
13268ENDDO
13269DO I = 1, N
13270 D(I) = E(I) * F
13271ENDDO
13272@end smallexample
13273This flag is enabled by default at @option{-O3}.
13274It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13275
d77de738 13276@opindex ftree-loop-distribute-patterns
ddf6fe37 13277@item -ftree-loop-distribute-patterns
d77de738
ML
13278Perform loop distribution of patterns that can be code generated with
13279calls to a library. This flag is enabled by default at @option{-O2} and
13280higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13281
13282This pass distributes the initialization loops and generates a call to
13283memset zero. For example, the loop
13284@smallexample
13285DO I = 1, N
13286 A(I) = 0
13287 B(I) = A(I) + I
13288ENDDO
13289@end smallexample
13290is transformed to
13291@smallexample
13292DO I = 1, N
13293 A(I) = 0
13294ENDDO
13295DO I = 1, N
13296 B(I) = A(I) + I
13297ENDDO
13298@end smallexample
13299and the initialization loop is transformed into a call to memset zero.
13300This flag is enabled by default at @option{-O3}.
13301It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13302
d77de738 13303@opindex floop-interchange
ddf6fe37 13304@item -floop-interchange
d77de738
ML
13305Perform loop interchange outside of graphite. This flag can improve cache
13306performance on loop nest and allow further loop optimizations, like
13307vectorization, to take place. For example, the loop
13308@smallexample
13309for (int i = 0; i < N; i++)
13310 for (int j = 0; j < N; j++)
13311 for (int k = 0; k < N; k++)
13312 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13313@end smallexample
13314is transformed to
13315@smallexample
13316for (int i = 0; i < N; i++)
13317 for (int k = 0; k < N; k++)
13318 for (int j = 0; j < N; j++)
13319 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13320@end smallexample
13321This flag is enabled by default at @option{-O3}.
13322It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13323
d77de738 13324@opindex floop-unroll-and-jam
ddf6fe37 13325@item -floop-unroll-and-jam
d77de738
ML
13326Apply unroll and jam transformations on feasible loops. In a loop
13327nest this unrolls the outer loop by some factor and fuses the resulting
13328multiple inner loops. This flag is enabled by default at @option{-O3}.
13329It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13330
d77de738 13331@opindex ftree-loop-im
ddf6fe37 13332@item -ftree-loop-im
d77de738
ML
13333Perform loop invariant motion on trees. This pass moves only invariants that
13334are hard to handle at RTL level (function calls, operations that expand to
13335nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13336operands of conditions that are invariant out of the loop, so that we can use
13337just trivial invariantness analysis in loop unswitching. The pass also includes
13338store motion.
13339
d77de738 13340@opindex ftree-loop-ivcanon
ddf6fe37 13341@item -ftree-loop-ivcanon
d77de738
ML
13342Create a canonical counter for number of iterations in loops for which
13343determining number of iterations requires complicated analysis. Later
13344optimizations then may determine the number easily. Useful especially
13345in connection with unrolling.
13346
d77de738 13347@opindex ftree-scev-cprop
ddf6fe37 13348@item -ftree-scev-cprop
d77de738
ML
13349Perform final value replacement. If a variable is modified in a loop
13350in such a way that its value when exiting the loop can be determined using
13351only its initial value and the number of loop iterations, replace uses of
13352the final value by such a computation, provided it is sufficiently cheap.
13353This reduces data dependencies and may allow further simplifications.
13354Enabled by default at @option{-O1} and higher.
13355
d77de738 13356@opindex fivopts
ddf6fe37 13357@item -fivopts
d77de738
ML
13358Perform induction variable optimizations (strength reduction, induction
13359variable merging and induction variable elimination) on trees.
13360
d77de738 13361@opindex ftree-parallelize-loops
ddf6fe37 13362@item -ftree-parallelize-loops=n
d77de738
ML
13363Parallelize loops, i.e., split their iteration space to run in n threads.
13364This is only possible for loops whose iterations are independent
13365and can be arbitrarily reordered. The optimization is only
13366profitable on multiprocessor machines, for loops that are CPU-intensive,
13367rather than constrained e.g.@: by memory bandwidth. This option
13368implies @option{-pthread}, and thus is only supported on targets
13369that have support for @option{-pthread}.
13370
d77de738 13371@opindex ftree-pta
ddf6fe37 13372@item -ftree-pta
d77de738
ML
13373Perform function-local points-to analysis on trees. This flag is
13374enabled by default at @option{-O1} and higher, except for @option{-Og}.
13375
d77de738 13376@opindex ftree-sra
ddf6fe37 13377@item -ftree-sra
d77de738
ML
13378Perform scalar replacement of aggregates. This pass replaces structure
13379references with scalars to prevent committing structures to memory too
13380early. This flag is enabled by default at @option{-O1} and higher,
13381except for @option{-Og}.
13382
d77de738 13383@opindex fstore-merging
ddf6fe37 13384@item -fstore-merging
d77de738
ML
13385Perform merging of narrow stores to consecutive memory addresses. This pass
13386merges contiguous stores of immediate values narrower than a word into fewer
13387wider stores to reduce the number of instructions. This is enabled by default
13388at @option{-O2} and higher as well as @option{-Os}.
13389
d77de738 13390@opindex ftree-ter
ddf6fe37 13391@item -ftree-ter
d77de738
ML
13392Perform temporary expression replacement during the SSA->normal phase. Single
13393use/single def temporaries are replaced at their use location with their
13394defining expression. This results in non-GIMPLE code, but gives the expanders
13395much more complex trees to work on resulting in better RTL generation. This is
13396enabled by default at @option{-O1} and higher.
13397
d77de738 13398@opindex ftree-slsr
ddf6fe37 13399@item -ftree-slsr
d77de738
ML
13400Perform straight-line strength reduction on trees. This recognizes related
13401expressions involving multiplications and replaces them by less expensive
13402calculations when possible. This is enabled by default at @option{-O1} and
13403higher.
13404
d77de738 13405@opindex ftree-vectorize
ddf6fe37 13406@item -ftree-vectorize
d77de738
ML
13407Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13408and @option{-ftree-slp-vectorize} if not explicitly specified.
13409
d77de738 13410@opindex ftree-loop-vectorize
ddf6fe37 13411@item -ftree-loop-vectorize
d77de738
ML
13412Perform loop vectorization on trees. This flag is enabled by default at
13413@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13414and @option{-fauto-profile}.
13415
d77de738 13416@opindex ftree-slp-vectorize
ddf6fe37 13417@item -ftree-slp-vectorize
d77de738
ML
13418Perform basic block vectorization on trees. This flag is enabled by default at
13419@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13420and @option{-fauto-profile}.
13421
d77de738 13422@opindex ftrivial-auto-var-init
ddf6fe37 13423@item -ftrivial-auto-var-init=@var{choice}
d77de738
ML
13424Initialize automatic variables with either a pattern or with zeroes to increase
13425the security and predictability of a program by preventing uninitialized memory
13426disclosure and use.
13427GCC still considers an automatic variable that doesn't have an explicit
13428initializer as uninitialized, @option{-Wuninitialized} and
13429@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13430warning messages on such automatic variables and the compiler will
13431perform optimization as if the variable were uninitialized.
d77de738
ML
13432With this option, GCC will also initialize any padding of automatic variables
13433that have structure or union types to zeroes.
13434However, the current implementation cannot initialize automatic variables that
13435are declared between the controlling expression and the first case of a
13436@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13437such cases.
13438
13439The three values of @var{choice} are:
13440
13441@itemize @bullet
13442@item
13443@samp{uninitialized} doesn't initialize any automatic variables.
13444This is C and C++'s default.
13445
13446@item
13447@samp{pattern} Initialize automatic variables with values which will likely
13448transform logic bugs into crashes down the line, are easily recognized in a
13449crash dump and without being values that programmers can rely on for useful
13450program semantics.
13451The current value is byte-repeatable pattern with byte "0xFE".
13452The values used for pattern initialization might be changed in the future.
13453
13454@item
13455@samp{zero} Initialize automatic variables with zeroes.
13456@end itemize
13457
13458The default is @samp{uninitialized}.
13459
13460You can control this behavior for a specific variable by using the variable
13461attribute @code{uninitialized} (@pxref{Variable Attributes}).
13462
d77de738 13463@opindex fvect-cost-model
ddf6fe37 13464@item -fvect-cost-model=@var{model}
d77de738
ML
13465Alter the cost model used for vectorization. The @var{model} argument
13466should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13467@samp{very-cheap}.
13468With the @samp{unlimited} model the vectorized code-path is assumed
13469to be profitable while with the @samp{dynamic} model a runtime check
13470guards the vectorized code-path to enable it only for iteration
13471counts that will likely execute faster than when executing the original
13472scalar loop. The @samp{cheap} model disables vectorization of
13473loops where doing so would be cost prohibitive for example due to
13474required runtime checks for data dependence or alignment but otherwise
13475is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13476allows vectorization if the vector code would entirely replace the
13477scalar code that is being vectorized. For example, if each iteration
13478of a vectorized loop would only be able to handle exactly four iterations
13479of the scalar loop, the @samp{very-cheap} model would only allow
13480vectorization if the scalar iteration count is known to be a multiple
13481of four.
13482
13483The default cost model depends on other optimization flags and is
13484either @samp{dynamic} or @samp{cheap}.
13485
d77de738 13486@opindex fsimd-cost-model
ddf6fe37 13487@item -fsimd-cost-model=@var{model}
d77de738
ML
13488Alter the cost model used for vectorization of loops marked with the OpenMP
13489simd directive. The @var{model} argument should be one of
13490@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13491have the same meaning as described in @option{-fvect-cost-model} and by
13492default a cost model defined with @option{-fvect-cost-model} is used.
13493
d77de738 13494@opindex ftree-vrp
ddf6fe37 13495@item -ftree-vrp
d77de738
ML
13496Perform Value Range Propagation on trees. This is similar to the
13497constant propagation pass, but instead of values, ranges of values are
13498propagated. This allows the optimizers to remove unnecessary range
13499checks like array bound checks and null pointer checks. This is
13500enabled by default at @option{-O2} and higher. Null pointer check
13501elimination is only done if @option{-fdelete-null-pointer-checks} is
13502enabled.
13503
d77de738 13504@opindex fsplit-paths
ddf6fe37 13505@item -fsplit-paths
d77de738
ML
13506Split paths leading to loop backedges. This can improve dead code
13507elimination and common subexpression elimination. This is enabled by
13508default at @option{-O3} and above.
13509
d77de738 13510@opindex fsplit-ivs-in-unroller
ddf6fe37 13511@item -fsplit-ivs-in-unroller
d77de738
ML
13512Enables expression of values of induction variables in later iterations
13513of the unrolled loop using the value in the first iteration. This breaks
13514long dependency chains, thus improving efficiency of the scheduling passes.
13515
13516A combination of @option{-fweb} and CSE is often sufficient to obtain the
13517same effect. However, that is not reliable in cases where the loop body
13518is more complicated than a single basic block. It also does not work at all
13519on some architectures due to restrictions in the CSE pass.
13520
13521This optimization is enabled by default.
13522
d77de738 13523@opindex fvariable-expansion-in-unroller
ddf6fe37 13524@item -fvariable-expansion-in-unroller
d77de738
ML
13525With this option, the compiler creates multiple copies of some
13526local variables when unrolling a loop, which can result in superior code.
13527
13528This optimization is enabled by default for PowerPC targets, but disabled
13529by default otherwise.
13530
d77de738 13531@opindex fpartial-inlining
ddf6fe37 13532@item -fpartial-inlining
d77de738
ML
13533Inline parts of functions. This option has any effect only
13534when inlining itself is turned on by the @option{-finline-functions}
13535or @option{-finline-small-functions} options.
13536
13537Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13538
d77de738 13539@opindex fpredictive-commoning
ddf6fe37 13540@item -fpredictive-commoning
d77de738
ML
13541Perform predictive commoning optimization, i.e., reusing computations
13542(especially memory loads and stores) performed in previous
13543iterations of loops.
13544
13545This option is enabled at level @option{-O3}.
13546It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13547
d77de738 13548@opindex fprefetch-loop-arrays
ddf6fe37 13549@item -fprefetch-loop-arrays
d77de738
ML
13550If supported by the target machine, generate instructions to prefetch
13551memory to improve the performance of loops that access large arrays.
13552
13553This option may generate better or worse code; results are highly
13554dependent on the structure of loops within the source code.
13555
13556Disabled at level @option{-Os}.
13557
d77de738
ML
13558@opindex fno-printf-return-value
13559@opindex fprintf-return-value
ddf6fe37 13560@item -fno-printf-return-value
d77de738
ML
13561Do not substitute constants for known return value of formatted output
13562functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13563@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13564transformation allows GCC to optimize or even eliminate branches based
13565on the known return value of these functions called with arguments that
13566are either constant, or whose values are known to be in a range that
13567makes determining the exact return value possible. For example, when
13568@option{-fprintf-return-value} is in effect, both the branch and the
13569body of the @code{if} statement (but not the call to @code{snprint})
13570can be optimized away when @code{i} is a 32-bit or smaller integer
13571because the return value is guaranteed to be at most 8.
13572
13573@smallexample
13574char buf[9];
13575if (snprintf (buf, "%08x", i) >= sizeof buf)
13576 @dots{}
13577@end smallexample
13578
13579The @option{-fprintf-return-value} option relies on other optimizations
13580and yields best results with @option{-O2} and above. It works in tandem
13581with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13582options. The @option{-fprintf-return-value} option is enabled by default.
13583
d77de738
ML
13584@opindex fno-peephole
13585@opindex fpeephole
13586@opindex fno-peephole2
13587@opindex fpeephole2
ddf6fe37
AA
13588@item -fno-peephole
13589@itemx -fno-peephole2
d77de738
ML
13590Disable any machine-specific peephole optimizations. The difference
13591between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13592are implemented in the compiler; some targets use one, some use the
13593other, a few use both.
13594
13595@option{-fpeephole} is enabled by default.
13596@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13597
d77de738
ML
13598@opindex fno-guess-branch-probability
13599@opindex fguess-branch-probability
ddf6fe37 13600@item -fno-guess-branch-probability
d77de738
ML
13601Do not guess branch probabilities using heuristics.
13602
13603GCC uses heuristics to guess branch probabilities if they are
13604not provided by profiling feedback (@option{-fprofile-arcs}). These
13605heuristics are based on the control flow graph. If some branch probabilities
13606are specified by @code{__builtin_expect}, then the heuristics are
13607used to guess branch probabilities for the rest of the control flow graph,
13608taking the @code{__builtin_expect} info into account. The interactions
13609between the heuristics and @code{__builtin_expect} can be complex, and in
13610some cases, it may be useful to disable the heuristics so that the effects
13611of @code{__builtin_expect} are easier to understand.
13612
13613It is also possible to specify expected probability of the expression
13614with @code{__builtin_expect_with_probability} built-in function.
13615
13616The default is @option{-fguess-branch-probability} at levels
13617@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13618
d77de738 13619@opindex freorder-blocks
ddf6fe37 13620@item -freorder-blocks
d77de738
ML
13621Reorder basic blocks in the compiled function in order to reduce number of
13622taken branches and improve code locality.
13623
13624Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13625
d77de738 13626@opindex freorder-blocks-algorithm
ddf6fe37 13627@item -freorder-blocks-algorithm=@var{algorithm}
d77de738
ML
13628Use the specified algorithm for basic block reordering. The
13629@var{algorithm} argument can be @samp{simple}, which does not increase
13630code size (except sometimes due to secondary effects like alignment),
13631or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13632put all often executed code together, minimizing the number of branches
13633executed by making extra copies of code.
13634
13635The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13636@samp{stc} at levels @option{-O2}, @option{-O3}.
13637
d77de738 13638@opindex freorder-blocks-and-partition
ddf6fe37 13639@item -freorder-blocks-and-partition
d77de738
ML
13640In addition to reordering basic blocks in the compiled function, in order
13641to reduce number of taken branches, partitions hot and cold basic blocks
13642into separate sections of the assembly and @file{.o} files, to improve
13643paging and cache locality performance.
13644
13645This optimization is automatically turned off in the presence of
13646exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13647section attribute and on any architecture that does not support named
13648sections. When @option{-fsplit-stack} is used this option is not
13649enabled by default (to avoid linker errors), but may be enabled
13650explicitly (if using a working linker).
13651
13652Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13653
d77de738 13654@opindex freorder-functions
ddf6fe37 13655@item -freorder-functions
d77de738
ML
13656Reorder functions in the object file in order to
13657improve code locality. This is implemented by using special
13658subsections @code{.text.hot} for most frequently executed functions and
13659@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13660the linker so object file format must support named sections and linker must
13661place them in a reasonable way.
13662
13663This option isn't effective unless you either provide profile feedback
13664(see @option{-fprofile-arcs} for details) or manually annotate functions with
13665@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13666
13667Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13668
d77de738 13669@opindex fstrict-aliasing
ddf6fe37 13670@item -fstrict-aliasing
d77de738
ML
13671Allow the compiler to assume the strictest aliasing rules applicable to
13672the language being compiled. For C (and C++), this activates
13673optimizations based on the type of expressions. In particular, an
13674object of one type is assumed never to reside at the same address as an
13675object of a different type, unless the types are almost the same. For
13676example, an @code{unsigned int} can alias an @code{int}, but not a
13677@code{void*} or a @code{double}. A character type may alias any other
13678type.
13679
13680@anchor{Type-punning}Pay special attention to code like this:
13681@smallexample
13682union a_union @{
13683 int i;
13684 double d;
13685@};
13686
13687int f() @{
13688 union a_union t;
13689 t.d = 3.0;
13690 return t.i;
13691@}
13692@end smallexample
13693The practice of reading from a different union member than the one most
13694recently written to (called ``type-punning'') is common. Even with
13695@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13696is accessed through the union type. So, the code above works as
13697expected. @xref{Structures unions enumerations and bit-fields
13698implementation}. However, this code might not:
13699@smallexample
13700int f() @{
13701 union a_union t;
13702 int* ip;
13703 t.d = 3.0;
13704 ip = &t.i;
13705 return *ip;
13706@}
13707@end smallexample
13708
13709Similarly, access by taking the address, casting the resulting pointer
13710and dereferencing the result has undefined behavior, even if the cast
13711uses a union type, e.g.:
13712@smallexample
13713int f() @{
13714 double d = 3.0;
13715 return ((union a_union *) &d)->i;
13716@}
13717@end smallexample
13718
13719The @option{-fstrict-aliasing} option is enabled at levels
13720@option{-O2}, @option{-O3}, @option{-Os}.
13721
d77de738 13722@opindex fipa-strict-aliasing
ddf6fe37 13723@item -fipa-strict-aliasing
d77de738
ML
13724Controls whether rules of @option{-fstrict-aliasing} are applied across
13725function boundaries. Note that if multiple functions gets inlined into a
13726single function the memory accesses are no longer considered to be crossing a
13727function boundary.
13728
13729The @option{-fipa-strict-aliasing} option is enabled by default and is
13730effective only in combination with @option{-fstrict-aliasing}.
13731
ddf6fe37 13732@opindex falign-functions
d77de738
ML
13733@item -falign-functions
13734@itemx -falign-functions=@var{n}
13735@itemx -falign-functions=@var{n}:@var{m}
13736@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13737@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13738Align the start of functions to the next power-of-two greater than or
13739equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13740least the first @var{m} bytes of the function can be fetched by the CPU
13741without crossing an @var{n}-byte alignment boundary.
13742
13743If @var{m} is not specified, it defaults to @var{n}.
13744
13745Examples: @option{-falign-functions=32} aligns functions to the next
1374632-byte boundary, @option{-falign-functions=24} aligns to the next
1374732-byte boundary only if this can be done by skipping 23 bytes or less,
13748@option{-falign-functions=32:7} aligns to the next
1374932-byte boundary only if this can be done by skipping 6 bytes or less.
13750
13751The second pair of @var{n2}:@var{m2} values allows you to specify
13752a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13753the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13754otherwise aligns to the next 32-byte boundary if this can be done
13755by skipping 2 bytes or less.
13756If @var{m2} is not specified, it defaults to @var{n2}.
13757
13758Some assemblers only support this flag when @var{n} is a power of two;
13759in that case, it is rounded up.
13760
13761@option{-fno-align-functions} and @option{-falign-functions=1} are
13762equivalent and mean that functions are not aligned.
13763
13764If @var{n} is not specified or is zero, use a machine-dependent default.
13765The maximum allowed @var{n} option value is 65536.
13766
13767Enabled at levels @option{-O2}, @option{-O3}.
13768
13769@item -flimit-function-alignment
13770If this option is enabled, the compiler tries to avoid unnecessarily
13771overaligning functions. It attempts to instruct the assembler to align
13772by the amount specified by @option{-falign-functions}, but not to
13773skip more bytes than the size of the function.
13774
ddf6fe37 13775@opindex falign-labels
d77de738
ML
13776@item -falign-labels
13777@itemx -falign-labels=@var{n}
13778@itemx -falign-labels=@var{n}:@var{m}
13779@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13780@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13781Align all branch targets to a power-of-two boundary.
13782
13783Parameters of this option are analogous to the @option{-falign-functions} option.
13784@option{-fno-align-labels} and @option{-falign-labels=1} are
13785equivalent and mean that labels are not aligned.
13786
13787If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13788are greater than this value, then their values are used instead.
13789
13790If @var{n} is not specified or is zero, use a machine-dependent default
13791which is very likely to be @samp{1}, meaning no alignment.
13792The maximum allowed @var{n} option value is 65536.
13793
13794Enabled at levels @option{-O2}, @option{-O3}.
13795
ddf6fe37 13796@opindex falign-loops
d77de738
ML
13797@item -falign-loops
13798@itemx -falign-loops=@var{n}
13799@itemx -falign-loops=@var{n}:@var{m}
13800@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13801@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13802Align loops to a power-of-two boundary. If the loops are executed
13803many times, this makes up for any execution of the dummy padding
13804instructions.
13805
13806If @option{-falign-labels} is greater than this value, then its value
13807is used instead.
13808
13809Parameters of this option are analogous to the @option{-falign-functions} option.
13810@option{-fno-align-loops} and @option{-falign-loops=1} are
13811equivalent and mean that loops are not aligned.
13812The maximum allowed @var{n} option value is 65536.
13813
13814If @var{n} is not specified or is zero, use a machine-dependent default.
13815
13816Enabled at levels @option{-O2}, @option{-O3}.
13817
ddf6fe37 13818@opindex falign-jumps
d77de738
ML
13819@item -falign-jumps
13820@itemx -falign-jumps=@var{n}
13821@itemx -falign-jumps=@var{n}:@var{m}
13822@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13823@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13824Align branch targets to a power-of-two boundary, for branch targets
13825where the targets can only be reached by jumping. In this case,
13826no dummy operations need be executed.
13827
13828If @option{-falign-labels} is greater than this value, then its value
13829is used instead.
13830
13831Parameters of this option are analogous to the @option{-falign-functions} option.
13832@option{-fno-align-jumps} and @option{-falign-jumps=1} are
13833equivalent and mean that loops are not aligned.
13834
13835If @var{n} is not specified or is zero, use a machine-dependent default.
13836The maximum allowed @var{n} option value is 65536.
13837
13838Enabled at levels @option{-O2}, @option{-O3}.
13839
d77de738 13840@opindex fno-allocation-dce
ddf6fe37 13841@item -fno-allocation-dce
d77de738
ML
13842Do not remove unused C++ allocations in dead code elimination.
13843
d77de738 13844@opindex fallow-store-data-races
ddf6fe37 13845@item -fallow-store-data-races
d77de738
ML
13846Allow the compiler to perform optimizations that may introduce new data races
13847on stores, without proving that the variable cannot be concurrently accessed
13848by other threads. Does not affect optimization of local data. It is safe to
13849use this option if it is known that global data will not be accessed by
13850multiple threads.
13851
13852Examples of optimizations enabled by @option{-fallow-store-data-races} include
13853hoisting or if-conversions that may cause a value that was already in memory
13854to be re-written with that same value. Such re-writing is safe in a single
13855threaded context but may be unsafe in a multi-threaded context. Note that on
13856some processors, if-conversions may be required in order to enable
13857vectorization.
13858
13859Enabled at level @option{-Ofast}.
13860
d77de738 13861@opindex funit-at-a-time
ddf6fe37 13862@item -funit-at-a-time
d77de738
ML
13863This option is left for compatibility reasons. @option{-funit-at-a-time}
13864has no effect, while @option{-fno-unit-at-a-time} implies
13865@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
13866
13867Enabled by default.
13868
d77de738
ML
13869@opindex fno-toplevel-reorder
13870@opindex ftoplevel-reorder
ddf6fe37 13871@item -fno-toplevel-reorder
d77de738
ML
13872Do not reorder top-level functions, variables, and @code{asm}
13873statements. Output them in the same order that they appear in the
13874input file. When this option is used, unreferenced static variables
13875are not removed. This option is intended to support existing code
13876that relies on a particular ordering. For new code, it is better to
13877use attributes when possible.
13878
13879@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
13880also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
13881Additionally @option{-fno-toplevel-reorder} implies
13882@option{-fno-section-anchors}.
13883
d77de738 13884@opindex funreachable-traps
ddf6fe37 13885@item -funreachable-traps
d77de738
ML
13886With this option, the compiler turns calls to
13887@code{__builtin_unreachable} into traps, instead of using them for
13888optimization. This also affects any such calls implicitly generated
13889by the compiler.
13890
13891This option has the same effect as @option{-fsanitize=unreachable
13892-fsanitize-trap=unreachable}, but does not affect the values of those
13893options. If @option{-fsanitize=unreachable} is enabled, that option
13894takes priority over this one.
13895
13896This option is enabled by default at @option{-O0} and @option{-Og}.
13897
d77de738 13898@opindex fweb
ddf6fe37 13899@item -fweb
d77de738
ML
13900Constructs webs as commonly used for register allocation purposes and assign
13901each web individual pseudo register. This allows the register allocation pass
13902to operate on pseudos directly, but also strengthens several other optimization
13903passes, such as CSE, loop optimizer and trivial dead code remover. It can,
13904however, make debugging impossible, since variables no longer stay in a
13905``home register''.
13906
13907Enabled by default with @option{-funroll-loops}.
13908
d77de738 13909@opindex fwhole-program
ddf6fe37 13910@item -fwhole-program
d77de738
ML
13911Assume that the current compilation unit represents the whole program being
13912compiled. All public functions and variables with the exception of @code{main}
13913and those merged by attribute @code{externally_visible} become static functions
13914and in effect are optimized more aggressively by interprocedural optimizers.
13915
39ebd3a9
JH
13916With @option{-flto} this option has a limited use. In most cases the
13917precise list of symbols used or exported from the binary is known the
13918resolution info passed to the link-time optimizer by the linker plugin. It is
13919still useful if no linker plugin is used or during incremental link step when
13920final code is produced (with @option{-flto}
13921@option{-flinker-output=nolto-rel}).
d77de738 13922
d77de738 13923@opindex flto
ddf6fe37 13924@item -flto[=@var{n}]
d77de738
ML
13925This option runs the standard link-time optimizer. When invoked
13926with source code, it generates GIMPLE (one of GCC's internal
13927representations) and writes it to special ELF sections in the object
13928file. When the object files are linked together, all the function
13929bodies are read from these ELF sections and instantiated as if they
13930had been part of the same translation unit.
13931
13932To use the link-time optimizer, @option{-flto} and optimization
13933options should be specified at compile time and during the final link.
13934It is recommended that you compile all the files participating in the
13935same link with the same options and also specify those options at
13936link time.
13937For example:
13938
13939@smallexample
13940gcc -c -O2 -flto foo.c
13941gcc -c -O2 -flto bar.c
13942gcc -o myprog -flto -O2 foo.o bar.o
13943@end smallexample
13944
13945The first two invocations to GCC save a bytecode representation
13946of GIMPLE into special ELF sections inside @file{foo.o} and
13947@file{bar.o}. The final invocation reads the GIMPLE bytecode from
13948@file{foo.o} and @file{bar.o}, merges the two files into a single
13949internal image, and compiles the result as usual. Since both
13950@file{foo.o} and @file{bar.o} are merged into a single image, this
13951causes all the interprocedural analyses and optimizations in GCC to
13952work across the two files as if they were a single one. This means,
13953for example, that the inliner is able to inline functions in
13954@file{bar.o} into functions in @file{foo.o} and vice-versa.
13955
13956Another (simpler) way to enable link-time optimization is:
13957
13958@smallexample
13959gcc -o myprog -flto -O2 foo.c bar.c
13960@end smallexample
13961
13962The above generates bytecode for @file{foo.c} and @file{bar.c},
13963merges them together into a single GIMPLE representation and optimizes
13964them as usual to produce @file{myprog}.
13965
13966The important thing to keep in mind is that to enable link-time
13967optimizations you need to use the GCC driver to perform the link step.
13968GCC automatically performs link-time optimization if any of the
13969objects involved were compiled with the @option{-flto} command-line option.
13970You can always override
13971the automatic decision to do link-time optimization
13972by passing @option{-fno-lto} to the link command.
13973
13974To make whole program optimization effective, it is necessary to make
13975certain whole program assumptions. The compiler needs to know
13976what functions and variables can be accessed by libraries and runtime
13977outside of the link-time optimized unit. When supported by the linker,
13978the linker plugin (see @option{-fuse-linker-plugin}) passes information
13979to the compiler about used and externally visible symbols. When
13980the linker plugin is not available, @option{-fwhole-program} should be
13981used to allow the compiler to make these assumptions, which leads
13982to more aggressive optimization decisions.
13983
13984When a file is compiled with @option{-flto} without
13985@option{-fuse-linker-plugin}, the generated object file is larger than
13986a regular object file because it contains GIMPLE bytecodes and the usual
13987final code (see @option{-ffat-lto-objects}). This means that
13988object files with LTO information can be linked as normal object
13989files; if @option{-fno-lto} is passed to the linker, no
13990interprocedural optimizations are applied. Note that when
13991@option{-fno-fat-lto-objects} is enabled the compile stage is faster
13992but you cannot perform a regular, non-LTO link on them.
13993
13994When producing the final binary, GCC only
13995applies link-time optimizations to those files that contain bytecode.
13996Therefore, you can mix and match object files and libraries with
13997GIMPLE bytecodes and final object code. GCC automatically selects
13998which files to optimize in LTO mode and which files to link without
13999further processing.
14000
14001Generally, options specified at link time override those
14002specified at compile time, although in some cases GCC attempts to infer
14003link-time options from the settings used to compile the input files.
14004
14005If you do not specify an optimization level option @option{-O} at
14006link time, then GCC uses the highest optimization level
14007used when compiling the object files. Note that it is generally
14008ineffective to specify an optimization level option only at link time and
14009not at compile time, for two reasons. First, compiling without
14010optimization suppresses compiler passes that gather information
14011needed for effective optimization at link time. Second, some early
14012optimization passes can be performed only at compile time and
14013not at link time.
14014
14015There are some code generation flags preserved by GCC when
14016generating bytecodes, as they need to be used during the final link.
14017Currently, the following options and their settings are taken from
14018the first object file that explicitly specifies them:
14019@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
14020@option{-fgnu-tm} and all the @option{-m} target flags.
14021
14022The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
14023@option{-fPIE} are combined based on the following scheme:
14024
14025@smallexample
14026@option{-fPIC} + @option{-fpic} = @option{-fpic}
14027@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
14028@option{-fpic/-fPIC} + (no option) = (no option)
14029@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
14030@option{-fpic} + @option{-fPIE} = @option{-fpie}
14031@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
14032@end smallexample
14033
14034Certain ABI-changing flags are required to match in all compilation units,
14035and trying to override this at link time with a conflicting value
14036is ignored. This includes options such as @option{-freg-struct-return}
14037and @option{-fpcc-struct-return}.
14038
14039Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
14040@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
14041are passed through to the link stage and merged conservatively for
14042conflicting translation units. Specifically
14043@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
14044precedence; and for example @option{-ffp-contract=off} takes precedence
14045over @option{-ffp-contract=fast}. You can override them at link time.
14046
14047Diagnostic options such as @option{-Wstringop-overflow} are passed
14048through to the link stage and their setting matches that of the
14049compile-step at function granularity. Note that this matters only
14050for diagnostics emitted during optimization. Note that code
14051transforms such as inlining can lead to warnings being enabled
14052or disabled for regions if code not consistent with the setting
14053at compile time.
14054
14055When you need to pass options to the assembler via @option{-Wa} or
14056@option{-Xassembler} make sure to either compile such translation
14057units with @option{-fno-lto} or consistently use the same assembler
14058options on all translation units. You can alternatively also
14059specify assembler options at LTO link time.
14060
14061To enable debug info generation you need to supply @option{-g} at
14062compile time. If any of the input files at link time were built
14063with debug info generation enabled the link will enable debug info
14064generation as well. Any elaborate debug info settings
14065like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
14066at the linker command line and mixing different settings in different
14067translation units is discouraged.
14068
14069If LTO encounters objects with C linkage declared with incompatible
14070types in separate translation units to be linked together (undefined
14071behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
14072issued. The behavior is still undefined at run time. Similar
14073diagnostics may be raised for other languages.
14074
14075Another feature of LTO is that it is possible to apply interprocedural
14076optimizations on files written in different languages:
14077
14078@smallexample
14079gcc -c -flto foo.c
14080g++ -c -flto bar.cc
14081gfortran -c -flto baz.f90
14082g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
14083@end smallexample
14084
14085Notice that the final link is done with @command{g++} to get the C++
14086runtime libraries and @option{-lgfortran} is added to get the Fortran
14087runtime libraries. In general, when mixing languages in LTO mode, you
14088should use the same link command options as when mixing languages in a
14089regular (non-LTO) compilation.
14090
14091If object files containing GIMPLE bytecode are stored in a library archive, say
14092@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
14093are using a linker with plugin support. To create static libraries suitable
14094for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
14095and @command{ranlib};
14096to show the symbols of object files with GIMPLE bytecode, use
14097@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
14098and @command{nm} have been compiled with plugin support. At link time, use the
14099flag @option{-fuse-linker-plugin} to ensure that the library participates in
14100the LTO optimization process:
14101
14102@smallexample
14103gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
14104@end smallexample
14105
14106With the linker plugin enabled, the linker extracts the needed
14107GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
14108to make them part of the aggregated GIMPLE image to be optimized.
14109
14110If you are not using a linker with plugin support and/or do not
14111enable the linker plugin, then the objects inside @file{libfoo.a}
14112are extracted and linked as usual, but they do not participate
14113in the LTO optimization process. In order to make a static library suitable
14114for both LTO optimization and usual linkage, compile its object files with
14115@option{-flto} @option{-ffat-lto-objects}.
14116
14117Link-time optimizations do not require the presence of the whole program to
14118operate. If the program does not require any symbols to be exported, it is
14119possible to combine @option{-flto} and @option{-fwhole-program} to allow
14120the interprocedural optimizers to use more aggressive assumptions which may
14121lead to improved optimization opportunities.
14122Use of @option{-fwhole-program} is not needed when linker plugin is
14123active (see @option{-fuse-linker-plugin}).
14124
14125The current implementation of LTO makes no
14126attempt to generate bytecode that is portable between different
14127types of hosts. The bytecode files are versioned and there is a
14128strict version check, so bytecode files generated in one version of
14129GCC do not work with an older or newer version of GCC.
14130
14131Link-time optimization does not work well with generation of debugging
14132information on systems other than those using a combination of ELF and
14133DWARF.
14134
14135If you specify the optional @var{n}, the optimization and code
14136generation done at link time is executed in parallel using @var{n}
14137parallel jobs by utilizing an installed @command{make} program. The
14138environment variable @env{MAKE} may be used to override the program
14139used.
14140
14141You can also specify @option{-flto=jobserver} to use GNU make's
14142job server mode to determine the number of parallel jobs. This
14143is useful when the Makefile calling GCC is already executing in parallel.
14144You must prepend a @samp{+} to the command recipe in the parent Makefile
14145for this to work. This option likely only works if @env{MAKE} is
14146GNU make. Even without the option value, GCC tries to automatically
14147detect a running GNU make's job server.
14148
14149Use @option{-flto=auto} to use GNU make's job server, if available,
14150or otherwise fall back to autodetection of the number of CPU threads
14151present in your system.
14152
d77de738 14153@opindex flto-partition
ddf6fe37 14154@item -flto-partition=@var{alg}
d77de738
ML
14155Specify the partitioning algorithm used by the link-time optimizer.
14156The value is either @samp{1to1} to specify a partitioning mirroring
14157the original source files or @samp{balanced} to specify partitioning
14158into equally sized chunks (whenever possible) or @samp{max} to create
14159new partition for every symbol where possible. Specifying @samp{none}
14160as an algorithm disables partitioning and streaming completely.
14161The default value is @samp{balanced}. While @samp{1to1} can be used
14162as an workaround for various code ordering issues, the @samp{max}
14163partitioning is intended for internal testing only.
14164The value @samp{one} specifies that exactly one partition should be
14165used while the value @samp{none} bypasses partitioning and executes
14166the link-time optimization step directly from the WPA phase.
14167
d77de738 14168@opindex flto-compression-level
ddf6fe37 14169@item -flto-compression-level=@var{n}
d77de738
ML
14170This option specifies the level of compression used for intermediate
14171language written to LTO object files, and is only meaningful in
14172conjunction with LTO mode (@option{-flto}). GCC currently supports two
14173LTO compression algorithms. For zstd, valid values are 0 (no compression)
14174to 19 (maximum compression), while zlib supports values from 0 to 9.
14175Values outside this range are clamped to either minimum or maximum
14176of the supported values. If the option is not given,
14177a default balanced compression setting is used.
14178
d77de738 14179@opindex fuse-linker-plugin
ddf6fe37 14180@item -fuse-linker-plugin
d77de738
ML
14181Enables the use of a linker plugin during link-time optimization. This
14182option relies on plugin support in the linker, which is available in gold
14183or in GNU ld 2.21 or newer.
14184
14185This option enables the extraction of object files with GIMPLE bytecode out
14186of library archives. This improves the quality of optimization by exposing
14187more code to the link-time optimizer. This information specifies what
14188symbols can be accessed externally (by non-LTO object or during dynamic
14189linking). Resulting code quality improvements on binaries (and shared
14190libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14191See @option{-flto} for a description of the effect of this flag and how to
14192use it.
14193
14194This option is enabled by default when LTO support in GCC is enabled
14195and GCC was configured for use with
14196a linker supporting plugins (GNU ld 2.21 or newer or gold).
14197
d77de738 14198@opindex ffat-lto-objects
ddf6fe37 14199@item -ffat-lto-objects
d77de738
ML
14200Fat LTO objects are object files that contain both the intermediate language
14201and the object code. This makes them usable for both LTO linking and normal
14202linking. This option is effective only when compiling with @option{-flto}
14203and is ignored at link time.
14204
14205@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14206requires the complete toolchain to be aware of LTO. It requires a linker with
14207linker plugin support for basic functionality. Additionally,
14208@command{nm}, @command{ar} and @command{ranlib}
14209need to support linker plugins to allow a full-featured build environment
14210(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14211@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14212to these tools. With non fat LTO makefiles need to be modified to use them.
14213
14214Note that modern binutils provide plugin auto-load mechanism.
14215Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14216effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14217@command{gcc-ranlib}).
14218
14219The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14220support.
14221
d77de738 14222@opindex fcompare-elim
ddf6fe37 14223@item -fcompare-elim
d77de738
ML
14224After register allocation and post-register allocation instruction splitting,
14225identify arithmetic instructions that compute processor flags similar to a
14226comparison operation based on that arithmetic. If possible, eliminate the
14227explicit comparison operation.
14228
14229This pass only applies to certain targets that cannot explicitly represent
14230the comparison operation before register allocation is complete.
14231
14232Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14233
d77de738 14234@opindex fcprop-registers
ddf6fe37 14235@item -fcprop-registers
d77de738
ML
14236After register allocation and post-register allocation instruction splitting,
14237perform a copy-propagation pass to try to reduce scheduling dependencies
14238and occasionally eliminate the copy.
14239
14240Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14241
d77de738 14242@opindex fprofile-correction
ddf6fe37 14243@item -fprofile-correction
d77de738
ML
14244Profiles collected using an instrumented binary for multi-threaded programs may
14245be inconsistent due to missed counter updates. When this option is specified,
14246GCC uses heuristics to correct or smooth out such inconsistencies. By
14247default, GCC emits an error message when an inconsistent profile is detected.
14248
14249This option is enabled by @option{-fauto-profile}.
14250
d77de738 14251@opindex fprofile-partial-training
ddf6fe37 14252@item -fprofile-partial-training
d77de738
ML
14253With @code{-fprofile-use} all portions of programs not executed during train
14254run are optimized agressively for size rather than speed. In some cases it is
14255not practical to train all possible hot paths in the program. (For
14256example, program may contain functions specific for a given hardware and
14257trianing may not cover all hardware configurations program is run on.) With
14258@code{-fprofile-partial-training} profile feedback will be ignored for all
14259functions not executed during the train run leading them to be optimized as if
14260they were compiled without profile feedback. This leads to better performance
14261when train run is not representative but also leads to significantly bigger
14262code.
14263
ddf6fe37 14264@opindex fprofile-use
d77de738
ML
14265@item -fprofile-use
14266@itemx -fprofile-use=@var{path}
d77de738
ML
14267Enable profile feedback-directed optimizations,
14268and the following optimizations, many of which
14269are generally profitable only with profile feedback available:
14270
43b72ede
AA
14271@gccoptlist{-fbranch-probabilities -fprofile-values
14272-funroll-loops -fpeel-loops -ftracer -fvpt
14273-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14274-fpredictive-commoning -fsplit-loops -funswitch-loops
14275-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14276-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14277-fprofile-reorder-functions}
14278
14279Before you can use this option, you must first generate profiling information.
14280@xref{Instrumentation Options}, for information about the
14281@option{-fprofile-generate} option.
14282
14283By default, GCC emits an error message if the feedback profiles do not
14284match the source code. This error can be turned into a warning by using
14285@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14286optimized code. Additionally, by default, GCC also emits a warning message if
14287the feedback profiles do not exist (see @option{-Wmissing-profile}).
14288
14289If @var{path} is specified, GCC looks at the @var{path} to find
14290the profile feedback data files. See @option{-fprofile-dir}.
14291
ddf6fe37 14292@opindex fauto-profile
d77de738
ML
14293@item -fauto-profile
14294@itemx -fauto-profile=@var{path}
d77de738
ML
14295Enable sampling-based feedback-directed optimizations,
14296and the following optimizations,
14297many of which are generally profitable only with profile feedback available:
14298
43b72ede
AA
14299@gccoptlist{-fbranch-probabilities -fprofile-values
14300-funroll-loops -fpeel-loops -ftracer -fvpt
14301-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14302-fpredictive-commoning -fsplit-loops -funswitch-loops
14303-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14304-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14305-fprofile-correction}
14306
14307@var{path} is the name of a file containing AutoFDO profile information.
14308If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14309
14310Producing an AutoFDO profile data file requires running your program
14311with the @command{perf} utility on a supported GNU/Linux target system.
14312For more information, see @uref{https://perf.wiki.kernel.org/}.
14313
14314E.g.
14315@smallexample
14316perf record -e br_inst_retired:near_taken -b -o perf.data \
14317 -- your_program
14318@end smallexample
14319
14320Then use the @command{create_gcov} tool to convert the raw profile data
14321to a format that can be used by GCC.@ You must also supply the
14322unstripped binary for your program to this tool.
14323See @uref{https://github.com/google/autofdo}.
14324
14325E.g.
14326@smallexample
14327create_gcov --binary=your_program.unstripped --profile=perf.data \
14328 --gcov=profile.afdo
14329@end smallexample
14330@end table
14331
14332The following options control compiler behavior regarding floating-point
14333arithmetic. These options trade off between speed and
14334correctness. All must be specifically enabled.
14335
14336@table @gcctabopt
d77de738 14337@opindex ffloat-store
ddf6fe37 14338@item -ffloat-store
d77de738
ML
14339Do not store floating-point variables in registers, and inhibit other
14340options that might change whether a floating-point value is taken from a
14341register or memory.
14342
14343@cindex floating-point precision
14344This option prevents undesirable excess precision on machines such as
14345the 68000 where the floating registers (of the 68881) keep more
14346precision than a @code{double} is supposed to have. Similarly for the
14347x86 architecture. For most programs, the excess precision does only
14348good, but a few programs rely on the precise definition of IEEE floating
14349point. Use @option{-ffloat-store} for such programs, after modifying
14350them to store all pertinent intermediate computations into variables.
14351
d77de738 14352@opindex fexcess-precision
ddf6fe37 14353@item -fexcess-precision=@var{style}
d77de738
ML
14354This option allows further control over excess precision on machines
14355where floating-point operations occur in a format with more precision or
14356range than the IEEE standard and interchange floating-point types. By
14357default, @option{-fexcess-precision=fast} is in effect; this means that
14358operations may be carried out in a wider precision than the types specified
14359in the source if that would result in faster code, and it is unpredictable
14360when rounding to the types specified in the source code takes place.
14361When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14362then excess precision follows the rules specified in ISO C99 or C++; in particular,
14363both casts and assignments cause values to be rounded to their
14364semantic types (whereas @option{-ffloat-store} only affects
14365assignments). This option is enabled by default for C or C++ if a strict
14366conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14367@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14368regardless of whether a strict conformance option is used.
14369
14370@opindex mfpmath
14371@option{-fexcess-precision=standard} is not implemented for languages
14372other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14373or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14374semantics apply without excess precision, and in the latter, rounding
14375is unpredictable.
14376
d77de738 14377@opindex ffast-math
ddf6fe37 14378@item -ffast-math
d77de738
ML
14379Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14380@option{-ffinite-math-only}, @option{-fno-rounding-math},
14381@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14382@option{-fexcess-precision=fast}.
14383
14384This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14385
14386This option is not turned on by any @option{-O} option besides
14387@option{-Ofast} since it can result in incorrect output for programs
14388that depend on an exact implementation of IEEE or ISO rules/specifications
14389for math functions. It may, however, yield faster code for programs
14390that do not require the guarantees of these specifications.
14391
d77de738
ML
14392@opindex fno-math-errno
14393@opindex fmath-errno
ddf6fe37 14394@item -fno-math-errno
d77de738
ML
14395Do not set @code{errno} after calling math functions that are executed
14396with a single instruction, e.g., @code{sqrt}. A program that relies on
14397IEEE exceptions for math error handling may want to use this flag
14398for speed while maintaining IEEE arithmetic compatibility.
14399
14400This option is not turned on by any @option{-O} option since
14401it can result in incorrect output for programs that depend on
14402an exact implementation of IEEE or ISO rules/specifications for
14403math functions. It may, however, yield faster code for programs
14404that do not require the guarantees of these specifications.
14405
14406The default is @option{-fmath-errno}.
14407
14408On Darwin systems, the math library never sets @code{errno}. There is
14409therefore no reason for the compiler to consider the possibility that
14410it might, and @option{-fno-math-errno} is the default.
14411
d77de738 14412@opindex funsafe-math-optimizations
ddf6fe37 14413@item -funsafe-math-optimizations
d77de738
ML
14414
14415Allow optimizations for floating-point arithmetic that (a) assume
14416that arguments and results are valid and (b) may violate IEEE or
14417ANSI standards. When used at link time, it may include libraries
14418or startup files that change the default FPU control word or other
14419similar optimizations.
14420
14421This option is not turned on by any @option{-O} option since
14422it can result in incorrect output for programs that depend on
14423an exact implementation of IEEE or ISO rules/specifications for
14424math functions. It may, however, yield faster code for programs
14425that do not require the guarantees of these specifications.
14426Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14427@option{-fassociative-math} and @option{-freciprocal-math}.
14428
14429The default is @option{-fno-unsafe-math-optimizations}.
14430
d77de738 14431@opindex fassociative-math
ddf6fe37 14432@item -fassociative-math
d77de738
ML
14433
14434Allow re-association of operands in series of floating-point operations.
14435This violates the ISO C and C++ language standard by possibly changing
14436computation result. NOTE: re-ordering may change the sign of zero as
14437well as ignore NaNs and inhibit or create underflow or overflow (and
14438thus cannot be used on code that relies on rounding behavior like
14439@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14440and thus may not be used when ordered comparisons are required.
14441This option requires that both @option{-fno-signed-zeros} and
14442@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14443much sense with @option{-frounding-math}. For Fortran the option
14444is automatically enabled when both @option{-fno-signed-zeros} and
14445@option{-fno-trapping-math} are in effect.
14446
14447The default is @option{-fno-associative-math}.
14448
d77de738 14449@opindex freciprocal-math
ddf6fe37 14450@item -freciprocal-math
d77de738
ML
14451
14452Allow the reciprocal of a value to be used instead of dividing by
14453the value if this enables optimizations. For example @code{x / y}
14454can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14455is subject to common subexpression elimination. Note that this loses
14456precision and increases the number of flops operating on the value.
14457
14458The default is @option{-fno-reciprocal-math}.
14459
d77de738 14460@opindex ffinite-math-only
ddf6fe37 14461@item -ffinite-math-only
d77de738
ML
14462Allow optimizations for floating-point arithmetic that assume
14463that arguments and results are not NaNs or +-Infs.
14464
14465This option is not turned on by any @option{-O} option since
14466it can result in incorrect output for programs that depend on
14467an exact implementation of IEEE or ISO rules/specifications for
14468math functions. It may, however, yield faster code for programs
14469that do not require the guarantees of these specifications.
14470
14471The default is @option{-fno-finite-math-only}.
14472
d77de738
ML
14473@opindex fno-signed-zeros
14474@opindex fsigned-zeros
ddf6fe37 14475@item -fno-signed-zeros
d77de738
ML
14476Allow optimizations for floating-point arithmetic that ignore the
14477signedness of zero. IEEE arithmetic specifies the behavior of
14478distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14479of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14480This option implies that the sign of a zero result isn't significant.
14481
14482The default is @option{-fsigned-zeros}.
14483
d77de738
ML
14484@opindex fno-trapping-math
14485@opindex ftrapping-math
ddf6fe37 14486@item -fno-trapping-math
d77de738
ML
14487Compile code assuming that floating-point operations cannot generate
14488user-visible traps. These traps include division by zero, overflow,
14489underflow, inexact result and invalid operation. This option requires
14490that @option{-fno-signaling-nans} be in effect. Setting this option may
14491allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14492
14493This option should never be turned on by any @option{-O} option since
14494it can result in incorrect output for programs that depend on
14495an exact implementation of IEEE or ISO rules/specifications for
14496math functions.
14497
14498The default is @option{-ftrapping-math}.
14499
14500Future versions of GCC may provide finer control of this setting
14501using C99's @code{FENV_ACCESS} pragma. This command-line option
14502will be used along with @option{-frounding-math} to specify the
14503default state for @code{FENV_ACCESS}.
14504
d77de738 14505@opindex frounding-math
ddf6fe37 14506@item -frounding-math
d77de738
ML
14507Disable transformations and optimizations that assume default floating-point
14508rounding behavior. This is round-to-zero for all floating point
14509to integer conversions, and round-to-nearest for all other arithmetic
14510truncations. This option should be specified for programs that change
14511the FP rounding mode dynamically, or that may be executed with a
14512non-default rounding mode. This option disables constant folding of
14513floating-point expressions at compile time (which may be affected by
14514rounding mode) and arithmetic transformations that are unsafe in the
14515presence of sign-dependent rounding modes.
14516
14517The default is @option{-fno-rounding-math}.
14518
14519This option is experimental and does not currently guarantee to
14520disable all GCC optimizations that are affected by rounding mode.
14521Future versions of GCC may provide finer control of this setting
14522using C99's @code{FENV_ACCESS} pragma. This command-line option
14523will be used along with @option{-ftrapping-math} to specify the
14524default state for @code{FENV_ACCESS}.
14525
d77de738 14526@opindex fsignaling-nans
ddf6fe37 14527@item -fsignaling-nans
d77de738
ML
14528Compile code assuming that IEEE signaling NaNs may generate user-visible
14529traps during floating-point operations. Setting this option disables
14530optimizations that may change the number of exceptions visible with
14531signaling NaNs. This option implies @option{-ftrapping-math}.
14532
14533This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14534be defined.
14535
14536The default is @option{-fno-signaling-nans}.
14537
14538This option is experimental and does not currently guarantee to
14539disable all GCC optimizations that affect signaling NaN behavior.
14540
d77de738
ML
14541@opindex fno-fp-int-builtin-inexact
14542@opindex ffp-int-builtin-inexact
ddf6fe37 14543@item -fno-fp-int-builtin-inexact
d77de738
ML
14544Do not allow the built-in functions @code{ceil}, @code{floor},
14545@code{round} and @code{trunc}, and their @code{float} and @code{long
14546double} variants, to generate code that raises the ``inexact''
14547floating-point exception for noninteger arguments. ISO C99 and C11
14548allow these functions to raise the ``inexact'' exception, but ISO/IEC
14549TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14550ISO C2X, does not allow these functions to do so.
14551
14552The default is @option{-ffp-int-builtin-inexact}, allowing the
14553exception to be raised, unless C2X or a later C standard is selected.
14554This option does nothing unless @option{-ftrapping-math} is in effect.
14555
14556Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14557generate a call to a library function then the ``inexact'' exception
14558may be raised if the library implementation does not follow TS 18661.
14559
d77de738 14560@opindex fsingle-precision-constant
ddf6fe37 14561@item -fsingle-precision-constant
d77de738
ML
14562Treat floating-point constants as single precision instead of
14563implicitly converting them to double-precision constants.
14564
d77de738 14565@opindex fcx-limited-range
ddf6fe37 14566@item -fcx-limited-range
d77de738
ML
14567When enabled, this option states that a range reduction step is not
14568needed when performing complex division. Also, there is no checking
14569whether the result of a complex multiplication or division is @code{NaN
14570+ I*NaN}, with an attempt to rescue the situation in that case. The
14571default is @option{-fno-cx-limited-range}, but is enabled by
14572@option{-ffast-math}.
14573
14574This option controls the default setting of the ISO C99
14575@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14576all languages.
14577
d77de738 14578@opindex fcx-fortran-rules
ddf6fe37 14579@item -fcx-fortran-rules
d77de738
ML
14580Complex multiplication and division follow Fortran rules. Range
14581reduction is done as part of complex division, but there is no checking
14582whether the result of a complex multiplication or division is @code{NaN
14583+ I*NaN}, with an attempt to rescue the situation in that case.
14584
14585The default is @option{-fno-cx-fortran-rules}.
14586
14587@end table
14588
14589The following options control optimizations that may improve
14590performance, but are not enabled by any @option{-O} options. This
14591section includes experimental options that may produce broken code.
14592
14593@table @gcctabopt
d77de738 14594@opindex fbranch-probabilities
ddf6fe37 14595@item -fbranch-probabilities
d77de738
ML
14596After running a program compiled with @option{-fprofile-arcs}
14597(@pxref{Instrumentation Options}),
14598you can compile it a second time using
14599@option{-fbranch-probabilities}, to improve optimizations based on
14600the number of times each branch was taken. When a program
14601compiled with @option{-fprofile-arcs} exits, it saves arc execution
14602counts to a file called @file{@var{sourcename}.gcda} for each source
14603file. The information in this data file is very dependent on the
14604structure of the generated code, so you must use the same source code
14605and the same optimization options for both compilations.
14606See details about the file naming in @option{-fprofile-arcs}.
14607
14608With @option{-fbranch-probabilities}, GCC puts a
14609@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14610These can be used to improve optimization. Currently, they are only
14611used in one place: in @file{reorg.cc}, instead of guessing which path a
14612branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14613exactly determine which path is taken more often.
14614
14615Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14616
d77de738 14617@opindex fprofile-values
ddf6fe37 14618@item -fprofile-values
d77de738
ML
14619If combined with @option{-fprofile-arcs}, it adds code so that some
14620data about values of expressions in the program is gathered.
14621
14622With @option{-fbranch-probabilities}, it reads back the data gathered
14623from profiling values of expressions for usage in optimizations.
14624
14625Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14626@option{-fauto-profile}.
14627
d77de738 14628@opindex fprofile-reorder-functions
ddf6fe37 14629@item -fprofile-reorder-functions
d77de738
ML
14630Function reordering based on profile instrumentation collects
14631first time of execution of a function and orders these functions
14632in ascending order.
14633
14634Enabled with @option{-fprofile-use}.
14635
d77de738 14636@opindex fvpt
ddf6fe37 14637@item -fvpt
d77de738
ML
14638If combined with @option{-fprofile-arcs}, this option instructs the compiler
14639to add code to gather information about values of expressions.
14640
14641With @option{-fbranch-probabilities}, it reads back the data gathered
14642and actually performs the optimizations based on them.
14643Currently the optimizations include specialization of division operations
14644using the knowledge about the value of the denominator.
14645
14646Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14647
d77de738 14648@opindex frename-registers
ddf6fe37 14649@item -frename-registers
d77de738
ML
14650Attempt to avoid false dependencies in scheduled code by making use
14651of registers left over after register allocation. This optimization
14652most benefits processors with lots of registers. Depending on the
14653debug information format adopted by the target, however, it can
14654make debugging impossible, since variables no longer stay in
14655a ``home register''.
14656
14657Enabled by default with @option{-funroll-loops}.
14658
d77de738 14659@opindex fschedule-fusion
ddf6fe37 14660@item -fschedule-fusion
d77de738
ML
14661Performs a target dependent pass over the instruction stream to schedule
14662instructions of same type together because target machine can execute them
14663more efficiently if they are adjacent to each other in the instruction flow.
14664
14665Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14666
d77de738 14667@opindex ftracer
ddf6fe37 14668@item -ftracer
d77de738
ML
14669Perform tail duplication to enlarge superblock size. This transformation
14670simplifies the control flow of the function allowing other optimizations to do
14671a better job.
14672
14673Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14674
d77de738 14675@opindex funroll-loops
ddf6fe37 14676@item -funroll-loops
d77de738
ML
14677Unroll loops whose number of iterations can be determined at compile time or
14678upon entry to the loop. @option{-funroll-loops} implies
14679@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14680It also turns on complete loop peeling (i.e.@: complete removal of loops with
14681a small constant number of iterations). This option makes code larger, and may
14682or may not make it run faster.
14683
14684Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14685
d77de738 14686@opindex funroll-all-loops
ddf6fe37 14687@item -funroll-all-loops
d77de738
ML
14688Unroll all loops, even if their number of iterations is uncertain when
14689the loop is entered. This usually makes programs run more slowly.
14690@option{-funroll-all-loops} implies the same options as
14691@option{-funroll-loops}.
14692
d77de738 14693@opindex fpeel-loops
ddf6fe37 14694@item -fpeel-loops
d77de738
ML
14695Peels loops for which there is enough information that they do not
14696roll much (from profile feedback or static analysis). It also turns on
14697complete loop peeling (i.e.@: complete removal of loops with small constant
14698number of iterations).
14699
14700Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14701
d77de738 14702@opindex fmove-loop-invariants
ddf6fe37 14703@item -fmove-loop-invariants
d77de738
ML
14704Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14705at level @option{-O1} and higher, except for @option{-Og}.
14706
d77de738 14707@opindex fmove-loop-stores
ddf6fe37 14708@item -fmove-loop-stores
d77de738
ML
14709Enables the loop store motion pass in the GIMPLE loop optimizer. This
14710moves invariant stores to after the end of the loop in exchange for
14711carrying the stored value in a register across the iteration.
14712Note for this option to have an effect @option{-ftree-loop-im} has to
14713be enabled as well. Enabled at level @option{-O1} and higher, except
14714for @option{-Og}.
14715
d77de738 14716@opindex fsplit-loops
ddf6fe37 14717@item -fsplit-loops
d77de738
ML
14718Split a loop into two if it contains a condition that's always true
14719for one side of the iteration space and false for the other.
14720
14721Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14722
d77de738 14723@opindex funswitch-loops
ddf6fe37 14724@item -funswitch-loops
d77de738
ML
14725Move branches with loop invariant conditions out of the loop, with duplicates
14726of the loop on both branches (modified according to result of the condition).
14727
14728Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14729
d77de738 14730@opindex fversion-loops-for-strides
ddf6fe37 14731@item -fversion-loops-for-strides
d77de738
ML
14732If a loop iterates over an array with a variable stride, create another
14733version of the loop that assumes the stride is always one. For example:
14734
14735@smallexample
14736for (int i = 0; i < n; ++i)
14737 x[i * stride] = @dots{};
14738@end smallexample
14739
14740becomes:
14741
14742@smallexample
14743if (stride == 1)
14744 for (int i = 0; i < n; ++i)
14745 x[i] = @dots{};
14746else
14747 for (int i = 0; i < n; ++i)
14748 x[i * stride] = @dots{};
14749@end smallexample
14750
14751This is particularly useful for assumed-shape arrays in Fortran where
14752(for example) it allows better vectorization assuming contiguous accesses.
14753This flag is enabled by default at @option{-O3}.
14754It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14755
d77de738
ML
14756@opindex ffunction-sections
14757@opindex fdata-sections
ddf6fe37
AA
14758@item -ffunction-sections
14759@itemx -fdata-sections
d77de738
ML
14760Place each function or data item into its own section in the output
14761file if the target supports arbitrary sections. The name of the
14762function or the name of the data item determines the section's name
14763in the output file.
14764
14765Use these options on systems where the linker can perform optimizations to
14766improve locality of reference in the instruction space. Most systems using the
14767ELF object format have linkers with such optimizations. On AIX, the linker
14768rearranges sections (CSECTs) based on the call graph. The performance impact
14769varies.
14770
14771Together with a linker garbage collection (linker @option{--gc-sections}
14772option) these options may lead to smaller statically-linked executables (after
14773stripping).
14774
14775On ELF/DWARF systems these options do not degenerate the quality of the debug
14776information. There could be issues with other object files/debug info formats.
14777
14778Only use these options when there are significant benefits from doing so. When
14779you specify these options, the assembler and linker create larger object and
14780executable files and are also slower. These options affect code generation.
14781They prevent optimizations by the compiler and assembler using relative
14782locations inside a translation unit since the locations are unknown until
14783link time. An example of such an optimization is relaxing calls to short call
14784instructions.
14785
d77de738 14786@opindex fstdarg-opt
ddf6fe37 14787@item -fstdarg-opt
d77de738
ML
14788Optimize the prologue of variadic argument functions with respect to usage of
14789those arguments.
14790
d77de738 14791@opindex fsection-anchors
ddf6fe37 14792@item -fsection-anchors
d77de738
ML
14793Try to reduce the number of symbolic address calculations by using
14794shared ``anchor'' symbols to address nearby objects. This transformation
14795can help to reduce the number of GOT entries and GOT accesses on some
14796targets.
14797
14798For example, the implementation of the following function @code{foo}:
14799
14800@smallexample
14801static int a, b, c;
14802int foo (void) @{ return a + b + c; @}
14803@end smallexample
14804
14805@noindent
14806usually calculates the addresses of all three variables, but if you
14807compile it with @option{-fsection-anchors}, it accesses the variables
14808from a common anchor point instead. The effect is similar to the
14809following pseudocode (which isn't valid C):
14810
14811@smallexample
14812int foo (void)
14813@{
14814 register int *xr = &x;
14815 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14816@}
14817@end smallexample
14818
14819Not all targets support this option.
14820
d77de738 14821@opindex fzero-call-used-regs
ddf6fe37 14822@item -fzero-call-used-regs=@var{choice}
d77de738
ML
14823Zero call-used registers at function return to increase program
14824security by either mitigating Return-Oriented Programming (ROP)
14825attacks or preventing information leakage through registers.
14826
14827The possible values of @var{choice} are the same as for the
14828@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
14829The default is @samp{skip}.
14830
14831You can control this behavior for a specific function by using the function
14832attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
14833
d77de738 14834@opindex param
ddf6fe37 14835@item --param @var{name}=@var{value}
d77de738
ML
14836In some places, GCC uses various constants to control the amount of
14837optimization that is done. For example, GCC does not inline functions
14838that contain more than a certain number of instructions. You can
14839control some of these constants on the command line using the
14840@option{--param} option.
14841
14842The names of specific parameters, and the meaning of the values, are
14843tied to the internals of the compiler, and are subject to change
14844without notice in future releases.
14845
c381327d
GP
14846In order to get the minimal, maximal and default values of a parameter,
14847use the @option{--help=param -Q} options.
d77de738
ML
14848
14849In each case, the @var{value} is an integer. The following choices
14850of @var{name} are recognized for all targets:
14851
14852@table @gcctabopt
14853@item predictable-branch-outcome
14854When branch is predicted to be taken with probability lower than this threshold
14855(in percent), then it is considered well predictable.
14856
14857@item max-rtl-if-conversion-insns
14858RTL if-conversion tries to remove conditional branches around a block and
14859replace them with conditionally executed instructions. This parameter
14860gives the maximum number of instructions in a block which should be
14861considered for if-conversion. The compiler will
14862also use other heuristics to decide whether if-conversion is likely to be
14863profitable.
14864
14865@item max-rtl-if-conversion-predictable-cost
14866RTL if-conversion will try to remove conditional branches around a block
14867and replace them with conditionally executed instructions. These parameters
14868give the maximum permissible cost for the sequence that would be generated
14869by if-conversion depending on whether the branch is statically determined
14870to be predictable or not. The units for this parameter are the same as
14871those for the GCC internal seq_cost metric. The compiler will try to
14872provide a reasonable default for this parameter using the BRANCH_COST
14873target macro.
14874
14875@item max-crossjump-edges
14876The maximum number of incoming edges to consider for cross-jumping.
14877The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
14878the number of edges incoming to each block. Increasing values mean
14879more aggressive optimization, making the compilation time increase with
14880probably small improvement in executable size.
14881
14882@item min-crossjump-insns
14883The minimum number of instructions that must be matched at the end
14884of two blocks before cross-jumping is performed on them. This
14885value is ignored in the case where all instructions in the block being
14886cross-jumped from are matched.
14887
14888@item max-grow-copy-bb-insns
14889The maximum code size expansion factor when copying basic blocks
14890instead of jumping. The expansion is relative to a jump instruction.
14891
14892@item max-goto-duplication-insns
14893The maximum number of instructions to duplicate to a block that jumps
14894to a computed goto. To avoid @math{O(N^2)} behavior in a number of
14895passes, GCC factors computed gotos early in the compilation process,
14896and unfactors them as late as possible. Only computed jumps at the
14897end of a basic blocks with no more than max-goto-duplication-insns are
14898unfactored.
14899
14900@item max-delay-slot-insn-search
14901The maximum number of instructions to consider when looking for an
14902instruction to fill a delay slot. If more than this arbitrary number of
14903instructions are searched, the time savings from filling the delay slot
14904are minimal, so stop searching. Increasing values mean more
14905aggressive optimization, making the compilation time increase with probably
14906small improvement in execution time.
14907
14908@item max-delay-slot-live-search
14909When trying to fill delay slots, the maximum number of instructions to
14910consider when searching for a block with valid live register
14911information. Increasing this arbitrarily chosen value means more
14912aggressive optimization, increasing the compilation time. This parameter
14913should be removed when the delay slot code is rewritten to maintain the
14914control-flow graph.
14915
14916@item max-gcse-memory
14917The approximate maximum amount of memory in @code{kB} that can be allocated in
14918order to perform the global common subexpression elimination
14919optimization. If more memory than specified is required, the
14920optimization is not done.
14921
14922@item max-gcse-insertion-ratio
14923If the ratio of expression insertions to deletions is larger than this value
14924for any expression, then RTL PRE inserts or removes the expression and thus
14925leaves partially redundant computations in the instruction stream.
14926
14927@item max-pending-list-length
14928The maximum number of pending dependencies scheduling allows
14929before flushing the current state and starting over. Large functions
14930with few branches or calls can create excessively large lists which
14931needlessly consume memory and resources.
14932
14933@item max-modulo-backtrack-attempts
14934The maximum number of backtrack attempts the scheduler should make
14935when modulo scheduling a loop. Larger values can exponentially increase
14936compilation time.
14937
14938@item max-inline-functions-called-once-loop-depth
14939Maximal loop depth of a call considered by inline heuristics that tries to
14940inline all functions called once.
14941
14942@item max-inline-functions-called-once-insns
14943Maximal estimated size of functions produced while inlining functions called
14944once.
14945
14946@item max-inline-insns-single
14947Several parameters control the tree inliner used in GCC@. This number sets the
14948maximum number of instructions (counted in GCC's internal representation) in a
14949single function that the tree inliner considers for inlining. This only
14950affects functions declared inline and methods implemented in a class
14951declaration (C++).
14952
14953
14954@item max-inline-insns-auto
14955When you use @option{-finline-functions} (included in @option{-O3}),
14956a lot of functions that would otherwise not be considered for inlining
14957by the compiler are investigated. To those functions, a different
14958(more restrictive) limit compared to functions declared inline can
14959be applied (@option{--param max-inline-insns-auto}).
14960
14961@item max-inline-insns-small
14962This is bound applied to calls which are considered relevant with
14963@option{-finline-small-functions}.
14964
14965@item max-inline-insns-size
14966This is bound applied to calls which are optimized for size. Small growth
14967may be desirable to anticipate optimization oppurtunities exposed by inlining.
14968
14969@item uninlined-function-insns
14970Number of instructions accounted by inliner for function overhead such as
14971function prologue and epilogue.
14972
14973@item uninlined-function-time
14974Extra time accounted by inliner for function overhead such as time needed to
14975execute function prologue and epilogue.
14976
14977@item inline-heuristics-hint-percent
14978The scale (in percents) applied to @option{inline-insns-single},
14979@option{inline-insns-single-O2}, @option{inline-insns-auto}
14980when inline heuristics hints that inlining is
14981very profitable (will enable later optimizations).
14982
14983@item uninlined-thunk-insns
14984@item uninlined-thunk-time
14985Same as @option{--param uninlined-function-insns} and
14986@option{--param uninlined-function-time} but applied to function thunks.
14987
14988@item inline-min-speedup
14989When estimated performance improvement of caller + callee runtime exceeds this
14990threshold (in percent), the function can be inlined regardless of the limit on
14991@option{--param max-inline-insns-single} and @option{--param
14992max-inline-insns-auto}.
14993
14994@item large-function-insns
14995The limit specifying really large functions. For functions larger than this
14996limit after inlining, inlining is constrained by
14997@option{--param large-function-growth}. This parameter is useful primarily
14998to avoid extreme compilation time caused by non-linear algorithms used by the
14999back end.
15000
15001@item large-function-growth
15002Specifies maximal growth of large function caused by inlining in percents.
15003For example, parameter value 100 limits large function growth to 2.0 times
15004the original size.
15005
15006@item large-unit-insns
15007The limit specifying large translation unit. Growth caused by inlining of
15008units larger than this limit is limited by @option{--param inline-unit-growth}.
15009For small units this might be too tight.
15010For example, consider a unit consisting of function A
15011that is inline and B that just calls A three times. If B is small relative to
15012A, the growth of unit is 300\% and yet such inlining is very sane. For very
15013large units consisting of small inlineable functions, however, the overall unit
15014growth limit is needed to avoid exponential explosion of code size. Thus for
15015smaller units, the size is increased to @option{--param large-unit-insns}
15016before applying @option{--param inline-unit-growth}.
15017
15018@item lazy-modules
15019Maximum number of concurrently open C++ module files when lazy loading.
15020
15021@item inline-unit-growth
15022Specifies maximal overall growth of the compilation unit caused by inlining.
15023For example, parameter value 20 limits unit growth to 1.2 times the original
15024size. Cold functions (either marked cold via an attribute or by profile
15025feedback) are not accounted into the unit size.
15026
15027@item ipa-cp-unit-growth
15028Specifies maximal overall growth of the compilation unit caused by
15029interprocedural constant propagation. For example, parameter value 10 limits
15030unit growth to 1.1 times the original size.
15031
15032@item ipa-cp-large-unit-insns
15033The size of translation unit that IPA-CP pass considers large.
15034
15035@item large-stack-frame
15036The limit specifying large stack frames. While inlining the algorithm is trying
15037to not grow past this limit too much.
15038
15039@item large-stack-frame-growth
15040Specifies maximal growth of large stack frames caused by inlining in percents.
15041For example, parameter value 1000 limits large stack frame growth to 11 times
15042the original size.
15043
15044@item max-inline-insns-recursive
15045@itemx max-inline-insns-recursive-auto
15046Specifies the maximum number of instructions an out-of-line copy of a
15047self-recursive inline
15048function can grow into by performing recursive inlining.
15049
15050@option{--param max-inline-insns-recursive} applies to functions
15051declared inline.
15052For functions not declared inline, recursive inlining
15053happens only when @option{-finline-functions} (included in @option{-O3}) is
15054enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
15055
15056@item max-inline-recursive-depth
15057@itemx max-inline-recursive-depth-auto
15058Specifies the maximum recursion depth used for recursive inlining.
15059
15060@option{--param max-inline-recursive-depth} applies to functions
15061declared inline. For functions not declared inline, recursive inlining
15062happens only when @option{-finline-functions} (included in @option{-O3}) is
15063enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
15064
15065@item min-inline-recursive-probability
15066Recursive inlining is profitable only for function having deep recursion
15067in average and can hurt for function having little recursion depth by
15068increasing the prologue size or complexity of function body to other
15069optimizers.
15070
15071When profile feedback is available (see @option{-fprofile-generate}) the actual
15072recursion depth can be guessed from the probability that function recurses
15073via a given call expression. This parameter limits inlining only to call
15074expressions whose probability exceeds the given threshold (in percents).
15075
15076@item early-inlining-insns
15077Specify growth that the early inliner can make. In effect it increases
15078the amount of inlining for code having a large abstraction penalty.
15079
15080@item max-early-inliner-iterations
15081Limit of iterations of the early inliner. This basically bounds
15082the number of nested indirect calls the early inliner can resolve.
15083Deeper chains are still handled by late inlining.
15084
15085@item comdat-sharing-probability
15086Probability (in percent) that C++ inline function with comdat visibility
15087are shared across multiple compilation units.
15088
15089@item modref-max-bases
15090@item modref-max-refs
15091@item modref-max-accesses
15092Specifies the maximal number of base pointers, references and accesses stored
15093for a single function by mod/ref analysis.
15094
15095@item modref-max-tests
15096Specifies the maxmal number of tests alias oracle can perform to disambiguate
15097memory locations using the mod/ref information. This parameter ought to be
15098bigger than @option{--param modref-max-bases} and @option{--param
15099modref-max-refs}.
15100
15101@item modref-max-depth
15102Specifies the maximum depth of DFS walk used by modref escape analysis.
15103Setting to 0 disables the analysis completely.
15104
15105@item modref-max-escape-points
15106Specifies the maximum number of escape points tracked by modref per SSA-name.
15107
15108@item modref-max-adjustments
15109Specifies the maximum number the access range is enlarged during modref dataflow
15110analysis.
15111
15112@item profile-func-internal-id
15113A parameter to control whether to use function internal id in profile
15114database lookup. If the value is 0, the compiler uses an id that
15115is based on function assembler name and filename, which makes old profile
15116data more tolerant to source changes such as function reordering etc.
15117
15118@item min-vect-loop-bound
15119The minimum number of iterations under which loops are not vectorized
15120when @option{-ftree-vectorize} is used. The number of iterations after
15121vectorization needs to be greater than the value specified by this option
15122to allow vectorization.
15123
15124@item gcse-cost-distance-ratio
15125Scaling factor in calculation of maximum distance an expression
15126can be moved by GCSE optimizations. This is currently supported only in the
15127code hoisting pass. The bigger the ratio, the more aggressive code hoisting
15128is with simple expressions, i.e., the expressions that have cost
15129less than @option{gcse-unrestricted-cost}. Specifying 0 disables
15130hoisting of simple expressions.
15131
15132@item gcse-unrestricted-cost
15133Cost, roughly measured as the cost of a single typical machine
15134instruction, at which GCSE optimizations do not constrain
15135the distance an expression can travel. This is currently
15136supported only in the code hoisting pass. The lesser the cost,
15137the more aggressive code hoisting is. Specifying 0
15138allows all expressions to travel unrestricted distances.
15139
15140@item max-hoist-depth
15141The depth of search in the dominator tree for expressions to hoist.
15142This is used to avoid quadratic behavior in hoisting algorithm.
15143The value of 0 does not limit on the search, but may slow down compilation
15144of huge functions.
15145
15146@item max-tail-merge-comparisons
15147The maximum amount of similar bbs to compare a bb with. This is used to
15148avoid quadratic behavior in tree tail merging.
15149
15150@item max-tail-merge-iterations
15151The maximum amount of iterations of the pass over the function. This is used to
15152limit compilation time in tree tail merging.
15153
15154@item store-merging-allow-unaligned
15155Allow the store merging pass to introduce unaligned stores if it is legal to
15156do so.
15157
15158@item max-stores-to-merge
15159The maximum number of stores to attempt to merge into wider stores in the store
15160merging pass.
15161
15162@item max-store-chains-to-track
15163The maximum number of store chains to track at the same time in the attempt
15164to merge them into wider stores in the store merging pass.
15165
15166@item max-stores-to-track
15167The maximum number of stores to track at the same time in the attemt to
15168to merge them into wider stores in the store merging pass.
15169
15170@item max-unrolled-insns
15171The maximum number of instructions that a loop may have to be unrolled.
15172If a loop is unrolled, this parameter also determines how many times
15173the loop code is unrolled.
15174
15175@item max-average-unrolled-insns
15176The maximum number of instructions biased by probabilities of their execution
15177that a loop may have to be unrolled. If a loop is unrolled,
15178this parameter also determines how many times the loop code is unrolled.
15179
15180@item max-unroll-times
15181The maximum number of unrollings of a single loop.
15182
15183@item max-peeled-insns
15184The maximum number of instructions that a loop may have to be peeled.
15185If a loop is peeled, this parameter also determines how many times
15186the loop code is peeled.
15187
15188@item max-peel-times
15189The maximum number of peelings of a single loop.
15190
15191@item max-peel-branches
15192The maximum number of branches on the hot path through the peeled sequence.
15193
15194@item max-completely-peeled-insns
15195The maximum number of insns of a completely peeled loop.
15196
15197@item max-completely-peel-times
15198The maximum number of iterations of a loop to be suitable for complete peeling.
15199
15200@item max-completely-peel-loop-nest-depth
15201The maximum depth of a loop nest suitable for complete peeling.
15202
15203@item max-unswitch-insns
15204The maximum number of insns of an unswitched loop.
15205
5b50850c
RB
15206@item max-unswitch-depth
15207The maximum depth of a loop nest to be unswitched.
15208
d77de738
ML
15209@item lim-expensive
15210The minimum cost of an expensive expression in the loop invariant motion.
15211
15212@item min-loop-cond-split-prob
15213When FDO profile information is available, @option{min-loop-cond-split-prob}
15214specifies minimum threshold for probability of semi-invariant condition
15215statement to trigger loop split.
15216
15217@item iv-consider-all-candidates-bound
15218Bound on number of candidates for induction variables, below which
15219all candidates are considered for each use in induction variable
15220optimizations. If there are more candidates than this,
15221only the most relevant ones are considered to avoid quadratic time complexity.
15222
15223@item iv-max-considered-uses
15224The induction variable optimizations give up on loops that contain more
15225induction variable uses.
15226
15227@item iv-always-prune-cand-set-bound
15228If the number of candidates in the set is smaller than this value,
15229always try to remove unnecessary ivs from the set
15230when adding a new one.
15231
15232@item avg-loop-niter
15233Average number of iterations of a loop.
15234
15235@item dse-max-object-size
15236Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15237Larger values may result in larger compilation times.
15238
15239@item dse-max-alias-queries-per-store
15240Maximum number of queries into the alias oracle per store.
15241Larger values result in larger compilation times and may result in more
15242removed dead stores.
15243
15244@item scev-max-expr-size
15245Bound on size of expressions used in the scalar evolutions analyzer.
15246Large expressions slow the analyzer.
15247
15248@item scev-max-expr-complexity
15249Bound on the complexity of the expressions in the scalar evolutions analyzer.
15250Complex expressions slow the analyzer.
15251
15252@item max-tree-if-conversion-phi-args
15253Maximum number of arguments in a PHI supported by TREE if conversion
15254unless the loop is marked with simd pragma.
15255
15256@item vect-max-layout-candidates
15257The maximum number of possible vector layouts (such as permutations)
15258to consider when optimizing to-be-vectorized code.
15259
15260@item vect-max-version-for-alignment-checks
15261The maximum number of run-time checks that can be performed when
15262doing loop versioning for alignment in the vectorizer.
15263
15264@item vect-max-version-for-alias-checks
15265The maximum number of run-time checks that can be performed when
15266doing loop versioning for alias in the vectorizer.
15267
15268@item vect-max-peeling-for-alignment
15269The maximum number of loop peels to enhance access alignment
15270for vectorizer. Value -1 means no limit.
15271
15272@item max-iterations-to-track
15273The maximum number of iterations of a loop the brute-force algorithm
15274for analysis of the number of iterations of the loop tries to evaluate.
15275
15276@item hot-bb-count-fraction
15277The denominator n of fraction 1/n of the maximal execution count of a
15278basic block in the entire program that a basic block needs to at least
15279have in order to be considered hot. The default is 10000, which means
15280that a basic block is considered hot if its execution count is greater
15281than 1/10000 of the maximal execution count. 0 means that it is never
15282considered hot. Used in non-LTO mode.
15283
15284@item hot-bb-count-ws-permille
15285The number of most executed permilles, ranging from 0 to 1000, of the
15286profiled execution of the entire program to which the execution count
15287of a basic block must be part of in order to be considered hot. The
15288default is 990, which means that a basic block is considered hot if
15289its execution count contributes to the upper 990 permilles, or 99.0%,
15290of the profiled execution of the entire program. 0 means that it is
15291never considered hot. Used in LTO mode.
15292
15293@item hot-bb-frequency-fraction
15294The denominator n of fraction 1/n of the execution frequency of the
15295entry block of a function that a basic block of this function needs
15296to at least have in order to be considered hot. The default is 1000,
15297which means that a basic block is considered hot in a function if it
15298is executed more frequently than 1/1000 of the frequency of the entry
15299block of the function. 0 means that it is never considered hot.
15300
15301@item unlikely-bb-count-fraction
15302The denominator n of fraction 1/n of the number of profiled runs of
15303the entire program below which the execution count of a basic block
15304must be in order for the basic block to be considered unlikely executed.
15305The default is 20, which means that a basic block is considered unlikely
15306executed if it is executed in fewer than 1/20, or 5%, of the runs of
15307the program. 0 means that it is always considered unlikely executed.
15308
15309@item max-predicted-iterations
15310The maximum number of loop iterations we predict statically. This is useful
15311in cases where a function contains a single loop with known bound and
15312another loop with unknown bound.
15313The known number of iterations is predicted correctly, while
15314the unknown number of iterations average to roughly 10. This means that the
15315loop without bounds appears artificially cold relative to the other one.
15316
15317@item builtin-expect-probability
15318Control the probability of the expression having the specified value. This
15319parameter takes a percentage (i.e.@: 0 ... 100) as input.
15320
15321@item builtin-string-cmp-inline-length
15322The maximum length of a constant string for a builtin string cmp call
15323eligible for inlining.
15324
15325@item align-threshold
15326
15327Select fraction of the maximal frequency of executions of a basic block in
15328a function to align the basic block.
15329
15330@item align-loop-iterations
15331
15332A loop expected to iterate at least the selected number of iterations is
15333aligned.
15334
15335@item tracer-dynamic-coverage
15336@itemx tracer-dynamic-coverage-feedback
15337
15338This value is used to limit superblock formation once the given percentage of
15339executed instructions is covered. This limits unnecessary code size
15340expansion.
15341
15342The @option{tracer-dynamic-coverage-feedback} parameter
15343is used only when profile
15344feedback is available. The real profiles (as opposed to statically estimated
15345ones) are much less balanced allowing the threshold to be larger value.
15346
15347@item tracer-max-code-growth
15348Stop tail duplication once code growth has reached given percentage. This is
15349a rather artificial limit, as most of the duplicates are eliminated later in
15350cross jumping, so it may be set to much higher values than is the desired code
15351growth.
15352
15353@item tracer-min-branch-ratio
15354
15355Stop reverse growth when the reverse probability of best edge is less than this
15356threshold (in percent).
15357
15358@item tracer-min-branch-probability
15359@itemx tracer-min-branch-probability-feedback
15360
15361Stop forward growth if the best edge has probability lower than this
15362threshold.
15363
15364Similarly to @option{tracer-dynamic-coverage} two parameters are
15365provided. @option{tracer-min-branch-probability-feedback} is used for
15366compilation with profile feedback and @option{tracer-min-branch-probability}
15367compilation without. The value for compilation with profile feedback
15368needs to be more conservative (higher) in order to make tracer
15369effective.
15370
15371@item stack-clash-protection-guard-size
15372Specify the size of the operating system provided stack guard as
153732 raised to @var{num} bytes. Higher values may reduce the
15374number of explicit probes, but a value larger than the operating system
15375provided guard will leave code vulnerable to stack clash style attacks.
15376
15377@item stack-clash-protection-probe-interval
15378Stack clash protection involves probing stack space as it is allocated. This
15379param controls the maximum distance between probes into the stack as 2 raised
15380to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15381larger than the operating system provided guard will leave code vulnerable to
15382stack clash style attacks.
15383
15384@item max-cse-path-length
15385
15386The maximum number of basic blocks on path that CSE considers.
15387
15388@item max-cse-insns
15389The maximum number of instructions CSE processes before flushing.
15390
15391@item ggc-min-expand
15392
15393GCC uses a garbage collector to manage its own memory allocation. This
15394parameter specifies the minimum percentage by which the garbage
15395collector's heap should be allowed to expand between collections.
15396Tuning this may improve compilation speed; it has no effect on code
15397generation.
15398
15399The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15400RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15401the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15402GCC is not able to calculate RAM on a particular platform, the lower
15403bound of 30% is used. Setting this parameter and
15404@option{ggc-min-heapsize} to zero causes a full collection to occur at
15405every opportunity. This is extremely slow, but can be useful for
15406debugging.
15407
15408@item ggc-min-heapsize
15409
15410Minimum size of the garbage collector's heap before it begins bothering
15411to collect garbage. The first collection occurs after the heap expands
15412by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15413tuning this may improve compilation speed, and has no effect on code
15414generation.
15415
15416The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15417tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15418with a lower bound of 4096 (four megabytes) and an upper bound of
15419131072 (128 megabytes). If GCC is not able to calculate RAM on a
15420particular platform, the lower bound is used. Setting this parameter
15421very large effectively disables garbage collection. Setting this
15422parameter and @option{ggc-min-expand} to zero causes a full collection
15423to occur at every opportunity.
15424
15425@item max-reload-search-insns
15426The maximum number of instruction reload should look backward for equivalent
15427register. Increasing values mean more aggressive optimization, making the
15428compilation time increase with probably slightly better performance.
15429
15430@item max-cselib-memory-locations
15431The maximum number of memory locations cselib should take into account.
15432Increasing values mean more aggressive optimization, making the compilation time
15433increase with probably slightly better performance.
15434
15435@item max-sched-ready-insns
15436The maximum number of instructions ready to be issued the scheduler should
15437consider at any given time during the first scheduling pass. Increasing
15438values mean more thorough searches, making the compilation time increase
15439with probably little benefit.
15440
15441@item max-sched-region-blocks
15442The maximum number of blocks in a region to be considered for
15443interblock scheduling.
15444
15445@item max-pipeline-region-blocks
15446The maximum number of blocks in a region to be considered for
15447pipelining in the selective scheduler.
15448
15449@item max-sched-region-insns
15450The maximum number of insns in a region to be considered for
15451interblock scheduling.
15452
15453@item max-pipeline-region-insns
15454The maximum number of insns in a region to be considered for
15455pipelining in the selective scheduler.
15456
15457@item min-spec-prob
15458The minimum probability (in percents) of reaching a source block
15459for interblock speculative scheduling.
15460
15461@item max-sched-extend-regions-iters
15462The maximum number of iterations through CFG to extend regions.
15463A value of 0 disables region extensions.
15464
15465@item max-sched-insn-conflict-delay
15466The maximum conflict delay for an insn to be considered for speculative motion.
15467
15468@item sched-spec-prob-cutoff
15469The minimal probability of speculation success (in percents), so that
15470speculative insns are scheduled.
15471
15472@item sched-state-edge-prob-cutoff
15473The minimum probability an edge must have for the scheduler to save its
15474state across it.
15475
15476@item sched-mem-true-dep-cost
15477Minimal distance (in CPU cycles) between store and load targeting same
15478memory locations.
15479
15480@item selsched-max-lookahead
15481The maximum size of the lookahead window of selective scheduling. It is a
15482depth of search for available instructions.
15483
15484@item selsched-max-sched-times
15485The maximum number of times that an instruction is scheduled during
15486selective scheduling. This is the limit on the number of iterations
15487through which the instruction may be pipelined.
15488
15489@item selsched-insns-to-rename
15490The maximum number of best instructions in the ready list that are considered
15491for renaming in the selective scheduler.
15492
15493@item sms-min-sc
15494The minimum value of stage count that swing modulo scheduler
15495generates.
15496
15497@item max-last-value-rtl
15498The maximum size measured as number of RTLs that can be recorded in an expression
15499in combiner for a pseudo register as last known value of that register.
15500
15501@item max-combine-insns
15502The maximum number of instructions the RTL combiner tries to combine.
15503
15504@item integer-share-limit
15505Small integer constants can use a shared data structure, reducing the
15506compiler's memory usage and increasing its speed. This sets the maximum
15507value of a shared integer constant.
15508
15509@item ssp-buffer-size
15510The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15511protection when @option{-fstack-protector} is used.
15512
15513@item min-size-for-stack-sharing
15514The minimum size of variables taking part in stack slot sharing when not
15515optimizing.
15516
15517@item max-jump-thread-duplication-stmts
15518Maximum number of statements allowed in a block that needs to be
15519duplicated when threading jumps.
15520
15521@item max-jump-thread-paths
15522The maximum number of paths to consider when searching for jump threading
15523opportunities. When arriving at a block, incoming edges are only considered
15524if the number of paths to be searched so far multiplied by the number of
15525incoming edges does not exhaust the specified maximum number of paths to
15526consider.
15527
15528@item max-fields-for-field-sensitive
15529Maximum number of fields in a structure treated in
15530a field sensitive manner during pointer analysis.
15531
15532@item prefetch-latency
15533Estimate on average number of instructions that are executed before
15534prefetch finishes. The distance prefetched ahead is proportional
15535to this constant. Increasing this number may also lead to less
15536streams being prefetched (see @option{simultaneous-prefetches}).
15537
15538@item simultaneous-prefetches
15539Maximum number of prefetches that can run at the same time.
15540
15541@item l1-cache-line-size
15542The size of cache line in L1 data cache, in bytes.
15543
15544@item l1-cache-size
15545The size of L1 data cache, in kilobytes.
15546
15547@item l2-cache-size
15548The size of L2 data cache, in kilobytes.
15549
15550@item prefetch-dynamic-strides
15551Whether the loop array prefetch pass should issue software prefetch hints
15552for strides that are non-constant. In some cases this may be
15553beneficial, though the fact the stride is non-constant may make it
15554hard to predict when there is clear benefit to issuing these hints.
15555
15556Set to 1 if the prefetch hints should be issued for non-constant
15557strides. Set to 0 if prefetch hints should be issued only for strides that
15558are known to be constant and below @option{prefetch-minimum-stride}.
15559
15560@item prefetch-minimum-stride
15561Minimum constant stride, in bytes, to start using prefetch hints for. If
15562the stride is less than this threshold, prefetch hints will not be issued.
15563
15564This setting is useful for processors that have hardware prefetchers, in
15565which case there may be conflicts between the hardware prefetchers and
15566the software prefetchers. If the hardware prefetchers have a maximum
15567stride they can handle, it should be used here to improve the use of
15568software prefetchers.
15569
15570A value of -1 means we don't have a threshold and therefore
15571prefetch hints can be issued for any constant stride.
15572
15573This setting is only useful for strides that are known and constant.
15574
15575@item destructive-interference-size
15576@item constructive-interference-size
15577The values for the C++17 variables
15578@code{std::hardware_destructive_interference_size} and
15579@code{std::hardware_constructive_interference_size}. The destructive
15580interference size is the minimum recommended offset between two
15581independent concurrently-accessed objects; the constructive
15582interference size is the maximum recommended size of contiguous memory
15583accessed together. Typically both will be the size of an L1 cache
15584line for the target, in bytes. For a generic target covering a range of L1
15585cache line sizes, typically the constructive interference size will be
15586the small end of the range and the destructive size will be the large
15587end.
15588
15589The destructive interference size is intended to be used for layout,
15590and thus has ABI impact. The default value is not expected to be
15591stable, and on some targets varies with @option{-mtune}, so use of
15592this variable in a context where ABI stability is important, such as
15593the public interface of a library, is strongly discouraged; if it is
15594used in that context, users can stabilize the value using this
15595option.
15596
15597The constructive interference size is less sensitive, as it is
15598typically only used in a @samp{static_assert} to make sure that a type
15599fits within a cache line.
15600
15601See also @option{-Winterference-size}.
15602
15603@item loop-interchange-max-num-stmts
15604The maximum number of stmts in a loop to be interchanged.
15605
15606@item loop-interchange-stride-ratio
15607The minimum ratio between stride of two loops for interchange to be profitable.
15608
15609@item min-insn-to-prefetch-ratio
15610The minimum ratio between the number of instructions and the
15611number of prefetches to enable prefetching in a loop.
15612
15613@item prefetch-min-insn-to-mem-ratio
15614The minimum ratio between the number of instructions and the
15615number of memory references to enable prefetching in a loop.
15616
15617@item use-canonical-types
15618Whether the compiler should use the ``canonical'' type system.
15619Should always be 1, which uses a more efficient internal
15620mechanism for comparing types in C++ and Objective-C++. However, if
15621bugs in the canonical type system are causing compilation failures,
15622set this value to 0 to disable canonical types.
15623
15624@item switch-conversion-max-branch-ratio
15625Switch initialization conversion refuses to create arrays that are
15626bigger than @option{switch-conversion-max-branch-ratio} times the number of
15627branches in the switch.
15628
15629@item max-partial-antic-length
15630Maximum length of the partial antic set computed during the tree
15631partial redundancy elimination optimization (@option{-ftree-pre}) when
15632optimizing at @option{-O3} and above. For some sorts of source code
15633the enhanced partial redundancy elimination optimization can run away,
15634consuming all of the memory available on the host machine. This
15635parameter sets a limit on the length of the sets that are computed,
15636which prevents the runaway behavior. Setting a value of 0 for
15637this parameter allows an unlimited set length.
15638
15639@item rpo-vn-max-loop-depth
15640Maximum loop depth that is value-numbered optimistically.
15641When the limit hits the innermost
15642@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15643loop nest are value-numbered optimistically and the remaining ones not.
15644
15645@item sccvn-max-alias-queries-per-access
15646Maximum number of alias-oracle queries we perform when looking for
15647redundancies for loads and stores. If this limit is hit the search
15648is aborted and the load or store is not considered redundant. The
15649number of queries is algorithmically limited to the number of
15650stores on all paths from the load to the function entry.
15651
15652@item ira-max-loops-num
15653IRA uses regional register allocation by default. If a function
15654contains more loops than the number given by this parameter, only at most
15655the given number of the most frequently-executed loops form regions
15656for regional register allocation.
15657
15658@item ira-max-conflict-table-size
15659Although IRA uses a sophisticated algorithm to compress the conflict
15660table, the table can still require excessive amounts of memory for
15661huge functions. If the conflict table for a function could be more
15662than the size in MB given by this parameter, the register allocator
15663instead uses a faster, simpler, and lower-quality
15664algorithm that does not require building a pseudo-register conflict table.
15665
15666@item ira-loop-reserved-regs
15667IRA can be used to evaluate more accurate register pressure in loops
15668for decisions to move loop invariants (see @option{-O3}). The number
15669of available registers reserved for some other purposes is given
15670by this parameter. Default of the parameter
15671is the best found from numerous experiments.
15672
15673@item ira-consider-dup-in-all-alts
15674Make IRA to consider matching constraint (duplicated operand number)
15675heavily in all available alternatives for preferred register class.
15676If it is set as zero, it means IRA only respects the matching
15677constraint when it's in the only available alternative with an
15678appropriate register class. Otherwise, it means IRA will check all
15679available alternatives for preferred register class even if it has
15680found some choice with an appropriate register class and respect the
15681found qualified matching constraint.
15682
9847c753
ML
15683@item ira-simple-lra-insn-threshold
15684Approximate function insn number in 1K units triggering simple local RA.
15685
d77de738
ML
15686@item lra-inheritance-ebb-probability-cutoff
15687LRA tries to reuse values reloaded in registers in subsequent insns.
15688This optimization is called inheritance. EBB is used as a region to
15689do this optimization. The parameter defines a minimal fall-through
15690edge probability in percentage used to add BB to inheritance EBB in
15691LRA. The default value was chosen
15692from numerous runs of SPEC2000 on x86-64.
15693
15694@item loop-invariant-max-bbs-in-loop
15695Loop invariant motion can be very expensive, both in compilation time and
15696in amount of needed compile-time memory, with very large loops. Loops
15697with more basic blocks than this parameter won't have loop invariant
15698motion optimization performed on them.
15699
15700@item loop-max-datarefs-for-datadeps
15701Building data dependencies is expensive for very large loops. This
15702parameter limits the number of data references in loops that are
15703considered for data dependence analysis. These large loops are no
15704handled by the optimizations using loop data dependencies.
15705
15706@item max-vartrack-size
15707Sets a maximum number of hash table slots to use during variable
15708tracking dataflow analysis of any function. If this limit is exceeded
15709with variable tracking at assignments enabled, analysis for that
15710function is retried without it, after removing all debug insns from
15711the function. If the limit is exceeded even without debug insns, var
15712tracking analysis is completely disabled for the function. Setting
15713the parameter to zero makes it unlimited.
15714
15715@item max-vartrack-expr-depth
15716Sets a maximum number of recursion levels when attempting to map
15717variable names or debug temporaries to value expressions. This trades
15718compilation time for more complete debug information. If this is set too
15719low, value expressions that are available and could be represented in
15720debug information may end up not being used; setting this higher may
15721enable the compiler to find more complex debug expressions, but compile
15722time and memory use may grow.
15723
15724@item max-debug-marker-count
15725Sets a threshold on the number of debug markers (e.g.@: begin stmt
15726markers) to avoid complexity explosion at inlining or expanding to RTL.
15727If a function has more such gimple stmts than the set limit, such stmts
15728will be dropped from the inlined copy of a function, and from its RTL
15729expansion.
15730
15731@item min-nondebug-insn-uid
15732Use uids starting at this parameter for nondebug insns. The range below
15733the parameter is reserved exclusively for debug insns created by
15734@option{-fvar-tracking-assignments}, but debug insns may get
15735(non-overlapping) uids above it if the reserved range is exhausted.
15736
10478270
MJ
15737@item ipa-sra-deref-prob-threshold
15738IPA-SRA replaces a pointer which is known not be NULL with one or more
15739new parameters only when the probability (in percent, relative to
15740function entry) of it being dereferenced is higher than this parameter.
15741
d77de738
ML
15742@item ipa-sra-ptr-growth-factor
15743IPA-SRA replaces a pointer to an aggregate with one or more new
15744parameters only when their cumulative size is less or equal to
15745@option{ipa-sra-ptr-growth-factor} times the size of the original
15746pointer parameter.
15747
69363825
ML
15748@item ipa-sra-ptrwrap-growth-factor
15749Additional maximum allowed growth of total size of new parameters
15750that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
15751if it points to a local variable that the caller only writes to and
15752passes it as an argument to other functions.
69363825 15753
d77de738
ML
15754@item ipa-sra-max-replacements
15755Maximum pieces of an aggregate that IPA-SRA tracks. As a
15756consequence, it is also the maximum number of replacements of a formal
15757parameter.
15758
15759@item sra-max-scalarization-size-Ospeed
15760@itemx sra-max-scalarization-size-Osize
15761The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15762replace scalar parts of aggregates with uses of independent scalar
15763variables. These parameters control the maximum size, in storage units,
15764of aggregate which is considered for replacement when compiling for
15765speed
15766(@option{sra-max-scalarization-size-Ospeed}) or size
15767(@option{sra-max-scalarization-size-Osize}) respectively.
15768
15769@item sra-max-propagations
15770The maximum number of artificial accesses that Scalar Replacement of
15771Aggregates (SRA) will track, per one local variable, in order to
15772facilitate copy propagation.
15773
15774@item tm-max-aggregate-size
15775When making copies of thread-local variables in a transaction, this
15776parameter specifies the size in bytes after which variables are
15777saved with the logging functions as opposed to save/restore code
15778sequence pairs. This option only applies when using
15779@option{-fgnu-tm}.
15780
15781@item graphite-max-nb-scop-params
15782To avoid exponential effects in the Graphite loop transforms, the
15783number of parameters in a Static Control Part (SCoP) is bounded.
15784A value of zero can be used to lift
15785the bound. A variable whose value is unknown at compilation time and
15786defined outside a SCoP is a parameter of the SCoP.
15787
15788@item loop-block-tile-size
15789Loop blocking or strip mining transforms, enabled with
15790@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15791loop in the loop nest by a given number of iterations. The strip
15792length can be changed using the @option{loop-block-tile-size}
15793parameter.
15794
15795@item ipa-jump-function-lookups
15796Specifies number of statements visited during jump function offset discovery.
15797
15798@item ipa-cp-value-list-size
15799IPA-CP attempts to track all possible values and types passed to a function's
15800parameter in order to propagate them and perform devirtualization.
15801@option{ipa-cp-value-list-size} is the maximum number of values and types it
15802stores per one formal parameter of a function.
15803
15804@item ipa-cp-eval-threshold
15805IPA-CP calculates its own score of cloning profitability heuristics
15806and performs those cloning opportunities with scores that exceed
15807@option{ipa-cp-eval-threshold}.
15808
15809@item ipa-cp-max-recursive-depth
15810Maximum depth of recursive cloning for self-recursive function.
15811
15812@item ipa-cp-min-recursive-probability
15813Recursive cloning only when the probability of call being executed exceeds
15814the parameter.
15815
15816@item ipa-cp-profile-count-base
15817When using @option{-fprofile-use} option, IPA-CP will consider the measured
15818execution count of a call graph edge at this percentage position in their
15819histogram as the basis for its heuristics calculation.
15820
15821@item ipa-cp-recursive-freq-factor
15822The number of times interprocedural copy propagation expects recursive
15823functions to call themselves.
15824
15825@item ipa-cp-recursion-penalty
15826Percentage penalty the recursive functions will receive when they
15827are evaluated for cloning.
15828
15829@item ipa-cp-single-call-penalty
15830Percentage penalty functions containing a single call to another
15831function will receive when they are evaluated for cloning.
15832
15833@item ipa-max-agg-items
15834IPA-CP is also capable to propagate a number of scalar values passed
15835in an aggregate. @option{ipa-max-agg-items} controls the maximum
15836number of such values per one parameter.
15837
15838@item ipa-cp-loop-hint-bonus
15839When IPA-CP determines that a cloning candidate would make the number
15840of iterations of a loop known, it adds a bonus of
15841@option{ipa-cp-loop-hint-bonus} to the profitability score of
15842the candidate.
15843
15844@item ipa-max-loop-predicates
15845The maximum number of different predicates IPA will use to describe when
15846loops in a function have known properties.
15847
15848@item ipa-max-aa-steps
15849During its analysis of function bodies, IPA-CP employs alias analysis
15850in order to track values pointed to by function parameters. In order
15851not spend too much time analyzing huge functions, it gives up and
15852consider all memory clobbered after examining
15853@option{ipa-max-aa-steps} statements modifying memory.
15854
15855@item ipa-max-switch-predicate-bounds
15856Maximal number of boundary endpoints of case ranges of switch statement.
15857For switch exceeding this limit, IPA-CP will not construct cloning cost
15858predicate, which is used to estimate cloning benefit, for default case
15859of the switch statement.
15860
15861@item ipa-max-param-expr-ops
15862IPA-CP will analyze conditional statement that references some function
15863parameter to estimate benefit for cloning upon certain constant value.
15864But if number of operations in a parameter expression exceeds
15865@option{ipa-max-param-expr-ops}, the expression is treated as complicated
15866one, and is not handled by IPA analysis.
15867
15868@item lto-partitions
15869Specify desired number of partitions produced during WHOPR compilation.
15870The number of partitions should exceed the number of CPUs used for compilation.
15871
15872@item lto-min-partition
15873Size of minimal partition for WHOPR (in estimated instructions).
15874This prevents expenses of splitting very small programs into too many
15875partitions.
15876
15877@item lto-max-partition
15878Size of max partition for WHOPR (in estimated instructions).
15879to provide an upper bound for individual size of partition.
15880Meant to be used only with balanced partitioning.
15881
15882@item lto-max-streaming-parallelism
15883Maximal number of parallel processes used for LTO streaming.
15884
15885@item cxx-max-namespaces-for-diagnostic-help
15886The maximum number of namespaces to consult for suggestions when C++
15887name lookup fails for an identifier.
15888
15889@item sink-frequency-threshold
15890The maximum relative execution frequency (in percents) of the target block
15891relative to a statement's original block to allow statement sinking of a
15892statement. Larger numbers result in more aggressive statement sinking.
15893A small positive adjustment is applied for
15894statements with memory operands as those are even more profitable so sink.
15895
15896@item max-stores-to-sink
15897The maximum number of conditional store pairs that can be sunk. Set to 0
15898if either vectorization (@option{-ftree-vectorize}) or if-conversion
15899(@option{-ftree-loop-if-convert}) is disabled.
15900
15901@item case-values-threshold
15902The smallest number of different values for which it is best to use a
15903jump-table instead of a tree of conditional branches. If the value is
159040, use the default for the machine.
15905
15906@item jump-table-max-growth-ratio-for-size
15907The maximum code size growth ratio when expanding
15908into a jump table (in percent). The parameter is used when
15909optimizing for size.
15910
15911@item jump-table-max-growth-ratio-for-speed
15912The maximum code size growth ratio when expanding
15913into a jump table (in percent). The parameter is used when
15914optimizing for speed.
15915
15916@item tree-reassoc-width
15917Set the maximum number of instructions executed in parallel in
15918reassociated tree. This parameter overrides target dependent
15919heuristics used by default if has non zero value.
15920
15921@item sched-pressure-algorithm
15922Choose between the two available implementations of
15923@option{-fsched-pressure}. Algorithm 1 is the original implementation
15924and is the more likely to prevent instructions from being reordered.
15925Algorithm 2 was designed to be a compromise between the relatively
15926conservative approach taken by algorithm 1 and the rather aggressive
15927approach taken by the default scheduler. It relies more heavily on
15928having a regular register file and accurate register pressure classes.
15929See @file{haifa-sched.cc} in the GCC sources for more details.
15930
15931The default choice depends on the target.
15932
15933@item max-slsr-cand-scan
15934Set the maximum number of existing candidates that are considered when
15935seeking a basis for a new straight-line strength reduction candidate.
15936
15937@item asan-globals
15938Enable buffer overflow detection for global objects. This kind
15939of protection is enabled by default if you are using
15940@option{-fsanitize=address} option.
15941To disable global objects protection use @option{--param asan-globals=0}.
15942
15943@item asan-stack
15944Enable buffer overflow detection for stack objects. This kind of
15945protection is enabled by default when using @option{-fsanitize=address}.
15946To disable stack protection use @option{--param asan-stack=0} option.
15947
15948@item asan-instrument-reads
15949Enable buffer overflow detection for memory reads. This kind of
15950protection is enabled by default when using @option{-fsanitize=address}.
15951To disable memory reads protection use
15952@option{--param asan-instrument-reads=0}.
15953
15954@item asan-instrument-writes
15955Enable buffer overflow detection for memory writes. This kind of
15956protection is enabled by default when using @option{-fsanitize=address}.
15957To disable memory writes protection use
15958@option{--param asan-instrument-writes=0} option.
15959
15960@item asan-memintrin
15961Enable detection for built-in functions. This kind of protection
15962is enabled by default when using @option{-fsanitize=address}.
15963To disable built-in functions protection use
15964@option{--param asan-memintrin=0}.
15965
15966@item asan-use-after-return
15967Enable detection of use-after-return. This kind of protection
15968is enabled by default when using the @option{-fsanitize=address} option.
15969To disable it use @option{--param asan-use-after-return=0}.
15970
15971Note: By default the check is disabled at run time. To enable it,
15972add @code{detect_stack_use_after_return=1} to the environment variable
15973@env{ASAN_OPTIONS}.
15974
15975@item asan-instrumentation-with-call-threshold
15976If number of memory accesses in function being instrumented
15977is greater or equal to this number, use callbacks instead of inline checks.
15978E.g. to disable inline code use
15979@option{--param asan-instrumentation-with-call-threshold=0}.
15980
545c9f8b 15981@item asan-kernel-mem-intrinsic-prefix
f56ed5b3
SL
15982If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
15983with @samp{__asan_} or @samp{__hwasan_}
15984for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
15985respectively.
545c9f8b 15986
d77de738
ML
15987@item hwasan-instrument-stack
15988Enable hwasan instrumentation of statically sized stack-allocated variables.
15989This kind of instrumentation is enabled by default when using
15990@option{-fsanitize=hwaddress} and disabled by default when using
15991@option{-fsanitize=kernel-hwaddress}.
15992To disable stack instrumentation use
15993@option{--param hwasan-instrument-stack=0}, and to enable it use
15994@option{--param hwasan-instrument-stack=1}.
15995
15996@item hwasan-random-frame-tag
15997When using stack instrumentation, decide tags for stack variables using a
15998deterministic sequence beginning at a random tag for each frame. With this
15999parameter unset tags are chosen using the same sequence but beginning from 1.
16000This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
16001for @option{-fsanitize=kernel-hwaddress}.
16002To disable it use @option{--param hwasan-random-frame-tag=0}.
16003
16004@item hwasan-instrument-allocas
16005Enable hwasan instrumentation of dynamically sized stack-allocated variables.
16006This kind of instrumentation is enabled by default when using
16007@option{-fsanitize=hwaddress} and disabled by default when using
16008@option{-fsanitize=kernel-hwaddress}.
16009To disable instrumentation of such variables use
16010@option{--param hwasan-instrument-allocas=0}, and to enable it use
16011@option{--param hwasan-instrument-allocas=1}.
16012
16013@item hwasan-instrument-reads
16014Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
16015default for both @option{-fsanitize=hwaddress} and
16016@option{-fsanitize=kernel-hwaddress}.
16017To disable checking memory reads use
16018@option{--param hwasan-instrument-reads=0}.
16019
16020@item hwasan-instrument-writes
16021Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
16022default for both @option{-fsanitize=hwaddress} and
16023@option{-fsanitize=kernel-hwaddress}.
16024To disable checking memory writes use
16025@option{--param hwasan-instrument-writes=0}.
16026
16027@item hwasan-instrument-mem-intrinsics
16028Enable hwasan instrumentation of builtin functions. Instrumentation of these
16029builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
16030and @option{-fsanitize=kernel-hwaddress}.
16031To disable instrumentation of builtin functions use
16032@option{--param hwasan-instrument-mem-intrinsics=0}.
16033
16034@item use-after-scope-direct-emission-threshold
16035If the size of a local variable in bytes is smaller or equal to this
16036number, directly poison (or unpoison) shadow memory instead of using
16037run-time callbacks.
16038
16039@item tsan-distinguish-volatile
16040Emit special instrumentation for accesses to volatiles.
16041
16042@item tsan-instrument-func-entry-exit
16043Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
16044
16045@item max-fsm-thread-path-insns
16046Maximum number of instructions to copy when duplicating blocks on a
16047finite state automaton jump thread path.
16048
16049@item threader-debug
16050threader-debug=[none|all] Enables verbose dumping of the threader solver.
16051
16052@item parloops-chunk-size
16053Chunk size of omp schedule for loops parallelized by parloops.
16054
16055@item parloops-schedule
16056Schedule type of omp schedule for loops parallelized by parloops (static,
16057dynamic, guided, auto, runtime).
16058
16059@item parloops-min-per-thread
16060The minimum number of iterations per thread of an innermost parallelized
16061loop for which the parallelized variant is preferred over the single threaded
16062one. Note that for a parallelized loop nest the
16063minimum number of iterations of the outermost loop per thread is two.
16064
16065@item max-ssa-name-query-depth
16066Maximum depth of recursion when querying properties of SSA names in things
16067like fold routines. One level of recursion corresponds to following a
16068use-def chain.
16069
16070@item max-speculative-devirt-maydefs
16071The maximum number of may-defs we analyze when looking for a must-def
16072specifying the dynamic type of an object that invokes a virtual call
16073we may be able to devirtualize speculatively.
16074
d77de738
ML
16075@item ranger-debug
16076Specifies the type of debug output to be issued for ranges.
16077
d77de738
ML
16078@item unroll-jam-min-percent
16079The minimum percentage of memory references that must be optimized
16080away for the unroll-and-jam transformation to be considered profitable.
16081
16082@item unroll-jam-max-unroll
16083The maximum number of times the outer loop should be unrolled by
16084the unroll-and-jam transformation.
16085
16086@item max-rtl-if-conversion-unpredictable-cost
16087Maximum permissible cost for the sequence that would be generated
16088by the RTL if-conversion pass for a branch that is considered unpredictable.
16089
16090@item max-variable-expansions-in-unroller
16091If @option{-fvariable-expansion-in-unroller} is used, the maximum number
16092of times that an individual variable will be expanded during loop unrolling.
16093
16094@item partial-inlining-entry-probability
16095Maximum probability of the entry BB of split region
16096(in percent relative to entry BB of the function)
16097to make partial inlining happen.
16098
16099@item max-tracked-strlens
16100Maximum number of strings for which strlen optimization pass will
16101track string lengths.
16102
16103@item gcse-after-reload-partial-fraction
16104The threshold ratio for performing partial redundancy
16105elimination after reload.
16106
16107@item gcse-after-reload-critical-fraction
16108The threshold ratio of critical edges execution count that
16109permit performing redundancy elimination after reload.
16110
16111@item max-loop-header-insns
16112The maximum number of insns in loop header duplicated
16113by the copy loop headers pass.
16114
16115@item vect-epilogues-nomask
16116Enable loop epilogue vectorization using smaller vector size.
16117
16118@item vect-partial-vector-usage
16119Controls when the loop vectorizer considers using partial vector loads
16120and stores as an alternative to falling back to scalar code. 0 stops
16121the vectorizer from ever using partial vector loads and stores. 1 allows
16122partial vector loads and stores if vectorization removes the need for the
16123code to iterate. 2 allows partial vector loads and stores in all loops.
16124The parameter only has an effect on targets that support partial
16125vector loads and stores.
16126
16127@item vect-inner-loop-cost-factor
16128The maximum factor which the loop vectorizer applies to the cost of statements
16129in an inner loop relative to the loop being vectorized. The factor applied
16130is the maximum of the estimated number of iterations of the inner loop and
16131this parameter. The default value of this parameter is 50.
16132
16133@item vect-induction-float
16134Enable loop vectorization of floating point inductions.
16135
cbe32d38
ML
16136@item vrp-sparse-threshold
16137Maximum number of basic blocks before VRP uses a sparse bitmap cache.
16138
16139@item vrp-switch-limit
16140Maximum number of outgoing edges in a switch before VRP will not process it.
16141
16142@item vrp-vector-threshold
16143Maximum number of basic blocks for VRP to use a basic cache vector.
16144
d77de738
ML
16145@item avoid-fma-max-bits
16146Maximum number of bits for which we avoid creating FMAs.
16147
16148@item sms-loop-average-count-threshold
16149A threshold on the average loop count considered by the swing modulo scheduler.
16150
16151@item sms-dfa-history
16152The number of cycles the swing modulo scheduler considers when checking
16153conflicts using DFA.
16154
16155@item graphite-allow-codegen-errors
16156Whether codegen errors should be ICEs when @option{-fchecking}.
16157
16158@item sms-max-ii-factor
16159A factor for tuning the upper bound that swing modulo scheduler
16160uses for scheduling a loop.
16161
16162@item lra-max-considered-reload-pseudos
16163The max number of reload pseudos which are considered during
16164spilling a non-reload pseudo.
16165
16166@item max-pow-sqrt-depth
16167Maximum depth of sqrt chains to use when synthesizing exponentiation
16168by a real constant.
16169
16170@item max-dse-active-local-stores
16171Maximum number of active local stores in RTL dead store elimination.
16172
16173@item asan-instrument-allocas
16174Enable asan allocas/VLAs protection.
16175
16176@item max-iterations-computation-cost
16177Bound on the cost of an expression to compute the number of iterations.
16178
16179@item max-isl-operations
16180Maximum number of isl operations, 0 means unlimited.
16181
16182@item graphite-max-arrays-per-scop
16183Maximum number of arrays per scop.
16184
16185@item max-vartrack-reverse-op-size
16186Max. size of loc list for which reverse ops should be added.
16187
16188@item fsm-scale-path-stmts
16189Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
16190crossing a loop backedge when comparing to
16191@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
16192
16193@item uninit-control-dep-attempts
16194Maximum number of nested calls to search for control dependencies
16195during uninitialized variable analysis.
16196
d77de738
ML
16197@item sched-autopref-queue-depth
16198Hardware autoprefetcher scheduler model control flag.
16199Number of lookahead cycles the model looks into; at '
16200' only enable instruction sorting heuristic.
16201
16202@item loop-versioning-max-inner-insns
16203The maximum number of instructions that an inner loop can have
16204before the loop versioning pass considers it too big to copy.
16205
16206@item loop-versioning-max-outer-insns
16207The maximum number of instructions that an outer loop can have
16208before the loop versioning pass considers it too big to copy,
16209discounting any instructions in inner loops that directly benefit
16210from versioning.
16211
16212@item ssa-name-def-chain-limit
16213The maximum number of SSA_NAME assignments to follow in determining
16214a property of a variable such as its value. This limits the number
16215of iterations or recursive calls GCC performs when optimizing certain
16216statements or when determining their validity prior to issuing
16217diagnostics.
16218
16219@item store-merging-max-size
16220Maximum size of a single store merging region in bytes.
16221
16222@item hash-table-verification-limit
16223The number of elements for which hash table verification is done
16224for each searched element.
16225
16226@item max-find-base-term-values
16227Maximum number of VALUEs handled during a single find_base_term call.
16228
16229@item analyzer-max-enodes-per-program-point
16230The maximum number of exploded nodes per program point within
16231the analyzer, before terminating analysis of that point.
16232
16233@item analyzer-max-constraints
16234The maximum number of constraints per state.
16235
16236@item analyzer-min-snodes-for-call-summary
16237The minimum number of supernodes within a function for the
16238analyzer to consider summarizing its effects at call sites.
16239
16240@item analyzer-max-enodes-for-full-dump
16241The maximum depth of exploded nodes that should appear in a dot dump
16242before switching to a less verbose format.
16243
16244@item analyzer-max-recursion-depth
16245The maximum number of times a callsite can appear in a call stack
16246within the analyzer, before terminating analysis of a call that would
16247recurse deeper.
16248
16249@item analyzer-max-svalue-depth
16250The maximum depth of a symbolic value, before approximating
16251the value as unknown.
16252
16253@item analyzer-max-infeasible-edges
16254The maximum number of infeasible edges to reject before declaring
16255a diagnostic as infeasible.
16256
16257@item gimple-fe-computed-hot-bb-threshold
16258The number of executions of a basic block which is considered hot.
16259The parameter is used only in GIMPLE FE.
16260
16261@item analyzer-bb-explosion-factor
16262The maximum number of 'after supernode' exploded nodes within the analyzer
16263per supernode, before terminating analysis.
16264
16265@item ranger-logical-depth
16266Maximum depth of logical expression evaluation ranger will look through
16267when evaluating outgoing edge ranges.
16268
9fd6d83a
ML
16269@item ranger-recompute-depth
16270Maximum depth of instruction chains to consider for recomputation
16271in the outgoing range calculator.
16272
d77de738
ML
16273@item relation-block-limit
16274Maximum number of relations the oracle will register in a basic block.
16275
16276@item min-pagesize
16277Minimum page size for warning purposes.
16278
16279@item openacc-kernels
16280Specify mode of OpenACC `kernels' constructs handling.
16281With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16282constructs are decomposed into parts, a sequence of compute
16283constructs, each then handled individually.
16284This is work in progress.
16285With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16286constructs are handled by the @samp{parloops} pass, en bloc.
16287This is the current default.
16288
16289@item openacc-privatization
4ace81b6
SL
16290Control whether the @option{-fopt-info-omp-note} and applicable
16291@option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
d77de738
ML
16292With @option{--param=openacc-privatization=quiet}, don't diagnose.
16293This is the current default.
16294With @option{--param=openacc-privatization=noisy}, do diagnose.
16295
16296@end table
16297
16298The following choices of @var{name} are available on AArch64 targets:
16299
16300@table @gcctabopt
16301@item aarch64-sve-compare-costs
16302When vectorizing for SVE, consider using ``unpacked'' vectors for
16303smaller elements and use the cost model to pick the cheapest approach.
16304Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16305
16306Using unpacked vectors includes storing smaller elements in larger
16307containers and accessing elements with extending loads and truncating
16308stores.
16309
16310@item aarch64-float-recp-precision
16311The number of Newton iterations for calculating the reciprocal for float type.
16312The precision of division is proportional to this param when division
16313approximation is enabled. The default value is 1.
16314
16315@item aarch64-double-recp-precision
16316The number of Newton iterations for calculating the reciprocal for double type.
16317The precision of division is propotional to this param when division
16318approximation is enabled. The default value is 2.
16319
16320@item aarch64-autovec-preference
16321Force an ISA selection strategy for auto-vectorization. Accepts values from
163220 to 4, inclusive.
16323@table @samp
16324@item 0
16325Use the default heuristics.
16326@item 1
16327Use only Advanced SIMD for auto-vectorization.
16328@item 2
16329Use only SVE for auto-vectorization.
16330@item 3
16331Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16332deemed equal.
16333@item 4
16334Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16335@end table
16336The default value is 0.
16337
16338@item aarch64-loop-vect-issue-rate-niters
16339The tuning for some AArch64 CPUs tries to take both latencies and issue
16340rates into account when deciding whether a loop should be vectorized
16341using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16342If this parameter is set to @var{n}, GCC will not use this heuristic
16343for loops that are known to execute in fewer than @var{n} Advanced
16344SIMD iterations.
16345
16346@item aarch64-vect-unroll-limit
16347The vectorizer will use available tuning information to determine whether it
16348would be beneficial to unroll the main vectorized loop and by how much. This
16349parameter set's the upper bound of how much the vectorizer will unroll the main
16350loop. The default value is four.
16351
16352@end table
16353
16354The following choices of @var{name} are available on i386 and x86_64 targets:
16355
16356@table @gcctabopt
16357@item x86-stlf-window-ninsns
16358Instructions number above which STFL stall penalty can be compensated.
16359
60101899
RB
16360@item x86-stv-max-visits
16361The maximum number of use and def visits when discovering a STV chain before
16362the discovery is aborted.
16363
d77de738
ML
16364@end table
16365
16366@end table
16367
16368@node Instrumentation Options
16369@section Program Instrumentation Options
16370@cindex instrumentation options
16371@cindex program instrumentation options
16372@cindex run-time error checking options
16373@cindex profiling options
16374@cindex options, program instrumentation
16375@cindex options, run-time error checking
16376@cindex options, profiling
16377
16378GCC supports a number of command-line options that control adding
16379run-time instrumentation to the code it normally generates.
16380For example, one purpose of instrumentation is collect profiling
16381statistics for use in finding program hot spots, code coverage
16382analysis, or profile-guided optimizations.
16383Another class of program instrumentation is adding run-time checking
16384to detect programming errors like invalid pointer
16385dereferences or out-of-bounds array accesses, as well as deliberately
16386hostile attacks such as stack smashing or C++ vtable hijacking.
16387There is also a general hook which can be used to implement other
16388forms of tracing or function-level instrumentation for debug or
16389program analysis purposes.
16390
16391@table @gcctabopt
16392@cindex @command{prof}
16393@cindex @command{gprof}
d77de738
ML
16394@opindex p
16395@opindex pg
ddf6fe37
AA
16396@item -p
16397@itemx -pg
d77de738
ML
16398Generate extra code to write profile information suitable for the
16399analysis program @command{prof} (for @option{-p}) or @command{gprof}
16400(for @option{-pg}). You must use this option when compiling
16401the source files you want data about, and you must also use it when
16402linking.
16403
16404You can use the function attribute @code{no_instrument_function} to
16405suppress profiling of individual functions when compiling with these options.
16406@xref{Common Function Attributes}.
16407
d77de738 16408@opindex fprofile-arcs
ddf6fe37 16409@item -fprofile-arcs
d77de738
ML
16410Add code so that program flow @dfn{arcs} are instrumented. During
16411execution the program records how many times each branch and call is
16412executed and how many times it is taken or returns. On targets that support
16413constructors with priority support, profiling properly handles constructors,
16414destructors and C++ constructors (and destructors) of classes which are used
16415as a type of a global variable.
16416
16417When the compiled
16418program exits it saves this data to a file called
16419@file{@var{auxname}.gcda} for each source file. The data may be used for
16420profile-directed optimizations (@option{-fbranch-probabilities}), or for
16421test coverage analysis (@option{-ftest-coverage}). Each object file's
16422@var{auxname} is generated from the name of the output file, if
16423explicitly specified and it is not the final executable, otherwise it is
16424the basename of the source file. In both cases any suffix is removed
16425(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16426@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16427
16428Note that if a command line directly links source files, the corresponding
16429@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16430E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16431@file{binary-b.gcda} files.
16432
16433@xref{Cross-profiling}.
16434
16435@cindex @command{gcov}
d77de738 16436@opindex coverage
ddf6fe37 16437@item --coverage
d77de738
ML
16438
16439This option is used to compile and link code instrumented for coverage
16440analysis. The option is a synonym for @option{-fprofile-arcs}
16441@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16442linking). See the documentation for those options for more details.
16443
16444@itemize
16445
16446@item
16447Compile the source files with @option{-fprofile-arcs} plus optimization
16448and code generation options. For test coverage analysis, use the
16449additional @option{-ftest-coverage} option. You do not need to profile
16450every source file in a program.
16451
16452@item
16453Compile the source files additionally with @option{-fprofile-abs-path}
16454to create absolute path names in the @file{.gcno} files. This allows
16455@command{gcov} to find the correct sources in projects where compilations
16456occur with different working directories.
16457
16458@item
16459Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16460(the latter implies the former).
16461
16462@item
16463Run the program on a representative workload to generate the arc profile
16464information. This may be repeated any number of times. You can run
16465concurrent instances of your program, and provided that the file system
16466supports locking, the data files will be correctly updated. Unless
16467a strict ISO C dialect option is in effect, @code{fork} calls are
16468detected and correctly handled without double counting.
16469
16470Moreover, an object file can be recompiled multiple times
16471and the corresponding @file{.gcda} file merges as long as
16472the source file and the compiler options are unchanged.
16473
16474@item
16475For profile-directed optimizations, compile the source files again with
16476the same optimization and code generation options plus
16477@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16478Control Optimization}).
16479
16480@item
16481For test coverage analysis, use @command{gcov} to produce human readable
16482information from the @file{.gcno} and @file{.gcda} files. Refer to the
16483@command{gcov} documentation for further information.
16484
16485@end itemize
16486
16487With @option{-fprofile-arcs}, for each function of your program GCC
16488creates a program flow graph, then finds a spanning tree for the graph.
16489Only arcs that are not on the spanning tree have to be instrumented: the
16490compiler adds code to count the number of times that these arcs are
16491executed. When an arc is the only exit or only entrance to a block, the
16492instrumentation code can be added to the block; otherwise, a new basic
16493block must be created to hold the instrumentation code.
16494
16495@need 2000
d77de738 16496@opindex ftest-coverage
ddf6fe37 16497@item -ftest-coverage
d77de738
ML
16498Produce a notes file that the @command{gcov} code-coverage utility
16499(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16500show program coverage. Each source file's note file is called
16501@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16502above for a description of @var{auxname} and instructions on how to
16503generate test coverage data. Coverage data matches the source files
16504more closely if you do not optimize.
16505
d77de738 16506@opindex fprofile-abs-path
ddf6fe37 16507@item -fprofile-abs-path
d77de738
ML
16508Automatically convert relative source file names to absolute path names
16509in the @file{.gcno} files. This allows @command{gcov} to find the correct
16510sources in projects where compilations occur with different working
16511directories.
16512
d77de738 16513@opindex fprofile-dir
ddf6fe37 16514@item -fprofile-dir=@var{path}
d77de738
ML
16515
16516Set the directory to search for the profile data files in to @var{path}.
16517This option affects only the profile data generated by
16518@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16519and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16520and its related options. Both absolute and relative paths can be used.
16521By default, GCC uses the current directory as @var{path}, thus the
16522profile data file appears in the same directory as the object file.
16523In order to prevent the file name clashing, if the object file name is
16524not an absolute path, we mangle the absolute path of the
16525@file{@var{sourcename}.gcda} file and use it as the file name of a
16526@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16527See similar option @option{-fprofile-note}.
16528
16529When an executable is run in a massive parallel environment, it is recommended
16530to save profile to different folders. That can be done with variables
16531in @var{path} that are exported during run-time:
16532
16533@table @gcctabopt
16534
16535@item %p
16536process ID.
16537
16538@item %q@{VAR@}
16539value of environment variable @var{VAR}
16540
16541@end table
16542
ddf6fe37 16543@opindex fprofile-generate
d77de738
ML
16544@item -fprofile-generate
16545@itemx -fprofile-generate=@var{path}
d77de738
ML
16546
16547Enable options usually used for instrumenting application to produce
16548profile useful for later recompilation with profile feedback based
16549optimization. You must use @option{-fprofile-generate} both when
16550compiling and when linking your program.
16551
16552The following options are enabled:
16553@option{-fprofile-arcs}, @option{-fprofile-values},
16554@option{-finline-functions}, and @option{-fipa-bit-cp}.
16555
16556If @var{path} is specified, GCC looks at the @var{path} to find
16557the profile feedback data files. See @option{-fprofile-dir}.
16558
16559To optimize the program based on the collected profile information, use
16560@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16561
ddf6fe37 16562@opindex fprofile-info-section
d77de738
ML
16563@item -fprofile-info-section
16564@itemx -fprofile-info-section=@var{name}
d77de738
ML
16565
16566Register the profile information in the specified section instead of using a
16567constructor/destructor. The section name is @var{name} if it is specified,
16568otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16569profile information generated by @option{-fprofile-arcs} is placed in the
16570specified section for each translation unit. This option disables the profile
16571information registration through a constructor and it disables the profile
16572information processing through a destructor. This option is not intended to be
16573used in hosted environments such as GNU/Linux. It targets freestanding
16574environments (for example embedded systems) with limited resources which do not
16575support constructors/destructors or the C library file I/O.
16576
16577The linker could collect the input sections in a continuous memory block and
16578define start and end symbols. A GNU linker script example which defines a
16579linker output section follows:
16580
16581@smallexample
16582 .gcov_info :
16583 @{
16584 PROVIDE (__gcov_info_start = .);
16585 KEEP (*(.gcov_info))
16586 PROVIDE (__gcov_info_end = .);
16587 @}
16588@end smallexample
16589
16590The program could dump the profiling information registered in this linker set
16591for example like this:
16592
16593@smallexample
16594#include <gcov.h>
16595#include <stdio.h>
16596#include <stdlib.h>
16597
16598extern const struct gcov_info *const __gcov_info_start[];
16599extern const struct gcov_info *const __gcov_info_end[];
16600
16601static void
16602dump (const void *d, unsigned n, void *arg)
16603@{
16604 const unsigned char *c = d;
16605
16606 for (unsigned i = 0; i < n; ++i)
16607 printf ("%02x", c[i]);
16608@}
16609
16610static void
16611filename (const char *f, void *arg)
16612@{
16613 __gcov_filename_to_gcfn (f, dump, arg );
16614@}
16615
16616static void *
16617allocate (unsigned length, void *arg)
16618@{
16619 return malloc (length);
16620@}
16621
16622static void
16623dump_gcov_info (void)
16624@{
16625 const struct gcov_info *const *info = __gcov_info_start;
16626 const struct gcov_info *const *end = __gcov_info_end;
16627
16628 /* Obfuscate variable to prevent compiler optimizations. */
16629 __asm__ ("" : "+r" (info));
16630
16631 while (info != end)
16632 @{
16633 void *arg = NULL;
16634 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16635 putchar ('\n');
16636 ++info;
16637 @}
16638@}
16639
16640int
16641main (void)
16642@{
16643 dump_gcov_info ();
16644 return 0;
16645@}
16646@end smallexample
16647
16648The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16649deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16650@code{__gcov_info_to_gcda} functions and merge the profile information into
16651@file{.gcda} files on the host filesystem.
16652
d77de738 16653@opindex fprofile-note
ddf6fe37 16654@item -fprofile-note=@var{path}
d77de738
ML
16655
16656If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16657location. If you combine the option with multiple source files,
16658the @file{.gcno} file will be overwritten.
16659
d77de738 16660@opindex fprofile-prefix-path
ddf6fe37 16661@item -fprofile-prefix-path=@var{path}
d77de738
ML
16662
16663This option can be used in combination with
16664@option{profile-generate=}@var{profile_dir} and
16665@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16666directory of built source tree. By default @var{profile_dir} will contain
16667files with mangled absolute paths of all object files in the built project.
16668This is not desirable when directory used to build the instrumented binary
16669differs from the directory used to build the binary optimized with profile
16670feedback because the profile data will not be found during the optimized build.
16671In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16672pointing to the base directory of the build can be used to strip the irrelevant
16673part of the path and keep all file names relative to the main build directory.
16674
d77de738 16675@opindex fprofile-prefix-map
ddf6fe37 16676@item -fprofile-prefix-map=@var{old}=@var{new}
d77de738
ML
16677When compiling files residing in directory @file{@var{old}}, record
16678profiling information (with @option{--coverage})
16679describing them as if the files resided in
16680directory @file{@var{new}} instead.
2eb0191a 16681See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
d77de738 16682
d77de738 16683@opindex fprofile-update
ddf6fe37 16684@item -fprofile-update=@var{method}
d77de738
ML
16685
16686Alter the update method for an application instrumented for profile
16687feedback based optimization. The @var{method} argument should be one of
16688@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16689The first one is useful for single-threaded applications,
16690while the second one prevents profile corruption by emitting thread-safe code.
16691
16692@strong{Warning:} When an application does not properly join all threads
16693(or creates an detached thread), a profile file can be still corrupted.
16694
16695Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16696when supported by a target, or to @samp{single} otherwise. The GCC driver
16697automatically selects @samp{prefer-atomic} when @option{-pthread}
16698is present in the command line.
16699
d77de738 16700@opindex fprofile-filter-files
ddf6fe37 16701@item -fprofile-filter-files=@var{regex}
d77de738
ML
16702
16703Instrument only functions from files whose name matches
16704any of the regular expressions (separated by semi-colons).
16705
16706For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16707only @file{main.c} and all C files starting with 'module'.
16708
d77de738 16709@opindex fprofile-exclude-files
ddf6fe37 16710@item -fprofile-exclude-files=@var{regex}
d77de738
ML
16711
16712Instrument only functions from files whose name does not match
16713any of the regular expressions (separated by semi-colons).
16714
16715For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16716of all files that are located in the @file{/usr/} folder.
16717
d77de738 16718@opindex fprofile-reproducible
ddf6fe37 16719@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
d77de738
ML
16720Control level of reproducibility of profile gathered by
16721@code{-fprofile-generate}. This makes it possible to rebuild program
16722with same outcome which is useful, for example, for distribution
16723packages.
16724
16725With @option{-fprofile-reproducible=serial} the profile gathered by
16726@option{-fprofile-generate} is reproducible provided the trained program
16727behaves the same at each invocation of the train run, it is not
16728multi-threaded and profile data streaming is always done in the same
16729order. Note that profile streaming happens at the end of program run but
16730also before @code{fork} function is invoked.
16731
16732Note that it is quite common that execution counts of some part of
16733programs depends, for example, on length of temporary file names or
16734memory space randomization (that may affect hash-table collision rate).
16735Such non-reproducible part of programs may be annotated by
16736@code{no_instrument_function} function attribute. @command{gcov-dump} with
16737@option{-l} can be used to dump gathered data and verify that they are
16738indeed reproducible.
16739
16740With @option{-fprofile-reproducible=parallel-runs} collected profile
16741stays reproducible regardless the order of streaming of the data into
16742gcda files. This setting makes it possible to run multiple instances of
16743instrumented program in parallel (such as with @code{make -j}). This
16744reduces quality of gathered data, in particular of indirect call
16745profiling.
16746
d77de738 16747@opindex fsanitize=address
ddf6fe37 16748@item -fsanitize=address
d77de738
ML
16749Enable AddressSanitizer, a fast memory error detector.
16750Memory access instructions are instrumented to detect
16751out-of-bounds and use-after-free bugs.
16752The option enables @option{-fsanitize-address-use-after-scope}.
16753See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16754more details. The run-time behavior can be influenced using the
16755@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16756the available options are shown at startup of the instrumented program. See
16757@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16758for a list of supported options.
16759The option cannot be combined with @option{-fsanitize=thread} or
16760@option{-fsanitize=hwaddress}. Note that the only target
16761@option{-fsanitize=hwaddress} is currently supported on is AArch64.
16762
6a07798c
MP
16763To get more accurate stack traces, it is possible to use options such as
16764@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
16765most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
16766optimizing sibling and tail recursive calls; this option is implicit for
16767@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
16768disables Identical Code Folding for functions). Since multiple runs of the
16769program may yield backtraces with different addresses due to ASLR (Address
16770Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
16771this can be achieved with @samp{setarch `uname -m` -R ./prog}.
16772
d77de738 16773@opindex fsanitize=kernel-address
f33d7a88 16774@item -fsanitize=kernel-address
d77de738 16775Enable AddressSanitizer for Linux kernel.
a0bf71be 16776See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738 16777
d77de738 16778@opindex fsanitize=hwaddress
f33d7a88 16779@item -fsanitize=hwaddress
d77de738
ML
16780Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16781ignore the top byte of a pointer to allow the detection of memory errors with
16782a low memory overhead.
16783Memory access instructions are instrumented to detect out-of-bounds and
16784use-after-free bugs.
16785The option enables @option{-fsanitize-address-use-after-scope}.
16786See
16787@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
16788for more details. The run-time behavior can be influenced using the
16789@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
16790the available options are shown at startup of the instrumented program.
16791The option cannot be combined with @option{-fsanitize=thread} or
16792@option{-fsanitize=address}, and is currently only available on AArch64.
16793
d77de738 16794@opindex fsanitize=kernel-hwaddress
ddf6fe37 16795@item -fsanitize=kernel-hwaddress
d77de738
ML
16796Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
16797Similar to @option{-fsanitize=kernel-address} but using an alternate
16798instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
16799instrumentation differences necessary for compiling the Linux kernel.
16800These differences are to avoid hwasan library initialization calls and to
16801account for the stack pointer having a different value in its top byte.
16802
16803@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
16804Instrumenting the stack and alloca calls are not on by default but are still
16805possible by specifying the command-line options
16806@option{--param hwasan-instrument-stack=1} and
16807@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
16808tag is not implemented for kernel instrumentation.
16809
d77de738 16810@opindex fsanitize=pointer-compare
ddf6fe37 16811@item -fsanitize=pointer-compare
d77de738
ML
16812Instrument comparison operation (<, <=, >, >=) with pointer operands.
16813The option must be combined with either @option{-fsanitize=kernel-address} or
16814@option{-fsanitize=address}
16815The option cannot be combined with @option{-fsanitize=thread}.
16816Note: By default the check is disabled at run time. To enable it,
16817add @code{detect_invalid_pointer_pairs=2} to the environment variable
16818@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16819invalid operation only when both pointers are non-null.
16820
d77de738 16821@opindex fsanitize=pointer-subtract
ddf6fe37 16822@item -fsanitize=pointer-subtract
d77de738
ML
16823Instrument subtraction with pointer operands.
16824The option must be combined with either @option{-fsanitize=kernel-address} or
16825@option{-fsanitize=address}
16826The option cannot be combined with @option{-fsanitize=thread}.
16827Note: By default the check is disabled at run time. To enable it,
16828add @code{detect_invalid_pointer_pairs=2} to the environment variable
16829@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16830invalid operation only when both pointers are non-null.
16831
d77de738 16832@opindex fsanitize=shadow-call-stack
ddf6fe37 16833@item -fsanitize=shadow-call-stack
d77de738
ML
16834Enable ShadowCallStack, a security enhancement mechanism used to protect
16835programs against return address overwrites (e.g. stack buffer overflows.)
16836It works by saving a function's return address to a separately allocated
16837shadow call stack in the function prologue and restoring the return address
16838from the shadow call stack in the function epilogue. Instrumentation only
16839occurs in functions that need to save the return address to the stack.
16840
16841Currently it only supports the aarch64 platform. It is specifically
16842designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
16843For the user space programs, runtime support is not currently provided
16844in libc and libgcc. Users who want to use this feature in user space need
16845to provide their own support for the runtime. It should be noted that
16846this may cause the ABI rules to be broken.
16847
16848On aarch64, the instrumentation makes use of the platform register @code{x18}.
16849This generally means that any code that may run on the same thread as code
16850compiled with ShadowCallStack must be compiled with the flag
16851@option{-ffixed-x18}, otherwise functions compiled without
16852@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
16853stack pointer.
16854
16855Also, because there is no userspace runtime support, code compiled with
16856ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
16857to turn off exceptions.
16858
16859See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
16860details.
16861
d77de738 16862@opindex fsanitize=thread
ddf6fe37 16863@item -fsanitize=thread
d77de738
ML
16864Enable ThreadSanitizer, a fast data race detector.
16865Memory access instructions are instrumented to detect
16866data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
16867details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
16868environment variable; see
16869@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
16870supported options.
16871The option cannot be combined with @option{-fsanitize=address},
16872@option{-fsanitize=leak}.
16873
16874Note that sanitized atomic builtins cannot throw exceptions when
16875operating on invalid memory addresses with non-call exceptions
16876(@option{-fnon-call-exceptions}).
16877
d77de738 16878@opindex fsanitize=leak
ddf6fe37 16879@item -fsanitize=leak
d77de738 16880Enable LeakSanitizer, a memory leak detector.
c5c4fdac
JG
16881This option only matters for linking of executables.
16882The executable is linked against a library that overrides @code{malloc}
d77de738
ML
16883and other allocator functions. See
16884@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
16885details. The run-time behavior can be influenced using the
16886@env{LSAN_OPTIONS} environment variable.
16887The option cannot be combined with @option{-fsanitize=thread}.
16888
d77de738 16889@opindex fsanitize=undefined
ddf6fe37 16890@item -fsanitize=undefined
d77de738
ML
16891Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
16892Various computations are instrumented to detect undefined behavior
16893at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
16894@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
16895
16896@table @gcctabopt
16897
d77de738 16898@opindex fsanitize=shift
ddf6fe37 16899@item -fsanitize=shift
d77de738
ML
16900This option enables checking that the result of a shift operation is
16901not undefined. Note that what exactly is considered undefined differs
16902slightly between C and C++, as well as between ISO C90 and C99, etc.
16903This option has two suboptions, @option{-fsanitize=shift-base} and
16904@option{-fsanitize=shift-exponent}.
16905
d77de738 16906@opindex fsanitize=shift-exponent
ddf6fe37 16907@item -fsanitize=shift-exponent
d77de738
ML
16908This option enables checking that the second argument of a shift operation
16909is not negative and is smaller than the precision of the promoted first
16910argument.
16911
d77de738 16912@opindex fsanitize=shift-base
ddf6fe37 16913@item -fsanitize=shift-base
d77de738
ML
16914If the second argument of a shift operation is within range, check that the
16915result of a shift operation is not undefined. Note that what exactly is
16916considered undefined differs slightly between C and C++, as well as between
16917ISO C90 and C99, etc.
16918
d77de738 16919@opindex fsanitize=integer-divide-by-zero
ddf6fe37 16920@item -fsanitize=integer-divide-by-zero
d77de738
ML
16921Detect integer division by zero.
16922
d77de738 16923@opindex fsanitize=unreachable
ddf6fe37 16924@item -fsanitize=unreachable
d77de738
ML
16925With this option, the compiler turns the @code{__builtin_unreachable}
16926call into a diagnostics message call instead. When reaching the
16927@code{__builtin_unreachable} call, the behavior is undefined.
16928
d77de738 16929@opindex fsanitize=vla-bound
ddf6fe37 16930@item -fsanitize=vla-bound
d77de738
ML
16931This option instructs the compiler to check that the size of a variable
16932length array is positive.
16933
d77de738 16934@opindex fsanitize=null
ddf6fe37 16935@item -fsanitize=null
d77de738
ML
16936This option enables pointer checking. Particularly, the application
16937built with this option turned on will issue an error message when it
16938tries to dereference a NULL pointer, or if a reference (possibly an
16939rvalue reference) is bound to a NULL pointer, or if a method is invoked
16940on an object pointed by a NULL pointer.
16941
d77de738 16942@opindex fsanitize=return
ddf6fe37 16943@item -fsanitize=return
d77de738
ML
16944This option enables return statement checking. Programs
16945built with this option turned on will issue an error message
16946when the end of a non-void function is reached without actually
16947returning a value. This option works in C++ only.
16948
d77de738 16949@opindex fsanitize=signed-integer-overflow
ddf6fe37 16950@item -fsanitize=signed-integer-overflow
d77de738
ML
16951This option enables signed integer overflow checking. We check that
16952the result of @code{+}, @code{*}, and both unary and binary @code{-}
16953does not overflow in the signed arithmetics. This also detects
16954@code{INT_MIN / -1} signed division. Note, integer promotion
16955rules must be taken into account. That is, the following is not an
16956overflow:
16957@smallexample
16958signed char a = SCHAR_MAX;
16959a++;
16960@end smallexample
16961
d77de738 16962@opindex fsanitize=bounds
ddf6fe37 16963@item -fsanitize=bounds
d77de738
ML
16964This option enables instrumentation of array bounds. Various out of bounds
16965accesses are detected. Flexible array members, flexible array member-like
c7728805
JJ
16966arrays, and initializers of variables with static storage are not
16967instrumented, with the exception of flexible array member-like arrays
16968for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
16969options or @code{strict_flex_array} attributes say they shouldn't be treated
16970like flexible array member-like arrays.
d77de738 16971
d77de738 16972@opindex fsanitize=bounds-strict
ddf6fe37 16973@item -fsanitize=bounds-strict
d77de738 16974This option enables strict instrumentation of array bounds. Most out of bounds
c7728805
JJ
16975accesses are detected, including flexible array member-like arrays.
16976Initializers of variables with static storage are not instrumented.
d77de738 16977
d77de738 16978@opindex fsanitize=alignment
ddf6fe37 16979@item -fsanitize=alignment
d77de738
ML
16980
16981This option enables checking of alignment of pointers when they are
16982dereferenced, or when a reference is bound to insufficiently aligned target,
16983or when a method or constructor is invoked on insufficiently aligned object.
16984
d77de738 16985@opindex fsanitize=object-size
ddf6fe37 16986@item -fsanitize=object-size
d77de738 16987This option enables instrumentation of memory references using the
7283380a
SP
16988@code{__builtin_dynamic_object_size} function. Various out of bounds
16989pointer accesses are detected.
d77de738 16990
d77de738 16991@opindex fsanitize=float-divide-by-zero
ddf6fe37 16992@item -fsanitize=float-divide-by-zero
d77de738
ML
16993Detect floating-point division by zero. Unlike other similar options,
16994@option{-fsanitize=float-divide-by-zero} is not enabled by
16995@option{-fsanitize=undefined}, since floating-point division by zero can
16996be a legitimate way of obtaining infinities and NaNs.
16997
d77de738 16998@opindex fsanitize=float-cast-overflow
ddf6fe37 16999@item -fsanitize=float-cast-overflow
d77de738
ML
17000This option enables floating-point type to integer conversion checking.
17001We check that the result of the conversion does not overflow.
17002Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
17003not enabled by @option{-fsanitize=undefined}.
17004This option does not work well with @code{FE_INVALID} exceptions enabled.
17005
d77de738 17006@opindex fsanitize=nonnull-attribute
ddf6fe37 17007@item -fsanitize=nonnull-attribute
d77de738
ML
17008
17009This option enables instrumentation of calls, checking whether null values
17010are not passed to arguments marked as requiring a non-null value by the
17011@code{nonnull} function attribute.
17012
d77de738 17013@opindex fsanitize=returns-nonnull-attribute
ddf6fe37 17014@item -fsanitize=returns-nonnull-attribute
d77de738
ML
17015
17016This option enables instrumentation of return statements in functions
17017marked with @code{returns_nonnull} function attribute, to detect returning
17018of null values from such functions.
17019
d77de738 17020@opindex fsanitize=bool
ddf6fe37 17021@item -fsanitize=bool
d77de738
ML
17022
17023This option enables instrumentation of loads from bool. If a value other
17024than 0/1 is loaded, a run-time error is issued.
17025
d77de738 17026@opindex fsanitize=enum
ddf6fe37 17027@item -fsanitize=enum
d77de738
ML
17028
17029This option enables instrumentation of loads from an enum type. If
17030a value outside the range of values for the enum type is loaded,
17031a run-time error is issued.
17032
d77de738 17033@opindex fsanitize=vptr
ddf6fe37 17034@item -fsanitize=vptr
d77de738
ML
17035
17036This option enables instrumentation of C++ member function calls, member
17037accesses and some conversions between pointers to base and derived classes,
17038to verify the referenced object has the correct dynamic type.
17039
d77de738 17040@opindex fsanitize=pointer-overflow
ddf6fe37 17041@item -fsanitize=pointer-overflow
d77de738
ML
17042
17043This option enables instrumentation of pointer arithmetics. If the pointer
17044arithmetics overflows, a run-time error is issued.
17045
d77de738 17046@opindex fsanitize=builtin
ddf6fe37 17047@item -fsanitize=builtin
d77de738
ML
17048
17049This option enables instrumentation of arguments to selected builtin
17050functions. If an invalid value is passed to such arguments, a run-time
17051error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
17052or @code{__builtin_clz} invokes undefined behavior and is diagnosed
17053by this option.
17054
17055@end table
17056
17057Note that sanitizers tend to increase the rate of false positive
17058warnings, most notably those around @option{-Wmaybe-uninitialized}.
17059We recommend against combining @option{-Werror} and [the use of]
17060sanitizers.
17061
17062While @option{-ftrapv} causes traps for signed overflows to be emitted,
17063@option{-fsanitize=undefined} gives a diagnostic message.
17064This currently works only for the C family of languages.
17065
d77de738 17066@opindex fno-sanitize=all
ddf6fe37 17067@item -fno-sanitize=all
d77de738
ML
17068
17069This option disables all previously enabled sanitizers.
17070@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
17071together.
17072
d77de738 17073@opindex fasan-shadow-offset
ddf6fe37 17074@item -fasan-shadow-offset=@var{number}
d77de738
ML
17075This option forces GCC to use custom shadow offset in AddressSanitizer checks.
17076It is useful for experimenting with different shadow memory layouts in
17077Kernel AddressSanitizer.
17078
d77de738 17079@opindex fsanitize-sections
ddf6fe37 17080@item -fsanitize-sections=@var{s1},@var{s2},...
d77de738
ML
17081Sanitize global variables in selected user-defined sections. @var{si} may
17082contain wildcards.
17083
d77de738
ML
17084@opindex fsanitize-recover
17085@opindex fno-sanitize-recover
ddf6fe37 17086@item -fsanitize-recover@r{[}=@var{opts}@r{]}
d77de738
ML
17087@option{-fsanitize-recover=} controls error recovery mode for sanitizers
17088mentioned in comma-separated list of @var{opts}. Enabling this option
17089for a sanitizer component causes it to attempt to continue
17090running the program as if no error happened. This means multiple
17091runtime errors can be reported in a single program run, and the exit
17092code of the program may indicate success even when errors
17093have been reported. The @option{-fno-sanitize-recover=} option
17094can be used to alter
17095this behavior: only the first detected error is reported
17096and program then exits with a non-zero exit code.
17097
17098Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
17099except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
17100@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
17101@option{-fsanitize=bounds-strict},
17102@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
17103For these sanitizers error recovery is turned on by default,
17104except @option{-fsanitize=address}, for which this feature is experimental.
17105@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
17106accepted, the former enables recovery for all sanitizers that support it,
17107the latter disables recovery for all sanitizers that support it.
17108
17109Even if a recovery mode is turned on the compiler side, it needs to be also
17110enabled on the runtime library side, otherwise the failures are still fatal.
17111The runtime library defaults to @code{halt_on_error=0} for
17112ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
17113AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
17114setting the @code{halt_on_error} flag in the corresponding environment variable.
17115
17116Syntax without an explicit @var{opts} parameter is deprecated. It is
17117equivalent to specifying an @var{opts} list of:
17118
17119@smallexample
17120undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
17121@end smallexample
17122
d77de738 17123@opindex fsanitize-address-use-after-scope
ddf6fe37 17124@item -fsanitize-address-use-after-scope
d77de738
ML
17125Enable sanitization of local variables to detect use-after-scope bugs.
17126The option sets @option{-fstack-reuse} to @samp{none}.
17127
d77de738
ML
17128@opindex fsanitize-trap
17129@opindex fno-sanitize-trap
ddf6fe37 17130@item -fsanitize-trap@r{[}=@var{opts}@r{]}
d77de738
ML
17131The @option{-fsanitize-trap=} option instructs the compiler to
17132report for sanitizers mentioned in comma-separated list of @var{opts}
17133undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
17134library routine. If this option is enabled for certain sanitizer,
17135it takes precedence over the @option{-fsanitizer-recover=} for that
17136sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
17137of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
17138
17139The advantage of this is that the @code{libubsan} library is not needed
17140and is not linked in, so this is usable even in freestanding environments.
17141
17142Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
17143except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
17144@option{-fsanitize=float-divide-by-zero} and
17145@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
17146specified, which enables it for @code{undefined} suboptions,
17147@option{-fsanitize=float-cast-overflow},
17148@option{-fsanitize=float-divide-by-zero} and
17149@option{-fsanitize=bounds-strict}.
17150If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
17151and @code{-fsanitize=vptr} is enabled on the command line, the
17152instrumentation is silently ignored as the instrumentation always needs
17153@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
17154
d77de738 17155@opindex fsanitize-undefined-trap-on-error
ddf6fe37 17156@item -fsanitize-undefined-trap-on-error
d77de738
ML
17157The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17158equivalent of @option{-fsanitize-trap=all}.
17159
d77de738 17160@opindex fsanitize-coverage=trace-pc
ddf6fe37 17161@item -fsanitize-coverage=trace-pc
d77de738
ML
17162Enable coverage-guided fuzzing code instrumentation.
17163Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17164
d77de738 17165@opindex fsanitize-coverage=trace-cmp
ddf6fe37 17166@item -fsanitize-coverage=trace-cmp
d77de738
ML
17167Enable dataflow guided fuzzing code instrumentation.
17168Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17169@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17170@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17171variable or @code{__sanitizer_cov_trace_const_cmp1},
17172@code{__sanitizer_cov_trace_const_cmp2},
17173@code{__sanitizer_cov_trace_const_cmp4} or
17174@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17175operand constant, @code{__sanitizer_cov_trace_cmpf} or
17176@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17177@code{__sanitizer_cov_trace_switch} for switch statements.
17178
d77de738 17179@opindex fcf-protection
ddf6fe37 17180@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
d77de738
ML
17181Enable code instrumentation of control-flow transfers to increase
17182program security by checking that target addresses of control-flow
17183transfer instructions (such as indirect function call, function return,
17184indirect jump) are valid. This prevents diverting the flow of control
17185to an unexpected target. This is intended to protect against such
17186threats as Return-oriented Programming (ROP), and similarly
17187call/jmp-oriented programming (COP/JOP).
17188
17189The value @code{branch} tells the compiler to implement checking of
17190validity of control-flow transfer at the point of indirect branch
17191instructions, i.e.@: call/jmp instructions. The value @code{return}
17192implements checking of validity at the point of returning from a
17193function. The value @code{full} is an alias for specifying both
17194@code{branch} and @code{return}. The value @code{none} turns off
17195instrumentation.
17196
17197The value @code{check} is used for the final link with link-time
17198optimization (LTO). An error is issued if LTO object files are
17199compiled with different @option{-fcf-protection} values. The
17200value @code{check} is ignored at the compile time.
17201
17202The macro @code{__CET__} is defined when @option{-fcf-protection} is
17203used. The first bit of @code{__CET__} is set to 1 for the value
17204@code{branch} and the second bit of @code{__CET__} is set to 1 for
17205the @code{return}.
17206
17207You can also use the @code{nocf_check} attribute to identify
17208which functions and calls should be skipped from instrumentation
17209(@pxref{Function Attributes}).
17210
17211Currently the x86 GNU/Linux target provides an implementation based
17212on Intel Control-flow Enforcement Technology (CET) which works for
17213i686 processor or newer.
17214
d77de738 17215@opindex fharden-compares
ddf6fe37 17216@item -fharden-compares
d77de738
ML
17217For every logical test that survives gimple optimizations and is
17218@emph{not} the condition in a conditional branch (for example,
17219conditions tested for conditional moves, or to store in boolean
17220variables), emit extra code to compute and verify the reversed
17221condition, and to call @code{__builtin_trap} if the results do not
17222match. Use with @samp{-fharden-conditional-branches} to cover all
17223conditionals.
17224
d77de738 17225@opindex fharden-conditional-branches
ddf6fe37 17226@item -fharden-conditional-branches
d77de738
ML
17227For every non-vectorized conditional branch that survives gimple
17228optimizations, emit extra code to compute and verify the reversed
17229condition, and to call @code{__builtin_trap} if the result is
17230unexpected. Use with @samp{-fharden-compares} to cover all
17231conditionals.
17232
d77de738 17233@opindex fstack-protector
ddf6fe37 17234@item -fstack-protector
d77de738
ML
17235Emit extra code to check for buffer overflows, such as stack smashing
17236attacks. This is done by adding a guard variable to functions with
17237vulnerable objects. This includes functions that call @code{alloca}, and
17238functions with buffers larger than or equal to 8 bytes. The guards are
17239initialized when a function is entered and then checked when the function
17240exits. If a guard check fails, an error message is printed and the program
17241exits. Only variables that are actually allocated on the stack are
17242considered, optimized away variables or variables allocated in registers
17243don't count.
17244
d77de738 17245@opindex fstack-protector-all
ddf6fe37 17246@item -fstack-protector-all
d77de738
ML
17247Like @option{-fstack-protector} except that all functions are protected.
17248
d77de738 17249@opindex fstack-protector-strong
ddf6fe37 17250@item -fstack-protector-strong
d77de738
ML
17251Like @option{-fstack-protector} but includes additional functions to
17252be protected --- those that have local array definitions, or have
17253references to local frame addresses. Only variables that are actually
17254allocated on the stack are considered, optimized away variables or variables
17255allocated in registers don't count.
17256
d77de738 17257@opindex fstack-protector-explicit
ddf6fe37 17258@item -fstack-protector-explicit
d77de738
ML
17259Like @option{-fstack-protector} but only protects those functions which
17260have the @code{stack_protect} attribute.
17261
d77de738 17262@opindex fstack-check
ddf6fe37 17263@item -fstack-check
d77de738
ML
17264Generate code to verify that you do not go beyond the boundary of the
17265stack. You should specify this flag if you are running in an
17266environment with multiple threads, but you only rarely need to specify it in
17267a single-threaded environment since stack overflow is automatically
17268detected on nearly all systems if there is only one stack.
17269
17270Note that this switch does not actually cause checking to be done; the
17271operating system or the language runtime must do that. The switch causes
17272generation of code to ensure that they see the stack being extended.
17273
17274You can additionally specify a string parameter: @samp{no} means no
17275checking, @samp{generic} means force the use of old-style checking,
17276@samp{specific} means use the best checking method and is equivalent
17277to bare @option{-fstack-check}.
17278
17279Old-style checking is a generic mechanism that requires no specific
17280target support in the compiler but comes with the following drawbacks:
17281
17282@enumerate
17283@item
17284Modified allocation strategy for large objects: they are always
17285allocated dynamically if their size exceeds a fixed threshold. Note this
17286may change the semantics of some code.
17287
17288@item
17289Fixed limit on the size of the static frame of functions: when it is
17290topped by a particular function, stack checking is not reliable and
17291a warning is issued by the compiler.
17292
17293@item
17294Inefficiency: because of both the modified allocation strategy and the
17295generic implementation, code performance is hampered.
17296@end enumerate
17297
17298Note that old-style stack checking is also the fallback method for
17299@samp{specific} if no target support has been added in the compiler.
17300
17301@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17302and stack overflows. @samp{specific} is an excellent choice when compiling
17303Ada code. It is not generally sufficient to protect against stack-clash
17304attacks. To protect against those you want @samp{-fstack-clash-protection}.
17305
d77de738 17306@opindex fstack-clash-protection
ddf6fe37 17307@item -fstack-clash-protection
d77de738
ML
17308Generate code to prevent stack clash style attacks. When this option is
17309enabled, the compiler will only allocate one page of stack space at a time
17310and each page is accessed immediately after allocation. Thus, it prevents
17311allocations from jumping over any stack guard page provided by the
17312operating system.
17313
17314Most targets do not fully support stack clash protection. However, on
17315those targets @option{-fstack-clash-protection} will protect dynamic stack
17316allocations. @option{-fstack-clash-protection} may also provide limited
17317protection for static stack allocations if the target supports
17318@option{-fstack-check=specific}.
17319
d77de738
ML
17320@opindex fstack-limit-register
17321@opindex fstack-limit-symbol
17322@opindex fno-stack-limit
ddf6fe37
AA
17323@item -fstack-limit-register=@var{reg}
17324@itemx -fstack-limit-symbol=@var{sym}
17325@itemx -fno-stack-limit
d77de738
ML
17326Generate code to ensure that the stack does not grow beyond a certain value,
17327either the value of a register or the address of a symbol. If a larger
17328stack is required, a signal is raised at run time. For most targets,
17329the signal is raised before the stack overruns the boundary, so
17330it is possible to catch the signal without taking special precautions.
17331
17332For instance, if the stack starts at absolute address @samp{0x80000000}
17333and grows downwards, you can use the flags
17334@option{-fstack-limit-symbol=__stack_limit} and
17335@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17336of 128KB@. Note that this may only work with the GNU linker.
17337
17338You can locally override stack limit checking by using the
17339@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17340
d77de738 17341@opindex fsplit-stack
ddf6fe37 17342@item -fsplit-stack
d77de738
ML
17343Generate code to automatically split the stack before it overflows.
17344The resulting program has a discontiguous stack which can only
17345overflow if the program is unable to allocate any more memory. This
17346is most useful when running threaded programs, as it is no longer
17347necessary to calculate a good stack size to use for each thread. This
17348is currently only implemented for the x86 targets running
17349GNU/Linux.
17350
17351When code compiled with @option{-fsplit-stack} calls code compiled
17352without @option{-fsplit-stack}, there may not be much stack space
17353available for the latter code to run. If compiling all code,
17354including library code, with @option{-fsplit-stack} is not an option,
17355then the linker can fix up these calls so that the code compiled
17356without @option{-fsplit-stack} always has a large stack. Support for
17357this is implemented in the gold linker in GNU binutils release 2.21
17358and later.
17359
d77de738 17360@opindex fvtable-verify
ddf6fe37 17361@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
d77de738
ML
17362This option is only available when compiling C++ code.
17363It turns on (or off, if using @option{-fvtable-verify=none}) the security
17364feature that verifies at run time, for every virtual call, that
17365the vtable pointer through which the call is made is valid for the type of
17366the object, and has not been corrupted or overwritten. If an invalid vtable
17367pointer is detected at run time, an error is reported and execution of the
17368program is immediately halted.
17369
17370This option causes run-time data structures to be built at program startup,
17371which are used for verifying the vtable pointers.
17372The options @samp{std} and @samp{preinit}
17373control the timing of when these data structures are built. In both cases the
17374data structures are built before execution reaches @code{main}. Using
17375@option{-fvtable-verify=std} causes the data structures to be built after
17376shared libraries have been loaded and initialized.
17377@option{-fvtable-verify=preinit} causes them to be built before shared
17378libraries have been loaded and initialized.
17379
17380If this option appears multiple times in the command line with different
17381values specified, @samp{none} takes highest priority over both @samp{std} and
17382@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17383
d77de738 17384@opindex fvtv-debug
ddf6fe37 17385@item -fvtv-debug
d77de738
ML
17386When used in conjunction with @option{-fvtable-verify=std} or
17387@option{-fvtable-verify=preinit}, causes debug versions of the
17388runtime functions for the vtable verification feature to be called.
17389This flag also causes the compiler to log information about which
17390vtable pointers it finds for each class.
17391This information is written to a file named @file{vtv_set_ptr_data.log}
17392in the directory named by the environment variable @env{VTV_LOGS_DIR}
17393if that is defined or the current working directory otherwise.
17394
17395Note: This feature @emph{appends} data to the log file. If you want a fresh log
17396file, be sure to delete any existing one.
17397
d77de738 17398@opindex fvtv-counts
ddf6fe37 17399@item -fvtv-counts
d77de738
ML
17400This is a debugging flag. When used in conjunction with
17401@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17402causes the compiler to keep track of the total number of virtual calls
17403it encounters and the number of verifications it inserts. It also
17404counts the number of calls to certain run-time library functions
17405that it inserts and logs this information for each compilation unit.
17406The compiler writes this information to a file named
17407@file{vtv_count_data.log} in the directory named by the environment
17408variable @env{VTV_LOGS_DIR} if that is defined or the current working
17409directory otherwise. It also counts the size of the vtable pointer sets
17410for each class, and writes this information to @file{vtv_class_set_sizes.log}
17411in the same directory.
17412
17413Note: This feature @emph{appends} data to the log files. To get fresh log
17414files, be sure to delete any existing ones.
17415
d77de738 17416@opindex finstrument-functions
ddf6fe37 17417@item -finstrument-functions
d77de738
ML
17418Generate instrumentation calls for entry and exit to functions. Just
17419after function entry and just before function exit, the following
17420profiling functions are called with the address of the current
17421function and its call site. (On some platforms,
17422@code{__builtin_return_address} does not work beyond the current
17423function, so the call site information may not be available to the
17424profiling functions otherwise.)
17425
17426@smallexample
17427void __cyg_profile_func_enter (void *this_fn,
17428 void *call_site);
17429void __cyg_profile_func_exit (void *this_fn,
17430 void *call_site);
17431@end smallexample
17432
17433The first argument is the address of the start of the current function,
17434which may be looked up exactly in the symbol table.
17435
17436This instrumentation is also done for functions expanded inline in other
17437functions. The profiling calls indicate where, conceptually, the
17438inline function is entered and exited. This means that addressable
17439versions of such functions must be available. If all your uses of a
17440function are expanded inline, this may mean an additional expansion of
17441code size. If you use @code{extern inline} in your C code, an
17442addressable version of such functions must be provided. (This is
17443normally the case anyway, but if you get lucky and the optimizer always
17444expands the functions inline, you might have gotten away without
17445providing static copies.)
17446
17447A function may be given the attribute @code{no_instrument_function}, in
17448which case this instrumentation is not done. This can be used, for
17449example, for the profiling functions listed above, high-priority
17450interrupt routines, and any functions from which the profiling functions
17451cannot safely be called (perhaps signal handlers, if the profiling
17452routines generate output or allocate memory).
17453@xref{Common Function Attributes}.
17454
9c19597c 17455@opindex finstrument-functions-once
ddf6fe37 17456@item -finstrument-functions-once
d77de738
ML
17457This is similar to @option{-finstrument-functions}, but the profiling
17458functions are called only once per instrumented function, i.e. the first
17459profiling function is called after the first entry into the instrumented
17460function and the second profiling function is called before the exit
17461corresponding to this first entry.
17462
17463The definition of @code{once} for the purpose of this option is a little
17464vague because the implementation is not protected against data races.
17465As a result, the implementation only guarantees that the profiling
17466functions are called at @emph{least} once per process and at @emph{most}
17467once per thread, but the calls are always paired, that is to say, if a
17468thread calls the first function, then it will call the second function,
17469unless it never reaches the exit of the instrumented function.
17470
d77de738 17471@opindex finstrument-functions-exclude-file-list
ddf6fe37 17472@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
d77de738
ML
17473
17474Set the list of functions that are excluded from instrumentation (see
17475the description of @option{-finstrument-functions}). If the file that
17476contains a function definition matches with one of @var{file}, then
17477that function is not instrumented. The match is done on substrings:
17478if the @var{file} parameter is a substring of the file name, it is
17479considered to be a match.
17480
17481For example:
17482
17483@smallexample
17484-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17485@end smallexample
17486
17487@noindent
17488excludes any inline function defined in files whose pathnames
17489contain @file{/bits/stl} or @file{include/sys}.
17490
17491If, for some reason, you want to include letter @samp{,} in one of
17492@var{sym}, write @samp{\,}. For example,
17493@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17494(note the single quote surrounding the option).
17495
d77de738 17496@opindex finstrument-functions-exclude-function-list
ddf6fe37 17497@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
d77de738
ML
17498
17499This is similar to @option{-finstrument-functions-exclude-file-list},
17500but this option sets the list of function names to be excluded from
17501instrumentation. The function name to be matched is its user-visible
17502name, such as @code{vector<int> blah(const vector<int> &)}, not the
17503internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17504match is done on substrings: if the @var{sym} parameter is a substring
17505of the function name, it is considered to be a match. For C99 and C++
17506extended identifiers, the function name must be given in UTF-8, not
17507using universal character names.
17508
d77de738 17509@opindex fpatchable-function-entry
ddf6fe37 17510@item -fpatchable-function-entry=@var{N}[,@var{M}]
d77de738
ML
17511Generate @var{N} NOPs right at the beginning
17512of each function, with the function entry point before the @var{M}th NOP.
17513If @var{M} is omitted, it defaults to @code{0} so the
17514function entry points to the address just at the first NOP.
17515The NOP instructions reserve extra space which can be used to patch in
17516any desired instrumentation at run time, provided that the code segment
17517is writable. The amount of space is controllable indirectly via
17518the number of NOPs; the NOP instruction used corresponds to the instruction
17519emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17520is target-specific and may also depend on the architecture variant and/or
17521other compilation options.
17522
17523For run-time identification, the starting addresses of these areas,
17524which correspond to their respective function entries minus @var{M},
17525are additionally collected in the @code{__patchable_function_entries}
17526section of the resulting binary.
17527
17528Note that the value of @code{__attribute__ ((patchable_function_entry
17529(N,M)))} takes precedence over command-line option
17530@option{-fpatchable-function-entry=N,M}. This can be used to increase
17531the area size or to remove it completely on a single function.
17532If @code{N=0}, no pad location is recorded.
17533
17534The NOP instructions are inserted at---and maybe before, depending on
17535@var{M}---the function entry address, even before the prologue. On
17536PowerPC with the ELFv2 ABI, for a function with dual entry points,
17537the local entry point is this function entry address.
17538
17539The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17540ELFv2 ABI, for a function with dual entry points, the supported values
17541for @var{M} are 0, 2, 6 and 14.
17542@end table
17543
17544
17545@node Preprocessor Options
17546@section Options Controlling the Preprocessor
17547@cindex preprocessor options
17548@cindex options, preprocessor
17549
17550These options control the C preprocessor, which is run on each C source
17551file before actual compilation.
17552
17553If you use the @option{-E} option, nothing is done except preprocessing.
17554Some of these options make sense only together with @option{-E} because
17555they cause the preprocessor output to be unsuitable for actual
17556compilation.
17557
17558In addition to the options listed here, there are a number of options
17559to control search paths for include files documented in
17560@ref{Directory Options}.
17561Options to control preprocessor diagnostics are listed in
17562@ref{Warning Options}.
17563
17564@table @gcctabopt
17565@include cppopts.texi
17566
d77de738 17567@opindex Wp
ddf6fe37 17568@item -Wp,@var{option}
d77de738
ML
17569You can use @option{-Wp,@var{option}} to bypass the compiler driver
17570and pass @var{option} directly through to the preprocessor. If
17571@var{option} contains commas, it is split into multiple options at the
17572commas. However, many options are modified, translated or interpreted
17573by the compiler driver before being passed to the preprocessor, and
17574@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17575interface is undocumented and subject to change, so whenever possible
17576you should avoid using @option{-Wp} and let the driver handle the
17577options instead.
17578
d77de738 17579@opindex Xpreprocessor
ddf6fe37 17580@item -Xpreprocessor @var{option}
d77de738
ML
17581Pass @var{option} as an option to the preprocessor. You can use this to
17582supply system-specific preprocessor options that GCC does not
17583recognize.
17584
17585If you want to pass an option that takes an argument, you must use
17586@option{-Xpreprocessor} twice, once for the option and once for the argument.
17587
d77de738 17588@opindex no-integrated-cpp
ddf6fe37 17589@item -no-integrated-cpp
d77de738
ML
17590Perform preprocessing as a separate pass before compilation.
17591By default, GCC performs preprocessing as an integrated part of
17592input tokenization and parsing.
17593If this option is provided, the appropriate language front end
17594(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17595and Objective-C, respectively) is instead invoked twice,
17596once for preprocessing only and once for actual compilation
17597of the preprocessed input.
17598This option may be useful in conjunction with the @option{-B} or
17599@option{-wrapper} options to specify an alternate preprocessor or
17600perform additional processing of the program source between
17601normal preprocessing and compilation.
17602
d77de738 17603@opindex flarge-source-files
ddf6fe37 17604@item -flarge-source-files
d77de738
ML
17605Adjust GCC to expect large source files, at the expense of slower
17606compilation and higher memory usage.
17607
17608Specifically, GCC normally tracks both column numbers and line numbers
17609within source files and it normally prints both of these numbers in
17610diagnostics. However, once it has processed a certain number of source
17611lines, it stops tracking column numbers and only tracks line numbers.
17612This means that diagnostics for later lines do not include column numbers.
17613It also means that options like @option{-Wmisleading-indentation} cease to work
17614at that point, although the compiler prints a note if this happens.
17615Passing @option{-flarge-source-files} significantly increases the number
17616of source lines that GCC can process before it stops tracking columns.
17617
17618@end table
17619
17620@node Assembler Options
17621@section Passing Options to the Assembler
17622
17623@c prevent bad page break with this line
17624You can pass options to the assembler.
17625
17626@table @gcctabopt
d77de738 17627@opindex Wa
ddf6fe37 17628@item -Wa,@var{option}
d77de738
ML
17629Pass @var{option} as an option to the assembler. If @var{option}
17630contains commas, it is split into multiple options at the commas.
17631
d77de738 17632@opindex Xassembler
ddf6fe37 17633@item -Xassembler @var{option}
d77de738
ML
17634Pass @var{option} as an option to the assembler. You can use this to
17635supply system-specific assembler options that GCC does not
17636recognize.
17637
17638If you want to pass an option that takes an argument, you must use
17639@option{-Xassembler} twice, once for the option and once for the argument.
17640
17641@end table
17642
17643@node Link Options
17644@section Options for Linking
17645@cindex link options
17646@cindex options, linking
17647
17648These options come into play when the compiler links object files into
17649an executable output file. They are meaningless if the compiler is
17650not doing a link step.
17651
17652@table @gcctabopt
17653@cindex file names
17654@item @var{object-file-name}
17655A file name that does not end in a special recognized suffix is
17656considered to name an object file or library. (Object files are
17657distinguished from libraries by the linker according to the file
17658contents.) If linking is done, these object files are used as input
17659to the linker.
17660
d77de738
ML
17661@opindex c
17662@opindex S
17663@opindex E
ddf6fe37
AA
17664@item -c
17665@itemx -S
17666@itemx -E
d77de738
ML
17667If any of these options is used, then the linker is not run, and
17668object file names should not be used as arguments. @xref{Overall
17669Options}.
17670
d77de738 17671@opindex flinker-output
ddf6fe37 17672@item -flinker-output=@var{type}
d77de738
ML
17673This option controls code generation of the link-time optimizer. By
17674default the linker output is automatically determined by the linker
17675plugin. For debugging the compiler and if incremental linking with a
17676non-LTO object file is desired, it may be useful to control the type
17677manually.
17678
17679If @var{type} is @samp{exec}, code generation produces a static
17680binary. In this case @option{-fpic} and @option{-fpie} are both
17681disabled.
17682
17683If @var{type} is @samp{dyn}, code generation produces a shared
17684library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17685but not enabled automatically. This allows to build shared libraries
17686without position-independent code on architectures where this is
17687possible, i.e.@: on x86.
17688
17689If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17690executable. This results in similar optimizations as @samp{exec}
17691except that @option{-fpie} is not disabled if specified at compilation
17692time.
17693
17694If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17695done. The sections containing intermediate code for link-time optimization are
17696merged, pre-optimized, and output to the resulting object file. In addition, if
17697@option{-ffat-lto-objects} is specified, binary code is produced for future
17698non-LTO linking. The object file produced by incremental linking is smaller
17699than a static library produced from the same object files. At link time the
17700result of incremental linking also loads faster than a static
17701library assuming that the majority of objects in the library are used.
17702
17703Finally @samp{nolto-rel} configures the compiler for incremental linking where
17704code generation is forced, a final binary is produced, and the intermediate
17705code for later link-time optimization is stripped. When multiple object files
17706are linked together the resulting code is better optimized than with
17707link-time optimizations disabled (for example, cross-module inlining
17708happens), but most of benefits of whole program optimizations are lost.
17709
17710During the incremental link (by @option{-r}) the linker plugin defaults to
17711@option{rel}. With current interfaces to GNU Binutils it is however not
17712possible to incrementally link LTO objects and non-LTO objects into a single
17713mixed object file. If any of object files in incremental link cannot
17714be used for link-time optimization, the linker plugin issues a warning and
17715uses @samp{nolto-rel}. To maintain whole program optimization, it is
17716recommended to link such objects into static library instead. Alternatively it
17717is possible to use H.J. Lu's binutils with support for mixed objects.
17718
d77de738 17719@opindex fuse-ld=bfd
ddf6fe37 17720@item -fuse-ld=bfd
d77de738
ML
17721Use the @command{bfd} linker instead of the default linker.
17722
d77de738 17723@opindex fuse-ld=gold
ddf6fe37 17724@item -fuse-ld=gold
d77de738
ML
17725Use the @command{gold} linker instead of the default linker.
17726
d77de738 17727@opindex fuse-ld=lld
ddf6fe37 17728@item -fuse-ld=lld
d77de738
ML
17729Use the LLVM @command{lld} linker instead of the default linker.
17730
d77de738 17731@opindex fuse-ld=mold
ddf6fe37 17732@item -fuse-ld=mold
d77de738
ML
17733Use the Modern Linker (@command{mold}) instead of the default linker.
17734
17735@cindex Libraries
ddf6fe37 17736@opindex l
d77de738
ML
17737@item -l@var{library}
17738@itemx -l @var{library}
d77de738
ML
17739Search the library named @var{library} when linking. (The second
17740alternative with the library as a separate argument is only for
17741POSIX compliance and is not recommended.)
17742
17743The @option{-l} option is passed directly to the linker by GCC. Refer
17744to your linker documentation for exact details. The general
17745description below applies to the GNU linker.
17746
17747The linker searches a standard list of directories for the library.
17748The directories searched include several standard system directories
17749plus any that you specify with @option{-L}.
17750
17751Static libraries are archives of object files, and have file names
17752like @file{lib@var{library}.a}. Some targets also support shared
17753libraries, which typically have names like @file{lib@var{library}.so}.
17754If both static and shared libraries are found, the linker gives
17755preference to linking with the shared library unless the
17756@option{-static} option is used.
17757
17758It makes a difference where in the command you write this option; the
17759linker searches and processes libraries and object files in the order they
17760are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17761after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17762to functions in @samp{z}, those functions may not be loaded.
17763
d77de738 17764@opindex lobjc
ddf6fe37 17765@item -lobjc
d77de738
ML
17766You need this special case of the @option{-l} option in order to
17767link an Objective-C or Objective-C++ program.
17768
d77de738 17769@opindex nostartfiles
ddf6fe37 17770@item -nostartfiles
d77de738
ML
17771Do not use the standard system startup files when linking.
17772The standard system libraries are used normally, unless @option{-nostdlib},
17773@option{-nolibc}, or @option{-nodefaultlibs} is used.
17774
d77de738 17775@opindex nodefaultlibs
ddf6fe37 17776@item -nodefaultlibs
d77de738
ML
17777Do not use the standard system libraries when linking.
17778Only the libraries you specify are passed to the linker, and options
17779specifying linkage of the system libraries, such as @option{-static-libgcc}
17780or @option{-shared-libgcc}, are ignored.
17781The standard startup files are used normally, unless @option{-nostartfiles}
17782is used.
17783
17784The compiler may generate calls to @code{memcmp},
17785@code{memset}, @code{memcpy} and @code{memmove}.
17786These entries are usually resolved by entries in
17787libc. These entry points should be supplied through some other
17788mechanism when this option is specified.
17789
d77de738 17790@opindex nolibc
ddf6fe37 17791@item -nolibc
d77de738
ML
17792Do not use the C library or system libraries tightly coupled with it when
17793linking. Still link with the startup files, @file{libgcc} or toolchain
17794provided language support libraries such as @file{libgnat}, @file{libgfortran}
17795or @file{libstdc++} unless options preventing their inclusion are used as
17796well. This typically removes @option{-lc} from the link command line, as well
17797as system libraries that normally go with it and become meaningless when
17798absence of a C library is assumed, for example @option{-lpthread} or
17799@option{-lm} in some configurations. This is intended for bare-board
17800targets when there is indeed no C library available.
17801
d77de738 17802@opindex nostdlib
ddf6fe37 17803@item -nostdlib
d77de738
ML
17804Do not use the standard system startup files or libraries when linking.
17805No startup files and only the libraries you specify are passed to
17806the linker, and options specifying linkage of the system libraries, such as
17807@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
17808
17809The compiler may generate calls to @code{memcmp}, @code{memset},
17810@code{memcpy} and @code{memmove}.
17811These entries are usually resolved by entries in
17812libc. These entry points should be supplied through some other
17813mechanism when this option is specified.
17814
17815@cindex @option{-lgcc}, use with @option{-nostdlib}
17816@cindex @option{-nostdlib} and unresolved references
17817@cindex unresolved references and @option{-nostdlib}
17818@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
17819@cindex @option{-nodefaultlibs} and unresolved references
17820@cindex unresolved references and @option{-nodefaultlibs}
17821One of the standard libraries bypassed by @option{-nostdlib} and
17822@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
17823which GCC uses to overcome shortcomings of particular machines, or special
17824needs for some languages.
17825(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
17826Collection (GCC) Internals},
17827for more discussion of @file{libgcc.a}.)
17828In most cases, you need @file{libgcc.a} even when you want to avoid
17829other standard libraries. In other words, when you specify @option{-nostdlib}
17830or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
17831This ensures that you have no unresolved references to internal GCC
17832library subroutines.
17833(An example of such an internal subroutine is @code{__main}, used to ensure C++
17834constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
17835GNU Compiler Collection (GCC) Internals}.)
17836
d77de738 17837@opindex nostdlib++
ddf6fe37 17838@item -nostdlib++
d77de738
ML
17839Do not implicitly link with standard C++ libraries.
17840
d77de738
ML
17841@opindex e
17842@opindex entry
ddf6fe37
AA
17843@item -e @var{entry}
17844@itemx --entry=@var{entry}
d77de738
ML
17845
17846Specify that the program entry point is @var{entry}. The argument is
17847interpreted by the linker; the GNU linker accepts either a symbol name
17848or an address.
17849
d77de738 17850@opindex pie
ddf6fe37 17851@item -pie
d77de738
ML
17852Produce a dynamically linked position independent executable on targets
17853that support it. For predictable results, you must also specify the same
17854set of options used for compilation (@option{-fpie}, @option{-fPIE},
17855or model suboptions) when you specify this linker option.
17856
d77de738 17857@opindex no-pie
ddf6fe37 17858@item -no-pie
d77de738
ML
17859Don't produce a dynamically linked position independent executable.
17860
d77de738 17861@opindex static-pie
ddf6fe37 17862@item -static-pie
d77de738
ML
17863Produce a static position independent executable on targets that support
17864it. A static position independent executable is similar to a static
17865executable, but can be loaded at any address without a dynamic linker.
17866For predictable results, you must also specify the same set of options
17867used for compilation (@option{-fpie}, @option{-fPIE}, or model
17868suboptions) when you specify this linker option.
17869
d77de738 17870@opindex pthread
ddf6fe37 17871@item -pthread
d77de738
ML
17872Link with the POSIX threads library. This option is supported on
17873GNU/Linux targets, most other Unix derivatives, and also on
17874x86 Cygwin and MinGW targets. On some targets this option also sets
17875flags for the preprocessor, so it should be used consistently for both
17876compilation and linking.
17877
d77de738 17878@opindex r
ddf6fe37 17879@item -r
d77de738
ML
17880Produce a relocatable object as output. This is also known as partial
17881linking.
17882
d77de738 17883@opindex rdynamic
ddf6fe37 17884@item -rdynamic
d77de738
ML
17885Pass the flag @option{-export-dynamic} to the ELF linker, on targets
17886that support it. This instructs the linker to add all symbols, not
17887only used ones, to the dynamic symbol table. This option is needed
17888for some uses of @code{dlopen} or to allow obtaining backtraces
17889from within a program.
17890
d77de738 17891@opindex s
ddf6fe37 17892@item -s
d77de738
ML
17893Remove all symbol table and relocation information from the executable.
17894
d77de738 17895@opindex static
ddf6fe37 17896@item -static
d77de738
ML
17897On systems that support dynamic linking, this overrides @option{-pie}
17898and prevents linking with the shared libraries. On other systems, this
17899option has no effect.
17900
d77de738 17901@opindex shared
ddf6fe37 17902@item -shared
d77de738
ML
17903Produce a shared object which can then be linked with other objects to
17904form an executable. Not all systems support this option. For predictable
17905results, you must also specify the same set of options used for compilation
17906(@option{-fpic}, @option{-fPIC}, or model suboptions) when
17907you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
17908needs to build supplementary stub code for constructors to work. On
17909multi-libbed systems, @samp{gcc -shared} must select the correct support
17910libraries to link against. Failing to supply the correct flags may lead
17911to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
17912is innocuous. @option{-shared} suppresses the addition of startup code
17913to alter the floating-point environment as done with @option{-ffast-math},
17914@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738 17915
d77de738
ML
17916@opindex shared-libgcc
17917@opindex static-libgcc
ddf6fe37
AA
17918@item -shared-libgcc
17919@itemx -static-libgcc
d77de738
ML
17920On systems that provide @file{libgcc} as a shared library, these options
17921force the use of either the shared or static version, respectively.
17922If no shared version of @file{libgcc} was built when the compiler was
17923configured, these options have no effect.
17924
17925There are several situations in which an application should use the
17926shared @file{libgcc} instead of the static version. The most common
17927of these is when the application wishes to throw and catch exceptions
17928across different shared libraries. In that case, each of the libraries
17929as well as the application itself should use the shared @file{libgcc}.
17930
17931Therefore, the G++ driver automatically adds @option{-shared-libgcc}
17932whenever you build a shared library or a main executable, because C++
17933programs typically use exceptions, so this is the right thing to do.
17934
17935If, instead, you use the GCC driver to create shared libraries, you may
17936find that they are not always linked with the shared @file{libgcc}.
17937If GCC finds, at its configuration time, that you have a non-GNU linker
17938or a GNU linker that does not support option @option{--eh-frame-hdr},
17939it links the shared version of @file{libgcc} into shared libraries
17940by default. Otherwise, it takes advantage of the linker and optimizes
17941away the linking with the shared version of @file{libgcc}, linking with
17942the static version of libgcc by default. This allows exceptions to
17943propagate through such shared libraries, without incurring relocation
17944costs at library load time.
17945
17946However, if a library or main executable is supposed to throw or catch
17947exceptions, you must link it using the G++ driver, or using the option
17948@option{-shared-libgcc}, such that it is linked with the shared
17949@file{libgcc}.
17950
d77de738 17951@opindex static-libasan
ddf6fe37 17952@item -static-libasan
d77de738
ML
17953When the @option{-fsanitize=address} option is used to link a program,
17954the GCC driver automatically links against @option{libasan}. If
17955@file{libasan} is available as a shared library, and the @option{-static}
17956option is not used, then this links against the shared version of
17957@file{libasan}. The @option{-static-libasan} option directs the GCC
17958driver to link @file{libasan} statically, without necessarily linking
17959other libraries statically.
17960
d77de738 17961@opindex static-libtsan
ddf6fe37 17962@item -static-libtsan
d77de738
ML
17963When the @option{-fsanitize=thread} option is used to link a program,
17964the GCC driver automatically links against @option{libtsan}. If
17965@file{libtsan} is available as a shared library, and the @option{-static}
17966option is not used, then this links against the shared version of
17967@file{libtsan}. The @option{-static-libtsan} option directs the GCC
17968driver to link @file{libtsan} statically, without necessarily linking
17969other libraries statically.
17970
d77de738 17971@opindex static-liblsan
ddf6fe37 17972@item -static-liblsan
d77de738
ML
17973When the @option{-fsanitize=leak} option is used to link a program,
17974the GCC driver automatically links against @option{liblsan}. If
17975@file{liblsan} is available as a shared library, and the @option{-static}
17976option is not used, then this links against the shared version of
17977@file{liblsan}. The @option{-static-liblsan} option directs the GCC
17978driver to link @file{liblsan} statically, without necessarily linking
17979other libraries statically.
17980
d77de738 17981@opindex static-libubsan
ddf6fe37 17982@item -static-libubsan
d77de738
ML
17983When the @option{-fsanitize=undefined} option is used to link a program,
17984the GCC driver automatically links against @option{libubsan}. If
17985@file{libubsan} is available as a shared library, and the @option{-static}
17986option is not used, then this links against the shared version of
17987@file{libubsan}. The @option{-static-libubsan} option directs the GCC
17988driver to link @file{libubsan} statically, without necessarily linking
17989other libraries statically.
17990
d77de738 17991@opindex static-libstdc++
ddf6fe37 17992@item -static-libstdc++
d77de738
ML
17993When the @command{g++} program is used to link a C++ program, it
17994normally automatically links against @option{libstdc++}. If
17995@file{libstdc++} is available as a shared library, and the
17996@option{-static} option is not used, then this links against the
17997shared version of @file{libstdc++}. That is normally fine. However, it
17998is sometimes useful to freeze the version of @file{libstdc++} used by
17999the program without going all the way to a fully static link. The
18000@option{-static-libstdc++} option directs the @command{g++} driver to
18001link @file{libstdc++} statically, without necessarily linking other
18002libraries statically.
18003
d77de738 18004@opindex symbolic
ddf6fe37 18005@item -symbolic
d77de738
ML
18006Bind references to global symbols when building a shared object. Warn
18007about any unresolved references (unless overridden by the link editor
18008option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
18009this option.
18010
d77de738
ML
18011@opindex T
18012@cindex linker script
f33d7a88 18013@item -T @var{script}
d77de738
ML
18014Use @var{script} as the linker script. This option is supported by most
18015systems using the GNU linker. On some targets, such as bare-board
18016targets without an operating system, the @option{-T} option may be required
18017when linking to avoid references to undefined symbols.
18018
d77de738 18019@opindex Xlinker
ddf6fe37 18020@item -Xlinker @var{option}
d77de738
ML
18021Pass @var{option} as an option to the linker. You can use this to
18022supply system-specific linker options that GCC does not recognize.
18023
18024If you want to pass an option that takes a separate argument, you must use
18025@option{-Xlinker} twice, once for the option and once for the argument.
18026For example, to pass @option{-assert definitions}, you must write
18027@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
18028@option{-Xlinker "-assert definitions"}, because this passes the entire
18029string as a single argument, which is not what the linker expects.
18030
18031When using the GNU linker, it is usually more convenient to pass
18032arguments to linker options using the @option{@var{option}=@var{value}}
18033syntax than as separate arguments. For example, you can specify
18034@option{-Xlinker -Map=output.map} rather than
18035@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
18036this syntax for command-line options.
18037
d77de738 18038@opindex Wl
ddf6fe37 18039@item -Wl,@var{option}
d77de738
ML
18040Pass @var{option} as an option to the linker. If @var{option} contains
18041commas, it is split into multiple options at the commas. You can use this
18042syntax to pass an argument to the option.
18043For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
18044linker. When using the GNU linker, you can also get the same effect with
18045@option{-Wl,-Map=output.map}.
18046
d77de738 18047@opindex u
ddf6fe37 18048@item -u @var{symbol}
d77de738
ML
18049Pretend the symbol @var{symbol} is undefined, to force linking of
18050library modules to define it. You can use @option{-u} multiple times with
18051different symbols to force loading of additional library modules.
18052
d77de738 18053@opindex z
ddf6fe37 18054@item -z @var{keyword}
d77de738
ML
18055@option{-z} is passed directly on to the linker along with the keyword
18056@var{keyword}. See the section in the documentation of your linker for
18057permitted values and their meanings.
18058@end table
18059
18060@node Directory Options
18061@section Options for Directory Search
18062@cindex directory options
18063@cindex options, directory search
18064@cindex search path
18065
18066These options specify directories to search for header files, for
18067libraries and for parts of the compiler:
18068
18069@table @gcctabopt
18070@include cppdiropts.texi
18071
d77de738 18072@opindex iplugindir=
ddf6fe37 18073@item -iplugindir=@var{dir}
d77de738
ML
18074Set the directory to search for plugins that are passed
18075by @option{-fplugin=@var{name}} instead of
18076@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
18077to be used by the user, but only passed by the driver.
18078
d77de738 18079@opindex L
ddf6fe37 18080@item -L@var{dir}
d77de738
ML
18081Add directory @var{dir} to the list of directories to be searched
18082for @option{-l}.
18083
d77de738 18084@opindex B
ddf6fe37 18085@item -B@var{prefix}
d77de738
ML
18086This option specifies where to find the executables, libraries,
18087include files, and data files of the compiler itself.
18088
18089The compiler driver program runs one or more of the subprograms
18090@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
18091@var{prefix} as a prefix for each program it tries to run, both with and
18092without @samp{@var{machine}/@var{version}/} for the corresponding target
18093machine and compiler version.
18094
18095For each subprogram to be run, the compiler driver first tries the
18096@option{-B} prefix, if any. If that name is not found, or if @option{-B}
18097is not specified, the driver tries two standard prefixes,
18098@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
18099those results in a file name that is found, the unmodified program
18100name is searched for using the directories specified in your
18101@env{PATH} environment variable.
18102
18103The compiler checks to see if the path provided by @option{-B}
18104refers to a directory, and if necessary it adds a directory
18105separator character at the end of the path.
18106
18107@option{-B} prefixes that effectively specify directory names also apply
18108to libraries in the linker, because the compiler translates these
18109options into @option{-L} options for the linker. They also apply to
18110include files in the preprocessor, because the compiler translates these
18111options into @option{-isystem} options for the preprocessor. In this case,
18112the compiler appends @samp{include} to the prefix.
18113
18114The runtime support file @file{libgcc.a} can also be searched for using
18115the @option{-B} prefix, if needed. If it is not found there, the two
18116standard prefixes above are tried, and that is all. The file is left
18117out of the link if it is not found by those means.
18118
18119Another way to specify a prefix much like the @option{-B} prefix is to use
18120the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
18121Variables}.
18122
18123As a special kludge, if the path provided by @option{-B} is
18124@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
181259, then it is replaced by @file{[dir/]include}. This is to help
18126with boot-strapping the compiler.
18127
d77de738 18128@opindex no-canonical-prefixes
ddf6fe37 18129@item -no-canonical-prefixes
d77de738
ML
18130Do not expand any symbolic links, resolve references to @samp{/../}
18131or @samp{/./}, or make the path absolute when generating a relative
18132prefix.
18133
d77de738 18134@opindex sysroot
ddf6fe37 18135@item --sysroot=@var{dir}
d77de738
ML
18136Use @var{dir} as the logical root directory for headers and libraries.
18137For example, if the compiler normally searches for headers in
18138@file{/usr/include} and libraries in @file{/usr/lib}, it instead
18139searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
18140
18141If you use both this option and the @option{-isysroot} option, then
18142the @option{--sysroot} option applies to libraries, but the
18143@option{-isysroot} option applies to header files.
18144
18145The GNU linker (beginning with version 2.16) has the necessary support
18146for this option. If your linker does not support this option, the
18147header file aspect of @option{--sysroot} still works, but the
18148library aspect does not.
18149
d77de738 18150@opindex no-sysroot-suffix
ddf6fe37 18151@item --no-sysroot-suffix
d77de738
ML
18152For some targets, a suffix is added to the root directory specified
18153with @option{--sysroot}, depending on the other options used, so that
18154headers may for example be found in
18155@file{@var{dir}/@var{suffix}/usr/include} instead of
18156@file{@var{dir}/usr/include}. This option disables the addition of
18157such a suffix.
18158
18159@end table
18160
18161@node Code Gen Options
18162@section Options for Code Generation Conventions
18163@cindex code generation conventions
18164@cindex options, code generation
18165@cindex run-time options
18166
18167These machine-independent options control the interface conventions
18168used in code generation.
18169
18170Most of them have both positive and negative forms; the negative form
18171of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18172one of the forms is listed---the one that is not the default. You
18173can figure out the other form by either removing @samp{no-} or adding
18174it.
18175
18176@table @gcctabopt
d77de738 18177@opindex fstack_reuse
ddf6fe37 18178@item -fstack-reuse=@var{reuse-level}
d77de738
ML
18179This option controls stack space reuse for user declared local/auto variables
18180and compiler generated temporaries. @var{reuse_level} can be @samp{all},
18181@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
18182local variables and temporaries, @samp{named_vars} enables the reuse only for
18183user defined local variables with names, and @samp{none} disables stack reuse
18184completely. The default value is @samp{all}. The option is needed when the
18185program extends the lifetime of a scoped local variable or a compiler generated
18186temporary beyond the end point defined by the language. When a lifetime of
18187a variable ends, and if the variable lives in memory, the optimizing compiler
18188has the freedom to reuse its stack space with other temporaries or scoped
18189local variables whose live range does not overlap with it. Legacy code extending
18190local lifetime is likely to break with the stack reuse optimization.
18191
18192For example,
18193
18194@smallexample
18195 int *p;
18196 @{
18197 int local1;
18198
18199 p = &local1;
18200 local1 = 10;
18201 ....
18202 @}
18203 @{
18204 int local2;
18205 local2 = 20;
18206 ...
18207 @}
18208
18209 if (*p == 10) // out of scope use of local1
18210 @{
18211
18212 @}
18213@end smallexample
18214
18215Another example:
18216@smallexample
18217
18218 struct A
18219 @{
18220 A(int k) : i(k), j(k) @{ @}
18221 int i;
18222 int j;
18223 @};
18224
18225 A *ap;
18226
18227 void foo(const A& ar)
18228 @{
18229 ap = &ar;
18230 @}
18231
18232 void bar()
18233 @{
18234 foo(A(10)); // temp object's lifetime ends when foo returns
18235
18236 @{
18237 A a(20);
18238 ....
18239 @}
18240 ap->i+= 10; // ap references out of scope temp whose space
18241 // is reused with a. What is the value of ap->i?
18242 @}
18243
18244@end smallexample
18245
18246The lifetime of a compiler generated temporary is well defined by the C++
18247standard. When a lifetime of a temporary ends, and if the temporary lives
18248in memory, the optimizing compiler has the freedom to reuse its stack
18249space with other temporaries or scoped local variables whose live range
18250does not overlap with it. However some of the legacy code relies on
18251the behavior of older compilers in which temporaries' stack space is
18252not reused, the aggressive stack reuse can lead to runtime errors. This
18253option is used to control the temporary stack reuse optimization.
18254
d77de738 18255@opindex ftrapv
ddf6fe37 18256@item -ftrapv
d77de738
ML
18257This option generates traps for signed overflow on addition, subtraction,
18258multiplication operations.
18259The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18260@option{-ftrapv} @option{-fwrapv} on the command-line results in
18261@option{-fwrapv} being effective. Note that only active options override, so
18262using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18263results in @option{-ftrapv} being effective.
18264
d77de738 18265@opindex fwrapv
ddf6fe37 18266@item -fwrapv
d77de738
ML
18267This option instructs the compiler to assume that signed arithmetic
18268overflow of addition, subtraction and multiplication wraps around
18269using twos-complement representation. This flag enables some optimizations
18270and disables others.
18271The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18272@option{-ftrapv} @option{-fwrapv} on the command-line results in
18273@option{-fwrapv} being effective. Note that only active options override, so
18274using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18275results in @option{-ftrapv} being effective.
18276
d77de738 18277@opindex fwrapv-pointer
ddf6fe37 18278@item -fwrapv-pointer
d77de738
ML
18279This option instructs the compiler to assume that pointer arithmetic
18280overflow on addition and subtraction wraps around using twos-complement
18281representation. This flag disables some optimizations which assume
18282pointer overflow is invalid.
18283
d77de738 18284@opindex fstrict-overflow
ddf6fe37 18285@item -fstrict-overflow
d77de738
ML
18286This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18287negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18288
d77de738 18289@opindex fexceptions
ddf6fe37 18290@item -fexceptions
d77de738
ML
18291Enable exception handling. Generates extra code needed to propagate
18292exceptions. For some targets, this implies GCC generates frame
18293unwind information for all functions, which can produce significant data
18294size overhead, although it does not affect execution. If you do not
18295specify this option, GCC enables it by default for languages like
18296C++ that normally require exception handling, and disables it for
18297languages like C that do not normally require it. However, you may need
18298to enable this option when compiling C code that needs to interoperate
18299properly with exception handlers written in C++. You may also wish to
18300disable this option if you are compiling older C++ programs that don't
18301use exception handling.
18302
d77de738 18303@opindex fnon-call-exceptions
ddf6fe37 18304@item -fnon-call-exceptions
d77de738
ML
18305Generate code that allows trapping instructions to throw exceptions.
18306Note that this requires platform-specific runtime support that does
18307not exist everywhere. Moreover, it only allows @emph{trapping}
18308instructions to throw exceptions, i.e.@: memory references or floating-point
18309instructions. It does not allow exceptions to be thrown from
18310arbitrary signal handlers such as @code{SIGALRM}. This enables
18311@option{-fexceptions}.
18312
d77de738 18313@opindex fdelete-dead-exceptions
ddf6fe37 18314@item -fdelete-dead-exceptions
d77de738
ML
18315Consider that instructions that may throw exceptions but don't otherwise
18316contribute to the execution of the program can be optimized away.
18317This does not affect calls to functions except those with the
18318@code{pure} or @code{const} attributes.
18319This option is enabled by default for the Ada and C++ compilers, as permitted by
18320the language specifications.
18321Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18322
d77de738 18323@opindex funwind-tables
ddf6fe37 18324@item -funwind-tables
d77de738
ML
18325Similar to @option{-fexceptions}, except that it just generates any needed
18326static data, but does not affect the generated code in any other way.
18327You normally do not need to enable this option; instead, a language processor
18328that needs this handling enables it on your behalf.
18329
d77de738 18330@opindex fasynchronous-unwind-tables
ddf6fe37 18331@item -fasynchronous-unwind-tables
d77de738
ML
18332Generate unwind table in DWARF format, if supported by target machine. The
18333table is exact at each instruction boundary, so it can be used for stack
18334unwinding from asynchronous events (such as debugger or garbage collector).
18335
d77de738
ML
18336@opindex fno-gnu-unique
18337@opindex fgnu-unique
ddf6fe37 18338@item -fno-gnu-unique
d77de738
ML
18339On systems with recent GNU assembler and C library, the C++ compiler
18340uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18341of template static data members and static local variables in inline
18342functions are unique even in the presence of @code{RTLD_LOCAL}; this
18343is necessary to avoid problems with a library used by two different
18344@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18345therefore disagreeing with the other one about the binding of the
18346symbol. But this causes @code{dlclose} to be ignored for affected
18347DSOs; if your program relies on reinitialization of a DSO via
18348@code{dlclose} and @code{dlopen}, you can use
18349@option{-fno-gnu-unique}.
18350
d77de738 18351@opindex fpcc-struct-return
ddf6fe37 18352@item -fpcc-struct-return
d77de738
ML
18353Return ``short'' @code{struct} and @code{union} values in memory like
18354longer ones, rather than in registers. This convention is less
18355efficient, but it has the advantage of allowing intercallability between
18356GCC-compiled files and files compiled with other compilers, particularly
18357the Portable C Compiler (pcc).
18358
18359The precise convention for returning structures in memory depends
18360on the target configuration macros.
18361
18362Short structures and unions are those whose size and alignment match
18363that of some integer type.
18364
18365@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18366switch is not binary compatible with code compiled with the
18367@option{-freg-struct-return} switch.
18368Use it to conform to a non-default application binary interface.
18369
d77de738 18370@opindex freg-struct-return
ddf6fe37 18371@item -freg-struct-return
d77de738
ML
18372Return @code{struct} and @code{union} values in registers when possible.
18373This is more efficient for small structures than
18374@option{-fpcc-struct-return}.
18375
18376If you specify neither @option{-fpcc-struct-return} nor
18377@option{-freg-struct-return}, GCC defaults to whichever convention is
18378standard for the target. If there is no standard convention, GCC
18379defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18380the principal compiler. In those cases, we can choose the standard, and
18381we chose the more efficient register return alternative.
18382
18383@strong{Warning:} code compiled with the @option{-freg-struct-return}
18384switch is not binary compatible with code compiled with the
18385@option{-fpcc-struct-return} switch.
18386Use it to conform to a non-default application binary interface.
18387
d77de738 18388@opindex fshort-enums
ddf6fe37 18389@item -fshort-enums
d77de738
ML
18390Allocate to an @code{enum} type only as many bytes as it needs for the
18391declared range of possible values. Specifically, the @code{enum} type
18392is equivalent to the smallest integer type that has enough room.
d8a656d5
JW
18393This option has no effect for an enumeration type with a fixed underlying
18394type.
d77de738
ML
18395
18396@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18397code that is not binary compatible with code generated without that switch.
18398Use it to conform to a non-default application binary interface.
18399
d77de738 18400@opindex fshort-wchar
ddf6fe37 18401@item -fshort-wchar
d77de738
ML
18402Override the underlying type for @code{wchar_t} to be @code{short
18403unsigned int} instead of the default for the target. This option is
18404useful for building programs to run under WINE@.
18405
18406@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18407code that is not binary compatible with code generated without that switch.
18408Use it to conform to a non-default application binary interface.
18409
d77de738
ML
18410@opindex fcommon
18411@opindex fno-common
18412@cindex tentative definitions
f33d7a88 18413@item -fcommon
d77de738
ML
18414In C code, this option controls the placement of global variables
18415defined without an initializer, known as @dfn{tentative definitions}
18416in the C standard. Tentative definitions are distinct from declarations
18417of a variable with the @code{extern} keyword, which do not allocate storage.
18418
18419The default is @option{-fno-common}, which specifies that the compiler places
18420uninitialized global variables in the BSS section of the object file.
18421This inhibits the merging of tentative definitions by the linker so you get a
18422multiple-definition error if the same variable is accidentally defined in more
18423than one compilation unit.
18424
18425The @option{-fcommon} places uninitialized global variables in a common block.
18426This allows the linker to resolve all tentative definitions of the same variable
18427in different compilation units to the same object, or to a non-tentative
18428definition. This behavior is inconsistent with C++, and on many targets implies
18429a speed and code size penalty on global variable references. It is mainly
18430useful to enable legacy code to link without errors.
18431
d77de738
ML
18432@opindex fno-ident
18433@opindex fident
ddf6fe37 18434@item -fno-ident
d77de738
ML
18435Ignore the @code{#ident} directive.
18436
d77de738 18437@opindex finhibit-size-directive
ddf6fe37 18438@item -finhibit-size-directive
d77de738
ML
18439Don't output a @code{.size} assembler directive, or anything else that
18440would cause trouble if the function is split in the middle, and the
18441two halves are placed at locations far apart in memory. This option is
18442used when compiling @file{crtstuff.c}; you should not need to use it
18443for anything else.
18444
d77de738 18445@opindex fverbose-asm
ddf6fe37 18446@item -fverbose-asm
d77de738
ML
18447Put extra commentary information in the generated assembly code to
18448make it more readable. This option is generally only of use to those
18449who actually need to read the generated assembly code (perhaps while
18450debugging the compiler itself).
18451
18452@option{-fno-verbose-asm}, the default, causes the
18453extra information to be omitted and is useful when comparing two assembler
18454files.
18455
18456The added comments include:
18457
18458@itemize @bullet
18459
18460@item
18461information on the compiler version and command-line options,
18462
18463@item
18464the source code lines associated with the assembly instructions,
18465in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18466
18467@item
18468hints on which high-level expressions correspond to
18469the various assembly instruction operands.
18470
18471@end itemize
18472
18473For example, given this C source file:
18474
18475@smallexample
18476int test (int n)
18477@{
18478 int i;
18479 int total = 0;
18480
18481 for (i = 0; i < n; i++)
18482 total += i * i;
18483
18484 return total;
18485@}
18486@end smallexample
18487
18488compiling to (x86_64) assembly via @option{-S} and emitting the result
18489direct to stdout via @option{-o} @option{-}
18490
18491@smallexample
18492gcc -S test.c -fverbose-asm -Os -o -
18493@end smallexample
18494
18495gives output similar to this:
18496
18497@smallexample
18498 .file "test.c"
18499# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18500 [...snip...]
18501# options passed:
18502 [...snip...]
18503
18504 .text
18505 .globl test
18506 .type test, @@function
18507test:
18508.LFB0:
18509 .cfi_startproc
18510# test.c:4: int total = 0;
18511 xorl %eax, %eax # <retval>
18512# test.c:6: for (i = 0; i < n; i++)
18513 xorl %edx, %edx # i
18514.L2:
18515# test.c:6: for (i = 0; i < n; i++)
18516 cmpl %edi, %edx # n, i
18517 jge .L5 #,
18518# test.c:7: total += i * i;
18519 movl %edx, %ecx # i, tmp92
18520 imull %edx, %ecx # i, tmp92
18521# test.c:6: for (i = 0; i < n; i++)
18522 incl %edx # i
18523# test.c:7: total += i * i;
18524 addl %ecx, %eax # tmp92, <retval>
18525 jmp .L2 #
18526.L5:
18527# test.c:10: @}
18528 ret
18529 .cfi_endproc
18530.LFE0:
18531 .size test, .-test
18532 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18533 .section .note.GNU-stack,"",@@progbits
18534@end smallexample
18535
18536The comments are intended for humans rather than machines and hence the
18537precise format of the comments is subject to change.
18538
d77de738 18539@opindex frecord-gcc-switches
ddf6fe37 18540@item -frecord-gcc-switches
d77de738
ML
18541This switch causes the command line used to invoke the
18542compiler to be recorded into the object file that is being created.
18543This switch is only implemented on some targets and the exact format
18544of the recording is target and binary file format dependent, but it
18545usually takes the form of a section containing ASCII text. This
18546switch is related to the @option{-fverbose-asm} switch, but that
18547switch only records information in the assembler output file as
18548comments, so it never reaches the object file.
18549See also @option{-grecord-gcc-switches} for another
18550way of storing compiler options into the object file.
18551
d77de738
ML
18552@opindex fpic
18553@cindex global offset table
18554@cindex PIC
f33d7a88 18555@item -fpic
d77de738
ML
18556Generate position-independent code (PIC) suitable for use in a shared
18557library, if supported for the target machine. Such code accesses all
18558constant addresses through a global offset table (GOT)@. The dynamic
18559loader resolves the GOT entries when the program starts (the dynamic
18560loader is not part of GCC; it is part of the operating system). If
18561the GOT size for the linked executable exceeds a machine-specific
18562maximum size, you get an error message from the linker indicating that
18563@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18564instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18565on the m68k and RS/6000. The x86 has no such limit.)
18566
18567Position-independent code requires special support, and therefore works
18568only on certain machines. For the x86, GCC supports PIC for System V
18569but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18570position-independent.
18571
18572When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18573are defined to 1.
18574
d77de738 18575@opindex fPIC
ddf6fe37 18576@item -fPIC
d77de738
ML
18577If supported for the target machine, emit position-independent code,
18578suitable for dynamic linking and avoiding any limit on the size of the
18579global offset table. This option makes a difference on AArch64, m68k,
18580PowerPC and SPARC@.
18581
18582Position-independent code requires special support, and therefore works
18583only on certain machines.
18584
18585When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18586are defined to 2.
18587
d77de738
ML
18588@opindex fpie
18589@opindex fPIE
ddf6fe37
AA
18590@item -fpie
18591@itemx -fPIE
d77de738
ML
18592These options are similar to @option{-fpic} and @option{-fPIC}, but the
18593generated position-independent code can be only linked into executables.
18594Usually these options are used to compile code that will be linked using
18595the @option{-pie} GCC option.
18596
18597@option{-fpie} and @option{-fPIE} both define the macros
18598@code{__pie__} and @code{__PIE__}. The macros have the value 1
18599for @option{-fpie} and 2 for @option{-fPIE}.
18600
d77de738
ML
18601@opindex fno-plt
18602@opindex fplt
ddf6fe37 18603@item -fno-plt
d77de738
ML
18604Do not use the PLT for external function calls in position-independent code.
18605Instead, load the callee address at call sites from the GOT and branch to it.
18606This leads to more efficient code by eliminating PLT stubs and exposing
18607GOT loads to optimizations. On architectures such as 32-bit x86 where
18608PLT stubs expect the GOT pointer in a specific register, this gives more
18609register allocation freedom to the compiler.
18610Lazy binding requires use of the PLT;
18611with @option{-fno-plt} all external symbols are resolved at load time.
18612
18613Alternatively, the function attribute @code{noplt} can be used to avoid calls
18614through the PLT for specific external functions.
18615
18616In position-dependent code, a few targets also convert calls to
18617functions that are marked to not use the PLT to use the GOT instead.
18618
d77de738
ML
18619@opindex fno-jump-tables
18620@opindex fjump-tables
ddf6fe37 18621@item -fno-jump-tables
d77de738
ML
18622Do not use jump tables for switch statements even where it would be
18623more efficient than other code generation strategies. This option is
18624of use in conjunction with @option{-fpic} or @option{-fPIC} for
18625building code that forms part of a dynamic linker and cannot
18626reference the address of a jump table. On some targets, jump tables
18627do not require a GOT and this option is not needed.
18628
d77de738
ML
18629@opindex fno-bit-tests
18630@opindex fbit-tests
ddf6fe37 18631@item -fno-bit-tests
d77de738
ML
18632Do not use bit tests for switch statements even where it would be
18633more efficient than other code generation strategies.
18634
d77de738 18635@opindex ffixed
ddf6fe37 18636@item -ffixed-@var{reg}
d77de738
ML
18637Treat the register named @var{reg} as a fixed register; generated code
18638should never refer to it (except perhaps as a stack pointer, frame
18639pointer or in some other fixed role).
18640
18641@var{reg} must be the name of a register. The register names accepted
18642are machine-specific and are defined in the @code{REGISTER_NAMES}
18643macro in the machine description macro file.
18644
18645This flag does not have a negative form, because it specifies a
18646three-way choice.
18647
d77de738 18648@opindex fcall-used
ddf6fe37 18649@item -fcall-used-@var{reg}
d77de738
ML
18650Treat the register named @var{reg} as an allocable register that is
18651clobbered by function calls. It may be allocated for temporaries or
18652variables that do not live across a call. Functions compiled this way
18653do not save and restore the register @var{reg}.
18654
18655It is an error to use this flag with the frame pointer or stack pointer.
18656Use of this flag for other registers that have fixed pervasive roles in
18657the machine's execution model produces disastrous results.
18658
18659This flag does not have a negative form, because it specifies a
18660three-way choice.
18661
d77de738 18662@opindex fcall-saved
ddf6fe37 18663@item -fcall-saved-@var{reg}
d77de738
ML
18664Treat the register named @var{reg} as an allocable register saved by
18665functions. It may be allocated even for temporaries or variables that
18666live across a call. Functions compiled this way save and restore
18667the register @var{reg} if they use it.
18668
18669It is an error to use this flag with the frame pointer or stack pointer.
18670Use of this flag for other registers that have fixed pervasive roles in
18671the machine's execution model produces disastrous results.
18672
18673A different sort of disaster results from the use of this flag for
18674a register in which function values may be returned.
18675
18676This flag does not have a negative form, because it specifies a
18677three-way choice.
18678
d77de738 18679@opindex fpack-struct
ddf6fe37 18680@item -fpack-struct[=@var{n}]
d77de738
ML
18681Without a value specified, pack all structure members together without
18682holes. When a value is specified (which must be a small power of two), pack
18683structure members according to this value, representing the maximum
18684alignment (that is, objects with default alignment requirements larger than
18685this are output potentially unaligned at the next fitting location.
18686
18687@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18688code that is not binary compatible with code generated without that switch.
18689Additionally, it makes the code suboptimal.
18690Use it to conform to a non-default application binary interface.
18691
d77de738 18692@opindex fleading-underscore
ddf6fe37 18693@item -fleading-underscore
d77de738
ML
18694This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18695change the way C symbols are represented in the object file. One use
18696is to help link with legacy assembly code.
18697
18698@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18699generate code that is not binary compatible with code generated without that
18700switch. Use it to conform to a non-default application binary interface.
18701Not all targets provide complete support for this switch.
18702
d77de738 18703@opindex ftls-model
ddf6fe37 18704@item -ftls-model=@var{model}
d77de738
ML
18705Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18706The @var{model} argument should be one of @samp{global-dynamic},
18707@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18708Note that the choice is subject to optimization: the compiler may use
18709a more efficient model for symbols not visible outside of the translation
18710unit, or if @option{-fpic} is not given on the command line.
18711
18712The default without @option{-fpic} is @samp{initial-exec}; with
18713@option{-fpic} the default is @samp{global-dynamic}.
18714
d77de738 18715@opindex ftrampolines
ddf6fe37 18716@item -ftrampolines
d77de738
ML
18717For targets that normally need trampolines for nested functions, always
18718generate them instead of using descriptors. Otherwise, for targets that
18719do not need them, like for example HP-PA or IA-64, do nothing.
18720
18721A trampoline is a small piece of code that is created at run time on the
18722stack when the address of a nested function is taken, and is used to call
18723the nested function indirectly. Therefore, it requires the stack to be
18724made executable in order for the program to work properly.
18725
18726@option{-fno-trampolines} is enabled by default on a language by language
18727basis to let the compiler avoid generating them, if it computes that this
18728is safe, and replace them with descriptors. Descriptors are made up of data
18729only, but the generated code must be prepared to deal with them. As of this
18730writing, @option{-fno-trampolines} is enabled by default only for Ada.
18731
18732Moreover, code compiled with @option{-ftrampolines} and code compiled with
18733@option{-fno-trampolines} are not binary compatible if nested functions are
18734present. This option must therefore be used on a program-wide basis and be
18735manipulated with extreme care.
18736
18737For languages other than Ada, the @code{-ftrampolines} and
18738@code{-fno-trampolines} options currently have no effect, and
18739trampolines are always generated on platforms that need them
18740for nested functions.
18741
d77de738 18742@opindex fvisibility
ddf6fe37 18743@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
18744Set the default ELF image symbol visibility to the specified option---all
18745symbols are marked with this unless overridden within the code.
18746Using this feature can very substantially improve linking and
18747load times of shared object libraries, produce more optimized
18748code, provide near-perfect API export and prevent symbol clashes.
18749It is @strong{strongly} recommended that you use this in any shared objects
18750you distribute.
18751
18752Despite the nomenclature, @samp{default} always means public; i.e.,
18753available to be linked against from outside the shared object.
18754@samp{protected} and @samp{internal} are pretty useless in real-world
18755usage so the only other commonly used option is @samp{hidden}.
18756The default if @option{-fvisibility} isn't specified is
18757@samp{default}, i.e., make every symbol public.
18758
18759A good explanation of the benefits offered by ensuring ELF
18760symbols have the correct visibility is given by ``How To Write
18761Shared Libraries'' by Ulrich Drepper (which can be found at
18762@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18763solution made possible by this option to marking things hidden when
18764the default is public is to make the default hidden and mark things
18765public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18766and @code{__attribute__ ((visibility("default")))} instead of
18767@code{__declspec(dllexport)} you get almost identical semantics with
18768identical syntax. This is a great boon to those working with
18769cross-platform projects.
18770
18771For those adding visibility support to existing code, you may find
18772@code{#pragma GCC visibility} of use. This works by you enclosing
18773the declarations you wish to set visibility for with (for example)
18774@code{#pragma GCC visibility push(hidden)} and
18775@code{#pragma GCC visibility pop}.
18776Bear in mind that symbol visibility should be viewed @strong{as
18777part of the API interface contract} and thus all new code should
18778always specify visibility when it is not the default; i.e., declarations
18779only for use within the local DSO should @strong{always} be marked explicitly
18780as hidden as so to avoid PLT indirection overheads---making this
18781abundantly clear also aids readability and self-documentation of the code.
18782Note that due to ISO C++ specification requirements, @code{operator new} and
18783@code{operator delete} must always be of default visibility.
18784
18785Be aware that headers from outside your project, in particular system
18786headers and headers from any other library you use, may not be
18787expecting to be compiled with visibility other than the default. You
18788may need to explicitly say @code{#pragma GCC visibility push(default)}
18789before including any such headers.
18790
18791@code{extern} declarations are not affected by @option{-fvisibility}, so
18792a lot of code can be recompiled with @option{-fvisibility=hidden} with
18793no modifications. However, this means that calls to @code{extern}
18794functions with no explicit visibility use the PLT, so it is more
18795effective to use @code{__attribute ((visibility))} and/or
18796@code{#pragma GCC visibility} to tell the compiler which @code{extern}
18797declarations should be treated as hidden.
18798
18799Note that @option{-fvisibility} does affect C++ vague linkage
18800entities. This means that, for instance, an exception class that is
18801be thrown between DSOs must be explicitly marked with default
18802visibility so that the @samp{type_info} nodes are unified between
18803the DSOs.
18804
18805An overview of these techniques, their benefits and how to use them
18806is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
18807
d77de738 18808@opindex fstrict-volatile-bitfields
ddf6fe37 18809@item -fstrict-volatile-bitfields
d77de738
ML
18810This option should be used if accesses to volatile bit-fields (or other
18811structure fields, although the compiler usually honors those types
18812anyway) should use a single access of the width of the
18813field's type, aligned to a natural alignment if possible. For
18814example, targets with memory-mapped peripheral registers might require
18815all such accesses to be 16 bits wide; with this flag you can
18816declare all peripheral bit-fields as @code{unsigned short} (assuming short
18817is 16 bits on these targets) to force GCC to use 16-bit accesses
18818instead of, perhaps, a more efficient 32-bit access.
18819
18820If this option is disabled, the compiler uses the most efficient
18821instruction. In the previous example, that might be a 32-bit load
18822instruction, even though that accesses bytes that do not contain
18823any portion of the bit-field, or memory-mapped registers unrelated to
18824the one being updated.
18825
18826In some cases, such as when the @code{packed} attribute is applied to a
18827structure field, it may not be possible to access the field with a single
18828read or write that is correctly aligned for the target machine. In this
18829case GCC falls back to generating multiple accesses rather than code that
18830will fault or truncate the result at run time.
18831
18832Note: Due to restrictions of the C/C++11 memory model, write accesses are
18833not allowed to touch non bit-field members. It is therefore recommended
18834to define all bits of the field's type as bit-field members.
18835
18836The default value of this option is determined by the application binary
18837interface for the target processor.
18838
d77de738 18839@opindex fsync-libcalls
ddf6fe37 18840@item -fsync-libcalls
d77de738
ML
18841This option controls whether any out-of-line instance of the @code{__sync}
18842family of functions may be used to implement the C++11 @code{__atomic}
18843family of functions.
18844
18845The default value of this option is enabled, thus the only useful form
18846of the option is @option{-fno-sync-libcalls}. This option is used in
18847the implementation of the @file{libatomic} runtime library.
18848
18849@end table
18850
18851@node Developer Options
18852@section GCC Developer Options
18853@cindex developer options
18854@cindex debugging GCC
18855@cindex debug dump options
18856@cindex dump options
18857@cindex compilation statistics
18858
18859This section describes command-line options that are primarily of
18860interest to GCC developers, including options to support compiler
18861testing and investigation of compiler bugs and compile-time
18862performance problems. This includes options that produce debug dumps
18863at various points in the compilation; that print statistics such as
18864memory use and execution time; and that print information about GCC's
18865configuration, such as where it searches for libraries. You should
18866rarely need to use any of these options for ordinary compilation and
18867linking tasks.
18868
18869Many developer options that cause GCC to dump output to a file take an
18870optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
18871or @samp{-} to dump to standard output, and @samp{stderr} for standard
18872error.
18873
18874If @samp{=@var{filename}} is omitted, a default dump file name is
18875constructed by concatenating the base dump file name, a pass number,
18876phase letter, and pass name. The base dump file name is the name of
18877output file produced by the compiler if explicitly specified and not
18878an executable; otherwise it is the source file name.
18879The pass number is determined by the order passes are registered with
18880the compiler's pass manager.
18881This is generally the same as the order of execution, but passes
18882registered by plugins, target-specific passes, or passes that are
18883otherwise registered late are numbered higher than the pass named
18884@samp{final}, even if they are executed earlier. The phase letter is
18885one of @samp{i} (inter-procedural analysis), @samp{l}
18886(language-specific), @samp{r} (RTL), or @samp{t} (tree).
18887The files are created in the directory of the output file.
18888
18889@table @gcctabopt
18890
ddf6fe37 18891@opindex fcallgraph-info
d77de738
ML
18892@item -fcallgraph-info
18893@itemx -fcallgraph-info=@var{MARKERS}
d77de738
ML
18894Makes the compiler output callgraph information for the program, on a
18895per-object-file basis. The information is generated in the common VCG
18896format. It can be decorated with additional, per-node and/or per-edge
18897information, if a list of comma-separated markers is additionally
18898specified. When the @code{su} marker is specified, the callgraph is
18899decorated with stack usage information; it is equivalent to
18900@option{-fstack-usage}. When the @code{da} marker is specified, the
18901callgraph is decorated with information about dynamically allocated
18902objects.
18903
18904When compiling with @option{-flto}, no callgraph information is output
18905along with the object file. At LTO link time, @option{-fcallgraph-info}
18906may generate multiple callgraph information files next to intermediate
18907LTO output files.
18908
ddf6fe37
AA
18909@opindex d
18910@opindex fdump-rtl-@var{pass}
d77de738
ML
18911@item -d@var{letters}
18912@itemx -fdump-rtl-@var{pass}
18913@itemx -fdump-rtl-@var{pass}=@var{filename}
d77de738
ML
18914Says to make debugging dumps during compilation at times specified by
18915@var{letters}. This is used for debugging the RTL-based passes of the
18916compiler.
18917
18918Some @option{-d@var{letters}} switches have different meaning when
18919@option{-E} is used for preprocessing. @xref{Preprocessor Options},
18920for information about preprocessor-specific dump options.
18921
18922Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
18923@option{-d} option @var{letters}. Here are the possible
18924letters for use in @var{pass} and @var{letters}, and their meanings:
18925
18926@table @gcctabopt
18927
d77de738 18928@opindex fdump-rtl-alignments
ddf6fe37 18929@item -fdump-rtl-alignments
d77de738
ML
18930Dump after branch alignments have been computed.
18931
d77de738 18932@opindex fdump-rtl-asmcons
ddf6fe37 18933@item -fdump-rtl-asmcons
d77de738
ML
18934Dump after fixing rtl statements that have unsatisfied in/out constraints.
18935
d77de738 18936@opindex fdump-rtl-auto_inc_dec
ddf6fe37 18937@item -fdump-rtl-auto_inc_dec
d77de738
ML
18938Dump after auto-inc-dec discovery. This pass is only run on
18939architectures that have auto inc or auto dec instructions.
18940
d77de738 18941@opindex fdump-rtl-barriers
ddf6fe37 18942@item -fdump-rtl-barriers
d77de738
ML
18943Dump after cleaning up the barrier instructions.
18944
d77de738 18945@opindex fdump-rtl-bbpart
ddf6fe37 18946@item -fdump-rtl-bbpart
d77de738
ML
18947Dump after partitioning hot and cold basic blocks.
18948
d77de738 18949@opindex fdump-rtl-bbro
ddf6fe37 18950@item -fdump-rtl-bbro
d77de738
ML
18951Dump after block reordering.
18952
d77de738
ML
18953@opindex fdump-rtl-btl2
18954@opindex fdump-rtl-btl2
ddf6fe37
AA
18955@item -fdump-rtl-btl1
18956@itemx -fdump-rtl-btl2
d77de738
ML
18957@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
18958after the two branch
18959target load optimization passes.
18960
d77de738 18961@opindex fdump-rtl-bypass
ddf6fe37 18962@item -fdump-rtl-bypass
d77de738
ML
18963Dump after jump bypassing and control flow optimizations.
18964
d77de738 18965@opindex fdump-rtl-combine
ddf6fe37 18966@item -fdump-rtl-combine
d77de738
ML
18967Dump after the RTL instruction combination pass.
18968
d77de738 18969@opindex fdump-rtl-compgotos
ddf6fe37 18970@item -fdump-rtl-compgotos
d77de738
ML
18971Dump after duplicating the computed gotos.
18972
d77de738
ML
18973@opindex fdump-rtl-ce1
18974@opindex fdump-rtl-ce2
18975@opindex fdump-rtl-ce3
ddf6fe37
AA
18976@item -fdump-rtl-ce1
18977@itemx -fdump-rtl-ce2
18978@itemx -fdump-rtl-ce3
d77de738
ML
18979@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
18980@option{-fdump-rtl-ce3} enable dumping after the three
18981if conversion passes.
18982
d77de738 18983@opindex fdump-rtl-cprop_hardreg
ddf6fe37 18984@item -fdump-rtl-cprop_hardreg
d77de738
ML
18985Dump after hard register copy propagation.
18986
d77de738 18987@opindex fdump-rtl-csa
ddf6fe37 18988@item -fdump-rtl-csa
d77de738
ML
18989Dump after combining stack adjustments.
18990
d77de738
ML
18991@opindex fdump-rtl-cse1
18992@opindex fdump-rtl-cse2
ddf6fe37
AA
18993@item -fdump-rtl-cse1
18994@itemx -fdump-rtl-cse2
d77de738
ML
18995@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
18996the two common subexpression elimination passes.
18997
d77de738 18998@opindex fdump-rtl-dce
ddf6fe37 18999@item -fdump-rtl-dce
d77de738
ML
19000Dump after the standalone dead code elimination passes.
19001
d77de738 19002@opindex fdump-rtl-dbr
ddf6fe37 19003@item -fdump-rtl-dbr
d77de738
ML
19004Dump after delayed branch scheduling.
19005
d77de738
ML
19006@opindex fdump-rtl-dce1
19007@opindex fdump-rtl-dce2
ddf6fe37
AA
19008@item -fdump-rtl-dce1
19009@itemx -fdump-rtl-dce2
d77de738
ML
19010@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
19011the two dead store elimination passes.
19012
d77de738 19013@opindex fdump-rtl-eh
ddf6fe37 19014@item -fdump-rtl-eh
d77de738
ML
19015Dump after finalization of EH handling code.
19016
d77de738 19017@opindex fdump-rtl-eh_ranges
ddf6fe37 19018@item -fdump-rtl-eh_ranges
d77de738
ML
19019Dump after conversion of EH handling range regions.
19020
d77de738 19021@opindex fdump-rtl-expand
ddf6fe37 19022@item -fdump-rtl-expand
d77de738
ML
19023Dump after RTL generation.
19024
d77de738
ML
19025@opindex fdump-rtl-fwprop1
19026@opindex fdump-rtl-fwprop2
ddf6fe37
AA
19027@item -fdump-rtl-fwprop1
19028@itemx -fdump-rtl-fwprop2
d77de738
ML
19029@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
19030dumping after the two forward propagation passes.
19031
d77de738
ML
19032@opindex fdump-rtl-gcse1
19033@opindex fdump-rtl-gcse2
ddf6fe37
AA
19034@item -fdump-rtl-gcse1
19035@itemx -fdump-rtl-gcse2
d77de738
ML
19036@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
19037after global common subexpression elimination.
19038
d77de738 19039@opindex fdump-rtl-init-regs
ddf6fe37 19040@item -fdump-rtl-init-regs
d77de738
ML
19041Dump after the initialization of the registers.
19042
d77de738 19043@opindex fdump-rtl-initvals
ddf6fe37 19044@item -fdump-rtl-initvals
d77de738
ML
19045Dump after the computation of the initial value sets.
19046
d77de738 19047@opindex fdump-rtl-into_cfglayout
ddf6fe37 19048@item -fdump-rtl-into_cfglayout
d77de738
ML
19049Dump after converting to cfglayout mode.
19050
d77de738 19051@opindex fdump-rtl-ira
ddf6fe37 19052@item -fdump-rtl-ira
d77de738
ML
19053Dump after iterated register allocation.
19054
d77de738 19055@opindex fdump-rtl-jump
ddf6fe37 19056@item -fdump-rtl-jump
d77de738
ML
19057Dump after the second jump optimization.
19058
d77de738 19059@opindex fdump-rtl-loop2
ddf6fe37 19060@item -fdump-rtl-loop2
d77de738
ML
19061@option{-fdump-rtl-loop2} enables dumping after the rtl
19062loop optimization passes.
19063
d77de738 19064@opindex fdump-rtl-mach
ddf6fe37 19065@item -fdump-rtl-mach
d77de738
ML
19066Dump after performing the machine dependent reorganization pass, if that
19067pass exists.
19068
d77de738 19069@opindex fdump-rtl-mode_sw
ddf6fe37 19070@item -fdump-rtl-mode_sw
d77de738
ML
19071Dump after removing redundant mode switches.
19072
d77de738 19073@opindex fdump-rtl-rnreg
ddf6fe37 19074@item -fdump-rtl-rnreg
d77de738
ML
19075Dump after register renumbering.
19076
d77de738 19077@opindex fdump-rtl-outof_cfglayout
ddf6fe37 19078@item -fdump-rtl-outof_cfglayout
d77de738
ML
19079Dump after converting from cfglayout mode.
19080
d77de738 19081@opindex fdump-rtl-peephole2
ddf6fe37 19082@item -fdump-rtl-peephole2
d77de738
ML
19083Dump after the peephole pass.
19084
d77de738 19085@opindex fdump-rtl-postreload
ddf6fe37 19086@item -fdump-rtl-postreload
d77de738
ML
19087Dump after post-reload optimizations.
19088
d77de738 19089@opindex fdump-rtl-pro_and_epilogue
ddf6fe37 19090@item -fdump-rtl-pro_and_epilogue
d77de738
ML
19091Dump after generating the function prologues and epilogues.
19092
d77de738
ML
19093@opindex fdump-rtl-sched1
19094@opindex fdump-rtl-sched2
ddf6fe37
AA
19095@item -fdump-rtl-sched1
19096@itemx -fdump-rtl-sched2
d77de738
ML
19097@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
19098after the basic block scheduling passes.
19099
d77de738 19100@opindex fdump-rtl-ree
ddf6fe37 19101@item -fdump-rtl-ree
d77de738
ML
19102Dump after sign/zero extension elimination.
19103
d77de738 19104@opindex fdump-rtl-seqabstr
ddf6fe37 19105@item -fdump-rtl-seqabstr
d77de738
ML
19106Dump after common sequence discovery.
19107
d77de738 19108@opindex fdump-rtl-shorten
ddf6fe37 19109@item -fdump-rtl-shorten
d77de738
ML
19110Dump after shortening branches.
19111
d77de738 19112@opindex fdump-rtl-sibling
ddf6fe37 19113@item -fdump-rtl-sibling
d77de738
ML
19114Dump after sibling call optimizations.
19115
d77de738
ML
19116@opindex fdump-rtl-split1
19117@opindex fdump-rtl-split2
19118@opindex fdump-rtl-split3
19119@opindex fdump-rtl-split4
19120@opindex fdump-rtl-split5
ddf6fe37
AA
19121@item -fdump-rtl-split1
19122@itemx -fdump-rtl-split2
19123@itemx -fdump-rtl-split3
19124@itemx -fdump-rtl-split4
19125@itemx -fdump-rtl-split5
d77de738
ML
19126These options enable dumping after five rounds of
19127instruction splitting.
19128
d77de738 19129@opindex fdump-rtl-sms
ddf6fe37 19130@item -fdump-rtl-sms
d77de738
ML
19131Dump after modulo scheduling. This pass is only run on some
19132architectures.
19133
d77de738 19134@opindex fdump-rtl-stack
ddf6fe37 19135@item -fdump-rtl-stack
d77de738
ML
19136Dump after conversion from GCC's ``flat register file'' registers to the
19137x87's stack-like registers. This pass is only run on x86 variants.
19138
d77de738
ML
19139@opindex fdump-rtl-subreg1
19140@opindex fdump-rtl-subreg2
ddf6fe37
AA
19141@item -fdump-rtl-subreg1
19142@itemx -fdump-rtl-subreg2
d77de738
ML
19143@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
19144the two subreg expansion passes.
19145
d77de738 19146@opindex fdump-rtl-unshare
ddf6fe37 19147@item -fdump-rtl-unshare
d77de738
ML
19148Dump after all rtl has been unshared.
19149
d77de738 19150@opindex fdump-rtl-vartrack
ddf6fe37 19151@item -fdump-rtl-vartrack
d77de738
ML
19152Dump after variable tracking.
19153
d77de738 19154@opindex fdump-rtl-vregs
ddf6fe37 19155@item -fdump-rtl-vregs
d77de738
ML
19156Dump after converting virtual registers to hard registers.
19157
d77de738 19158@opindex fdump-rtl-web
ddf6fe37 19159@item -fdump-rtl-web
d77de738
ML
19160Dump after live range splitting.
19161
d77de738
ML
19162@opindex fdump-rtl-regclass
19163@opindex fdump-rtl-subregs_of_mode_init
19164@opindex fdump-rtl-subregs_of_mode_finish
19165@opindex fdump-rtl-dfinit
19166@opindex fdump-rtl-dfinish
ddf6fe37
AA
19167@item -fdump-rtl-regclass
19168@itemx -fdump-rtl-subregs_of_mode_init
19169@itemx -fdump-rtl-subregs_of_mode_finish
19170@itemx -fdump-rtl-dfinit
19171@itemx -fdump-rtl-dfinish
d77de738
ML
19172These dumps are defined but always produce empty files.
19173
d77de738
ML
19174@opindex da
19175@opindex fdump-rtl-all
ddf6fe37
AA
19176@item -da
19177@itemx -fdump-rtl-all
d77de738
ML
19178Produce all the dumps listed above.
19179
d77de738 19180@opindex dA
ddf6fe37 19181@item -dA
d77de738
ML
19182Annotate the assembler output with miscellaneous debugging information.
19183
d77de738 19184@opindex dD
ddf6fe37 19185@item -dD
d77de738
ML
19186Dump all macro definitions, at the end of preprocessing, in addition to
19187normal output.
19188
d77de738 19189@opindex dH
ddf6fe37 19190@item -dH
d77de738
ML
19191Produce a core dump whenever an error occurs.
19192
d77de738 19193@opindex dp
ddf6fe37 19194@item -dp
d77de738
ML
19195Annotate the assembler output with a comment indicating which
19196pattern and alternative is used. The length and cost of each instruction are
19197also printed.
19198
d77de738 19199@opindex dP
ddf6fe37 19200@item -dP
d77de738
ML
19201Dump the RTL in the assembler output as a comment before each instruction.
19202Also turns on @option{-dp} annotation.
19203
d77de738 19204@opindex dx
ddf6fe37 19205@item -dx
d77de738
ML
19206Just generate RTL for a function instead of compiling it. Usually used
19207with @option{-fdump-rtl-expand}.
19208@end table
19209
d77de738 19210@opindex fdump-debug
ddf6fe37 19211@item -fdump-debug
d77de738
ML
19212Dump debugging information generated during the debug
19213generation phase.
19214
d77de738 19215@opindex fdump-earlydebug
ddf6fe37 19216@item -fdump-earlydebug
d77de738
ML
19217Dump debugging information generated during the early debug
19218generation phase.
19219
d77de738 19220@opindex fdump-noaddr
ddf6fe37 19221@item -fdump-noaddr
d77de738
ML
19222When doing debugging dumps, suppress address output. This makes it more
19223feasible to use diff on debugging dumps for compiler invocations with
19224different compiler binaries and/or different
19225text / bss / data / heap / stack / dso start locations.
19226
d77de738 19227@opindex freport-bug
ddf6fe37 19228@item -freport-bug
d77de738
ML
19229Collect and dump debug information into a temporary file if an
19230internal compiler error (ICE) occurs.
19231
d77de738 19232@opindex fdump-unnumbered
ddf6fe37 19233@item -fdump-unnumbered
d77de738
ML
19234When doing debugging dumps, suppress instruction numbers and address output.
19235This makes it more feasible to use diff on debugging dumps for compiler
19236invocations with different options, in particular with and without
19237@option{-g}.
19238
d77de738 19239@opindex fdump-unnumbered-links
ddf6fe37 19240@item -fdump-unnumbered-links
d77de738
ML
19241When doing debugging dumps (see @option{-d} option above), suppress
19242instruction numbers for the links to the previous and next instructions
19243in a sequence.
19244
ddf6fe37 19245@opindex fdump-ipa
d77de738
ML
19246@item -fdump-ipa-@var{switch}
19247@itemx -fdump-ipa-@var{switch}-@var{options}
d77de738
ML
19248Control the dumping at various stages of inter-procedural analysis
19249language tree to a file. The file name is generated by appending a
19250switch specific suffix to the source file name, and the file is created
19251in the same directory as the output file. The following dumps are
19252possible:
19253
19254@table @samp
19255@item all
19256Enables all inter-procedural analysis dumps.
19257
19258@item cgraph
19259Dumps information about call-graph optimization, unused function removal,
19260and inlining decisions.
19261
19262@item inline
19263Dump after function inlining.
19264
19265@end table
19266
19267Additionally, the options @option{-optimized}, @option{-missed},
19268@option{-note}, and @option{-all} can be provided, with the same meaning
19269as for @option{-fopt-info}, defaulting to @option{-optimized}.
19270
19271For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19272information on callsites that were inlined, along with callsites
19273that were not inlined.
19274
19275By default, the dump will contain messages about successful
19276optimizations (equivalent to @option{-optimized}) together with
19277low-level details about the analysis.
19278
d77de738 19279@opindex fdump-lang
ddf6fe37 19280@item -fdump-lang
d77de738
ML
19281Dump language-specific information. The file name is made by appending
19282@file{.lang} to the source file name.
19283
ddf6fe37
AA
19284@opindex fdump-lang-all
19285@opindex fdump-lang
d77de738
ML
19286@item -fdump-lang-all
19287@itemx -fdump-lang-@var{switch}
19288@itemx -fdump-lang-@var{switch}-@var{options}
19289@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19290Control the dumping of language-specific information. The @var{options}
19291and @var{filename} portions behave as described in the
19292@option{-fdump-tree} option. The following @var{switch} values are
19293accepted:
19294
19295@table @samp
19296@item all
19297
19298Enable all language-specific dumps.
19299
19300@item class
19301Dump class hierarchy information. Virtual table information is emitted
19302unless '@option{slim}' is specified. This option is applicable to C++ only.
19303
19304@item module
19305Dump module information. Options @option{lineno} (locations),
19306@option{graph} (reachability), @option{blocks} (clusters),
19307@option{uid} (serialization), @option{alias} (mergeable),
19308@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19309(macros) may provide additional information. This option is
19310applicable to C++ only.
19311
19312@item raw
19313Dump the raw internal tree data. This option is applicable to C++ only.
19314
19315@end table
19316
d77de738 19317@opindex fdump-passes
ddf6fe37 19318@item -fdump-passes
d77de738
ML
19319Print on @file{stderr} the list of optimization passes that are turned
19320on and off by the current command-line options.
19321
d77de738 19322@opindex fdump-statistics
ddf6fe37 19323@item -fdump-statistics-@var{option}
d77de738
ML
19324Enable and control dumping of pass statistics in a separate file. The
19325file name is generated by appending a suffix ending in
19326@samp{.statistics} to the source file name, and the file is created in
19327the same directory as the output file. If the @samp{-@var{option}}
19328form is used, @samp{-stats} causes counters to be summed over the
19329whole compilation unit while @samp{-details} dumps every event as
19330the passes generate them. The default with no option is to sum
19331counters for each function compiled.
19332
ddf6fe37
AA
19333@opindex fdump-tree-all
19334@opindex fdump-tree
d77de738
ML
19335@item -fdump-tree-all
19336@itemx -fdump-tree-@var{switch}
19337@itemx -fdump-tree-@var{switch}-@var{options}
19338@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19339Control the dumping at various stages of processing the intermediate
19340language tree to a file. If the @samp{-@var{options}}
19341form is used, @var{options} is a list of @samp{-} separated options
19342which control the details of the dump. Not all options are applicable
19343to all dumps; those that are not meaningful are ignored. The
19344following options are available
19345
19346@table @samp
19347@item address
19348Print the address of each node. Usually this is not meaningful as it
19349changes according to the environment and source file. Its primary use
19350is for tying up a dump file with a debug environment.
19351@item asmname
19352If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19353in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19354use working backward from mangled names in the assembly file.
19355@item slim
19356When dumping front-end intermediate representations, inhibit dumping
19357of members of a scope or body of a function merely because that scope
19358has been reached. Only dump such items when they are directly reachable
19359by some other path.
19360
19361When dumping pretty-printed trees, this option inhibits dumping the
19362bodies of control structures.
19363
19364When dumping RTL, print the RTL in slim (condensed) form instead of
19365the default LISP-like representation.
19366@item raw
19367Print a raw representation of the tree. By default, trees are
19368pretty-printed into a C-like representation.
19369@item details
19370Enable more detailed dumps (not honored by every dump option). Also
19371include information from the optimization passes.
19372@item stats
19373Enable dumping various statistics about the pass (not honored by every dump
19374option).
19375@item blocks
19376Enable showing basic block boundaries (disabled in raw dumps).
19377@item graph
19378For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19379dump a representation of the control flow graph suitable for viewing with
19380GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19381the file is pretty-printed as a subgraph, so that GraphViz can render them
19382all in a single plot.
19383
19384This option currently only works for RTL dumps, and the RTL is always
19385dumped in slim form.
19386@item vops
19387Enable showing virtual operands for every statement.
19388@item lineno
19389Enable showing line numbers for statements.
19390@item uid
19391Enable showing the unique ID (@code{DECL_UID}) for each variable.
19392@item verbose
19393Enable showing the tree dump for each statement.
19394@item eh
19395Enable showing the EH region number holding each statement.
19396@item scev
19397Enable showing scalar evolution analysis details.
19398@item optimized
19399Enable showing optimization information (only available in certain
19400passes).
19401@item missed
19402Enable showing missed optimization information (only available in certain
19403passes).
19404@item note
19405Enable other detailed optimization information (only available in
19406certain passes).
19407@item all
19408Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19409and @option{lineno}.
19410@item optall
19411Turn on all optimization options, i.e., @option{optimized},
19412@option{missed}, and @option{note}.
19413@end table
19414
19415To determine what tree dumps are available or find the dump for a pass
19416of interest follow the steps below.
19417
19418@enumerate
19419@item
19420Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19421look for a code that corresponds to the pass you are interested in.
19422For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19423@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19424The number at the end distinguishes distinct invocations of the same pass.
19425@item
19426To enable the creation of the dump file, append the pass code to
19427the @option{-fdump-} option prefix and invoke GCC with it. For example,
19428to enable the dump from the Early Value Range Propagation pass, invoke
19429GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19430specify the name of the dump file. If you don't specify one, GCC
19431creates as described below.
19432@item
19433Find the pass dump in a file whose name is composed of three components
19434separated by a period: the name of the source file GCC was invoked to
19435compile, a numeric suffix indicating the pass number followed by the
19436letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19437and finally the pass code. For example, the Early VRP pass dump might
19438be in a file named @file{myfile.c.038t.evrp} in the current working
19439directory. Note that the numeric codes are not stable and may change
19440from one version of GCC to another.
19441@end enumerate
19442
ddf6fe37 19443@opindex fopt-info
d77de738
ML
19444@item -fopt-info
19445@itemx -fopt-info-@var{options}
19446@itemx -fopt-info-@var{options}=@var{filename}
d77de738
ML
19447Controls optimization dumps from various optimization passes. If the
19448@samp{-@var{options}} form is used, @var{options} is a list of
19449@samp{-} separated option keywords to select the dump details and
19450optimizations.
19451
19452The @var{options} can be divided into three groups:
19453@enumerate
19454@item
19455options describing what kinds of messages should be emitted,
19456@item
19457options describing the verbosity of the dump, and
19458@item
19459options describing which optimizations should be included.
19460@end enumerate
19461The options from each group can be freely mixed as they are
19462non-overlapping. However, in case of any conflicts,
19463the later options override the earlier options on the command
19464line.
19465
19466The following options control which kinds of messages should be emitted:
19467
19468@table @samp
19469@item optimized
19470Print information when an optimization is successfully applied. It is
19471up to a pass to decide which information is relevant. For example, the
19472vectorizer passes print the source location of loops which are
19473successfully vectorized.
19474@item missed
19475Print information about missed optimizations. Individual passes
19476control which information to include in the output.
19477@item note
19478Print verbose information about optimizations, such as certain
19479transformations, more detailed messages about decisions etc.
19480@item all
19481Print detailed optimization information. This includes
19482@samp{optimized}, @samp{missed}, and @samp{note}.
19483@end table
19484
19485The following option controls the dump verbosity:
19486
19487@table @samp
19488@item internals
19489By default, only ``high-level'' messages are emitted. This option enables
19490additional, more detailed, messages, which are likely to only be of interest
19491to GCC developers.
19492@end table
19493
19494One or more of the following option keywords can be used to describe a
19495group of optimizations:
19496
19497@table @samp
19498@item ipa
19499Enable dumps from all interprocedural optimizations.
19500@item loop
19501Enable dumps from all loop optimizations.
19502@item inline
19503Enable dumps from all inlining optimizations.
19504@item omp
19505Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19506@item vec
19507Enable dumps from all vectorization optimizations.
19508@item optall
19509Enable dumps from all optimizations. This is a superset of
19510the optimization groups listed above.
19511@end table
19512
19513If @var{options} is
19514omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19515about successful optimizations from all the passes, omitting messages
19516that are treated as ``internals''.
19517
19518If the @var{filename} is provided, then the dumps from all the
19519applicable optimizations are concatenated into the @var{filename}.
19520Otherwise the dump is output onto @file{stderr}. Though multiple
19521@option{-fopt-info} options are accepted, only one of them can include
19522a @var{filename}. If other filenames are provided then all but the
19523first such option are ignored.
19524
19525Note that the output @var{filename} is overwritten
19526in case of multiple translation units. If a combined output from
19527multiple translation units is desired, @file{stderr} should be used
19528instead.
19529
19530In the following example, the optimization info is output to
19531@file{stderr}:
19532
19533@smallexample
19534gcc -O3 -fopt-info
19535@end smallexample
19536
19537This example:
19538@smallexample
19539gcc -O3 -fopt-info-missed=missed.all
19540@end smallexample
19541
19542@noindent
19543outputs missed optimization report from all the passes into
19544@file{missed.all}, and this one:
19545
19546@smallexample
19547gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19548@end smallexample
19549
19550@noindent
19551prints information about missed optimization opportunities from
19552vectorization passes on @file{stderr}.
19553Note that @option{-fopt-info-vec-missed} is equivalent to
19554@option{-fopt-info-missed-vec}. The order of the optimization group
19555names and message types listed after @option{-fopt-info} does not matter.
19556
19557As another example,
19558@smallexample
19559gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19560@end smallexample
19561
19562@noindent
19563outputs information about missed optimizations as well as
19564optimized locations from all the inlining passes into
19565@file{inline.txt}.
19566
19567Finally, consider:
19568
19569@smallexample
19570gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19571@end smallexample
19572
19573@noindent
19574Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19575in conflict since only one output file is allowed. In this case, only
19576the first option takes effect and the subsequent options are
19577ignored. Thus only @file{vec.miss} is produced which contains
19578dumps from the vectorizer about missed opportunities.
19579
d77de738 19580@opindex fsave-optimization-record
ddf6fe37 19581@item -fsave-optimization-record
d77de738
ML
19582Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19583were performed, for those optimizations that support @option{-fopt-info}.
19584
19585This option is experimental and the format of the data within the
19586compressed JSON file is subject to change.
19587
19588It is roughly equivalent to a machine-readable version of
19589@option{-fopt-info-all}, as a collection of messages with source file,
19590line number and column number, with the following additional data for
19591each message:
19592
19593@itemize @bullet
19594
19595@item
19596the execution count of the code being optimized, along with metadata about
19597whether this was from actual profile data, or just an estimate, allowing
19598consumers to prioritize messages by code hotness,
19599
19600@item
19601the function name of the code being optimized, where applicable,
19602
19603@item
19604the ``inlining chain'' for the code being optimized, so that when
19605a function is inlined into several different places (which might
19606themselves be inlined), the reader can distinguish between the copies,
19607
19608@item
19609objects identifying those parts of the message that refer to expressions,
19610statements or symbol-table nodes, which of these categories they are, and,
19611when available, their source code location,
19612
19613@item
19614the GCC pass that emitted the message, and
19615
19616@item
19617the location in GCC's own code from which the message was emitted
19618
19619@end itemize
19620
19621Additionally, some messages are logically nested within other
19622messages, reflecting implementation details of the optimization
19623passes.
19624
d77de738 19625@opindex fsched-verbose
ddf6fe37 19626@item -fsched-verbose=@var{n}
d77de738
ML
19627On targets that use instruction scheduling, this option controls the
19628amount of debugging output the scheduler prints to the dump files.
19629
19630For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19631same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19632For @var{n} greater than one, it also output basic block probabilities,
19633detailed ready list information and unit/insn info. For @var{n} greater
19634than two, it includes RTL at abort point, control-flow and regions info.
19635And for @var{n} over four, @option{-fsched-verbose} also includes
19636dependence info.
19637
19638
19639
d77de738
ML
19640@opindex fdisable-
19641@opindex fenable-
ddf6fe37
AA
19642@item -fenable-@var{kind}-@var{pass}
19643@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
d77de738
ML
19644
19645This is a set of options that are used to explicitly disable/enable
19646optimization passes. These options are intended for use for debugging GCC.
19647Compiler users should use regular options for enabling/disabling
19648passes instead.
19649
19650@table @gcctabopt
19651
19652@item -fdisable-ipa-@var{pass}
19653Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19654statically invoked in the compiler multiple times, the pass name should be
19655appended with a sequential number starting from 1.
19656
19657@item -fdisable-rtl-@var{pass}
19658@itemx -fdisable-rtl-@var{pass}=@var{range-list}
19659Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19660statically invoked in the compiler multiple times, the pass name should be
19661appended with a sequential number starting from 1. @var{range-list} is a
19662comma-separated list of function ranges or assembler names. Each range is a number
19663pair separated by a colon. The range is inclusive in both ends. If the range
19664is trivial, the number pair can be simplified as a single number. If the
19665function's call graph node's @var{uid} falls within one of the specified ranges,
19666the @var{pass} is disabled for that function. The @var{uid} is shown in the
19667function header of a dump file, and the pass names can be dumped by using
19668option @option{-fdump-passes}.
19669
19670@item -fdisable-tree-@var{pass}
19671@itemx -fdisable-tree-@var{pass}=@var{range-list}
19672Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19673option arguments.
19674
19675@item -fenable-ipa-@var{pass}
19676Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19677statically invoked in the compiler multiple times, the pass name should be
19678appended with a sequential number starting from 1.
19679
19680@item -fenable-rtl-@var{pass}
19681@itemx -fenable-rtl-@var{pass}=@var{range-list}
19682Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19683description and examples.
19684
19685@item -fenable-tree-@var{pass}
19686@itemx -fenable-tree-@var{pass}=@var{range-list}
19687Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19688of option arguments.
19689
19690@end table
19691
19692Here are some examples showing uses of these options.
19693
19694@smallexample
19695
19696# disable ccp1 for all functions
19697 -fdisable-tree-ccp1
19698# disable complete unroll for function whose cgraph node uid is 1
19699 -fenable-tree-cunroll=1
19700# disable gcse2 for functions at the following ranges [1,1],
19701# [300,400], and [400,1000]
19702# disable gcse2 for functions foo and foo2
19703 -fdisable-rtl-gcse2=foo,foo2
19704# disable early inlining
19705 -fdisable-tree-einline
19706# disable ipa inlining
19707 -fdisable-ipa-inline
19708# enable tree full unroll
19709 -fenable-tree-unroll
19710
19711@end smallexample
19712
d77de738
ML
19713@opindex fchecking
19714@opindex fno-checking
ddf6fe37
AA
19715@item -fchecking
19716@itemx -fchecking=@var{n}
d77de738
ML
19717Enable internal consistency checking. The default depends on
19718the compiler configuration. @option{-fchecking=2} enables further
19719internal consistency checking that might affect code generation.
19720
d77de738 19721@opindex frandom-seed
ddf6fe37 19722@item -frandom-seed=@var{string}
d77de738
ML
19723This option provides a seed that GCC uses in place of
19724random numbers in generating certain symbol names
19725that have to be different in every compiled file. It is also used to
19726place unique stamps in coverage data files and the object files that
19727produce them. You can use the @option{-frandom-seed} option to produce
19728reproducibly identical object files.
19729
19730The @var{string} can either be a number (decimal, octal or hex) or an
19731arbitrary string (in which case it's converted to a number by
19732computing CRC32).
19733
19734The @var{string} should be different for every file you compile.
19735
d77de738 19736@opindex save-temps
ddf6fe37 19737@item -save-temps
d77de738
ML
19738Store the usual ``temporary'' intermediate files permanently; name them
19739as auxiliary output files, as specified described under
19740@option{-dumpbase} and @option{-dumpdir}.
19741
19742When used in combination with the @option{-x} command-line option,
19743@option{-save-temps} is sensible enough to avoid overwriting an
19744input source file with the same extension as an intermediate file.
19745The corresponding intermediate file may be obtained by renaming the
19746source file before using @option{-save-temps}.
19747
d77de738 19748@opindex save-temps=cwd
ddf6fe37 19749@item -save-temps=cwd
d77de738
ML
19750Equivalent to @option{-save-temps -dumpdir ./}.
19751
d77de738 19752@opindex save-temps=obj
ddf6fe37 19753@item -save-temps=obj
d77de738
ML
19754Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19755@file{outdir/} is the directory of the output file specified after the
19756@option{-o} option, including any directory separators. If the
19757@option{-o} option is not used, the @option{-save-temps=obj} switch
19758behaves like @option{-save-temps=cwd}.
19759
d77de738 19760@opindex time
ddf6fe37 19761@item -time@r{[}=@var{file}@r{]}
d77de738
ML
19762Report the CPU time taken by each subprocess in the compilation
19763sequence. For C source files, this is the compiler proper and assembler
19764(plus the linker if linking is done).
19765
19766Without the specification of an output file, the output looks like this:
19767
19768@smallexample
19769# cc1 0.12 0.01
19770# as 0.00 0.01
19771@end smallexample
19772
19773The first number on each line is the ``user time'', that is time spent
19774executing the program itself. The second number is ``system time'',
19775time spent executing operating system routines on behalf of the program.
19776Both numbers are in seconds.
19777
19778With the specification of an output file, the output is appended to the
19779named file, and it looks like this:
19780
19781@smallexample
197820.12 0.01 cc1 @var{options}
197830.00 0.01 as @var{options}
19784@end smallexample
19785
19786The ``user time'' and the ``system time'' are moved before the program
19787name, and the options passed to the program are displayed, so that one
19788can later tell what file was being compiled, and with which options.
19789
d77de738 19790@opindex fdump-final-insns
ddf6fe37 19791@item -fdump-final-insns@r{[}=@var{file}@r{]}
d77de738
ML
19792Dump the final internal representation (RTL) to @var{file}. If the
19793optional argument is omitted (or if @var{file} is @code{.}), the name
19794of the dump file is determined by appending @code{.gkd} to the
19795dump base name, see @option{-dumpbase}.
19796
d77de738
ML
19797@opindex fcompare-debug
19798@opindex fno-compare-debug
ddf6fe37 19799@item -fcompare-debug@r{[}=@var{opts}@r{]}
d77de738
ML
19800If no error occurs during compilation, run the compiler a second time,
19801adding @var{opts} and @option{-fcompare-debug-second} to the arguments
19802passed to the second compilation. Dump the final internal
19803representation in both compilations, and print an error if they differ.
19804
19805If the equal sign is omitted, the default @option{-gtoggle} is used.
19806
19807The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
19808and nonzero, implicitly enables @option{-fcompare-debug}. If
19809@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
19810then it is used for @var{opts}, otherwise the default @option{-gtoggle}
19811is used.
19812
19813@option{-fcompare-debug=}, with the equal sign but without @var{opts},
19814is equivalent to @option{-fno-compare-debug}, which disables the dumping
19815of the final representation and the second compilation, preventing even
19816@env{GCC_COMPARE_DEBUG} from taking effect.
19817
19818To verify full coverage during @option{-fcompare-debug} testing, set
19819@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
19820which GCC rejects as an invalid option in any actual compilation
19821(rather than preprocessing, assembly or linking). To get just a
19822warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
19823not overridden} will do.
19824
d77de738 19825@opindex fcompare-debug-second
ddf6fe37 19826@item -fcompare-debug-second
d77de738
ML
19827This option is implicitly passed to the compiler for the second
19828compilation requested by @option{-fcompare-debug}, along with options to
19829silence warnings, and omitting other options that would cause the compiler
19830to produce output to files or to standard output as a side effect. Dump
19831files and preserved temporary files are renamed so as to contain the
19832@code{.gk} additional extension during the second compilation, to avoid
19833overwriting those generated by the first.
19834
19835When this option is passed to the compiler driver, it causes the
19836@emph{first} compilation to be skipped, which makes it useful for little
19837other than debugging the compiler proper.
19838
d77de738 19839@opindex gtoggle
ddf6fe37 19840@item -gtoggle
d77de738
ML
19841Turn off generation of debug info, if leaving out this option
19842generates it, or turn it on at level 2 otherwise. The position of this
19843argument in the command line does not matter; it takes effect after all
19844other options are processed, and it does so only once, no matter how
19845many times it is given. This is mainly intended to be used with
19846@option{-fcompare-debug}.
19847
d77de738
ML
19848@opindex fvar-tracking-assignments-toggle
19849@opindex fno-var-tracking-assignments-toggle
ddf6fe37 19850@item -fvar-tracking-assignments-toggle
d77de738
ML
19851Toggle @option{-fvar-tracking-assignments}, in the same way that
19852@option{-gtoggle} toggles @option{-g}.
19853
d77de738 19854@opindex Q
ddf6fe37 19855@item -Q
d77de738
ML
19856Makes the compiler print out each function name as it is compiled, and
19857print some statistics about each pass when it finishes.
19858
d77de738 19859@opindex ftime-report
ddf6fe37 19860@item -ftime-report
d77de738
ML
19861Makes the compiler print some statistics about the time consumed by each
19862pass when it finishes.
19863
d77de738 19864@opindex ftime-report-details
ddf6fe37 19865@item -ftime-report-details
d77de738
ML
19866Record the time consumed by infrastructure parts separately for each pass.
19867
d77de738 19868@opindex fira-verbose
ddf6fe37 19869@item -fira-verbose=@var{n}
d77de738
ML
19870Control the verbosity of the dump file for the integrated register allocator.
19871The default value is 5. If the value @var{n} is greater or equal to 10,
19872the dump output is sent to stderr using the same format as @var{n} minus 10.
19873
d77de738 19874@opindex flto-report
ddf6fe37 19875@item -flto-report
d77de738
ML
19876Prints a report with internal details on the workings of the link-time
19877optimizer. The contents of this report vary from version to version.
19878It is meant to be useful to GCC developers when processing object
19879files in LTO mode (via @option{-flto}).
19880
19881Disabled by default.
19882
d77de738 19883@opindex flto-report-wpa
ddf6fe37 19884@item -flto-report-wpa
d77de738
ML
19885Like @option{-flto-report}, but only print for the WPA phase of link-time
19886optimization.
19887
d77de738 19888@opindex fmem-report
ddf6fe37 19889@item -fmem-report
d77de738
ML
19890Makes the compiler print some statistics about permanent memory
19891allocation when it finishes.
19892
d77de738 19893@opindex fmem-report-wpa
ddf6fe37 19894@item -fmem-report-wpa
d77de738
ML
19895Makes the compiler print some statistics about permanent memory
19896allocation for the WPA phase only.
19897
d77de738 19898@opindex fpre-ipa-mem-report
d77de738 19899@opindex fpost-ipa-mem-report
ddf6fe37
AA
19900@item -fpre-ipa-mem-report
19901@item -fpost-ipa-mem-report
d77de738
ML
19902Makes the compiler print some statistics about permanent memory
19903allocation before or after interprocedural optimization.
19904
d77de738 19905@opindex fmultiflags
ddf6fe37 19906@item -fmultiflags
d77de738
ML
19907This option enables multilib-aware @code{TFLAGS} to be used to build
19908target libraries with options different from those the compiler is
19909configured to use by default, through the use of specs (@xref{Spec
19910Files}) set up by compiler internals, by the target, or by builders at
19911configure time.
19912
19913Like @code{TFLAGS}, this allows the target libraries to be built for
19914portable baseline environments, while the compiler defaults to more
19915demanding ones. That's useful because users can easily override the
19916defaults the compiler is configured to use to build their own programs,
19917if the defaults are not ideal for their target environment, whereas
19918rebuilding the runtime libraries is usually not as easy or desirable.
19919
19920Unlike @code{TFLAGS}, the use of specs enables different flags to be
19921selected for different multilibs. The way to accomplish that is to
19922build with @samp{make TFLAGS=-fmultiflags}, after configuring
19923@samp{--with-specs=%@{fmultiflags:...@}}.
19924
19925This option is discarded by the driver once it's done processing driver
19926self spec.
19927
19928It is also useful to check that @code{TFLAGS} are being used to build
19929all target libraries, by configuring a non-bootstrap compiler
19930@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
19931the compiler and target libraries.
19932
d77de738 19933@opindex fprofile-report
ddf6fe37 19934@item -fprofile-report
d77de738
ML
19935Makes the compiler print some statistics about consistency of the
19936(estimated) profile and effect of individual passes.
19937
d77de738 19938@opindex fstack-usage
ddf6fe37 19939@item -fstack-usage
d77de738
ML
19940Makes the compiler output stack usage information for the program, on a
19941per-function basis. The filename for the dump is made by appending
19942@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
19943the output file, if explicitly specified and it is not an executable,
19944otherwise it is the basename of the source file. An entry is made up
19945of three fields:
19946
19947@itemize
19948@item
19949The name of the function.
19950@item
19951A number of bytes.
19952@item
19953One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
19954@end itemize
19955
19956The qualifier @code{static} means that the function manipulates the stack
19957statically: a fixed number of bytes are allocated for the frame on function
19958entry and released on function exit; no stack adjustments are otherwise made
19959in the function. The second field is this fixed number of bytes.
19960
19961The qualifier @code{dynamic} means that the function manipulates the stack
19962dynamically: in addition to the static allocation described above, stack
19963adjustments are made in the body of the function, for example to push/pop
19964arguments around function calls. If the qualifier @code{bounded} is also
19965present, the amount of these adjustments is bounded at compile time and
19966the second field is an upper bound of the total amount of stack used by
19967the function. If it is not present, the amount of these adjustments is
19968not bounded at compile time and the second field only represents the
19969bounded part.
19970
d77de738 19971@opindex fstats
ddf6fe37 19972@item -fstats
d77de738
ML
19973Emit statistics about front-end processing at the end of the compilation.
19974This option is supported only by the C++ front end, and
19975the information is generally only useful to the G++ development team.
19976
d77de738 19977@opindex fdbg-cnt-list
ddf6fe37 19978@item -fdbg-cnt-list
d77de738
ML
19979Print the name and the counter upper bound for all debug counters.
19980
19981
d77de738 19982@opindex fdbg-cnt
ddf6fe37 19983@item -fdbg-cnt=@var{counter-value-list}
d77de738
ML
19984Set the internal debug counter lower and upper bound. @var{counter-value-list}
19985is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
19986[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
19987the name of the counter and list of closed intervals.
19988The @var{lower_bound} is optional and is zero
19989initialized if not set.
19990For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
19991@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
19992eleventh invocation.
19993For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
19994
d77de738 19995@opindex print-file-name
ddf6fe37 19996@item -print-file-name=@var{library}
d77de738
ML
19997Print the full absolute name of the library file @var{library} that
19998would be used when linking---and don't do anything else. With this
19999option, GCC does not compile or link anything; it just prints the
20000file name.
20001
d77de738 20002@opindex print-multi-directory
ddf6fe37 20003@item -print-multi-directory
d77de738
ML
20004Print the directory name corresponding to the multilib selected by any
20005other switches present in the command line. This directory is supposed
20006to exist in @env{GCC_EXEC_PREFIX}.
20007
d77de738 20008@opindex print-multi-lib
ddf6fe37 20009@item -print-multi-lib
d77de738
ML
20010Print the mapping from multilib directory names to compiler switches
20011that enable them. The directory name is separated from the switches by
20012@samp{;}, and each switch starts with an @samp{@@} instead of the
20013@samp{-}, without spaces between multiple switches. This is supposed to
20014ease shell processing.
20015
d77de738 20016@opindex print-multi-os-directory
ddf6fe37 20017@item -print-multi-os-directory
d77de738
ML
20018Print the path to OS libraries for the selected
20019multilib, relative to some @file{lib} subdirectory. If OS libraries are
20020present in the @file{lib} subdirectory and no multilibs are used, this is
20021usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
20022sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
20023@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
20024subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
20025
d77de738 20026@opindex print-multiarch
ddf6fe37 20027@item -print-multiarch
d77de738
ML
20028Print the path to OS libraries for the selected multiarch,
20029relative to some @file{lib} subdirectory.
20030
d77de738 20031@opindex print-prog-name
ddf6fe37 20032@item -print-prog-name=@var{program}
d77de738
ML
20033Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
20034
d77de738 20035@opindex print-libgcc-file-name
ddf6fe37 20036@item -print-libgcc-file-name
d77de738
ML
20037Same as @option{-print-file-name=libgcc.a}.
20038
20039This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
20040but you do want to link with @file{libgcc.a}. You can do:
20041
20042@smallexample
20043gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
20044@end smallexample
20045
d77de738 20046@opindex print-search-dirs
ddf6fe37 20047@item -print-search-dirs
d77de738
ML
20048Print the name of the configured installation directory and a list of
20049program and library directories @command{gcc} searches---and don't do anything else.
20050
20051This is useful when @command{gcc} prints the error message
20052@samp{installation problem, cannot exec cpp0: No such file or directory}.
20053To resolve this you either need to put @file{cpp0} and the other compiler
20054components where @command{gcc} expects to find them, or you can set the environment
20055variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
20056Don't forget the trailing @samp{/}.
20057@xref{Environment Variables}.
20058
d77de738 20059@opindex print-sysroot
ddf6fe37 20060@item -print-sysroot
d77de738
ML
20061Print the target sysroot directory that is used during
20062compilation. This is the target sysroot specified either at configure
20063time or using the @option{--sysroot} option, possibly with an extra
20064suffix that depends on compilation options. If no target sysroot is
20065specified, the option prints nothing.
20066
d77de738 20067@opindex print-sysroot-headers-suffix
ddf6fe37 20068@item -print-sysroot-headers-suffix
d77de738
ML
20069Print the suffix added to the target sysroot when searching for
20070headers, or give an error if the compiler is not configured with such
20071a suffix---and don't do anything else.
20072
d77de738 20073@opindex dumpmachine
ddf6fe37 20074@item -dumpmachine
d77de738
ML
20075Print the compiler's target machine (for example,
20076@samp{i686-pc-linux-gnu})---and don't do anything else.
20077
d77de738 20078@opindex dumpversion
ddf6fe37 20079@item -dumpversion
d77de738
ML
20080Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
20081anything else. This is the compiler version used in filesystem paths and
20082specs. Depending on how the compiler has been configured it can be just
20083a single number (major version), two numbers separated by a dot (major and
20084minor version) or three numbers separated by dots (major, minor and patchlevel
20085version).
20086
d77de738 20087@opindex dumpfullversion
ddf6fe37 20088@item -dumpfullversion
d77de738
ML
20089Print the full compiler version---and don't do anything else. The output is
20090always three numbers separated by dots, major, minor and patchlevel version.
20091
d77de738 20092@opindex dumpspecs
ddf6fe37 20093@item -dumpspecs
d77de738
ML
20094Print the compiler's built-in specs---and don't do anything else. (This
20095is used when GCC itself is being built.) @xref{Spec Files}.
20096@end table
20097
20098@node Submodel Options
20099@section Machine-Dependent Options
20100@cindex submodel options
20101@cindex specifying hardware config
20102@cindex hardware models and configurations, specifying
20103@cindex target-dependent options
20104@cindex machine-dependent options
20105
20106Each target machine supported by GCC can have its own options---for
20107example, to allow you to compile for a particular processor variant or
20108ABI, or to control optimizations specific to that machine. By
20109convention, the names of machine-specific options start with
20110@samp{-m}.
20111
20112Some configurations of the compiler also support additional target-specific
20113options, usually for compatibility with other compilers on the same
20114platform.
20115
20116@c This list is ordered alphanumerically by subsection name.
20117@c It should be the same order and spelling as these options are listed
20118@c in Machine Dependent Options
20119
20120@menu
20121* AArch64 Options::
20122* Adapteva Epiphany Options::
20123* AMD GCN Options::
20124* ARC Options::
20125* ARM Options::
20126* AVR Options::
20127* Blackfin Options::
20128* C6X Options::
20129* CRIS Options::
20130* C-SKY Options::
20131* Darwin Options::
20132* DEC Alpha Options::
20133* eBPF Options::
20134* FR30 Options::
20135* FT32 Options::
20136* FRV Options::
20137* GNU/Linux Options::
20138* H8/300 Options::
20139* HPPA Options::
20140* IA-64 Options::
20141* LM32 Options::
20142* LoongArch Options::
20143* M32C Options::
20144* M32R/D Options::
20145* M680x0 Options::
20146* MCore Options::
d77de738
ML
20147* MicroBlaze Options::
20148* MIPS Options::
20149* MMIX Options::
20150* MN10300 Options::
20151* Moxie Options::
20152* MSP430 Options::
20153* NDS32 Options::
20154* Nios II Options::
20155* Nvidia PTX Options::
20156* OpenRISC Options::
20157* PDP-11 Options::
d77de738
ML
20158* PowerPC Options::
20159* PRU Options::
20160* RISC-V Options::
20161* RL78 Options::
20162* RS/6000 and PowerPC Options::
20163* RX Options::
20164* S/390 and zSeries Options::
d77de738
ML
20165* SH Options::
20166* Solaris 2 Options::
20167* SPARC Options::
20168* System V Options::
20169* V850 Options::
20170* VAX Options::
20171* Visium Options::
20172* VMS Options::
20173* VxWorks Options::
20174* x86 Options::
20175* x86 Windows Options::
20176* Xstormy16 Options::
20177* Xtensa Options::
20178* zSeries Options::
20179@end menu
20180
20181@node AArch64 Options
20182@subsection AArch64 Options
20183@cindex AArch64 Options
20184
20185These options are defined for AArch64 implementations:
20186
20187@table @gcctabopt
20188
d77de738 20189@opindex mabi
ddf6fe37 20190@item -mabi=@var{name}
d77de738
ML
20191Generate code for the specified data model. Permissible values
20192are @samp{ilp32} for SysV-like data model where int, long int and pointers
20193are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
20194but long int and pointers are 64 bits.
20195
20196The default depends on the specific target configuration. Note that
20197the LP64 and ILP32 ABIs are not link-compatible; you must compile your
20198entire program with the same ABI, and link with a compatible set of libraries.
20199
d77de738 20200@opindex mbig-endian
ddf6fe37 20201@item -mbig-endian
d77de738
ML
20202Generate big-endian code. This is the default when GCC is configured for an
20203@samp{aarch64_be-*-*} target.
20204
d77de738 20205@opindex mgeneral-regs-only
ddf6fe37 20206@item -mgeneral-regs-only
d77de738
ML
20207Generate code which uses only the general-purpose registers. This will prevent
20208the compiler from using floating-point and Advanced SIMD registers but will not
20209impose any restrictions on the assembler.
20210
d77de738 20211@opindex mlittle-endian
ddf6fe37 20212@item -mlittle-endian
d77de738
ML
20213Generate little-endian code. This is the default when GCC is configured for an
20214@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
20215
d77de738 20216@opindex mcmodel=tiny
ddf6fe37 20217@item -mcmodel=tiny
d77de738
ML
20218Generate code for the tiny code model. The program and its statically defined
20219symbols must be within 1MB of each other. Programs can be statically or
20220dynamically linked.
20221
d77de738 20222@opindex mcmodel=small
ddf6fe37 20223@item -mcmodel=small
d77de738
ML
20224Generate code for the small code model. The program and its statically defined
20225symbols must be within 4GB of each other. Programs can be statically or
20226dynamically linked. This is the default code model.
20227
d77de738 20228@opindex mcmodel=large
ddf6fe37 20229@item -mcmodel=large
d77de738
ML
20230Generate code for the large code model. This makes no assumptions about
20231addresses and sizes of sections. Programs can be statically linked only. The
20232@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20233@option{-fpic} and @option{-fPIC}.
20234
573624ec
KT
20235@item -mtp=@var{name}
20236@opindex mtp
20237Specify the system register to use as a thread pointer. The valid values
4389a2d2
KT
20238are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
20239@samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0},
20240@samp{el1}, @samp{el2}, @samp{el3} are also accepted.
20241The default setting is @samp{tpidr_el0}. It is recommended to compile all
20242code intended to interoperate with the same value of this option to avoid
20243accessing a different thread pointer from the wrong exception level.
573624ec 20244
d77de738
ML
20245@opindex mstrict-align
20246@opindex mno-strict-align
ddf6fe37
AA
20247@item -mstrict-align
20248@itemx -mno-strict-align
d77de738
ML
20249Avoid or allow generating memory accesses that may not be aligned on a natural
20250object boundary as described in the architecture specification.
20251
d77de738
ML
20252@opindex momit-leaf-frame-pointer
20253@opindex mno-omit-leaf-frame-pointer
ddf6fe37
AA
20254@item -momit-leaf-frame-pointer
20255@itemx -mno-omit-leaf-frame-pointer
d77de738
ML
20256Omit or keep the frame pointer in leaf functions. The former behavior is the
20257default.
20258
d77de738
ML
20259@opindex mstack-protector-guard
20260@opindex mstack-protector-guard-reg
20261@opindex mstack-protector-guard-offset
ddf6fe37
AA
20262@item -mstack-protector-guard=@var{guard}
20263@itemx -mstack-protector-guard-reg=@var{reg}
20264@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
20265Generate stack protection code using canary at @var{guard}. Supported
20266locations are @samp{global} for a global canary or @samp{sysreg} for a
20267canary in an appropriate system register.
20268
20269With the latter choice the options
20270@option{-mstack-protector-guard-reg=@var{reg}} and
20271@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20272which system register to use as base register for reading the canary,
20273and from what offset from that base register. There is no default
20274register or offset as this is entirely for use within the Linux
20275kernel.
20276
d77de738 20277@opindex mtls-dialect=desc
ddf6fe37 20278@item -mtls-dialect=desc
d77de738
ML
20279Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20280of TLS variables. This is the default.
20281
d77de738 20282@opindex mtls-dialect=traditional
ddf6fe37 20283@item -mtls-dialect=traditional
d77de738
ML
20284Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20285of TLS variables.
20286
d77de738 20287@opindex mtls-size
ddf6fe37 20288@item -mtls-size=@var{size}
d77de738
ML
20289Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20290This option requires binutils 2.26 or newer.
20291
d77de738
ML
20292@opindex mfix-cortex-a53-835769
20293@opindex mno-fix-cortex-a53-835769
ddf6fe37
AA
20294@item -mfix-cortex-a53-835769
20295@itemx -mno-fix-cortex-a53-835769
d77de738
ML
20296Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20297This involves inserting a NOP instruction between memory instructions and
2029864-bit integer multiply-accumulate instructions.
20299
d77de738
ML
20300@opindex mfix-cortex-a53-843419
20301@opindex mno-fix-cortex-a53-843419
ddf6fe37
AA
20302@item -mfix-cortex-a53-843419
20303@itemx -mno-fix-cortex-a53-843419
d77de738
ML
20304Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20305This erratum workaround is made at link time and this will only pass the
20306corresponding flag to the linker.
20307
d77de738
ML
20308@opindex mlow-precision-recip-sqrt
20309@opindex mno-low-precision-recip-sqrt
ddf6fe37
AA
20310@item -mlow-precision-recip-sqrt
20311@itemx -mno-low-precision-recip-sqrt
d77de738
ML
20312Enable or disable the reciprocal square root approximation.
20313This option only has an effect if @option{-ffast-math} or
20314@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20315precision of reciprocal square root results to about 16 bits for
20316single precision and to 32 bits for double precision.
20317
d77de738
ML
20318@opindex mlow-precision-sqrt
20319@opindex mno-low-precision-sqrt
ddf6fe37
AA
20320@item -mlow-precision-sqrt
20321@itemx -mno-low-precision-sqrt
d77de738
ML
20322Enable or disable the square root approximation.
20323This option only has an effect if @option{-ffast-math} or
20324@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20325precision of square root results to about 16 bits for
20326single precision and to 32 bits for double precision.
20327If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20328
d77de738
ML
20329@opindex mlow-precision-div
20330@opindex mno-low-precision-div
ddf6fe37
AA
20331@item -mlow-precision-div
20332@itemx -mno-low-precision-div
d77de738
ML
20333Enable or disable the division approximation.
20334This option only has an effect if @option{-ffast-math} or
20335@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20336precision of division results to about 16 bits for
20337single precision and to 32 bits for double precision.
20338
20339@item -mtrack-speculation
20340@itemx -mno-track-speculation
20341Enable or disable generation of additional code to track speculative
20342execution through conditional branches. The tracking state can then
20343be used by the compiler when expanding calls to
20344@code{__builtin_speculation_safe_copy} to permit a more efficient code
20345sequence to be generated.
20346
20347@item -moutline-atomics
20348@itemx -mno-outline-atomics
20349Enable or disable calls to out-of-line helpers to implement atomic operations.
20350These helpers will, at runtime, determine if the LSE instructions from
20351ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20352instructions that are present in the base ARMv8.0 ISA.
20353
20354This option is only applicable when compiling for the base ARMv8.0
20355instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20356or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20357used directly. The same applies when using @option{-mcpu=} when the
20358selected cpu supports the @samp{lse} feature.
20359This option is on by default.
20360
d77de738 20361@opindex march
ddf6fe37 20362@item -march=@var{name}
d77de738
ML
20363Specify the name of the target architecture and, optionally, one or
20364more feature modifiers. This option has the form
20365@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20366
20367The table below summarizes the permissible values for @var{arch}
20368and the features that they enable by default:
20369
20370@multitable @columnfractions 0.20 0.20 0.60
20371@headitem @var{arch} value @tab Architecture @tab Includes by default
20372@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20373@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20374@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20375@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20376@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20377@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20378@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20379@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20380@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20381@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20382@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20383@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20384@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20385@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20386@end multitable
20387
20388The value @samp{native} is available on native AArch64 GNU/Linux and
20389causes the compiler to pick the architecture of the host system. This
20390option has no effect if the compiler is unable to recognize the
20391architecture of the host system,
20392
20393The permissible values for @var{feature} are listed in the sub-section
20394on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20395Feature Modifiers}. Where conflicting feature modifiers are
20396specified, the right-most feature is used.
20397
20398GCC uses @var{name} to determine what kind of instructions it can emit
20399when generating assembly code. If @option{-march} is specified
20400without either of @option{-mtune} or @option{-mcpu} also being
20401specified, the code is tuned to perform well across a range of target
20402processors implementing the target architecture.
20403
d77de738 20404@opindex mtune
ddf6fe37 20405@item -mtune=@var{name}
d77de738
ML
20406Specify the name of the target processor for which GCC should tune the
20407performance of the code. Permissible values for this option are:
20408@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20409@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20410@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20411@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20412@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20413@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20414@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20415@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20416@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20417@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20418@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20419@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20420@samp{octeontx2f95mm},
20421@samp{a64fx},
20422@samp{thunderx}, @samp{thunderxt88},
20423@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20424@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20425@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20426@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20427@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20428@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
e07556a8
SP
20429@samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715},
20430@samp{ampere1}, @samp{ampere1a}, and @samp{native}.
d77de738
ML
20431
20432The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20433@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20434@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20435should tune for a big.LITTLE system.
20436
20437The value @samp{neoverse-512tvb} specifies that GCC should tune
20438for Neoverse cores that (a) implement SVE and (b) have a total vector
20439bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20440tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20441instructions a cycle and that can execute an equivalent number of SVE
20442arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20443This is more general than tuning for a specific core like Neoverse V1
20444but is more specific than the default tuning described below.
20445
20446Additionally on native AArch64 GNU/Linux systems the value
20447@samp{native} tunes performance to the host system. This option has no effect
20448if the compiler is unable to recognize the processor of the host system.
20449
20450Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20451are specified, the code is tuned to perform well across a range
20452of target processors.
20453
20454This option cannot be suffixed by feature modifiers.
20455
d77de738 20456@opindex mcpu
ddf6fe37 20457@item -mcpu=@var{name}
d77de738
ML
20458Specify the name of the target processor, optionally suffixed by one
20459or more feature modifiers. This option has the form
20460@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20461the permissible values for @var{cpu} are the same as those available
20462for @option{-mtune}. The permissible values for @var{feature} are
20463documented in the sub-section on
20464@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20465Feature Modifiers}. Where conflicting feature modifiers are
20466specified, the right-most feature is used.
20467
20468GCC uses @var{name} to determine what kind of instructions it can emit when
20469generating assembly code (as if by @option{-march}) and to determine
20470the target processor for which to tune for performance (as if
20471by @option{-mtune}). Where this option is used in conjunction
20472with @option{-march} or @option{-mtune}, those options take precedence
20473over the appropriate part of this option.
20474
20475@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20476to a specific core, but instead refers to all Neoverse cores that
20477(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20478a cycle. Unless overridden by @option{-march},
20479@option{-mcpu=neoverse-512tvb} generates code that can run on a
20480Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20481these properties. Unless overridden by @option{-mtune},
20482@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20483@option{-mtune=neoverse-512tvb}.
20484
d77de738 20485@opindex moverride
ddf6fe37 20486@item -moverride=@var{string}
d77de738
ML
20487Override tuning decisions made by the back-end in response to a
20488@option{-mtune=} switch. The syntax, semantics, and accepted values
20489for @var{string} in this option are not guaranteed to be consistent
20490across releases.
20491
20492This option is only intended to be useful when developing GCC.
20493
d77de738 20494@opindex mverbose-cost-dump
ddf6fe37 20495@item -mverbose-cost-dump
d77de738
ML
20496Enable verbose cost model dumping in the debug dump files. This option is
20497provided for use in debugging the compiler.
20498
d77de738
ML
20499@opindex mpc-relative-literal-loads
20500@opindex mno-pc-relative-literal-loads
ddf6fe37
AA
20501@item -mpc-relative-literal-loads
20502@itemx -mno-pc-relative-literal-loads
d77de738
ML
20503Enable or disable PC-relative literal loads. With this option literal pools are
20504accessed using a single instruction and emitted after each function. This
20505limits the maximum size of functions to 1MB. This is enabled by default for
20506@option{-mcmodel=tiny}.
20507
d77de738 20508@opindex msign-return-address
ddf6fe37 20509@item -msign-return-address=@var{scope}
d77de738
ML
20510Select the function scope on which return address signing will be applied.
20511Permissible values are @samp{none}, which disables return address signing,
20512@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20513functions, and @samp{all}, which enables pointer signing for all functions. The
20514default value is @samp{none}. This option has been deprecated by
20515-mbranch-protection.
20516
d77de738 20517@opindex mbranch-protection
ddf6fe37 20518@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
d77de738
ML
20519Select the branch protection features to use.
20520@samp{none} is the default and turns off all types of branch protection.
20521@samp{standard} turns on all types of branch protection features. If a feature
20522has additional tuning options, then @samp{standard} sets it to its standard
20523level.
20524@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20525level: signing functions that save the return address to memory (non-leaf
20526functions will practically always do this) using the a-key. The optional
20527argument @samp{leaf} can be used to extend the signing to include leaf
20528functions. The optional argument @samp{b-key} can be used to sign the functions
20529with the B-key instead of the A-key.
20530@samp{bti} turns on branch target identification mechanism.
20531
d77de738 20532@opindex mharden-sls
ddf6fe37 20533@item -mharden-sls=@var{opts}
d77de738
ML
20534Enable compiler hardening against straight line speculation (SLS).
20535@var{opts} is a comma-separated list of the following options:
20536@table @samp
20537@item retbr
20538@item blr
20539@end table
20540In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20541@samp{-mharden-sls=none} disables all SLS hardening.
20542
d77de738 20543@opindex msve-vector-bits
ddf6fe37 20544@item -msve-vector-bits=@var{bits}
d77de738
ML
20545Specify the number of bits in an SVE vector register. This option only has
20546an effect when SVE is enabled.
20547
20548GCC supports two forms of SVE code generation: ``vector-length
20549agnostic'' output that works with any size of vector register and
20550``vector-length specific'' output that allows GCC to make assumptions
20551about the vector length when it is useful for optimization reasons.
20552The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20553@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20554Specifying @samp{scalable} selects vector-length agnostic
20555output. At present @samp{-msve-vector-bits=128} also generates vector-length
20556agnostic output for big-endian targets. All other values generate
20557vector-length specific code. The behavior of these values may change
20558in future releases and no value except @samp{scalable} should be
20559relied on for producing code that is portable across different
20560hardware SVE vector lengths.
20561
20562The default is @samp{-msve-vector-bits=scalable}, which produces
20563vector-length agnostic code.
20564@end table
20565
20566@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20567@anchor{aarch64-feature-modifiers}
20568@cindex @option{-march} feature modifiers
20569@cindex @option{-mcpu} feature modifiers
20570Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20571the following and their inverses @option{no@var{feature}}:
20572
20573@table @samp
20574@item crc
20575Enable CRC extension. This is on by default for
20576@option{-march=armv8.1-a}.
20577@item crypto
20578Enable Crypto extension. This also enables Advanced SIMD and floating-point
20579instructions.
20580@item fp
20581Enable floating-point instructions. This is on by default for all possible
20582values for options @option{-march} and @option{-mcpu}.
20583@item simd
20584Enable Advanced SIMD instructions. This also enables floating-point
20585instructions. This is on by default for all possible values for options
20586@option{-march} and @option{-mcpu}.
20587@item sve
20588Enable Scalable Vector Extension instructions. This also enables Advanced
20589SIMD and floating-point instructions.
20590@item lse
20591Enable Large System Extension instructions. This is on by default for
20592@option{-march=armv8.1-a}.
20593@item rdma
20594Enable Round Double Multiply Accumulate instructions. This is on by default
20595for @option{-march=armv8.1-a}.
20596@item fp16
20597Enable FP16 extension. This also enables floating-point instructions.
20598@item fp16fml
20599Enable FP16 fmla extension. This also enables FP16 extensions and
20600floating-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.
20601
20602@item rcpc
0431e8ae
AV
20603Enable the RCpc extension. This enables the use of the LDAPR instructions for
20604load-acquire atomic semantics, and passes it on to the assembler, enabling
20605inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20606@item dotprod
20607Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20608@item aes
20609Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20610SIMD instructions.
20611@item sha2
20612Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20613@item sha3
20614Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20615instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20616@item sm4
20617Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20618Use of this option with architectures prior to Armv8.2-A is not supported.
20619@item profile
20620Enable the Statistical Profiling extension. This option is only to enable the
20621extension at the assembler level and does not affect code generation.
20622@item rng
20623Enable the Armv8.5-a Random Number instructions. This option is only to
20624enable the extension at the assembler level and does not affect code
20625generation.
20626@item memtag
20627Enable the Armv8.5-a Memory Tagging Extensions.
20628Use of this option with architectures prior to Armv8.5-A is not supported.
20629@item sb
20630Enable the Armv8-a Speculation Barrier instruction. This option is only to
20631enable the extension at the assembler level and does not affect code
20632generation. This option is enabled by default for @option{-march=armv8.5-a}.
20633@item ssbs
20634Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20635is only to enable the extension at the assembler level and does not affect code
20636generation. This option is enabled by default for @option{-march=armv8.5-a}.
20637@item predres
20638Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20639This option is only to enable the extension at the assembler level and does
20640not affect code generation. This option is enabled by default for
20641@option{-march=armv8.5-a}.
20642@item sve2
20643Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20644instructions.
20645@item sve2-bitperm
20646Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20647@item sve2-sm4
20648Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20649@item sve2-aes
20650Enable SVE2 aes instructions. This also enables SVE2 instructions.
20651@item sve2-sha3
20652Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20653@item tme
20654Enable the Transactional Memory Extension.
20655@item i8mm
20656Enable 8-bit Integer Matrix Multiply instructions. This also enables
20657Advanced SIMD and floating-point instructions. This option is enabled by
20658default for @option{-march=armv8.6-a}. Use of this option with architectures
20659prior to Armv8.2-A is not supported.
20660@item f32mm
20661Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20662SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20663not supported.
20664@item f64mm
20665Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20666SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20667not supported.
20668@item bf16
20669Enable brain half-precision floating-point instructions. This also enables
20670Advanced SIMD and floating-point instructions. This option is enabled by
20671default for @option{-march=armv8.6-a}. Use of this option with architectures
20672prior to Armv8.2-A is not supported.
20673@item ls64
20674Enable the 64-byte atomic load and store instructions for accelerators.
20675This option is enabled by default for @option{-march=armv8.7-a}.
20676@item mops
20677Enable the instructions to accelerate memory operations like @code{memcpy},
20678@code{memmove}, @code{memset}. This option is enabled by default for
20679@option{-march=armv8.8-a}
20680@item flagm
20681Enable the Flag Manipulation instructions Extension.
20682@item pauth
20683Enable the Pointer Authentication Extension.
d758d190
KT
20684@item cssc
20685Enable the Common Short Sequence Compression instructions.
d77de738
ML
20686
20687@end table
20688
20689Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20690which implies @option{fp}.
20691Conversely, @option{nofp} implies @option{nosimd}, which implies
20692@option{nocrypto}, @option{noaes} and @option{nosha2}.
20693
20694@node Adapteva Epiphany Options
20695@subsection Adapteva Epiphany Options
20696
20697These @samp{-m} options are defined for Adapteva Epiphany:
20698
20699@table @gcctabopt
d77de738 20700@opindex mhalf-reg-file
ddf6fe37 20701@item -mhalf-reg-file
d77de738
ML
20702Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20703That allows code to run on hardware variants that lack these registers.
20704
d77de738 20705@opindex mprefer-short-insn-regs
ddf6fe37 20706@item -mprefer-short-insn-regs
d77de738
ML
20707Preferentially allocate registers that allow short instruction generation.
20708This can result in increased instruction count, so this may either reduce or
20709increase overall code size.
20710
d77de738 20711@opindex mbranch-cost
ddf6fe37 20712@item -mbranch-cost=@var{num}
d77de738
ML
20713Set the cost of branches to roughly @var{num} ``simple'' instructions.
20714This cost is only a heuristic and is not guaranteed to produce
20715consistent results across releases.
20716
d77de738 20717@opindex mcmove
ddf6fe37 20718@item -mcmove
d77de738
ML
20719Enable the generation of conditional moves.
20720
d77de738 20721@opindex mnops
ddf6fe37 20722@item -mnops=@var{num}
d77de738
ML
20723Emit @var{num} NOPs before every other generated instruction.
20724
d77de738
ML
20725@opindex mno-soft-cmpsf
20726@opindex msoft-cmpsf
ddf6fe37 20727@item -mno-soft-cmpsf
d77de738
ML
20728For single-precision floating-point comparisons, emit an @code{fsub} instruction
20729and test the flags. This is faster than a software comparison, but can
20730get incorrect results in the presence of NaNs, or when two different small
20731numbers are compared such that their difference is calculated as zero.
20732The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20733software comparisons.
20734
d77de738 20735@opindex mstack-offset
ddf6fe37 20736@item -mstack-offset=@var{num}
d77de738
ML
20737Set the offset between the top of the stack and the stack pointer.
20738E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20739can be used by leaf functions without stack allocation.
20740Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20741Note also that this option changes the ABI; compiling a program with a
20742different stack offset than the libraries have been compiled with
20743generally does not work.
20744This option can be useful if you want to evaluate if a different stack
20745offset would give you better code, but to actually use a different stack
20746offset to build working programs, it is recommended to configure the
20747toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20748
d77de738
ML
20749@opindex mno-round-nearest
20750@opindex mround-nearest
ddf6fe37 20751@item -mno-round-nearest
d77de738
ML
20752Make the scheduler assume that the rounding mode has been set to
20753truncating. The default is @option{-mround-nearest}.
20754
d77de738 20755@opindex mlong-calls
ddf6fe37 20756@item -mlong-calls
d77de738
ML
20757If not otherwise specified by an attribute, assume all calls might be beyond
20758the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20759function address into a register before performing a (otherwise direct) call.
20760This is the default.
20761
d77de738 20762@opindex short-calls
ddf6fe37 20763@item -mshort-calls
d77de738
ML
20764If not otherwise specified by an attribute, assume all direct calls are
20765in the range of the @code{b} / @code{bl} instructions, so use these instructions
20766for direct calls. The default is @option{-mlong-calls}.
20767
d77de738 20768@opindex msmall16
ddf6fe37 20769@item -msmall16
d77de738
ML
20770Assume addresses can be loaded as 16-bit unsigned values. This does not
20771apply to function addresses for which @option{-mlong-calls} semantics
20772are in effect.
20773
d77de738 20774@opindex mfp-mode
ddf6fe37 20775@item -mfp-mode=@var{mode}
d77de738
ML
20776Set the prevailing mode of the floating-point unit.
20777This determines the floating-point mode that is provided and expected
20778at function call and return time. Making this mode match the mode you
20779predominantly need at function start can make your programs smaller and
20780faster by avoiding unnecessary mode switches.
20781
20782@var{mode} can be set to one the following values:
20783
20784@table @samp
20785@item caller
20786Any mode at function entry is valid, and retained or restored when
20787the function returns, and when it calls other functions.
20788This mode is useful for compiling libraries or other compilation units
20789you might want to incorporate into different programs with different
20790prevailing FPU modes, and the convenience of being able to use a single
20791object file outweighs the size and speed overhead for any extra
20792mode switching that might be needed, compared with what would be needed
20793with a more specific choice of prevailing FPU mode.
20794
20795@item truncate
20796This is the mode used for floating-point calculations with
20797truncating (i.e.@: round towards zero) rounding mode. That includes
20798conversion from floating point to integer.
20799
20800@item round-nearest
20801This is the mode used for floating-point calculations with
20802round-to-nearest-or-even rounding mode.
20803
20804@item int
20805This is the mode used to perform integer calculations in the FPU, e.g.@:
20806integer multiply, or integer multiply-and-accumulate.
20807@end table
20808
20809The default is @option{-mfp-mode=caller}
20810
d77de738
ML
20811@opindex mno-split-lohi
20812@opindex msplit-lohi
20813@opindex mno-postinc
20814@opindex mpostinc
20815@opindex mno-postmodify
20816@opindex mpostmodify
ddf6fe37
AA
20817@item -mno-split-lohi
20818@itemx -mno-postinc
20819@itemx -mno-postmodify
d77de738
ML
20820Code generation tweaks that disable, respectively, splitting of 32-bit
20821loads, generation of post-increment addresses, and generation of
20822post-modify addresses. The defaults are @option{msplit-lohi},
20823@option{-mpost-inc}, and @option{-mpost-modify}.
20824
d77de738
ML
20825@opindex mno-vect-double
20826@opindex mvect-double
ddf6fe37 20827@item -mnovect-double
d77de738
ML
20828Change the preferred SIMD mode to SImode. The default is
20829@option{-mvect-double}, which uses DImode as preferred SIMD mode.
20830
d77de738 20831@opindex max-vect-align
ddf6fe37 20832@item -max-vect-align=@var{num}
d77de738
ML
20833The maximum alignment for SIMD vector mode types.
20834@var{num} may be 4 or 8. The default is 8.
20835Note that this is an ABI change, even though many library function
20836interfaces are unaffected if they don't use SIMD vector modes
20837in places that affect size and/or alignment of relevant types.
20838
d77de738 20839@opindex msplit-vecmove-early
ddf6fe37 20840@item -msplit-vecmove-early
d77de738
ML
20841Split vector moves into single word moves before reload. In theory this
20842can give better register allocation, but so far the reverse seems to be
20843generally the case.
20844
d77de738 20845@opindex m1reg-
ddf6fe37 20846@item -m1reg-@var{reg}
d77de738
ML
20847Specify a register to hold the constant @minus{}1, which makes loading small negative
20848constants and certain bitmasks faster.
20849Allowable values for @var{reg} are @samp{r43} and @samp{r63},
20850which specify use of that register as a fixed register,
20851and @samp{none}, which means that no register is used for this
20852purpose. The default is @option{-m1reg-none}.
20853
20854@end table
20855
20856@node AMD GCN Options
20857@subsection AMD GCN Options
20858@cindex AMD GCN Options
20859
20860These options are defined specifically for the AMD GCN port.
20861
20862@table @gcctabopt
20863
d77de738 20864@opindex march
d77de738 20865@opindex mtune
ddf6fe37
AA
20866@item -march=@var{gpu}
20867@itemx -mtune=@var{gpu}
d77de738
ML
20868Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
20869are
20870
20871@table @samp
20872@item fiji
20873Compile for GCN3 Fiji devices (gfx803).
20874
20875@item gfx900
20876Compile for GCN5 Vega 10 devices (gfx900).
20877
20878@item gfx906
20879Compile for GCN5 Vega 20 devices (gfx906).
20880
20881@item gfx908
20882Compile for CDNA1 Instinct MI100 series devices (gfx908).
20883
20884@item gfx90a
20885Compile for CDNA2 Instinct MI200 series devices (gfx90a).
20886
20887@end table
20888
ddf6fe37 20889@opindex msram-ecc
d77de738
ML
20890@item -msram-ecc=on
20891@itemx -msram-ecc=off
20892@itemx -msram-ecc=any
d77de738
ML
20893Compile binaries suitable for devices with the SRAM-ECC feature enabled,
20894disabled, or either mode. This feature can be enabled per-process on some
20895devices. The compiled code must match the device mode. The default is
20896@samp{any}, for devices that support it.
20897
d77de738 20898@opindex mstack-size
ddf6fe37 20899@item -mstack-size=@var{bytes}
d77de738
ML
20900Specify how many @var{bytes} of stack space will be requested for each GPU
20901thread (wave-front). Beware that there may be many threads and limited memory
20902available. The size of the stack allocation may also have an impact on
20903run-time performance. The default is 32KB when using OpenACC or OpenMP, and
209041MB otherwise.
20905
d77de738 20906@opindex mxnack
366e3d30
TB
20907@item -mxnack=on
20908@itemx -mxnack=off
20909@itemx -mxnack=any
20910Compile binaries suitable for devices with the XNACK feature enabled, disabled,
20911or either mode. Some devices always require XNACK and some allow the user to
20912configure XNACK. The compiled code must match the device mode.
20913@c The default is @samp{-mxnack=any}.
20914At present this option is a placeholder for support that is not yet implemented.
d77de738
ML
20915
20916@end table
20917
20918@node ARC Options
20919@subsection ARC Options
20920@cindex ARC options
20921
20922The following options control the architecture variant for which code
20923is being compiled:
20924
20925@c architecture variants
20926@table @gcctabopt
20927
d77de738 20928@opindex mbarrel-shifter
ddf6fe37 20929@item -mbarrel-shifter
d77de738
ML
20930Generate instructions supported by barrel shifter. This is the default
20931unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
20932
d77de738 20933@opindex mjli-always
ddf6fe37 20934@item -mjli-always
d77de738
ML
20935Force to call a function using jli_s instruction. This option is
20936valid only for ARCv2 architecture.
20937
d77de738 20938@opindex mcpu
ddf6fe37 20939@item -mcpu=@var{cpu}
d77de738
ML
20940Set architecture type, register usage, and instruction scheduling
20941parameters for @var{cpu}. There are also shortcut alias options
20942available for backward compatibility and convenience. Supported
20943values for @var{cpu} are
20944
20945@table @samp
20946@opindex mA6
20947@opindex mARC600
20948@item arc600
20949Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
20950
d77de738 20951@opindex mARC601
ddf6fe37 20952@item arc601
d77de738
ML
20953Compile for ARC601. Alias: @option{-mARC601}.
20954
d77de738
ML
20955@opindex mA7
20956@opindex mARC700
ddf6fe37 20957@item arc700
d77de738
ML
20958Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
20959This is the default when configured with @option{--with-cpu=arc700}@.
20960
20961@item arcem
20962Compile for ARC EM.
20963
20964@item archs
20965Compile for ARC HS.
20966
20967@item em
20968Compile for ARC EM CPU with no hardware extensions.
20969
20970@item em4
20971Compile for ARC EM4 CPU.
20972
20973@item em4_dmips
20974Compile for ARC EM4 DMIPS CPU.
20975
20976@item em4_fpus
20977Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
20978extension.
20979
20980@item em4_fpuda
20981Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
20982double assist instructions.
20983
20984@item hs
20985Compile for ARC HS CPU with no hardware extensions except the atomic
20986instructions.
20987
20988@item hs34
20989Compile for ARC HS34 CPU.
20990
20991@item hs38
20992Compile for ARC HS38 CPU.
20993
20994@item hs38_linux
20995Compile for ARC HS38 CPU with all hardware extensions on.
20996
20997@item hs4x
20998Compile for ARC HS4x CPU.
20999
21000@item hs4xd
21001Compile for ARC HS4xD CPU.
21002
21003@item hs4x_rel31
21004Compile for ARC HS4x CPU release 3.10a.
21005
21006@item arc600_norm
21007Compile for ARC 600 CPU with @code{norm} instructions enabled.
21008
21009@item arc600_mul32x16
21010Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
21011instructions enabled.
21012
21013@item arc600_mul64
21014Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
21015instructions enabled.
21016
21017@item arc601_norm
21018Compile for ARC 601 CPU with @code{norm} instructions enabled.
21019
21020@item arc601_mul32x16
21021Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
21022instructions enabled.
21023
21024@item arc601_mul64
21025Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
21026instructions enabled.
21027
21028@item nps400
21029Compile for ARC 700 on NPS400 chip.
21030
21031@item em_mini
21032Compile for ARC EM minimalist configuration featuring reduced register
21033set.
21034
21035@end table
21036
d77de738 21037@opindex mdpfp
d77de738 21038@opindex mdpfp-compact
ddf6fe37
AA
21039@item -mdpfp
21040@itemx -mdpfp-compact
d77de738
ML
21041Generate double-precision FPX instructions, tuned for the compact
21042implementation.
21043
d77de738 21044@opindex mdpfp-fast
ddf6fe37 21045@item -mdpfp-fast
d77de738
ML
21046Generate double-precision FPX instructions, tuned for the fast
21047implementation.
21048
d77de738 21049@opindex mno-dpfp-lrsr
ddf6fe37 21050@item -mno-dpfp-lrsr
d77de738
ML
21051Disable @code{lr} and @code{sr} instructions from using FPX extension
21052aux registers.
21053
d77de738 21054@opindex mea
ddf6fe37 21055@item -mea
d77de738
ML
21056Generate extended arithmetic instructions. Currently only
21057@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
21058supported. Only valid for @option{-mcpu=ARC700}.
21059
d77de738
ML
21060@opindex mno-mpy
21061@opindex mmpy
ddf6fe37 21062@item -mno-mpy
d77de738
ML
21063Do not generate @code{mpy}-family instructions for ARC700. This option is
21064deprecated.
21065
d77de738 21066@opindex mmul32x16
ddf6fe37 21067@item -mmul32x16
d77de738
ML
21068Generate 32x16-bit multiply and multiply-accumulate instructions.
21069
d77de738 21070@opindex mmul64
ddf6fe37 21071@item -mmul64
d77de738
ML
21072Generate @code{mul64} and @code{mulu64} instructions.
21073Only valid for @option{-mcpu=ARC600}.
21074
d77de738 21075@opindex mnorm
ddf6fe37 21076@item -mnorm
d77de738
ML
21077Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
21078is in effect.
21079
d77de738 21080@opindex mspfp
d77de738 21081@opindex mspfp-compact
ddf6fe37
AA
21082@item -mspfp
21083@itemx -mspfp-compact
d77de738
ML
21084Generate single-precision FPX instructions, tuned for the compact
21085implementation.
21086
d77de738 21087@opindex mspfp-fast
ddf6fe37 21088@item -mspfp-fast
d77de738
ML
21089Generate single-precision FPX instructions, tuned for the fast
21090implementation.
21091
d77de738 21092@opindex msimd
ddf6fe37 21093@item -msimd
d77de738
ML
21094Enable generation of ARC SIMD instructions via target-specific
21095builtins. Only valid for @option{-mcpu=ARC700}.
21096
d77de738 21097@opindex msoft-float
ddf6fe37 21098@item -msoft-float
d77de738
ML
21099This option ignored; it is provided for compatibility purposes only.
21100Software floating-point code is emitted by default, and this default
21101can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
21102@option{-mspfp-fast} for single precision, and @option{-mdpfp},
21103@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
21104
d77de738 21105@opindex mswap
ddf6fe37 21106@item -mswap
d77de738
ML
21107Generate @code{swap} instructions.
21108
d77de738 21109@opindex matomic
ddf6fe37 21110@item -matomic
d77de738
ML
21111This enables use of the locked load/store conditional extension to implement
21112atomic memory built-in functions. Not available for ARC 6xx or ARC
21113EM cores.
21114
d77de738 21115@opindex mdiv-rem
ddf6fe37 21116@item -mdiv-rem
d77de738
ML
21117Enable @code{div} and @code{rem} instructions for ARCv2 cores.
21118
d77de738 21119@opindex mcode-density
ddf6fe37 21120@item -mcode-density
d77de738
ML
21121Enable code density instructions for ARC EM.
21122This option is on by default for ARC HS.
21123
d77de738 21124@opindex mll64
ddf6fe37 21125@item -mll64
d77de738
ML
21126Enable double load/store operations for ARC HS cores.
21127
d77de738 21128@opindex mtp-regno
ddf6fe37 21129@item -mtp-regno=@var{regno}
d77de738
ML
21130Specify thread pointer register number.
21131
d77de738 21132@opindex mmpy-option
ddf6fe37 21133@item -mmpy-option=@var{multo}
d77de738
ML
21134Compile ARCv2 code with a multiplier design option. You can specify
21135the option using either a string or numeric value for @var{multo}.
21136@samp{wlh1} is the default value. The recognized values are:
21137
21138@table @samp
21139@item 0
21140@itemx none
21141No multiplier available.
21142
21143@item 1
21144@itemx w
2114516x16 multiplier, fully pipelined.
21146The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
21147
21148@item 2
21149@itemx wlh1
2115032x32 multiplier, fully
21151pipelined (1 stage). The following instructions are additionally
21152enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21153
21154@item 3
21155@itemx wlh2
2115632x32 multiplier, fully pipelined
21157(2 stages). The following instructions are additionally enabled: @code{mpy},
21158@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21159
21160@item 4
21161@itemx wlh3
21162Two 16x16 multipliers, blocking,
21163sequential. The following instructions are additionally enabled: @code{mpy},
21164@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21165
21166@item 5
21167@itemx wlh4
21168One 16x16 multiplier, blocking,
21169sequential. The following instructions are additionally enabled: @code{mpy},
21170@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21171
21172@item 6
21173@itemx wlh5
21174One 32x4 multiplier, blocking,
21175sequential. The following instructions are additionally enabled: @code{mpy},
21176@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21177
21178@item 7
21179@itemx plus_dmpy
21180ARC HS SIMD support.
21181
21182@item 8
21183@itemx plus_macd
21184ARC HS SIMD support.
21185
21186@item 9
21187@itemx plus_qmacw
21188ARC HS SIMD support.
21189
21190@end table
21191
21192This option is only available for ARCv2 cores@.
21193
d77de738 21194@opindex mfpu
ddf6fe37 21195@item -mfpu=@var{fpu}
d77de738
ML
21196Enables support for specific floating-point hardware extensions for ARCv2
21197cores. Supported values for @var{fpu} are:
21198
21199@table @samp
21200
21201@item fpus
21202Enables support for single-precision floating-point hardware
21203extensions@.
21204
21205@item fpud
21206Enables support for double-precision floating-point hardware
21207extensions. The single-precision floating-point extension is also
21208enabled. Not available for ARC EM@.
21209
21210@item fpuda
21211Enables support for double-precision floating-point hardware
21212extensions using double-precision assist instructions. The single-precision
21213floating-point extension is also enabled. This option is
21214only available for ARC EM@.
21215
21216@item fpuda_div
21217Enables support for double-precision floating-point hardware
21218extensions using double-precision assist instructions.
21219The single-precision floating-point, square-root, and divide
21220extensions are also enabled. This option is
21221only available for ARC EM@.
21222
21223@item fpuda_fma
21224Enables support for double-precision floating-point hardware
21225extensions using double-precision assist instructions.
21226The single-precision floating-point and fused multiply and add
21227hardware extensions are also enabled. This option is
21228only available for ARC EM@.
21229
21230@item fpuda_all
21231Enables support for double-precision floating-point hardware
21232extensions using double-precision assist instructions.
21233All single-precision floating-point hardware extensions are also
21234enabled. This option is only available for ARC EM@.
21235
21236@item fpus_div
21237Enables support for single-precision floating-point, square-root and divide
21238hardware extensions@.
21239
21240@item fpud_div
21241Enables support for double-precision floating-point, square-root and divide
21242hardware extensions. This option
21243includes option @samp{fpus_div}. Not available for ARC EM@.
21244
21245@item fpus_fma
21246Enables support for single-precision floating-point and
21247fused multiply and add hardware extensions@.
21248
21249@item fpud_fma
21250Enables support for double-precision floating-point and
21251fused multiply and add hardware extensions. This option
21252includes option @samp{fpus_fma}. Not available for ARC EM@.
21253
21254@item fpus_all
21255Enables support for all single-precision floating-point hardware
21256extensions@.
21257
21258@item fpud_all
21259Enables support for all single- and double-precision floating-point
21260hardware extensions. Not available for ARC EM@.
21261
21262@end table
21263
d77de738 21264@opindex mirq-ctrl-saved
ddf6fe37 21265@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
d77de738
ML
21266Specifies general-purposes registers that the processor automatically
21267saves/restores on interrupt entry and exit. @var{register-range} is
21268specified as two registers separated by a dash. The register range
21269always starts with @code{r0}, the upper limit is @code{fp} register.
21270@var{blink} and @var{lp_count} are optional. This option is only
21271valid for ARC EM and ARC HS cores.
21272
d77de738 21273@opindex mrgf-banked-regs
ddf6fe37 21274@item -mrgf-banked-regs=@var{number}
d77de738
ML
21275Specifies the number of registers replicated in second register bank
21276on entry to fast interrupt. Fast interrupts are interrupts with the
21277highest priority level P0. These interrupts save only PC and STATUS32
21278registers to avoid memory transactions during interrupt entry and exit
21279sequences. Use this option when you are using fast interrupts in an
21280ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21281
d77de738 21282@opindex mlpc-width
ddf6fe37 21283@item -mlpc-width=@var{width}
d77de738
ML
21284Specify the width of the @code{lp_count} register. Valid values for
21285@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21286fixed to 32 bits. If the width is less than 32, the compiler does not
21287attempt to transform loops in your program to use the zero-delay loop
21288mechanism unless it is known that the @code{lp_count} register can
21289hold the required loop-counter value. Depending on the width
21290specified, the compiler and run-time library might continue to use the
21291loop mechanism for various needs. This option defines macro
21292@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21293
d77de738 21294@opindex mrf16
ddf6fe37 21295@item -mrf16
d77de738
ML
21296This option instructs the compiler to generate code for a 16-entry
21297register file. This option defines the @code{__ARC_RF16__}
21298preprocessor macro.
21299
d77de738 21300@opindex mbranch-index
ddf6fe37 21301@item -mbranch-index
d77de738
ML
21302Enable use of @code{bi} or @code{bih} instructions to implement jump
21303tables.
21304
21305@end table
21306
21307The following options are passed through to the assembler, and also
21308define preprocessor macro symbols.
21309
21310@c Flags used by the assembler, but for which we define preprocessor
21311@c macro symbols as well.
21312@table @gcctabopt
d77de738 21313@opindex mdsp-packa
ddf6fe37 21314@item -mdsp-packa
d77de738
ML
21315Passed down to the assembler to enable the DSP Pack A extensions.
21316Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21317deprecated.
21318
d77de738 21319@opindex mdvbf
ddf6fe37 21320@item -mdvbf
d77de738
ML
21321Passed down to the assembler to enable the dual Viterbi butterfly
21322extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21323option is deprecated.
21324
21325@c ARC700 4.10 extension instruction
d77de738 21326@opindex mlock
ddf6fe37 21327@item -mlock
d77de738
ML
21328Passed down to the assembler to enable the locked load/store
21329conditional extension. Also sets the preprocessor symbol
21330@code{__Xlock}.
21331
d77de738 21332@opindex mmac-d16
ddf6fe37 21333@item -mmac-d16
d77de738
ML
21334Passed down to the assembler. Also sets the preprocessor symbol
21335@code{__Xxmac_d16}. This option is deprecated.
21336
d77de738 21337@opindex mmac-24
ddf6fe37 21338@item -mmac-24
d77de738
ML
21339Passed down to the assembler. Also sets the preprocessor symbol
21340@code{__Xxmac_24}. This option is deprecated.
21341
21342@c ARC700 4.10 extension instruction
d77de738 21343@opindex mrtsc
ddf6fe37 21344@item -mrtsc
d77de738
ML
21345Passed down to the assembler to enable the 64-bit time-stamp counter
21346extension instruction. Also sets the preprocessor symbol
21347@code{__Xrtsc}. This option is deprecated.
21348
21349@c ARC700 4.10 extension instruction
d77de738 21350@opindex mswape
ddf6fe37 21351@item -mswape
d77de738
ML
21352Passed down to the assembler to enable the swap byte ordering
21353extension instruction. Also sets the preprocessor symbol
21354@code{__Xswape}.
21355
d77de738 21356@opindex mtelephony
ddf6fe37 21357@item -mtelephony
d77de738
ML
21358Passed down to the assembler to enable dual- and single-operand
21359instructions for telephony. Also sets the preprocessor symbol
21360@code{__Xtelephony}. This option is deprecated.
21361
d77de738 21362@opindex mxy
ddf6fe37 21363@item -mxy
d77de738
ML
21364Passed down to the assembler to enable the XY memory extension. Also
21365sets the preprocessor symbol @code{__Xxy}.
21366
21367@end table
21368
21369The following options control how the assembly code is annotated:
21370
21371@c Assembly annotation options
21372@table @gcctabopt
d77de738 21373@opindex misize
ddf6fe37 21374@item -misize
d77de738
ML
21375Annotate assembler instructions with estimated addresses.
21376
d77de738 21377@opindex mannotate-align
ddf6fe37 21378@item -mannotate-align
d77de738
ML
21379Explain what alignment considerations lead to the decision to make an
21380instruction short or long.
21381
21382@end table
21383
21384The following options are passed through to the linker:
21385
21386@c options passed through to the linker
21387@table @gcctabopt
d77de738 21388@opindex marclinux
ddf6fe37 21389@item -marclinux
d77de738
ML
21390Passed through to the linker, to specify use of the @code{arclinux} emulation.
21391This option is enabled by default in tool chains built for
21392@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21393when profiling is not requested.
21394
d77de738 21395@opindex marclinux_prof
ddf6fe37 21396@item -marclinux_prof
d77de738
ML
21397Passed through to the linker, to specify use of the
21398@code{arclinux_prof} emulation. This option is enabled by default in
21399tool chains built for @w{@code{arc-linux-uclibc}} and
21400@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21401
21402@end table
21403
21404The following options control the semantics of generated code:
21405
21406@c semantically relevant code generation options
21407@table @gcctabopt
d77de738 21408@opindex mlong-calls
ddf6fe37 21409@item -mlong-calls
d77de738
ML
21410Generate calls as register indirect calls, thus providing access
21411to the full 32-bit address range.
21412
d77de738 21413@opindex mmedium-calls
ddf6fe37 21414@item -mmedium-calls
d77de738
ML
21415Don't use less than 25-bit addressing range for calls, which is the
21416offset available for an unconditional branch-and-link
21417instruction. Conditional execution of function calls is suppressed, to
21418allow use of the 25-bit range, rather than the 21-bit range with
21419conditional branch-and-link. This is the default for tool chains built
21420for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21421
d77de738 21422@opindex G
ddf6fe37 21423@item -G @var{num}
d77de738
ML
21424Put definitions of externally-visible data in a small data section if
21425that data is no bigger than @var{num} bytes. The default value of
21426@var{num} is 4 for any ARC configuration, or 8 when we have double
21427load/store operations.
21428
d77de738
ML
21429@opindex mno-sdata
21430@opindex msdata
ddf6fe37 21431@item -mno-sdata
d77de738
ML
21432Do not generate sdata references. This is the default for tool chains
21433built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21434targets.
21435
d77de738 21436@opindex mvolatile-cache
ddf6fe37 21437@item -mvolatile-cache
d77de738
ML
21438Use ordinarily cached memory accesses for volatile references. This is the
21439default.
21440
d77de738
ML
21441@opindex mno-volatile-cache
21442@opindex mvolatile-cache
ddf6fe37 21443@item -mno-volatile-cache
d77de738
ML
21444Enable cache bypass for volatile references.
21445
21446@end table
21447
21448The following options fine tune code generation:
21449@c code generation tuning options
21450@table @gcctabopt
d77de738 21451@opindex malign-call
ddf6fe37 21452@item -malign-call
d77de738
ML
21453Does nothing. Preserved for backward compatibility.
21454
d77de738 21455@opindex mauto-modify-reg
ddf6fe37 21456@item -mauto-modify-reg
d77de738
ML
21457Enable the use of pre/post modify with register displacement.
21458
d77de738 21459@opindex mbbit-peephole
ddf6fe37 21460@item -mbbit-peephole
d77de738
ML
21461Enable bbit peephole2.
21462
d77de738 21463@opindex mno-brcc
ddf6fe37 21464@item -mno-brcc
d77de738
ML
21465This option disables a target-specific pass in @file{arc_reorg} to
21466generate compare-and-branch (@code{br@var{cc}}) instructions.
21467It has no effect on
21468generation of these instructions driven by the combiner pass.
21469
d77de738 21470@opindex mcase-vector-pcrel
ddf6fe37 21471@item -mcase-vector-pcrel
d77de738
ML
21472Use PC-relative switch case tables to enable case table shortening.
21473This is the default for @option{-Os}.
21474
d77de738 21475@opindex mcompact-casesi
ddf6fe37 21476@item -mcompact-casesi
d77de738
ML
21477Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21478and only available for ARCv1 cores. This option is deprecated.
21479
d77de738 21480@opindex mno-cond-exec
ddf6fe37 21481@item -mno-cond-exec
d77de738
ML
21482Disable the ARCompact-specific pass to generate conditional
21483execution instructions.
21484
21485Due to delay slot scheduling and interactions between operand numbers,
21486literal sizes, instruction lengths, and the support for conditional execution,
21487the target-independent pass to generate conditional execution is often lacking,
21488so the ARC port has kept a special pass around that tries to find more
21489conditional execution generation opportunities after register allocation,
21490branch shortening, and delay slot scheduling have been done. This pass
21491generally, but not always, improves performance and code size, at the cost of
21492extra compilation time, which is why there is an option to switch it off.
21493If you have a problem with call instructions exceeding their allowable
21494offset range because they are conditionalized, you should consider using
21495@option{-mmedium-calls} instead.
21496
d77de738 21497@opindex mearly-cbranchsi
ddf6fe37 21498@item -mearly-cbranchsi
d77de738
ML
21499Enable pre-reload use of the @code{cbranchsi} pattern.
21500
d77de738 21501@opindex mexpand-adddi
ddf6fe37 21502@item -mexpand-adddi
d77de738
ML
21503Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21504@code{add.f}, @code{adc} etc. This option is deprecated.
21505
d77de738 21506@opindex mindexed-loads
ddf6fe37 21507@item -mindexed-loads
d77de738
ML
21508Enable the use of indexed loads. This can be problematic because some
21509optimizers then assume that indexed stores exist, which is not
21510the case.
21511
d77de738 21512@opindex mlra
ddf6fe37 21513@item -mlra
d77de738
ML
21514Enable Local Register Allocation. This is still experimental for ARC,
21515so by default the compiler uses standard reload
21516(i.e.@: @option{-mno-lra}).
21517
d77de738 21518@opindex mlra-priority-none
ddf6fe37 21519@item -mlra-priority-none
d77de738
ML
21520Don't indicate any priority for target registers.
21521
d77de738 21522@opindex mlra-priority-compact
ddf6fe37 21523@item -mlra-priority-compact
d77de738
ML
21524Indicate target register priority for r0..r3 / r12..r15.
21525
d77de738 21526@opindex mlra-priority-noncompact
ddf6fe37 21527@item -mlra-priority-noncompact
d77de738
ML
21528Reduce target register priority for r0..r3 / r12..r15.
21529
d77de738 21530@opindex mmillicode
ddf6fe37 21531@item -mmillicode
d77de738
ML
21532When optimizing for size (using @option{-Os}), prologues and epilogues
21533that have to save or restore a large number of registers are often
21534shortened by using call to a special function in libgcc; this is
21535referred to as a @emph{millicode} call. As these calls can pose
21536performance issues, and/or cause linking issues when linking in a
21537nonstandard way, this option is provided to turn on or off millicode
21538call generation.
21539
d77de738 21540@opindex mcode-density-frame
ddf6fe37 21541@item -mcode-density-frame
d77de738
ML
21542This option enable the compiler to emit @code{enter} and @code{leave}
21543instructions. These instructions are only valid for CPUs with
21544code-density feature.
21545
d77de738 21546@opindex mmixed-code
ddf6fe37 21547@item -mmixed-code
d77de738
ML
21548Does nothing. Preserved for backward compatibility.
21549
d77de738 21550@opindex mq-class
ddf6fe37 21551@item -mq-class
d77de738
ML
21552Ths option is deprecated. Enable @samp{q} instruction alternatives.
21553This is the default for @option{-Os}.
21554
d77de738 21555@opindex mRcq
ddf6fe37 21556@item -mRcq
d77de738
ML
21557Does nothing. Preserved for backward compatibility.
21558
d77de738 21559@opindex mRcw
ddf6fe37 21560@item -mRcw
d77de738
ML
21561Does nothing. Preserved for backward compatibility.
21562
d77de738 21563@opindex msize-level
ddf6fe37 21564@item -msize-level=@var{level}
d77de738
ML
21565Fine-tune size optimization with regards to instruction lengths and alignment.
21566The recognized values for @var{level} are:
21567@table @samp
21568@item 0
21569No size optimization. This level is deprecated and treated like @samp{1}.
21570
21571@item 1
21572Short instructions are used opportunistically.
21573
21574@item 2
21575In addition, alignment of loops and of code after barriers are dropped.
21576
21577@item 3
21578In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21579
21580@end table
21581
21582This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21583the behavior when this is not set is equivalent to level @samp{1}.
21584
d77de738 21585@opindex mtune
ddf6fe37 21586@item -mtune=@var{cpu}
d77de738
ML
21587Set instruction scheduling parameters for @var{cpu}, overriding any implied
21588by @option{-mcpu=}.
21589
21590Supported values for @var{cpu} are
21591
21592@table @samp
21593@item ARC600
21594Tune for ARC600 CPU.
21595
21596@item ARC601
21597Tune for ARC601 CPU.
21598
21599@item ARC700
21600Tune for ARC700 CPU with standard multiplier block.
21601
21602@item ARC700-xmac
21603Tune for ARC700 CPU with XMAC block.
21604
21605@item ARC725D
21606Tune for ARC725D CPU.
21607
21608@item ARC750D
21609Tune for ARC750D CPU.
21610
21611@item core3
21612Tune for ARCv2 core3 type CPU. This option enable usage of
21613@code{dbnz} instruction.
21614
21615@item release31a
21616Tune for ARC4x release 3.10a.
21617
21618@end table
21619
d77de738 21620@opindex mmultcost
ddf6fe37 21621@item -mmultcost=@var{num}
d77de738
ML
21622Cost to assume for a multiply instruction, with @samp{4} being equal to a
21623normal instruction.
21624
d77de738 21625@opindex munalign-prob-threshold
ddf6fe37 21626@item -munalign-prob-threshold=@var{probability}
d77de738
ML
21627Does nothing. Preserved for backward compatibility.
21628
21629@end table
21630
21631The following options are maintained for backward compatibility, but
21632are now deprecated and will be removed in a future release:
21633
21634@c Deprecated options
21635@table @gcctabopt
21636
d77de738 21637@opindex margonaut
ddf6fe37 21638@item -margonaut
d77de738
ML
21639Obsolete FPX.
21640
d77de738 21641@opindex mbig-endian
d77de738 21642@opindex EB
ddf6fe37
AA
21643@item -mbig-endian
21644@itemx -EB
d77de738
ML
21645Compile code for big-endian targets. Use of these options is now
21646deprecated. Big-endian code is supported by configuring GCC to build
21647@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21648for which big endian is the default.
21649
d77de738 21650@opindex mlittle-endian
d77de738 21651@opindex EL
ddf6fe37
AA
21652@item -mlittle-endian
21653@itemx -EL
d77de738
ML
21654Compile code for little-endian targets. Use of these options is now
21655deprecated. Little-endian code is supported by configuring GCC to build
21656@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21657for which little endian is the default.
21658
d77de738 21659@opindex mbarrel_shifter
ddf6fe37 21660@item -mbarrel_shifter
d77de738
ML
21661Replaced by @option{-mbarrel-shifter}.
21662
d77de738 21663@opindex mdpfp_compact
ddf6fe37 21664@item -mdpfp_compact
d77de738
ML
21665Replaced by @option{-mdpfp-compact}.
21666
d77de738 21667@opindex mdpfp_fast
ddf6fe37 21668@item -mdpfp_fast
d77de738
ML
21669Replaced by @option{-mdpfp-fast}.
21670
d77de738 21671@opindex mdsp_packa
ddf6fe37 21672@item -mdsp_packa
d77de738
ML
21673Replaced by @option{-mdsp-packa}.
21674
d77de738 21675@opindex mEA
ddf6fe37 21676@item -mEA
d77de738
ML
21677Replaced by @option{-mea}.
21678
d77de738 21679@opindex mmac_24
ddf6fe37 21680@item -mmac_24
d77de738
ML
21681Replaced by @option{-mmac-24}.
21682
d77de738 21683@opindex mmac_d16
ddf6fe37 21684@item -mmac_d16
d77de738
ML
21685Replaced by @option{-mmac-d16}.
21686
d77de738 21687@opindex mspfp_compact
ddf6fe37 21688@item -mspfp_compact
d77de738
ML
21689Replaced by @option{-mspfp-compact}.
21690
d77de738 21691@opindex mspfp_fast
ddf6fe37 21692@item -mspfp_fast
d77de738
ML
21693Replaced by @option{-mspfp-fast}.
21694
d77de738 21695@opindex mtune
ddf6fe37 21696@item -mtune=@var{cpu}
d77de738
ML
21697Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21698@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21699@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21700
d77de738 21701@opindex multcost
ddf6fe37 21702@item -multcost=@var{num}
d77de738
ML
21703Replaced by @option{-mmultcost}.
21704
21705@end table
21706
21707@node ARM Options
21708@subsection ARM Options
21709@cindex ARM options
21710
21711These @samp{-m} options are defined for the ARM port:
21712
21713@table @gcctabopt
d77de738 21714@opindex mabi
ddf6fe37 21715@item -mabi=@var{name}
d77de738
ML
21716Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21717@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21718
d77de738 21719@opindex mapcs-frame
ddf6fe37 21720@item -mapcs-frame
d77de738
ML
21721Generate a stack frame that is compliant with the ARM Procedure Call
21722Standard for all functions, even if this is not strictly necessary for
21723correct execution of the code. Specifying @option{-fomit-frame-pointer}
21724with this option causes the stack frames not to be generated for
21725leaf functions. The default is @option{-mno-apcs-frame}.
21726This option is deprecated.
21727
d77de738 21728@opindex mapcs
ddf6fe37 21729@item -mapcs
d77de738
ML
21730This is a synonym for @option{-mapcs-frame} and is deprecated.
21731
21732@ignore
21733@c not currently implemented
d77de738 21734@opindex mapcs-stack-check
ddf6fe37 21735@item -mapcs-stack-check
d77de738
ML
21736Generate code to check the amount of stack space available upon entry to
21737every function (that actually uses some stack space). If there is
21738insufficient space available then either the function
21739@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21740called, depending upon the amount of stack space required. The runtime
21741system is required to provide these functions. The default is
21742@option{-mno-apcs-stack-check}, since this produces smaller code.
21743
21744@c not currently implemented
d77de738 21745@opindex mapcs-reentrant
ddf6fe37 21746@item -mapcs-reentrant
d77de738
ML
21747Generate reentrant, position-independent code. The default is
21748@option{-mno-apcs-reentrant}.
21749@end ignore
21750
d77de738 21751@opindex mthumb-interwork
ddf6fe37 21752@item -mthumb-interwork
d77de738
ML
21753Generate code that supports calling between the ARM and Thumb
21754instruction sets. Without this option, on pre-v5 architectures, the
21755two instruction sets cannot be reliably used inside one program. The
21756default is @option{-mno-thumb-interwork}, since slightly larger code
21757is generated when @option{-mthumb-interwork} is specified. In AAPCS
21758configurations this option is meaningless.
21759
d77de738
ML
21760@opindex mno-sched-prolog
21761@opindex msched-prolog
ddf6fe37 21762@item -mno-sched-prolog
d77de738
ML
21763Prevent the reordering of instructions in the function prologue, or the
21764merging of those instruction with the instructions in the function's
21765body. This means that all functions start with a recognizable set
21766of instructions (or in fact one of a choice from a small set of
21767different function prologues), and this information can be used to
21768locate the start of functions inside an executable piece of code. The
21769default is @option{-msched-prolog}.
21770
d77de738 21771@opindex mfloat-abi
ddf6fe37 21772@item -mfloat-abi=@var{name}
d77de738
ML
21773Specifies which floating-point ABI to use. Permissible values
21774are: @samp{soft}, @samp{softfp} and @samp{hard}.
21775
21776Specifying @samp{soft} causes GCC to generate output containing
21777library calls for floating-point operations.
21778@samp{softfp} allows the generation of code using hardware floating-point
21779instructions, but still uses the soft-float calling conventions.
21780@samp{hard} allows generation of floating-point instructions
21781and uses FPU-specific calling conventions.
21782
21783The default depends on the specific target configuration. Note that
21784the hard-float and soft-float ABIs are not link-compatible; you must
21785compile your entire program with the same ABI, and link with a
21786compatible set of libraries.
21787
d77de738 21788@opindex mgeneral-regs-only
ddf6fe37 21789@item -mgeneral-regs-only
d77de738
ML
21790Generate code which uses only the general-purpose registers. This will prevent
21791the compiler from using floating-point and Advanced SIMD registers but will not
21792impose any restrictions on the assembler.
21793
d77de738 21794@opindex mlittle-endian
ddf6fe37 21795@item -mlittle-endian
d77de738
ML
21796Generate code for a processor running in little-endian mode. This is
21797the default for all standard configurations.
21798
d77de738 21799@opindex mbig-endian
ddf6fe37 21800@item -mbig-endian
d77de738
ML
21801Generate code for a processor running in big-endian mode; the default is
21802to compile code for a little-endian processor.
21803
ddf6fe37 21804@opindex mbe8
d77de738
ML
21805@item -mbe8
21806@itemx -mbe32
d77de738
ML
21807When linking a big-endian image select between BE8 and BE32 formats.
21808The option has no effect for little-endian images and is ignored. The
21809default is dependent on the selected target architecture. For ARMv6
21810and later architectures the default is BE8, for older architectures
21811the default is BE32. BE32 format has been deprecated by ARM.
21812
d77de738 21813@opindex march
ddf6fe37 21814@item -march=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
21815This specifies the name of the target ARM architecture. GCC uses this
21816name to determine what kind of instructions it can emit when generating
21817assembly code. This option can be used in conjunction with or instead
21818of the @option{-mcpu=} option.
21819
21820Permissible names are:
21821@samp{armv4t},
21822@samp{armv5t}, @samp{armv5te},
21823@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
21824@samp{armv6z}, @samp{armv6zk},
21825@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
21826@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
21827@samp{armv8.4-a},
21828@samp{armv8.5-a},
21829@samp{armv8.6-a},
21830@samp{armv9-a},
21831@samp{armv7-r},
21832@samp{armv8-r},
21833@samp{armv6-m}, @samp{armv6s-m},
21834@samp{armv7-m}, @samp{armv7e-m},
21835@samp{armv8-m.base}, @samp{armv8-m.main},
21836@samp{armv8.1-m.main},
21837@samp{armv9-a},
21838@samp{iwmmxt} and @samp{iwmmxt2}.
21839
21840Additionally, the following architectures, which lack support for the
21841Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
21842
21843Many of the architectures support extensions. These can be added by
21844appending @samp{+@var{extension}} to the architecture name. Extension
21845options are processed in order and capabilities accumulate. An extension
21846will also enable any necessary base extensions
21847upon which it depends. For example, the @samp{+crypto} extension
21848will always enable the @samp{+simd} extension. The exception to the
21849additive construction is for extensions that are prefixed with
21850@samp{+no@dots{}}: these extensions disable the specified option and
21851any other extensions that may depend on the presence of that
21852extension.
21853
21854For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
21855writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
21856entirely disabled by the @samp{+nofp} option that follows it.
21857
21858Most extension names are generically named, but have an effect that is
21859dependent upon the architecture to which it is applied. For example,
21860the @samp{+simd} option can be applied to both @samp{armv7-a} and
21861@samp{armv8-a} architectures, but will enable the original ARMv7-A
21862Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
21863variant for @samp{armv8-a}.
21864
21865The table below lists the supported extensions for each architecture.
21866Architectures not mentioned do not support any extensions.
21867
21868@table @samp
21869@item armv5te
21870@itemx armv6
21871@itemx armv6j
21872@itemx armv6k
21873@itemx armv6kz
21874@itemx armv6t2
21875@itemx armv6z
21876@itemx armv6zk
21877@table @samp
21878@item +fp
21879The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
21880used as an alias for this extension.
21881
21882@item +nofp
21883Disable the floating-point instructions.
21884@end table
21885
21886@item armv7
21887The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
21888@table @samp
21889@item +fp
21890The VFPv3 floating-point instructions, with 16 double-precision
21891registers. The extension @samp{+vfpv3-d16} can be used as an alias
21892for this extension. Note that floating-point is not supported by the
21893base ARMv7-M architecture, but is compatible with both the ARMv7-A and
21894ARMv7-R architectures.
21895
21896@item +nofp
21897Disable the floating-point instructions.
21898@end table
21899
21900@item armv7-a
21901@table @samp
21902@item +mp
21903The multiprocessing extension.
21904
21905@item +sec
21906The security extension.
21907
21908@item +fp
21909The VFPv3 floating-point instructions, with 16 double-precision
21910registers. The extension @samp{+vfpv3-d16} can be used as an alias
21911for this extension.
21912
21913@item +simd
21914The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21915The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
21916for this extension.
21917
21918@item +vfpv3
21919The VFPv3 floating-point instructions, with 32 double-precision
21920registers.
21921
21922@item +vfpv3-d16-fp16
21923The VFPv3 floating-point instructions, with 16 double-precision
21924registers and the half-precision floating-point conversion operations.
21925
21926@item +vfpv3-fp16
21927The VFPv3 floating-point instructions, with 32 double-precision
21928registers and the half-precision floating-point conversion operations.
21929
21930@item +vfpv4-d16
21931The VFPv4 floating-point instructions, with 16 double-precision
21932registers.
21933
21934@item +vfpv4
21935The VFPv4 floating-point instructions, with 32 double-precision
21936registers.
21937
21938@item +neon-fp16
21939The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21940the half-precision floating-point conversion operations.
21941
21942@item +neon-vfpv4
21943The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
21944
21945@item +nosimd
21946Disable the Advanced SIMD instructions (does not disable floating point).
21947
21948@item +nofp
21949Disable the floating-point and Advanced SIMD instructions.
21950@end table
21951
21952@item armv7ve
21953The extended version of the ARMv7-A architecture with support for
21954virtualization.
21955@table @samp
21956@item +fp
21957The VFPv4 floating-point instructions, with 16 double-precision registers.
21958The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
21959
21960@item +simd
21961The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
21962extension @samp{+neon-vfpv4} can be used as an alias for this extension.
21963
21964@item +vfpv3-d16
21965The VFPv3 floating-point instructions, with 16 double-precision
21966registers.
21967
21968@item +vfpv3
21969The VFPv3 floating-point instructions, with 32 double-precision
21970registers.
21971
21972@item +vfpv3-d16-fp16
21973The VFPv3 floating-point instructions, with 16 double-precision
21974registers and the half-precision floating-point conversion operations.
21975
21976@item +vfpv3-fp16
21977The VFPv3 floating-point instructions, with 32 double-precision
21978registers and the half-precision floating-point conversion operations.
21979
21980@item +vfpv4-d16
21981The VFPv4 floating-point instructions, with 16 double-precision
21982registers.
21983
21984@item +vfpv4
21985The VFPv4 floating-point instructions, with 32 double-precision
21986registers.
21987
21988@item +neon
21989The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21990The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
21991
21992@item +neon-fp16
21993The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21994the half-precision floating-point conversion operations.
21995
21996@item +nosimd
21997Disable the Advanced SIMD instructions (does not disable floating point).
21998
21999@item +nofp
22000Disable the floating-point and Advanced SIMD instructions.
22001@end table
22002
22003@item armv8-a
22004@table @samp
22005@item +crc
22006The Cyclic Redundancy Check (CRC) instructions.
22007@item +simd
22008The ARMv8-A Advanced SIMD and floating-point instructions.
22009@item +crypto
22010The cryptographic instructions.
22011@item +nocrypto
22012Disable the cryptographic instructions.
22013@item +nofp
22014Disable the floating-point, Advanced SIMD and cryptographic instructions.
22015@item +sb
22016Speculation Barrier Instruction.
22017@item +predres
22018Execution and Data Prediction Restriction Instructions.
22019@end table
22020
22021@item armv8.1-a
22022@table @samp
22023@item +simd
22024The ARMv8.1-A Advanced SIMD and floating-point instructions.
22025
22026@item +crypto
22027The cryptographic instructions. This also enables the Advanced SIMD and
22028floating-point instructions.
22029
22030@item +nocrypto
22031Disable the cryptographic instructions.
22032
22033@item +nofp
22034Disable the floating-point, Advanced SIMD and cryptographic instructions.
22035
22036@item +sb
22037Speculation Barrier Instruction.
22038
22039@item +predres
22040Execution and Data Prediction Restriction Instructions.
22041@end table
22042
22043@item armv8.2-a
22044@itemx armv8.3-a
22045@table @samp
22046@item +fp16
22047The half-precision floating-point data processing instructions.
22048This also enables the Advanced SIMD and floating-point instructions.
22049
22050@item +fp16fml
22051The half-precision floating-point fmla extension. This also enables
22052the half-precision floating-point extension and Advanced SIMD and
22053floating-point instructions.
22054
22055@item +simd
22056The ARMv8.1-A Advanced SIMD and floating-point instructions.
22057
22058@item +crypto
22059The cryptographic instructions. This also enables the Advanced SIMD and
22060floating-point instructions.
22061
22062@item +dotprod
22063Enable the Dot Product extension. This also enables Advanced SIMD instructions.
22064
22065@item +nocrypto
22066Disable the cryptographic extension.
22067
22068@item +nofp
22069Disable the floating-point, Advanced SIMD and cryptographic instructions.
22070
22071@item +sb
22072Speculation Barrier Instruction.
22073
22074@item +predres
22075Execution and Data Prediction Restriction Instructions.
22076
22077@item +i8mm
220788-bit Integer Matrix Multiply instructions.
22079This also enables Advanced SIMD and floating-point instructions.
22080
22081@item +bf16
22082Brain half-precision floating-point instructions.
22083This also enables Advanced SIMD and floating-point instructions.
22084@end table
22085
22086@item armv8.4-a
22087@table @samp
22088@item +fp16
22089The half-precision floating-point data processing instructions.
22090This also enables the Advanced SIMD and floating-point instructions as well
22091as the Dot Product extension and the half-precision floating-point fmla
22092extension.
22093
22094@item +simd
22095The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22096Dot Product extension.
22097
22098@item +crypto
22099The cryptographic instructions. This also enables the Advanced SIMD and
22100floating-point instructions as well as the Dot Product extension.
22101
22102@item +nocrypto
22103Disable the cryptographic extension.
22104
22105@item +nofp
22106Disable the floating-point, Advanced SIMD and cryptographic instructions.
22107
22108@item +sb
22109Speculation Barrier Instruction.
22110
22111@item +predres
22112Execution and Data Prediction Restriction Instructions.
22113
22114@item +i8mm
221158-bit Integer Matrix Multiply instructions.
22116This also enables Advanced SIMD and floating-point instructions.
22117
22118@item +bf16
22119Brain half-precision floating-point instructions.
22120This also enables Advanced SIMD and floating-point instructions.
22121@end table
22122
22123@item armv8.5-a
22124@table @samp
22125@item +fp16
22126The half-precision floating-point data processing instructions.
22127This also enables the Advanced SIMD and floating-point instructions as well
22128as the Dot Product extension and the half-precision floating-point fmla
22129extension.
22130
22131@item +simd
22132The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22133Dot Product extension.
22134
22135@item +crypto
22136The cryptographic instructions. This also enables the Advanced SIMD and
22137floating-point instructions as well as the Dot Product extension.
22138
22139@item +nocrypto
22140Disable the cryptographic extension.
22141
22142@item +nofp
22143Disable the floating-point, Advanced SIMD and cryptographic instructions.
22144
22145@item +i8mm
221468-bit Integer Matrix Multiply instructions.
22147This also enables Advanced SIMD and floating-point instructions.
22148
22149@item +bf16
22150Brain half-precision floating-point instructions.
22151This also enables Advanced SIMD and floating-point instructions.
22152@end table
22153
22154@item armv8.6-a
22155@table @samp
22156@item +fp16
22157The half-precision floating-point data processing instructions.
22158This also enables the Advanced SIMD and floating-point instructions as well
22159as the Dot Product extension and the half-precision floating-point fmla
22160extension.
22161
22162@item +simd
22163The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22164Dot Product extension.
22165
22166@item +crypto
22167The cryptographic instructions. This also enables the Advanced SIMD and
22168floating-point instructions as well as the Dot Product extension.
22169
22170@item +nocrypto
22171Disable the cryptographic extension.
22172
22173@item +nofp
22174Disable the floating-point, Advanced SIMD and cryptographic instructions.
22175
22176@item +i8mm
221778-bit Integer Matrix Multiply instructions.
22178This also enables Advanced SIMD and floating-point instructions.
22179
22180@item +bf16
22181Brain half-precision floating-point instructions.
22182This also enables Advanced SIMD and floating-point instructions.
22183@end table
22184
22185@item armv7-r
22186@table @samp
22187@item +fp.sp
22188The single-precision VFPv3 floating-point instructions. The extension
22189@samp{+vfpv3xd} can be used as an alias for this extension.
22190
22191@item +fp
22192The VFPv3 floating-point instructions with 16 double-precision registers.
22193The extension +vfpv3-d16 can be used as an alias for this extension.
22194
22195@item +vfpv3xd-d16-fp16
22196The single-precision VFPv3 floating-point instructions with 16 double-precision
22197registers and the half-precision floating-point conversion operations.
22198
22199@item +vfpv3-d16-fp16
22200The VFPv3 floating-point instructions with 16 double-precision
22201registers and the half-precision floating-point conversion operations.
22202
22203@item +nofp
22204Disable the floating-point extension.
22205
22206@item +idiv
22207The ARM-state integer division instructions.
22208
22209@item +noidiv
22210Disable the ARM-state integer division extension.
22211@end table
22212
22213@item armv7e-m
22214@table @samp
22215@item +fp
22216The single-precision VFPv4 floating-point instructions.
22217
22218@item +fpv5
22219The single-precision FPv5 floating-point instructions.
22220
22221@item +fp.dp
22222The single- and double-precision FPv5 floating-point instructions.
22223
22224@item +nofp
22225Disable the floating-point extensions.
22226@end table
22227
22228@item armv8.1-m.main
22229@table @samp
22230
22231@item +dsp
22232The DSP instructions.
22233
22234@item +mve
22235The M-Profile Vector Extension (MVE) integer instructions.
22236
22237@item +mve.fp
22238The M-Profile Vector Extension (MVE) integer and single precision
22239floating-point instructions.
22240
22241@item +fp
22242The single-precision floating-point instructions.
22243
22244@item +fp.dp
22245The single- and double-precision floating-point instructions.
22246
22247@item +nofp
22248Disable the floating-point extension.
22249
22250@item +cdecp0, +cdecp1, ... , +cdecp7
22251Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22252to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
22253
22254@item +pacbti
22255Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
22256@end table
22257
22258@item armv8-m.main
22259@table @samp
22260@item +dsp
22261The DSP instructions.
22262
22263@item +nodsp
22264Disable the DSP extension.
22265
22266@item +fp
22267The single-precision floating-point instructions.
22268
22269@item +fp.dp
22270The single- and double-precision floating-point instructions.
22271
22272@item +nofp
22273Disable the floating-point extension.
22274
22275@item +cdecp0, +cdecp1, ... , +cdecp7
22276Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22277to the numbers given in the options in the range 0 to 7.
22278@end table
22279
22280@item armv8-r
22281@table @samp
22282@item +crc
22283The Cyclic Redundancy Check (CRC) instructions.
22284@item +fp.sp
22285The single-precision FPv5 floating-point instructions.
22286@item +simd
22287The ARMv8-A Advanced SIMD and floating-point instructions.
22288@item +crypto
22289The cryptographic instructions.
22290@item +nocrypto
22291Disable the cryptographic instructions.
22292@item +nofp
22293Disable the floating-point, Advanced SIMD and cryptographic instructions.
22294@end table
22295
22296@end table
22297
22298@option{-march=native} causes the compiler to auto-detect the architecture
22299of the build computer. At present, this feature is only supported on
22300GNU/Linux, and not all architectures are recognized. If the auto-detect
22301is unsuccessful the option has no effect.
22302
d77de738 22303@opindex mtune
ddf6fe37 22304@item -mtune=@var{name}
d77de738
ML
22305This option specifies the name of the target ARM processor for
22306which GCC should tune the performance of the code.
22307For some ARM implementations better performance can be obtained by using
22308this option.
22309Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22310@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22311@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22312@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22313@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22314@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22315@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22316@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22317@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22318@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22319@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22320@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22321@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22322@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22323@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22324@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22325@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22326@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22327@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
ccfd1e7f
SP
22328@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
22329@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
22330@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22331@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22332@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22333@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22334@samp{xgene1}.
22335
22336Additionally, this option can specify that GCC should tune the performance
22337of the code for a big.LITTLE system. Permissible names are:
22338@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22339@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22340@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22341@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22342
22343@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22344performance for a blend of processors within architecture @var{arch}.
22345The aim is to generate code that run well on the current most popular
22346processors, balancing between optimizations that benefit some CPUs in the
22347range, and avoiding performance pitfalls of other CPUs. The effects of
22348this option may change in future GCC versions as CPU models come and go.
22349
22350@option{-mtune} permits the same extension options as @option{-mcpu}, but
22351the extension options do not affect the tuning of the generated code.
22352
22353@option{-mtune=native} causes the compiler to auto-detect the CPU
22354of the build computer. At present, this feature is only supported on
22355GNU/Linux, and not all architectures are recognized. If the auto-detect is
22356unsuccessful the option has no effect.
22357
d77de738 22358@opindex mcpu
ddf6fe37 22359@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22360This specifies the name of the target ARM processor. GCC uses this name
22361to derive the name of the target ARM architecture (as if specified
22362by @option{-march}) and the ARM processor type for which to tune for
22363performance (as if specified by @option{-mtune}). Where this option
22364is used in conjunction with @option{-march} or @option{-mtune},
22365those options take precedence over the appropriate part of this option.
22366
22367Many of the supported CPUs implement optional architectural
22368extensions. Where this is so the architectural extensions are
22369normally enabled by default. If implementations that lack the
22370extension exist, then the extension syntax can be used to disable
22371those extensions that have been omitted. For floating-point and
22372Advanced SIMD (Neon) instructions, the settings of the options
22373@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22374floating-point and Advanced SIMD instructions will only be used if
22375@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22376@option{-mfpu} other than @samp{auto} will override the available
22377floating-point and SIMD extension instructions.
22378
22379For example, @samp{cortex-a9} can be found in three major
22380configurations: integer only, with just a floating-point unit or with
22381floating-point and Advanced SIMD. The default is to enable all the
22382instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22383be used to disable just the SIMD or both the SIMD and floating-point
22384instructions respectively.
22385
22386Permissible names for this option are the same as those for
22387@option{-mtune}.
22388
22389The following extension options are common to the listed CPUs:
22390
22391@table @samp
22392@item +nodsp
ccfd1e7f
SP
22393Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
22394@samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector
22395Extension (MVE) integer and single precision floating-point instructions on
22396@samp{cortex-m55} and @samp{cortex-m85}.
22397
22398@item +nopacbti
22399Disable the Pointer Authentication and Branch Target Identification Extension
22400on @samp{cortex-m85}.
d77de738
ML
22401
22402@item +nomve
22403Disable the M-Profile Vector Extension (MVE) integer and single precision
ccfd1e7f 22404floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22405
22406@item +nomve.fp
22407Disable the M-Profile Vector Extension (MVE) single precision floating-point
ccfd1e7f 22408instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 22409
798a0d05
SP
22410@item +cdecp0, +cdecp1, ... , +cdecp7
22411Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22412to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22413
d77de738
ML
22414@item +nofp
22415Disables the floating-point instructions on @samp{arm9e},
22416@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22417@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22418@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22419@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
ccfd1e7f
SP
22420@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
22421@samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22422Disables the floating-point and SIMD instructions on
22423@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22424@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22425@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22426@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22427@samp{cortex-a53} and @samp{cortex-a55}.
22428
22429@item +nofp.dp
22430Disables the double-precision component of the floating-point instructions
22431on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22432@samp{cortex-r52plus} and @samp{cortex-m7}.
22433
22434@item +nosimd
22435Disables the SIMD (but not floating-point) instructions on
22436@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22437and @samp{cortex-a9}.
22438
22439@item +crypto
22440Enables the cryptographic instructions on @samp{cortex-a32},
22441@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22442@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22443@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22444@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22445@samp{cortex-a75.cortex-a55}.
22446@end table
22447
22448Additionally the @samp{generic-armv7-a} pseudo target defaults to
22449VFPv3 with 16 double-precision registers. It supports the following
22450extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22451@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22452@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22453@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22454the extensions to @option{-march=armv7-a}.
22455
22456@option{-mcpu=generic-@var{arch}} is also permissible, and is
22457equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22458See @option{-mtune} for more information.
22459
22460@option{-mcpu=native} causes the compiler to auto-detect the CPU
22461of the build computer. At present, this feature is only supported on
22462GNU/Linux, and not all architectures are recognized. If the auto-detect
22463is unsuccessful the option has no effect.
22464
d77de738 22465@opindex mfpu
ddf6fe37 22466@item -mfpu=@var{name}
d77de738
ML
22467This specifies what floating-point hardware (or hardware emulation) is
22468available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22469@samp{vfpv3},
22470@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22471@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22472@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22473@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22474@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22475Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22476is an alias for @samp{vfpv2}.
22477
22478The setting @samp{auto} is the default and is special. It causes the
22479compiler to select the floating-point and Advanced SIMD instructions
22480based on the settings of @option{-mcpu} and @option{-march}.
22481
22482If the selected floating-point hardware includes the NEON extension
22483(e.g.@: @option{-mfpu=neon}), note that floating-point
22484operations are not generated by GCC's auto-vectorization pass unless
22485@option{-funsafe-math-optimizations} is also specified. This is
22486because NEON hardware does not fully implement the IEEE 754 standard for
22487floating-point arithmetic (in particular denormal values are treated as
22488zero), so the use of NEON instructions may lead to a loss of precision.
22489
22490You 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}).
22491
d77de738 22492@opindex mfp16-format
ddf6fe37 22493@item -mfp16-format=@var{name}
d77de738
ML
22494Specify the format of the @code{__fp16} half-precision floating-point type.
22495Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22496the default is @samp{none}, in which case the @code{__fp16} type is not
22497defined. @xref{Half-Precision}, for more information.
22498
d77de738 22499@opindex mstructure-size-boundary
ddf6fe37 22500@item -mstructure-size-boundary=@var{n}
d77de738
ML
22501The sizes of all structures and unions are rounded up to a multiple
22502of the number of bits set by this option. Permissible values are 8, 32
22503and 64. The default value varies for different toolchains. For the COFF
22504targeted toolchain the default value is 8. A value of 64 is only allowed
22505if the underlying ABI supports it.
22506
22507Specifying a larger number can produce faster, more efficient code, but
22508can also increase the size of the program. Different values are potentially
22509incompatible. Code compiled with one value cannot necessarily expect to
22510work with code or libraries compiled with another value, if they exchange
22511information using structures or unions.
22512
22513This option is deprecated.
22514
d77de738 22515@opindex mabort-on-noreturn
ddf6fe37 22516@item -mabort-on-noreturn
d77de738
ML
22517Generate a call to the function @code{abort} at the end of a
22518@code{noreturn} function. It is executed if the function tries to
22519return.
22520
d77de738
ML
22521@opindex mlong-calls
22522@opindex mno-long-calls
ddf6fe37
AA
22523@item -mlong-calls
22524@itemx -mno-long-calls
d77de738
ML
22525Tells the compiler to perform function calls by first loading the
22526address of the function into a register and then performing a subroutine
22527call on this register. This switch is needed if the target function
22528lies outside of the 64-megabyte addressing range of the offset-based
22529version of subroutine call instruction.
22530
22531Even if this switch is enabled, not all function calls are turned
22532into long calls. The heuristic is that static functions, functions
22533that have the @code{short_call} attribute, functions that are inside
22534the scope of a @code{#pragma no_long_calls} directive, and functions whose
22535definitions have already been compiled within the current compilation
22536unit are not turned into long calls. The exceptions to this rule are
22537that weak function definitions, functions with the @code{long_call}
22538attribute or the @code{section} attribute, and functions that are within
22539the scope of a @code{#pragma long_calls} directive are always
22540turned into long calls.
22541
22542This feature is not enabled by default. Specifying
22543@option{-mno-long-calls} restores the default behavior, as does
22544placing the function calls within the scope of a @code{#pragma
22545long_calls_off} directive. Note these switches have no effect on how
22546the compiler generates code to handle function calls via function
22547pointers.
22548
d77de738 22549@opindex msingle-pic-base
ddf6fe37 22550@item -msingle-pic-base
d77de738
ML
22551Treat the register used for PIC addressing as read-only, rather than
22552loading it in the prologue for each function. The runtime system is
22553responsible for initializing this register with an appropriate value
22554before execution begins.
22555
d77de738 22556@opindex mpic-register
ddf6fe37 22557@item -mpic-register=@var{reg}
d77de738
ML
22558Specify the register to be used for PIC addressing.
22559For standard PIC base case, the default is any suitable register
22560determined by compiler. For single PIC base case, the default is
22561@samp{R9} if target is EABI based or stack-checking is enabled,
22562otherwise the default is @samp{R10}.
22563
d77de738 22564@opindex mpic-data-is-text-relative
ddf6fe37 22565@item -mpic-data-is-text-relative
d77de738
ML
22566Assume that the displacement between the text and data segments is fixed
22567at static link time. This permits using PC-relative addressing
22568operations to access data known to be in the data segment. For
22569non-VxWorks RTP targets, this option is enabled by default. When
22570disabled on such targets, it will enable @option{-msingle-pic-base} by
22571default.
22572
d77de738 22573@opindex mpoke-function-name
ddf6fe37 22574@item -mpoke-function-name
d77de738
ML
22575Write the name of each function into the text section, directly
22576preceding the function prologue. The generated code is similar to this:
22577
22578@smallexample
22579 t0
22580 .ascii "arm_poke_function_name", 0
22581 .align
22582 t1
22583 .word 0xff000000 + (t1 - t0)
22584 arm_poke_function_name
22585 mov ip, sp
22586 stmfd sp!, @{fp, ip, lr, pc@}
22587 sub fp, ip, #4
22588@end smallexample
22589
22590When performing a stack backtrace, code can inspect the value of
22591@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22592location @code{pc - 12} and the top 8 bits are set, then we know that
22593there is a function name embedded immediately preceding this location
22594and has length @code{((pc[-3]) & 0xff000000)}.
22595
d77de738
ML
22596@opindex marm
22597@opindex mthumb
ddf6fe37
AA
22598@item -mthumb
22599@itemx -marm
d77de738
ML
22600
22601Select between generating code that executes in ARM and Thumb
22602states. The default for most configurations is to generate code
22603that executes in ARM state, but the default can be changed by
22604configuring GCC with the @option{--with-mode=}@var{state}
22605configure option.
22606
22607You can also override the ARM and Thumb mode for each function
22608by using the @code{target("thumb")} and @code{target("arm")} function attributes
22609(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22610
d77de738 22611@opindex mflip-thumb
ddf6fe37 22612@item -mflip-thumb
d77de738
ML
22613Switch ARM/Thumb modes on alternating functions.
22614This option is provided for regression testing of mixed Thumb/ARM code
22615generation, and is not intended for ordinary use in compiling code.
22616
d77de738 22617@opindex mtpcs-frame
ddf6fe37 22618@item -mtpcs-frame
d77de738
ML
22619Generate a stack frame that is compliant with the Thumb Procedure Call
22620Standard for all non-leaf functions. (A leaf function is one that does
22621not call any other functions.) The default is @option{-mno-tpcs-frame}.
22622
d77de738 22623@opindex mtpcs-leaf-frame
ddf6fe37 22624@item -mtpcs-leaf-frame
d77de738
ML
22625Generate a stack frame that is compliant with the Thumb Procedure Call
22626Standard for all leaf functions. (A leaf function is one that does
22627not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22628
d77de738 22629@opindex mcallee-super-interworking
ddf6fe37 22630@item -mcallee-super-interworking
d77de738
ML
22631Gives all externally visible functions in the file being compiled an ARM
22632instruction set header which switches to Thumb mode before executing the
22633rest of the function. This allows these functions to be called from
22634non-interworking code. This option is not valid in AAPCS configurations
22635because interworking is enabled by default.
22636
d77de738 22637@opindex mcaller-super-interworking
ddf6fe37 22638@item -mcaller-super-interworking
d77de738
ML
22639Allows calls via function pointers (including virtual functions) to
22640execute correctly regardless of whether the target code has been
22641compiled for interworking or not. There is a small overhead in the cost
22642of executing a function pointer if this option is enabled. This option
22643is not valid in AAPCS configurations because interworking is enabled
22644by default.
22645
d77de738 22646@opindex mtp
ddf6fe37 22647@item -mtp=@var{name}
d77de738
ML
22648Specify the access model for the thread local storage pointer. The valid
22649models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
22650@samp{cp15}, which fetches the thread pointer from @code{cp15} directly
22651(supported in the arm6k architecture), and @samp{auto}, which uses the
22652best available method for the selected processor. The default setting is
22653@samp{auto}.
22654
d77de738 22655@opindex mtls-dialect
ddf6fe37 22656@item -mtls-dialect=@var{dialect}
d77de738
ML
22657Specify the dialect to use for accessing thread local storage. Two
22658@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22659@samp{gnu} dialect selects the original GNU scheme for supporting
22660local and global dynamic TLS models. The @samp{gnu2} dialect
22661selects the GNU descriptor scheme, which provides better performance
22662for shared libraries. The GNU descriptor scheme is compatible with
22663the original scheme, but does require new assembler, linker and
22664library support. Initial and local exec TLS models are unaffected by
22665this option and always use the original scheme.
22666
d77de738 22667@opindex mword-relocations
ddf6fe37 22668@item -mword-relocations
d77de738
ML
22669Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22670This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22671loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22672is specified. This option conflicts with @option{-mslow-flash-data}.
22673
d77de738 22674@opindex mfix-cortex-m3-ldrd
ddf6fe37 22675@item -mfix-cortex-m3-ldrd
d77de738
ML
22676Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22677with overlapping destination and base registers are used. This option avoids
22678generating these instructions. This option is enabled by default when
22679@option{-mcpu=cortex-m3} is specified.
22680
22681@item -mfix-cortex-a57-aes-1742098
22682@itemx -mno-fix-cortex-a57-aes-1742098
22683@itemx -mfix-cortex-a72-aes-1655431
22684@itemx -mno-fix-cortex-a72-aes-1655431
22685Enable (disable) mitigation for an erratum on Cortex-A57 and
22686Cortex-A72 that affects the AES cryptographic instructions. This
22687option is enabled by default when either @option{-mcpu=cortex-a57} or
22688@option{-mcpu=cortex-a72} is specified.
22689
d77de738
ML
22690@opindex munaligned-access
22691@opindex mno-unaligned-access
ddf6fe37
AA
22692@item -munaligned-access
22693@itemx -mno-unaligned-access
d77de738
ML
22694Enables (or disables) reading and writing of 16- and 32- bit values
22695from addresses that are not 16- or 32- bit aligned. By default
22696unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22697ARMv8-M Baseline architectures, and enabled for all other
22698architectures. If unaligned access is not enabled then words in packed
22699data structures are accessed a byte at a time.
22700
22701The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22702generated object file to either true or false, depending upon the
22703setting of this option. If unaligned access is enabled then the
22704preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22705defined.
22706
d77de738 22707@opindex mneon-for-64bits
ddf6fe37 22708@item -mneon-for-64bits
d77de738
ML
22709This option is deprecated and has no effect.
22710
d77de738 22711@opindex mslow-flash-data
ddf6fe37 22712@item -mslow-flash-data
d77de738
ML
22713Assume loading data from flash is slower than fetching instruction.
22714Therefore literal load is minimized for better performance.
22715This option is only supported when compiling for ARMv7 M-profile and
22716off by default. It conflicts with @option{-mword-relocations}.
22717
d77de738 22718@opindex masm-syntax-unified
ddf6fe37 22719@item -masm-syntax-unified
d77de738
ML
22720Assume inline assembler is using unified asm syntax. The default is
22721currently off which implies divided syntax. This option has no impact
22722on Thumb2. However, this may change in future releases of GCC.
22723Divided syntax should be considered deprecated.
22724
d77de738 22725@opindex mrestrict-it
ddf6fe37 22726@item -mrestrict-it
d77de738
ML
22727Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22728IT blocks can only contain a single 16-bit instruction from a select
22729set of instructions. This option is on by default for ARMv8-A Thumb mode.
22730
d77de738 22731@opindex mprint-tune-info
ddf6fe37 22732@item -mprint-tune-info
d77de738
ML
22733Print CPU tuning information as comment in assembler file. This is
22734an option used only for regression testing of the compiler and not
22735intended for ordinary use in compiling code. This option is disabled
22736by default.
22737
d77de738 22738@opindex mverbose-cost-dump
ddf6fe37 22739@item -mverbose-cost-dump
d77de738
ML
22740Enable verbose cost model dumping in the debug dump files. This option is
22741provided for use in debugging the compiler.
22742
d77de738 22743@opindex mpure-code
ddf6fe37 22744@item -mpure-code
d77de738
ML
22745Do not allow constant data to be placed in code sections.
22746Additionally, when compiling for ELF object format give all text sections the
22747ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22748is only available when generating non-pic code for M-profile targets.
22749
d77de738 22750@opindex mcmse
ddf6fe37 22751@item -mcmse
d77de738
ML
22752Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22753Development Tools Engineering Specification", which can be found on
22754@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22755
d77de738 22756@opindex mfix-cmse-cve-2021-35465
ddf6fe37 22757@item -mfix-cmse-cve-2021-35465
d77de738
ML
22758Mitigate against a potential security issue with the @code{VLLDM} instruction
22759in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22760enabled by default when the option @option{-mcpu=} is used with
ccfd1e7f
SP
22761@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85}
22762or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used
22763to disable the mitigation.
d77de738 22764
d77de738
ML
22765@opindex mstack-protector-guard
22766@opindex mstack-protector-guard-offset
ddf6fe37
AA
22767@item -mstack-protector-guard=@var{guard}
22768@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
22769Generate stack protection code using canary at @var{guard}. Supported
22770locations are @samp{global} for a global canary or @samp{tls} for a
22771canary accessible via the TLS register. The option
22772@option{-mstack-protector-guard-offset=} is for use with
22773@option{-fstack-protector-guard=tls} and not for use in user-land code.
22774
d77de738
ML
22775@opindex mfdpic
22776@opindex mno-fdpic
ddf6fe37
AA
22777@item -mfdpic
22778@itemx -mno-fdpic
d77de738
ML
22779Select the FDPIC ABI, which uses 64-bit function descriptors to
22780represent pointers to functions. When the compiler is configured for
22781@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
22782and implies @option{-fPIE} if none of the PIC/PIE-related options is
22783provided. On other targets, it only enables the FDPIC-specific code
22784generation features, and the user should explicitly provide the
22785PIC/PIE-related options as needed.
22786
22787Note that static linking is not supported because it would still
22788involve the dynamic linker when the program self-relocates. If such
22789behavior is acceptable, use -static and -Wl,-dynamic-linker options.
22790
22791The opposite @option{-mno-fdpic} option is useful (and required) to
22792build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
22793toolchain as the one used to build the userland programs.
22794
14fab5fb 22795@opindex mbranch-protection
ddf6fe37 22796@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
22797Enable branch protection features (armv8.1-m.main only).
22798@samp{none} generate code without branch protection or return address
22799signing.
22800@samp{standard[+@var{leaf}]} generate code with all branch protection
22801features enabled at their standard level.
22802@samp{pac-ret[+@var{leaf}]} generate code with return address signing
22803set to its standard level, which is to sign all functions that save
22804the return address to memory.
22805@samp{leaf} When return address signing is enabled, also sign leaf
22806functions even if they do not write the return address to memory.
22807+@samp{bti} Add landing-pad instructions at the permitted targets of
22808indirect branch instructions.
22809
22810If the @samp{+pacbti} architecture extension is not enabled, then all
22811branch protection and return address signing operations are
22812constrained to use only the instructions defined in the
22813architectural-NOP space. The generated code will remain
22814backwards-compatible with earlier versions of the architecture, but
22815the additional security can be enabled at run time on processors that
22816support the @samp{PACBTI} extension.
22817
22818Branch target enforcement using BTI can only be enabled at runtime if
22819all code in the application has been compiled with at least
22820@samp{-mbranch-protection=bti}.
22821
22822Any setting other than @samp{none} is supported only on armv8-m.main
22823or later.
22824
22825The default is to generate code without branch protection or return
22826address signing.
22827
d77de738
ML
22828@end table
22829
22830@node AVR Options
22831@subsection AVR Options
22832@cindex AVR Options
22833
22834These options are defined for AVR implementations:
22835
22836@table @gcctabopt
d77de738 22837@opindex mmcu
ddf6fe37 22838@item -mmcu=@var{mcu}
d77de738
ML
22839Specify Atmel AVR instruction set architectures (ISA) or MCU type.
22840
22841The default for this option is@tie{}@samp{avr2}.
22842
22843GCC supports the following AVR devices and ISAs:
22844
22845@include avr-mmcu.texi
22846
d77de738 22847@opindex mabsdata
ddf6fe37 22848@item -mabsdata
d77de738
ML
22849
22850Assume that all data in static storage can be accessed by LDS / STS
22851instructions. This option has only an effect on reduced Tiny devices like
22852ATtiny40. See also the @code{absdata}
22853@ref{AVR Variable Attributes,variable attribute}.
22854
d77de738 22855@opindex maccumulate-args
ddf6fe37 22856@item -maccumulate-args
d77de738
ML
22857Accumulate outgoing function arguments and acquire/release the needed
22858stack space for outgoing function arguments once in function
22859prologue/epilogue. Without this option, outgoing arguments are pushed
22860before calling a function and popped afterwards.
22861
22862Popping the arguments after the function call can be expensive on
22863AVR so that accumulating the stack space might lead to smaller
22864executables because arguments need not be removed from the
22865stack after such a function call.
22866
22867This option can lead to reduced code size for functions that perform
22868several calls to functions that get their arguments on the stack like
22869calls to printf-like functions.
22870
d77de738 22871@opindex mbranch-cost
ddf6fe37 22872@item -mbranch-cost=@var{cost}
d77de738
ML
22873Set the branch costs for conditional branch instructions to
22874@var{cost}. Reasonable values for @var{cost} are small, non-negative
22875integers. The default branch cost is 0.
22876
d77de738 22877@opindex mcall-prologues
ddf6fe37 22878@item -mcall-prologues
d77de738
ML
22879Functions prologues/epilogues are expanded as calls to appropriate
22880subroutines. Code size is smaller.
22881
d77de738
ML
22882@opindex mdouble
22883@opindex mlong-double
ddf6fe37
AA
22884@item -mdouble=@var{bits}
22885@itemx -mlong-double=@var{bits}
d77de738
ML
22886Set the size (in bits) of the @code{double} or @code{long double} type,
22887respectively. Possible values for @var{bits} are 32 and 64.
22888Whether or not a specific value for @var{bits} is allowed depends on
22889the @code{--with-double=} and @code{--with-long-double=}
22890@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
22891and the same applies for the default values of the options.
22892
d77de738 22893@opindex mgas-isr-prologues
ddf6fe37 22894@item -mgas-isr-prologues
d77de738
ML
22895Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
22896instruction supported by GNU Binutils.
22897If this option is on, the feature can still be disabled for individual
22898ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
22899function attribute. This feature is activated per default
22900if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
22901and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
22902
d77de738 22903@opindex mint8
ddf6fe37 22904@item -mint8
d77de738
ML
22905Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
22906@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
22907and @code{long long} is 4 bytes. Please note that this option does not
22908conform to the C standards, but it results in smaller code
22909size.
22910
d77de738 22911@opindex mmain-is-OS_task
ddf6fe37 22912@item -mmain-is-OS_task
d77de738
ML
22913Do not save registers in @code{main}. The effect is the same like
22914attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
22915to @code{main}. It is activated per default if optimization is on.
22916
d77de738 22917@opindex mn-flash
ddf6fe37 22918@item -mn-flash=@var{num}
d77de738
ML
22919Assume that the flash memory has a size of
22920@var{num} times 64@tie{}KiB.
22921
d77de738 22922@opindex mno-interrupts
ddf6fe37 22923@item -mno-interrupts
d77de738
ML
22924Generated code is not compatible with hardware interrupts.
22925Code size is smaller.
22926
d77de738 22927@opindex mrelax
ddf6fe37 22928@item -mrelax
d77de738
ML
22929Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
22930@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
22931Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
22932the assembler's command line and the @option{--relax} option to the
22933linker's command line.
22934
22935Jump relaxing is performed by the linker because jump offsets are not
22936known before code is located. Therefore, the assembler code generated by the
22937compiler is the same, but the instructions in the executable may
22938differ from instructions in the assembler code.
22939
22940Relaxing must be turned on if linker stubs are needed, see the
22941section on @code{EIND} and linker stubs below.
22942
d77de738 22943@opindex mrmw
ddf6fe37 22944@item -mrmw
d77de738
ML
22945Assume that the device supports the Read-Modify-Write
22946instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
22947
d77de738 22948@opindex mshort-calls
ddf6fe37 22949@item -mshort-calls
d77de738
ML
22950
22951Assume that @code{RJMP} and @code{RCALL} can target the whole
22952program memory.
22953
22954This option is used internally for multilib selection. It is
22955not an optimization option, and you don't need to set it by hand.
22956
d77de738 22957@opindex msp8
ddf6fe37 22958@item -msp8
d77de738
ML
22959Treat the stack pointer register as an 8-bit register,
22960i.e.@: assume the high byte of the stack pointer is zero.
22961In general, you don't need to set this option by hand.
22962
22963This option is used internally by the compiler to select and
22964build multilibs for architectures @code{avr2} and @code{avr25}.
22965These architectures mix devices with and without @code{SPH}.
22966For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
22967the compiler driver adds or removes this option from the compiler
22968proper's command line, because the compiler then knows if the device
22969or architecture has an 8-bit stack pointer and thus no @code{SPH}
22970register or not.
22971
d77de738 22972@opindex mstrict-X
ddf6fe37 22973@item -mstrict-X
d77de738
ML
22974Use address register @code{X} in a way proposed by the hardware. This means
22975that @code{X} is only used in indirect, post-increment or
22976pre-decrement addressing.
22977
22978Without this option, the @code{X} register may be used in the same way
22979as @code{Y} or @code{Z} which then is emulated by additional
22980instructions.
22981For example, loading a value with @code{X+const} addressing with a
22982small non-negative @code{const < 64} to a register @var{Rn} is
22983performed as
22984
22985@example
22986adiw r26, const ; X += const
22987ld @var{Rn}, X ; @var{Rn} = *X
22988sbiw r26, const ; X -= const
22989@end example
22990
d77de738 22991@opindex mtiny-stack
ddf6fe37 22992@item -mtiny-stack
d77de738
ML
22993Only change the lower 8@tie{}bits of the stack pointer.
22994
d77de738 22995@opindex mfract-convert-truncate
ddf6fe37 22996@item -mfract-convert-truncate
d77de738
ML
22997Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
22998
d77de738 22999@opindex nodevicelib
ddf6fe37 23000@item -nodevicelib
d77de738
ML
23001Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
23002
d77de738 23003@opindex nodevicespecs
ddf6fe37 23004@item -nodevicespecs
d77de738
ML
23005Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
23006command line. The user takes responsibility for supplying the sub-processes
23007like compiler proper, assembler and linker with appropriate command line
23008options. This means that the user has to supply her private device specs
23009file by means of @option{-specs=@var{path-to-specs-file}}. There is no
23010more need for option @option{-mmcu=@var{mcu}}.
23011
23012This option can also serve as a replacement for the older way of
23013specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
23014which contains a folder named @code{device-specs} which contains a specs file named
23015@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
23016
d77de738
ML
23017@opindex Waddr-space-convert
23018@opindex Wno-addr-space-convert
ddf6fe37 23019@item -Waddr-space-convert
d77de738
ML
23020Warn about conversions between address spaces in the case where the
23021resulting address space is not contained in the incoming address space.
23022
d77de738
ML
23023@opindex Wmisspelled-isr
23024@opindex Wno-misspelled-isr
ddf6fe37 23025@item -Wmisspelled-isr
d77de738
ML
23026Warn if the ISR is misspelled, i.e.@: without __vector prefix.
23027Enabled by default.
23028@end table
23029
23030@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
23031@cindex @code{EIND}
23032Pointers in the implementation are 16@tie{}bits wide.
23033The address of a function or label is represented as word address so
23034that indirect jumps and calls can target any code address in the
23035range of 64@tie{}Ki words.
23036
23037In order to facilitate indirect jump on devices with more than 128@tie{}Ki
23038bytes of program memory space, there is a special function register called
23039@code{EIND} that serves as most significant part of the target address
23040when @code{EICALL} or @code{EIJMP} instructions are used.
23041
23042Indirect jumps and calls on these devices are handled as follows by
23043the compiler and are subject to some limitations:
23044
23045@itemize @bullet
23046
23047@item
23048The compiler never sets @code{EIND}.
23049
23050@item
23051The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
23052instructions or might read @code{EIND} directly in order to emulate an
23053indirect call/jump by means of a @code{RET} instruction.
23054
23055@item
23056The compiler assumes that @code{EIND} never changes during the startup
23057code or during the application. In particular, @code{EIND} is not
23058saved/restored in function or interrupt service routine
23059prologue/epilogue.
23060
23061@item
23062For indirect calls to functions and computed goto, the linker
23063generates @emph{stubs}. Stubs are jump pads sometimes also called
23064@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
23065The stub contains a direct jump to the desired address.
23066
23067@item
23068Linker relaxation must be turned on so that the linker generates
23069the stubs correctly in all situations. See the compiler option
23070@option{-mrelax} and the linker option @option{--relax}.
23071There are corner cases where the linker is supposed to generate stubs
23072but aborts without relaxation and without a helpful error message.
23073
23074@item
23075The default linker script is arranged for code with @code{EIND = 0}.
23076If code is supposed to work for a setup with @code{EIND != 0}, a custom
23077linker script has to be used in order to place the sections whose
23078name start with @code{.trampolines} into the segment where @code{EIND}
23079points to.
23080
23081@item
23082The startup code from libgcc never sets @code{EIND}.
23083Notice that startup code is a blend of code from libgcc and AVR-LibC.
23084For the impact of AVR-LibC on @code{EIND}, see the
a65da9be 23085@w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
d77de738
ML
23086
23087@item
23088It is legitimate for user-specific startup code to set up @code{EIND}
23089early, for example by means of initialization code located in
23090section @code{.init3}. Such code runs prior to general startup code
23091that initializes RAM and calls constructors, but after the bit
23092of startup code from AVR-LibC that sets @code{EIND} to the segment
23093where the vector table is located.
23094@example
23095#include <avr/io.h>
23096
23097static void
23098__attribute__((section(".init3"),naked,used,no_instrument_function))
23099init3_set_eind (void)
23100@{
23101 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
23102 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
23103@}
23104@end example
23105
23106@noindent
23107The @code{__trampolines_start} symbol is defined in the linker script.
23108
23109@item
23110Stubs are generated automatically by the linker if
23111the following two conditions are met:
23112@itemize @minus
23113
23114@item The address of a label is taken by means of the @code{gs} modifier
23115(short for @emph{generate stubs}) like so:
23116@example
23117LDI r24, lo8(gs(@var{func}))
23118LDI r25, hi8(gs(@var{func}))
23119@end example
23120@item The final location of that label is in a code segment
23121@emph{outside} the segment where the stubs are located.
23122@end itemize
23123
23124@item
23125The compiler emits such @code{gs} modifiers for code labels in the
23126following situations:
23127@itemize @minus
23128@item Taking address of a function or code label.
23129@item Computed goto.
23130@item If prologue-save function is used, see @option{-mcall-prologues}
23131command-line option.
23132@item Switch/case dispatch tables. If you do not want such dispatch
23133tables you can specify the @option{-fno-jump-tables} command-line option.
23134@item C and C++ constructors/destructors called during startup/shutdown.
23135@item If the tools hit a @code{gs()} modifier explained above.
23136@end itemize
23137
23138@item
23139Jumping to non-symbolic addresses like so is @emph{not} supported:
23140
23141@example
23142int main (void)
23143@{
23144 /* Call function at word address 0x2 */
23145 return ((int(*)(void)) 0x2)();
23146@}
23147@end example
23148
23149Instead, a stub has to be set up, i.e.@: the function has to be called
23150through a symbol (@code{func_4} in the example):
23151
23152@example
23153int main (void)
23154@{
23155 extern int func_4 (void);
23156
23157 /* Call function at byte address 0x4 */
23158 return func_4();
23159@}
23160@end example
23161
23162and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
23163Alternatively, @code{func_4} can be defined in the linker script.
23164@end itemize
23165
23166@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
23167@cindex @code{RAMPD}
23168@cindex @code{RAMPX}
23169@cindex @code{RAMPY}
23170@cindex @code{RAMPZ}
23171Some AVR devices support memories larger than the 64@tie{}KiB range
23172that can be accessed with 16-bit pointers. To access memory locations
23173outside this 64@tie{}KiB range, the content of a @code{RAMP}
23174register is used as high part of the address:
23175The @code{X}, @code{Y}, @code{Z} address register is concatenated
23176with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
23177register, respectively, to get a wide address. Similarly,
23178@code{RAMPD} is used together with direct addressing.
23179
23180@itemize
23181@item
23182The startup code initializes the @code{RAMP} special function
23183registers with zero.
23184
23185@item
23186If a @ref{AVR Named Address Spaces,named address space} other than
23187generic or @code{__flash} is used, then @code{RAMPZ} is set
23188as needed before the operation.
23189
23190@item
23191If the device supports RAM larger than 64@tie{}KiB and the compiler
23192needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
23193is reset to zero after the operation.
23194
23195@item
23196If the device comes with a specific @code{RAMP} register, the ISR
23197prologue/epilogue saves/restores that SFR and initializes it with
23198zero in case the ISR code might (implicitly) use it.
23199
23200@item
23201RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
23202If you use inline assembler to read from locations outside the
2320316-bit address range and change one of the @code{RAMP} registers,
23204you must reset it to zero after the access.
23205
23206@end itemize
23207
23208@subsubsection AVR Built-in Macros
23209
23210GCC defines several built-in macros so that the user code can test
23211for the presence or absence of features. Almost any of the following
23212built-in macros are deduced from device capabilities and thus
23213triggered by the @option{-mmcu=} command-line option.
23214
23215For even more AVR-specific built-in macros see
23216@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
23217
23218@table @code
23219
23220@item __AVR_ARCH__
23221Build-in macro that resolves to a decimal number that identifies the
23222architecture and depends on the @option{-mmcu=@var{mcu}} option.
23223Possible values are:
23224
23225@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
23226@code{4}, @code{5}, @code{51}, @code{6}
23227
23228for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
23229@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
23230
23231respectively and
23232
23233@code{100},
23234@code{102}, @code{103}, @code{104},
23235@code{105}, @code{106}, @code{107}
23236
23237for @var{mcu}=@code{avrtiny},
23238@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
23239@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
23240If @var{mcu} specifies a device, this built-in macro is set
23241accordingly. For example, with @option{-mmcu=atmega8} the macro is
23242defined to @code{4}.
23243
23244@item __AVR_@var{Device}__
23245Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
23246the device's name. For example, @option{-mmcu=atmega8} defines the
23247built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
23248@code{__AVR_ATtiny261A__}, etc.
23249
23250The built-in macros' names follow
23251the scheme @code{__AVR_@var{Device}__} where @var{Device} is
23252the device name as from the AVR user manual. The difference between
23253@var{Device} in the built-in macro and @var{device} in
23254@option{-mmcu=@var{device}} is that the latter is always lowercase.
23255
23256If @var{device} is not a device but only a core architecture like
23257@samp{avr51}, this macro is not defined.
23258
23259@item __AVR_DEVICE_NAME__
23260Setting @option{-mmcu=@var{device}} defines this built-in macro to
23261the device's name. For example, with @option{-mmcu=atmega8} the macro
23262is defined to @code{atmega8}.
23263
23264If @var{device} is not a device but only a core architecture like
23265@samp{avr51}, this macro is not defined.
23266
23267@item __AVR_XMEGA__
23268The device / architecture belongs to the XMEGA family of devices.
23269
23270@item __AVR_HAVE_ELPM__
23271The device has the @code{ELPM} instruction.
23272
23273@item __AVR_HAVE_ELPMX__
23274The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23275R@var{n},Z+} instructions.
23276
23277@item __AVR_HAVE_MOVW__
23278The device has the @code{MOVW} instruction to perform 16-bit
23279register-register moves.
23280
23281@item __AVR_HAVE_LPMX__
23282The device has the @code{LPM R@var{n},Z} and
23283@code{LPM R@var{n},Z+} instructions.
23284
23285@item __AVR_HAVE_MUL__
23286The device has a hardware multiplier.
23287
23288@item __AVR_HAVE_JMP_CALL__
23289The device has the @code{JMP} and @code{CALL} instructions.
23290This is the case for devices with more than 8@tie{}KiB of program
23291memory.
23292
23293@item __AVR_HAVE_EIJMP_EICALL__
23294@itemx __AVR_3_BYTE_PC__
23295The device has the @code{EIJMP} and @code{EICALL} instructions.
23296This is the case for devices with more than 128@tie{}KiB of program memory.
23297This also means that the program counter
23298(PC) is 3@tie{}bytes wide.
23299
23300@item __AVR_2_BYTE_PC__
23301The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23302with up to 128@tie{}KiB of program memory.
23303
23304@item __AVR_HAVE_8BIT_SP__
23305@itemx __AVR_HAVE_16BIT_SP__
23306The stack pointer (SP) register is treated as 8-bit respectively
2330716-bit register by the compiler.
23308The definition of these macros is affected by @option{-mtiny-stack}.
23309
23310@item __AVR_HAVE_SPH__
23311@itemx __AVR_SP8__
23312The device has the SPH (high part of stack pointer) special function
23313register or has an 8-bit stack pointer, respectively.
23314The definition of these macros is affected by @option{-mmcu=} and
23315in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23316by @option{-msp8}.
23317
23318@item __AVR_HAVE_RAMPD__
23319@itemx __AVR_HAVE_RAMPX__
23320@itemx __AVR_HAVE_RAMPY__
23321@itemx __AVR_HAVE_RAMPZ__
23322The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23323@code{RAMPZ} special function register, respectively.
23324
23325@item __NO_INTERRUPTS__
23326This macro reflects the @option{-mno-interrupts} command-line option.
23327
23328@item __AVR_ERRATA_SKIP__
23329@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23330Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23331instructions because of a hardware erratum. Skip instructions are
23332@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23333The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23334set.
23335
23336@item __AVR_ISA_RMW__
23337The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23338
23339@item __AVR_SFR_OFFSET__=@var{offset}
23340Instructions that can address I/O special function registers directly
23341like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23342address as if addressed by an instruction to access RAM like @code{LD}
23343or @code{STS}. This offset depends on the device architecture and has
23344to be subtracted from the RAM address in order to get the
23345respective I/O@tie{}address.
23346
23347@item __AVR_SHORT_CALLS__
23348The @option{-mshort-calls} command line option is set.
23349
23350@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23351Some devices support reading from flash memory by means of @code{LD*}
23352instructions. The flash memory is seen in the data address space
23353at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23354is not defined, this feature is not available. If defined,
23355the address space is linear and there is no need to put
23356@code{.rodata} into RAM. This is handled by the default linker
23357description file, and is currently available for
23358@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23359there is no need to use address spaces like @code{__flash} or
23360features like attribute @code{progmem} and @code{pgm_read_*}.
23361
23362@item __WITH_AVRLIBC__
23363The compiler is configured to be used together with AVR-Libc.
23364See the @option{--with-avrlibc} configure option.
23365
23366@item __HAVE_DOUBLE_MULTILIB__
23367Defined if @option{-mdouble=} acts as a multilib option.
23368
23369@item __HAVE_DOUBLE32__
23370@itemx __HAVE_DOUBLE64__
23371Defined if the compiler supports 32-bit double resp. 64-bit double.
23372The actual layout is specified by option @option{-mdouble=}.
23373
23374@item __DEFAULT_DOUBLE__
23375The size in bits of @code{double} if @option{-mdouble=} is not set.
23376To test the layout of @code{double} in a program, use the built-in
23377macro @code{__SIZEOF_DOUBLE__}.
23378
23379@item __HAVE_LONG_DOUBLE32__
23380@itemx __HAVE_LONG_DOUBLE64__
23381@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23382@itemx __DEFAULT_LONG_DOUBLE__
23383Same as above, but for @code{long double} instead of @code{double}.
23384
23385@item __WITH_DOUBLE_COMPARISON__
23386Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23387@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23388and is defined to @code{2} or @code{3}.
23389
23390@item __WITH_LIBF7_LIBGCC__
23391@itemx __WITH_LIBF7_MATH__
23392@itemx __WITH_LIBF7_MATH_SYMBOLS__
23393Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23394@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23395
23396@end table
23397
23398@node Blackfin Options
23399@subsection Blackfin Options
23400@cindex Blackfin Options
23401
23402@table @gcctabopt
d77de738 23403@opindex mcpu=
ddf6fe37 23404@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
d77de738
ML
23405Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23406can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23407@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23408@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23409@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23410@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23411@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23412@samp{bf561}, @samp{bf592}.
23413
23414The optional @var{sirevision} specifies the silicon revision of the target
23415Blackfin processor. Any workarounds available for the targeted silicon revision
23416are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23417If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23418are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23419hexadecimal digits representing the major and minor numbers in the silicon
23420revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23421is not defined. If @var{sirevision} is @samp{any}, the
23422@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23423If this optional @var{sirevision} is not used, GCC assumes the latest known
23424silicon revision of the targeted Blackfin processor.
23425
23426GCC defines a preprocessor macro for the specified @var{cpu}.
23427For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23428provided by libgloss to be linked in if @option{-msim} is not given.
23429
23430Without this option, @samp{bf532} is used as the processor by default.
23431
23432Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23433only the preprocessor macro is defined.
23434
d77de738 23435@opindex msim
ddf6fe37 23436@item -msim
d77de738
ML
23437Specifies that the program will be run on the simulator. This causes
23438the simulator BSP provided by libgloss to be linked in. This option
23439has effect only for @samp{bfin-elf} toolchain.
23440Certain other options, such as @option{-mid-shared-library} and
23441@option{-mfdpic}, imply @option{-msim}.
23442
d77de738 23443@opindex momit-leaf-frame-pointer
ddf6fe37 23444@item -momit-leaf-frame-pointer
d77de738
ML
23445Don't keep the frame pointer in a register for leaf functions. This
23446avoids the instructions to save, set up and restore frame pointers and
23447makes an extra register available in leaf functions.
23448
d77de738 23449@opindex mspecld-anomaly
ddf6fe37 23450@item -mspecld-anomaly
d77de738
ML
23451When enabled, the compiler ensures that the generated code does not
23452contain speculative loads after jump instructions. If this option is used,
23453@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23454
d77de738
ML
23455@opindex mno-specld-anomaly
23456@opindex mspecld-anomaly
ddf6fe37 23457@item -mno-specld-anomaly
d77de738
ML
23458Don't generate extra code to prevent speculative loads from occurring.
23459
d77de738 23460@opindex mcsync-anomaly
ddf6fe37 23461@item -mcsync-anomaly
d77de738
ML
23462When enabled, the compiler ensures that the generated code does not
23463contain CSYNC or SSYNC instructions too soon after conditional branches.
23464If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23465
d77de738
ML
23466@opindex mno-csync-anomaly
23467@opindex mcsync-anomaly
ddf6fe37 23468@item -mno-csync-anomaly
d77de738
ML
23469Don't generate extra code to prevent CSYNC or SSYNC instructions from
23470occurring too soon after a conditional branch.
23471
d77de738 23472@opindex mlow64k
ddf6fe37 23473@item -mlow64k
d77de738
ML
23474When enabled, the compiler is free to take advantage of the knowledge that
23475the entire program fits into the low 64k of memory.
23476
d77de738 23477@opindex mno-low64k
ddf6fe37 23478@item -mno-low64k
d77de738
ML
23479Assume that the program is arbitrarily large. This is the default.
23480
d77de738 23481@opindex mstack-check-l1
ddf6fe37 23482@item -mstack-check-l1
d77de738
ML
23483Do stack checking using information placed into L1 scratchpad memory by the
23484uClinux kernel.
23485
d77de738 23486@opindex mid-shared-library
ddf6fe37 23487@item -mid-shared-library
d77de738
ML
23488Generate code that supports shared libraries via the library ID method.
23489This allows for execute in place and shared libraries in an environment
23490without virtual memory management. This option implies @option{-fPIC}.
23491With a @samp{bfin-elf} target, this option implies @option{-msim}.
23492
d77de738
ML
23493@opindex mno-id-shared-library
23494@opindex mid-shared-library
ddf6fe37 23495@item -mno-id-shared-library
d77de738
ML
23496Generate code that doesn't assume ID-based shared libraries are being used.
23497This is the default.
23498
d77de738 23499@opindex mleaf-id-shared-library
ddf6fe37 23500@item -mleaf-id-shared-library
d77de738
ML
23501Generate code that supports shared libraries via the library ID method,
23502but assumes that this library or executable won't link against any other
23503ID shared libraries. That allows the compiler to use faster code for jumps
23504and calls.
23505
d77de738
ML
23506@opindex mno-leaf-id-shared-library
23507@opindex mleaf-id-shared-library
ddf6fe37 23508@item -mno-leaf-id-shared-library
d77de738
ML
23509Do not assume that the code being compiled won't link against any ID shared
23510libraries. Slower code is generated for jump and call insns.
23511
d77de738 23512@opindex mshared-library-id
ddf6fe37 23513@item -mshared-library-id=n
d77de738
ML
23514Specifies the identification number of the ID-based shared library being
23515compiled. Specifying a value of 0 generates more compact code; specifying
23516other values forces the allocation of that number to the current
23517library but is no more space- or time-efficient than omitting this option.
23518
d77de738 23519@opindex msep-data
ddf6fe37 23520@item -msep-data
d77de738
ML
23521Generate code that allows the data segment to be located in a different
23522area of memory from the text segment. This allows for execute in place in
23523an environment without virtual memory management by eliminating relocations
23524against the text section.
23525
d77de738
ML
23526@opindex mno-sep-data
23527@opindex msep-data
ddf6fe37 23528@item -mno-sep-data
d77de738
ML
23529Generate code that assumes that the data segment follows the text segment.
23530This is the default.
23531
d77de738
ML
23532@opindex mlong-calls
23533@opindex mno-long-calls
ddf6fe37
AA
23534@item -mlong-calls
23535@itemx -mno-long-calls
d77de738
ML
23536Tells the compiler to perform function calls by first loading the
23537address of the function into a register and then performing a subroutine
23538call on this register. This switch is needed if the target function
23539lies outside of the 24-bit addressing range of the offset-based
23540version of subroutine call instruction.
23541
23542This feature is not enabled by default. Specifying
23543@option{-mno-long-calls} restores the default behavior. Note these
23544switches have no effect on how the compiler generates code to handle
23545function calls via function pointers.
23546
d77de738 23547@opindex mfast-fp
ddf6fe37 23548@item -mfast-fp
d77de738
ML
23549Link with the fast floating-point library. This library relaxes some of
23550the IEEE floating-point standard's rules for checking inputs against
23551Not-a-Number (NAN), in the interest of performance.
23552
d77de738 23553@opindex minline-plt
ddf6fe37 23554@item -minline-plt
d77de738
ML
23555Enable inlining of PLT entries in function calls to functions that are
23556not known to bind locally. It has no effect without @option{-mfdpic}.
23557
d77de738 23558@opindex mmulticore
ddf6fe37 23559@item -mmulticore
d77de738
ML
23560Build a standalone application for multicore Blackfin processors.
23561This option causes proper start files and link scripts supporting
23562multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23563It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23564
23565This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23566selects the one-application-per-core programming model. Without
23567@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23568programming model is used. In this model, the main function of Core B
23569should be named as @code{coreb_main}.
23570
23571If this option is not used, the single-core application programming
23572model is used.
23573
d77de738 23574@opindex mcorea
ddf6fe37 23575@item -mcorea
d77de738
ML
23576Build a standalone application for Core A of BF561 when using
23577the one-application-per-core programming model. Proper start files
23578and link scripts are used to support Core A, and the macro
23579@code{__BFIN_COREA} is defined.
23580This option can only be used in conjunction with @option{-mmulticore}.
23581
d77de738 23582@opindex mcoreb
ddf6fe37 23583@item -mcoreb
d77de738
ML
23584Build a standalone application for Core B of BF561 when using
23585the one-application-per-core programming model. Proper start files
23586and link scripts are used to support Core B, and the macro
23587@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23588should be used instead of @code{main}.
23589This option can only be used in conjunction with @option{-mmulticore}.
23590
d77de738 23591@opindex msdram
ddf6fe37 23592@item -msdram
d77de738
ML
23593Build a standalone application for SDRAM. Proper start files and
23594link scripts are used to put the application into SDRAM, and the macro
23595@code{__BFIN_SDRAM} is defined.
23596The loader should initialize SDRAM before loading the application.
23597
d77de738 23598@opindex micplb
ddf6fe37 23599@item -micplb
d77de738
ML
23600Assume that ICPLBs are enabled at run time. This has an effect on certain
23601anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23602are enabled; for standalone applications the default is off.
23603@end table
23604
23605@node C6X Options
23606@subsection C6X Options
23607@cindex C6X Options
23608
23609@table @gcctabopt
d77de738 23610@opindex march
ddf6fe37 23611@item -march=@var{name}
d77de738
ML
23612This specifies the name of the target architecture. GCC uses this
23613name to determine what kind of instructions it can emit when generating
23614assembly code. Permissible names are: @samp{c62x},
23615@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23616
d77de738 23617@opindex mbig-endian
ddf6fe37 23618@item -mbig-endian
d77de738
ML
23619Generate code for a big-endian target.
23620
d77de738 23621@opindex mlittle-endian
ddf6fe37 23622@item -mlittle-endian
d77de738
ML
23623Generate code for a little-endian target. This is the default.
23624
d77de738 23625@opindex msim
ddf6fe37 23626@item -msim
d77de738
ML
23627Choose startup files and linker script suitable for the simulator.
23628
d77de738 23629@opindex msdata=default
ddf6fe37 23630@item -msdata=default
d77de738
ML
23631Put small global and static data in the @code{.neardata} section,
23632which is pointed to by register @code{B14}. Put small uninitialized
23633global and static data in the @code{.bss} section, which is adjacent
23634to the @code{.neardata} section. Put small read-only data into the
23635@code{.rodata} section. The corresponding sections used for large
23636pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23637
d77de738 23638@opindex msdata=all
ddf6fe37 23639@item -msdata=all
d77de738
ML
23640Put all data, not just small objects, into the sections reserved for
23641small data, and use addressing relative to the @code{B14} register to
23642access them.
23643
d77de738 23644@opindex msdata=none
ddf6fe37 23645@item -msdata=none
d77de738
ML
23646Make no use of the sections reserved for small data, and use absolute
23647addresses to access all data. Put all initialized global and static
23648data in the @code{.fardata} section, and all uninitialized data in the
23649@code{.far} section. Put all constant data into the @code{.const}
23650section.
23651@end table
23652
23653@node CRIS Options
23654@subsection CRIS Options
23655@cindex CRIS Options
23656
23657These options are defined specifically for the CRIS ports.
23658
23659@table @gcctabopt
d77de738
ML
23660@opindex march
23661@opindex mcpu
ddf6fe37
AA
23662@item -march=@var{architecture-type}
23663@itemx -mcpu=@var{architecture-type}
d77de738
ML
23664Generate code for the specified architecture. The choices for
23665@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23666respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23667Default is @samp{v0}.
23668
d77de738 23669@opindex mtune
ddf6fe37 23670@item -mtune=@var{architecture-type}
d77de738
ML
23671Tune to @var{architecture-type} everything applicable about the generated
23672code, except for the ABI and the set of available instructions. The
23673choices for @var{architecture-type} are the same as for
23674@option{-march=@var{architecture-type}}.
23675
d77de738 23676@opindex mmax-stack-frame
ddf6fe37 23677@item -mmax-stack-frame=@var{n}
d77de738
ML
23678Warn when the stack frame of a function exceeds @var{n} bytes.
23679
d77de738
ML
23680@opindex metrax4
23681@opindex metrax100
ddf6fe37
AA
23682@item -metrax4
23683@itemx -metrax100
d77de738
ML
23684The options @option{-metrax4} and @option{-metrax100} are synonyms for
23685@option{-march=v3} and @option{-march=v8} respectively.
23686
d77de738
ML
23687@opindex mmul-bug-workaround
23688@opindex mno-mul-bug-workaround
ddf6fe37
AA
23689@item -mmul-bug-workaround
23690@itemx -mno-mul-bug-workaround
d77de738
ML
23691Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23692models where it applies. This option is disabled by default.
23693
d77de738 23694@opindex mpdebug
ddf6fe37 23695@item -mpdebug
d77de738
ML
23696Enable CRIS-specific verbose debug-related information in the assembly
23697code. This option also has the effect of turning off the @samp{#NO_APP}
23698formatted-code indicator to the assembler at the beginning of the
23699assembly file.
23700
d77de738 23701@opindex mcc-init
ddf6fe37 23702@item -mcc-init
d77de738
ML
23703Do not use condition-code results from previous instruction; always emit
23704compare and test instructions before use of condition codes.
23705
d77de738
ML
23706@opindex mno-side-effects
23707@opindex mside-effects
ddf6fe37 23708@item -mno-side-effects
d77de738
ML
23709Do not emit instructions with side effects in addressing modes other than
23710post-increment.
23711
d77de738
ML
23712@opindex mstack-align
23713@opindex mno-stack-align
23714@opindex mdata-align
23715@opindex mno-data-align
23716@opindex mconst-align
23717@opindex mno-const-align
ddf6fe37
AA
23718@item -mstack-align
23719@itemx -mno-stack-align
23720@itemx -mdata-align
23721@itemx -mno-data-align
23722@itemx -mconst-align
23723@itemx -mno-const-align
d77de738
ML
23724These options (@samp{no-} options) arrange (eliminate arrangements) for the
23725stack frame, individual data and constants to be aligned for the maximum
23726single data access size for the chosen CPU model. The default is to
23727arrange for 32-bit alignment. ABI details such as structure layout are
23728not affected by these options.
23729
d77de738
ML
23730@opindex m32-bit
23731@opindex m16-bit
23732@opindex m8-bit
ddf6fe37
AA
23733@item -m32-bit
23734@itemx -m16-bit
23735@itemx -m8-bit
d77de738
ML
23736Similar to the stack- data- and const-align options above, these options
23737arrange for stack frame, writable data and constants to all be 32-bit,
2373816-bit or 8-bit aligned. The default is 32-bit alignment.
23739
d77de738
ML
23740@opindex mno-prologue-epilogue
23741@opindex mprologue-epilogue
ddf6fe37
AA
23742@item -mno-prologue-epilogue
23743@itemx -mprologue-epilogue
d77de738
ML
23744With @option{-mno-prologue-epilogue}, the normal function prologue and
23745epilogue which set up the stack frame are omitted and no return
23746instructions or return sequences are generated in the code. Use this
23747option only together with visual inspection of the compiled code: no
23748warnings or errors are generated when call-saved registers must be saved,
23749or storage for local variables needs to be allocated.
23750
d77de738 23751@opindex melf
ddf6fe37 23752@item -melf
d77de738
ML
23753Legacy no-op option.
23754
d77de738 23755@opindex sim
ddf6fe37 23756@item -sim
d77de738
ML
23757This option arranges
23758to link with input-output functions from a simulator library. Code,
23759initialized data and zero-initialized data are allocated consecutively.
23760
d77de738 23761@opindex sim2
ddf6fe37 23762@item -sim2
d77de738
ML
23763Like @option{-sim}, but pass linker options to locate initialized data at
237640x40000000 and zero-initialized data at 0x80000000.
23765@end table
23766
23767@node C-SKY Options
23768@subsection C-SKY Options
23769@cindex C-SKY Options
23770
23771GCC supports these options when compiling for C-SKY V2 processors.
23772
23773@table @gcctabopt
23774
d77de738 23775@opindex march=
ddf6fe37 23776@item -march=@var{arch}
d77de738
ML
23777Specify the C-SKY target architecture. Valid values for @var{arch} are:
23778@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
23779The default is @samp{ck810}.
23780
d77de738 23781@opindex mcpu=
ddf6fe37 23782@item -mcpu=@var{cpu}
d77de738
ML
23783Specify the C-SKY target processor. Valid values for @var{cpu} are:
23784@samp{ck801}, @samp{ck801t},
23785@samp{ck802}, @samp{ck802t}, @samp{ck802j},
23786@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
23787@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
23788@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
23789@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
23790@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
23791@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
23792@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
23793@samp{ck803eftr1}, @samp{ck803efhtr1},
23794@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
23795@samp{ck803sef}, @samp{ck803seft},
23796@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
23797@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
23798@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
23799@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
23800
d77de738 23801@opindex mbig-endian
d77de738 23802@opindex EB
d77de738 23803@opindex mlittle-endian
d77de738 23804@opindex EL
ddf6fe37
AA
23805@item -mbig-endian
23806@itemx -EB
23807@itemx -mlittle-endian
23808@itemx -EL
d77de738
ML
23809
23810Select big- or little-endian code. The default is little-endian.
23811
d77de738 23812@opindex mfloat-abi
ddf6fe37 23813@item -mfloat-abi=@var{name}
d77de738
ML
23814Specifies which floating-point ABI to use. Permissible values
23815are: @samp{soft}, @samp{softfp} and @samp{hard}.
23816
23817Specifying @samp{soft} causes GCC to generate output containing
23818library calls for floating-point operations.
23819@samp{softfp} allows the generation of code using hardware floating-point
23820instructions, but still uses the soft-float calling conventions.
23821@samp{hard} allows generation of floating-point instructions
23822and uses FPU-specific calling conventions.
23823
23824The default depends on the specific target configuration. Note that
23825the hard-float and soft-float ABIs are not link-compatible; you must
23826compile your entire program with the same ABI, and link with a
23827compatible set of libraries.
23828
d77de738 23829@opindex mhard-float
d77de738 23830@opindex msoft-float
ddf6fe37
AA
23831@item -mhard-float
23832@itemx -msoft-float
d77de738
ML
23833
23834Select hardware or software floating-point implementations.
23835The default is soft float.
23836
ddf6fe37 23837@opindex mdouble-float
d77de738
ML
23838@item -mdouble-float
23839@itemx -mno-double-float
d77de738
ML
23840When @option{-mhard-float} is in effect, enable generation of
23841double-precision float instructions. This is the default except
23842when compiling for CK803.
23843
ddf6fe37 23844@opindex mfdivdu
d77de738
ML
23845@item -mfdivdu
23846@itemx -mno-fdivdu
d77de738
ML
23847When @option{-mhard-float} is in effect, enable generation of
23848@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
23849This is the default except when compiling for CK803.
23850
d77de738 23851@opindex mfpu=
ddf6fe37 23852@item -mfpu=@var{fpu}
d77de738
ML
23853Select the floating-point processor. This option can only be used with
23854@option{-mhard-float}.
23855Values for @var{fpu} are
23856@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
23857@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
23858@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
23859
ddf6fe37 23860@opindex melrw
d77de738
ML
23861@item -melrw
23862@itemx -mno-elrw
d77de738
ML
23863Enable the extended @code{lrw} instruction. This option defaults to on
23864for CK801 and off otherwise.
23865
ddf6fe37 23866@opindex mistack
d77de738
ML
23867@item -mistack
23868@itemx -mno-istack
d77de738
ML
23869Enable interrupt stack instructions; the default is off.
23870
23871The @option{-mistack} option is required to handle the
23872@code{interrupt} and @code{isr} function attributes
23873(@pxref{C-SKY Function Attributes}).
23874
d77de738 23875@opindex mmp
ddf6fe37 23876@item -mmp
d77de738
ML
23877Enable multiprocessor instructions; the default is off.
23878
d77de738 23879@opindex mcp
ddf6fe37 23880@item -mcp
d77de738
ML
23881Enable coprocessor instructions; the default is off.
23882
d77de738 23883@opindex mcache
ddf6fe37 23884@item -mcache
d77de738
ML
23885Enable coprocessor instructions; the default is off.
23886
d77de738 23887@opindex msecurity
ddf6fe37 23888@item -msecurity
d77de738
ML
23889Enable C-SKY security instructions; the default is off.
23890
d77de738 23891@opindex mtrust
ddf6fe37 23892@item -mtrust
d77de738
ML
23893Enable C-SKY trust instructions; the default is off.
23894
d77de738 23895@opindex mdsp
d77de738 23896@opindex medsp
d77de738 23897@opindex mvdsp
ddf6fe37
AA
23898@item -mdsp
23899@itemx -medsp
23900@itemx -mvdsp
d77de738
ML
23901Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
23902All of these options default to off.
23903
ddf6fe37 23904@opindex mdiv
d77de738
ML
23905@item -mdiv
23906@itemx -mno-div
d77de738
ML
23907Generate divide instructions. Default is off.
23908
ddf6fe37 23909@opindex msmart
d77de738
ML
23910@item -msmart
23911@itemx -mno-smart
d77de738
ML
23912Generate code for Smart Mode, using only registers numbered 0-7 to allow
23913use of 16-bit instructions. This option is ignored for CK801 where this
23914is the required behavior, and it defaults to on for CK802.
23915For other targets, the default is off.
23916
ddf6fe37 23917@opindex mhigh-registers
d77de738
ML
23918@item -mhigh-registers
23919@itemx -mno-high-registers
d77de738
ML
23920Generate code using the high registers numbered 16-31. This option
23921is not supported on CK801, CK802, or CK803, and is enabled by default
23922for other processors.
23923
ddf6fe37 23924@opindex manchor
d77de738
ML
23925@item -manchor
23926@itemx -mno-anchor
d77de738
ML
23927Generate code using global anchor symbol addresses.
23928
ddf6fe37 23929@opindex mpushpop
d77de738
ML
23930@item -mpushpop
23931@itemx -mno-pushpop
d77de738
ML
23932Generate code using @code{push} and @code{pop} instructions. This option
23933defaults to on.
23934
ddf6fe37 23935@opindex mmultiple-stld
d77de738
ML
23936@item -mmultiple-stld
23937@itemx -mstm
23938@itemx -mno-multiple-stld
23939@itemx -mno-stm
d77de738
ML
23940Generate code using @code{stm} and @code{ldm} instructions. This option
23941isn't supported on CK801 but is enabled by default on other processors.
23942
ddf6fe37 23943@opindex mconstpool
d77de738
ML
23944@item -mconstpool
23945@itemx -mno-constpool
d77de738
ML
23946Create constant pools in the compiler instead of deferring it to the
23947assembler. This option is the default and required for correct code
23948generation on CK801 and CK802, and is optional on other processors.
23949
ddf6fe37 23950@opindex mstack-size
d77de738
ML
23951@item -mstack-size
23952@item -mno-stack-size
d77de738
ML
23953Emit @code{.stack_size} directives for each function in the assembly
23954output. This option defaults to off.
23955
ddf6fe37 23956@opindex mccrt
d77de738
ML
23957@item -mccrt
23958@itemx -mno-ccrt
d77de738
ML
23959Generate code for the C-SKY compiler runtime instead of libgcc. This
23960option defaults to off.
23961
d77de738 23962@opindex mbranch-cost=
ddf6fe37 23963@item -mbranch-cost=@var{n}
d77de738
ML
23964Set the branch costs to roughly @code{n} instructions. The default is 1.
23965
ddf6fe37 23966@opindex msched-prolog
d77de738
ML
23967@item -msched-prolog
23968@itemx -mno-sched-prolog
d77de738
ML
23969Permit scheduling of function prologue and epilogue sequences. Using
23970this option can result in code that is not compliant with the C-SKY V2 ABI
23971prologue requirements and that cannot be debugged or backtraced.
23972It is disabled by default.
23973
d77de738 23974@opindex msim
ddf6fe37 23975@item -msim
d77de738
ML
23976Links the library libsemi.a which is in compatible with simulator. Applicable
23977to ELF compiler only.
23978
23979@end table
23980
23981@node Darwin Options
23982@subsection Darwin Options
23983@cindex Darwin options
23984
23985These options are defined for all architectures running the Darwin operating
23986system.
23987
23988FSF GCC on Darwin does not create ``fat'' object files; it creates
23989an object file for the single architecture that GCC was built to
23990target. Apple's GCC on Darwin does create ``fat'' files if multiple
23991@option{-arch} options are used; it does so by running the compiler or
23992linker multiple times and joining the results together with
23993@file{lipo}.
23994
23995The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
23996@samp{i686}) is determined by the flags that specify the ISA
23997that GCC is targeting, like @option{-mcpu} or @option{-march}. The
23998@option{-force_cpusubtype_ALL} option can be used to override this.
23999
24000The Darwin tools vary in their behavior when presented with an ISA
24001mismatch. The assembler, @file{as}, only permits instructions to
24002be used that are valid for the subtype of the file it is generating,
24003so you cannot put 64-bit instructions in a @samp{ppc750} object file.
24004The linker for shared libraries, @file{/usr/bin/libtool}, fails
24005and prints an error if asked to create a shared library with a less
24006restrictive subtype than its input files (for instance, trying to put
24007a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
24008for executables, @command{ld}, quietly gives the executable the most
24009restrictive subtype of any of its input files.
24010
24011@table @gcctabopt
d77de738 24012@opindex F
ddf6fe37 24013@item -F@var{dir}
d77de738
ML
24014Add the framework directory @var{dir} to the head of the list of
24015directories to be searched for header files. These directories are
24016interleaved with those specified by @option{-I} options and are
24017scanned in a left-to-right order.
24018
24019A framework directory is a directory with frameworks in it. A
24020framework is a directory with a @file{Headers} and/or
24021@file{PrivateHeaders} directory contained directly in it that ends
24022in @file{.framework}. The name of a framework is the name of this
24023directory excluding the @file{.framework}. Headers associated with
24024the framework are found in one of those two directories, with
24025@file{Headers} being searched first. A subframework is a framework
24026directory that is in a framework's @file{Frameworks} directory.
24027Includes of subframework headers can only appear in a header of a
24028framework that contains the subframework, or in a sibling subframework
24029header. Two subframeworks are siblings if they occur in the same
24030framework. A subframework should not have the same name as a
24031framework; a warning is issued if this is violated. Currently a
24032subframework cannot have subframeworks; in the future, the mechanism
24033may be extended to support this. The standard frameworks can be found
24034in @file{/System/Library/Frameworks} and
24035@file{/Library/Frameworks}. An example include looks like
24036@code{#include <Framework/header.h>}, where @file{Framework} denotes
24037the name of the framework and @file{header.h} is found in the
24038@file{PrivateHeaders} or @file{Headers} directory.
24039
d77de738 24040@opindex iframework
ddf6fe37 24041@item -iframework@var{dir}
d77de738
ML
24042Like @option{-F} except the directory is a treated as a system
24043directory. The main difference between this @option{-iframework} and
24044@option{-F} is that with @option{-iframework} the compiler does not
24045warn about constructs contained within header files found via
24046@var{dir}. This option is valid only for the C family of languages.
24047
d77de738 24048@opindex gused
ddf6fe37 24049@item -gused
d77de738
ML
24050Emit debugging information for symbols that are used. For stabs
24051debugging format, this enables @option{-feliminate-unused-debug-symbols}.
24052This is by default ON@.
24053
d77de738 24054@opindex gfull
ddf6fe37 24055@item -gfull
d77de738
ML
24056Emit debugging information for all symbols and types.
24057
24058@item -mmacosx-version-min=@var{version}
24059The earliest version of MacOS X that this executable will run on
24060is @var{version}. Typical values of @var{version} include @code{10.1},
24061@code{10.2}, and @code{10.3.9}.
24062
24063If the compiler was built to use the system's headers by default,
24064then the default for this option is the system version on which the
24065compiler is running, otherwise the default is to make choices that
24066are compatible with as many systems and code bases as possible.
24067
d77de738 24068@opindex mkernel
ddf6fe37 24069@item -mkernel
d77de738
ML
24070Enable kernel development mode. The @option{-mkernel} option sets
24071@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
24072@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
24073@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
24074applicable. This mode also sets @option{-mno-altivec},
24075@option{-msoft-float}, @option{-fno-builtin} and
24076@option{-mlong-branch} for PowerPC targets.
24077
d77de738 24078@opindex mone-byte-bool
ddf6fe37 24079@item -mone-byte-bool
d77de738
ML
24080Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
24081By default @code{sizeof(bool)} is @code{4} when compiling for
24082Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
24083option has no effect on x86.
24084
24085@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
24086to generate code that is not binary compatible with code generated
24087without that switch. Using this switch may require recompiling all
24088other modules in a program, including system libraries. Use this
24089switch to conform to a non-default data model.
24090
d77de738
ML
24091@opindex mfix-and-continue
24092@opindex ffix-and-continue
24093@opindex findirect-data
ddf6fe37
AA
24094@item -mfix-and-continue
24095@itemx -ffix-and-continue
24096@itemx -findirect-data
d77de738
ML
24097Generate code suitable for fast turnaround development, such as to
24098allow GDB to dynamically load @file{.o} files into already-running
24099programs. @option{-findirect-data} and @option{-ffix-and-continue}
24100are provided for backwards compatibility.
24101
d77de738 24102@opindex all_load
ddf6fe37 24103@item -all_load
d77de738
ML
24104Loads all members of static archive libraries.
24105See man ld(1) for more information.
24106
d77de738 24107@opindex arch_errors_fatal
ddf6fe37 24108@item -arch_errors_fatal
d77de738
ML
24109Cause the errors having to do with files that have the wrong architecture
24110to be fatal.
24111
d77de738 24112@opindex bind_at_load
ddf6fe37 24113@item -bind_at_load
d77de738
ML
24114Causes the output file to be marked such that the dynamic linker will
24115bind all undefined references when the file is loaded or launched.
24116
d77de738 24117@opindex bundle
ddf6fe37 24118@item -bundle
d77de738
ML
24119Produce a Mach-o bundle format file.
24120See man ld(1) for more information.
24121
d77de738 24122@opindex bundle_loader
ddf6fe37 24123@item -bundle_loader @var{executable}
d77de738
ML
24124This option specifies the @var{executable} that will load the build
24125output file being linked. See man ld(1) for more information.
24126
d77de738 24127@opindex dynamiclib
ddf6fe37 24128@item -dynamiclib
d77de738
ML
24129When passed this option, GCC produces a dynamic library instead of
24130an executable when linking, using the Darwin @file{libtool} command.
24131
d77de738 24132@opindex force_cpusubtype_ALL
ddf6fe37 24133@item -force_cpusubtype_ALL
d77de738
ML
24134This causes GCC's output file to have the @samp{ALL} subtype, instead of
24135one controlled by the @option{-mcpu} or @option{-march} option.
24136
24137@item -allowable_client @var{client_name}
24138@itemx -client_name
24139@itemx -compatibility_version
24140@itemx -current_version
24141@itemx -dead_strip
24142@itemx -dependency-file
24143@itemx -dylib_file
24144@itemx -dylinker_install_name
24145@itemx -dynamic
24146@itemx -exported_symbols_list
24147@itemx -filelist
24148@need 800
24149@itemx -flat_namespace
24150@itemx -force_flat_namespace
24151@itemx -headerpad_max_install_names
24152@itemx -image_base
24153@itemx -init
24154@itemx -install_name
24155@itemx -keep_private_externs
24156@itemx -multi_module
24157@itemx -multiply_defined
24158@itemx -multiply_defined_unused
24159@need 800
24160@itemx -noall_load
24161@itemx -no_dead_strip_inits_and_terms
24162@itemx -nofixprebinding
24163@itemx -nomultidefs
24164@itemx -noprebind
24165@itemx -noseglinkedit
24166@itemx -pagezero_size
24167@itemx -prebind
24168@itemx -prebind_all_twolevel_modules
24169@itemx -private_bundle
24170@need 800
24171@itemx -read_only_relocs
24172@itemx -sectalign
24173@itemx -sectobjectsymbols
24174@itemx -whyload
24175@itemx -seg1addr
24176@itemx -sectcreate
24177@itemx -sectobjectsymbols
24178@itemx -sectorder
24179@itemx -segaddr
24180@itemx -segs_read_only_addr
24181@need 800
24182@itemx -segs_read_write_addr
24183@itemx -seg_addr_table
24184@itemx -seg_addr_table_filename
24185@itemx -seglinkedit
24186@itemx -segprot
24187@itemx -segs_read_only_addr
24188@itemx -segs_read_write_addr
24189@itemx -single_module
24190@itemx -static
24191@itemx -sub_library
24192@need 800
d77de738
ML
24193@opindex allowable_client
24194@opindex client_name
24195@opindex compatibility_version
24196@opindex current_version
24197@opindex dead_strip
24198@opindex dependency-file
24199@opindex dylib_file
24200@opindex dylinker_install_name
24201@opindex dynamic
24202@opindex exported_symbols_list
24203@opindex filelist
24204@opindex flat_namespace
24205@opindex force_flat_namespace
24206@opindex headerpad_max_install_names
24207@opindex image_base
24208@opindex init
24209@opindex install_name
24210@opindex keep_private_externs
24211@opindex multi_module
24212@opindex multiply_defined
24213@opindex multiply_defined_unused
24214@opindex noall_load
24215@opindex no_dead_strip_inits_and_terms
24216@opindex nofixprebinding
24217@opindex nomultidefs
24218@opindex noprebind
24219@opindex noseglinkedit
24220@opindex pagezero_size
24221@opindex prebind
24222@opindex prebind_all_twolevel_modules
24223@opindex private_bundle
24224@opindex read_only_relocs
24225@opindex sectalign
24226@opindex sectobjectsymbols
24227@opindex whyload
24228@opindex seg1addr
24229@opindex sectcreate
24230@opindex sectobjectsymbols
24231@opindex sectorder
24232@opindex segaddr
24233@opindex segs_read_only_addr
24234@opindex segs_read_write_addr
24235@opindex seg_addr_table
24236@opindex seg_addr_table_filename
24237@opindex seglinkedit
24238@opindex segprot
24239@opindex segs_read_only_addr
24240@opindex segs_read_write_addr
24241@opindex single_module
24242@opindex static
24243@opindex sub_library
24244@opindex sub_umbrella
24245@opindex twolevel_namespace
24246@opindex umbrella
24247@opindex undefined
24248@opindex unexported_symbols_list
24249@opindex weak_reference_mismatches
24250@opindex whatsloaded
ddf6fe37
AA
24251@itemx -sub_umbrella
24252@itemx -twolevel_namespace
24253@itemx -umbrella
24254@itemx -undefined
24255@itemx -unexported_symbols_list
24256@itemx -weak_reference_mismatches
24257@itemx -whatsloaded
d77de738
ML
24258These options are passed to the Darwin linker. The Darwin linker man page
24259describes them in detail.
24260@end table
24261
24262@node DEC Alpha Options
24263@subsection DEC Alpha Options
24264
24265These @samp{-m} options are defined for the DEC Alpha implementations:
24266
24267@table @gcctabopt
d77de738
ML
24268@opindex mno-soft-float
24269@opindex msoft-float
ddf6fe37
AA
24270@item -mno-soft-float
24271@itemx -msoft-float
d77de738
ML
24272Use (do not use) the hardware floating-point instructions for
24273floating-point operations. When @option{-msoft-float} is specified,
24274functions in @file{libgcc.a} are used to perform floating-point
24275operations. Unless they are replaced by routines that emulate the
24276floating-point operations, or compiled in such a way as to call such
24277emulations routines, these routines issue floating-point
24278operations. If you are compiling for an Alpha without floating-point
24279operations, you must ensure that the library is built so as not to call
24280them.
24281
24282Note that Alpha implementations without floating-point operations are
24283required to have floating-point registers.
24284
d77de738
ML
24285@opindex mfp-reg
24286@opindex mno-fp-regs
ddf6fe37
AA
24287@item -mfp-reg
24288@itemx -mno-fp-regs
d77de738
ML
24289Generate code that uses (does not use) the floating-point register set.
24290@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24291register set is not used, floating-point operands are passed in integer
24292registers as if they were integers and floating-point results are passed
24293in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24294so any function with a floating-point argument or return value called by code
24295compiled with @option{-mno-fp-regs} must also be compiled with that
24296option.
24297
24298A typical use of this option is building a kernel that does not use,
24299and hence need not save and restore, any floating-point registers.
24300
d77de738 24301@opindex mieee
ddf6fe37 24302@item -mieee
d77de738
ML
24303The Alpha architecture implements floating-point hardware optimized for
24304maximum performance. It is mostly compliant with the IEEE floating-point
24305standard. However, for full compliance, software assistance is
24306required. This option generates code fully IEEE-compliant code
24307@emph{except} that the @var{inexact-flag} is not maintained (see below).
24308If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24309defined during compilation. The resulting code is less efficient but is
24310able to correctly support denormalized numbers and exceptional IEEE
24311values such as not-a-number and plus/minus infinity. Other Alpha
24312compilers call this option @option{-ieee_with_no_inexact}.
24313
d77de738 24314@opindex mieee-with-inexact
ddf6fe37 24315@item -mieee-with-inexact
d77de738
ML
24316This is like @option{-mieee} except the generated code also maintains
24317the IEEE @var{inexact-flag}. Turning on this option causes the
24318generated code to implement fully-compliant IEEE math. In addition to
24319@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24320macro. On some Alpha implementations the resulting code may execute
24321significantly slower than the code generated by default. Since there is
24322very little code that depends on the @var{inexact-flag}, you should
24323normally not specify this option. Other Alpha compilers call this
24324option @option{-ieee_with_inexact}.
24325
d77de738 24326@opindex mfp-trap-mode
ddf6fe37 24327@item -mfp-trap-mode=@var{trap-mode}
d77de738
ML
24328This option controls what floating-point related traps are enabled.
24329Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24330The trap mode can be set to one of four values:
24331
24332@table @samp
24333@item n
24334This is the default (normal) setting. The only traps that are enabled
24335are the ones that cannot be disabled in software (e.g., division by zero
24336trap).
24337
24338@item u
24339In addition to the traps enabled by @samp{n}, underflow traps are enabled
24340as well.
24341
24342@item su
24343Like @samp{u}, but the instructions are marked to be safe for software
24344completion (see Alpha architecture manual for details).
24345
24346@item sui
24347Like @samp{su}, but inexact traps are enabled as well.
24348@end table
24349
d77de738 24350@opindex mfp-rounding-mode
ddf6fe37 24351@item -mfp-rounding-mode=@var{rounding-mode}
d77de738
ML
24352Selects the IEEE rounding mode. Other Alpha compilers call this option
24353@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24354of:
24355
24356@table @samp
24357@item n
24358Normal IEEE rounding mode. Floating-point numbers are rounded towards
24359the nearest machine number or towards the even machine number in case
24360of a tie.
24361
24362@item m
24363Round towards minus infinity.
24364
24365@item c
24366Chopped rounding mode. Floating-point numbers are rounded towards zero.
24367
24368@item d
24369Dynamic rounding mode. A field in the floating-point control register
24370(@var{fpcr}, see Alpha architecture reference manual) controls the
24371rounding mode in effect. The C library initializes this register for
24372rounding towards plus infinity. Thus, unless your program modifies the
24373@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24374@end table
24375
d77de738 24376@opindex mtrap-precision
ddf6fe37 24377@item -mtrap-precision=@var{trap-precision}
d77de738
ML
24378In the Alpha architecture, floating-point traps are imprecise. This
24379means without software assistance it is impossible to recover from a
24380floating trap and program execution normally needs to be terminated.
24381GCC can generate code that can assist operating system trap handlers
24382in determining the exact location that caused a floating-point trap.
24383Depending on the requirements of an application, different levels of
24384precisions can be selected:
24385
24386@table @samp
24387@item p
24388Program precision. This option is the default and means a trap handler
24389can only identify which program caused a floating-point exception.
24390
24391@item f
24392Function precision. The trap handler can determine the function that
24393caused a floating-point exception.
24394
24395@item i
24396Instruction precision. The trap handler can determine the exact
24397instruction that caused a floating-point exception.
24398@end table
24399
24400Other Alpha compilers provide the equivalent options called
24401@option{-scope_safe} and @option{-resumption_safe}.
24402
d77de738 24403@opindex mieee-conformant
ddf6fe37 24404@item -mieee-conformant
d77de738
ML
24405This option marks the generated code as IEEE conformant. You must not
24406use this option unless you also specify @option{-mtrap-precision=i} and either
24407@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24408is to emit the line @samp{.eflag 48} in the function prologue of the
24409generated assembly file.
24410
d77de738 24411@opindex mbuild-constants
ddf6fe37 24412@item -mbuild-constants
d77de738
ML
24413Normally GCC examines a 32- or 64-bit integer constant to
24414see if it can construct it from smaller constants in two or three
24415instructions. If it cannot, it outputs the constant as a literal and
24416generates code to load it from the data segment at run time.
24417
24418Use this option to require GCC to construct @emph{all} integer constants
24419using code, even if it takes more instructions (the maximum is six).
24420
24421You typically use this option to build a shared library dynamic
24422loader. Itself a shared library, it must relocate itself in memory
24423before it can find the variables and constants in its own data segment.
24424
d77de738
ML
24425@opindex mbwx
24426@opindex mno-bwx
24427@opindex mcix
24428@opindex mno-cix
24429@opindex mfix
24430@opindex mno-fix
24431@opindex mmax
24432@opindex mno-max
ddf6fe37
AA
24433@item -mbwx
24434@itemx -mno-bwx
24435@itemx -mcix
24436@itemx -mno-cix
24437@itemx -mfix
24438@itemx -mno-fix
24439@itemx -mmax
24440@itemx -mno-max
d77de738
ML
24441Indicate whether GCC should generate code to use the optional BWX,
24442CIX, FIX and MAX instruction sets. The default is to use the instruction
24443sets supported by the CPU type specified via @option{-mcpu=} option or that
24444of the CPU on which GCC was built if none is specified.
24445
d77de738
ML
24446@opindex mfloat-vax
24447@opindex mfloat-ieee
ddf6fe37
AA
24448@item -mfloat-vax
24449@itemx -mfloat-ieee
d77de738
ML
24450Generate code that uses (does not use) VAX F and G floating-point
24451arithmetic instead of IEEE single and double precision.
24452
d77de738
ML
24453@opindex mexplicit-relocs
24454@opindex mno-explicit-relocs
ddf6fe37
AA
24455@item -mexplicit-relocs
24456@itemx -mno-explicit-relocs
d77de738
ML
24457Older Alpha assemblers provided no way to generate symbol relocations
24458except via assembler macros. Use of these macros does not allow
24459optimal instruction scheduling. GNU binutils as of version 2.12
24460supports a new syntax that allows the compiler to explicitly mark
24461which relocations should apply to which instructions. This option
24462is mostly useful for debugging, as GCC detects the capabilities of
24463the assembler when it is built and sets the default accordingly.
24464
d77de738
ML
24465@opindex msmall-data
24466@opindex mlarge-data
ddf6fe37
AA
24467@item -msmall-data
24468@itemx -mlarge-data
d77de738
ML
24469When @option{-mexplicit-relocs} is in effect, static data is
24470accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24471is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24472(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2447316-bit relocations off of the @code{$gp} register. This limits the
24474size of the small data area to 64KB, but allows the variables to be
24475directly accessed via a single instruction.
24476
24477The default is @option{-mlarge-data}. With this option the data area
24478is limited to just below 2GB@. Programs that require more than 2GB of
24479data must use @code{malloc} or @code{mmap} to allocate the data in the
24480heap instead of in the program's data segment.
24481
24482When generating code for shared libraries, @option{-fpic} implies
24483@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24484
d77de738
ML
24485@opindex msmall-text
24486@opindex mlarge-text
ddf6fe37
AA
24487@item -msmall-text
24488@itemx -mlarge-text
d77de738
ML
24489When @option{-msmall-text} is used, the compiler assumes that the
24490code of the entire program (or shared library) fits in 4MB, and is
24491thus reachable with a branch instruction. When @option{-msmall-data}
24492is used, the compiler can assume that all local symbols share the
24493same @code{$gp} value, and thus reduce the number of instructions
24494required for a function call from 4 to 1.
24495
24496The default is @option{-mlarge-text}.
24497
d77de738 24498@opindex mcpu
ddf6fe37 24499@item -mcpu=@var{cpu_type}
d77de738
ML
24500Set the instruction set and instruction scheduling parameters for
24501machine type @var{cpu_type}. You can specify either the @samp{EV}
24502style name or the corresponding chip number. GCC supports scheduling
24503parameters for the EV4, EV5 and EV6 family of processors and
24504chooses the default values for the instruction set from the processor
24505you specify. If you do not specify a processor type, GCC defaults
24506to the processor on which the compiler was built.
24507
24508Supported values for @var{cpu_type} are
24509
24510@table @samp
24511@item ev4
24512@itemx ev45
24513@itemx 21064
24514Schedules as an EV4 and has no instruction set extensions.
24515
24516@item ev5
24517@itemx 21164
24518Schedules as an EV5 and has no instruction set extensions.
24519
24520@item ev56
24521@itemx 21164a
24522Schedules as an EV5 and supports the BWX extension.
24523
24524@item pca56
24525@itemx 21164pc
24526@itemx 21164PC
24527Schedules as an EV5 and supports the BWX and MAX extensions.
24528
24529@item ev6
24530@itemx 21264
24531Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24532
24533@item ev67
24534@itemx 21264a
24535Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24536@end table
24537
24538Native toolchains also support the value @samp{native},
24539which selects the best architecture option for the host processor.
24540@option{-mcpu=native} has no effect if GCC does not recognize
24541the processor.
24542
d77de738 24543@opindex mtune
ddf6fe37 24544@item -mtune=@var{cpu_type}
d77de738
ML
24545Set only the instruction scheduling parameters for machine type
24546@var{cpu_type}. The instruction set is not changed.
24547
24548Native toolchains also support the value @samp{native},
24549which selects the best architecture option for the host processor.
24550@option{-mtune=native} has no effect if GCC does not recognize
24551the processor.
24552
d77de738 24553@opindex mmemory-latency
ddf6fe37 24554@item -mmemory-latency=@var{time}
d77de738
ML
24555Sets the latency the scheduler should assume for typical memory
24556references as seen by the application. This number is highly
24557dependent on the memory access patterns used by the application
24558and the size of the external cache on the machine.
24559
24560Valid options for @var{time} are
24561
24562@table @samp
24563@item @var{number}
24564A decimal number representing clock cycles.
24565
24566@item L1
24567@itemx L2
24568@itemx L3
24569@itemx main
24570The compiler contains estimates of the number of clock cycles for
24571``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24572(also called Dcache, Scache, and Bcache), as well as to main memory.
24573Note that L3 is only valid for EV5.
24574
24575@end table
24576@end table
24577
24578@node eBPF Options
24579@subsection eBPF Options
24580@cindex eBPF Options
24581
24582@table @gcctabopt
24583@item -mframe-limit=@var{bytes}
24584This specifies the hard limit for frame sizes, in bytes. Currently,
24585the value that can be specified should be less than or equal to
24586@samp{32767}. Defaults to whatever limit is imposed by the version of
24587the Linux kernel targeted.
24588
d77de738 24589@opindex mkernel
ddf6fe37 24590@item -mkernel=@var{version}
d77de738
ML
24591This specifies the minimum version of the kernel that will run the
24592compiled program. GCC uses this version to determine which
24593instructions to use, what kernel helpers to allow, etc. Currently,
24594@var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
24595@samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
24596@samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
24597@samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
24598@samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
24599@samp{5.2}, @samp{latest} and @samp{native}.
24600
d77de738 24601@opindex mbig-endian
ddf6fe37 24602@item -mbig-endian
d77de738
ML
24603Generate code for a big-endian target.
24604
d77de738 24605@opindex mlittle-endian
ddf6fe37 24606@item -mlittle-endian
d77de738
ML
24607Generate code for a little-endian target. This is the default.
24608
d77de738 24609@opindex mjmpext
ddf6fe37 24610@item -mjmpext
d77de738
ML
24611Enable generation of extra conditional-branch instructions.
24612Enabled for CPU v2 and above.
24613
d77de738 24614@opindex mjmp32
ddf6fe37 24615@item -mjmp32
d77de738
ML
24616Enable 32-bit jump instructions. Enabled for CPU v3 and above.
24617
d77de738 24618@opindex malu32
ddf6fe37 24619@item -malu32
d77de738
ML
24620Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
24621
d77de738 24622@opindex mcpu
ddf6fe37 24623@item -mcpu=@var{version}
d77de738
ML
24624This specifies which version of the eBPF ISA to target. Newer versions
24625may not be supported by all kernels. The default is @samp{v3}.
24626
24627Supported values for @var{version} are:
24628
24629@table @samp
24630@item v1
24631The first stable eBPF ISA with no special features or extensions.
24632
24633@item v2
24634Supports the jump extensions, as in @option{-mjmpext}.
24635
24636@item v3
24637All features of v2, plus:
24638@itemize @minus
24639@item 32-bit jump operations, as in @option{-mjmp32}
24640@item 32-bit ALU operations, as in @option{-malu32}
24641@end itemize
24642
24643@end table
24644
d77de738 24645@opindex mco-re
ddf6fe37 24646@item -mco-re
d77de738
ML
24647Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24648is implied by @option{-gbtf}.
24649
d77de738 24650@opindex mno-co-re
ddf6fe37 24651@item -mno-co-re
d77de738
ML
24652Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24653support is enabled by default when generating BTF debug information for
24654the BPF target.
24655
24656@item -mxbpf
24657Generate code for an expanded version of BPF, which relaxes some of
24658the restrictions imposed by the BPF architecture:
24659@itemize @minus
24660@item Save and restore callee-saved registers at function entry and
24661exit, respectively.
24662@end itemize
24663@end table
24664
24665@node FR30 Options
24666@subsection FR30 Options
24667@cindex FR30 Options
24668
24669These options are defined specifically for the FR30 port.
24670
24671@table @gcctabopt
24672
d77de738 24673@opindex msmall-model
ddf6fe37 24674@item -msmall-model
d77de738
ML
24675Use the small address space model. This can produce smaller code, but
24676it does assume that all symbolic values and addresses fit into a
2467720-bit range.
24678
d77de738 24679@opindex mno-lsim
ddf6fe37 24680@item -mno-lsim
d77de738
ML
24681Assume that runtime support has been provided and so there is no need
24682to include the simulator library (@file{libsim.a}) on the linker
24683command line.
24684
24685@end table
24686
24687@node FT32 Options
24688@subsection FT32 Options
24689@cindex FT32 Options
24690
24691These options are defined specifically for the FT32 port.
24692
24693@table @gcctabopt
24694
d77de738 24695@opindex msim
ddf6fe37 24696@item -msim
d77de738
ML
24697Specifies that the program will be run on the simulator. This causes
24698an alternate runtime startup and library to be linked.
24699You must not use this option when generating programs that will run on
24700real hardware; you must provide your own runtime library for whatever
24701I/O functions are needed.
24702
d77de738 24703@opindex mlra
ddf6fe37 24704@item -mlra
d77de738
ML
24705Enable Local Register Allocation. This is still experimental for FT32,
24706so by default the compiler uses standard reload.
24707
d77de738 24708@opindex mnodiv
ddf6fe37 24709@item -mnodiv
d77de738
ML
24710Do not use div and mod instructions.
24711
d77de738 24712@opindex mft32b
ddf6fe37 24713@item -mft32b
d77de738
ML
24714Enable use of the extended instructions of the FT32B processor.
24715
d77de738 24716@opindex mcompress
ddf6fe37 24717@item -mcompress
d77de738
ML
24718Compress all code using the Ft32B code compression scheme.
24719
d77de738 24720@opindex mnopm
ddf6fe37 24721@item -mnopm
d77de738
ML
24722Do not generate code that reads program memory.
24723
24724@end table
24725
24726@node FRV Options
24727@subsection FRV Options
24728@cindex FRV Options
24729
24730@table @gcctabopt
d77de738 24731@opindex mgpr-32
ddf6fe37 24732@item -mgpr-32
d77de738
ML
24733
24734Only use the first 32 general-purpose registers.
24735
d77de738 24736@opindex mgpr-64
ddf6fe37 24737@item -mgpr-64
d77de738
ML
24738
24739Use all 64 general-purpose registers.
24740
d77de738 24741@opindex mfpr-32
ddf6fe37 24742@item -mfpr-32
d77de738
ML
24743
24744Use only the first 32 floating-point registers.
24745
d77de738 24746@opindex mfpr-64
ddf6fe37 24747@item -mfpr-64
d77de738
ML
24748
24749Use all 64 floating-point registers.
24750
d77de738 24751@opindex mhard-float
ddf6fe37 24752@item -mhard-float
d77de738
ML
24753
24754Use hardware instructions for floating-point operations.
24755
d77de738 24756@opindex msoft-float
ddf6fe37 24757@item -msoft-float
d77de738
ML
24758
24759Use library routines for floating-point operations.
24760
d77de738 24761@opindex malloc-cc
ddf6fe37 24762@item -malloc-cc
d77de738
ML
24763
24764Dynamically allocate condition code registers.
24765
d77de738 24766@opindex mfixed-cc
ddf6fe37 24767@item -mfixed-cc
d77de738
ML
24768
24769Do not try to dynamically allocate condition code registers, only
24770use @code{icc0} and @code{fcc0}.
24771
d77de738 24772@opindex mdword
ddf6fe37 24773@item -mdword
d77de738
ML
24774
24775Change ABI to use double word insns.
24776
d77de738
ML
24777@opindex mno-dword
24778@opindex mdword
ddf6fe37 24779@item -mno-dword
d77de738
ML
24780
24781Do not use double word instructions.
24782
d77de738 24783@opindex mdouble
ddf6fe37 24784@item -mdouble
d77de738
ML
24785
24786Use floating-point double instructions.
24787
d77de738 24788@opindex mno-double
ddf6fe37 24789@item -mno-double
d77de738
ML
24790
24791Do not use floating-point double instructions.
24792
d77de738 24793@opindex mmedia
ddf6fe37 24794@item -mmedia
d77de738
ML
24795
24796Use media instructions.
24797
d77de738 24798@opindex mno-media
ddf6fe37 24799@item -mno-media
d77de738
ML
24800
24801Do not use media instructions.
24802
d77de738 24803@opindex mmuladd
ddf6fe37 24804@item -mmuladd
d77de738
ML
24805
24806Use multiply and add/subtract instructions.
24807
d77de738 24808@opindex mno-muladd
ddf6fe37 24809@item -mno-muladd
d77de738
ML
24810
24811Do not use multiply and add/subtract instructions.
24812
d77de738 24813@opindex mfdpic
ddf6fe37 24814@item -mfdpic
d77de738
ML
24815
24816Select the FDPIC ABI, which uses function descriptors to represent
24817pointers to functions. Without any PIC/PIE-related options, it
24818implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
24819assumes GOT entries and small data are within a 12-bit range from the
24820GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
24821are computed with 32 bits.
24822With a @samp{bfin-elf} target, this option implies @option{-msim}.
24823
d77de738 24824@opindex minline-plt
ddf6fe37 24825@item -minline-plt
d77de738
ML
24826
24827Enable inlining of PLT entries in function calls to functions that are
24828not known to bind locally. It has no effect without @option{-mfdpic}.
24829It's enabled by default if optimizing for speed and compiling for
24830shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
24831optimization option such as @option{-O3} or above is present in the
24832command line.
24833
d77de738 24834@opindex mTLS
ddf6fe37 24835@item -mTLS
d77de738
ML
24836
24837Assume a large TLS segment when generating thread-local code.
24838
d77de738 24839@opindex mtls
ddf6fe37 24840@item -mtls
d77de738
ML
24841
24842Do not assume a large TLS segment when generating thread-local code.
24843
d77de738 24844@opindex mgprel-ro
ddf6fe37 24845@item -mgprel-ro
d77de738
ML
24846
24847Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
24848that is known to be in read-only sections. It's enabled by default,
24849except for @option{-fpic} or @option{-fpie}: even though it may help
24850make the global offset table smaller, it trades 1 instruction for 4.
24851With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
24852one of which may be shared by multiple symbols, and it avoids the need
24853for a GOT entry for the referenced symbol, so it's more likely to be a
24854win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
24855
d77de738 24856@opindex multilib-library-pic
ddf6fe37 24857@item -multilib-library-pic
d77de738
ML
24858
24859Link with the (library, not FD) pic libraries. It's implied by
24860@option{-mlibrary-pic}, as well as by @option{-fPIC} and
24861@option{-fpic} without @option{-mfdpic}. You should never have to use
24862it explicitly.
24863
d77de738 24864@opindex mlinked-fp
ddf6fe37 24865@item -mlinked-fp
d77de738
ML
24866
24867Follow the EABI requirement of always creating a frame pointer whenever
24868a stack frame is allocated. This option is enabled by default and can
24869be disabled with @option{-mno-linked-fp}.
24870
d77de738 24871@opindex mlong-calls
ddf6fe37 24872@item -mlong-calls
d77de738
ML
24873
24874Use indirect addressing to call functions outside the current
24875compilation unit. This allows the functions to be placed anywhere
24876within the 32-bit address space.
24877
d77de738 24878@opindex malign-labels
ddf6fe37 24879@item -malign-labels
d77de738
ML
24880
24881Try to align labels to an 8-byte boundary by inserting NOPs into the
24882previous packet. This option only has an effect when VLIW packing
24883is enabled. It doesn't create new packets; it merely adds NOPs to
24884existing ones.
24885
d77de738 24886@opindex mlibrary-pic
ddf6fe37 24887@item -mlibrary-pic
d77de738
ML
24888
24889Generate position-independent EABI code.
24890
d77de738 24891@opindex macc-4
ddf6fe37 24892@item -macc-4
d77de738
ML
24893
24894Use only the first four media accumulator registers.
24895
d77de738 24896@opindex macc-8
ddf6fe37 24897@item -macc-8
d77de738
ML
24898
24899Use all eight media accumulator registers.
24900
d77de738 24901@opindex mpack
ddf6fe37 24902@item -mpack
d77de738
ML
24903
24904Pack VLIW instructions.
24905
d77de738 24906@opindex mno-pack
ddf6fe37 24907@item -mno-pack
d77de738
ML
24908
24909Do not pack VLIW instructions.
24910
d77de738 24911@opindex mno-eflags
ddf6fe37 24912@item -mno-eflags
d77de738
ML
24913
24914Do not mark ABI switches in e_flags.
24915
d77de738 24916@opindex mcond-move
ddf6fe37 24917@item -mcond-move
d77de738
ML
24918
24919Enable the use of conditional-move instructions (default).
24920
24921This switch is mainly for debugging the compiler and will likely be removed
24922in a future version.
24923
d77de738 24924@opindex mno-cond-move
ddf6fe37 24925@item -mno-cond-move
d77de738
ML
24926
24927Disable the use of conditional-move instructions.
24928
24929This switch is mainly for debugging the compiler and will likely be removed
24930in a future version.
24931
d77de738 24932@opindex mscc
ddf6fe37 24933@item -mscc
d77de738
ML
24934
24935Enable the use of conditional set instructions (default).
24936
24937This switch is mainly for debugging the compiler and will likely be removed
24938in a future version.
24939
d77de738 24940@opindex mno-scc
ddf6fe37 24941@item -mno-scc
d77de738
ML
24942
24943Disable the use of conditional set instructions.
24944
24945This switch is mainly for debugging the compiler and will likely be removed
24946in a future version.
24947
d77de738 24948@opindex mcond-exec
ddf6fe37 24949@item -mcond-exec
d77de738
ML
24950
24951Enable the use of conditional execution (default).
24952
24953This switch is mainly for debugging the compiler and will likely be removed
24954in a future version.
24955
d77de738 24956@opindex mno-cond-exec
ddf6fe37 24957@item -mno-cond-exec
d77de738
ML
24958
24959Disable the use of conditional execution.
24960
24961This switch is mainly for debugging the compiler and will likely be removed
24962in a future version.
24963
d77de738 24964@opindex mvliw-branch
ddf6fe37 24965@item -mvliw-branch
d77de738
ML
24966
24967Run a pass to pack branches into VLIW instructions (default).
24968
24969This switch is mainly for debugging the compiler and will likely be removed
24970in a future version.
24971
d77de738 24972@opindex mno-vliw-branch
ddf6fe37 24973@item -mno-vliw-branch
d77de738
ML
24974
24975Do not run a pass to pack branches into VLIW instructions.
24976
24977This switch is mainly for debugging the compiler and will likely be removed
24978in a future version.
24979
d77de738 24980@opindex mmulti-cond-exec
ddf6fe37 24981@item -mmulti-cond-exec
d77de738
ML
24982
24983Enable optimization of @code{&&} and @code{||} in conditional execution
24984(default).
24985
24986This switch is mainly for debugging the compiler and will likely be removed
24987in a future version.
24988
d77de738 24989@opindex mno-multi-cond-exec
ddf6fe37 24990@item -mno-multi-cond-exec
d77de738
ML
24991
24992Disable optimization of @code{&&} and @code{||} in conditional execution.
24993
24994This switch is mainly for debugging the compiler and will likely be removed
24995in a future version.
24996
d77de738 24997@opindex mnested-cond-exec
ddf6fe37 24998@item -mnested-cond-exec
d77de738
ML
24999
25000Enable nested conditional execution optimizations (default).
25001
25002This switch is mainly for debugging the compiler and will likely be removed
25003in a future version.
25004
d77de738 25005@opindex mno-nested-cond-exec
ddf6fe37 25006@item -mno-nested-cond-exec
d77de738
ML
25007
25008Disable nested conditional execution optimizations.
25009
25010This switch is mainly for debugging the compiler and will likely be removed
25011in a future version.
25012
d77de738 25013@opindex moptimize-membar
ddf6fe37 25014@item -moptimize-membar
d77de738
ML
25015
25016This switch removes redundant @code{membar} instructions from the
25017compiler-generated code. It is enabled by default.
25018
d77de738
ML
25019@opindex mno-optimize-membar
25020@opindex moptimize-membar
ddf6fe37 25021@item -mno-optimize-membar
d77de738
ML
25022
25023This switch disables the automatic removal of redundant @code{membar}
25024instructions from the generated code.
25025
d77de738 25026@opindex mtomcat-stats
ddf6fe37 25027@item -mtomcat-stats
d77de738
ML
25028
25029Cause gas to print out tomcat statistics.
25030
d77de738 25031@opindex mcpu
ddf6fe37 25032@item -mcpu=@var{cpu}
d77de738
ML
25033
25034Select the processor type for which to generate code. Possible values are
25035@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
25036@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
25037
25038@end table
25039
25040@node GNU/Linux Options
25041@subsection GNU/Linux Options
25042
25043These @samp{-m} options are defined for GNU/Linux targets:
25044
25045@table @gcctabopt
d77de738 25046@opindex mglibc
ddf6fe37 25047@item -mglibc
d77de738
ML
25048Use the GNU C library. This is the default except
25049on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
25050@samp{*-*-linux-*android*} targets.
25051
d77de738 25052@opindex muclibc
ddf6fe37 25053@item -muclibc
d77de738
ML
25054Use uClibc C library. This is the default on
25055@samp{*-*-linux-*uclibc*} targets.
25056
d77de738 25057@opindex mmusl
ddf6fe37 25058@item -mmusl
d77de738
ML
25059Use the musl C library. This is the default on
25060@samp{*-*-linux-*musl*} targets.
25061
d77de738 25062@opindex mbionic
ddf6fe37 25063@item -mbionic
d77de738
ML
25064Use Bionic C library. This is the default on
25065@samp{*-*-linux-*android*} targets.
25066
d77de738 25067@opindex mandroid
ddf6fe37 25068@item -mandroid
d77de738
ML
25069Compile code compatible with Android platform. This is the default on
25070@samp{*-*-linux-*android*} targets.
25071
25072When compiling, this option enables @option{-mbionic}, @option{-fPIC},
25073@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
25074this option makes the GCC driver pass Android-specific options to the linker.
25075Finally, this option causes the preprocessor macro @code{__ANDROID__}
25076to be defined.
25077
d77de738 25078@opindex tno-android-cc
ddf6fe37 25079@item -tno-android-cc
d77de738
ML
25080Disable compilation effects of @option{-mandroid}, i.e., do not enable
25081@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
25082@option{-fno-rtti} by default.
25083
d77de738 25084@opindex tno-android-ld
ddf6fe37 25085@item -tno-android-ld
d77de738
ML
25086Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
25087linking options to the linker.
25088
25089@end table
25090
25091@node H8/300 Options
25092@subsection H8/300 Options
25093
25094These @samp{-m} options are defined for the H8/300 implementations:
25095
25096@table @gcctabopt
d77de738 25097@opindex mrelax
ddf6fe37 25098@item -mrelax
d77de738
ML
25099Shorten some address references at link time, when possible; uses the
25100linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
25101ld, Using ld}, for a fuller description.
25102
d77de738 25103@opindex mh
ddf6fe37 25104@item -mh
d77de738
ML
25105Generate code for the H8/300H@.
25106
d77de738 25107@opindex ms
ddf6fe37 25108@item -ms
d77de738
ML
25109Generate code for the H8S@.
25110
d77de738 25111@opindex mn
ddf6fe37 25112@item -mn
d77de738
ML
25113Generate code for the H8S and H8/300H in the normal mode. This switch
25114must be used either with @option{-mh} or @option{-ms}.
25115
d77de738 25116@opindex ms2600
ddf6fe37 25117@item -ms2600
d77de738
ML
25118Generate code for the H8S/2600. This switch must be used with @option{-ms}.
25119
d77de738 25120@opindex mexr
ddf6fe37 25121@item -mexr
d77de738
ML
25122Extended registers are stored on stack before execution of function
25123with monitor attribute. Default option is @option{-mexr}.
25124This option is valid only for H8S targets.
25125
d77de738
ML
25126@opindex mno-exr
25127@opindex mexr
ddf6fe37 25128@item -mno-exr
d77de738
ML
25129Extended registers are not stored on stack before execution of function
25130with monitor attribute. Default option is @option{-mno-exr}.
25131This option is valid only for H8S targets.
25132
d77de738 25133@opindex mint32
ddf6fe37 25134@item -mint32
d77de738
ML
25135Make @code{int} data 32 bits by default.
25136
d77de738 25137@opindex malign-300
ddf6fe37 25138@item -malign-300
d77de738
ML
25139On the H8/300H and H8S, use the same alignment rules as for the H8/300.
25140The default for the H8/300H and H8S is to align longs and floats on
251414-byte boundaries.
25142@option{-malign-300} causes them to be aligned on 2-byte boundaries.
25143This option has no effect on the H8/300.
25144@end table
25145
25146@node HPPA Options
25147@subsection HPPA Options
25148@cindex HPPA Options
25149
25150These @samp{-m} options are defined for the HPPA family of computers:
25151
25152@table @gcctabopt
d77de738 25153@opindex march
ddf6fe37 25154@item -march=@var{architecture-type}
d77de738
ML
25155Generate code for the specified architecture. The choices for
25156@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
251571.1, and @samp{2.0} for PA 2.0 processors. Refer to
25158@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
25159architecture option for your machine. Code compiled for lower numbered
25160architectures runs on higher numbered architectures, but not the
25161other way around.
25162
d77de738
ML
25163@opindex mpa-risc-1-0
25164@opindex mpa-risc-1-1
25165@opindex mpa-risc-2-0
ddf6fe37
AA
25166@item -mpa-risc-1-0
25167@itemx -mpa-risc-1-1
25168@itemx -mpa-risc-2-0
d77de738
ML
25169Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
25170
cf467fb9
JDA
25171@opindex matomic-libcalls
25172@opindex mno-atomic-libcalls
ddf6fe37 25173@item -matomic-libcalls
cf467fb9
JDA
25174Generate libcalls for atomic loads and stores when sync libcalls are disabled.
25175This option is enabled by default. It only affects the generation of
25176atomic libcalls by the HPPA backend.
25177
25178Both the sync and @file{libatomic} libcall implementations use locking.
25179As a result, processor stores are not atomic with respect to other
25180atomic operations. Processor loads up to DImode are atomic with
25181respect to other atomic operations provided they are implemented as
25182a single access.
25183
25184The PA-RISC architecture does not support any atomic operations in
25185hardware except for the @code{ldcw} instruction. Thus, all atomic
25186support is implemented using sync and atomic libcalls. Sync libcall
25187support is in @file{libgcc.a}. Atomic libcall support is in
25188@file{libatomic}.
25189
25190This option generates @code{__atomic_exchange} calls for atomic stores.
25191It also provides special handling for atomic DImode accesses on 32-bit
25192targets.
25193
cf467fb9 25194@opindex mbig-switch
ddf6fe37 25195@item -mbig-switch
cf467fb9
JDA
25196Does nothing. Preserved for backward compatibility.
25197
d77de738 25198@opindex mcaller-copies
ddf6fe37 25199@item -mcaller-copies
d77de738
ML
25200The caller copies function arguments passed by hidden reference. This
25201option should be used with care as it is not compatible with the default
2520232-bit runtime. However, only aggregates larger than eight bytes are
25203passed by hidden reference and the option provides better compatibility
25204with OpenMP.
25205
cf467fb9 25206@opindex mcoherent-ldcw
ddf6fe37 25207@item -mcoherent-ldcw
cf467fb9 25208Use ldcw/ldcd coherent cache-control hint.
d77de738 25209
d77de738 25210@opindex mdisable-fpregs
ddf6fe37 25211@item -mdisable-fpregs
cf467fb9 25212Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738 25213
d77de738 25214@opindex mdisable-indexing
ddf6fe37 25215@item -mdisable-indexing
d77de738
ML
25216Prevent the compiler from using indexing address modes. This avoids some
25217rather obscure problems when compiling MIG generated code under MACH@.
25218
d77de738 25219@opindex mfast-indirect-calls
ddf6fe37 25220@item -mfast-indirect-calls
d77de738
ML
25221Generate code that assumes calls never cross space boundaries. This
25222allows GCC to emit code that performs faster indirect calls.
25223
25224This option does not work in the presence of shared libraries or nested
25225functions.
25226
d77de738 25227@opindex mfixed-range
ddf6fe37 25228@item -mfixed-range=@var{register-range}
d77de738
ML
25229Generate code treating the given register range as fixed registers.
25230A fixed register is one that the register allocator cannot use. This is
25231useful when compiling kernel code. A register range is specified as
25232two registers separated by a dash. Multiple register ranges can be
25233specified separated by a comma.
25234
d77de738 25235@opindex mgas
ddf6fe37 25236@item -mgas
d77de738
ML
25237Enable the use of assembler directives only GAS understands.
25238
d77de738 25239@opindex mgnu-ld
ddf6fe37 25240@item -mgnu-ld
d77de738
ML
25241Use options specific to GNU @command{ld}.
25242This passes @option{-shared} to @command{ld} when
25243building a shared library. It is the default when GCC is configured,
25244explicitly or implicitly, with the GNU linker. This option does not
25245affect which @command{ld} is called; it only changes what parameters
25246are passed to that @command{ld}.
25247The @command{ld} that is called is determined by the
25248@option{--with-ld} configure option, GCC's program search path, and
25249finally by the user's @env{PATH}. The linker used by GCC can be printed
25250using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25251on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25252
d77de738 25253@opindex mhp-ld
ddf6fe37 25254@item -mhp-ld
d77de738
ML
25255Use options specific to HP @command{ld}.
25256This passes @option{-b} to @command{ld} when building
25257a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25258links. It is the default when GCC is configured, explicitly or
25259implicitly, with the HP linker. This option does not affect
25260which @command{ld} is called; it only changes what parameters are passed to that
25261@command{ld}.
25262The @command{ld} that is called is determined by the @option{--with-ld}
25263configure option, GCC's program search path, and finally by the user's
25264@env{PATH}. The linker used by GCC can be printed using @samp{which
25265`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25266HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25267
cf467fb9 25268@opindex mlinker-opt
ddf6fe37 25269@item -mlinker-opt
cf467fb9
JDA
25270Enable the optimization pass in the HP-UX linker. Note this makes symbolic
25271debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25272linkers in which they give bogus error messages when linking some programs.
25273
d77de738
ML
25274@opindex mno-long-calls
25275@opindex mlong-calls
ddf6fe37 25276@item -mlong-calls
d77de738
ML
25277Generate code that uses long call sequences. This ensures that a call
25278is always able to reach linker generated stubs. The default is to generate
25279long calls only when the distance from the call site to the beginning
25280of the function or translation unit, as the case may be, exceeds a
25281predefined limit set by the branch type being used. The limits for
25282normal calls are 7,600,000 and 240,000 bytes, respectively for the
25283PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25284240,000 bytes.
25285
25286Distances are measured from the beginning of functions when using the
25287@option{-ffunction-sections} option, or when using the @option{-mgas}
25288and @option{-mno-portable-runtime} options together under HP-UX with
25289the SOM linker.
25290
25291It is normally not desirable to use this option as it degrades
25292performance. However, it may be useful in large applications,
25293particularly when partial linking is used to build the application.
25294
25295The types of long calls used depends on the capabilities of the
25296assembler and linker, and the type of code being generated. The
25297impact on systems that support long absolute calls, and long pic
25298symbol-difference or pc-relative calls should be relatively small.
25299However, an indirect call is used on 32-bit ELF systems in pic code
25300and it is quite long.
25301
cf467fb9 25302@opindex mlong-load-store
ddf6fe37 25303@item -mlong-load-store
cf467fb9
JDA
25304Generate 3-instruction load and store sequences as sometimes required by
25305the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25306the HP compilers.
25307
cf467fb9 25308@opindex mjump-in-delay
ddf6fe37 25309@item -mjump-in-delay
cf467fb9
JDA
25310This option is ignored and provided for compatibility purposes only.
25311
cf467fb9
JDA
25312@opindex mno-space-regs
25313@opindex mspace-regs
ddf6fe37 25314@item -mno-space-regs
cf467fb9
JDA
25315Generate code that assumes the target has no space registers. This allows
25316GCC to generate faster indirect calls and use unscaled index address modes.
25317
25318Such code is suitable for level 0 PA systems and kernels.
25319
cf467fb9 25320@opindex mordered
ddf6fe37 25321@item -mordered
cf467fb9
JDA
25322Assume memory references are ordered and barriers are not needed.
25323
cf467fb9 25324@opindex mportable-runtime
ddf6fe37 25325@item -mportable-runtime
cf467fb9
JDA
25326Use the portable calling conventions proposed by HP for ELF systems.
25327
cf467fb9 25328@opindex mschedule
ddf6fe37 25329@item -mschedule=@var{cpu-type}
cf467fb9
JDA
25330Schedule code according to the constraints for the machine type
25331@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25332@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25333to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25334proper scheduling option for your machine. The default scheduling is
25335@samp{8000}.
25336
cf467fb9 25337@opindex msio
ddf6fe37 25338@item -msio
cf467fb9
JDA
25339Generate the predefine, @code{_SIO}, for server IO@. The default is
25340@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25341@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25342options are available under HP-UX and HI-UX@.
25343
cf467fb9 25344@opindex msoft-float
ddf6fe37 25345@item -msoft-float
cf467fb9
JDA
25346Generate output containing library calls for floating point.
25347@strong{Warning:} the requisite libraries are not available for all HPPA
25348targets. Normally the facilities of the machine's usual C compiler are
25349used, but this cannot be done directly in cross-compilation. You must make
25350your own arrangements to provide suitable library functions for
25351cross-compilation.
25352
25353@option{-msoft-float} changes the calling convention in the output file;
25354therefore, it is only useful if you compile @emph{all} of a program with
25355this option. In particular, you need to compile @file{libgcc.a}, the
25356library that comes with GCC, with @option{-msoft-float} in order for
25357this to work.
25358
cf467fb9 25359@opindex msoft-mult
ddf6fe37 25360@item -msoft-mult
cf467fb9
JDA
25361Use software integer multiplication.
25362
25363This disables the use of the @code{xmpyu} instruction.
25364
d77de738 25365@opindex march
ddf6fe37 25366@item -munix=@var{unix-std}
d77de738
ML
25367Generate compiler predefines and select a startfile for the specified
25368UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25369and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25370is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2537111.11 and later. The default values are @samp{93} for HP-UX 10.00,
25372@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25373and later.
25374
25375@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25376@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25377and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25378@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25379@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25380@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25381
25382It is @emph{important} to note that this option changes the interfaces
25383for various library routines. It also affects the operational behavior
25384of the C library. Thus, @emph{extreme} care is needed in using this
25385option.
25386
25387Library code that is intended to operate with more than one UNIX
25388standard must test, set and restore the variable @code{__xpg4_extended_mask}
25389as appropriate. Most GNU software doesn't provide this capability.
25390
d77de738 25391@opindex nolibdld
ddf6fe37 25392@item -nolibdld
d77de738
ML
25393Suppress the generation of link options to search libdld.sl when the
25394@option{-static} option is specified on HP-UX 10 and later.
25395
d77de738 25396@opindex static
ddf6fe37 25397@item -static
d77de738
ML
25398The HP-UX implementation of setlocale in libc has a dependency on
25399libdld.sl. There isn't an archive version of libdld.sl. Thus,
25400when the @option{-static} option is specified, special link options
25401are needed to resolve this dependency.
25402
25403On HP-UX 10 and later, the GCC driver adds the necessary options to
25404link with libdld.sl when the @option{-static} option is specified.
25405This causes the resulting binary to be dynamic. On the 64-bit port,
25406the linkers generate dynamic binaries by default in any case. The
25407@option{-nolibdld} option can be used to prevent the GCC driver from
25408adding these link options.
25409
d77de738 25410@opindex threads
ddf6fe37 25411@item -threads
d77de738
ML
25412Add support for multithreading with the @dfn{dce thread} library
25413under HP-UX@. This option sets flags for both the preprocessor and
25414linker.
25415@end table
25416
25417@node IA-64 Options
25418@subsection IA-64 Options
25419@cindex IA-64 Options
25420
25421These are the @samp{-m} options defined for the Intel IA-64 architecture.
25422
25423@table @gcctabopt
d77de738 25424@opindex mbig-endian
ddf6fe37 25425@item -mbig-endian
d77de738
ML
25426Generate code for a big-endian target. This is the default for HP-UX@.
25427
d77de738 25428@opindex mlittle-endian
ddf6fe37 25429@item -mlittle-endian
d77de738
ML
25430Generate code for a little-endian target. This is the default for AIX5
25431and GNU/Linux.
25432
d77de738
ML
25433@opindex mgnu-as
25434@opindex mno-gnu-as
ddf6fe37
AA
25435@item -mgnu-as
25436@itemx -mno-gnu-as
d77de738
ML
25437Generate (or don't) code for the GNU assembler. This is the default.
25438@c Also, this is the default if the configure option @option{--with-gnu-as}
25439@c is used.
25440
d77de738
ML
25441@opindex mgnu-ld
25442@opindex mno-gnu-ld
ddf6fe37
AA
25443@item -mgnu-ld
25444@itemx -mno-gnu-ld
d77de738
ML
25445Generate (or don't) code for the GNU linker. This is the default.
25446@c Also, this is the default if the configure option @option{--with-gnu-ld}
25447@c is used.
25448
d77de738 25449@opindex mno-pic
ddf6fe37 25450@item -mno-pic
d77de738
ML
25451Generate code that does not use a global pointer register. The result
25452is not position independent code, and violates the IA-64 ABI@.
25453
d77de738
ML
25454@opindex mvolatile-asm-stop
25455@opindex mno-volatile-asm-stop
ddf6fe37
AA
25456@item -mvolatile-asm-stop
25457@itemx -mno-volatile-asm-stop
d77de738
ML
25458Generate (or don't) a stop bit immediately before and after volatile asm
25459statements.
25460
d77de738
ML
25461@opindex mregister-names
25462@opindex mno-register-names
ddf6fe37
AA
25463@item -mregister-names
25464@itemx -mno-register-names
d77de738
ML
25465Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25466the stacked registers. This may make assembler output more readable.
25467
d77de738
ML
25468@opindex mno-sdata
25469@opindex msdata
ddf6fe37
AA
25470@item -mno-sdata
25471@itemx -msdata
d77de738
ML
25472Disable (or enable) optimizations that use the small data section. This may
25473be useful for working around optimizer bugs.
25474
d77de738 25475@opindex mconstant-gp
ddf6fe37 25476@item -mconstant-gp
d77de738
ML
25477Generate code that uses a single constant global pointer value. This is
25478useful when compiling kernel code.
25479
d77de738 25480@opindex mauto-pic
ddf6fe37 25481@item -mauto-pic
d77de738
ML
25482Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25483This is useful when compiling firmware code.
25484
d77de738 25485@opindex minline-float-divide-min-latency
ddf6fe37 25486@item -minline-float-divide-min-latency
d77de738
ML
25487Generate code for inline divides of floating-point values
25488using the minimum latency algorithm.
25489
d77de738 25490@opindex minline-float-divide-max-throughput
ddf6fe37 25491@item -minline-float-divide-max-throughput
d77de738
ML
25492Generate code for inline divides of floating-point values
25493using the maximum throughput algorithm.
25494
d77de738 25495@opindex mno-inline-float-divide
ddf6fe37 25496@item -mno-inline-float-divide
d77de738
ML
25497Do not generate inline code for divides of floating-point values.
25498
d77de738 25499@opindex minline-int-divide-min-latency
ddf6fe37 25500@item -minline-int-divide-min-latency
d77de738
ML
25501Generate code for inline divides of integer values
25502using the minimum latency algorithm.
25503
d77de738 25504@opindex minline-int-divide-max-throughput
ddf6fe37 25505@item -minline-int-divide-max-throughput
d77de738
ML
25506Generate code for inline divides of integer values
25507using the maximum throughput algorithm.
25508
d77de738
ML
25509@opindex mno-inline-int-divide
25510@opindex minline-int-divide
ddf6fe37 25511@item -mno-inline-int-divide
d77de738
ML
25512Do not generate inline code for divides of integer values.
25513
d77de738 25514@opindex minline-sqrt-min-latency
ddf6fe37 25515@item -minline-sqrt-min-latency
d77de738
ML
25516Generate code for inline square roots
25517using the minimum latency algorithm.
25518
d77de738 25519@opindex minline-sqrt-max-throughput
ddf6fe37 25520@item -minline-sqrt-max-throughput
d77de738
ML
25521Generate code for inline square roots
25522using the maximum throughput algorithm.
25523
d77de738 25524@opindex mno-inline-sqrt
ddf6fe37 25525@item -mno-inline-sqrt
d77de738
ML
25526Do not generate inline code for @code{sqrt}.
25527
d77de738
ML
25528@opindex mfused-madd
25529@opindex mno-fused-madd
ddf6fe37
AA
25530@item -mfused-madd
25531@itemx -mno-fused-madd
d77de738
ML
25532Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25533instructions. The default is to use these instructions.
25534
d77de738
ML
25535@opindex mno-dwarf2-asm
25536@opindex mdwarf2-asm
ddf6fe37
AA
25537@item -mno-dwarf2-asm
25538@itemx -mdwarf2-asm
d77de738
ML
25539Don't (or do) generate assembler code for the DWARF line number debugging
25540info. This may be useful when not using the GNU assembler.
25541
d77de738
ML
25542@opindex mearly-stop-bits
25543@opindex mno-early-stop-bits
ddf6fe37
AA
25544@item -mearly-stop-bits
25545@itemx -mno-early-stop-bits
d77de738
ML
25546Allow stop bits to be placed earlier than immediately preceding the
25547instruction that triggered the stop bit. This can improve instruction
25548scheduling, but does not always do so.
25549
d77de738 25550@opindex mfixed-range
ddf6fe37 25551@item -mfixed-range=@var{register-range}
d77de738
ML
25552Generate code treating the given register range as fixed registers.
25553A fixed register is one that the register allocator cannot use. This is
25554useful when compiling kernel code. A register range is specified as
25555two registers separated by a dash. Multiple register ranges can be
25556specified separated by a comma.
25557
d77de738 25558@opindex mtls-size
ddf6fe37 25559@item -mtls-size=@var{tls-size}
d77de738
ML
25560Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2556164.
25562
d77de738 25563@opindex mtune
ddf6fe37 25564@item -mtune=@var{cpu-type}
d77de738
ML
25565Tune the instruction scheduling for a particular CPU, Valid values are
25566@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25567and @samp{mckinley}.
25568
d77de738
ML
25569@opindex milp32
25570@opindex mlp64
ddf6fe37
AA
25571@item -milp32
25572@itemx -mlp64
d77de738
ML
25573Generate code for a 32-bit or 64-bit environment.
25574The 32-bit environment sets int, long and pointer to 32 bits.
25575The 64-bit environment sets int to 32 bits and long and pointer
25576to 64 bits. These are HP-UX specific flags.
25577
d77de738
ML
25578@opindex mno-sched-br-data-spec
25579@opindex msched-br-data-spec
ddf6fe37
AA
25580@item -mno-sched-br-data-spec
25581@itemx -msched-br-data-spec
d77de738
ML
25582(Dis/En)able data speculative scheduling before reload.
25583This results in generation of @code{ld.a} instructions and
25584the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25585The default setting is disabled.
25586
d77de738
ML
25587@opindex msched-ar-data-spec
25588@opindex mno-sched-ar-data-spec
ddf6fe37
AA
25589@item -msched-ar-data-spec
25590@itemx -mno-sched-ar-data-spec
d77de738
ML
25591(En/Dis)able data speculative scheduling after reload.
25592This results in generation of @code{ld.a} instructions and
25593the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25594The default setting is enabled.
25595
d77de738
ML
25596@opindex mno-sched-control-spec
25597@opindex msched-control-spec
ddf6fe37
AA
25598@item -mno-sched-control-spec
25599@itemx -msched-control-spec
d77de738
ML
25600(Dis/En)able control speculative scheduling. This feature is
25601available only during region scheduling (i.e.@: before reload).
25602This results in generation of the @code{ld.s} instructions and
25603the corresponding check instructions @code{chk.s}.
25604The default setting is disabled.
25605
d77de738
ML
25606@opindex msched-br-in-data-spec
25607@opindex mno-sched-br-in-data-spec
ddf6fe37
AA
25608@item -msched-br-in-data-spec
25609@itemx -mno-sched-br-in-data-spec
d77de738
ML
25610(En/Dis)able speculative scheduling of the instructions that
25611are dependent on the data speculative loads before reload.
25612This is effective only with @option{-msched-br-data-spec} enabled.
25613The default setting is enabled.
25614
d77de738
ML
25615@opindex msched-ar-in-data-spec
25616@opindex mno-sched-ar-in-data-spec
ddf6fe37
AA
25617@item -msched-ar-in-data-spec
25618@itemx -mno-sched-ar-in-data-spec
d77de738
ML
25619(En/Dis)able speculative scheduling of the instructions that
25620are dependent on the data speculative loads after reload.
25621This is effective only with @option{-msched-ar-data-spec} enabled.
25622The default setting is enabled.
25623
d77de738
ML
25624@opindex msched-in-control-spec
25625@opindex mno-sched-in-control-spec
ddf6fe37
AA
25626@item -msched-in-control-spec
25627@itemx -mno-sched-in-control-spec
d77de738
ML
25628(En/Dis)able speculative scheduling of the instructions that
25629are dependent on the control speculative loads.
25630This is effective only with @option{-msched-control-spec} enabled.
25631The default setting is enabled.
25632
d77de738
ML
25633@opindex mno-sched-prefer-non-data-spec-insns
25634@opindex msched-prefer-non-data-spec-insns
ddf6fe37
AA
25635@item -mno-sched-prefer-non-data-spec-insns
25636@itemx -msched-prefer-non-data-spec-insns
d77de738
ML
25637If enabled, data-speculative instructions are chosen for schedule
25638only if there are no other choices at the moment. This makes
25639the use of the data speculation much more conservative.
25640The default setting is disabled.
25641
d77de738
ML
25642@opindex mno-sched-prefer-non-control-spec-insns
25643@opindex msched-prefer-non-control-spec-insns
ddf6fe37
AA
25644@item -mno-sched-prefer-non-control-spec-insns
25645@itemx -msched-prefer-non-control-spec-insns
d77de738
ML
25646If enabled, control-speculative instructions are chosen for schedule
25647only if there are no other choices at the moment. This makes
25648the use of the control speculation much more conservative.
25649The default setting is disabled.
25650
d77de738
ML
25651@opindex mno-sched-count-spec-in-critical-path
25652@opindex msched-count-spec-in-critical-path
ddf6fe37
AA
25653@item -mno-sched-count-spec-in-critical-path
25654@itemx -msched-count-spec-in-critical-path
d77de738
ML
25655If enabled, speculative dependencies are considered during
25656computation of the instructions priorities. This makes the use of the
25657speculation a bit more conservative.
25658The default setting is disabled.
25659
d77de738 25660@opindex msched-spec-ldc
ddf6fe37 25661@item -msched-spec-ldc
d77de738
ML
25662Use a simple data speculation check. This option is on by default.
25663
d77de738 25664@opindex msched-spec-ldc
ddf6fe37 25665@item -msched-control-spec-ldc
d77de738
ML
25666Use a simple check for control speculation. This option is on by default.
25667
d77de738 25668@opindex msched-stop-bits-after-every-cycle
ddf6fe37 25669@item -msched-stop-bits-after-every-cycle
d77de738
ML
25670Place a stop bit after every cycle when scheduling. This option is on
25671by default.
25672
d77de738 25673@opindex msched-fp-mem-deps-zero-cost
ddf6fe37 25674@item -msched-fp-mem-deps-zero-cost
d77de738
ML
25675Assume that floating-point stores and loads are not likely to cause a conflict
25676when placed into the same instruction group. This option is disabled by
25677default.
25678
d77de738 25679@opindex msel-sched-dont-check-control-spec
ddf6fe37 25680@item -msel-sched-dont-check-control-spec
d77de738
ML
25681Generate checks for control speculation in selective scheduling.
25682This flag is disabled by default.
25683
d77de738 25684@opindex msched-max-memory-insns
ddf6fe37 25685@item -msched-max-memory-insns=@var{max-insns}
d77de738
ML
25686Limit on the number of memory insns per instruction group, giving lower
25687priority to subsequent memory insns attempting to schedule in the same
25688instruction group. Frequently useful to prevent cache bank conflicts.
25689The default value is 1.
25690
d77de738 25691@opindex msched-max-memory-insns-hard-limit
ddf6fe37 25692@item -msched-max-memory-insns-hard-limit
d77de738
ML
25693Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25694disallowing more than that number in an instruction group.
25695Otherwise, the limit is ``soft'', meaning that non-memory operations
25696are preferred when the limit is reached, but memory operations may still
25697be scheduled.
25698
25699@end table
25700
25701@node LM32 Options
25702@subsection LM32 Options
25703@cindex LM32 options
25704
25705These @option{-m} options are defined for the LatticeMico32 architecture:
25706
25707@table @gcctabopt
d77de738 25708@opindex mbarrel-shift-enabled
ddf6fe37 25709@item -mbarrel-shift-enabled
d77de738
ML
25710Enable barrel-shift instructions.
25711
d77de738 25712@opindex mdivide-enabled
ddf6fe37 25713@item -mdivide-enabled
d77de738
ML
25714Enable divide and modulus instructions.
25715
d77de738 25716@opindex multiply-enabled
ddf6fe37 25717@item -mmultiply-enabled
d77de738
ML
25718Enable multiply instructions.
25719
d77de738 25720@opindex msign-extend-enabled
ddf6fe37 25721@item -msign-extend-enabled
d77de738
ML
25722Enable sign extend instructions.
25723
d77de738 25724@opindex muser-enabled
ddf6fe37 25725@item -muser-enabled
d77de738
ML
25726Enable user-defined instructions.
25727
25728@end table
25729
25730@node LoongArch Options
25731@subsection LoongArch Options
25732@cindex LoongArch Options
25733
25734These command-line options are defined for LoongArch targets:
25735
25736@table @gcctabopt
9c19597c 25737@opindex march
ddf6fe37 25738@item -march=@var{cpu-type}
d77de738
ML
25739Generate instructions for the machine type @var{cpu-type}. In contrast to
25740@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
25741for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
25742to generate code that may not run at all on processors other than the one
25743indicated. Specifying @option{-march=@var{cpu-type}} implies
25744@option{-mtune=@var{cpu-type}}, except where noted otherwise.
25745
25746The choices for @var{cpu-type} are:
25747
25748@table @samp
25749@item native
25750This selects the CPU to generate code for at compilation time by determining
25751the processor type of the compiling machine. Using @option{-march=native}
25752enables all instruction subsets supported by the local machine (hence
25753the result might not run on different machines). Using @option{-mtune=native}
25754produces code optimized for the local machine under the constraints
25755of the selected instruction set.
25756@item loongarch64
25757A generic CPU with 64-bit extensions.
25758@item la464
25759LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
25760@end table
25761
d77de738 25762@opindex mtune
ddf6fe37 25763@item -mtune=@var{cpu-type}
d77de738
ML
25764Optimize the output for the given processor, specified by microarchitecture
25765name.
25766
d77de738 25767@opindex mabi
ddf6fe37 25768@item -mabi=@var{base-abi-type}
d77de738
ML
25769Generate code for the specified calling convention.
25770@var{base-abi-type} can be one of:
25771@table @samp
25772@item lp64d
25773Uses 64-bit general purpose registers and 32/64-bit floating-point
25774registers for parameter passing. Data model is LP64, where @samp{int}
25775is 32 bits, while @samp{long int} and pointers are 64 bits.
25776@item lp64f
25777Uses 64-bit general purpose registers and 32-bit floating-point
25778registers for parameter passing. Data model is LP64, where @samp{int}
25779is 32 bits, while @samp{long int} and pointers are 64 bits.
25780@item lp64s
25781Uses 64-bit general purpose registers and no floating-point
25782registers for parameter passing. Data model is LP64, where @samp{int}
25783is 32 bits, while @samp{long int} and pointers are 64 bits.
25784@end table
25785
d77de738 25786@opindex mfpu
ddf6fe37 25787@item -mfpu=@var{fpu-type}
d77de738
ML
25788Generate code for the specified FPU type, which can be one of:
25789@table @samp
25790@item 64
25791Allow the use of hardware floating-point instructions for 32-bit
25792and 64-bit operations.
25793@item 32
25794Allow the use of hardware floating-point instructions for 32-bit
25795operations.
25796@item none
25797@item 0
25798Prevent the use of hardware floating-point instructions.
25799@end table
25800
d77de738 25801@opindex msoft-float
ddf6fe37 25802@item -msoft-float
d77de738
ML
25803Force @option{-mfpu=none} and prevents the use of floating-point
25804registers for parameter passing. This option may change the target
25805ABI.
25806
9c19597c 25807@opindex msingle-float
ddf6fe37 25808@item -msingle-float
d77de738
ML
25809Force @option{-mfpu=32} and allow the use of 32-bit floating-point
25810registers for parameter passing. This option may change the target
25811ABI.
25812
9c19597c 25813@opindex mdouble-float
ddf6fe37 25814@item -mdouble-float
d77de738
ML
25815Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
25816registers for parameter passing. This option may change the target
25817ABI.
25818
9c19597c 25819@opindex mbranch-cost
ddf6fe37 25820@item -mbranch-cost=@var{n}
d77de738
ML
25821Set the cost of branches to roughly @var{n} instructions.
25822
ddf6fe37 25823@opindex mcheck-zero-division
d77de738
ML
25824@item -mcheck-zero-division
25825@itemx -mno-check-zero-divison
d77de738
ML
25826Trap (do not trap) on integer division by zero. The default is
25827@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
25828@option{-mno-check-zero-division} for other optimization levels.
25829
ddf6fe37 25830@opindex mcond-move-int
d77de738
ML
25831@item -mcond-move-int
25832@itemx -mno-cond-move-int
d77de738
ML
25833Conditional moves for integral data in general-purpose registers
25834are enabled (disabled). The default is @option{-mcond-move-int}.
25835
ddf6fe37 25836@opindex mcond-move-float
d77de738
ML
25837@item -mcond-move-float
25838@itemx -mno-cond-move-float
d77de738
ML
25839Conditional moves for floating-point registers are enabled (disabled).
25840The default is @option{-mcond-move-float}.
25841
ddf6fe37 25842@opindex mmemcpy
d77de738
ML
25843@item -mmemcpy
25844@itemx -mno-memcpy
d77de738
ML
25845Force (do not force) the use of @code{memcpy} for non-trivial block moves.
25846The default is @option{-mno-memcpy}, which allows GCC to inline most
25847constant-sized copies. Setting optimization level to @option{-Os} also
25848forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
25849behavior if explicitly specified, regardless of the order these options on
25850the command line.
25851
ddf6fe37 25852@opindex mstrict-align
d77de738
ML
25853@item -mstrict-align
25854@itemx -mno-strict-align
d77de738
ML
25855Avoid or allow generating memory accesses that may not be aligned on a natural
25856object boundary as described in the architecture specification. The default is
25857@option{-mno-strict-align}.
25858
9c19597c 25859@opindex msmall-data-limit
ddf6fe37 25860@item -msmall-data-limit=@var{number}
d77de738
ML
25861Put global and static data smaller than @var{number} bytes into a special
25862section (on some targets). The default value is 0.
25863
9c19597c 25864@opindex mmax-inline-memcpy-size
ddf6fe37 25865@item -mmax-inline-memcpy-size=@var{n}
d77de738
ML
25866Inline all block moves (such as calls to @code{memcpy} or structure copies)
25867less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
25868
25869@item -mcmodel=@var{code-model}
25870Set the code model to one of:
25871@table @samp
25872@item tiny-static (Not implemented yet)
25873@item tiny (Not implemented yet)
25874
25875@item normal
25876The text segment must be within 128MB addressing space. The data segment must
25877be within 2GB addressing space.
25878
25879@item medium
25880The text segment and data segment must be within 2GB addressing space.
25881
25882@item large (Not implemented yet)
25883
25884@item extreme
25885This mode does not limit the size of the code segment and data segment.
25886The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
25887@option{-mno-explicit-relocs}.
25888@end table
25889The default code model is @code{normal}.
25890
d77de738
ML
25891@opindex mexplicit-relocs
25892@opindex mno-explicit-relocs
ddf6fe37
AA
25893@item -mexplicit-relocs
25894@itemx -mno-explicit-relocs
d77de738
ML
25895Use or do not use assembler relocation operators when dealing with symbolic
25896addresses. The alternative is to use assembler macros instead, which may
25897limit optimization. The default value for the option is determined during
25898GCC build-time by detecting corresponding assembler support:
25899@code{-mexplicit-relocs} if said support is present,
25900@code{-mno-explicit-relocs} otherwise. This option is mostly useful for
25901debugging, or interoperation with assemblers different from the build-time
25902one.
25903
ddf6fe37 25904@opindex mdirect-extern-access
d77de738
ML
25905@item -mdirect-extern-access
25906@itemx -mno-direct-extern-access
d77de738
ML
25907Do not use or use GOT to access external symbols. The default is
25908@option{-mno-direct-extern-access}: GOT is used for external symbols with
25909default visibility, but not used for other external symbols.
25910
25911With @option{-mdirect-extern-access}, GOT is not used and all external
25912symbols are PC-relatively addressed. It is @strong{only} suitable for
25913environments where no dynamic link is performed, like firmwares, OS
25914kernels, executables linked with @option{-static} or @option{-static-pie}.
25915@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
25916@option{-fpic}.
25917@end table
25918
25919@node M32C Options
25920@subsection M32C Options
25921@cindex M32C options
25922
25923@table @gcctabopt
d77de738 25924@opindex mcpu=
ddf6fe37 25925@item -mcpu=@var{name}
d77de738
ML
25926Select the CPU for which code is generated. @var{name} may be one of
25927@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
25928/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
25929the M32C/80 series.
25930
d77de738 25931@opindex msim
ddf6fe37 25932@item -msim
d77de738
ML
25933Specifies that the program will be run on the simulator. This causes
25934an alternate runtime library to be linked in which supports, for
25935example, file I/O@. You must not use this option when generating
25936programs that will run on real hardware; you must provide your own
25937runtime library for whatever I/O functions are needed.
25938
d77de738 25939@opindex memregs=
ddf6fe37 25940@item -memregs=@var{number}
d77de738
ML
25941Specifies the number of memory-based pseudo-registers GCC uses
25942during code generation. These pseudo-registers are used like real
25943registers, so there is a tradeoff between GCC's ability to fit the
25944code into available registers, and the performance penalty of using
25945memory instead of registers. Note that all modules in a program must
25946be compiled with the same value for this option. Because of that, you
25947must not use this option with GCC's default runtime libraries.
25948
25949@end table
25950
25951@node M32R/D Options
25952@subsection M32R/D Options
25953@cindex M32R/D options
25954
25955These @option{-m} options are defined for Renesas M32R/D architectures:
25956
25957@table @gcctabopt
d77de738 25958@opindex m32r2
ddf6fe37 25959@item -m32r2
d77de738
ML
25960Generate code for the M32R/2@.
25961
d77de738 25962@opindex m32rx
ddf6fe37 25963@item -m32rx
d77de738
ML
25964Generate code for the M32R/X@.
25965
d77de738 25966@opindex m32r
ddf6fe37 25967@item -m32r
d77de738
ML
25968Generate code for the M32R@. This is the default.
25969
d77de738 25970@opindex mmodel=small
ddf6fe37 25971@item -mmodel=small
d77de738
ML
25972Assume all objects live in the lower 16MB of memory (so that their addresses
25973can be loaded with the @code{ld24} instruction), and assume all subroutines
25974are reachable with the @code{bl} instruction.
25975This is the default.
25976
25977The addressability of a particular object can be set with the
25978@code{model} attribute.
25979
d77de738 25980@opindex mmodel=medium
ddf6fe37 25981@item -mmodel=medium
d77de738
ML
25982Assume objects may be anywhere in the 32-bit address space (the compiler
25983generates @code{seth/add3} instructions to load their addresses), and
25984assume all subroutines are reachable with the @code{bl} instruction.
25985
d77de738 25986@opindex mmodel=large
ddf6fe37 25987@item -mmodel=large
d77de738
ML
25988Assume objects may be anywhere in the 32-bit address space (the compiler
25989generates @code{seth/add3} instructions to load their addresses), and
25990assume subroutines may not be reachable with the @code{bl} instruction
25991(the compiler generates the much slower @code{seth/add3/jl}
25992instruction sequence).
25993
d77de738 25994@opindex msdata=none
ddf6fe37 25995@item -msdata=none
d77de738
ML
25996Disable use of the small data area. Variables are put into
25997one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
25998@code{section} attribute has been specified).
25999This is the default.
26000
26001The small data area consists of sections @code{.sdata} and @code{.sbss}.
26002Objects may be explicitly put in the small data area with the
26003@code{section} attribute using one of these sections.
26004
d77de738 26005@opindex msdata=sdata
ddf6fe37 26006@item -msdata=sdata
d77de738
ML
26007Put small global and static data in the small data area, but do not
26008generate special code to reference them.
26009
d77de738 26010@opindex msdata=use
ddf6fe37 26011@item -msdata=use
d77de738
ML
26012Put small global and static data in the small data area, and generate
26013special instructions to reference them.
26014
d77de738
ML
26015@opindex G
26016@cindex smaller data references
f33d7a88 26017@item -G @var{num}
d77de738
ML
26018Put global and static objects less than or equal to @var{num} bytes
26019into the small data or BSS sections instead of the normal data or BSS
26020sections. The default value of @var{num} is 8.
26021The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
26022for this option to have any effect.
26023
26024All modules should be compiled with the same @option{-G @var{num}} value.
26025Compiling with different values of @var{num} may or may not work; if it
26026doesn't the linker gives an error message---incorrect code is not
26027generated.
26028
d77de738 26029@opindex mdebug
ddf6fe37 26030@item -mdebug
d77de738
ML
26031Makes the M32R-specific code in the compiler display some statistics
26032that might help in debugging programs.
26033
d77de738 26034@opindex malign-loops
ddf6fe37 26035@item -malign-loops
d77de738
ML
26036Align all loops to a 32-byte boundary.
26037
d77de738 26038@opindex mno-align-loops
ddf6fe37 26039@item -mno-align-loops
d77de738
ML
26040Do not enforce a 32-byte alignment for loops. This is the default.
26041
d77de738 26042@opindex missue-rate=@var{number}
ddf6fe37 26043@item -missue-rate=@var{number}
d77de738
ML
26044Issue @var{number} instructions per cycle. @var{number} can only be 1
26045or 2.
26046
d77de738 26047@opindex mbranch-cost=@var{number}
ddf6fe37 26048@item -mbranch-cost=@var{number}
d77de738
ML
26049@var{number} can only be 1 or 2. If it is 1 then branches are
26050preferred over conditional code, if it is 2, then the opposite applies.
26051
d77de738 26052@opindex mflush-trap=@var{number}
ddf6fe37 26053@item -mflush-trap=@var{number}
d77de738
ML
26054Specifies the trap number to use to flush the cache. The default is
2605512. Valid numbers are between 0 and 15 inclusive.
26056
d77de738 26057@opindex mno-flush-trap
ddf6fe37 26058@item -mno-flush-trap
d77de738
ML
26059Specifies that the cache cannot be flushed by using a trap.
26060
d77de738 26061@opindex mflush-func=@var{name}
ddf6fe37 26062@item -mflush-func=@var{name}
d77de738
ML
26063Specifies the name of the operating system function to call to flush
26064the cache. The default is @samp{_flush_cache}, but a function call
26065is only used if a trap is not available.
26066
d77de738 26067@opindex mno-flush-func
ddf6fe37 26068@item -mno-flush-func
d77de738
ML
26069Indicates that there is no OS function for flushing the cache.
26070
26071@end table
26072
26073@node M680x0 Options
26074@subsection M680x0 Options
26075@cindex M680x0 options
26076
26077These are the @samp{-m} options defined for M680x0 and ColdFire processors.
26078The default settings depend on which architecture was selected when
26079the compiler was configured; the defaults for the most common choices
26080are given below.
26081
26082@table @gcctabopt
d77de738 26083@opindex march
ddf6fe37 26084@item -march=@var{arch}
d77de738
ML
26085Generate code for a specific M680x0 or ColdFire instruction set
26086architecture. Permissible values of @var{arch} for M680x0
26087architectures are: @samp{68000}, @samp{68010}, @samp{68020},
26088@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
26089architectures are selected according to Freescale's ISA classification
26090and the permissible values are: @samp{isaa}, @samp{isaaplus},
26091@samp{isab} and @samp{isac}.
26092
26093GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
26094code for a ColdFire target. The @var{arch} in this macro is one of the
26095@option{-march} arguments given above.
26096
26097When used together, @option{-march} and @option{-mtune} select code
26098that runs on a family of similar processors but that is optimized
26099for a particular microarchitecture.
26100
d77de738 26101@opindex mcpu
ddf6fe37 26102@item -mcpu=@var{cpu}
d77de738
ML
26103Generate code for a specific M680x0 or ColdFire processor.
26104The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
26105@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
26106and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
26107below, which also classifies the CPUs into families:
26108
26109@multitable @columnfractions 0.20 0.80
26110@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
26111@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}
26112@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
26113@item @samp{5206e} @tab @samp{5206e}
26114@item @samp{5208} @tab @samp{5207} @samp{5208}
26115@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
26116@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
26117@item @samp{5216} @tab @samp{5214} @samp{5216}
26118@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
26119@item @samp{5225} @tab @samp{5224} @samp{5225}
26120@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
26121@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
26122@item @samp{5249} @tab @samp{5249}
26123@item @samp{5250} @tab @samp{5250}
26124@item @samp{5271} @tab @samp{5270} @samp{5271}
26125@item @samp{5272} @tab @samp{5272}
26126@item @samp{5275} @tab @samp{5274} @samp{5275}
26127@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
26128@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
26129@item @samp{5307} @tab @samp{5307}
26130@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
26131@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
26132@item @samp{5407} @tab @samp{5407}
26133@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}
26134@end multitable
26135
26136@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
26137@var{arch} is compatible with @var{cpu}. Other combinations of
26138@option{-mcpu} and @option{-march} are rejected.
26139
26140GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
26141@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
26142where the value of @var{family} is given by the table above.
26143
d77de738 26144@opindex mtune
ddf6fe37 26145@item -mtune=@var{tune}
d77de738
ML
26146Tune the code for a particular microarchitecture within the
26147constraints set by @option{-march} and @option{-mcpu}.
26148The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
26149@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
26150and @samp{cpu32}. The ColdFire microarchitectures
26151are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
26152
26153You can also use @option{-mtune=68020-40} for code that needs
26154to run relatively well on 68020, 68030 and 68040 targets.
26155@option{-mtune=68020-60} is similar but includes 68060 targets
26156as well. These two options select the same tuning decisions as
26157@option{-m68020-40} and @option{-m68020-60} respectively.
26158
26159GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
26160when tuning for 680x0 architecture @var{arch}. It also defines
26161@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
26162option is used. If GCC is tuning for a range of architectures,
26163as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
26164it defines the macros for every architecture in the range.
26165
26166GCC also defines the macro @code{__m@var{uarch}__} when tuning for
26167ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
26168of the arguments given above.
26169
d77de738
ML
26170@opindex m68000
26171@opindex mc68000
ddf6fe37
AA
26172@item -m68000
26173@itemx -mc68000
d77de738
ML
26174Generate output for a 68000. This is the default
26175when the compiler is configured for 68000-based systems.
26176It is equivalent to @option{-march=68000}.
26177
26178Use this option for microcontrollers with a 68000 or EC000 core,
26179including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
26180
d77de738 26181@opindex m68010
ddf6fe37 26182@item -m68010
d77de738
ML
26183Generate output for a 68010. This is the default
26184when the compiler is configured for 68010-based systems.
26185It is equivalent to @option{-march=68010}.
26186
d77de738
ML
26187@opindex m68020
26188@opindex mc68020
ddf6fe37
AA
26189@item -m68020
26190@itemx -mc68020
d77de738
ML
26191Generate output for a 68020. This is the default
26192when the compiler is configured for 68020-based systems.
26193It is equivalent to @option{-march=68020}.
26194
d77de738 26195@opindex m68030
ddf6fe37 26196@item -m68030
d77de738
ML
26197Generate output for a 68030. This is the default when the compiler is
26198configured for 68030-based systems. It is equivalent to
26199@option{-march=68030}.
26200
d77de738 26201@opindex m68040
ddf6fe37 26202@item -m68040
d77de738
ML
26203Generate output for a 68040. This is the default when the compiler is
26204configured for 68040-based systems. It is equivalent to
26205@option{-march=68040}.
26206
26207This option inhibits the use of 68881/68882 instructions that have to be
26208emulated by software on the 68040. Use this option if your 68040 does not
26209have code to emulate those instructions.
26210
d77de738 26211@opindex m68060
ddf6fe37 26212@item -m68060
d77de738
ML
26213Generate output for a 68060. This is the default when the compiler is
26214configured for 68060-based systems. It is equivalent to
26215@option{-march=68060}.
26216
26217This option inhibits the use of 68020 and 68881/68882 instructions that
26218have to be emulated by software on the 68060. Use this option if your 68060
26219does not have code to emulate those instructions.
26220
d77de738 26221@opindex mcpu32
ddf6fe37 26222@item -mcpu32
d77de738
ML
26223Generate output for a CPU32. This is the default
26224when the compiler is configured for CPU32-based systems.
26225It is equivalent to @option{-march=cpu32}.
26226
26227Use this option for microcontrollers with a
26228CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2622968336, 68340, 68341, 68349 and 68360.
26230
d77de738 26231@opindex m5200
ddf6fe37 26232@item -m5200
d77de738
ML
26233Generate output for a 520X ColdFire CPU@. This is the default
26234when the compiler is configured for 520X-based systems.
26235It is equivalent to @option{-mcpu=5206}, and is now deprecated
26236in favor of that option.
26237
26238Use this option for microcontroller with a 5200 core, including
26239the MCF5202, MCF5203, MCF5204 and MCF5206.
26240
d77de738 26241@opindex m5206e
ddf6fe37 26242@item -m5206e
d77de738
ML
26243Generate output for a 5206e ColdFire CPU@. The option is now
26244deprecated in favor of the equivalent @option{-mcpu=5206e}.
26245
d77de738 26246@opindex m528x
ddf6fe37 26247@item -m528x
d77de738
ML
26248Generate output for a member of the ColdFire 528X family.
26249The option is now deprecated in favor of the equivalent
26250@option{-mcpu=528x}.
26251
d77de738 26252@opindex m5307
ddf6fe37 26253@item -m5307
d77de738
ML
26254Generate output for a ColdFire 5307 CPU@. The option is now deprecated
26255in favor of the equivalent @option{-mcpu=5307}.
26256
d77de738 26257@opindex m5407
ddf6fe37 26258@item -m5407
d77de738
ML
26259Generate output for a ColdFire 5407 CPU@. The option is now deprecated
26260in favor of the equivalent @option{-mcpu=5407}.
26261
d77de738 26262@opindex mcfv4e
ddf6fe37 26263@item -mcfv4e
d77de738
ML
26264Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
26265This includes use of hardware floating-point instructions.
26266The option is equivalent to @option{-mcpu=547x}, and is now
26267deprecated in favor of that option.
26268
d77de738 26269@opindex m68020-40
ddf6fe37 26270@item -m68020-40
d77de738
ML
26271Generate output for a 68040, without using any of the new instructions.
26272This results in code that can run relatively efficiently on either a
2627368020/68881 or a 68030 or a 68040. The generated code does use the
2627468881 instructions that are emulated on the 68040.
26275
26276The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26277
d77de738 26278@opindex m68020-60
ddf6fe37 26279@item -m68020-60
d77de738
ML
26280Generate output for a 68060, without using any of the new instructions.
26281This results in code that can run relatively efficiently on either a
2628268020/68881 or a 68030 or a 68040. The generated code does use the
2628368881 instructions that are emulated on the 68060.
26284
26285The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26286
d77de738
ML
26287@opindex mhard-float
26288@opindex m68881
ddf6fe37
AA
26289@item -mhard-float
26290@itemx -m68881
d77de738
ML
26291Generate floating-point instructions. This is the default for 68020
26292and above, and for ColdFire devices that have an FPU@. It defines the
26293macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26294on ColdFire targets.
26295
d77de738 26296@opindex msoft-float
ddf6fe37 26297@item -msoft-float
d77de738
ML
26298Do not generate floating-point instructions; use library calls instead.
26299This is the default for 68000, 68010, and 68832 targets. It is also
26300the default for ColdFire devices that have no FPU.
26301
d77de738
ML
26302@opindex mdiv
26303@opindex mno-div
ddf6fe37
AA
26304@item -mdiv
26305@itemx -mno-div
d77de738
ML
26306Generate (do not generate) ColdFire hardware divide and remainder
26307instructions. If @option{-march} is used without @option{-mcpu},
26308the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26309architectures. Otherwise, the default is taken from the target CPU
26310(either the default CPU, or the one specified by @option{-mcpu}). For
26311example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26312@option{-mcpu=5206e}.
26313
26314GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26315
d77de738 26316@opindex mshort
ddf6fe37 26317@item -mshort
d77de738
ML
26318Consider type @code{int} to be 16 bits wide, like @code{short int}.
26319Additionally, parameters passed on the stack are also aligned to a
2632016-bit boundary even on targets whose API mandates promotion to 32-bit.
26321
d77de738 26322@opindex mno-short
ddf6fe37 26323@item -mno-short
d77de738
ML
26324Do not consider type @code{int} to be 16 bits wide. This is the default.
26325
d77de738
ML
26326@opindex mnobitfield
26327@opindex mno-bitfield
ddf6fe37
AA
26328@item -mnobitfield
26329@itemx -mno-bitfield
d77de738
ML
26330Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26331and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26332
d77de738 26333@opindex mbitfield
ddf6fe37 26334@item -mbitfield
d77de738
ML
26335Do use the bit-field instructions. The @option{-m68020} option implies
26336@option{-mbitfield}. This is the default if you use a configuration
26337designed for a 68020.
26338
d77de738 26339@opindex mrtd
ddf6fe37 26340@item -mrtd
d77de738
ML
26341Use a different function-calling convention, in which functions
26342that take a fixed number of arguments return with the @code{rtd}
26343instruction, which pops their arguments while returning. This
26344saves one instruction in the caller since there is no need to pop
26345the arguments there.
26346
26347This calling convention is incompatible with the one normally
26348used on Unix, so you cannot use it if you need to call libraries
26349compiled with the Unix compiler.
26350
26351Also, you must provide function prototypes for all functions that
26352take variable numbers of arguments (including @code{printf});
26353otherwise incorrect code is generated for calls to those
26354functions.
26355
26356In addition, seriously incorrect code results if you call a
26357function with too many arguments. (Normally, extra arguments are
26358harmlessly ignored.)
26359
26360The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2636168040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26362
26363The default is @option{-mno-rtd}.
26364
d77de738
ML
26365@opindex malign-int
26366@opindex mno-align-int
ddf6fe37
AA
26367@item -malign-int
26368@itemx -mno-align-int
d77de738
ML
26369Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26370@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26371boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26372Aligning variables on 32-bit boundaries produces code that runs somewhat
26373faster on processors with 32-bit busses at the expense of more memory.
26374
26375@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26376aligns structures containing the above types differently than
26377most published application binary interface specifications for the m68k.
26378
26379@opindex mpcrel
26380Use the pc-relative addressing mode of the 68000 directly, instead of
26381using a global offset table. At present, this option implies @option{-fpic},
26382allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26383not presently supported with @option{-mpcrel}, though this could be supported for
2638468020 and higher processors.
26385
d77de738
ML
26386@opindex mno-strict-align
26387@opindex mstrict-align
ddf6fe37
AA
26388@item -mno-strict-align
26389@itemx -mstrict-align
d77de738
ML
26390Do not (do) assume that unaligned memory references are handled by
26391the system.
26392
26393@item -msep-data
26394Generate code that allows the data segment to be located in a different
26395area of memory from the text segment. This allows for execute-in-place in
26396an environment without virtual memory management. This option implies
26397@option{-fPIC}.
26398
26399@item -mno-sep-data
26400Generate code that assumes that the data segment follows the text segment.
26401This is the default.
26402
26403@item -mid-shared-library
26404Generate code that supports shared libraries via the library ID method.
26405This allows for execute-in-place and shared libraries in an environment
26406without virtual memory management. This option implies @option{-fPIC}.
26407
26408@item -mno-id-shared-library
26409Generate code that doesn't assume ID-based shared libraries are being used.
26410This is the default.
26411
26412@item -mshared-library-id=n
26413Specifies the identification number of the ID-based shared library being
26414compiled. Specifying a value of 0 generates more compact code; specifying
26415other values forces the allocation of that number to the current
26416library, but is no more space- or time-efficient than omitting this option.
26417
d77de738
ML
26418@opindex mxgot
26419@opindex mno-xgot
ddf6fe37
AA
26420@item -mxgot
26421@itemx -mno-xgot
d77de738
ML
26422When generating position-independent code for ColdFire, generate code
26423that works if the GOT has more than 8192 entries. This code is
26424larger and slower than code generated without this option. On M680x0
26425processors, this option is not needed; @option{-fPIC} suffices.
26426
26427GCC normally uses a single instruction to load values from the GOT@.
26428While this is relatively efficient, it only works if the GOT
26429is smaller than about 64k. Anything larger causes the linker
26430to report an error such as:
26431
26432@cindex relocation truncated to fit (ColdFire)
26433@smallexample
26434relocation truncated to fit: R_68K_GOT16O foobar
26435@end smallexample
26436
26437If this happens, you should recompile your code with @option{-mxgot}.
26438It should then work with very large GOTs. However, code generated with
26439@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26440the value of a global symbol.
26441
26442Note that some linkers, including newer versions of the GNU linker,
26443can create multiple GOTs and sort GOT entries. If you have such a linker,
26444you should only need to use @option{-mxgot} when compiling a single
26445object file that accesses more than 8192 GOT entries. Very few do.
26446
26447These options have no effect unless GCC is generating
26448position-independent code.
26449
d77de738 26450@opindex mlong-jump-table-offsets
ddf6fe37 26451@item -mlong-jump-table-offsets
d77de738
ML
26452Use 32-bit offsets in @code{switch} tables. The default is to use
2645316-bit offsets.
26454
26455@end table
26456
26457@node MCore Options
26458@subsection MCore Options
26459@cindex MCore options
26460
26461These are the @samp{-m} options defined for the Motorola M*Core
26462processors.
26463
26464@table @gcctabopt
26465
d77de738
ML
26466@opindex mhardlit
26467@opindex mno-hardlit
ddf6fe37
AA
26468@item -mhardlit
26469@itemx -mno-hardlit
d77de738
ML
26470Inline constants into the code stream if it can be done in two
26471instructions or less.
26472
d77de738
ML
26473@opindex mdiv
26474@opindex mno-div
ddf6fe37
AA
26475@item -mdiv
26476@itemx -mno-div
d77de738
ML
26477Use the divide instruction. (Enabled by default).
26478
d77de738
ML
26479@opindex mrelax-immediate
26480@opindex mno-relax-immediate
ddf6fe37
AA
26481@item -mrelax-immediate
26482@itemx -mno-relax-immediate
d77de738
ML
26483Allow arbitrary-sized immediates in bit operations.
26484
d77de738
ML
26485@opindex mwide-bitfields
26486@opindex mno-wide-bitfields
ddf6fe37
AA
26487@item -mwide-bitfields
26488@itemx -mno-wide-bitfields
d77de738
ML
26489Always treat bit-fields as @code{int}-sized.
26490
d77de738
ML
26491@opindex m4byte-functions
26492@opindex mno-4byte-functions
ddf6fe37
AA
26493@item -m4byte-functions
26494@itemx -mno-4byte-functions
d77de738
ML
26495Force all functions to be aligned to a 4-byte boundary.
26496
d77de738
ML
26497@opindex mcallgraph-data
26498@opindex mno-callgraph-data
ddf6fe37
AA
26499@item -mcallgraph-data
26500@itemx -mno-callgraph-data
d77de738
ML
26501Emit callgraph information.
26502
d77de738
ML
26503@opindex mslow-bytes
26504@opindex mno-slow-bytes
ddf6fe37
AA
26505@item -mslow-bytes
26506@itemx -mno-slow-bytes
d77de738
ML
26507Prefer word access when reading byte quantities.
26508
d77de738
ML
26509@opindex mlittle-endian
26510@opindex mbig-endian
ddf6fe37
AA
26511@item -mlittle-endian
26512@itemx -mbig-endian
d77de738
ML
26513Generate code for a little-endian target.
26514
d77de738
ML
26515@opindex m210
26516@opindex m340
ddf6fe37
AA
26517@item -m210
26518@itemx -m340
d77de738
ML
26519Generate code for the 210 processor.
26520
d77de738 26521@opindex mno-lsim
ddf6fe37 26522@item -mno-lsim
d77de738
ML
26523Assume that runtime support has been provided and so omit the
26524simulator library (@file{libsim.a)} from the linker command line.
26525
d77de738 26526@opindex mstack-increment
ddf6fe37 26527@item -mstack-increment=@var{size}
d77de738
ML
26528Set the maximum amount for a single stack increment operation. Large
26529values can increase the speed of programs that contain functions
26530that need a large amount of stack space, but they can also trigger a
26531segmentation fault if the stack is extended too much. The default
26532value is 0x1000.
26533
26534@end table
26535
d77de738
ML
26536@node MicroBlaze Options
26537@subsection MicroBlaze Options
26538@cindex MicroBlaze Options
26539
26540@table @gcctabopt
26541
d77de738 26542@opindex msoft-float
ddf6fe37 26543@item -msoft-float
d77de738
ML
26544Use software emulation for floating point (default).
26545
d77de738 26546@opindex mhard-float
ddf6fe37 26547@item -mhard-float
d77de738
ML
26548Use hardware floating-point instructions.
26549
d77de738 26550@opindex mmemcpy
ddf6fe37 26551@item -mmemcpy
d77de738
ML
26552Do not optimize block moves, use @code{memcpy}.
26553
d77de738 26554@opindex mno-clearbss
ddf6fe37 26555@item -mno-clearbss
d77de738
ML
26556This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26557
d77de738 26558@opindex mcpu=
ddf6fe37 26559@item -mcpu=@var{cpu-type}
d77de738
ML
26560Use features of, and schedule code for, the given CPU.
26561Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26562where @var{X} is a major version, @var{YY} is the minor version, and
26563@var{Z} is compatibility code. Example values are @samp{v3.00.a},
26564@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26565
d77de738 26566@opindex mxl-soft-mul
ddf6fe37 26567@item -mxl-soft-mul
d77de738
ML
26568Use software multiply emulation (default).
26569
d77de738 26570@opindex mxl-soft-div
ddf6fe37 26571@item -mxl-soft-div
d77de738
ML
26572Use software emulation for divides (default).
26573
d77de738 26574@opindex mxl-barrel-shift
ddf6fe37 26575@item -mxl-barrel-shift
d77de738
ML
26576Use the hardware barrel shifter.
26577
d77de738 26578@opindex mxl-pattern-compare
ddf6fe37 26579@item -mxl-pattern-compare
d77de738
ML
26580Use pattern compare instructions.
26581
d77de738 26582@opindex msmall-divides
ddf6fe37 26583@item -msmall-divides
d77de738
ML
26584Use table lookup optimization for small signed integer divisions.
26585
d77de738 26586@opindex mxl-stack-check
ddf6fe37 26587@item -mxl-stack-check
d77de738
ML
26588This option is deprecated. Use @option{-fstack-check} instead.
26589
d77de738 26590@opindex mxl-gp-opt
ddf6fe37 26591@item -mxl-gp-opt
d77de738
ML
26592Use GP-relative @code{.sdata}/@code{.sbss} sections.
26593
d77de738 26594@opindex mxl-multiply-high
ddf6fe37 26595@item -mxl-multiply-high
d77de738
ML
26596Use multiply high instructions for high part of 32x32 multiply.
26597
d77de738 26598@opindex mxl-float-convert
ddf6fe37 26599@item -mxl-float-convert
d77de738
ML
26600Use hardware floating-point conversion instructions.
26601
d77de738 26602@opindex mxl-float-sqrt
ddf6fe37 26603@item -mxl-float-sqrt
d77de738
ML
26604Use hardware floating-point square root instruction.
26605
d77de738 26606@opindex mbig-endian
ddf6fe37 26607@item -mbig-endian
d77de738
ML
26608Generate code for a big-endian target.
26609
d77de738 26610@opindex mlittle-endian
ddf6fe37 26611@item -mlittle-endian
d77de738
ML
26612Generate code for a little-endian target.
26613
d77de738 26614@opindex mxl-reorder
ddf6fe37 26615@item -mxl-reorder
d77de738
ML
26616Use reorder instructions (swap and byte reversed load/store).
26617
26618@item -mxl-mode-@var{app-model}
26619Select application model @var{app-model}. Valid models are
26620@table @samp
26621@item executable
26622normal executable (default), uses startup code @file{crt0.o}.
26623
26624@item xmdstub
26625for use with Xilinx Microprocessor Debugger (XMD) based
26626software intrusive debug agent called xmdstub. This uses startup file
26627@file{crt1.o} and sets the start address of the program to 0x800.
26628
26629@item bootstrap
26630for applications that are loaded using a bootloader.
26631This model uses startup file @file{crt2.o} which does not contain a processor
26632reset vector handler. This is suitable for transferring control on a
26633processor reset to the bootloader rather than the application.
26634
26635@item novectors
26636for applications that do not require any of the
26637MicroBlaze vectors. This option may be useful for applications running
26638within a monitoring application. This model uses @file{crt3.o} as a startup file.
26639@end table
26640
26641Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26642@option{-mxl-mode-@var{app-model}}.
26643
d77de738 26644@opindex mpic-data-is-text-relative
ddf6fe37 26645@item -mpic-data-is-text-relative
d77de738
ML
26646Assume that the displacement between the text and data segments is fixed
26647at static link time. This allows data to be referenced by offset from start of
26648text address instead of GOT since PC-relative addressing is not supported.
26649
26650@end table
26651
26652@node MIPS Options
26653@subsection MIPS Options
26654@cindex MIPS options
26655
26656@table @gcctabopt
26657
d77de738 26658@opindex EB
ddf6fe37 26659@item -EB
d77de738
ML
26660Generate big-endian code.
26661
d77de738 26662@opindex EL
ddf6fe37 26663@item -EL
d77de738
ML
26664Generate little-endian code. This is the default for @samp{mips*el-*-*}
26665configurations.
26666
d77de738 26667@opindex march
ddf6fe37 26668@item -march=@var{arch}
d77de738
ML
26669Generate code that runs on @var{arch}, which can be the name of a
26670generic MIPS ISA, or the name of a particular processor.
26671The ISA names are:
26672@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26673@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26674@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26675@samp{mips64r5} and @samp{mips64r6}.
26676The processor names are:
26677@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26678@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26679@samp{5kc}, @samp{5kf},
26680@samp{20kc},
26681@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26682@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26683@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26684@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26685@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26686@samp{i6400}, @samp{i6500},
26687@samp{interaptiv},
26688@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
26689@samp{gs464e}, @samp{gs264e},
26690@samp{m4k},
26691@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
26692@samp{m5100}, @samp{m5101},
26693@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
26694@samp{orion},
26695@samp{p5600}, @samp{p6600},
26696@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
26697@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
26698@samp{r6000}, @samp{r8000},
26699@samp{rm7000}, @samp{rm9000},
26700@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
26701@samp{sb1},
26702@samp{sr71000},
26703@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
26704@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
26705@samp{xlr} and @samp{xlp}.
26706The special value @samp{from-abi} selects the
26707most compatible architecture for the selected ABI (that is,
26708@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
26709
26710The native Linux/GNU toolchain also supports the value @samp{native},
26711which selects the best architecture option for the host processor.
26712@option{-march=native} has no effect if GCC does not recognize
26713the processor.
26714
26715In processor names, a final @samp{000} can be abbreviated as @samp{k}
26716(for example, @option{-march=r2k}). Prefixes are optional, and
26717@samp{vr} may be written @samp{r}.
26718
26719Names of the form @samp{@var{n}f2_1} refer to processors with
26720FPUs clocked at half the rate of the core, names of the form
26721@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
26722rate as the core, and names of the form @samp{@var{n}f3_2} refer to
26723processors with FPUs clocked a ratio of 3:2 with respect to the core.
26724For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
26725for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
26726accepted as synonyms for @samp{@var{n}f1_1}.
26727
26728GCC defines two macros based on the value of this option. The first
26729is @code{_MIPS_ARCH}, which gives the name of target architecture, as
26730a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
26731where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
26732For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
26733to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
26734
26735Note that the @code{_MIPS_ARCH} macro uses the processor names given
26736above. In other words, it has the full prefix and does not
26737abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
26738the macro names the resolved architecture (either @code{"mips1"} or
26739@code{"mips3"}). It names the default architecture when no
26740@option{-march} option is given.
26741
d77de738 26742@opindex mtune
ddf6fe37 26743@item -mtune=@var{arch}
d77de738
ML
26744Optimize for @var{arch}. Among other things, this option controls
26745the way instructions are scheduled, and the perceived cost of arithmetic
26746operations. The list of @var{arch} values is the same as for
26747@option{-march}.
26748
26749When this option is not used, GCC optimizes for the processor
26750specified by @option{-march}. By using @option{-march} and
26751@option{-mtune} together, it is possible to generate code that
26752runs on a family of processors, but optimize the code for one
26753particular member of that family.
26754
26755@option{-mtune} defines the macros @code{_MIPS_TUNE} and
26756@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
26757@option{-march} ones described above.
26758
d77de738 26759@opindex mips1
ddf6fe37 26760@item -mips1
d77de738
ML
26761Equivalent to @option{-march=mips1}.
26762
d77de738 26763@opindex mips2
ddf6fe37 26764@item -mips2
d77de738
ML
26765Equivalent to @option{-march=mips2}.
26766
d77de738 26767@opindex mips3
ddf6fe37 26768@item -mips3
d77de738
ML
26769Equivalent to @option{-march=mips3}.
26770
d77de738 26771@opindex mips4
ddf6fe37 26772@item -mips4
d77de738
ML
26773Equivalent to @option{-march=mips4}.
26774
d77de738 26775@opindex mips32
ddf6fe37 26776@item -mips32
d77de738
ML
26777Equivalent to @option{-march=mips32}.
26778
d77de738 26779@opindex mips32r3
ddf6fe37 26780@item -mips32r3
d77de738
ML
26781Equivalent to @option{-march=mips32r3}.
26782
d77de738 26783@opindex mips32r5
ddf6fe37 26784@item -mips32r5
d77de738
ML
26785Equivalent to @option{-march=mips32r5}.
26786
d77de738 26787@opindex mips32r6
ddf6fe37 26788@item -mips32r6
d77de738
ML
26789Equivalent to @option{-march=mips32r6}.
26790
d77de738 26791@opindex mips64
ddf6fe37 26792@item -mips64
d77de738
ML
26793Equivalent to @option{-march=mips64}.
26794
d77de738 26795@opindex mips64r2
ddf6fe37 26796@item -mips64r2
d77de738
ML
26797Equivalent to @option{-march=mips64r2}.
26798
d77de738 26799@opindex mips64r3
ddf6fe37 26800@item -mips64r3
d77de738
ML
26801Equivalent to @option{-march=mips64r3}.
26802
d77de738 26803@opindex mips64r5
ddf6fe37 26804@item -mips64r5
d77de738
ML
26805Equivalent to @option{-march=mips64r5}.
26806
d77de738 26807@opindex mips64r6
ddf6fe37 26808@item -mips64r6
d77de738
ML
26809Equivalent to @option{-march=mips64r6}.
26810
d77de738
ML
26811@opindex mips16
26812@opindex mno-mips16
ddf6fe37
AA
26813@item -mips16
26814@itemx -mno-mips16
d77de738
ML
26815Generate (do not generate) MIPS16 code. If GCC is targeting a
26816MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
26817
26818MIPS16 code generation can also be controlled on a per-function basis
26819by means of @code{mips16} and @code{nomips16} attributes.
26820@xref{Function Attributes}, for more information.
26821
d77de738 26822@opindex mflip-mips16
ddf6fe37 26823@item -mflip-mips16
d77de738
ML
26824Generate MIPS16 code on alternating functions. This option is provided
26825for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
26826not intended for ordinary use in compiling user code.
26827
d77de738
ML
26828@opindex minterlink-compressed
26829@opindex mno-interlink-compressed
ddf6fe37
AA
26830@item -minterlink-compressed
26831@itemx -mno-interlink-compressed
d77de738
ML
26832Require (do not require) that code using the standard (uncompressed) MIPS ISA
26833be link-compatible with MIPS16 and microMIPS code, and vice versa.
26834
26835For example, code using the standard ISA encoding cannot jump directly
26836to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
26837@option{-minterlink-compressed} therefore disables direct jumps unless GCC
26838knows that the target of the jump is not compressed.
26839
d77de738
ML
26840@opindex minterlink-mips16
26841@opindex mno-interlink-mips16
ddf6fe37
AA
26842@item -minterlink-mips16
26843@itemx -mno-interlink-mips16
d77de738
ML
26844Aliases of @option{-minterlink-compressed} and
26845@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
26846and are retained for backwards compatibility.
26847
d77de738
ML
26848@opindex mabi=32
26849@opindex mabi=o64
26850@opindex mabi=n32
26851@opindex mabi=64
26852@opindex mabi=eabi
ddf6fe37
AA
26853@item -mabi=32
26854@itemx -mabi=o64
26855@itemx -mabi=n32
26856@itemx -mabi=64
26857@itemx -mabi=eabi
d77de738
ML
26858Generate code for the given ABI@.
26859
26860Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
26861generates 64-bit code when you select a 64-bit architecture, but you
26862can use @option{-mgp32} to get 32-bit code instead.
26863
26864For information about the O64 ABI, see
26865@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
26866
26867GCC supports a variant of the o32 ABI in which floating-point registers
26868are 64 rather than 32 bits wide. You can select this combination with
26869@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
26870and @code{mfhc1} instructions and is therefore only supported for
26871MIPS32R2, MIPS32R3 and MIPS32R5 processors.
26872
26873The register assignments for arguments and return values remain the
26874same, but each scalar value is passed in a single 64-bit register
26875rather than a pair of 32-bit registers. For example, scalar
26876floating-point values are returned in @samp{$f0} only, not a
26877@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
26878remains the same in that the even-numbered double-precision registers
26879are saved.
26880
26881Two additional variants of the o32 ABI are supported to enable
26882a transition from 32-bit to 64-bit registers. These are FPXX
26883(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
26884The FPXX extension mandates that all code must execute correctly
26885when run using 32-bit or 64-bit registers. The code can be interlinked
26886with either FP32 or FP64, but not both.
26887The FP64A extension is similar to the FP64 extension but forbids the
26888use of odd-numbered single-precision registers. This can be used
26889in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
26890processors and allows both FP32 and FP64A code to interlink and
26891run in the same process without changing FPU modes.
26892
d77de738
ML
26893@opindex mabicalls
26894@opindex mno-abicalls
ddf6fe37
AA
26895@item -mabicalls
26896@itemx -mno-abicalls
d77de738
ML
26897Generate (do not generate) code that is suitable for SVR4-style
26898dynamic objects. @option{-mabicalls} is the default for SVR4-based
26899systems.
26900
26901@item -mshared
26902@itemx -mno-shared
26903Generate (do not generate) code that is fully position-independent,
26904and that can therefore be linked into shared libraries. This option
26905only affects @option{-mabicalls}.
26906
26907All @option{-mabicalls} code has traditionally been position-independent,
26908regardless of options like @option{-fPIC} and @option{-fpic}. However,
26909as an extension, the GNU toolchain allows executables to use absolute
26910accesses for locally-binding symbols. It can also use shorter GP
26911initialization sequences and generate direct calls to locally-defined
26912functions. This mode is selected by @option{-mno-shared}.
26913
26914@option{-mno-shared} depends on binutils 2.16 or higher and generates
26915objects that can only be linked by the GNU linker. However, the option
26916does not affect the ABI of the final executable; it only affects the ABI
26917of relocatable objects. Using @option{-mno-shared} generally makes
26918executables both smaller and quicker.
26919
26920@option{-mshared} is the default.
26921
d77de738
ML
26922@opindex mplt
26923@opindex mno-plt
ddf6fe37
AA
26924@item -mplt
26925@itemx -mno-plt
d77de738
ML
26926Assume (do not assume) that the static and dynamic linkers
26927support PLTs and copy relocations. This option only affects
26928@option{-mno-shared -mabicalls}. For the n64 ABI, this option
26929has no effect without @option{-msym32}.
26930
26931You can make @option{-mplt} the default by configuring
26932GCC with @option{--with-mips-plt}. The default is
26933@option{-mno-plt} otherwise.
26934
d77de738
ML
26935@opindex mxgot
26936@opindex mno-xgot
ddf6fe37
AA
26937@item -mxgot
26938@itemx -mno-xgot
d77de738
ML
26939Lift (do not lift) the usual restrictions on the size of the global
26940offset table.
26941
26942GCC normally uses a single instruction to load values from the GOT@.
26943While this is relatively efficient, it only works if the GOT
26944is smaller than about 64k. Anything larger causes the linker
26945to report an error such as:
26946
26947@cindex relocation truncated to fit (MIPS)
26948@smallexample
26949relocation truncated to fit: R_MIPS_GOT16 foobar
26950@end smallexample
26951
26952If this happens, you should recompile your code with @option{-mxgot}.
26953This works with very large GOTs, although the code is also
26954less efficient, since it takes three instructions to fetch the
26955value of a global symbol.
26956
26957Note that some linkers can create multiple GOTs. If you have such a
26958linker, you should only need to use @option{-mxgot} when a single object
26959file accesses more than 64k's worth of GOT entries. Very few do.
26960
26961These options have no effect unless GCC is generating position
26962independent code.
26963
d77de738 26964@opindex mgp32
ddf6fe37 26965@item -mgp32
d77de738
ML
26966Assume that general-purpose registers are 32 bits wide.
26967
d77de738 26968@opindex mgp64
ddf6fe37 26969@item -mgp64
d77de738
ML
26970Assume that general-purpose registers are 64 bits wide.
26971
d77de738 26972@opindex mfp32
ddf6fe37 26973@item -mfp32
d77de738
ML
26974Assume that floating-point registers are 32 bits wide.
26975
d77de738 26976@opindex mfp64
ddf6fe37 26977@item -mfp64
d77de738
ML
26978Assume that floating-point registers are 64 bits wide.
26979
d77de738 26980@opindex mfpxx
ddf6fe37 26981@item -mfpxx
d77de738
ML
26982Do not assume the width of floating-point registers.
26983
d77de738 26984@opindex mhard-float
ddf6fe37 26985@item -mhard-float
d77de738
ML
26986Use floating-point coprocessor instructions.
26987
d77de738 26988@opindex msoft-float
ddf6fe37 26989@item -msoft-float
d77de738
ML
26990Do not use floating-point coprocessor instructions. Implement
26991floating-point calculations using library calls instead.
26992
d77de738 26993@opindex mno-float
ddf6fe37 26994@item -mno-float
d77de738
ML
26995Equivalent to @option{-msoft-float}, but additionally asserts that the
26996program being compiled does not perform any floating-point operations.
26997This option is presently supported only by some bare-metal MIPS
26998configurations, where it may select a special set of libraries
26999that lack all floating-point support (including, for example, the
27000floating-point @code{printf} formats).
27001If code compiled with @option{-mno-float} accidentally contains
27002floating-point operations, it is likely to suffer a link-time
27003or run-time failure.
27004
d77de738 27005@opindex msingle-float
ddf6fe37 27006@item -msingle-float
d77de738
ML
27007Assume that the floating-point coprocessor only supports single-precision
27008operations.
27009
d77de738 27010@opindex mdouble-float
ddf6fe37 27011@item -mdouble-float
d77de738
ML
27012Assume that the floating-point coprocessor supports double-precision
27013operations. This is the default.
27014
d77de738
ML
27015@opindex modd-spreg
27016@opindex mno-odd-spreg
ddf6fe37
AA
27017@item -modd-spreg
27018@itemx -mno-odd-spreg
d77de738
ML
27019Enable the use of odd-numbered single-precision floating-point registers
27020for the o32 ABI. This is the default for processors that are known to
27021support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
27022is set by default.
27023
d77de738
ML
27024@opindex mabs=2008
27025@opindex mabs=legacy
ddf6fe37
AA
27026@item -mabs=2008
27027@itemx -mabs=legacy
d77de738
ML
27028These options control the treatment of the special not-a-number (NaN)
27029IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
27030@code{neg.@i{fmt}} machine instructions.
27031
27032By default or when @option{-mabs=legacy} is used the legacy
27033treatment is selected. In this case these instructions are considered
27034arithmetic and avoided where correct operation is required and the
27035input operand might be a NaN. A longer sequence of instructions that
27036manipulate the sign bit of floating-point datum manually is used
27037instead unless the @option{-ffinite-math-only} option has also been
27038specified.
27039
27040The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
27041this case these instructions are considered non-arithmetic and therefore
27042operating correctly in all cases, including in particular where the
27043input operand is a NaN. These instructions are therefore always used
27044for the respective operations.
27045
d77de738
ML
27046@opindex mnan=2008
27047@opindex mnan=legacy
ddf6fe37
AA
27048@item -mnan=2008
27049@itemx -mnan=legacy
d77de738
ML
27050These options control the encoding of the special not-a-number (NaN)
27051IEEE 754 floating-point data.
27052
27053The @option{-mnan=legacy} option selects the legacy encoding. In this
27054case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
27055significand field being 0, whereas signaling NaNs (sNaNs) are denoted
27056by the first bit of their trailing significand field being 1.
27057
27058The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
27059this case qNaNs are denoted by the first bit of their trailing
27060significand field being 1, whereas sNaNs are denoted by the first bit of
27061their trailing significand field being 0.
27062
27063The default is @option{-mnan=legacy} unless GCC has been configured with
27064@option{--with-nan=2008}.
27065
d77de738
ML
27066@opindex mllsc
27067@opindex mno-llsc
ddf6fe37
AA
27068@item -mllsc
27069@itemx -mno-llsc
d77de738
ML
27070Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
27071implement atomic memory built-in functions. When neither option is
27072specified, GCC uses the instructions if the target architecture
27073supports them.
27074
27075@option{-mllsc} is useful if the runtime environment can emulate the
27076instructions and @option{-mno-llsc} can be useful when compiling for
27077nonstandard ISAs. You can make either option the default by
27078configuring GCC with @option{--with-llsc} and @option{--without-llsc}
27079respectively. @option{--with-llsc} is the default for some
27080configurations; see the installation documentation for details.
27081
d77de738
ML
27082@opindex mdsp
27083@opindex mno-dsp
ddf6fe37
AA
27084@item -mdsp
27085@itemx -mno-dsp
d77de738
ML
27086Use (do not use) revision 1 of the MIPS DSP ASE@.
27087@xref{MIPS DSP Built-in Functions}. This option defines the
27088preprocessor macro @code{__mips_dsp}. It also defines
27089@code{__mips_dsp_rev} to 1.
27090
d77de738
ML
27091@opindex mdspr2
27092@opindex mno-dspr2
ddf6fe37
AA
27093@item -mdspr2
27094@itemx -mno-dspr2
d77de738
ML
27095Use (do not use) revision 2 of the MIPS DSP ASE@.
27096@xref{MIPS DSP Built-in Functions}. This option defines the
27097preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
27098It also defines @code{__mips_dsp_rev} to 2.
27099
d77de738
ML
27100@opindex msmartmips
27101@opindex mno-smartmips
ddf6fe37
AA
27102@item -msmartmips
27103@itemx -mno-smartmips
d77de738
ML
27104Use (do not use) the MIPS SmartMIPS ASE.
27105
d77de738
ML
27106@opindex mpaired-single
27107@opindex mno-paired-single
ddf6fe37
AA
27108@item -mpaired-single
27109@itemx -mno-paired-single
d77de738
ML
27110Use (do not use) paired-single floating-point instructions.
27111@xref{MIPS Paired-Single Support}. This option requires
27112hardware floating-point support to be enabled.
27113
d77de738
ML
27114@opindex mdmx
27115@opindex mno-mdmx
ddf6fe37
AA
27116@item -mdmx
27117@itemx -mno-mdmx
d77de738
ML
27118Use (do not use) MIPS Digital Media Extension instructions.
27119This option can only be used when generating 64-bit code and requires
27120hardware floating-point support to be enabled.
27121
d77de738
ML
27122@opindex mips3d
27123@opindex mno-mips3d
ddf6fe37
AA
27124@item -mips3d
27125@itemx -mno-mips3d
d77de738
ML
27126Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
27127The option @option{-mips3d} implies @option{-mpaired-single}.
27128
d77de738
ML
27129@opindex mmicromips
27130@opindex mno-mmicromips
ddf6fe37
AA
27131@item -mmicromips
27132@itemx -mno-micromips
d77de738
ML
27133Generate (do not generate) microMIPS code.
27134
27135MicroMIPS code generation can also be controlled on a per-function basis
27136by means of @code{micromips} and @code{nomicromips} attributes.
27137@xref{Function Attributes}, for more information.
27138
d77de738
ML
27139@opindex mmt
27140@opindex mno-mt
ddf6fe37
AA
27141@item -mmt
27142@itemx -mno-mt
d77de738
ML
27143Use (do not use) MT Multithreading instructions.
27144
d77de738
ML
27145@opindex mmcu
27146@opindex mno-mcu
ddf6fe37
AA
27147@item -mmcu
27148@itemx -mno-mcu
d77de738
ML
27149Use (do not use) the MIPS MCU ASE instructions.
27150
d77de738
ML
27151@opindex meva
27152@opindex mno-eva
ddf6fe37
AA
27153@item -meva
27154@itemx -mno-eva
d77de738
ML
27155Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
27156
d77de738
ML
27157@opindex mvirt
27158@opindex mno-virt
ddf6fe37
AA
27159@item -mvirt
27160@itemx -mno-virt
d77de738
ML
27161Use (do not use) the MIPS Virtualization (VZ) instructions.
27162
d77de738
ML
27163@opindex mxpa
27164@opindex mno-xpa
ddf6fe37
AA
27165@item -mxpa
27166@itemx -mno-xpa
d77de738
ML
27167Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
27168
d77de738
ML
27169@opindex mcrc
27170@opindex mno-crc
ddf6fe37
AA
27171@item -mcrc
27172@itemx -mno-crc
d77de738
ML
27173Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
27174
d77de738
ML
27175@opindex mginv
27176@opindex mno-ginv
ddf6fe37
AA
27177@item -mginv
27178@itemx -mno-ginv
d77de738
ML
27179Use (do not use) the MIPS Global INValidate (GINV) instructions.
27180
d77de738
ML
27181@opindex mloongson-mmi
27182@opindex mno-loongson-mmi
ddf6fe37
AA
27183@item -mloongson-mmi
27184@itemx -mno-loongson-mmi
d77de738
ML
27185Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
27186
d77de738
ML
27187@opindex mloongson-ext
27188@opindex mno-loongson-ext
ddf6fe37
AA
27189@item -mloongson-ext
27190@itemx -mno-loongson-ext
d77de738
ML
27191Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
27192
d77de738
ML
27193@opindex mloongson-ext2
27194@opindex mno-loongson-ext2
ddf6fe37
AA
27195@item -mloongson-ext2
27196@itemx -mno-loongson-ext2
d77de738
ML
27197Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
27198
d77de738 27199@opindex mlong64
ddf6fe37 27200@item -mlong64
d77de738
ML
27201Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
27202an explanation of the default and the way that the pointer size is
27203determined.
27204
d77de738 27205@opindex mlong32
ddf6fe37 27206@item -mlong32
d77de738
ML
27207Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
27208
27209The default size of @code{int}s, @code{long}s and pointers depends on
27210the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
27211uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2721232-bit @code{long}s. Pointers are the same size as @code{long}s,
27213or the same size as integer registers, whichever is smaller.
27214
d77de738
ML
27215@opindex msym32
27216@opindex mno-sym32
ddf6fe37
AA
27217@item -msym32
27218@itemx -mno-sym32
d77de738
ML
27219Assume (do not assume) that all symbols have 32-bit values, regardless
27220of the selected ABI@. This option is useful in combination with
27221@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
27222to generate shorter and faster references to symbolic addresses.
27223
d77de738 27224@opindex G
ddf6fe37 27225@item -G @var{num}
d77de738
ML
27226Put definitions of externally-visible data in a small data section
27227if that data is no bigger than @var{num} bytes. GCC can then generate
27228more efficient accesses to the data; see @option{-mgpopt} for details.
27229
27230The default @option{-G} option depends on the configuration.
27231
d77de738
ML
27232@opindex mlocal-sdata
27233@opindex mno-local-sdata
ddf6fe37
AA
27234@item -mlocal-sdata
27235@itemx -mno-local-sdata
d77de738
ML
27236Extend (do not extend) the @option{-G} behavior to local data too,
27237such as to static variables in C@. @option{-mlocal-sdata} is the
27238default for all configurations.
27239
27240If the linker complains that an application is using too much small data,
27241you might want to try rebuilding the less performance-critical parts with
27242@option{-mno-local-sdata}. You might also want to build large
27243libraries with @option{-mno-local-sdata}, so that the libraries leave
27244more room for the main program.
27245
d77de738
ML
27246@opindex mextern-sdata
27247@opindex mno-extern-sdata
ddf6fe37
AA
27248@item -mextern-sdata
27249@itemx -mno-extern-sdata
d77de738
ML
27250Assume (do not assume) that externally-defined data is in
27251a small data section if the size of that data is within the @option{-G} limit.
27252@option{-mextern-sdata} is the default for all configurations.
27253
27254If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
27255@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
27256that is no bigger than @var{num} bytes, you must make sure that @var{Var}
27257is placed in a small data section. If @var{Var} is defined by another
27258module, you must either compile that module with a high-enough
27259@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
27260definition. If @var{Var} is common, you must link the application
27261with a high-enough @option{-G} setting.
27262
27263The easiest way of satisfying these restrictions is to compile
27264and link every module with the same @option{-G} option. However,
27265you may wish to build a library that supports several different
27266small data limits. You can do this by compiling the library with
27267the highest supported @option{-G} setting and additionally using
27268@option{-mno-extern-sdata} to stop the library from making assumptions
27269about externally-defined data.
27270
d77de738
ML
27271@opindex mgpopt
27272@opindex mno-gpopt
ddf6fe37
AA
27273@item -mgpopt
27274@itemx -mno-gpopt
d77de738
ML
27275Use (do not use) GP-relative accesses for symbols that are known to be
27276in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27277@option{-mextern-sdata}. @option{-mgpopt} is the default for all
27278configurations.
27279
27280@option{-mno-gpopt} is useful for cases where the @code{$gp} register
27281might not hold the value of @code{_gp}. For example, if the code is
27282part of a library that might be used in a boot monitor, programs that
27283call boot monitor routines pass an unknown value in @code{$gp}.
27284(In such situations, the boot monitor itself is usually compiled
27285with @option{-G0}.)
27286
27287@option{-mno-gpopt} implies @option{-mno-local-sdata} and
27288@option{-mno-extern-sdata}.
27289
d77de738
ML
27290@opindex membedded-data
27291@opindex mno-embedded-data
ddf6fe37
AA
27292@item -membedded-data
27293@itemx -mno-embedded-data
d77de738
ML
27294Allocate variables to the read-only data section first if possible, then
27295next in the small data section if possible, otherwise in data. This gives
27296slightly slower code than the default, but reduces the amount of RAM required
27297when executing, and thus may be preferred for some embedded systems.
27298
d77de738
ML
27299@opindex muninit-const-in-rodata
27300@opindex mno-uninit-const-in-rodata
ddf6fe37
AA
27301@item -muninit-const-in-rodata
27302@itemx -mno-uninit-const-in-rodata
d77de738
ML
27303Put uninitialized @code{const} variables in the read-only data section.
27304This option is only meaningful in conjunction with @option{-membedded-data}.
27305
d77de738 27306@opindex mcode-readable
ddf6fe37 27307@item -mcode-readable=@var{setting}
d77de738
ML
27308Specify whether GCC may generate code that reads from executable sections.
27309There are three possible settings:
27310
27311@table @gcctabopt
27312@item -mcode-readable=yes
27313Instructions may freely access executable sections. This is the
27314default setting.
27315
27316@item -mcode-readable=pcrel
27317MIPS16 PC-relative load instructions can access executable sections,
27318but other instructions must not do so. This option is useful on 4KSc
27319and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27320It is also useful on processors that can be configured to have a dual
27321instruction/data SRAM interface and that, like the M4K, automatically
27322redirect PC-relative loads to the instruction RAM.
27323
27324@item -mcode-readable=no
27325Instructions must not access executable sections. This option can be
27326useful on targets that are configured to have a dual instruction/data
27327SRAM interface but that (unlike the M4K) do not automatically redirect
27328PC-relative loads to the instruction RAM.
27329@end table
27330
d77de738
ML
27331@opindex msplit-addresses
27332@opindex mno-split-addresses
ddf6fe37
AA
27333@item -msplit-addresses
27334@itemx -mno-split-addresses
d77de738
ML
27335Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27336relocation operators. This option has been superseded by
27337@option{-mexplicit-relocs} but is retained for backwards compatibility.
27338
d77de738
ML
27339@opindex mexplicit-relocs
27340@opindex mno-explicit-relocs
ddf6fe37
AA
27341@item -mexplicit-relocs
27342@itemx -mno-explicit-relocs
d77de738
ML
27343Use (do not use) assembler relocation operators when dealing with symbolic
27344addresses. The alternative, selected by @option{-mno-explicit-relocs},
27345is to use assembler macros instead.
27346
27347@option{-mexplicit-relocs} is the default if GCC was configured
27348to use an assembler that supports relocation operators.
27349
d77de738
ML
27350@opindex mcheck-zero-division
27351@opindex mno-check-zero-division
ddf6fe37
AA
27352@item -mcheck-zero-division
27353@itemx -mno-check-zero-division
d77de738
ML
27354Trap (do not trap) on integer division by zero.
27355
27356The default is @option{-mcheck-zero-division}.
27357
d77de738
ML
27358@opindex mdivide-traps
27359@opindex mdivide-breaks
ddf6fe37
AA
27360@item -mdivide-traps
27361@itemx -mdivide-breaks
d77de738
ML
27362MIPS systems check for division by zero by generating either a
27363conditional trap or a break instruction. Using traps results in
27364smaller code, but is only supported on MIPS II and later. Also, some
27365versions of the Linux kernel have a bug that prevents trap from
27366generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27367allow conditional traps on architectures that support them and
27368@option{-mdivide-breaks} to force the use of breaks.
27369
27370The default is usually @option{-mdivide-traps}, but this can be
27371overridden at configure time using @option{--with-divide=breaks}.
27372Divide-by-zero checks can be completely disabled using
27373@option{-mno-check-zero-division}.
27374
d77de738
ML
27375@opindex mload-store-pairs
27376@opindex mno-load-store-pairs
ddf6fe37
AA
27377@item -mload-store-pairs
27378@itemx -mno-load-store-pairs
d77de738
ML
27379Enable (disable) an optimization that pairs consecutive load or store
27380instructions to enable load/store bonding. This option is enabled by
27381default but only takes effect when the selected architecture is known
27382to support bonding.
27383
d77de738
ML
27384@opindex munaligned-access
27385@opindex mno-unaligned-access
ddf6fe37
AA
27386@item -munaligned-access
27387@itemx -mno-unaligned-access
d77de738
ML
27388Enable (disable) direct unaligned access for MIPS Release 6.
27389MIPSr6 requires load/store unaligned-access support,
27390by hardware or trap&emulate.
27391So @option{-mno-unaligned-access} may be needed by kernel.
27392
d77de738
ML
27393@opindex mmemcpy
27394@opindex mno-memcpy
ddf6fe37
AA
27395@item -mmemcpy
27396@itemx -mno-memcpy
d77de738
ML
27397Force (do not force) the use of @code{memcpy} for non-trivial block
27398moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27399most constant-sized copies.
27400
d77de738
ML
27401@opindex mlong-calls
27402@opindex mno-long-calls
ddf6fe37
AA
27403@item -mlong-calls
27404@itemx -mno-long-calls
d77de738
ML
27405Disable (do not disable) use of the @code{jal} instruction. Calling
27406functions using @code{jal} is more efficient but requires the caller
27407and callee to be in the same 256 megabyte segment.
27408
27409This option has no effect on abicalls code. The default is
27410@option{-mno-long-calls}.
27411
d77de738
ML
27412@opindex mmad
27413@opindex mno-mad
ddf6fe37
AA
27414@item -mmad
27415@itemx -mno-mad
d77de738
ML
27416Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27417instructions, as provided by the R4650 ISA@.
27418
d77de738
ML
27419@opindex mimadd
27420@opindex mno-imadd
ddf6fe37
AA
27421@item -mimadd
27422@itemx -mno-imadd
d77de738
ML
27423Enable (disable) use of the @code{madd} and @code{msub} integer
27424instructions. The default is @option{-mimadd} on architectures
27425that support @code{madd} and @code{msub} except for the 74k
27426architecture where it was found to generate slower code.
27427
d77de738
ML
27428@opindex mfused-madd
27429@opindex mno-fused-madd
ddf6fe37
AA
27430@item -mfused-madd
27431@itemx -mno-fused-madd
d77de738
ML
27432Enable (disable) use of the floating-point multiply-accumulate
27433instructions, when they are available. The default is
27434@option{-mfused-madd}.
27435
27436On the R8000 CPU when multiply-accumulate instructions are used,
27437the intermediate product is calculated to infinite precision
27438and is not subject to the FCSR Flush to Zero bit. This may be
27439undesirable in some circumstances. On other processors the result
27440is numerically identical to the equivalent computation using
27441separate multiply, add, subtract and negate instructions.
27442
d77de738 27443@opindex nocpp
ddf6fe37 27444@item -nocpp
d77de738
ML
27445Tell the MIPS assembler to not run its preprocessor over user
27446assembler files (with a @samp{.s} suffix) when assembling them.
27447
d77de738
ML
27448@opindex mfix-24k
27449@opindex mno-fix-24k
ddf6fe37
AA
27450@item -mfix-24k
27451@itemx -mno-fix-24k
d77de738
ML
27452Work around the 24K E48 (lost data on stores during refill) errata.
27453The workarounds are implemented by the assembler rather than by GCC@.
27454
d77de738
ML
27455@opindex mfix-r4000
27456@opindex mno-fix-r4000
ddf6fe37
AA
27457@item -mfix-r4000
27458@itemx -mno-fix-r4000
d77de738
ML
27459Work around certain R4000 CPU errata:
27460@itemize @minus
27461@item
27462A double-word or a variable shift may give an incorrect result if executed
27463immediately after starting an integer division.
27464@item
27465A double-word or a variable shift may give an incorrect result if executed
27466while an integer multiplication is in progress.
27467@item
27468An integer division may give an incorrect result if started in a delay slot
27469of a taken branch or a jump.
27470@end itemize
27471
d77de738
ML
27472@opindex mfix-r4400
27473@opindex mno-fix-r4400
ddf6fe37
AA
27474@item -mfix-r4400
27475@itemx -mno-fix-r4400
d77de738
ML
27476Work around certain R4400 CPU errata:
27477@itemize @minus
27478@item
27479A double-word or a variable shift may give an incorrect result if executed
27480immediately after starting an integer division.
27481@end itemize
27482
d77de738
ML
27483@opindex mfix-r10000
27484@opindex mno-fix-r10000
ddf6fe37
AA
27485@item -mfix-r10000
27486@itemx -mno-fix-r10000
d77de738
ML
27487Work around certain R10000 errata:
27488@itemize @minus
27489@item
27490@code{ll}/@code{sc} sequences may not behave atomically on revisions
27491prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27492@end itemize
27493
27494This option can only be used if the target architecture supports
27495branch-likely instructions. @option{-mfix-r10000} is the default when
27496@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27497otherwise.
27498
ddf6fe37 27499@opindex mfix-r5900
d77de738
ML
27500@item -mfix-r5900
27501@itemx -mno-fix-r5900
d77de738
ML
27502Do not attempt to schedule the preceding instruction into the delay slot
27503of a branch instruction placed at the end of a short loop of six
27504instructions or fewer and always schedule a @code{nop} instruction there
27505instead. The short loop bug under certain conditions causes loops to
27506execute only once or twice, due to a hardware bug in the R5900 chip. The
27507workaround is implemented by the assembler rather than by GCC@.
27508
ddf6fe37 27509@opindex mfix-rm7000
d77de738
ML
27510@item -mfix-rm7000
27511@itemx -mno-fix-rm7000
d77de738
ML
27512Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27513workarounds are implemented by the assembler rather than by GCC@.
27514
ddf6fe37 27515@opindex mfix-vr4120
d77de738
ML
27516@item -mfix-vr4120
27517@itemx -mno-fix-vr4120
d77de738
ML
27518Work around certain VR4120 errata:
27519@itemize @minus
27520@item
27521@code{dmultu} does not always produce the correct result.
27522@item
27523@code{div} and @code{ddiv} do not always produce the correct result if one
27524of the operands is negative.
27525@end itemize
27526The workarounds for the division errata rely on special functions in
27527@file{libgcc.a}. At present, these functions are only provided by
27528the @code{mips64vr*-elf} configurations.
27529
27530Other VR4120 errata require a NOP to be inserted between certain pairs of
27531instructions. These errata are handled by the assembler, not by GCC itself.
27532
d77de738 27533@opindex mfix-vr4130
ddf6fe37 27534@item -mfix-vr4130
d77de738
ML
27535Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27536workarounds are implemented by the assembler rather than by GCC,
27537although GCC avoids using @code{mflo} and @code{mfhi} if the
27538VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27539instructions are available instead.
27540
ddf6fe37 27541@opindex mfix-sb1
d77de738
ML
27542@item -mfix-sb1
27543@itemx -mno-fix-sb1
d77de738
ML
27544Work around certain SB-1 CPU core errata.
27545(This flag currently works around the SB-1 revision 2
27546``F1'' and ``F2'' floating-point errata.)
27547
d77de738 27548@opindex mr10k-cache-barrier
ddf6fe37 27549@item -mr10k-cache-barrier=@var{setting}
d77de738
ML
27550Specify whether GCC should insert cache barriers to avoid the
27551side effects of speculation on R10K processors.
27552
27553In common with many processors, the R10K tries to predict the outcome
27554of a conditional branch and speculatively executes instructions from
27555the ``taken'' branch. It later aborts these instructions if the
27556predicted outcome is wrong. However, on the R10K, even aborted
27557instructions can have side effects.
27558
27559This problem only affects kernel stores and, depending on the system,
27560kernel loads. As an example, a speculatively-executed store may load
27561the target memory into cache and mark the cache line as dirty, even if
27562the store itself is later aborted. If a DMA operation writes to the
27563same area of memory before the ``dirty'' line is flushed, the cached
27564data overwrites the DMA-ed data. See the R10K processor manual
27565for a full description, including other potential problems.
27566
27567One workaround is to insert cache barrier instructions before every memory
27568access that might be speculatively executed and that might have side
27569effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27570controls GCC's implementation of this workaround. It assumes that
27571aborted accesses to any byte in the following regions does not have
27572side effects:
27573
27574@enumerate
27575@item
27576the memory occupied by the current function's stack frame;
27577
27578@item
27579the memory occupied by an incoming stack argument;
27580
27581@item
27582the memory occupied by an object with a link-time-constant address.
27583@end enumerate
27584
27585It is the kernel's responsibility to ensure that speculative
27586accesses to these regions are indeed safe.
27587
27588If the input program contains a function declaration such as:
27589
27590@smallexample
27591void foo (void);
27592@end smallexample
27593
27594then the implementation of @code{foo} must allow @code{j foo} and
27595@code{jal foo} to be executed speculatively. GCC honors this
27596restriction for functions it compiles itself. It expects non-GCC
27597functions (such as hand-written assembly code) to do the same.
27598
27599The option has three forms:
27600
27601@table @gcctabopt
27602@item -mr10k-cache-barrier=load-store
27603Insert a cache barrier before a load or store that might be
27604speculatively executed and that might have side effects even
27605if aborted.
27606
27607@item -mr10k-cache-barrier=store
27608Insert a cache barrier before a store that might be speculatively
27609executed and that might have side effects even if aborted.
27610
27611@item -mr10k-cache-barrier=none
27612Disable the insertion of cache barriers. This is the default setting.
27613@end table
27614
ddf6fe37 27615@opindex mflush-func
d77de738
ML
27616@item -mflush-func=@var{func}
27617@itemx -mno-flush-func
d77de738
ML
27618Specifies the function to call to flush the I and D caches, or to not
27619call any such function. If called, the function must take the same
27620arguments as the common @code{_flush_func}, that is, the address of the
27621memory range for which the cache is being flushed, the size of the
27622memory range, and the number 3 (to flush both caches). The default
27623depends on the target GCC was configured for, but commonly is either
27624@code{_flush_func} or @code{__cpu_flush}.
27625
d77de738 27626@opindex mbranch-cost
ddf6fe37 27627@item mbranch-cost=@var{num}
d77de738
ML
27628Set the cost of branches to roughly @var{num} ``simple'' instructions.
27629This cost is only a heuristic and is not guaranteed to produce
27630consistent results across releases. A zero cost redundantly selects
27631the default, which is based on the @option{-mtune} setting.
27632
d77de738
ML
27633@opindex mbranch-likely
27634@opindex mno-branch-likely
ddf6fe37
AA
27635@item -mbranch-likely
27636@itemx -mno-branch-likely
d77de738
ML
27637Enable or disable use of Branch Likely instructions, regardless of the
27638default for the selected architecture. By default, Branch Likely
27639instructions may be generated if they are supported by the selected
27640architecture. An exception is for the MIPS32 and MIPS64 architectures
27641and processors that implement those architectures; for those, Branch
27642Likely instructions are not be generated by default because the MIPS32
27643and MIPS64 architectures specifically deprecate their use.
27644
d77de738
ML
27645@opindex mcompact-branches=never
27646@opindex mcompact-branches=optimal
27647@opindex mcompact-branches=always
ddf6fe37
AA
27648@item -mcompact-branches=never
27649@itemx -mcompact-branches=optimal
27650@itemx -mcompact-branches=always
d77de738
ML
27651These options control which form of branches will be generated. The
27652default is @option{-mcompact-branches=optimal}.
27653
27654The @option{-mcompact-branches=never} option ensures that compact branch
27655instructions will never be generated.
27656
27657The @option{-mcompact-branches=always} option ensures that a compact
27658branch instruction will be generated if available for MIPS Release 6 onwards.
27659If a compact branch instruction is not available (or pre-R6),
27660a delay slot form of the branch will be used instead.
27661
27662If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27663The behaviour for MIPS16/microMIPS may change in future,
27664since they do have some compact branch instructions.
27665
27666The @option{-mcompact-branches=optimal} option will cause a delay slot
27667branch to be used if one is available in the current ISA and the delay
27668slot is successfully filled. If the delay slot is not filled, a compact
27669branch will be chosen if one is available.
27670
ddf6fe37 27671@opindex mfp-exceptions
d77de738
ML
27672@item -mfp-exceptions
27673@itemx -mno-fp-exceptions
d77de738
ML
27674Specifies whether FP exceptions are enabled. This affects how
27675FP instructions are scheduled for some processors.
27676The default is that FP exceptions are
27677enabled.
27678
27679For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2768064-bit code, then we can use both FP pipes. Otherwise, we can only use one
27681FP pipe.
27682
ddf6fe37 27683@opindex mvr4130-align
d77de738
ML
27684@item -mvr4130-align
27685@itemx -mno-vr4130-align
d77de738
ML
27686The VR4130 pipeline is two-way superscalar, but can only issue two
27687instructions together if the first one is 8-byte aligned. When this
27688option is enabled, GCC aligns pairs of instructions that it
27689thinks should execute in parallel.
27690
27691This option only has an effect when optimizing for the VR4130.
27692It normally makes code faster, but at the expense of making it bigger.
27693It is enabled by default at optimization level @option{-O3}.
27694
ddf6fe37 27695@opindex msynci
d77de738
ML
27696@item -msynci
27697@itemx -mno-synci
d77de738
ML
27698Enable (disable) generation of @code{synci} instructions on
27699architectures that support it. The @code{synci} instructions (if
27700enabled) are generated when @code{__builtin___clear_cache} is
27701compiled.
27702
27703This option defaults to @option{-mno-synci}, but the default can be
27704overridden by configuring GCC with @option{--with-synci}.
27705
27706When compiling code for single processor systems, it is generally safe
27707to use @code{synci}. However, on many multi-core (SMP) systems, it
27708does not invalidate the instruction caches on all cores and may lead
27709to undefined behavior.
27710
ddf6fe37 27711@opindex mrelax-pic-calls
d77de738
ML
27712@item -mrelax-pic-calls
27713@itemx -mno-relax-pic-calls
d77de738
ML
27714Try to turn PIC calls that are normally dispatched via register
27715@code{$25} into direct calls. This is only possible if the linker can
27716resolve the destination at link time and if the destination is within
27717range for a direct call.
27718
27719@option{-mrelax-pic-calls} is the default if GCC was configured to use
27720an assembler and a linker that support the @code{.reloc} assembly
27721directive and @option{-mexplicit-relocs} is in effect. With
27722@option{-mno-explicit-relocs}, this optimization can be performed by the
27723assembler and the linker alone without help from the compiler.
27724
d77de738
ML
27725@opindex mmcount-ra-address
27726@opindex mno-mcount-ra-address
ddf6fe37
AA
27727@item -mmcount-ra-address
27728@itemx -mno-mcount-ra-address
d77de738
ML
27729Emit (do not emit) code that allows @code{_mcount} to modify the
27730calling function's return address. When enabled, this option extends
27731the usual @code{_mcount} interface with a new @var{ra-address}
27732parameter, which has type @code{intptr_t *} and is passed in register
27733@code{$12}. @code{_mcount} can then modify the return address by
27734doing both of the following:
27735@itemize
27736@item
27737Returning the new address in register @code{$31}.
27738@item
27739Storing the new address in @code{*@var{ra-address}},
27740if @var{ra-address} is nonnull.
27741@end itemize
27742
27743The default is @option{-mno-mcount-ra-address}.
27744
ddf6fe37 27745@opindex mframe-header-opt
d77de738
ML
27746@item -mframe-header-opt
27747@itemx -mno-frame-header-opt
d77de738
ML
27748Enable (disable) frame header optimization in the o32 ABI. When using the
27749o32 ABI, calling functions will allocate 16 bytes on the stack for the called
27750function to write out register arguments. When enabled, this optimization
27751will suppress the allocation of the frame header if it can be determined that
27752it is unused.
27753
27754This optimization is off by default at all optimization levels.
27755
ddf6fe37 27756@opindex mlxc1-sxc1
d77de738
ML
27757@item -mlxc1-sxc1
27758@itemx -mno-lxc1-sxc1
d77de738
ML
27759When applicable, enable (disable) the generation of @code{lwxc1},
27760@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
27761
ddf6fe37 27762@opindex mmadd4
d77de738
ML
27763@item -mmadd4
27764@itemx -mno-madd4
d77de738
ML
27765When applicable, enable (disable) the generation of 4-operand @code{madd.s},
27766@code{madd.d} and related instructions. Enabled by default.
27767
27768@end table
27769
27770@node MMIX Options
27771@subsection MMIX Options
27772@cindex MMIX Options
27773
27774These options are defined for the MMIX:
27775
27776@table @gcctabopt
d77de738
ML
27777@opindex mlibfuncs
27778@opindex mno-libfuncs
ddf6fe37
AA
27779@item -mlibfuncs
27780@itemx -mno-libfuncs
d77de738
ML
27781Specify that intrinsic library functions are being compiled, passing all
27782values in registers, no matter the size.
27783
d77de738
ML
27784@opindex mepsilon
27785@opindex mno-epsilon
ddf6fe37
AA
27786@item -mepsilon
27787@itemx -mno-epsilon
d77de738
ML
27788Generate floating-point comparison instructions that compare with respect
27789to the @code{rE} epsilon register.
27790
d77de738
ML
27791@opindex mabi=mmixware
27792@opindex mabi=gnu
ddf6fe37
AA
27793@item -mabi=mmixware
27794@itemx -mabi=gnu
d77de738
ML
27795Generate code that passes function parameters and return values that (in
27796the called function) are seen as registers @code{$0} and up, as opposed to
27797the GNU ABI which uses global registers @code{$231} and up.
27798
d77de738
ML
27799@opindex mzero-extend
27800@opindex mno-zero-extend
ddf6fe37
AA
27801@item -mzero-extend
27802@itemx -mno-zero-extend
d77de738
ML
27803When reading data from memory in sizes shorter than 64 bits, use (do not
27804use) zero-extending load instructions by default, rather than
27805sign-extending ones.
27806
d77de738
ML
27807@opindex mknuthdiv
27808@opindex mno-knuthdiv
ddf6fe37
AA
27809@item -mknuthdiv
27810@itemx -mno-knuthdiv
d77de738
ML
27811Make the result of a division yielding a remainder have the same sign as
27812the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
27813remainder follows the sign of the dividend. Both methods are
27814arithmetically valid, the latter being almost exclusively used.
27815
d77de738
ML
27816@opindex mtoplevel-symbols
27817@opindex mno-toplevel-symbols
ddf6fe37
AA
27818@item -mtoplevel-symbols
27819@itemx -mno-toplevel-symbols
d77de738
ML
27820Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
27821code can be used with the @code{PREFIX} assembly directive.
27822
d77de738 27823@opindex melf
ddf6fe37 27824@item -melf
d77de738
ML
27825Generate an executable in the ELF format, rather than the default
27826@samp{mmo} format used by the @command{mmix} simulator.
27827
d77de738
ML
27828@opindex mbranch-predict
27829@opindex mno-branch-predict
ddf6fe37
AA
27830@item -mbranch-predict
27831@itemx -mno-branch-predict
d77de738
ML
27832Use (do not use) the probable-branch instructions, when static branch
27833prediction indicates a probable branch.
27834
d77de738
ML
27835@opindex mbase-addresses
27836@opindex mno-base-addresses
ddf6fe37
AA
27837@item -mbase-addresses
27838@itemx -mno-base-addresses
d77de738
ML
27839Generate (do not generate) code that uses @emph{base addresses}. Using a
27840base address automatically generates a request (handled by the assembler
27841and the linker) for a constant to be set up in a global register. The
27842register is used for one or more base address requests within the range 0
27843to 255 from the value held in the register. The generally leads to short
27844and fast code, but the number of different data items that can be
27845addressed is limited. This means that a program that uses lots of static
27846data may require @option{-mno-base-addresses}.
27847
d77de738
ML
27848@opindex msingle-exit
27849@opindex mno-single-exit
ddf6fe37
AA
27850@item -msingle-exit
27851@itemx -mno-single-exit
d77de738
ML
27852Force (do not force) generated code to have a single exit point in each
27853function.
27854@end table
27855
27856@node MN10300 Options
27857@subsection MN10300 Options
27858@cindex MN10300 options
27859
27860These @option{-m} options are defined for Matsushita MN10300 architectures:
27861
27862@table @gcctabopt
d77de738 27863@opindex mmult-bug
ddf6fe37 27864@item -mmult-bug
d77de738
ML
27865Generate code to avoid bugs in the multiply instructions for the MN10300
27866processors. This is the default.
27867
d77de738 27868@opindex mno-mult-bug
ddf6fe37 27869@item -mno-mult-bug
d77de738
ML
27870Do not generate code to avoid bugs in the multiply instructions for the
27871MN10300 processors.
27872
d77de738 27873@opindex mam33
ddf6fe37 27874@item -mam33
d77de738
ML
27875Generate code using features specific to the AM33 processor.
27876
d77de738 27877@opindex mno-am33
ddf6fe37 27878@item -mno-am33
d77de738
ML
27879Do not generate code using features specific to the AM33 processor. This
27880is the default.
27881
d77de738 27882@opindex mam33-2
ddf6fe37 27883@item -mam33-2
d77de738
ML
27884Generate code using features specific to the AM33/2.0 processor.
27885
d77de738 27886@opindex mam34
ddf6fe37 27887@item -mam34
d77de738
ML
27888Generate code using features specific to the AM34 processor.
27889
d77de738 27890@opindex mtune
ddf6fe37 27891@item -mtune=@var{cpu-type}
d77de738
ML
27892Use the timing characteristics of the indicated CPU type when
27893scheduling instructions. This does not change the targeted processor
27894type. The CPU type must be one of @samp{mn10300}, @samp{am33},
27895@samp{am33-2} or @samp{am34}.
27896
d77de738 27897@opindex mreturn-pointer-on-d0
ddf6fe37 27898@item -mreturn-pointer-on-d0
d77de738
ML
27899When generating a function that returns a pointer, return the pointer
27900in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
27901only in @code{a0}, and attempts to call such functions without a prototype
27902result in errors. Note that this option is on by default; use
27903@option{-mno-return-pointer-on-d0} to disable it.
27904
d77de738 27905@opindex mno-crt0
ddf6fe37 27906@item -mno-crt0
d77de738
ML
27907Do not link in the C run-time initialization object file.
27908
d77de738 27909@opindex mrelax
ddf6fe37 27910@item -mrelax
d77de738
ML
27911Indicate to the linker that it should perform a relaxation optimization pass
27912to shorten branches, calls and absolute memory addresses. This option only
27913has an effect when used on the command line for the final link step.
27914
27915This option makes symbolic debugging impossible.
27916
d77de738 27917@opindex mliw
ddf6fe37 27918@item -mliw
d77de738
ML
27919Allow the compiler to generate @emph{Long Instruction Word}
27920instructions if the target is the @samp{AM33} or later. This is the
27921default. This option defines the preprocessor macro @code{__LIW__}.
27922
d77de738 27923@opindex mno-liw
ddf6fe37 27924@item -mno-liw
d77de738
ML
27925Do not allow the compiler to generate @emph{Long Instruction Word}
27926instructions. This option defines the preprocessor macro
27927@code{__NO_LIW__}.
27928
d77de738 27929@opindex msetlb
ddf6fe37 27930@item -msetlb
d77de738
ML
27931Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
27932instructions if the target is the @samp{AM33} or later. This is the
27933default. This option defines the preprocessor macro @code{__SETLB__}.
27934
d77de738 27935@opindex mno-setlb
ddf6fe37 27936@item -mno-setlb
d77de738
ML
27937Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
27938instructions. This option defines the preprocessor macro
27939@code{__NO_SETLB__}.
27940
27941@end table
27942
27943@node Moxie Options
27944@subsection Moxie Options
27945@cindex Moxie Options
27946
27947@table @gcctabopt
27948
d77de738 27949@opindex meb
ddf6fe37 27950@item -meb
d77de738
ML
27951Generate big-endian code. This is the default for @samp{moxie-*-*}
27952configurations.
27953
d77de738 27954@opindex mel
ddf6fe37 27955@item -mel
d77de738
ML
27956Generate little-endian code.
27957
d77de738 27958@opindex mmul.x
ddf6fe37 27959@item -mmul.x
d77de738
ML
27960Generate mul.x and umul.x instructions. This is the default for
27961@samp{moxiebox-*-*} configurations.
27962
d77de738 27963@opindex mno-crt0
ddf6fe37 27964@item -mno-crt0
d77de738
ML
27965Do not link in the C run-time initialization object file.
27966
27967@end table
27968
27969@node MSP430 Options
27970@subsection MSP430 Options
27971@cindex MSP430 Options
27972
27973These options are defined for the MSP430:
27974
27975@table @gcctabopt
27976
d77de738 27977@opindex masm-hex
ddf6fe37 27978@item -masm-hex
d77de738
ML
27979Force assembly output to always use hex constants. Normally such
27980constants are signed decimals, but this option is available for
27981testsuite and/or aesthetic purposes.
27982
d77de738 27983@opindex mmcu=
ddf6fe37 27984@item -mmcu=
d77de738
ML
27985Select the MCU to target. This is used to create a C preprocessor
27986symbol based upon the MCU name, converted to upper case and pre- and
27987post-fixed with @samp{__}. This in turn is used by the
27988@file{msp430.h} header file to select an MCU-specific supplementary
27989header file.
27990
27991The option also sets the ISA to use. If the MCU name is one that is
27992known to only support the 430 ISA then that is selected, otherwise the
27993430X ISA is selected. A generic MCU name of @samp{msp430} can also be
27994used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
27995name selects the 430X ISA.
27996
27997In addition an MCU-specific linker script is added to the linker
27998command line. The script's name is the name of the MCU with
27999@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
28000command line defines the C preprocessor symbol @code{__XXX__} and
28001cause the linker to search for a script called @file{xxx.ld}.
28002
28003The ISA and hardware multiply supported for the different MCUs is hard-coded
28004into GCC. However, an external @samp{devices.csv} file can be used to
28005extend device support beyond those that have been hard-coded.
28006
28007GCC searches for the @samp{devices.csv} file using the following methods in the
28008given precedence order, where the first method takes precendence over the
28009second which takes precedence over the third.
28010
28011@table @asis
28012@item Include path specified with @code{-I} and @code{-L}
28013@samp{devices.csv} will be searched for in each of the directories specified by
28014include paths and linker library search paths.
28015@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
28016Define the value of the global environment variable
28017@samp{MSP430_GCC_INCLUDE_DIR}
28018to the full path to the directory containing devices.csv, and GCC will search
28019this directory for devices.csv. If devices.csv is found, this directory will
28020also be registered as an include path, and linker library path. Header files
28021and linker scripts in this directory can therefore be used without manually
28022specifying @code{-I} and @code{-L} on the command line.
28023@item The @samp{msp430-elf@{,bare@}/include/devices} directory
28024Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
28025toolchain root directory. This directory does not exist in a default
28026installation, but if the user has created it and copied @samp{devices.csv}
28027there, then the MCU data will be read. As above, this directory will
28028also be registered as an include path, and linker library path.
28029
28030@end table
28031If none of the above search methods find @samp{devices.csv}, then the
28032hard-coded MCU data is used.
28033
28034
d77de738
ML
28035@opindex mwarn-mcu
28036@opindex mno-warn-mcu
ddf6fe37
AA
28037@item -mwarn-mcu
28038@itemx -mno-warn-mcu
d77de738
ML
28039This option enables or disables warnings about conflicts between the
28040MCU name specified by the @option{-mmcu} option and the ISA set by the
28041@option{-mcpu} option and/or the hardware multiply support set by the
28042@option{-mhwmult} option. It also toggles warnings about unrecognized
28043MCU names. This option is on by default.
28044
d77de738 28045@opindex mcpu=
ddf6fe37 28046@item -mcpu=
d77de738
ML
28047Specifies the ISA to use. Accepted values are @samp{msp430},
28048@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
28049@option{-mmcu=} option should be used to select the ISA.
28050
d77de738 28051@opindex msim
ddf6fe37 28052@item -msim
d77de738
ML
28053Link to the simulator runtime libraries and linker script. Overrides
28054any scripts that would be selected by the @option{-mmcu=} option.
28055
d77de738 28056@opindex mlarge
ddf6fe37 28057@item -mlarge
d77de738
ML
28058Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
28059
d77de738 28060@opindex msmall
ddf6fe37 28061@item -msmall
d77de738
ML
28062Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
28063
d77de738 28064@opindex mrelax
ddf6fe37 28065@item -mrelax
d77de738
ML
28066This option is passed to the assembler and linker, and allows the
28067linker to perform certain optimizations that cannot be done until
28068the final link.
28069
d77de738 28070@opindex mhwmult=
ddf6fe37 28071@item mhwmult=
d77de738
ML
28072Describes the type of hardware multiply supported by the target.
28073Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
28074for the original 16-bit-only multiply supported by early MCUs.
28075@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
28076@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
28077A value of @samp{auto} can also be given. This tells GCC to deduce
28078the hardware multiply support based upon the MCU name provided by the
28079@option{-mmcu} option. If no @option{-mmcu} option is specified or if
28080the MCU name is not recognized then no hardware multiply support is
28081assumed. @code{auto} is the default setting.
28082
28083Hardware multiplies are normally performed by calling a library
28084routine. This saves space in the generated code. When compiling at
28085@option{-O3} or higher however the hardware multiplier is invoked
28086inline. This makes for bigger, but faster code.
28087
28088The hardware multiply routines disable interrupts whilst running and
28089restore the previous interrupt state when they finish. This makes
28090them safe to use inside interrupt handlers as well as in normal code.
28091
d77de738 28092@opindex minrt
ddf6fe37 28093@item -minrt
d77de738
ML
28094Enable the use of a minimum runtime environment - no static
28095initializers or constructors. This is intended for memory-constrained
28096devices. The compiler includes special symbols in some objects
28097that tell the linker and runtime which code fragments are required.
28098
d77de738 28099@opindex mtiny-printf
ddf6fe37 28100@item -mtiny-printf
d77de738
ML
28101Enable reduced code size @code{printf} and @code{puts} library functions.
28102The @samp{tiny} implementations of these functions are not reentrant, so
28103must be used with caution in multi-threaded applications.
28104
28105Support for streams has been removed and the string to be printed will
28106always be sent to stdout via the @code{write} syscall. The string is not
28107buffered before it is sent to write.
28108
28109This option requires Newlib Nano IO, so GCC must be configured with
28110@samp{--enable-newlib-nano-formatted-io}.
28111
d77de738 28112@opindex mmax-inline-shift=
ddf6fe37 28113@item -mmax-inline-shift=
d77de738
ML
28114This option takes an integer between 0 and 64 inclusive, and sets
28115the maximum number of inline shift instructions which should be emitted to
28116perform a shift operation by a constant amount. When this value needs to be
28117exceeded, an mspabi helper function is used instead. The default value is 4.
28118
28119This only affects cases where a shift by multiple positions cannot be
28120completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
28121
28122Shifts of a 32-bit value are at least twice as costly, so the value passed for
28123this option is divided by 2 and the resulting value used instead.
28124
d77de738
ML
28125@opindex mcode-region
28126@opindex mdata-region
ddf6fe37
AA
28127@item -mcode-region=
28128@itemx -mdata-region=
d77de738
ML
28129These options tell the compiler where to place functions and data that
28130do not have one of the @code{lower}, @code{upper}, @code{either} or
28131@code{section} attributes. Possible values are @code{lower},
28132@code{upper}, @code{either} or @code{any}. The first three behave
28133like the corresponding attribute. The fourth possible value -
28134@code{any} - is the default. It leaves placement entirely up to the
28135linker script and how it assigns the standard sections
28136(@code{.text}, @code{.data}, etc) to the memory regions.
28137
d77de738 28138@opindex msilicon-errata
ddf6fe37 28139@item -msilicon-errata=
d77de738
ML
28140This option passes on a request to assembler to enable the fixes for
28141the named silicon errata.
28142
d77de738 28143@opindex msilicon-errata-warn
ddf6fe37 28144@item -msilicon-errata-warn=
d77de738
ML
28145This option passes on a request to the assembler to enable warning
28146messages when a silicon errata might need to be applied.
28147
d77de738
ML
28148@opindex mwarn-devices-csv
28149@opindex mno-warn-devices-csv
ddf6fe37
AA
28150@item -mwarn-devices-csv
28151@itemx -mno-warn-devices-csv
d77de738
ML
28152Warn if @samp{devices.csv} is not found or there are problem parsing it
28153(default: on).
28154
28155@end table
28156
28157@node NDS32 Options
28158@subsection NDS32 Options
28159@cindex NDS32 Options
28160
28161These options are defined for NDS32 implementations:
28162
28163@table @gcctabopt
28164
d77de738 28165@opindex mbig-endian
ddf6fe37 28166@item -mbig-endian
d77de738
ML
28167Generate code in big-endian mode.
28168
d77de738 28169@opindex mlittle-endian
ddf6fe37 28170@item -mlittle-endian
d77de738
ML
28171Generate code in little-endian mode.
28172
d77de738 28173@opindex mreduced-regs
ddf6fe37 28174@item -mreduced-regs
d77de738
ML
28175Use reduced-set registers for register allocation.
28176
d77de738 28177@opindex mfull-regs
ddf6fe37 28178@item -mfull-regs
d77de738
ML
28179Use full-set registers for register allocation.
28180
d77de738 28181@opindex mcmov
ddf6fe37 28182@item -mcmov
d77de738
ML
28183Generate conditional move instructions.
28184
d77de738 28185@opindex mno-cmov
ddf6fe37 28186@item -mno-cmov
d77de738
ML
28187Do not generate conditional move instructions.
28188
d77de738 28189@opindex mext-perf
ddf6fe37 28190@item -mext-perf
d77de738
ML
28191Generate performance extension instructions.
28192
d77de738 28193@opindex mno-ext-perf
ddf6fe37 28194@item -mno-ext-perf
d77de738
ML
28195Do not generate performance extension instructions.
28196
d77de738 28197@opindex mext-perf2
ddf6fe37 28198@item -mext-perf2
d77de738
ML
28199Generate performance extension 2 instructions.
28200
d77de738 28201@opindex mno-ext-perf2
ddf6fe37 28202@item -mno-ext-perf2
d77de738
ML
28203Do not generate performance extension 2 instructions.
28204
d77de738 28205@opindex mext-string
ddf6fe37 28206@item -mext-string
d77de738
ML
28207Generate string extension instructions.
28208
d77de738 28209@opindex mno-ext-string
ddf6fe37 28210@item -mno-ext-string
d77de738
ML
28211Do not generate string extension instructions.
28212
d77de738 28213@opindex mv3push
ddf6fe37 28214@item -mv3push
d77de738
ML
28215Generate v3 push25/pop25 instructions.
28216
d77de738 28217@opindex mno-v3push
ddf6fe37 28218@item -mno-v3push
d77de738
ML
28219Do not generate v3 push25/pop25 instructions.
28220
d77de738 28221@opindex m16-bit
ddf6fe37 28222@item -m16-bit
d77de738
ML
28223Generate 16-bit instructions.
28224
d77de738 28225@opindex mno-16-bit
ddf6fe37 28226@item -mno-16-bit
d77de738
ML
28227Do not generate 16-bit instructions.
28228
d77de738 28229@opindex misr-vector-size
ddf6fe37 28230@item -misr-vector-size=@var{num}
d77de738
ML
28231Specify the size of each interrupt vector, which must be 4 or 16.
28232
d77de738 28233@opindex mcache-block-size
ddf6fe37 28234@item -mcache-block-size=@var{num}
d77de738
ML
28235Specify the size of each cache block,
28236which must be a power of 2 between 4 and 512.
28237
d77de738 28238@opindex march
ddf6fe37 28239@item -march=@var{arch}
d77de738
ML
28240Specify the name of the target architecture.
28241
d77de738 28242@opindex mcmodel
ddf6fe37 28243@item -mcmodel=@var{code-model}
d77de738
ML
28244Set the code model to one of
28245@table @asis
28246@item @samp{small}
28247All the data and read-only data segments must be within 512KB addressing space.
28248The text segment must be within 16MB addressing space.
28249@item @samp{medium}
28250The data segment must be within 512KB while the read-only data segment can be
28251within 4GB addressing space. The text segment should be still within 16MB
28252addressing space.
28253@item @samp{large}
28254All the text and data segments can be within 4GB addressing space.
28255@end table
28256
d77de738 28257@opindex mctor-dtor
ddf6fe37 28258@item -mctor-dtor
d77de738
ML
28259Enable constructor/destructor feature.
28260
d77de738 28261@opindex mrelax
ddf6fe37 28262@item -mrelax
d77de738
ML
28263Guide linker to relax instructions.
28264
28265@end table
28266
28267@node Nios II Options
28268@subsection Nios II Options
28269@cindex Nios II options
28270@cindex Altera Nios II options
28271
28272These are the options defined for the Altera Nios II processor.
28273
28274@table @gcctabopt
28275
d77de738
ML
28276@opindex G
28277@cindex smaller data references
f33d7a88 28278@item -G @var{num}
d77de738
ML
28279Put global and static objects less than or equal to @var{num} bytes
28280into the small data or BSS sections instead of the normal data or BSS
28281sections. The default value of @var{num} is 8.
28282
ddf6fe37
AA
28283@opindex mgpopt
28284@opindex mno-gpopt
d77de738
ML
28285@item -mgpopt=@var{option}
28286@itemx -mgpopt
28287@itemx -mno-gpopt
d77de738
ML
28288Generate (do not generate) GP-relative accesses. The following
28289@var{option} names are recognized:
28290
28291@table @samp
28292
28293@item none
28294Do not generate GP-relative accesses.
28295
28296@item local
28297Generate GP-relative accesses for small data objects that are not
28298external, weak, or uninitialized common symbols.
28299Also use GP-relative addressing for objects that
28300have been explicitly placed in a small data section via a @code{section}
28301attribute.
28302
28303@item global
28304As for @samp{local}, but also generate GP-relative accesses for
28305small data objects that are external, weak, or common. If you use this option,
28306you must ensure that all parts of your program (including libraries) are
28307compiled with the same @option{-G} setting.
28308
28309@item data
28310Generate GP-relative accesses for all data objects in the program. If you
28311use this option, the entire data and BSS segments
28312of your program must fit in 64K of memory and you must use an appropriate
28313linker script to allocate them within the addressable range of the
28314global pointer.
28315
28316@item all
28317Generate GP-relative addresses for function pointers as well as data
28318pointers. If you use this option, the entire text, data, and BSS segments
28319of your program must fit in 64K of memory and you must use an appropriate
28320linker script to allocate them within the addressable range of the
28321global pointer.
28322
28323@end table
28324
28325@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28326@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28327
28328The default is @option{-mgpopt} except when @option{-fpic} or
28329@option{-fPIC} is specified to generate position-independent code.
28330Note that the Nios II ABI does not permit GP-relative accesses from
28331shared libraries.
28332
28333You may need to specify @option{-mno-gpopt} explicitly when building
28334programs that include large amounts of small data, including large
28335GOT data sections. In this case, the 16-bit offset for GP-relative
28336addressing may not be large enough to allow access to the entire
28337small data section.
28338
d77de738 28339@opindex mgprel-sec
ddf6fe37 28340@item -mgprel-sec=@var{regexp}
d77de738
ML
28341This option specifies additional section names that can be accessed via
28342GP-relative addressing. It is most useful in conjunction with
28343@code{section} attributes on variable declarations
28344(@pxref{Common Variable Attributes}) and a custom linker script.
28345The @var{regexp} is a POSIX Extended Regular Expression.
28346
28347This option does not affect the behavior of the @option{-G} option, and
28348the specified sections are in addition to the standard @code{.sdata}
28349and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28350
d77de738 28351@opindex mr0rel-sec
ddf6fe37 28352@item -mr0rel-sec=@var{regexp}
d77de738
ML
28353This option specifies names of sections that can be accessed via a
2835416-bit offset from @code{r0}; that is, in the low 32K or high 32K
28355of the 32-bit address space. It is most useful in conjunction with
28356@code{section} attributes on variable declarations
28357(@pxref{Common Variable Attributes}) and a custom linker script.
28358The @var{regexp} is a POSIX Extended Regular Expression.
28359
28360In contrast to the use of GP-relative addressing for small data,
28361zero-based addressing is never generated by default and there are no
28362conventional section names used in standard linker scripts for sections
28363in the low or high areas of memory.
28364
d77de738
ML
28365@opindex mel
28366@opindex meb
ddf6fe37
AA
28367@item -mel
28368@itemx -meb
d77de738
ML
28369Generate little-endian (default) or big-endian (experimental) code,
28370respectively.
28371
d77de738 28372@opindex march
ddf6fe37 28373@item -march=@var{arch}
d77de738
ML
28374This specifies the name of the target Nios II architecture. GCC uses this
28375name to determine what kind of instructions it can emit when generating
28376assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28377
28378The preprocessor macro @code{__nios2_arch__} is available to programs,
28379with value 1 or 2, indicating the targeted ISA level.
28380
d77de738
ML
28381@opindex mno-bypass-cache
28382@opindex mbypass-cache
ddf6fe37
AA
28383@item -mbypass-cache
28384@itemx -mno-bypass-cache
d77de738
ML
28385Force all load and store instructions to always bypass cache by
28386using I/O variants of the instructions. The default is not to
28387bypass the cache.
28388
d77de738
ML
28389@opindex mcache-volatile
28390@opindex mno-cache-volatile
ddf6fe37
AA
28391@item -mno-cache-volatile
28392@itemx -mcache-volatile
d77de738
ML
28393Volatile memory access bypass the cache using the I/O variants of
28394the load and store instructions. The default is not to bypass the cache.
28395
d77de738
ML
28396@opindex mno-fast-sw-div
28397@opindex mfast-sw-div
ddf6fe37
AA
28398@item -mno-fast-sw-div
28399@itemx -mfast-sw-div
d77de738
ML
28400Do not use table-based fast divide for small numbers. The default
28401is to use the fast divide at @option{-O3} and above.
28402
d77de738
ML
28403@opindex mno-hw-mul
28404@opindex mhw-mul
28405@opindex mno-hw-mulx
28406@opindex mhw-mulx
28407@opindex mno-hw-div
28408@opindex mhw-div
ddf6fe37
AA
28409@item -mno-hw-mul
28410@itemx -mhw-mul
28411@itemx -mno-hw-mulx
28412@itemx -mhw-mulx
28413@itemx -mno-hw-div
28414@itemx -mhw-div
d77de738
ML
28415Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28416instructions by the compiler. The default is to emit @code{mul}
28417and not emit @code{div} and @code{mulx}.
28418
28419@item -mbmx
28420@itemx -mno-bmx
28421@itemx -mcdx
28422@itemx -mno-cdx
28423Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28424CDX (code density) instructions. Enabling these instructions also
28425requires @option{-march=r2}. Since these instructions are optional
28426extensions to the R2 architecture, the default is not to emit them.
28427
d77de738
ML
28428@opindex mcustom-@var{insn}
28429@opindex mno-custom-@var{insn}
ddf6fe37
AA
28430@item -mcustom-@var{insn}=@var{N}
28431@itemx -mno-custom-@var{insn}
d77de738
ML
28432Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28433custom instruction with encoding @var{N} when generating code that uses
28434@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28435instruction 253 for single-precision floating-point add operations instead
28436of the default behavior of using a library call.
28437
28438The following values of @var{insn} are supported. Except as otherwise
28439noted, floating-point operations are expected to be implemented with
28440normal IEEE 754 semantics and correspond directly to the C operators or the
28441equivalent GCC built-in functions (@pxref{Other Builtins}).
28442
28443Single-precision floating point:
28444@table @asis
28445
28446@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28447Binary arithmetic operations.
28448
28449@item @samp{fnegs}
28450Unary negation.
28451
28452@item @samp{fabss}
28453Unary absolute value.
28454
28455@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28456Comparison operations.
28457
28458@item @samp{fmins}, @samp{fmaxs}
28459Floating-point minimum and maximum. These instructions are only
28460generated if @option{-ffinite-math-only} is specified.
28461
28462@item @samp{fsqrts}
28463Unary square root operation.
28464
28465@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28466Floating-point trigonometric and exponential functions. These instructions
28467are only generated if @option{-funsafe-math-optimizations} is also specified.
28468
28469@end table
28470
28471Double-precision floating point:
28472@table @asis
28473
28474@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28475Binary arithmetic operations.
28476
28477@item @samp{fnegd}
28478Unary negation.
28479
28480@item @samp{fabsd}
28481Unary absolute value.
28482
28483@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28484Comparison operations.
28485
28486@item @samp{fmind}, @samp{fmaxd}
28487Double-precision minimum and maximum. These instructions are only
28488generated if @option{-ffinite-math-only} is specified.
28489
28490@item @samp{fsqrtd}
28491Unary square root operation.
28492
28493@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28494Double-precision trigonometric and exponential functions. These instructions
28495are only generated if @option{-funsafe-math-optimizations} is also specified.
28496
28497@end table
28498
28499Conversions:
28500@table @asis
28501@item @samp{fextsd}
28502Conversion from single precision to double precision.
28503
28504@item @samp{ftruncds}
28505Conversion from double precision to single precision.
28506
28507@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28508Conversion from floating point to signed or unsigned integer types, with
28509truncation towards zero.
28510
28511@item @samp{round}
28512Conversion from single-precision floating point to signed integer,
28513rounding to the nearest integer and ties away from zero.
28514This corresponds to the @code{__builtin_lroundf} function when
28515@option{-fno-math-errno} is used.
28516
28517@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28518Conversion from signed or unsigned integer types to floating-point types.
28519
28520@end table
28521
28522In addition, all of the following transfer instructions for internal
28523registers X and Y must be provided to use any of the double-precision
28524floating-point instructions. Custom instructions taking two
28525double-precision source operands expect the first operand in the
2852664-bit register X. The other operand (or only operand of a unary
28527operation) is given to the custom arithmetic instruction with the
28528least significant half in source register @var{src1} and the most
28529significant half in @var{src2}. A custom instruction that returns a
28530double-precision result returns the most significant 32 bits in the
28531destination register and the other half in 32-bit register Y.
28532GCC automatically generates the necessary code sequences to write
28533register X and/or read register Y when double-precision floating-point
28534instructions are used.
28535
28536@table @asis
28537
28538@item @samp{fwrx}
28539Write @var{src1} into the least significant half of X and @var{src2} into
28540the most significant half of X.
28541
28542@item @samp{fwry}
28543Write @var{src1} into Y.
28544
28545@item @samp{frdxhi}, @samp{frdxlo}
28546Read the most or least (respectively) significant half of X and store it in
28547@var{dest}.
28548
28549@item @samp{frdy}
28550Read the value of Y and store it into @var{dest}.
28551@end table
28552
28553Note that you can gain more local control over generation of Nios II custom
28554instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28555and @code{target("no-custom-@var{insn}")} function attributes
28556(@pxref{Function Attributes})
28557or pragmas (@pxref{Function Specific Option Pragmas}).
28558
d77de738 28559@opindex mcustom-fpu-cfg
ddf6fe37 28560@item -mcustom-fpu-cfg=@var{name}
d77de738
ML
28561
28562This option enables a predefined, named set of custom instruction encodings
28563(see @option{-mcustom-@var{insn}} above).
28564Currently, the following sets are defined:
28565
28566@option{-mcustom-fpu-cfg=60-1} is equivalent to:
43b72ede
AA
28567@gccoptlist{-mcustom-fmuls=252
28568-mcustom-fadds=253
28569-mcustom-fsubs=254
d77de738
ML
28570-fsingle-precision-constant}
28571
28572@option{-mcustom-fpu-cfg=60-2} is equivalent to:
43b72ede
AA
28573@gccoptlist{-mcustom-fmuls=252
28574-mcustom-fadds=253
28575-mcustom-fsubs=254
28576-mcustom-fdivs=255
d77de738
ML
28577-fsingle-precision-constant}
28578
28579@option{-mcustom-fpu-cfg=72-3} is equivalent to:
43b72ede
AA
28580@gccoptlist{-mcustom-floatus=243
28581-mcustom-fixsi=244
28582-mcustom-floatis=245
28583-mcustom-fcmpgts=246
28584-mcustom-fcmples=249
28585-mcustom-fcmpeqs=250
28586-mcustom-fcmpnes=251
28587-mcustom-fmuls=252
28588-mcustom-fadds=253
28589-mcustom-fsubs=254
28590-mcustom-fdivs=255
d77de738
ML
28591-fsingle-precision-constant}
28592
28593@option{-mcustom-fpu-cfg=fph2} is equivalent to:
43b72ede
AA
28594@gccoptlist{-mcustom-fabss=224
28595-mcustom-fnegs=225
28596-mcustom-fcmpnes=226
28597-mcustom-fcmpeqs=227
28598-mcustom-fcmpges=228
28599-mcustom-fcmpgts=229
28600-mcustom-fcmples=230
28601-mcustom-fcmplts=231
28602-mcustom-fmaxs=232
28603-mcustom-fmins=233
28604-mcustom-round=248
28605-mcustom-fixsi=249
28606-mcustom-floatis=250
28607-mcustom-fsqrts=251
28608-mcustom-fmuls=252
28609-mcustom-fadds=253
28610-mcustom-fsubs=254
28611-mcustom-fdivs=255}
d77de738
ML
28612
28613Custom instruction assignments given by individual
28614@option{-mcustom-@var{insn}=} options override those given by
28615@option{-mcustom-fpu-cfg=}, regardless of the
28616order of the options on the command line.
28617
28618Note that you can gain more local control over selection of a FPU
28619configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28620function attribute (@pxref{Function Attributes})
28621or pragma (@pxref{Function Specific Option Pragmas}).
28622
28623The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28624Hardware 2 Component}. Please note that the custom instructions enabled by
28625@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28626if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28627@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28628specified. In contrast to the other configurations,
28629@option{-fsingle-precision-constant} is not set.
28630
28631@end table
28632
28633These additional @samp{-m} options are available for the Altera Nios II
28634ELF (bare-metal) target:
28635
28636@table @gcctabopt
28637
d77de738 28638@opindex mhal
ddf6fe37 28639@item -mhal
d77de738
ML
28640Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28641startup and termination code, and is typically used in conjunction with
28642@option{-msys-crt0=} to specify the location of the alternate startup code
28643provided by the HAL BSP.
28644
d77de738 28645@opindex msmallc
ddf6fe37 28646@item -msmallc
d77de738
ML
28647Link with a limited version of the C library, @option{-lsmallc}, rather than
28648Newlib.
28649
d77de738 28650@opindex msys-crt0
ddf6fe37 28651@item -msys-crt0=@var{startfile}
d77de738
ML
28652@var{startfile} is the file name of the startfile (crt0) to use
28653when linking. This option is only useful in conjunction with @option{-mhal}.
28654
d77de738 28655@opindex msys-lib
ddf6fe37 28656@item -msys-lib=@var{systemlib}
d77de738
ML
28657@var{systemlib} is the library name of the library that provides
28658low-level system calls required by the C library,
28659e.g.@: @code{read} and @code{write}.
28660This option is typically used to link with a library provided by a HAL BSP.
28661
28662@end table
28663
28664@node Nvidia PTX Options
28665@subsection Nvidia PTX Options
28666@cindex Nvidia PTX options
28667@cindex nvptx options
28668
28669These options are defined for Nvidia PTX:
28670
28671@table @gcctabopt
28672
d77de738 28673@opindex m64
ddf6fe37 28674@item -m64
d77de738
ML
28675Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28676supported.
28677
d77de738 28678@opindex march
ddf6fe37 28679@item -march=@var{architecture-string}
d77de738
ML
28680Generate code for the specified PTX ISA target architecture
28681(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
28682@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
28683@samp{sm_80}.
28684The default depends on how the compiler has been configured, see
28685@option{--with-arch}.
28686
28687This option sets the value of the preprocessor macro
28688@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
28689@samp{350}.
28690
d77de738 28691@opindex misa
ddf6fe37 28692@item -misa=@var{architecture-string}
d77de738
ML
28693Alias of @option{-march=}.
28694
d77de738 28695@opindex march
ddf6fe37 28696@item -march-map=@var{architecture-string}
d77de738
ML
28697Select the closest available @option{-march=} value that is not more
28698capable. For instance, for @option{-march-map=sm_50} select
28699@option{-march=sm_35}, and for @option{-march-map=sm_53} select
28700@option{-march=sm_53}.
28701
d77de738 28702@opindex mptx
ddf6fe37 28703@item -mptx=@var{version-string}
d77de738
ML
28704Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
28705Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
28706@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
28707version is required for specified PTX ISA target architecture via
28708option @option{-march=}.
28709
28710This option sets the values of the preprocessor macros
28711@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
28712for instance, for @samp{3.1} the macros have the values @samp{3} and
28713@samp{1}, respectively.
28714
d77de738 28715@opindex mmainkernel
ddf6fe37 28716@item -mmainkernel
d77de738
ML
28717Link in code for a __main kernel. This is for stand-alone instead of
28718offloading execution.
28719
d77de738 28720@opindex moptimize
ddf6fe37 28721@item -moptimize
d77de738
ML
28722Apply partitioned execution optimizations. This is the default when any
28723level of optimization is selected.
28724
d77de738 28725@opindex msoft-stack
ddf6fe37 28726@item -msoft-stack
d77de738
ML
28727Generate code that does not use @code{.local} memory
28728directly for stack storage. Instead, a per-warp stack pointer is
28729maintained explicitly. This enables variable-length stack allocation (with
28730variable-length arrays or @code{alloca}), and when global memory is used for
28731underlying storage, makes it possible to access automatic variables from other
28732threads, or with atomic instructions. This code generation variant is used
28733for OpenMP offloading, but the option is exposed on its own for the purpose
28734of testing the compiler; to generate code suitable for linking into programs
28735using OpenMP offloading, use option @option{-mgomp}.
28736
d77de738 28737@opindex muniform-simt
ddf6fe37 28738@item -muniform-simt
d77de738
ML
28739Switch to code generation variant that allows to execute all threads in each
28740warp, while maintaining memory state and side effects as if only one thread
28741in each warp was active outside of OpenMP SIMD regions. All atomic operations
28742and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
28743current lane index equals the master lane index), and the register being
28744assigned is copied via a shuffle instruction from the master lane. Outside of
28745SIMD regions lane 0 is the master; inside, each thread sees itself as the
28746master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
28747all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
28748regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
28749with current lane index to compute the master lane index.
28750
d77de738 28751@opindex mgomp
ddf6fe37 28752@item -mgomp
d77de738
ML
28753Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
28754@option{-muniform-simt} options, and selects corresponding multilib variant.
28755
28756@end table
28757
28758@node OpenRISC Options
28759@subsection OpenRISC Options
28760@cindex OpenRISC Options
28761
28762These options are defined for OpenRISC:
28763
28764@table @gcctabopt
28765
d77de738 28766@opindex mboard
ddf6fe37 28767@item -mboard=@var{name}
d77de738
ML
28768Configure a board specific runtime. This will be passed to the linker for
28769newlib board library linking. The default is @code{or1ksim}.
28770
d77de738 28771@opindex mnewlib
ddf6fe37 28772@item -mnewlib
d77de738
ML
28773This option is ignored; it is for compatibility purposes only. This used to
28774select linker and preprocessor options for use with newlib.
28775
d77de738
ML
28776@opindex msoft-div
28777@opindex mhard-div
ddf6fe37
AA
28778@item -msoft-div
28779@itemx -mhard-div
d77de738
ML
28780Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
28781This default is hardware divide.
28782
d77de738
ML
28783@opindex msoft-mul
28784@opindex mhard-mul
ddf6fe37
AA
28785@item -msoft-mul
28786@itemx -mhard-mul
d77de738
ML
28787Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
28788This default is hardware multiply.
28789
d77de738
ML
28790@opindex msoft-float
28791@opindex mhard-float
ddf6fe37
AA
28792@item -msoft-float
28793@itemx -mhard-float
d77de738
ML
28794Select software or hardware for floating point operations.
28795The default is software.
28796
d77de738 28797@opindex mdouble-float
ddf6fe37 28798@item -mdouble-float
d77de738
ML
28799When @option{-mhard-float} is selected, enables generation of double-precision
28800floating point instructions. By default functions from @file{libgcc} are used
28801to perform double-precision floating point operations.
28802
d77de738 28803@opindex munordered-float
ddf6fe37 28804@item -munordered-float
d77de738
ML
28805When @option{-mhard-float} is selected, enables generation of unordered
28806floating point compare and set flag (@code{lf.sfun*}) instructions. By default
28807functions from @file{libgcc} are used to perform unordered floating point
28808compare and set flag operations.
28809
d77de738 28810@opindex mcmov
ddf6fe37 28811@item -mcmov
d77de738
ML
28812Enable generation of conditional move (@code{l.cmov}) instructions. By
28813default the equivalent will be generated using set and branch.
28814
d77de738 28815@opindex mror
ddf6fe37 28816@item -mror
d77de738
ML
28817Enable generation of rotate right (@code{l.ror}) instructions. By default
28818functions from @file{libgcc} are used to perform rotate right operations.
28819
d77de738 28820@opindex mrori
ddf6fe37 28821@item -mrori
d77de738
ML
28822Enable generation of rotate right with immediate (@code{l.rori}) instructions.
28823By default functions from @file{libgcc} are used to perform rotate right with
28824immediate operations.
28825
d77de738 28826@opindex msext
ddf6fe37 28827@item -msext
d77de738
ML
28828Enable generation of sign extension (@code{l.ext*}) instructions. By default
28829memory loads are used to perform sign extension.
28830
d77de738 28831@opindex msfimm
ddf6fe37 28832@item -msfimm
d77de738
ML
28833Enable generation of compare and set flag with immediate (@code{l.sf*i})
28834instructions. By default extra instructions will be generated to store the
28835immediate to a register first.
28836
d77de738 28837@opindex mshftimm
ddf6fe37 28838@item -mshftimm
d77de738
ML
28839Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
28840@code{l.slli}) instructions. By default extra instructions will be generated
28841to store the immediate to a register first.
28842
d77de738 28843@opindex mcmodel=small
ddf6fe37 28844@item -mcmodel=small
d77de738
ML
28845Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
28846the default model.
28847
d77de738 28848@opindex mcmodel=large
ddf6fe37 28849@item -mcmodel=large
d77de738
ML
28850Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
28851
28852
28853@end table
28854
28855@node PDP-11 Options
28856@subsection PDP-11 Options
28857@cindex PDP-11 Options
28858
28859These options are defined for the PDP-11:
28860
28861@table @gcctabopt
d77de738 28862@opindex mfpu
ddf6fe37 28863@item -mfpu
d77de738
ML
28864Use hardware FPP floating point. This is the default. (FIS floating
28865point on the PDP-11/40 is not supported.) Implies -m45.
28866
d77de738 28867@opindex msoft-float
ddf6fe37 28868@item -msoft-float
d77de738
ML
28869Do not use hardware floating point.
28870
d77de738 28871@opindex mac0
ddf6fe37 28872@item -mac0
d77de738
ML
28873Return floating-point results in ac0 (fr0 in Unix assembler syntax).
28874
d77de738 28875@opindex mno-ac0
ddf6fe37 28876@item -mno-ac0
d77de738
ML
28877Return floating-point results in memory. This is the default.
28878
d77de738 28879@opindex m40
ddf6fe37 28880@item -m40
d77de738
ML
28881Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
28882
d77de738 28883@opindex m45
ddf6fe37 28884@item -m45
d77de738
ML
28885Generate code for a PDP-11/45. This is the default.
28886
d77de738 28887@opindex m10
ddf6fe37 28888@item -m10
d77de738
ML
28889Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
28890
d77de738
ML
28891@opindex mint16
28892@opindex mno-int32
ddf6fe37
AA
28893@item -mint16
28894@itemx -mno-int32
d77de738
ML
28895Use 16-bit @code{int}. This is the default.
28896
d77de738
ML
28897@opindex mint32
28898@opindex mno-int16
ddf6fe37
AA
28899@item -mint32
28900@itemx -mno-int16
d77de738
ML
28901Use 32-bit @code{int}.
28902
d77de738 28903@opindex msplit
ddf6fe37 28904@item -msplit
d77de738
ML
28905Target has split instruction and data space. Implies -m45.
28906
d77de738 28907@opindex munix-asm
ddf6fe37 28908@item -munix-asm
d77de738
ML
28909Use Unix assembler syntax.
28910
d77de738 28911@opindex mdec-asm
ddf6fe37 28912@item -mdec-asm
d77de738
ML
28913Use DEC assembler syntax.
28914
d77de738 28915@opindex mgnu-asm
ddf6fe37 28916@item -mgnu-asm
d77de738
ML
28917Use GNU assembler syntax. This is the default.
28918
d77de738 28919@opindex mlra
ddf6fe37 28920@item -mlra
d77de738
ML
28921Use the new LRA register allocator. By default, the old ``reload''
28922allocator is used.
28923@end table
28924
d77de738
ML
28925@node PowerPC Options
28926@subsection PowerPC Options
28927@cindex PowerPC options
28928
28929These are listed under @xref{RS/6000 and PowerPC Options}.
28930
28931@node PRU Options
28932@subsection PRU Options
28933@cindex PRU Options
28934
28935These command-line options are defined for PRU target:
28936
28937@table @gcctabopt
d77de738 28938@opindex minrt
ddf6fe37 28939@item -minrt
d77de738
ML
28940Link with a minimum runtime environment, with no support for static
28941initializers and constructors. Using this option can significantly reduce
28942the size of the final ELF binary. Beware that the compiler could still
28943generate code with static initializers and constructors. It is up to the
28944programmer to ensure that the source program will not use those features.
28945
d77de738 28946@opindex mmcu
ddf6fe37 28947@item -mmcu=@var{mcu}
d77de738
ML
28948Specify the PRU MCU variant to use. Check Newlib for the exact list of
28949supported MCUs.
28950
d77de738 28951@opindex mno-relax
ddf6fe37 28952@item -mno-relax
d77de738
ML
28953Make GCC pass the @option{--no-relax} command-line option to the linker
28954instead of the @option{--relax} option.
28955
d77de738 28956@opindex mloop
ddf6fe37 28957@item -mloop
d77de738
ML
28958Allow (or do not allow) GCC to use the LOOP instruction.
28959
d77de738 28960@opindex mabi
ddf6fe37 28961@item -mabi=@var{variant}
d77de738
ML
28962Specify the ABI variant to output code for. @option{-mabi=ti} selects the
28963unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
28964more naturally with certain GCC assumptions. These are the differences:
28965
28966@table @samp
28967@item Function Pointer Size
28968TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
28969supports only 32-bit data and code pointers.
28970
28971@item Optional Return Value Pointer
28972Function return values larger than 64 bits are passed by using a hidden
28973pointer as the first argument of the function. TI ABI, though, mandates that
28974the pointer can be NULL in case the caller is not using the returned value.
28975GNU always passes and expects a valid return value pointer.
28976
28977@end table
28978
28979The current @option{-mabi=ti} implementation simply raises a compile error
28980when any of the above code constructs is detected. As a consequence
28981the standard C library cannot be built and it is omitted when linking with
28982@option{-mabi=ti}.
28983
28984Relaxation is a GNU feature and for safety reasons is disabled when using
28985@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
28986instructions, so the GNU linker cannot adjust them when shortening adjacent
28987LDI32 pseudo instructions.
28988
28989@end table
28990
28991@node RISC-V Options
28992@subsection RISC-V Options
28993@cindex RISC-V Options
28994
28995These command-line options are defined for RISC-V targets:
28996
28997@table @gcctabopt
d77de738 28998@opindex mbranch-cost
ddf6fe37 28999@item -mbranch-cost=@var{n}
d77de738
ML
29000Set the cost of branches to roughly @var{n} instructions.
29001
ddf6fe37 29002@opindex plt
d77de738
ML
29003@item -mplt
29004@itemx -mno-plt
d77de738
ML
29005When generating PIC code, do or don't allow the use of PLTs. Ignored for
29006non-PIC. The default is @option{-mplt}.
29007
d77de738 29008@opindex mabi
ddf6fe37 29009@item -mabi=@var{ABI-string}
d77de738
ML
29010Specify integer and floating-point calling convention. @var{ABI-string}
29011contains two parts: the size of integer types and the registers used for
29012floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
29013@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2901432-bit), and that floating-point values up to 64 bits wide are passed in F
29015registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
29016allows the compiler to generate code that uses the F and D extensions but only
29017allows floating-point values up to 32 bits long to be passed in registers; or
29018@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
29019passed in registers.
29020
29021The default for this argument is system dependent, users who want a specific
29022calling convention should specify one explicitly. The valid calling
29023conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
29024@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
29025implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
29026invalid because the ABI requires 64-bit values be passed in F registers, but F
29027registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
29028only be used with the @samp{rv32e} architecture. This ABI is not well
29029specified at present, and is subject to change.
29030
ddf6fe37 29031@opindex mfdiv
d77de738
ML
29032@item -mfdiv
29033@itemx -mno-fdiv
d77de738
ML
29034Do or don't use hardware floating-point divide and square root instructions.
29035This requires the F or D extensions for floating-point registers. The default
29036is to use them if the specified architecture has these instructions.
29037
ddf6fe37 29038@opindex mdiv
d77de738
ML
29039@item -mdiv
29040@itemx -mno-div
d77de738
ML
29041Do or don't use hardware instructions for integer division. This requires the
29042M extension. The default is to use them if the specified architecture has
29043these instructions.
29044
d77de738 29045@opindex misa-spec
ddf6fe37 29046@item -misa-spec=@var{ISA-spec-string}
d77de738
ML
29047Specify the version of the RISC-V Unprivileged (formerly User-Level)
29048ISA specification to produce code conforming to. The possibilities
29049for @var{ISA-spec-string} are:
29050@table @code
29051@item 2.2
29052Produce code conforming to version 2.2.
29053@item 20190608
29054Produce code conforming to version 20190608.
29055@item 20191213
29056Produce code conforming to version 20191213.
29057@end table
29058The default is @option{-misa-spec=20191213} unless GCC has been configured
29059with @option{--with-isa-spec=} specifying a different default version.
29060
d77de738 29061@opindex march
ddf6fe37 29062@item -march=@var{ISA-string}
d77de738
ML
29063Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
29064lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
29065@samp{rv32imaf}.
29066
29067When @option{-march=} is not specified, use the setting from @option{-mcpu}.
29068
29069If both @option{-march} and @option{-mcpu=} are not specified, the default for
29070this argument is system dependent, users who want a specific architecture
29071extensions should specify one explicitly.
29072
d77de738 29073@opindex mcpu
ddf6fe37 29074@item -mcpu=@var{processor-string}
d77de738
ML
29075Use architecture of and optimize the output for the given processor, specified
29076by particular CPU name.
29077Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
29078@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
29079@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 29080@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738 29081
d77de738 29082@opindex mtune
ddf6fe37 29083@item -mtune=@var{processor-string}
d77de738
ML
29084Optimize the output for the given processor, specified by microarchitecture or
29085particular CPU name. Permissible values for this option are: @samp{rocket},
29086@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 29087@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
29088
29089When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
29090the default is @samp{rocket} if both are not specified.
29091
29092The @samp{size} choice is not intended for use by end-users. This is used
29093when @option{-Os} is specified. It overrides the instruction cost info
29094provided by @option{-mtune=}, but does not override the pipeline info. This
29095helps reduce code size while still giving good performance.
29096
d77de738 29097@opindex mpreferred-stack-boundary
ddf6fe37 29098@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
29099Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
29100byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
29101the default is 4 (16 bytes or 128-bits).
29102
29103@strong{Warning:} If you use this switch, then you must build all modules with
29104the same value, including any libraries. This includes the system libraries
29105and startup modules.
29106
d77de738 29107@opindex msmall-data-limit
ddf6fe37 29108@item -msmall-data-limit=@var{n}
d77de738
ML
29109Put global and static data smaller than @var{n} bytes into a special section
29110(on some targets).
29111
ddf6fe37 29112@opindex msave-restore
d77de738
ML
29113@item -msave-restore
29114@itemx -mno-save-restore
d77de738
ML
29115Do or don't use smaller but slower prologue and epilogue code that uses
29116library function calls. The default is to use fast inline prologues and
29117epilogues.
29118
f797260a
PN
29119@opindex minline-atomics
29120@item -minline-atomics
29121@itemx -mno-inline-atomics
29122Do or don't use smaller but slower subword atomic emulation code that uses
29123libatomic function calls. The default is to use fast inline subword atomics
29124that do not require libatomic.
29125
ddf6fe37 29126@opindex mshorten-memrefs
d77de738
ML
29127@item -mshorten-memrefs
29128@itemx -mno-shorten-memrefs
d77de738
ML
29129Do or do not attempt to make more use of compressed load/store instructions by
29130replacing a load/store of 'base register + large offset' with a new load/store
29131of 'new base + small offset'. If the new base gets stored in a compressed
29132register, then the new load/store can be compressed. Currently targets 32-bit
29133integer load/stores only.
29134
ddf6fe37 29135@opindex mstrict-align
d77de738
ML
29136@item -mstrict-align
29137@itemx -mno-strict-align
d77de738
ML
29138Do not or do generate unaligned memory accesses. The default is set depending
29139on whether the processor we are optimizing for supports fast unaligned access
29140or not.
29141
d77de738 29142@opindex mcmodel=medlow
ddf6fe37 29143@item -mcmodel=medlow
d77de738
ML
29144Generate code for the medium-low code model. The program and its statically
29145defined symbols must lie within a single 2 GiB address range and must lie
29146between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
29147statically or dynamically linked. This is the default code model.
29148
d77de738 29149@opindex mcmodel=medany
ddf6fe37 29150@item -mcmodel=medany
d77de738
ML
29151Generate code for the medium-any code model. The program and its statically
29152defined symbols must be within any single 2 GiB address range. Programs can be
29153statically or dynamically linked.
29154
29155The code generated by the medium-any code model is position-independent, but is
29156not guaranteed to function correctly when linked into position-independent
29157executables or libraries.
29158
29159@item -mexplicit-relocs
29160@itemx -mno-exlicit-relocs
29161Use or do not use assembler relocation operators when dealing with symbolic
29162addresses. The alternative is to use assembler macros instead, which may
29163limit optimization.
29164
ddf6fe37 29165@opindex mrelax
d77de738
ML
29166@item -mrelax
29167@itemx -mno-relax
d77de738
ML
29168Take advantage of linker relaxations to reduce the number of instructions
29169required to materialize symbol addresses. The default is to take advantage of
29170linker relaxations.
29171
ddf6fe37 29172@opindex mriscv-attribute
d77de738
ML
29173@item -mriscv-attribute
29174@itemx -mno-riscv-attribute
d77de738
ML
29175Emit (do not emit) RISC-V attribute to record extra information into ELF
29176objects. This feature requires at least binutils 2.32.
29177
ddf6fe37 29178@opindex mcsr-check
d77de738
ML
29179@item -mcsr-check
29180@itemx -mno-csr-check
d77de738
ML
29181Enables or disables the CSR checking.
29182
d77de738 29183@opindex malign-data
ddf6fe37 29184@item -malign-data=@var{type}
d77de738
ML
29185Control how GCC aligns variables and constants of array, structure, or union
29186types. Supported values for @var{type} are @samp{xlen} which uses x register
29187width as the alignment value, and @samp{natural} which uses natural alignment.
29188@samp{xlen} is the default.
29189
d77de738 29190@opindex mbig-endian
ddf6fe37 29191@item -mbig-endian
d77de738
ML
29192Generate big-endian code. This is the default when GCC is configured for a
29193@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
29194
d77de738 29195@opindex mlittle-endian
ddf6fe37 29196@item -mlittle-endian
d77de738
ML
29197Generate little-endian code. This is the default when GCC is configured for a
29198@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
29199@samp{riscv32be-*-*} target.
29200
d77de738
ML
29201@opindex mstack-protector-guard
29202@opindex mstack-protector-guard-reg
29203@opindex mstack-protector-guard-offset
ddf6fe37
AA
29204@item -mstack-protector-guard=@var{guard}
29205@itemx -mstack-protector-guard-reg=@var{reg}
29206@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
29207Generate stack protection code using canary at @var{guard}. Supported
29208locations are @samp{global} for a global canary or @samp{tls} for per-thread
29209canary in the TLS block.
29210
29211With the latter choice the options
29212@option{-mstack-protector-guard-reg=@var{reg}} and
29213@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
29214which register to use as base register for reading the canary,
29215and from what offset from that base register. There is no default
29216register or offset as this is entirely for use within the Linux
29217kernel.
29218@end table
29219
29220@node RL78 Options
29221@subsection RL78 Options
29222@cindex RL78 Options
29223
29224@table @gcctabopt
29225
d77de738 29226@opindex msim
ddf6fe37 29227@item -msim
d77de738
ML
29228Links in additional target libraries to support operation within a
29229simulator.
29230
ddf6fe37 29231@opindex mmul
d77de738
ML
29232@item -mmul=none
29233@itemx -mmul=g10
29234@itemx -mmul=g13
29235@itemx -mmul=g14
29236@itemx -mmul=rl78
d77de738
ML
29237Specifies the type of hardware multiplication and division support to
29238be used. The simplest is @code{none}, which uses software for both
29239multiplication and division. This is the default. The @code{g13}
29240value is for the hardware multiply/divide peripheral found on the
29241RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
29242the multiplication and division instructions supported by the RL78/G14
29243(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
29244the value @code{mg10} is an alias for @code{none}.
29245
29246In addition a C preprocessor macro is defined, based upon the setting
29247of this option. Possible values are: @code{__RL78_MUL_NONE__},
29248@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
29249
ddf6fe37 29250@opindex mcpu
d77de738
ML
29251@item -mcpu=g10
29252@itemx -mcpu=g13
29253@itemx -mcpu=g14
29254@itemx -mcpu=rl78
d77de738
ML
29255Specifies the RL78 core to target. The default is the G14 core, also
29256known as an S3 core or just RL78. The G13 or S2 core does not have
29257multiply or divide instructions, instead it uses a hardware peripheral
29258for these operations. The G10 or S1 core does not have register
29259banks, so it uses a different calling convention.
29260
29261If this option is set it also selects the type of hardware multiply
29262support to use, unless this is overridden by an explicit
29263@option{-mmul=none} option on the command line. Thus specifying
29264@option{-mcpu=g13} enables the use of the G13 hardware multiply
29265peripheral and specifying @option{-mcpu=g10} disables the use of
29266hardware multiplications altogether.
29267
29268Note, although the RL78/G14 core is the default target, specifying
29269@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
29270change the behavior of the toolchain since it also enables G14
29271hardware multiply support. If these options are not specified on the
29272command line then software multiplication routines will be used even
29273though the code targets the RL78 core. This is for backwards
29274compatibility with older toolchains which did not have hardware
29275multiply and divide support.
29276
29277In addition a C preprocessor macro is defined, based upon the setting
29278of this option. Possible values are: @code{__RL78_G10__},
29279@code{__RL78_G13__} or @code{__RL78_G14__}.
29280
d77de738
ML
29281@opindex mg10
29282@opindex mg13
29283@opindex mg14
29284@opindex mrl78
ddf6fe37
AA
29285@item -mg10
29286@itemx -mg13
29287@itemx -mg14
29288@itemx -mrl78
d77de738
ML
29289These are aliases for the corresponding @option{-mcpu=} option. They
29290are provided for backwards compatibility.
29291
d77de738 29292@opindex mallregs
ddf6fe37 29293@item -mallregs
d77de738
ML
29294Allow the compiler to use all of the available registers. By default
29295registers @code{r24..r31} are reserved for use in interrupt handlers.
29296With this option enabled these registers can be used in ordinary
29297functions as well.
29298
d77de738
ML
29299@opindex m64bit-doubles
29300@opindex m32bit-doubles
ddf6fe37
AA
29301@item -m64bit-doubles
29302@itemx -m32bit-doubles
d77de738
ML
29303Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29304or 32 bits (@option{-m32bit-doubles}) in size. The default is
29305@option{-m32bit-doubles}.
29306
d77de738
ML
29307@opindex msave-mduc-in-interrupts
29308@opindex mno-save-mduc-in-interrupts
ddf6fe37
AA
29309@item -msave-mduc-in-interrupts
29310@itemx -mno-save-mduc-in-interrupts
d77de738
ML
29311Specifies that interrupt handler functions should preserve the
29312MDUC registers. This is only necessary if normal code might use
29313the MDUC registers, for example because it performs multiplication
29314and division operations. The default is to ignore the MDUC registers
29315as this makes the interrupt handlers faster. The target option -mg13
29316needs to be passed for this to work as this feature is only available
29317on the G13 target (S2 core). The MDUC registers will only be saved
29318if the interrupt handler performs a multiplication or division
29319operation or it calls another function.
29320
29321@end table
29322
29323@node RS/6000 and PowerPC Options
29324@subsection IBM RS/6000 and PowerPC Options
29325@cindex RS/6000 and PowerPC Options
29326@cindex IBM RS/6000 and PowerPC Options
29327
29328These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29329@table @gcctabopt
29330@item -mpowerpc-gpopt
29331@itemx -mno-powerpc-gpopt
29332@itemx -mpowerpc-gfxopt
29333@itemx -mno-powerpc-gfxopt
29334@need 800
29335@itemx -mpowerpc64
29336@itemx -mno-powerpc64
29337@itemx -mmfcrf
29338@itemx -mno-mfcrf
29339@itemx -mpopcntb
29340@itemx -mno-popcntb
29341@itemx -mpopcntd
29342@itemx -mno-popcntd
29343@itemx -mfprnd
29344@itemx -mno-fprnd
29345@need 800
d77de738
ML
29346@opindex mpowerpc-gpopt
29347@opindex mno-powerpc-gpopt
29348@opindex mpowerpc-gfxopt
29349@opindex mno-powerpc-gfxopt
29350@opindex mpowerpc64
29351@opindex mno-powerpc64
29352@opindex mmfcrf
29353@opindex mno-mfcrf
29354@opindex mpopcntb
29355@opindex mno-popcntb
29356@opindex mpopcntd
29357@opindex mno-popcntd
29358@opindex mfprnd
29359@opindex mno-fprnd
29360@opindex mcmpb
29361@opindex mno-cmpb
29362@opindex mhard-dfp
29363@opindex mno-hard-dfp
ddf6fe37
AA
29364@itemx -mcmpb
29365@itemx -mno-cmpb
29366@itemx -mhard-dfp
29367@itemx -mno-hard-dfp
d77de738
ML
29368You use these options to specify which instructions are available on the
29369processor you are using. The default value of these options is
29370determined when configuring GCC@. Specifying the
29371@option{-mcpu=@var{cpu_type}} overrides the specification of these
29372options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29373rather than the options listed above.
29374
29375Specifying @option{-mpowerpc-gpopt} allows
29376GCC to use the optional PowerPC architecture instructions in the
29377General Purpose group, including floating-point square root. Specifying
29378@option{-mpowerpc-gfxopt} allows GCC to
29379use the optional PowerPC architecture instructions in the Graphics
29380group, including floating-point select.
29381
29382The @option{-mmfcrf} option allows GCC to generate the move from
29383condition register field instruction implemented on the POWER4
29384processor and other processors that support the PowerPC V2.01
29385architecture.
29386The @option{-mpopcntb} option allows GCC to generate the popcount and
29387double-precision FP reciprocal estimate instruction implemented on the
29388POWER5 processor and other processors that support the PowerPC V2.02
29389architecture.
29390The @option{-mpopcntd} option allows GCC to generate the popcount
29391instruction implemented on the POWER7 processor and other processors
29392that support the PowerPC V2.06 architecture.
29393The @option{-mfprnd} option allows GCC to generate the FP round to
29394integer instructions implemented on the POWER5+ processor and other
29395processors that support the PowerPC V2.03 architecture.
29396The @option{-mcmpb} option allows GCC to generate the compare bytes
29397instruction implemented on the POWER6 processor and other processors
29398that support the PowerPC V2.05 architecture.
29399The @option{-mhard-dfp} option allows GCC to generate the decimal
29400floating-point instructions implemented on some POWER processors.
29401
29402The @option{-mpowerpc64} option allows GCC to generate the additional
2940364-bit instructions that are found in the full PowerPC64 architecture
29404and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29405@option{-mno-powerpc64}.
29406
d77de738 29407@opindex mcpu
ddf6fe37 29408@item -mcpu=@var{cpu_type}
d77de738
ML
29409Set architecture type, register usage, and
29410instruction scheduling parameters for machine type @var{cpu_type}.
29411Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29412@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29413@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29414@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29415@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29416@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29417@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29418@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29419@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29420@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29421@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29422@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29423
29424@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29425@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29426endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29427architecture machine types, with an appropriate, generic processor
29428model assumed for scheduling purposes.
29429
29430Specifying @samp{native} as cpu type detects and selects the
29431architecture option that corresponds to the host processor of the
29432system performing the compilation.
29433@option{-mcpu=native} has no effect if GCC does not recognize the
29434processor.
29435
29436The other options specify a specific processor. Code generated under
29437those options runs best on that processor, and may not run at all on
29438others.
29439
29440The @option{-mcpu} options automatically enable or disable the
29441following options:
29442
43b72ede
AA
29443@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
29444-mpopcntb -mpopcntd -mpowerpc64
29445-mpowerpc-gpopt -mpowerpc-gfxopt
29446-mmulhw -mdlmzb -mmfpgpr -mvsx
29447-mcrypto -mhtm -mpower8-fusion -mpower8-vector
29448-mquad-memory -mquad-memory-atomic -mfloat128
29449-mfloat128-hardware -mprefixed -mpcrel -mmma
d77de738
ML
29450-mrop-protect}
29451
29452The particular options set for any particular CPU varies between
29453compiler versions, depending on what setting seems to produce optimal
29454code for that CPU; it doesn't necessarily reflect the actual hardware's
29455capabilities. If you wish to set an individual option to a particular
29456value, you may specify it after the @option{-mcpu} option, like
29457@option{-mcpu=970 -mno-altivec}.
29458
29459On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29460not enabled or disabled by the @option{-mcpu} option at present because
29461AIX does not have full support for these options. You may still
29462enable or disable them individually if you're sure it'll work in your
29463environment.
29464
d77de738 29465@opindex mtune
ddf6fe37 29466@item -mtune=@var{cpu_type}
d77de738
ML
29467Set the instruction scheduling parameters for machine type
29468@var{cpu_type}, but do not set the architecture type or register usage,
29469as @option{-mcpu=@var{cpu_type}} does. The same
29470values for @var{cpu_type} are used for @option{-mtune} as for
29471@option{-mcpu}. If both are specified, the code generated uses the
29472architecture and registers set by @option{-mcpu}, but the
29473scheduling parameters set by @option{-mtune}.
29474
d77de738 29475@opindex mcmodel=small
ddf6fe37 29476@item -mcmodel=small
d77de738
ML
29477Generate PowerPC64 code for the small model: The TOC is limited to
2947864k.
29479
d77de738 29480@opindex mcmodel=medium
ddf6fe37 29481@item -mcmodel=medium
d77de738
ML
29482Generate PowerPC64 code for the medium model: The TOC and other static
29483data may be up to a total of 4G in size. This is the default for 64-bit
29484Linux.
29485
d77de738 29486@opindex mcmodel=large
ddf6fe37 29487@item -mcmodel=large
d77de738
ML
29488Generate PowerPC64 code for the large model: The TOC may be up to 4G
29489in size. Other data and code is only limited by the 64-bit address
29490space.
29491
d77de738
ML
29492@opindex maltivec
29493@opindex mno-altivec
ddf6fe37
AA
29494@item -maltivec
29495@itemx -mno-altivec
d77de738
ML
29496Generate code that uses (does not use) AltiVec instructions, and also
29497enable the use of built-in functions that allow more direct access to
29498the AltiVec instruction set. You may also need to set
29499@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29500enhancements.
29501
29502When @option{-maltivec} is used, the element order for AltiVec intrinsics
29503such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29504match array element order corresponding to the endianness of the
29505target. That is, element zero identifies the leftmost element in a
29506vector register when targeting a big-endian platform, and identifies
29507the rightmost element in a vector register when targeting a
29508little-endian platform.
29509
d77de738
ML
29510@opindex mvrsave
29511@opindex mno-vrsave
ddf6fe37
AA
29512@item -mvrsave
29513@itemx -mno-vrsave
d77de738
ML
29514Generate VRSAVE instructions when generating AltiVec code.
29515
d77de738 29516@opindex msecure-plt
ddf6fe37 29517@item -msecure-plt
d77de738
ML
29518Generate code that allows @command{ld} and @command{ld.so}
29519to build executables and shared
29520libraries with non-executable @code{.plt} and @code{.got} sections.
29521This is a PowerPC
2952232-bit SYSV ABI option.
29523
d77de738 29524@opindex mbss-plt
ddf6fe37 29525@item -mbss-plt
d77de738
ML
29526Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29527fills in, and
29528requires @code{.plt} and @code{.got}
29529sections that are both writable and executable.
29530This is a PowerPC 32-bit SYSV ABI option.
29531
d77de738
ML
29532@opindex misel
29533@opindex mno-isel
ddf6fe37
AA
29534@item -misel
29535@itemx -mno-isel
d77de738
ML
29536This switch enables or disables the generation of ISEL instructions.
29537
d77de738
ML
29538@opindex mvsx
29539@opindex mno-vsx
ddf6fe37
AA
29540@item -mvsx
29541@itemx -mno-vsx
d77de738
ML
29542Generate code that uses (does not use) vector/scalar (VSX)
29543instructions, and also enable the use of built-in functions that allow
29544more direct access to the VSX instruction set.
29545
d77de738
ML
29546@opindex mcrypto
29547@opindex mno-crypto
ddf6fe37
AA
29548@item -mcrypto
29549@itemx -mno-crypto
d77de738
ML
29550Enable the use (disable) of the built-in functions that allow direct
29551access to the cryptographic instructions that were added in version
295522.07 of the PowerPC ISA.
29553
d77de738
ML
29554@opindex mhtm
29555@opindex mno-htm
ddf6fe37
AA
29556@item -mhtm
29557@itemx -mno-htm
d77de738
ML
29558Enable (disable) the use of the built-in functions that allow direct
29559access to the Hardware Transactional Memory (HTM) instructions that
29560were added in version 2.07 of the PowerPC ISA.
29561
d77de738
ML
29562@opindex mpower8-fusion
29563@opindex mno-power8-fusion
ddf6fe37
AA
29564@item -mpower8-fusion
29565@itemx -mno-power8-fusion
d77de738
ML
29566Generate code that keeps (does not keeps) some integer operations
29567adjacent so that the instructions can be fused together on power8 and
29568later processors.
29569
d77de738
ML
29570@opindex mpower8-vector
29571@opindex mno-power8-vector
ddf6fe37
AA
29572@item -mpower8-vector
29573@itemx -mno-power8-vector
d77de738
ML
29574Generate code that uses (does not use) the vector and scalar
29575instructions that were added in version 2.07 of the PowerPC ISA. Also
29576enable the use of built-in functions that allow more direct access to
29577the vector instructions.
29578
d77de738
ML
29579@opindex mquad-memory
29580@opindex mno-quad-memory
ddf6fe37
AA
29581@item -mquad-memory
29582@itemx -mno-quad-memory
d77de738
ML
29583Generate code that uses (does not use) the non-atomic quad word memory
29584instructions. The @option{-mquad-memory} option requires use of
2958564-bit mode.
29586
d77de738
ML
29587@opindex mquad-memory-atomic
29588@opindex mno-quad-memory-atomic
ddf6fe37
AA
29589@item -mquad-memory-atomic
29590@itemx -mno-quad-memory-atomic
d77de738
ML
29591Generate code that uses (does not use) the atomic quad word memory
29592instructions. The @option{-mquad-memory-atomic} option requires use of
2959364-bit mode.
29594
d77de738
ML
29595@opindex mfloat128
29596@opindex mno-float128
ddf6fe37
AA
29597@item -mfloat128
29598@itemx -mno-float128
d77de738
ML
29599Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29600and use either software emulation for IEEE 128-bit floating point or
29601hardware instructions.
29602
29603The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29604128-bit floating point support. The IEEE 128-bit floating point is only
29605supported on Linux.
29606
29607The default for @option{-mfloat128} is enabled on PowerPC Linux
29608systems using the VSX instruction set, and disabled on other systems.
29609
29610If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29611@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29612point support will also enable the generation of ISA 3.0 IEEE 128-bit
29613floating point instructions. Otherwise, if you do not specify to
29614generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29615system, IEEE 128-bit floating point will be done with software
29616emulation.
29617
d77de738
ML
29618@opindex mfloat128-hardware
29619@opindex mno-float128-hardware
ddf6fe37
AA
29620@item -mfloat128-hardware
29621@itemx -mno-float128-hardware
d77de738
ML
29622Enable/disable using ISA 3.0 hardware instructions to support the
29623@var{__float128} data type.
29624
29625The default for @option{-mfloat128-hardware} is enabled on PowerPC
29626Linux systems using the ISA 3.0 instruction set, and disabled on other
29627systems.
29628
d77de738
ML
29629@opindex m32
29630@opindex m64
ddf6fe37
AA
29631@item -m32
29632@itemx -m64
d77de738
ML
29633Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29634targets (including GNU/Linux). The 32-bit environment sets int, long
29635and pointer to 32 bits and generates code that runs on any PowerPC
29636variant. The 64-bit environment sets int to 32 bits and long and
29637pointer to 64 bits, and generates code for PowerPC64, as for
29638@option{-mpowerpc64}.
29639
d77de738
ML
29640@opindex mfull-toc
29641@opindex mno-fp-in-toc
29642@opindex mno-sum-in-toc
29643@opindex mminimal-toc
ddf6fe37
AA
29644@item -mfull-toc
29645@itemx -mno-fp-in-toc
29646@itemx -mno-sum-in-toc
29647@itemx -mminimal-toc
d77de738
ML
29648Modify generation of the TOC (Table Of Contents), which is created for
29649every executable file. The @option{-mfull-toc} option is selected by
29650default. In that case, GCC allocates at least one TOC entry for
29651each unique non-automatic variable reference in your program. GCC
29652also places floating-point constants in the TOC@. However, only
2965316,384 entries are available in the TOC@.
29654
29655If you receive a linker error message that saying you have overflowed
29656the available TOC space, you can reduce the amount of TOC space used
29657with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
29658@option{-mno-fp-in-toc} prevents GCC from putting floating-point
29659constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
29660generate code to calculate the sum of an address and a constant at
29661run time instead of putting that sum into the TOC@. You may specify one
29662or both of these options. Each causes GCC to produce very slightly
29663slower and larger code at the expense of conserving TOC space.
29664
29665If you still run out of space in the TOC even when you specify both of
29666these options, specify @option{-mminimal-toc} instead. This option causes
29667GCC to make only one TOC entry for every file. When you specify this
29668option, GCC produces code that is slower and larger but which
29669uses extremely little TOC space. You may wish to use this option
29670only on files that contain less frequently-executed code.
29671
d77de738
ML
29672@opindex maix64
29673@opindex maix32
ddf6fe37
AA
29674@item -maix64
29675@itemx -maix32
d77de738
ML
29676Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
29677@code{long} type, and the infrastructure needed to support them.
29678Specifying @option{-maix64} implies @option{-mpowerpc64},
29679while @option{-maix32} disables the 64-bit ABI and
29680implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
29681
d77de738
ML
29682@opindex mxl-compat
29683@opindex mno-xl-compat
ddf6fe37
AA
29684@item -mxl-compat
29685@itemx -mno-xl-compat
d77de738
ML
29686Produce code that conforms more closely to IBM XL compiler semantics
29687when using AIX-compatible ABI@. Pass floating-point arguments to
29688prototyped functions beyond the register save area (RSA) on the stack
29689in addition to argument FPRs. Do not assume that most significant
29690double in 128-bit long double value is properly rounded when comparing
29691values and converting to double. Use XL symbol names for long double
29692support routines.
29693
29694The AIX calling convention was extended but not initially documented to
29695handle an obscure K&R C case of calling a function that takes the
29696address of its arguments with fewer arguments than declared. IBM XL
29697compilers access floating-point arguments that do not fit in the
29698RSA from the stack when a subroutine is compiled without
29699optimization. Because always storing floating-point arguments on the
29700stack is inefficient and rarely needed, this option is not enabled by
29701default and only is necessary when calling subroutines compiled by IBM
29702XL compilers without optimization.
29703
d77de738 29704@opindex mpe
ddf6fe37 29705@item -mpe
d77de738
ML
29706Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
29707application written to use message passing with special startup code to
29708enable the application to run. The system must have PE installed in the
29709standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
29710must be overridden with the @option{-specs=} option to specify the
29711appropriate directory location. The Parallel Environment does not
29712support threads, so the @option{-mpe} option and the @option{-pthread}
29713option are incompatible.
29714
d77de738
ML
29715@opindex malign-natural
29716@opindex malign-power
ddf6fe37
AA
29717@item -malign-natural
29718@itemx -malign-power
d77de738
ML
29719On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
29720@option{-malign-natural} overrides the ABI-defined alignment of larger
29721types, such as floating-point doubles, on their natural size-based boundary.
29722The option @option{-malign-power} instructs GCC to follow the ABI-specified
29723alignment rules. GCC defaults to the standard alignment defined in the ABI@.
29724
29725On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
29726is not supported.
29727
d77de738
ML
29728@opindex msoft-float
29729@opindex mhard-float
ddf6fe37
AA
29730@item -msoft-float
29731@itemx -mhard-float
d77de738
ML
29732Generate code that does not use (uses) the floating-point register set.
29733Software floating-point emulation is provided if you use the
29734@option{-msoft-float} option, and pass the option to GCC when linking.
29735
d77de738
ML
29736@opindex mmultiple
29737@opindex mno-multiple
ddf6fe37
AA
29738@item -mmultiple
29739@itemx -mno-multiple
d77de738
ML
29740Generate code that uses (does not use) the load multiple word
29741instructions and the store multiple word instructions. These
29742instructions are generated by default on POWER systems, and not
29743generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
29744PowerPC systems, since those instructions do not work when the
29745processor is in little-endian mode. The exceptions are PPC740 and
29746PPC750 which permit these instructions in little-endian mode.
29747
d77de738
ML
29748@opindex mupdate
29749@opindex mno-update
ddf6fe37
AA
29750@item -mupdate
29751@itemx -mno-update
d77de738
ML
29752Generate code that uses (does not use) the load or store instructions
29753that update the base register to the address of the calculated memory
29754location. These instructions are generated by default. If you use
29755@option{-mno-update}, there is a small window between the time that the
29756stack pointer is updated and the address of the previous frame is
29757stored, which means code that walks the stack frame across interrupts or
29758signals may get corrupted data.
29759
d77de738
ML
29760@opindex mavoid-indexed-addresses
29761@opindex mno-avoid-indexed-addresses
ddf6fe37
AA
29762@item -mavoid-indexed-addresses
29763@itemx -mno-avoid-indexed-addresses
d77de738
ML
29764Generate code that tries to avoid (not avoid) the use of indexed load
29765or store instructions. These instructions can incur a performance
29766penalty on Power6 processors in certain situations, such as when
29767stepping through large arrays that cross a 16M boundary. This option
29768is enabled by default when targeting Power6 and disabled otherwise.
29769
d77de738
ML
29770@opindex mfused-madd
29771@opindex mno-fused-madd
ddf6fe37
AA
29772@item -mfused-madd
29773@itemx -mno-fused-madd
d77de738
ML
29774Generate code that uses (does not use) the floating-point multiply and
29775accumulate instructions. These instructions are generated by default
29776if hardware floating point is used. The machine-dependent
29777@option{-mfused-madd} option is now mapped to the machine-independent
29778@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29779mapped to @option{-ffp-contract=off}.
29780
d77de738
ML
29781@opindex mmulhw
29782@opindex mno-mulhw
ddf6fe37
AA
29783@item -mmulhw
29784@itemx -mno-mulhw
d77de738
ML
29785Generate code that uses (does not use) the half-word multiply and
29786multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
29787These instructions are generated by default when targeting those
29788processors.
29789
d77de738
ML
29790@opindex mdlmzb
29791@opindex mno-dlmzb
ddf6fe37
AA
29792@item -mdlmzb
29793@itemx -mno-dlmzb
d77de738
ML
29794Generate code that uses (does not use) the string-search @samp{dlmzb}
29795instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
29796generated by default when targeting those processors.
29797
d77de738
ML
29798@opindex mno-bit-align
29799@opindex mbit-align
ddf6fe37
AA
29800@item -mno-bit-align
29801@itemx -mbit-align
d77de738
ML
29802On System V.4 and embedded PowerPC systems do not (do) force structures
29803and unions that contain bit-fields to be aligned to the base type of the
29804bit-field.
29805
29806For example, by default a structure containing nothing but 8
29807@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
29808boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
29809the structure is aligned to a 1-byte boundary and is 1 byte in
29810size.
29811
d77de738
ML
29812@opindex mno-strict-align
29813@opindex mstrict-align
ddf6fe37
AA
29814@item -mno-strict-align
29815@itemx -mstrict-align
d77de738
ML
29816On System V.4 and embedded PowerPC systems do not (do) assume that
29817unaligned memory references are handled by the system.
29818
d77de738
ML
29819@opindex mrelocatable
29820@opindex mno-relocatable
ddf6fe37
AA
29821@item -mrelocatable
29822@itemx -mno-relocatable
d77de738
ML
29823Generate code that allows (does not allow) a static executable to be
29824relocated to a different address at run time. A simple embedded
29825PowerPC system loader should relocate the entire contents of
29826@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
29827a table of 32-bit addresses generated by this option. For this to
29828work, all objects linked together must be compiled with
29829@option{-mrelocatable} or @option{-mrelocatable-lib}.
29830@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
29831
d77de738
ML
29832@opindex mrelocatable-lib
29833@opindex mno-relocatable-lib
ddf6fe37
AA
29834@item -mrelocatable-lib
29835@itemx -mno-relocatable-lib
d77de738
ML
29836Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
29837@code{.fixup} section to allow static executables to be relocated at
29838run time, but @option{-mrelocatable-lib} does not use the smaller stack
29839alignment of @option{-mrelocatable}. Objects compiled with
29840@option{-mrelocatable-lib} may be linked with objects compiled with
29841any combination of the @option{-mrelocatable} options.
29842
d77de738
ML
29843@opindex mno-toc
29844@opindex mtoc
ddf6fe37
AA
29845@item -mno-toc
29846@itemx -mtoc
d77de738
ML
29847On System V.4 and embedded PowerPC systems do not (do) assume that
29848register 2 contains a pointer to a global area pointing to the addresses
29849used in the program.
29850
d77de738
ML
29851@opindex mlittle
29852@opindex mlittle-endian
ddf6fe37
AA
29853@item -mlittle
29854@itemx -mlittle-endian
d77de738
ML
29855On System V.4 and embedded PowerPC systems compile code for the
29856processor in little-endian mode. The @option{-mlittle-endian} option is
29857the same as @option{-mlittle}.
29858
d77de738
ML
29859@opindex mbig
29860@opindex mbig-endian
ddf6fe37
AA
29861@item -mbig
29862@itemx -mbig-endian
d77de738
ML
29863On System V.4 and embedded PowerPC systems compile code for the
29864processor in big-endian mode. The @option{-mbig-endian} option is
29865the same as @option{-mbig}.
29866
d77de738 29867@opindex mdynamic-no-pic
ddf6fe37 29868@item -mdynamic-no-pic
d77de738
ML
29869On Darwin and Mac OS X systems, compile code so that it is not
29870relocatable, but that its external references are relocatable. The
29871resulting code is suitable for applications, but not shared
29872libraries.
29873
d77de738 29874@opindex msingle-pic-base
ddf6fe37 29875@item -msingle-pic-base
d77de738
ML
29876Treat the register used for PIC addressing as read-only, rather than
29877loading it in the prologue for each function. The runtime system is
29878responsible for initializing this register with an appropriate value
29879before execution begins.
29880
d77de738 29881@opindex mprioritize-restricted-insns
ddf6fe37 29882@item -mprioritize-restricted-insns=@var{priority}
d77de738
ML
29883This option controls the priority that is assigned to
29884dispatch-slot restricted instructions during the second scheduling
29885pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
29886or @samp{2} to assign no, highest, or second-highest (respectively)
29887priority to dispatch-slot restricted
29888instructions.
29889
d77de738 29890@opindex msched-costly-dep
ddf6fe37 29891@item -msched-costly-dep=@var{dependence_type}
d77de738
ML
29892This option controls which dependences are considered costly
29893by the target during instruction scheduling. The argument
29894@var{dependence_type} takes one of the following values:
29895
29896@table @asis
29897@item @samp{no}
29898No dependence is costly.
29899
29900@item @samp{all}
29901All dependences are costly.
29902
29903@item @samp{true_store_to_load}
29904A true dependence from store to load is costly.
29905
29906@item @samp{store_to_load}
29907Any dependence from store to load is costly.
29908
29909@item @var{number}
29910Any dependence for which the latency is greater than or equal to
29911@var{number} is costly.
29912@end table
29913
d77de738 29914@opindex minsert-sched-nops
ddf6fe37 29915@item -minsert-sched-nops=@var{scheme}
d77de738
ML
29916This option controls which NOP insertion scheme is used during
29917the second scheduling pass. The argument @var{scheme} takes one of the
29918following values:
29919
29920@table @asis
29921@item @samp{no}
29922Don't insert NOPs.
29923
29924@item @samp{pad}
29925Pad with NOPs any dispatch group that has vacant issue slots,
29926according to the scheduler's grouping.
29927
29928@item @samp{regroup_exact}
29929Insert NOPs to force costly dependent insns into
29930separate groups. Insert exactly as many NOPs as needed to force an insn
29931to a new group, according to the estimated processor grouping.
29932
29933@item @var{number}
29934Insert NOPs to force costly dependent insns into
29935separate groups. Insert @var{number} NOPs to force an insn to a new group.
29936@end table
29937
d77de738 29938@opindex mcall-sysv
ddf6fe37 29939@item -mcall-sysv
d77de738
ML
29940On System V.4 and embedded PowerPC systems compile code using calling
29941conventions that adhere to the March 1995 draft of the System V
29942Application Binary Interface, PowerPC processor supplement. This is the
29943default unless you configured GCC using @samp{powerpc-*-eabiaix}.
29944
d77de738
ML
29945@opindex mcall-sysv-eabi
29946@opindex mcall-eabi
ddf6fe37
AA
29947@item -mcall-sysv-eabi
29948@itemx -mcall-eabi
d77de738
ML
29949Specify both @option{-mcall-sysv} and @option{-meabi} options.
29950
d77de738 29951@opindex mcall-sysv-noeabi
ddf6fe37 29952@item -mcall-sysv-noeabi
d77de738
ML
29953Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
29954
d7971cf7 29955@opindex mcall-aixdesc
ddf6fe37 29956@item -mcall-aixdesc
d77de738
ML
29957On System V.4 and embedded PowerPC systems compile code for the AIX
29958operating system.
29959
d77de738 29960@opindex mcall-linux
ddf6fe37 29961@item -mcall-linux
d77de738
ML
29962On System V.4 and embedded PowerPC systems compile code for the
29963Linux-based GNU system.
29964
d77de738 29965@opindex mcall-freebsd
ddf6fe37 29966@item -mcall-freebsd
d77de738
ML
29967On System V.4 and embedded PowerPC systems compile code for the
29968FreeBSD operating system.
29969
d77de738 29970@opindex mcall-netbsd
ddf6fe37 29971@item -mcall-netbsd
d77de738
ML
29972On System V.4 and embedded PowerPC systems compile code for the
29973NetBSD operating system.
29974
d7971cf7 29975@opindex mcall-openbsd
ddf6fe37 29976@item -mcall-openbsd
d77de738
ML
29977On System V.4 and embedded PowerPC systems compile code for the
29978OpenBSD operating system.
29979
d77de738 29980@opindex mtraceback
ddf6fe37 29981@item -mtraceback=@var{traceback_type}
d77de738
ML
29982Select the type of traceback table. Valid values for @var{traceback_type}
29983are @samp{full}, @samp{part}, and @samp{no}.
29984
d77de738 29985@opindex maix-struct-return
ddf6fe37 29986@item -maix-struct-return
d77de738
ML
29987Return all structures in memory (as specified by the AIX ABI)@.
29988
d77de738 29989@opindex msvr4-struct-return
ddf6fe37 29990@item -msvr4-struct-return
d77de738
ML
29991Return structures smaller than 8 bytes in registers (as specified by the
29992SVR4 ABI)@.
29993
d77de738 29994@opindex mabi
ddf6fe37 29995@item -mabi=@var{abi-type}
d77de738
ML
29996Extend the current ABI with a particular extension, or remove such extension.
29997Valid values are: @samp{altivec}, @samp{no-altivec},
29998@samp{ibmlongdouble}, @samp{ieeelongdouble},
29999@samp{elfv1}, @samp{elfv2},
30000and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
30001
d77de738 30002@opindex mabi=ibmlongdouble
ddf6fe37 30003@item -mabi=ibmlongdouble
d77de738
ML
30004Change the current ABI to use IBM extended-precision long double.
30005This is not likely to work if your system defaults to using IEEE
30006extended-precision long double. If you change the long double type
30007from IEEE extended-precision, the compiler will issue a warning unless
30008you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
30009to be enabled.
30010
d77de738 30011@opindex mabi=ieeelongdouble
ddf6fe37 30012@item -mabi=ieeelongdouble
d77de738
ML
30013Change the current ABI to use IEEE extended-precision long double.
30014This is not likely to work if your system defaults to using IBM
30015extended-precision long double. If you change the long double type
30016from IBM extended-precision, the compiler will issue a warning unless
30017you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
30018to be enabled.
30019
d77de738 30020@opindex mabi=elfv1
ddf6fe37 30021@item -mabi=elfv1
d77de738
ML
30022Change the current ABI to use the ELFv1 ABI.
30023This is the default ABI for big-endian PowerPC 64-bit Linux.
30024Overriding the default ABI requires special system support and is
30025likely to fail in spectacular ways.
30026
d77de738 30027@opindex mabi=elfv2
ddf6fe37 30028@item -mabi=elfv2
d77de738
ML
30029Change the current ABI to use the ELFv2 ABI.
30030This is the default ABI for little-endian PowerPC 64-bit Linux.
30031Overriding the default ABI requires special system support and is
30032likely to fail in spectacular ways.
30033
d77de738
ML
30034@opindex mgnu-attribute
30035@opindex mno-gnu-attribute
ddf6fe37
AA
30036@item -mgnu-attribute
30037@itemx -mno-gnu-attribute
d77de738
ML
30038Emit .gnu_attribute assembly directives to set tag/value pairs in a
30039.gnu.attributes section that specify ABI variations in function
30040parameters or return values.
30041
d77de738
ML
30042@opindex mprototype
30043@opindex mno-prototype
ddf6fe37
AA
30044@item -mprototype
30045@itemx -mno-prototype
d77de738
ML
30046On System V.4 and embedded PowerPC systems assume that all calls to
30047variable argument functions are properly prototyped. Otherwise, the
30048compiler must insert an instruction before every non-prototyped call to
30049set or clear bit 6 of the condition code register (@code{CR}) to
30050indicate whether floating-point values are passed in the floating-point
30051registers in case the function takes variable arguments. With
30052@option{-mprototype}, only calls to prototyped variable argument functions
30053set or clear the bit.
30054
d77de738 30055@opindex msim
ddf6fe37 30056@item -msim
d77de738
ML
30057On embedded PowerPC systems, assume that the startup module is called
30058@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
30059@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
30060configurations.
30061
d77de738 30062@opindex mmvme
ddf6fe37 30063@item -mmvme
d77de738
ML
30064On embedded PowerPC systems, assume that the startup module is called
30065@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
30066@file{libc.a}.
30067
d77de738 30068@opindex mads
ddf6fe37 30069@item -mads
d77de738
ML
30070On embedded PowerPC systems, assume that the startup module is called
30071@file{crt0.o} and the standard C libraries are @file{libads.a} and
30072@file{libc.a}.
30073
d77de738 30074@opindex myellowknife
ddf6fe37 30075@item -myellowknife
d77de738
ML
30076On embedded PowerPC systems, assume that the startup module is called
30077@file{crt0.o} and the standard C libraries are @file{libyk.a} and
30078@file{libc.a}.
30079
d77de738 30080@opindex mvxworks
ddf6fe37 30081@item -mvxworks
d77de738
ML
30082On System V.4 and embedded PowerPC systems, specify that you are
30083compiling for a VxWorks system.
30084
d77de738 30085@opindex memb
ddf6fe37 30086@item -memb
d77de738
ML
30087On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
30088header to indicate that @samp{eabi} extended relocations are used.
30089
d77de738
ML
30090@opindex meabi
30091@opindex mno-eabi
ddf6fe37
AA
30092@item -meabi
30093@itemx -mno-eabi
d77de738
ML
30094On System V.4 and embedded PowerPC systems do (do not) adhere to the
30095Embedded Applications Binary Interface (EABI), which is a set of
30096modifications to the System V.4 specifications. Selecting @option{-meabi}
30097means that the stack is aligned to an 8-byte boundary, a function
30098@code{__eabi} is called from @code{main} to set up the EABI
30099environment, and the @option{-msdata} option can use both @code{r2} and
30100@code{r13} to point to two separate small data areas. Selecting
30101@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
30102no EABI initialization function is called from @code{main}, and the
30103@option{-msdata} option only uses @code{r13} to point to a single
30104small data area. The @option{-meabi} option is on by default if you
30105configured GCC using one of the @samp{powerpc*-*-eabi*} options.
30106
d77de738 30107@opindex msdata=eabi
ddf6fe37 30108@item -msdata=eabi
d77de738
ML
30109On System V.4 and embedded PowerPC systems, put small initialized
30110@code{const} global and static data in the @code{.sdata2} section, which
30111is pointed to by register @code{r2}. Put small initialized
30112non-@code{const} global and static data in the @code{.sdata} section,
30113which is pointed to by register @code{r13}. Put small uninitialized
30114global and static data in the @code{.sbss} section, which is adjacent to
30115the @code{.sdata} section. The @option{-msdata=eabi} option is
30116incompatible with the @option{-mrelocatable} option. The
30117@option{-msdata=eabi} option also sets the @option{-memb} option.
30118
d77de738 30119@opindex msdata=sysv
ddf6fe37 30120@item -msdata=sysv
d77de738
ML
30121On System V.4 and embedded PowerPC systems, put small global and static
30122data in the @code{.sdata} section, which is pointed to by register
30123@code{r13}. Put small uninitialized global and static data in the
30124@code{.sbss} section, which is adjacent to the @code{.sdata} section.
30125The @option{-msdata=sysv} option is incompatible with the
30126@option{-mrelocatable} option.
30127
d77de738
ML
30128@opindex msdata=default
30129@opindex msdata
ddf6fe37
AA
30130@item -msdata=default
30131@itemx -msdata
d77de738
ML
30132On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
30133compile code the same as @option{-msdata=eabi}, otherwise compile code the
30134same as @option{-msdata=sysv}.
30135
d77de738 30136@opindex msdata=data
ddf6fe37 30137@item -msdata=data
d77de738
ML
30138On System V.4 and embedded PowerPC systems, put small global
30139data in the @code{.sdata} section. Put small uninitialized global
30140data in the @code{.sbss} section. Do not use register @code{r13}
30141to address small data however. This is the default behavior unless
30142other @option{-msdata} options are used.
30143
d77de738
ML
30144@opindex msdata=none
30145@opindex mno-sdata
ddf6fe37
AA
30146@item -msdata=none
30147@itemx -mno-sdata
d77de738
ML
30148On embedded PowerPC systems, put all initialized global and static data
30149in the @code{.data} section, and all uninitialized data in the
30150@code{.bss} section.
30151
d77de738
ML
30152@opindex mreadonly-in-sdata
30153@opindex mno-readonly-in-sdata
ddf6fe37 30154@item -mreadonly-in-sdata
d77de738
ML
30155Put read-only objects in the @code{.sdata} section as well. This is the
30156default.
30157
d77de738 30158@opindex mblock-move-inline-limit
ddf6fe37 30159@item -mblock-move-inline-limit=@var{num}
d77de738
ML
30160Inline all block moves (such as calls to @code{memcpy} or structure
30161copies) less than or equal to @var{num} bytes. The minimum value for
30162@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
30163targets. The default value is target-specific.
30164
d77de738 30165@opindex mblock-compare-inline-limit
ddf6fe37 30166@item -mblock-compare-inline-limit=@var{num}
d77de738
ML
30167Generate non-looping inline code for all block compares (such as calls
30168to @code{memcmp} or structure compares) less than or equal to @var{num}
30169bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
30170block compare is disabled. The default value is target-specific.
30171
d77de738 30172@opindex mblock-compare-inline-loop-limit
ddf6fe37 30173@item -mblock-compare-inline-loop-limit=@var{num}
d77de738
ML
30174Generate an inline expansion using loop code for all block compares that
30175are less than or equal to @var{num} bytes, but greater than the limit
30176for non-loop inline block compare expansion. If the block length is not
30177constant, at most @var{num} bytes will be compared before @code{memcmp}
30178is called to compare the remainder of the block. The default value is
30179target-specific.
30180
d77de738 30181@opindex mstring-compare-inline-limit
ddf6fe37 30182@item -mstring-compare-inline-limit=@var{num}
d77de738
ML
30183Compare at most @var{num} string bytes with inline code.
30184If the difference or end of string is not found at the
30185end of the inline compare a call to @code{strcmp} or @code{strncmp} will
30186take care of the rest of the comparison. The default is 64 bytes.
30187
d77de738
ML
30188@opindex G
30189@cindex smaller data references (PowerPC)
30190@cindex .sdata/.sdata2 references (PowerPC)
f33d7a88 30191@item -G @var{num}
d77de738
ML
30192On embedded PowerPC systems, put global and static items less than or
30193equal to @var{num} bytes into the small data or BSS sections instead of
30194the normal data or BSS section. By default, @var{num} is 8. The
30195@option{-G @var{num}} switch is also passed to the linker.
30196All modules should be compiled with the same @option{-G @var{num}} value.
30197
d77de738
ML
30198@opindex mregnames
30199@opindex mno-regnames
ddf6fe37
AA
30200@item -mregnames
30201@itemx -mno-regnames
d77de738
ML
30202On System V.4 and embedded PowerPC systems do (do not) emit register
30203names in the assembly language output using symbolic forms.
30204
d77de738
ML
30205@opindex mlongcall
30206@opindex mno-longcall
ddf6fe37
AA
30207@item -mlongcall
30208@itemx -mno-longcall
d77de738
ML
30209By default assume that all calls are far away so that a longer and more
30210expensive calling sequence is required. This is required for calls
30211farther than 32 megabytes (33,554,432 bytes) from the current location.
30212A short call is generated if the compiler knows
30213the call cannot be that far away. This setting can be overridden by
30214the @code{shortcall} function attribute, or by @code{#pragma
30215longcall(0)}.
30216
30217Some linkers are capable of detecting out-of-range calls and generating
30218glue code on the fly. On these systems, long calls are unnecessary and
30219generate slower code. As of this writing, the AIX linker can do this,
30220as can the GNU linker for PowerPC/64. It is planned to add this feature
30221to the GNU linker for 32-bit PowerPC systems as well.
30222
30223On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
30224GCC can generate long calls using an inline PLT call sequence (see
30225@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
30226ELFv1 (big-endian) do not support inline PLT calls.
30227
30228On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
30229callee, L42}, plus a @dfn{branch island} (glue code). The two target
30230addresses represent the callee and the branch island. The
30231Darwin/PPC linker prefers the first address and generates a @code{bl
30232callee} if the PPC @code{bl} instruction reaches the callee directly;
30233otherwise, the linker generates @code{bl L42} to call the branch
30234island. The branch island is appended to the body of the
30235calling function; it computes the full 32-bit address of the callee
30236and jumps to it.
30237
30238On Mach-O (Darwin) systems, this option directs the compiler emit to
30239the glue for every direct call, and the Darwin linker decides whether
30240to use or discard it.
30241
30242In the future, GCC may ignore all longcall specifications
30243when the linker is known to generate glue.
30244
d77de738
ML
30245@opindex mpltseq
30246@opindex mno-pltseq
ddf6fe37
AA
30247@item -mpltseq
30248@itemx -mno-pltseq
d77de738
ML
30249Implement (do not implement) -fno-plt and long calls using an inline
30250PLT call sequence that supports lazy linking and long calls to
30251functions in dlopen'd shared libraries. Inline PLT calls are only
30252supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
30253linkers, and are enabled by default if the support is detected when
30254configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
30255configured with @option{--enable-secureplt}. @option{-mpltseq} code
30256and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
30257linked together.
30258
d77de738
ML
30259@opindex mtls-markers
30260@opindex mno-tls-markers
ddf6fe37
AA
30261@item -mtls-markers
30262@itemx -mno-tls-markers
d77de738
ML
30263Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
30264specifying the function argument. The relocation allows the linker to
30265reliably associate function call with argument setup instructions for
30266TLS optimization, which in turn allows GCC to better schedule the
30267sequence.
30268
ddf6fe37 30269@opindex mrecip
d77de738
ML
30270@item -mrecip
30271@itemx -mno-recip
d77de738
ML
30272This option enables use of the reciprocal estimate and
30273reciprocal square root estimate instructions with additional
30274Newton-Raphson steps to increase precision instead of doing a divide or
30275square root and divide for floating-point arguments. You should use
30276the @option{-ffast-math} option when using @option{-mrecip} (or at
30277least @option{-funsafe-math-optimizations},
30278@option{-ffinite-math-only}, @option{-freciprocal-math} and
30279@option{-fno-trapping-math}). Note that while the throughput of the
30280sequence is generally higher than the throughput of the non-reciprocal
30281instruction, the precision of the sequence can be decreased by up to 2
30282ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30283roots.
30284
d77de738 30285@opindex mrecip=opt
ddf6fe37 30286@item -mrecip=@var{opt}
d77de738
ML
30287This option controls which reciprocal estimate instructions
30288may be used. @var{opt} is a comma-separated list of options, which may
30289be preceded by a @code{!} to invert the option:
30290
30291@table @samp
30292
30293@item all
30294Enable all estimate instructions.
30295
30296@item default
30297Enable the default instructions, equivalent to @option{-mrecip}.
30298
30299@item none
30300Disable all estimate instructions, equivalent to @option{-mno-recip}.
30301
30302@item div
30303Enable the reciprocal approximation instructions for both
30304single and double precision.
30305
30306@item divf
30307Enable the single-precision reciprocal approximation instructions.
30308
30309@item divd
30310Enable the double-precision reciprocal approximation instructions.
30311
30312@item rsqrt
30313Enable the reciprocal square root approximation instructions for both
30314single and double precision.
30315
30316@item rsqrtf
30317Enable the single-precision reciprocal square root approximation instructions.
30318
30319@item rsqrtd
30320Enable the double-precision reciprocal square root approximation instructions.
30321
30322@end table
30323
30324So, for example, @option{-mrecip=all,!rsqrtd} enables
30325all of the reciprocal estimate instructions, except for the
30326@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30327which handle the double-precision reciprocal square root calculations.
30328
ddf6fe37 30329@opindex mrecip-precision
d77de738
ML
30330@item -mrecip-precision
30331@itemx -mno-recip-precision
d77de738
ML
30332Assume (do not assume) that the reciprocal estimate instructions
30333provide higher-precision estimates than is mandated by the PowerPC
30334ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30335@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30336The double-precision square root estimate instructions are not generated by
30337default on low-precision machines, since they do not provide an
30338estimate that converges after three steps.
30339
d77de738 30340@opindex mveclibabi
ddf6fe37 30341@item -mveclibabi=@var{type}
d77de738
ML
30342Specifies the ABI type to use for vectorizing intrinsics using an
30343external library. The only type supported at present is @samp{mass},
30344which specifies to use IBM's Mathematical Acceleration Subsystem
30345(MASS) libraries for vectorizing intrinsics using external libraries.
30346GCC currently emits calls to @code{acosd2}, @code{acosf4},
30347@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30348@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30349@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30350@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30351@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30352@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30353@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30354@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30355@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30356@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30357@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30358@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30359@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30360for power7. Both @option{-ftree-vectorize} and
30361@option{-funsafe-math-optimizations} must also be enabled. The MASS
30362libraries must be specified at link time.
30363
ddf6fe37 30364@opindex mfriz
d77de738
ML
30365@item -mfriz
30366@itemx -mno-friz
d77de738
ML
30367Generate (do not generate) the @code{friz} instruction when the
30368@option{-funsafe-math-optimizations} option is used to optimize
30369rounding of floating-point values to 64-bit integer and back to floating
30370point. The @code{friz} instruction does not return the same value if
30371the floating-point number is too large to fit in an integer.
30372
ddf6fe37 30373@opindex mpointers-to-nested-functions
d77de738
ML
30374@item -mpointers-to-nested-functions
30375@itemx -mno-pointers-to-nested-functions
d77de738
ML
30376Generate (do not generate) code to load up the static chain register
30377(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30378systems where a function pointer points to a 3-word descriptor giving
30379the function address, TOC value to be loaded in register @code{r2}, and
30380static chain value to be loaded in register @code{r11}. The
30381@option{-mpointers-to-nested-functions} is on by default. You cannot
30382call through pointers to nested functions or pointers
30383to functions compiled in other languages that use the static chain if
30384you use @option{-mno-pointers-to-nested-functions}.
30385
ddf6fe37 30386@opindex msave-toc-indirect
d77de738
ML
30387@item -msave-toc-indirect
30388@itemx -mno-save-toc-indirect
d77de738
ML
30389Generate (do not generate) code to save the TOC value in the reserved
30390stack location in the function prologue if the function calls through
30391a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30392saved in the prologue, it is saved just before the call through the
30393pointer. The @option{-mno-save-toc-indirect} option is the default.
30394
ddf6fe37 30395@opindex mcompat-align-parm
d77de738
ML
30396@item -mcompat-align-parm
30397@itemx -mno-compat-align-parm
d77de738
ML
30398Generate (do not generate) code to pass structure parameters with a
30399maximum alignment of 64 bits, for compatibility with older versions
30400of GCC.
30401
30402Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30403structure parameter on a 128-bit boundary when that structure contained
30404a member requiring 128-bit alignment. This is corrected in more
30405recent versions of GCC. This option may be used to generate code
30406that is compatible with functions compiled with older versions of
30407GCC.
30408
30409The @option{-mno-compat-align-parm} option is the default.
30410
d77de738
ML
30411@opindex mstack-protector-guard
30412@opindex mstack-protector-guard-reg
30413@opindex mstack-protector-guard-offset
30414@opindex mstack-protector-guard-symbol
ddf6fe37
AA
30415@item -mstack-protector-guard=@var{guard}
30416@itemx -mstack-protector-guard-reg=@var{reg}
30417@itemx -mstack-protector-guard-offset=@var{offset}
30418@itemx -mstack-protector-guard-symbol=@var{symbol}
d77de738
ML
30419Generate stack protection code using canary at @var{guard}. Supported
30420locations are @samp{global} for global canary or @samp{tls} for per-thread
30421canary in the TLS block (the default with GNU libc version 2.4 or later).
30422
30423With the latter choice the options
30424@option{-mstack-protector-guard-reg=@var{reg}} and
30425@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30426which register to use as base register for reading the canary, and from what
30427offset from that base register. The default for those is as specified in the
30428relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30429the offset with a symbol reference to a canary in the TLS block.
30430
d77de738
ML
30431@opindex mpcrel
30432@opindex mno-pcrel
ddf6fe37
AA
30433@item -mpcrel
30434@itemx -mno-pcrel
d77de738
ML
30435Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30436option requires that the medium code model (@option{-mcmodel=medium})
30437and prefixed addressing (@option{-mprefixed}) options are enabled.
30438
d77de738
ML
30439@opindex mprefixed
30440@opindex mno-prefixed
ddf6fe37
AA
30441@item -mprefixed
30442@itemx -mno-prefixed
d77de738
ML
30443Generate (do not generate) addressing modes using prefixed load and
30444store instructions. The @option{-mprefixed} option requires that
30445the option @option{-mcpu=power10} (or later) is enabled.
30446
d77de738
ML
30447@opindex mmma
30448@opindex mno-mma
ddf6fe37
AA
30449@item -mmma
30450@itemx -mno-mma
d77de738
ML
30451Generate (do not generate) the MMA instructions. The @option{-mma}
30452option requires that the option @option{-mcpu=power10} (or later)
30453is enabled.
30454
d77de738
ML
30455@opindex mrop-protect
30456@opindex mno-rop-protect
ddf6fe37
AA
30457@item -mrop-protect
30458@itemx -mno-rop-protect
d77de738
ML
30459Generate (do not generate) ROP protection instructions when the target
30460processor supports them. Currently this option disables the shrink-wrap
30461optimization (@option{-fshrink-wrap}).
30462
d77de738
ML
30463@opindex mprivileged
30464@opindex mno-privileged
ddf6fe37
AA
30465@item -mprivileged
30466@itemx -mno-privileged
d77de738
ML
30467Generate (do not generate) code that will run in privileged state.
30468
d77de738
ML
30469@opindex block-ops-unaligned-vsx
30470@opindex no-block-ops-unaligned-vsx
ddf6fe37
AA
30471@item -mblock-ops-unaligned-vsx
30472@itemx -mno-block-ops-unaligned-vsx
d77de738
ML
30473Generate (do not generate) unaligned vsx loads and stores for
30474inline expansion of @code{memcpy} and @code{memmove}.
30475
30476@item --param rs6000-vect-unroll-limit=
30477The vectorizer will check with target information to determine whether it
30478would be beneficial to unroll the main vectorized loop and by how much. This
30479parameter sets the upper bound of how much the vectorizer will unroll the main
30480loop. The default value is four.
30481
30482@end table
30483
30484@node RX Options
30485@subsection RX Options
30486@cindex RX Options
30487
30488These command-line options are defined for RX targets:
30489
30490@table @gcctabopt
d77de738
ML
30491@opindex m64bit-doubles
30492@opindex m32bit-doubles
ddf6fe37
AA
30493@item -m64bit-doubles
30494@itemx -m32bit-doubles
d77de738
ML
30495Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30496or 32 bits (@option{-m32bit-doubles}) in size. The default is
30497@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30498works on 32-bit values, which is why the default is
30499@option{-m32bit-doubles}.
30500
d77de738
ML
30501@opindex fpu
30502@opindex nofpu
ddf6fe37
AA
30503@item -fpu
30504@itemx -nofpu
d77de738
ML
30505Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30506floating-point hardware. The default is enabled for the RX600
30507series and disabled for the RX200 series.
30508
30509Floating-point instructions are only generated for 32-bit floating-point
30510values, however, so the FPU hardware is not used for doubles if the
30511@option{-m64bit-doubles} option is used.
30512
30513@emph{Note} If the @option{-fpu} option is enabled then
30514@option{-funsafe-math-optimizations} is also enabled automatically.
30515This is because the RX FPU instructions are themselves unsafe.
30516
d77de738 30517@opindex mcpu
ddf6fe37 30518@item -mcpu=@var{name}
d77de738
ML
30519Selects the type of RX CPU to be targeted. Currently three types are
30520supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30521the specific @samp{RX610} CPU. The default is @samp{RX600}.
30522
30523The only difference between @samp{RX600} and @samp{RX610} is that the
30524@samp{RX610} does not support the @code{MVTIPL} instruction.
30525
30526The @samp{RX200} series does not have a hardware floating-point unit
30527and so @option{-nofpu} is enabled by default when this type is
30528selected.
30529
d77de738
ML
30530@opindex mbig-endian-data
30531@opindex mlittle-endian-data
ddf6fe37
AA
30532@item -mbig-endian-data
30533@itemx -mlittle-endian-data
d77de738
ML
30534Store data (but not code) in the big-endian format. The default is
30535@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30536format.
30537
d77de738 30538@opindex msmall-data-limit
ddf6fe37 30539@item -msmall-data-limit=@var{N}
d77de738
ML
30540Specifies the maximum size in bytes of global and static variables
30541which can be placed into the small data area. Using the small data
30542area can lead to smaller and faster code, but the size of area is
30543limited and it is up to the programmer to ensure that the area does
30544not overflow. Also when the small data area is used one of the RX's
30545registers (usually @code{r13}) is reserved for use pointing to this
30546area, so it is no longer available for use by the compiler. This
30547could result in slower and/or larger code if variables are pushed onto
30548the stack instead of being held in this register.
30549
30550Note, common variables (variables that have not been initialized) and
30551constants are not placed into the small data area as they are assigned
30552to other sections in the output executable.
30553
30554The default value is zero, which disables this feature. Note, this
30555feature is not enabled by default with higher optimization levels
30556(@option{-O2} etc) because of the potentially detrimental effects of
30557reserving a register. It is up to the programmer to experiment and
30558discover whether this feature is of benefit to their program. See the
30559description of the @option{-mpid} option for a description of how the
30560actual register to hold the small data area pointer is chosen.
30561
d77de738
ML
30562@opindex msim
30563@opindex mno-sim
ddf6fe37
AA
30564@item -msim
30565@itemx -mno-sim
d77de738
ML
30566Use the simulator runtime. The default is to use the libgloss
30567board-specific runtime.
30568
d77de738
ML
30569@opindex mas100-syntax
30570@opindex mno-as100-syntax
ddf6fe37
AA
30571@item -mas100-syntax
30572@itemx -mno-as100-syntax
d77de738
ML
30573When generating assembler output use a syntax that is compatible with
30574Renesas's AS100 assembler. This syntax can also be handled by the GAS
30575assembler, but it has some restrictions so it is not generated by default.
30576
d77de738 30577@opindex mmax-constant-size
ddf6fe37 30578@item -mmax-constant-size=@var{N}
d77de738
ML
30579Specifies the maximum size, in bytes, of a constant that can be used as
30580an operand in a RX instruction. Although the RX instruction set does
30581allow constants of up to 4 bytes in length to be used in instructions,
30582a longer value equates to a longer instruction. Thus in some
30583circumstances it can be beneficial to restrict the size of constants
30584that are used in instructions. Constants that are too big are instead
30585placed into a constant pool and referenced via register indirection.
30586
30587The value @var{N} can be between 0 and 4. A value of 0 (the default)
30588or 4 means that constants of any size are allowed.
30589
d77de738 30590@opindex mrelax
ddf6fe37 30591@item -mrelax
d77de738
ML
30592Enable linker relaxation. Linker relaxation is a process whereby the
30593linker attempts to reduce the size of a program by finding shorter
30594versions of various instructions. Disabled by default.
30595
d77de738 30596@opindex mint-register
ddf6fe37 30597@item -mint-register=@var{N}
d77de738
ML
30598Specify the number of registers to reserve for fast interrupt handler
30599functions. The value @var{N} can be between 0 and 4. A value of 1
30600means that register @code{r13} is reserved for the exclusive use
30601of fast interrupt handlers. A value of 2 reserves @code{r13} and
30602@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30603@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30604A value of 0, the default, does not reserve any registers.
30605
d77de738 30606@opindex msave-acc-in-interrupts
ddf6fe37 30607@item -msave-acc-in-interrupts
d77de738
ML
30608Specifies that interrupt handler functions should preserve the
30609accumulator register. This is only necessary if normal code might use
30610the accumulator register, for example because it performs 64-bit
30611multiplications. The default is to ignore the accumulator as this
30612makes the interrupt handlers faster.
30613
d77de738
ML
30614@opindex mpid
30615@opindex mno-pid
ddf6fe37
AA
30616@item -mpid
30617@itemx -mno-pid
d77de738
ML
30618Enables the generation of position independent data. When enabled any
30619access to constant data is done via an offset from a base address
30620held in a register. This allows the location of constant data to be
30621determined at run time without requiring the executable to be
30622relocated, which is a benefit to embedded applications with tight
30623memory constraints. Data that can be modified is not affected by this
30624option.
30625
30626Note, using this feature reserves a register, usually @code{r13}, for
30627the constant data base address. This can result in slower and/or
30628larger code, especially in complicated functions.
30629
30630The actual register chosen to hold the constant data base address
30631depends upon whether the @option{-msmall-data-limit} and/or the
30632@option{-mint-register} command-line options are enabled. Starting
30633with register @code{r13} and proceeding downwards, registers are
30634allocated first to satisfy the requirements of @option{-mint-register},
30635then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30636is possible for the small data area register to be @code{r8} if both
30637@option{-mint-register=4} and @option{-mpid} are specified on the
30638command line.
30639
30640By default this feature is not enabled. The default can be restored
30641via the @option{-mno-pid} command-line option.
30642
d77de738
ML
30643@opindex mno-warn-multiple-fast-interrupts
30644@opindex mwarn-multiple-fast-interrupts
ddf6fe37
AA
30645@item -mno-warn-multiple-fast-interrupts
30646@itemx -mwarn-multiple-fast-interrupts
d77de738
ML
30647Prevents GCC from issuing a warning message if it finds more than one
30648fast interrupt handler when it is compiling a file. The default is to
30649issue a warning for each extra fast interrupt handler found, as the RX
30650only supports one such interrupt.
30651
d77de738
ML
30652@opindex mallow-string-insns
30653@opindex mno-allow-string-insns
ddf6fe37
AA
30654@item -mallow-string-insns
30655@itemx -mno-allow-string-insns
d77de738
ML
30656Enables or disables the use of the string manipulation instructions
30657@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
30658@code{SWHILE} and also the @code{RMPA} instruction. These
30659instructions may prefetch data, which is not safe to do if accessing
30660an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
30661for more information).
30662
30663The default is to allow these instructions, but it is not possible for
30664GCC to reliably detect all circumstances where a string instruction
30665might be used to access an I/O register, so their use cannot be
30666disabled automatically. Instead it is reliant upon the programmer to
30667use the @option{-mno-allow-string-insns} option if their program
30668accesses I/O space.
30669
30670When the instructions are enabled GCC defines the C preprocessor
30671symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
30672symbol @code{__RX_DISALLOW_STRING_INSNS__}.
30673
d77de738
ML
30674@opindex mjsr
30675@opindex mno-jsr
ddf6fe37
AA
30676@item -mjsr
30677@itemx -mno-jsr
d77de738
ML
30678Use only (or not only) @code{JSR} instructions to access functions.
30679This option can be used when code size exceeds the range of @code{BSR}
30680instructions. Note that @option{-mno-jsr} does not mean to not use
30681@code{JSR} but instead means that any type of branch may be used.
30682@end table
30683
30684@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
30685has special significance to the RX port when used with the
30686@code{interrupt} function attribute. This attribute indicates a
30687function intended to process fast interrupts. GCC ensures
30688that it only uses the registers @code{r10}, @code{r11}, @code{r12}
30689and/or @code{r13} and only provided that the normal use of the
30690corresponding registers have been restricted via the
30691@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
30692options.
30693
30694@node S/390 and zSeries Options
30695@subsection S/390 and zSeries Options
30696@cindex S/390 and zSeries Options
30697
30698These are the @samp{-m} options defined for the S/390 and zSeries architecture.
30699
30700@table @gcctabopt
d77de738
ML
30701@opindex mhard-float
30702@opindex msoft-float
ddf6fe37
AA
30703@item -mhard-float
30704@itemx -msoft-float
d77de738
ML
30705Use (do not use) the hardware floating-point instructions and registers
30706for floating-point operations. When @option{-msoft-float} is specified,
30707functions in @file{libgcc.a} are used to perform floating-point
30708operations. When @option{-mhard-float} is specified, the compiler
30709generates IEEE floating-point instructions. This is the default.
30710
d77de738
ML
30711@opindex mhard-dfp
30712@opindex mno-hard-dfp
ddf6fe37
AA
30713@item -mhard-dfp
30714@itemx -mno-hard-dfp
d77de738
ML
30715Use (do not use) the hardware decimal-floating-point instructions for
30716decimal-floating-point operations. When @option{-mno-hard-dfp} is
30717specified, functions in @file{libgcc.a} are used to perform
30718decimal-floating-point operations. When @option{-mhard-dfp} is
30719specified, the compiler generates decimal-floating-point hardware
30720instructions. This is the default for @option{-march=z9-ec} or higher.
30721
d77de738
ML
30722@opindex mlong-double-64
30723@opindex mlong-double-128
ddf6fe37
AA
30724@item -mlong-double-64
30725@itemx -mlong-double-128
d77de738
ML
30726These switches control the size of @code{long double} type. A size
30727of 64 bits makes the @code{long double} type equivalent to the @code{double}
30728type. This is the default.
30729
d77de738
ML
30730@opindex mbackchain
30731@opindex mno-backchain
ddf6fe37
AA
30732@item -mbackchain
30733@itemx -mno-backchain
d77de738
ML
30734Store (do not store) the address of the caller's frame as backchain pointer
30735into the callee's stack frame.
30736A backchain may be needed to allow debugging using tools that do not understand
30737DWARF call frame information.
30738When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
30739at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
30740the backchain is placed into the topmost word of the 96/160 byte register
30741save area.
30742
30743In general, code compiled with @option{-mbackchain} is call-compatible with
30744code compiled with @option{-mno-backchain}; however, use of the backchain
30745for debugging purposes usually requires that the whole binary is built with
30746@option{-mbackchain}. Note that the combination of @option{-mbackchain},
30747@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30748to build a linux kernel use @option{-msoft-float}.
30749
30750The default is to not maintain the backchain.
30751
d77de738
ML
30752@opindex mpacked-stack
30753@opindex mno-packed-stack
ddf6fe37
AA
30754@item -mpacked-stack
30755@itemx -mno-packed-stack
d77de738
ML
30756Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
30757specified, the compiler uses the all fields of the 96/160 byte register save
30758area only for their default purpose; unused fields still take up stack space.
30759When @option{-mpacked-stack} is specified, register save slots are densely
30760packed at the top of the register save area; unused space is reused for other
30761purposes, allowing for more efficient use of the available stack space.
30762However, when @option{-mbackchain} is also in effect, the topmost word of
30763the save area is always used to store the backchain, and the return address
30764register is always saved two words below the backchain.
30765
30766As long as the stack frame backchain is not used, code generated with
30767@option{-mpacked-stack} is call-compatible with code generated with
30768@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
30769S/390 or zSeries generated code that uses the stack frame backchain at run
30770time, not just for debugging purposes. Such code is not call-compatible
30771with code compiled with @option{-mpacked-stack}. Also, note that the
30772combination of @option{-mbackchain},
30773@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30774to build a linux kernel use @option{-msoft-float}.
30775
30776The default is to not use the packed stack layout.
30777
d77de738
ML
30778@opindex msmall-exec
30779@opindex mno-small-exec
ddf6fe37
AA
30780@item -msmall-exec
30781@itemx -mno-small-exec
d77de738
ML
30782Generate (or do not generate) code using the @code{bras} instruction
30783to do subroutine calls.
30784This only works reliably if the total executable size does not
30785exceed 64k. The default is to use the @code{basr} instruction instead,
30786which does not have this limitation.
30787
d77de738
ML
30788@opindex m64
30789@opindex m31
ddf6fe37
AA
30790@item -m64
30791@itemx -m31
d77de738
ML
30792When @option{-m31} is specified, generate code compliant to the
30793GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
30794code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
30795particular to generate 64-bit instructions. For the @samp{s390}
30796targets, the default is @option{-m31}, while the @samp{s390x}
30797targets default to @option{-m64}.
30798
d77de738
ML
30799@opindex mzarch
30800@opindex mesa
ddf6fe37
AA
30801@item -mzarch
30802@itemx -mesa
d77de738
ML
30803When @option{-mzarch} is specified, generate code using the
30804instructions available on z/Architecture.
30805When @option{-mesa} is specified, generate code using the
30806instructions available on ESA/390. Note that @option{-mesa} is
30807not possible with @option{-m64}.
30808When generating code compliant to the GNU/Linux for S/390 ABI,
30809the default is @option{-mesa}. When generating code compliant
30810to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
30811
d77de738
ML
30812@opindex mhtm
30813@opindex mno-htm
ddf6fe37
AA
30814@item -mhtm
30815@itemx -mno-htm
d77de738
ML
30816The @option{-mhtm} option enables a set of builtins making use of
30817instructions available with the transactional execution facility
30818introduced with the IBM zEnterprise EC12 machine generation
30819@ref{S/390 System z Built-in Functions}.
30820@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
30821
d77de738
ML
30822@opindex mvx
30823@opindex mno-vx
ddf6fe37
AA
30824@item -mvx
30825@itemx -mno-vx
d77de738
ML
30826When @option{-mvx} is specified, generate code using the instructions
30827available with the vector extension facility introduced with the IBM
30828z13 machine generation.
30829This option changes the ABI for some vector type values with regard to
30830alignment and calling conventions. In case vector type values are
30831being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
30832command will be added to mark the resulting binary with the ABI used.
30833@option{-mvx} is enabled by default when using @option{-march=z13}.
30834
d77de738
ML
30835@opindex mzvector
30836@opindex mno-zvector
ddf6fe37
AA
30837@item -mzvector
30838@itemx -mno-zvector
d77de738
ML
30839The @option{-mzvector} option enables vector language extensions and
30840builtins using instructions available with the vector extension
30841facility introduced with the IBM z13 machine generation.
30842This option adds support for @samp{vector} to be used as a keyword to
30843define vector type variables and arguments. @samp{vector} is only
30844available when GNU extensions are enabled. It will not be expanded
30845when requesting strict standard compliance e.g.@: with @option{-std=c99}.
30846In addition to the GCC low-level builtins @option{-mzvector} enables
30847a set of builtins added for compatibility with AltiVec-style
30848implementations like Power and Cell. In order to make use of these
30849builtins the header file @file{vecintrin.h} needs to be included.
30850@option{-mzvector} is disabled by default.
30851
d77de738
ML
30852@opindex mmvcle
30853@opindex mno-mvcle
ddf6fe37
AA
30854@item -mmvcle
30855@itemx -mno-mvcle
d77de738
ML
30856Generate (or do not generate) code using the @code{mvcle} instruction
30857to perform block moves. When @option{-mno-mvcle} is specified,
30858use a @code{mvc} loop instead. This is the default unless optimizing for
30859size.
30860
d77de738
ML
30861@opindex mdebug
30862@opindex mno-debug
ddf6fe37
AA
30863@item -mdebug
30864@itemx -mno-debug
d77de738
ML
30865Print (or do not print) additional debug information when compiling.
30866The default is to not print debug information.
30867
d77de738 30868@opindex march
ddf6fe37 30869@item -march=@var{cpu-type}
d77de738
ML
30870Generate code that runs on @var{cpu-type}, which is the name of a
30871system representing a certain processor type. Possible values for
30872@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
30873@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
30874@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
30875@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
30876@samp{z16}/@samp{arch14}, and @samp{native}.
30877
30878The default is @option{-march=z900}.
30879
30880Specifying @samp{native} as cpu type can be used to select the best
30881architecture option for the host processor.
30882@option{-march=native} has no effect if GCC does not recognize the
30883processor.
30884
d77de738 30885@opindex mtune
ddf6fe37 30886@item -mtune=@var{cpu-type}
d77de738
ML
30887Tune to @var{cpu-type} everything applicable about the generated code,
30888except for the ABI and the set of available instructions.
30889The list of @var{cpu-type} values is the same as for @option{-march}.
30890The default is the value used for @option{-march}.
30891
d77de738
ML
30892@opindex mtpf-trace
30893@opindex mno-tpf-trace
ddf6fe37
AA
30894@item -mtpf-trace
30895@itemx -mno-tpf-trace
d77de738
ML
30896Generate code that adds (does not add) in TPF OS specific branches to trace
30897routines in the operating system. This option is off by default, even
30898when compiling for the TPF OS@.
30899
d77de738
ML
30900@opindex mtpf-trace-skip
30901@opindex mno-tpf-trace-skip
ddf6fe37
AA
30902@item -mtpf-trace-skip
30903@itemx -mno-tpf-trace-skip
d77de738
ML
30904Generate code that changes (does not change) the default branch
30905targets enabled by @option{-mtpf-trace} to point to specialized trace
30906routines providing the ability of selectively skipping function trace
30907entries for the TPF OS. This option is off by default, even when
30908compiling for the TPF OS and specifying @option{-mtpf-trace}.
30909
d77de738
ML
30910@opindex mfused-madd
30911@opindex mno-fused-madd
ddf6fe37
AA
30912@item -mfused-madd
30913@itemx -mno-fused-madd
d77de738
ML
30914Generate code that uses (does not use) the floating-point multiply and
30915accumulate instructions. These instructions are generated by default if
30916hardware floating point is used.
30917
d77de738 30918@opindex mwarn-framesize
ddf6fe37 30919@item -mwarn-framesize=@var{framesize}
d77de738
ML
30920Emit a warning if the current function exceeds the given frame size. Because
30921this is a compile-time check it doesn't need to be a real problem when the program
30922runs. It is intended to identify functions that most probably cause
30923a stack overflow. It is useful to be used in an environment with limited stack
30924size e.g.@: the linux kernel.
30925
d77de738 30926@opindex mwarn-dynamicstack
ddf6fe37 30927@item -mwarn-dynamicstack
d77de738
ML
30928Emit a warning if the function calls @code{alloca} or uses dynamically-sized
30929arrays. This is generally a bad idea with a limited stack size.
30930
d77de738
ML
30931@opindex mstack-guard
30932@opindex mstack-size
ddf6fe37
AA
30933@item -mstack-guard=@var{stack-guard}
30934@itemx -mstack-size=@var{stack-size}
d77de738
ML
30935If these options are provided the S/390 back end emits additional instructions in
30936the function prologue that trigger a trap if the stack size is @var{stack-guard}
30937bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
30938If the @var{stack-guard} option is omitted the smallest power of 2 larger than
30939the frame size of the compiled function is chosen.
30940These options are intended to be used to help debugging stack overflow problems.
30941The additionally emitted code causes only little overhead and hence can also be
30942used in production-like systems without greater performance degradation. The given
30943values have to be exact powers of 2 and @var{stack-size} has to be greater than
30944@var{stack-guard} without exceeding 64k.
30945In order to be efficient the extra code makes the assumption that the stack starts
30946at an address aligned to the value given by @var{stack-size}.
30947The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
30948
d77de738 30949@opindex mhotpatch
ddf6fe37 30950@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
d77de738
ML
30951If the hotpatch option is enabled, a ``hot-patching'' function
30952prologue is generated for all functions in the compilation unit.
30953The funtion label is prepended with the given number of two-byte
30954NOP instructions (@var{pre-halfwords}, maximum 1000000). After
30955the label, 2 * @var{post-halfwords} bytes are appended, using the
30956largest NOP like instructions the architecture allows (maximum
309571000000).
30958
30959If both arguments are zero, hotpatching is disabled.
30960
30961This option can be overridden for individual functions with the
30962@code{hotpatch} attribute.
30963@end table
30964
d77de738
ML
30965@node SH Options
30966@subsection SH Options
30967
30968These @samp{-m} options are defined for the SH implementations:
30969
30970@table @gcctabopt
d77de738 30971@opindex m1
ddf6fe37 30972@item -m1
d77de738
ML
30973Generate code for the SH1.
30974
d77de738 30975@opindex m2
ddf6fe37 30976@item -m2
d77de738
ML
30977Generate code for the SH2.
30978
30979@item -m2e
30980Generate code for the SH2e.
30981
d77de738 30982@opindex m2a-nofpu
ddf6fe37 30983@item -m2a-nofpu
d77de738
ML
30984Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
30985that the floating-point unit is not used.
30986
d77de738 30987@opindex m2a-single-only
ddf6fe37 30988@item -m2a-single-only
d77de738
ML
30989Generate code for the SH2a-FPU, in such a way that no double-precision
30990floating-point operations are used.
30991
d77de738 30992@opindex m2a-single
ddf6fe37 30993@item -m2a-single
d77de738
ML
30994Generate code for the SH2a-FPU assuming the floating-point unit is in
30995single-precision mode by default.
30996
d77de738 30997@opindex m2a
ddf6fe37 30998@item -m2a
d77de738
ML
30999Generate code for the SH2a-FPU assuming the floating-point unit is in
31000double-precision mode by default.
31001
d77de738 31002@opindex m3
ddf6fe37 31003@item -m3
d77de738
ML
31004Generate code for the SH3.
31005
d77de738 31006@opindex m3e
ddf6fe37 31007@item -m3e
d77de738
ML
31008Generate code for the SH3e.
31009
d77de738 31010@opindex m4-nofpu
ddf6fe37 31011@item -m4-nofpu
d77de738
ML
31012Generate code for the SH4 without a floating-point unit.
31013
d77de738 31014@opindex m4-single-only
ddf6fe37 31015@item -m4-single-only
d77de738
ML
31016Generate code for the SH4 with a floating-point unit that only
31017supports single-precision arithmetic.
31018
d77de738 31019@opindex m4-single
ddf6fe37 31020@item -m4-single
d77de738
ML
31021Generate code for the SH4 assuming the floating-point unit is in
31022single-precision mode by default.
31023
d77de738 31024@opindex m4
ddf6fe37 31025@item -m4
d77de738
ML
31026Generate code for the SH4.
31027
d77de738 31028@opindex m4-100
ddf6fe37 31029@item -m4-100
d77de738
ML
31030Generate code for SH4-100.
31031
d77de738 31032@opindex m4-100-nofpu
ddf6fe37 31033@item -m4-100-nofpu
d77de738
ML
31034Generate code for SH4-100 in such a way that the
31035floating-point unit is not used.
31036
d77de738 31037@opindex m4-100-single
ddf6fe37 31038@item -m4-100-single
d77de738
ML
31039Generate code for SH4-100 assuming the floating-point unit is in
31040single-precision mode by default.
31041
d77de738 31042@opindex m4-100-single-only
ddf6fe37 31043@item -m4-100-single-only
d77de738
ML
31044Generate code for SH4-100 in such a way that no double-precision
31045floating-point operations are used.
31046
d77de738 31047@opindex m4-200
ddf6fe37 31048@item -m4-200
d77de738
ML
31049Generate code for SH4-200.
31050
d77de738 31051@opindex m4-200-nofpu
ddf6fe37 31052@item -m4-200-nofpu
d77de738
ML
31053Generate code for SH4-200 without in such a way that the
31054floating-point unit is not used.
31055
d77de738 31056@opindex m4-200-single
ddf6fe37 31057@item -m4-200-single
d77de738
ML
31058Generate code for SH4-200 assuming the floating-point unit is in
31059single-precision mode by default.
31060
d77de738 31061@opindex m4-200-single-only
ddf6fe37 31062@item -m4-200-single-only
d77de738
ML
31063Generate code for SH4-200 in such a way that no double-precision
31064floating-point operations are used.
31065
d77de738 31066@opindex m4-300
ddf6fe37 31067@item -m4-300
d77de738
ML
31068Generate code for SH4-300.
31069
d77de738 31070@opindex m4-300-nofpu
ddf6fe37 31071@item -m4-300-nofpu
d77de738
ML
31072Generate code for SH4-300 without in such a way that the
31073floating-point unit is not used.
31074
d77de738 31075@opindex m4-300-single
ddf6fe37 31076@item -m4-300-single
d77de738
ML
31077Generate code for SH4-300 in such a way that no double-precision
31078floating-point operations are used.
31079
d77de738 31080@opindex m4-300-single-only
ddf6fe37 31081@item -m4-300-single-only
d77de738
ML
31082Generate code for SH4-300 in such a way that no double-precision
31083floating-point operations are used.
31084
d77de738 31085@opindex m4-340
ddf6fe37 31086@item -m4-340
d77de738
ML
31087Generate code for SH4-340 (no MMU, no FPU).
31088
d77de738 31089@opindex m4-500
ddf6fe37 31090@item -m4-500
d77de738
ML
31091Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
31092assembler.
31093
d77de738 31094@opindex m4a-nofpu
ddf6fe37 31095@item -m4a-nofpu
d77de738
ML
31096Generate code for the SH4al-dsp, or for a SH4a in such a way that the
31097floating-point unit is not used.
31098
d77de738 31099@opindex m4a-single-only
ddf6fe37 31100@item -m4a-single-only
d77de738
ML
31101Generate code for the SH4a, in such a way that no double-precision
31102floating-point operations are used.
31103
d77de738 31104@opindex m4a-single
ddf6fe37 31105@item -m4a-single
d77de738
ML
31106Generate code for the SH4a assuming the floating-point unit is in
31107single-precision mode by default.
31108
d77de738 31109@opindex m4a
ddf6fe37 31110@item -m4a
d77de738
ML
31111Generate code for the SH4a.
31112
d77de738 31113@opindex m4al
ddf6fe37 31114@item -m4al
d77de738
ML
31115Same as @option{-m4a-nofpu}, except that it implicitly passes
31116@option{-dsp} to the assembler. GCC doesn't generate any DSP
31117instructions at the moment.
31118
d77de738 31119@opindex mb
ddf6fe37 31120@item -mb
d77de738
ML
31121Compile code for the processor in big-endian mode.
31122
d77de738 31123@opindex ml
ddf6fe37 31124@item -ml
d77de738
ML
31125Compile code for the processor in little-endian mode.
31126
d77de738 31127@opindex mdalign
ddf6fe37 31128@item -mdalign
d77de738
ML
31129Align doubles at 64-bit boundaries. Note that this changes the calling
31130conventions, and thus some functions from the standard C library do
31131not work unless you recompile it first with @option{-mdalign}.
31132
d77de738 31133@opindex mrelax
ddf6fe37 31134@item -mrelax
d77de738
ML
31135Shorten some address references at link time, when possible; uses the
31136linker option @option{-relax}.
31137
d77de738 31138@opindex mbigtable
ddf6fe37 31139@item -mbigtable
d77de738
ML
31140Use 32-bit offsets in @code{switch} tables. The default is to use
3114116-bit offsets.
31142
d77de738 31143@opindex mbitops
ddf6fe37 31144@item -mbitops
d77de738
ML
31145Enable the use of bit manipulation instructions on SH2A.
31146
d77de738 31147@opindex mfmovd
ddf6fe37 31148@item -mfmovd
d77de738
ML
31149Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
31150alignment constraints.
31151
d77de738 31152@opindex mrenesas
ddf6fe37 31153@item -mrenesas
d77de738
ML
31154Comply with the calling conventions defined by Renesas.
31155
d77de738 31156@opindex mno-renesas
ddf6fe37 31157@item -mno-renesas
d77de738
ML
31158Comply with the calling conventions defined for GCC before the Renesas
31159conventions were available. This option is the default for all
31160targets of the SH toolchain.
31161
d77de738 31162@opindex mnomacsave
ddf6fe37 31163@item -mnomacsave
d77de738
ML
31164Mark the @code{MAC} register as call-clobbered, even if
31165@option{-mrenesas} is given.
31166
d77de738
ML
31167@opindex mieee
31168@opindex mno-ieee
ddf6fe37
AA
31169@item -mieee
31170@itemx -mno-ieee
d77de738
ML
31171Control the IEEE compliance of floating-point comparisons, which affects the
31172handling of cases where the result of a comparison is unordered. By default
31173@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
31174enabled @option{-mno-ieee} is implicitly set, which results in faster
31175floating-point greater-equal and less-equal comparisons. The implicit settings
31176can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
31177
d77de738 31178@opindex minline-ic_invalidate
ddf6fe37 31179@item -minline-ic_invalidate
d77de738
ML
31180Inline code to invalidate instruction cache entries after setting up
31181nested function trampolines.
31182This option has no effect if @option{-musermode} is in effect and the selected
31183code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
31184instruction.
31185If the selected code generation option does not allow the use of the @code{icbi}
31186instruction, and @option{-musermode} is not in effect, the inlined code
31187manipulates the instruction cache address array directly with an associative
31188write. This not only requires privileged mode at run time, but it also
31189fails if the cache line had been mapped via the TLB and has become unmapped.
31190
d77de738 31191@opindex misize
ddf6fe37 31192@item -misize
d77de738
ML
31193Dump instruction size and location in the assembly code.
31194
d77de738 31195@opindex mpadstruct
ddf6fe37 31196@item -mpadstruct
d77de738
ML
31197This option is deprecated. It pads structures to multiple of 4 bytes,
31198which is incompatible with the SH ABI@.
31199
d77de738 31200@opindex matomic-model=@var{model}
ddf6fe37 31201@item -matomic-model=@var{model}
d77de738
ML
31202Sets the model of atomic operations and additional parameters as a comma
31203separated list. For details on the atomic built-in functions see
31204@ref{__atomic Builtins}. The following models and parameters are supported:
31205
31206@table @samp
31207
31208@item none
31209Disable compiler generated atomic sequences and emit library calls for atomic
31210operations. This is the default if the target is not @code{sh*-*-linux*}.
31211
31212@item soft-gusa
31213Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
31214built-in functions. The generated atomic sequences require additional support
31215from the interrupt/exception handling code of the system and are only suitable
31216for SH3* and SH4* single-core systems. This option is enabled by default when
31217the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
31218this option also partially utilizes the hardware atomic instructions
31219@code{movli.l} and @code{movco.l} to create more efficient code, unless
31220@samp{strict} is specified.
31221
31222@item soft-tcb
31223Generate software atomic sequences that use a variable in the thread control
31224block. This is a variation of the gUSA sequences which can also be used on
31225SH1* and SH2* targets. The generated atomic sequences require additional
31226support from the interrupt/exception handling code of the system and are only
31227suitable for single-core systems. When using this model, the @samp{gbr-offset=}
31228parameter has to be specified as well.
31229
31230@item soft-imask
31231Generate software atomic sequences that temporarily disable interrupts by
31232setting @code{SR.IMASK = 1111}. This model works only when the program runs
31233in privileged mode and is only suitable for single-core systems. Additional
31234support from the interrupt/exception handling code of the system is not
31235required. This model is enabled by default when the target is
31236@code{sh*-*-linux*} and SH1* or SH2*.
31237
31238@item hard-llcs
31239Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
31240instructions only. This is only available on SH4A and is suitable for
31241multi-core systems. Since the hardware instructions support only 32 bit atomic
31242variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
31243Code compiled with this option is also compatible with other software
31244atomic model interrupt/exception handling systems if executed on an SH4A
31245system. Additional support from the interrupt/exception handling code of the
31246system is not required for this model.
31247
31248@item gbr-offset=
31249This parameter specifies the offset in bytes of the variable in the thread
31250control block structure that should be used by the generated atomic sequences
31251when the @samp{soft-tcb} model has been selected. For other models this
31252parameter is ignored. The specified value must be an integer multiple of four
31253and in the range 0-1020.
31254
31255@item strict
31256This parameter prevents mixed usage of multiple atomic models, even if they
31257are compatible, and makes the compiler generate atomic sequences of the
31258specified model only.
31259
31260@end table
31261
d77de738 31262@opindex mtas
ddf6fe37 31263@item -mtas
d77de738
ML
31264Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
31265Notice that depending on the particular hardware and software configuration
31266this can degrade overall performance due to the operand cache line flushes
31267that are implied by the @code{tas.b} instruction. On multi-core SH4A
31268processors the @code{tas.b} instruction must be used with caution since it
31269can result in data corruption for certain cache configurations.
31270
d77de738 31271@opindex mprefergot
ddf6fe37 31272@item -mprefergot
d77de738
ML
31273When generating position-independent code, emit function calls using
31274the Global Offset Table instead of the Procedure Linkage Table.
31275
d77de738
ML
31276@opindex musermode
31277@opindex mno-usermode
ddf6fe37
AA
31278@item -musermode
31279@itemx -mno-usermode
d77de738
ML
31280Don't allow (allow) the compiler generating privileged mode code. Specifying
31281@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31282inlined code would not work in user mode. @option{-musermode} is the default
31283when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31284@option{-musermode} has no effect, since there is no user mode.
31285
d77de738 31286@opindex multcost=@var{number}
ddf6fe37 31287@item -multcost=@var{number}
d77de738
ML
31288Set the cost to assume for a multiply insn.
31289
d77de738 31290@opindex mdiv=@var{strategy}
ddf6fe37 31291@item -mdiv=@var{strategy}
d77de738
ML
31292Set the division strategy to be used for integer division operations.
31293@var{strategy} can be one of:
31294
31295@table @samp
31296
31297@item call-div1
31298Calls a library function that uses the single-step division instruction
31299@code{div1} to perform the operation. Division by zero calculates an
31300unspecified result and does not trap. This is the default except for SH4,
31301SH2A and SHcompact.
31302
31303@item call-fp
31304Calls a library function that performs the operation in double precision
31305floating point. Division by zero causes a floating-point exception. This is
31306the default for SHcompact with FPU. Specifying this for targets that do not
31307have a double precision FPU defaults to @code{call-div1}.
31308
31309@item call-table
31310Calls a library function that uses a lookup table for small divisors and
31311the @code{div1} instruction with case distinction for larger divisors. Division
31312by zero calculates an unspecified result and does not trap. This is the default
31313for SH4. Specifying this for targets that do not have dynamic shift
31314instructions defaults to @code{call-div1}.
31315
31316@end table
31317
31318When a division strategy has not been specified the default strategy is
31319selected based on the current target. For SH2A the default strategy is to
31320use the @code{divs} and @code{divu} instructions instead of library function
31321calls.
31322
d77de738 31323@opindex maccumulate-outgoing-args
ddf6fe37 31324@item -maccumulate-outgoing-args
d77de738
ML
31325Reserve space once for outgoing arguments in the function prologue rather
31326than around each call. Generally beneficial for performance and size. Also
31327needed for unwinding to avoid changing the stack frame around conditional code.
31328
d77de738 31329@opindex mdivsi3_libfunc=@var{name}
ddf6fe37 31330@item -mdivsi3_libfunc=@var{name}
d77de738
ML
31331Set the name of the library function used for 32-bit signed division to
31332@var{name}.
31333This only affects the name used in the @samp{call} division strategies, and
31334the compiler still expects the same sets of input/output/clobbered registers as
31335if this option were not present.
31336
d77de738 31337@opindex mfixed-range
ddf6fe37 31338@item -mfixed-range=@var{register-range}
d77de738
ML
31339Generate code treating the given register range as fixed registers.
31340A fixed register is one that the register allocator cannot use. This is
31341useful when compiling kernel code. A register range is specified as
31342two registers separated by a dash. Multiple register ranges can be
31343specified separated by a comma.
31344
d77de738 31345@opindex mbranch-cost=@var{num}
ddf6fe37 31346@item -mbranch-cost=@var{num}
d77de738
ML
31347Assume @var{num} to be the cost for a branch instruction. Higher numbers
31348make the compiler try to generate more branch-free code if possible.
31349If not specified the value is selected depending on the processor type that
31350is being compiled for.
31351
d77de738
ML
31352@opindex mzdcbranch
31353@opindex mno-zdcbranch
ddf6fe37
AA
31354@item -mzdcbranch
31355@itemx -mno-zdcbranch
d77de738
ML
31356Assume (do not assume) that zero displacement conditional branch instructions
31357@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31358compiler prefers zero displacement branch code sequences. This is
31359enabled by default when generating code for SH4 and SH4A. It can be explicitly
31360disabled by specifying @option{-mno-zdcbranch}.
31361
d77de738 31362@opindex mcbranch-force-delay-slot
ddf6fe37 31363@item -mcbranch-force-delay-slot
d77de738
ML
31364Force the usage of delay slots for conditional branches, which stuffs the delay
31365slot with a @code{nop} if a suitable instruction cannot be found. By default
31366this option is disabled. It can be enabled to work around hardware bugs as
31367found in the original SH7055.
31368
d77de738
ML
31369@opindex mfused-madd
31370@opindex mno-fused-madd
ddf6fe37
AA
31371@item -mfused-madd
31372@itemx -mno-fused-madd
d77de738
ML
31373Generate code that uses (does not use) the floating-point multiply and
31374accumulate instructions. These instructions are generated by default
31375if hardware floating point is used. The machine-dependent
31376@option{-mfused-madd} option is now mapped to the machine-independent
31377@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31378mapped to @option{-ffp-contract=off}.
31379
d77de738
ML
31380@opindex mfsca
31381@opindex mno-fsca
ddf6fe37
AA
31382@item -mfsca
31383@itemx -mno-fsca
d77de738
ML
31384Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31385and cosine approximations. The option @option{-mfsca} must be used in
31386combination with @option{-funsafe-math-optimizations}. It is enabled by default
31387when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31388approximations even if @option{-funsafe-math-optimizations} is in effect.
31389
d77de738
ML
31390@opindex mfsrra
31391@opindex mno-fsrra
ddf6fe37
AA
31392@item -mfsrra
31393@itemx -mno-fsrra
d77de738
ML
31394Allow or disallow the compiler to emit the @code{fsrra} instruction for
31395reciprocal square root approximations. The option @option{-mfsrra} must be used
31396in combination with @option{-funsafe-math-optimizations} and
31397@option{-ffinite-math-only}. It is enabled by default when generating code for
31398SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31399even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31400in effect.
31401
d77de738 31402@opindex mpretend-cmove
ddf6fe37 31403@item -mpretend-cmove
d77de738
ML
31404Prefer zero-displacement conditional branches for conditional move instruction
31405patterns. This can result in faster code on the SH4 processor.
31406
d77de738 31407@opindex fdpic
ddf6fe37 31408@item -mfdpic
d77de738
ML
31409Generate code using the FDPIC ABI.
31410
31411@end table
31412
31413@node Solaris 2 Options
31414@subsection Solaris 2 Options
31415@cindex Solaris 2 options
31416
31417These @samp{-m} options are supported on Solaris 2:
31418
31419@table @gcctabopt
d77de738 31420@opindex mclear-hwcap
ddf6fe37 31421@item -mclear-hwcap
d77de738
ML
31422@option{-mclear-hwcap} tells the compiler to remove the hardware
31423capabilities generated by the Solaris assembler. This is only necessary
31424when object files use ISA extensions not supported by the current
31425machine, but check at runtime whether or not to use them.
31426
d77de738 31427@opindex mimpure-text
ddf6fe37 31428@item -mimpure-text
d77de738
ML
31429@option{-mimpure-text}, used in addition to @option{-shared}, tells
31430the compiler to not pass @option{-z text} to the linker when linking a
31431shared object. Using this option, you can link position-dependent
31432code into a shared object.
31433
31434@option{-mimpure-text} suppresses the ``relocations remain against
31435allocatable but non-writable sections'' linker error message.
31436However, the necessary relocations trigger copy-on-write, and the
31437shared object is not actually shared across processes. Instead of
31438using @option{-mimpure-text}, you should compile all source code with
31439@option{-fpic} or @option{-fPIC}.
31440
31441@end table
31442
31443These switches are supported in addition to the above on Solaris 2:
31444
31445@table @gcctabopt
d77de738 31446@opindex pthreads
ddf6fe37 31447@item -pthreads
d77de738
ML
31448This is a synonym for @option{-pthread}.
31449@end table
31450
31451@node SPARC Options
31452@subsection SPARC Options
31453@cindex SPARC options
31454
31455These @samp{-m} options are supported on the SPARC:
31456
31457@table @gcctabopt
d77de738
ML
31458@opindex mno-app-regs
31459@opindex mapp-regs
ddf6fe37
AA
31460@item -mno-app-regs
31461@itemx -mapp-regs
d77de738
ML
31462Specify @option{-mapp-regs} to generate output using the global registers
314632 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31464global register 1, each global register 2 through 4 is then treated as an
31465allocable register that is clobbered by function calls. This is the default.
31466
31467To be fully SVR4 ABI-compliant at the cost of some performance loss,
31468specify @option{-mno-app-regs}. You should compile libraries and system
31469software with this option.
31470
d77de738
ML
31471@opindex mflat
31472@opindex mno-flat
ddf6fe37
AA
31473@item -mflat
31474@itemx -mno-flat
d77de738
ML
31475With @option{-mflat}, the compiler does not generate save/restore instructions
31476and uses a ``flat'' or single register window model. This model is compatible
31477with the regular register window model. The local registers and the input
31478registers (0--5) are still treated as ``call-saved'' registers and are
31479saved on the stack as needed.
31480
31481With @option{-mno-flat} (the default), the compiler generates save/restore
31482instructions (except for leaf functions). This is the normal operating mode.
31483
d77de738
ML
31484@opindex mfpu
31485@opindex mhard-float
ddf6fe37
AA
31486@item -mfpu
31487@itemx -mhard-float
d77de738
ML
31488Generate output containing floating-point instructions. This is the
31489default.
31490
d77de738
ML
31491@opindex mno-fpu
31492@opindex msoft-float
ddf6fe37
AA
31493@item -mno-fpu
31494@itemx -msoft-float
d77de738
ML
31495Generate output containing library calls for floating point.
31496@strong{Warning:} the requisite libraries are not available for all SPARC
31497targets. Normally the facilities of the machine's usual C compiler are
31498used, but this cannot be done directly in cross-compilation. You must make
31499your own arrangements to provide suitable library functions for
31500cross-compilation. The embedded targets @samp{sparc-*-aout} and
31501@samp{sparclite-*-*} do provide software floating-point support.
31502
31503@option{-msoft-float} changes the calling convention in the output file;
31504therefore, it is only useful if you compile @emph{all} of a program with
31505this option. In particular, you need to compile @file{libgcc.a}, the
31506library that comes with GCC, with @option{-msoft-float} in order for
31507this to work.
31508
d77de738 31509@opindex mhard-quad-float
ddf6fe37 31510@item -mhard-quad-float
d77de738
ML
31511Generate output containing quad-word (long double) floating-point
31512instructions.
31513
d77de738 31514@opindex msoft-quad-float
ddf6fe37 31515@item -msoft-quad-float
d77de738
ML
31516Generate output containing library calls for quad-word (long double)
31517floating-point instructions. The functions called are those specified
31518in the SPARC ABI@. This is the default.
31519
31520As of this writing, there are no SPARC implementations that have hardware
31521support for the quad-word floating-point instructions. They all invoke
31522a trap handler for one of these instructions, and then the trap handler
31523emulates the effect of the instruction. Because of the trap handler overhead,
31524this is much slower than calling the ABI library routines. Thus the
31525@option{-msoft-quad-float} option is the default.
31526
d77de738
ML
31527@opindex mno-unaligned-doubles
31528@opindex munaligned-doubles
ddf6fe37
AA
31529@item -mno-unaligned-doubles
31530@itemx -munaligned-doubles
d77de738
ML
31531Assume that doubles have 8-byte alignment. This is the default.
31532
31533With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31534alignment only if they are contained in another type, or if they have an
31535absolute address. Otherwise, it assumes they have 4-byte alignment.
31536Specifying this option avoids some rare compatibility problems with code
31537generated by other compilers. It is not the default because it results
31538in a performance loss, especially for floating-point code.
31539
d77de738
ML
31540@opindex muser-mode
31541@opindex mno-user-mode
ddf6fe37
AA
31542@item -muser-mode
31543@itemx -mno-user-mode
d77de738
ML
31544Do not generate code that can only run in supervisor mode. This is relevant
31545only for the @code{casa} instruction emitted for the LEON3 processor. This
31546is the default.
31547
d77de738
ML
31548@opindex mfaster-structs
31549@opindex mno-faster-structs
ddf6fe37
AA
31550@item -mfaster-structs
31551@itemx -mno-faster-structs
d77de738
ML
31552With @option{-mfaster-structs}, the compiler assumes that structures
31553should have 8-byte alignment. This enables the use of pairs of
31554@code{ldd} and @code{std} instructions for copies in structure
31555assignment, in place of twice as many @code{ld} and @code{st} pairs.
31556However, the use of this changed alignment directly violates the SPARC
31557ABI@. Thus, it's intended only for use on targets where the developer
31558acknowledges that their resulting code is not directly in line with
31559the rules of the ABI@.
31560
d77de738
ML
31561@opindex mstd-struct-return
31562@opindex mno-std-struct-return
ddf6fe37
AA
31563@item -mstd-struct-return
31564@itemx -mno-std-struct-return
d77de738
ML
31565With @option{-mstd-struct-return}, the compiler generates checking code
31566in functions returning structures or unions to detect size mismatches
31567between the two sides of function calls, as per the 32-bit ABI@.
31568
31569The default is @option{-mno-std-struct-return}. This option has no effect
31570in 64-bit mode.
31571
d77de738
ML
31572@opindex mlra
31573@opindex mno-lra
ddf6fe37
AA
31574@item -mlra
31575@itemx -mno-lra
d77de738
ML
31576Enable Local Register Allocation. This is the default for SPARC since GCC 7
31577so @option{-mno-lra} needs to be passed to get old Reload.
31578
d77de738 31579@opindex mcpu
ddf6fe37 31580@item -mcpu=@var{cpu_type}
d77de738
ML
31581Set the instruction set, register set, and instruction scheduling parameters
31582for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31583@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31584@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31585@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31586@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31587@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31588@samp{m8}.
31589
31590Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31591which selects the best architecture option for the host processor.
31592@option{-mcpu=native} has no effect if GCC does not recognize
31593the processor.
31594
31595Default instruction scheduling parameters are used for values that select
31596an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31597@samp{sparclite}, @samp{sparclet}, @samp{v9}.
31598
31599Here is a list of each supported architecture and their supported
31600implementations.
31601
31602@table @asis
31603@item v7
31604cypress, leon3v7
31605
31606@item v8
31607supersparc, hypersparc, leon, leon3, leon5
31608
31609@item sparclite
31610f930, f934, sparclite86x
31611
31612@item sparclet
31613tsc701
31614
31615@item v9
31616ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31617niagara7, m8
31618@end table
31619
31620By default (unless configured otherwise), GCC generates code for the V7
31621variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31622additionally optimizes it for the Cypress CY7C602 chip, as used in the
31623SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31624SPARCStation 1, 2, IPX etc.
31625
31626With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31627architecture. The only difference from V7 code is that the compiler emits
31628the integer multiply and integer divide instructions which exist in SPARC-V8
31629but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31630optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
316312000 series.
31632
31633With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31634the SPARC architecture. This adds the integer multiply, integer divide step
31635and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31636With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31637Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31638@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31639MB86934 chip, which is the more recent SPARClite with FPU@.
31640
31641With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31642the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31643integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31644but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31645optimizes it for the TEMIC SPARClet chip.
31646
31647With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31648architecture. This adds 64-bit integer and floating-point move instructions,
316493 additional floating-point condition code registers and conditional move
31650instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31651optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31652@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31653Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31654@option{-mcpu=niagara}, the compiler additionally optimizes it for
31655Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31656additionally optimizes it for Sun UltraSPARC T2 chips. With
31657@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
31658UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
31659additionally optimizes it for Sun UltraSPARC T4 chips. With
31660@option{-mcpu=niagara7}, the compiler additionally optimizes it for
31661Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
31662additionally optimizes it for Oracle M8 chips.
31663
d77de738 31664@opindex mtune
ddf6fe37 31665@item -mtune=@var{cpu_type}
d77de738
ML
31666Set the instruction scheduling parameters for machine type
31667@var{cpu_type}, but do not set the instruction set or register set that the
31668option @option{-mcpu=@var{cpu_type}} does.
31669
31670The same values for @option{-mcpu=@var{cpu_type}} can be used for
31671@option{-mtune=@var{cpu_type}}, but the only useful values are those
31672that select a particular CPU implementation. Those are
31673@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
31674@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
31675@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
31676@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
31677@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
31678and GNU/Linux toolchains, @samp{native} can also be used.
31679
d77de738
ML
31680@opindex mv8plus
31681@opindex mno-v8plus
ddf6fe37
AA
31682@item -mv8plus
31683@itemx -mno-v8plus
d77de738
ML
31684With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
31685difference from the V8 ABI is that the global and out registers are
31686considered 64 bits wide. This is enabled by default on Solaris in 32-bit
31687mode for all SPARC-V9 processors.
31688
d77de738
ML
31689@opindex mvis
31690@opindex mno-vis
ddf6fe37
AA
31691@item -mvis
31692@itemx -mno-vis
d77de738
ML
31693With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
31694Visual Instruction Set extensions. The default is @option{-mno-vis}.
31695
d77de738
ML
31696@opindex mvis2
31697@opindex mno-vis2
ddf6fe37
AA
31698@item -mvis2
31699@itemx -mno-vis2
d77de738
ML
31700With @option{-mvis2}, GCC generates code that takes advantage of
31701version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
31702default is @option{-mvis2} when targeting a cpu that supports such
31703instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
31704also sets @option{-mvis}.
31705
d77de738
ML
31706@opindex mvis3
31707@opindex mno-vis3
ddf6fe37
AA
31708@item -mvis3
31709@itemx -mno-vis3
d77de738
ML
31710With @option{-mvis3}, GCC generates code that takes advantage of
31711version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
31712default is @option{-mvis3} when targeting a cpu that supports such
31713instructions, such as niagara-3 and later. Setting @option{-mvis3}
31714also sets @option{-mvis2} and @option{-mvis}.
31715
d77de738
ML
31716@opindex mvis4
31717@opindex mno-vis4
ddf6fe37
AA
31718@item -mvis4
31719@itemx -mno-vis4
d77de738
ML
31720With @option{-mvis4}, GCC generates code that takes advantage of
31721version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
31722default is @option{-mvis4} when targeting a cpu that supports such
31723instructions, such as niagara-7 and later. Setting @option{-mvis4}
31724also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
31725
d77de738
ML
31726@opindex mvis4b
31727@opindex mno-vis4b
ddf6fe37
AA
31728@item -mvis4b
31729@itemx -mno-vis4b
d77de738
ML
31730With @option{-mvis4b}, GCC generates code that takes advantage of
31731version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
31732the additional VIS instructions introduced in the Oracle SPARC
31733Architecture 2017. The default is @option{-mvis4b} when targeting a
31734cpu that supports such instructions, such as m8 and later. Setting
31735@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
31736@option{-mvis2} and @option{-mvis}.
31737
d77de738
ML
31738@opindex mcbcond
31739@opindex mno-cbcond
ddf6fe37
AA
31740@item -mcbcond
31741@itemx -mno-cbcond
d77de738
ML
31742With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
31743Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
31744when targeting a CPU that supports such instructions, such as Niagara-4 and
31745later.
31746
d77de738
ML
31747@opindex mfmaf
31748@opindex mno-fmaf
ddf6fe37
AA
31749@item -mfmaf
31750@itemx -mno-fmaf
d77de738
ML
31751With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
31752Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
31753when targeting a CPU that supports such instructions, such as Niagara-3 and
31754later.
31755
d77de738
ML
31756@opindex mfsmuld
31757@opindex mno-fsmuld
ddf6fe37
AA
31758@item -mfsmuld
31759@itemx -mno-fsmuld
d77de738
ML
31760With @option{-mfsmuld}, GCC generates code that takes advantage of the
31761Floating-point Multiply Single to Double (FsMULd) instruction. The default is
31762@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
31763or V9 with FPU except @option{-mcpu=leon}.
31764
d77de738
ML
31765@opindex mpopc
31766@opindex mno-popc
ddf6fe37
AA
31767@item -mpopc
31768@itemx -mno-popc
d77de738
ML
31769With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
31770Population Count instruction. The default is @option{-mpopc}
31771when targeting a CPU that supports such an instruction, such as Niagara-2 and
31772later.
31773
d77de738
ML
31774@opindex msubxc
31775@opindex mno-subxc
ddf6fe37
AA
31776@item -msubxc
31777@itemx -mno-subxc
d77de738
ML
31778With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
31779Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
31780when targeting a CPU that supports such an instruction, such as Niagara-7 and
31781later.
31782
d77de738 31783@opindex mfix-at697f
ddf6fe37 31784@item -mfix-at697f
d77de738
ML
31785Enable the documented workaround for the single erratum of the Atmel AT697F
31786processor (which corresponds to erratum #13 of the AT697E processor).
31787
d77de738 31788@opindex mfix-ut699
ddf6fe37 31789@item -mfix-ut699
d77de738
ML
31790Enable the documented workarounds for the floating-point errata and the data
31791cache nullify errata of the UT699 processor.
31792
d77de738 31793@opindex mfix-ut700
ddf6fe37 31794@item -mfix-ut700
d77de738
ML
31795Enable the documented workaround for the back-to-back store errata of
31796the UT699E/UT700 processor.
31797
d77de738 31798@opindex mfix-gr712rc
ddf6fe37 31799@item -mfix-gr712rc
d77de738
ML
31800Enable the documented workaround for the back-to-back store errata of
31801the GR712RC processor.
31802@end table
31803
31804These @samp{-m} options are supported in addition to the above
31805on SPARC-V9 processors in 64-bit environments:
31806
31807@table @gcctabopt
d77de738
ML
31808@opindex m32
31809@opindex m64
ddf6fe37
AA
31810@item -m32
31811@itemx -m64
d77de738
ML
31812Generate code for a 32-bit or 64-bit environment.
31813The 32-bit environment sets int, long and pointer to 32 bits.
31814The 64-bit environment sets int to 32 bits and long and pointer
31815to 64 bits.
31816
d77de738 31817@opindex mcmodel
ddf6fe37 31818@item -mcmodel=@var{which}
d77de738
ML
31819Set the code model to one of
31820
31821@table @samp
31822@item medlow
31823The Medium/Low code model: 64-bit addresses, programs
31824must be linked in the low 32 bits of memory. Programs can be statically
31825or dynamically linked.
31826
31827@item medmid
31828The Medium/Middle code model: 64-bit addresses, programs
31829must be linked in the low 44 bits of memory, the text and data segments must
31830be less than 2GB in size and the data segment must be located within 2GB of
31831the text segment.
31832
31833@item medany
31834The Medium/Anywhere code model: 64-bit addresses, programs
31835may be linked anywhere in memory, the text and data segments must be less
31836than 2GB in size and the data segment must be located within 2GB of the
31837text segment.
31838
31839@item embmedany
31840The Medium/Anywhere code model for embedded systems:
3184164-bit addresses, the text and data segments must be less than 2GB in
31842size, both starting anywhere in memory (determined at link time). The
31843global register %g4 points to the base of the data segment. Programs
31844are statically linked and PIC is not supported.
31845@end table
31846
d77de738 31847@opindex mmemory-model
ddf6fe37 31848@item -mmemory-model=@var{mem-model}
d77de738
ML
31849Set the memory model in force on the processor to one of
31850
31851@table @samp
31852@item default
31853The default memory model for the processor and operating system.
31854
31855@item rmo
31856Relaxed Memory Order
31857
31858@item pso
31859Partial Store Order
31860
31861@item tso
31862Total Store Order
31863
31864@item sc
31865Sequential Consistency
31866@end table
31867
31868These memory models are formally defined in Appendix D of the SPARC-V9
31869architecture manual, as set in the processor's @code{PSTATE.MM} field.
31870
d77de738
ML
31871@opindex mstack-bias
31872@opindex mno-stack-bias
ddf6fe37
AA
31873@item -mstack-bias
31874@itemx -mno-stack-bias
d77de738
ML
31875With @option{-mstack-bias}, GCC assumes that the stack pointer, and
31876frame pointer if present, are offset by @minus{}2047 which must be added back
31877when making stack frame references. This is the default in 64-bit mode.
31878Otherwise, assume no such offset is present.
31879@end table
31880
31881@node System V Options
31882@subsection Options for System V
31883
31884These additional options are available on System V Release 4 for
31885compatibility with other compilers on those systems:
31886
31887@table @gcctabopt
d77de738 31888@opindex G
ddf6fe37 31889@item -G
d77de738
ML
31890Create a shared object.
31891It is recommended that @option{-symbolic} or @option{-shared} be used instead.
31892
d77de738 31893@opindex Qy
ddf6fe37 31894@item -Qy
d77de738
ML
31895Identify the versions of each tool used by the compiler, in a
31896@code{.ident} assembler directive in the output.
31897
d77de738 31898@opindex Qn
ddf6fe37 31899@item -Qn
d77de738
ML
31900Refrain from adding @code{.ident} directives to the output file (this is
31901the default).
31902
d77de738 31903@opindex YP
ddf6fe37 31904@item -YP,@var{dirs}
d77de738
ML
31905Search the directories @var{dirs}, and no others, for libraries
31906specified with @option{-l}.
31907
d77de738 31908@opindex Ym
ddf6fe37 31909@item -Ym,@var{dir}
d77de738
ML
31910Look in the directory @var{dir} to find the M4 preprocessor.
31911The assembler uses this option.
31912@c This is supposed to go with a -Yd for predefined M4 macro files, but
31913@c the generic assembler that comes with Solaris takes just -Ym.
31914@end table
31915
31916@node V850 Options
31917@subsection V850 Options
31918@cindex V850 Options
31919
31920These @samp{-m} options are defined for V850 implementations:
31921
31922@table @gcctabopt
d77de738
ML
31923@opindex mlong-calls
31924@opindex mno-long-calls
ddf6fe37
AA
31925@item -mlong-calls
31926@itemx -mno-long-calls
d77de738
ML
31927Treat all calls as being far away (near). If calls are assumed to be
31928far away, the compiler always loads the function's address into a
31929register, and calls indirect through the pointer.
31930
d77de738
ML
31931@opindex mno-ep
31932@opindex mep
ddf6fe37
AA
31933@item -mno-ep
31934@itemx -mep
d77de738
ML
31935Do not optimize (do optimize) basic blocks that use the same index
31936pointer 4 or more times to copy pointer into the @code{ep} register, and
31937use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
31938option is on by default if you optimize.
31939
d77de738
ML
31940@opindex mno-prolog-function
31941@opindex mprolog-function
ddf6fe37
AA
31942@item -mno-prolog-function
31943@itemx -mprolog-function
d77de738
ML
31944Do not use (do use) external functions to save and restore registers
31945at the prologue and epilogue of a function. The external functions
31946are slower, but use less code space if more than one function saves
31947the same number of registers. The @option{-mprolog-function} option
31948is on by default if you optimize.
31949
d77de738 31950@opindex mspace
ddf6fe37 31951@item -mspace
d77de738
ML
31952Try to make the code as small as possible. At present, this just turns
31953on the @option{-mep} and @option{-mprolog-function} options.
31954
d77de738 31955@opindex mtda
ddf6fe37 31956@item -mtda=@var{n}
d77de738
ML
31957Put static or global variables whose size is @var{n} bytes or less into
31958the tiny data area that register @code{ep} points to. The tiny data
31959area can hold up to 256 bytes in total (128 bytes for byte references).
31960
d77de738 31961@opindex msda
ddf6fe37 31962@item -msda=@var{n}
d77de738
ML
31963Put static or global variables whose size is @var{n} bytes or less into
31964the small data area that register @code{gp} points to. The small data
31965area can hold up to 64 kilobytes.
31966
d77de738 31967@opindex mzda
ddf6fe37 31968@item -mzda=@var{n}
d77de738
ML
31969Put static or global variables whose size is @var{n} bytes or less into
31970the first 32 kilobytes of memory.
31971
d77de738 31972@opindex mv850
ddf6fe37 31973@item -mv850
d77de738
ML
31974Specify that the target processor is the V850.
31975
d77de738 31976@opindex mv850e3v5
ddf6fe37 31977@item -mv850e3v5
d77de738
ML
31978Specify that the target processor is the V850E3V5. The preprocessor
31979constant @code{__v850e3v5__} is defined if this option is used.
31980
d77de738 31981@opindex mv850e2v4
ddf6fe37 31982@item -mv850e2v4
d77de738
ML
31983Specify that the target processor is the V850E3V5. This is an alias for
31984the @option{-mv850e3v5} option.
31985
d77de738 31986@opindex mv850e2v3
ddf6fe37 31987@item -mv850e2v3
d77de738
ML
31988Specify that the target processor is the V850E2V3. The preprocessor
31989constant @code{__v850e2v3__} is defined if this option is used.
31990
d77de738 31991@opindex mv850e2
ddf6fe37 31992@item -mv850e2
d77de738
ML
31993Specify that the target processor is the V850E2. The preprocessor
31994constant @code{__v850e2__} is defined if this option is used.
31995
d77de738 31996@opindex mv850e1
ddf6fe37 31997@item -mv850e1
d77de738
ML
31998Specify that the target processor is the V850E1. The preprocessor
31999constants @code{__v850e1__} and @code{__v850e__} are defined if
32000this option is used.
32001
d77de738 32002@opindex mv850es
ddf6fe37 32003@item -mv850es
d77de738
ML
32004Specify that the target processor is the V850ES. This is an alias for
32005the @option{-mv850e1} option.
32006
d77de738 32007@opindex mv850e
ddf6fe37 32008@item -mv850e
d77de738
ML
32009Specify that the target processor is the V850E@. The preprocessor
32010constant @code{__v850e__} is defined if this option is used.
32011
32012If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
32013nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
32014are defined then a default target processor is chosen and the
32015relevant @samp{__v850*__} preprocessor constant is defined.
32016
32017The preprocessor constants @code{__v850} and @code{__v851__} are always
32018defined, regardless of which processor variant is the target.
32019
d77de738
ML
32020@opindex mdisable-callt
32021@opindex mno-disable-callt
ddf6fe37
AA
32022@item -mdisable-callt
32023@itemx -mno-disable-callt
d77de738
ML
32024This option suppresses generation of the @code{CALLT} instruction for the
32025v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
32026architecture.
32027
32028This option is enabled by default when the RH850 ABI is
32029in use (see @option{-mrh850-abi}), and disabled by default when the
32030GCC ABI is in use. If @code{CALLT} instructions are being generated
32031then the C preprocessor symbol @code{__V850_CALLT__} is defined.
32032
d77de738
ML
32033@opindex mrelax
32034@opindex mno-relax
ddf6fe37
AA
32035@item -mrelax
32036@itemx -mno-relax
d77de738
ML
32037Pass on (or do not pass on) the @option{-mrelax} command-line option
32038to the assembler.
32039
d77de738
ML
32040@opindex mlong-jumps
32041@opindex mno-long-jumps
ddf6fe37
AA
32042@item -mlong-jumps
32043@itemx -mno-long-jumps
d77de738
ML
32044Disable (or re-enable) the generation of PC-relative jump instructions.
32045
d77de738
ML
32046@opindex msoft-float
32047@opindex mhard-float
ddf6fe37
AA
32048@item -msoft-float
32049@itemx -mhard-float
d77de738
ML
32050Disable (or re-enable) the generation of hardware floating point
32051instructions. This option is only significant when the target
32052architecture is @samp{V850E2V3} or higher. If hardware floating point
32053instructions are being generated then the C preprocessor symbol
32054@code{__FPU_OK__} is defined, otherwise the symbol
32055@code{__NO_FPU__} is defined.
32056
d77de738 32057@opindex mloop
ddf6fe37 32058@item -mloop
d77de738
ML
32059Enables the use of the e3v5 LOOP instruction. The use of this
32060instruction is not enabled by default when the e3v5 architecture is
32061selected because its use is still experimental.
32062
d77de738
ML
32063@opindex mrh850-abi
32064@opindex mghs
ddf6fe37
AA
32065@item -mrh850-abi
32066@itemx -mghs
d77de738
ML
32067Enables support for the RH850 version of the V850 ABI. This is the
32068default. With this version of the ABI the following rules apply:
32069
32070@itemize
32071@item
32072Integer sized structures and unions are returned via a memory pointer
32073rather than a register.
32074
32075@item
32076Large structures and unions (more than 8 bytes in size) are passed by
32077value.
32078
32079@item
32080Functions are aligned to 16-bit boundaries.
32081
32082@item
32083The @option{-m8byte-align} command-line option is supported.
32084
32085@item
32086The @option{-mdisable-callt} command-line option is enabled by
32087default. The @option{-mno-disable-callt} command-line option is not
32088supported.
32089@end itemize
32090
32091When this version of the ABI is enabled the C preprocessor symbol
32092@code{__V850_RH850_ABI__} is defined.
32093
d77de738 32094@opindex mgcc-abi
ddf6fe37 32095@item -mgcc-abi
d77de738
ML
32096Enables support for the old GCC version of the V850 ABI. With this
32097version of the ABI the following rules apply:
32098
32099@itemize
32100@item
32101Integer sized structures and unions are returned in register @code{r10}.
32102
32103@item
32104Large structures and unions (more than 8 bytes in size) are passed by
32105reference.
32106
32107@item
32108Functions are aligned to 32-bit boundaries, unless optimizing for
32109size.
32110
32111@item
32112The @option{-m8byte-align} command-line option is not supported.
32113
32114@item
32115The @option{-mdisable-callt} command-line option is supported but not
32116enabled by default.
32117@end itemize
32118
32119When this version of the ABI is enabled the C preprocessor symbol
32120@code{__V850_GCC_ABI__} is defined.
32121
d77de738
ML
32122@opindex m8byte-align
32123@opindex mno-8byte-align
ddf6fe37
AA
32124@item -m8byte-align
32125@itemx -mno-8byte-align
d77de738
ML
32126Enables support for @code{double} and @code{long long} types to be
32127aligned on 8-byte boundaries. The default is to restrict the
32128alignment of all objects to at most 4-bytes. When
32129@option{-m8byte-align} is in effect the C preprocessor symbol
32130@code{__V850_8BYTE_ALIGN__} is defined.
32131
d77de738 32132@opindex mbig-switch
ddf6fe37 32133@item -mbig-switch
d77de738
ML
32134Generate code suitable for big switch tables. Use this option only if
32135the assembler/linker complain about out of range branches within a switch
32136table.
32137
d77de738 32138@opindex mapp-regs
ddf6fe37 32139@item -mapp-regs
d77de738
ML
32140This option causes r2 and r5 to be used in the code generated by
32141the compiler. This setting is the default.
32142
d77de738 32143@opindex mno-app-regs
ddf6fe37 32144@item -mno-app-regs
d77de738
ML
32145This option causes r2 and r5 to be treated as fixed registers.
32146
32147@end table
32148
32149@node VAX Options
32150@subsection VAX Options
32151@cindex VAX options
32152
32153These @samp{-m} options are defined for the VAX:
32154
32155@table @gcctabopt
d77de738 32156@opindex munix
ddf6fe37 32157@item -munix
d77de738
ML
32158Do not output certain jump instructions (@code{aobleq} and so on)
32159that the Unix assembler for the VAX cannot handle across long
32160ranges.
32161
d77de738 32162@opindex mgnu
ddf6fe37 32163@item -mgnu
d77de738
ML
32164Do output those jump instructions, on the assumption that the
32165GNU assembler is being used.
32166
d77de738 32167@opindex mg
ddf6fe37 32168@item -mg
d77de738
ML
32169Output code for G-format floating-point numbers instead of D-format.
32170
d77de738
ML
32171@opindex mlra
32172@opindex mno-lra
ddf6fe37
AA
32173@item -mlra
32174@itemx -mno-lra
d77de738
ML
32175Enable Local Register Allocation. This is still experimental for the VAX,
32176so by default the compiler uses standard reload.
32177@end table
32178
32179@node Visium Options
32180@subsection Visium Options
32181@cindex Visium options
32182
32183@table @gcctabopt
32184
d77de738 32185@opindex mdebug
ddf6fe37 32186@item -mdebug
d77de738
ML
32187A program which performs file I/O and is destined to run on an MCM target
32188should be linked with this option. It causes the libraries libc.a and
32189libdebug.a to be linked. The program should be run on the target under
32190the control of the GDB remote debugging stub.
32191
d77de738 32192@opindex msim
ddf6fe37 32193@item -msim
d77de738
ML
32194A program which performs file I/O and is destined to run on the simulator
32195should be linked with option. This causes libraries libc.a and libsim.a to
32196be linked.
32197
d77de738
ML
32198@opindex mfpu
32199@opindex mhard-float
ddf6fe37
AA
32200@item -mfpu
32201@itemx -mhard-float
d77de738
ML
32202Generate code containing floating-point instructions. This is the
32203default.
32204
d77de738
ML
32205@opindex mno-fpu
32206@opindex msoft-float
ddf6fe37
AA
32207@item -mno-fpu
32208@itemx -msoft-float
d77de738
ML
32209Generate code containing library calls for floating-point.
32210
32211@option{-msoft-float} changes the calling convention in the output file;
32212therefore, it is only useful if you compile @emph{all} of a program with
32213this option. In particular, you need to compile @file{libgcc.a}, the
32214library that comes with GCC, with @option{-msoft-float} in order for
32215this to work.
32216
d77de738 32217@opindex mcpu
ddf6fe37 32218@item -mcpu=@var{cpu_type}
d77de738
ML
32219Set the instruction set, register set, and instruction scheduling parameters
32220for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32221@samp{mcm}, @samp{gr5} and @samp{gr6}.
32222
32223@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
32224
32225By default (unless configured otherwise), GCC generates code for the GR5
32226variant of the Visium architecture.
32227
32228With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
32229architecture. The only difference from GR5 code is that the compiler will
32230generate block move instructions.
32231
d77de738 32232@opindex mtune
ddf6fe37 32233@item -mtune=@var{cpu_type}
d77de738
ML
32234Set the instruction scheduling parameters for machine type @var{cpu_type},
32235but do not set the instruction set or register set that the option
32236@option{-mcpu=@var{cpu_type}} would.
32237
d77de738 32238@opindex msv-mode
ddf6fe37 32239@item -msv-mode
d77de738
ML
32240Generate code for the supervisor mode, where there are no restrictions on
32241the access to general registers. This is the default.
32242
d77de738 32243@opindex muser-mode
ddf6fe37 32244@item -muser-mode
d77de738
ML
32245Generate code for the user mode, where the access to some general registers
32246is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
32247mode; on the GR6, only registers r29 to r31 are affected.
32248@end table
32249
32250@node VMS Options
32251@subsection VMS Options
32252
32253These @samp{-m} options are defined for the VMS implementations:
32254
32255@table @gcctabopt
d77de738 32256@opindex mvms-return-codes
ddf6fe37 32257@item -mvms-return-codes
d77de738
ML
32258Return VMS condition codes from @code{main}. The default is to return POSIX-style
32259condition (e.g.@: error) codes.
32260
d77de738 32261@opindex mdebug-main=@var{prefix}
ddf6fe37 32262@item -mdebug-main=@var{prefix}
d77de738
ML
32263Flag the first routine whose name starts with @var{prefix} as the main
32264routine for the debugger.
32265
d77de738 32266@opindex mmalloc64
ddf6fe37 32267@item -mmalloc64
d77de738
ML
32268Default to 64-bit memory allocation routines.
32269
d77de738 32270@opindex mpointer-size=@var{size}
ddf6fe37 32271@item -mpointer-size=@var{size}
d77de738
ML
32272Set the default size of pointers. Possible options for @var{size} are
32273@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
32274for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
32275The later option disables @code{pragma pointer_size}.
32276@end table
32277
32278@node VxWorks Options
32279@subsection VxWorks Options
32280@cindex VxWorks Options
32281
32282The options in this section are defined for all VxWorks targets.
32283Options specific to the target hardware are listed with the other
32284options for that target.
32285
32286@table @gcctabopt
d77de738 32287@opindex mrtp
ddf6fe37 32288@item -mrtp
d77de738
ML
32289GCC can generate code for both VxWorks kernels and real time processes
32290(RTPs). This option switches from the former to the latter. It also
32291defines the preprocessor macro @code{__RTP__}.
32292
d77de738 32293@opindex non-static
ddf6fe37 32294@item -non-static
d77de738
ML
32295Link an RTP executable against shared libraries rather than static
32296libraries. The options @option{-static} and @option{-shared} can
32297also be used for RTPs (@pxref{Link Options}); @option{-static}
32298is the default.
32299
d77de738
ML
32300@opindex Bstatic
32301@opindex Bdynamic
ddf6fe37
AA
32302@item -Bstatic
32303@itemx -Bdynamic
d77de738
ML
32304These options are passed down to the linker. They are defined for
32305compatibility with Diab.
32306
d77de738 32307@opindex Xbind-lazy
ddf6fe37 32308@item -Xbind-lazy
d77de738
ML
32309Enable lazy binding of function calls. This option is equivalent to
32310@option{-Wl,-z,now} and is defined for compatibility with Diab.
32311
d77de738 32312@opindex Xbind-now
ddf6fe37 32313@item -Xbind-now
d77de738
ML
32314Disable lazy binding of function calls. This option is the default and
32315is defined for compatibility with Diab.
32316@end table
32317
32318@node x86 Options
32319@subsection x86 Options
32320@cindex x86 Options
32321
32322These @samp{-m} options are defined for the x86 family of computers.
32323
32324@table @gcctabopt
32325
d77de738 32326@opindex march
ddf6fe37 32327@item -march=@var{cpu-type}
d77de738
ML
32328Generate instructions for the machine type @var{cpu-type}. In contrast to
32329@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32330for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32331to generate code that may not run at all on processors other than the one
32332indicated. Specifying @option{-march=@var{cpu-type}} implies
32333@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32334
32335The choices for @var{cpu-type} are:
32336
32337@table @samp
32338@item native
32339This selects the CPU to generate code for at compilation time by determining
32340the processor type of the compiling machine. Using @option{-march=native}
32341enables all instruction subsets supported by the local machine (hence
32342the result might not run on different machines). Using @option{-mtune=native}
32343produces code optimized for the local machine under the constraints
32344of the selected instruction set.
32345
32346@item x86-64
32347A generic CPU with 64-bit extensions.
32348
32349@item x86-64-v2
32350@itemx x86-64-v3
32351@itemx x86-64-v4
32352These choices for @var{cpu-type} select the corresponding
32353micro-architecture level from the x86-64 psABI. On ABIs other than
32354the x86-64 psABI they select the same CPU features as the x86-64 psABI
32355documents for the particular micro-architecture level.
32356
32357Since these @var{cpu-type} values do not have a corresponding
32358@option{-mtune} setting, using @option{-march} with these values enables
32359generic tuning. Specific tuning can be enabled using the
32360@option{-mtune=@var{other-cpu-type}} option with an appropriate
32361@var{other-cpu-type} value.
32362
32363@item i386
32364Original Intel i386 CPU@.
32365
32366@item i486
32367Intel i486 CPU@. (No scheduling is implemented for this chip.)
32368
32369@item i586
32370@itemx pentium
32371Intel Pentium CPU with no MMX support.
32372
32373@item lakemont
32374Intel Lakemont MCU, based on Intel Pentium CPU.
32375
32376@item pentium-mmx
32377Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32378
32379@item pentiumpro
32380Intel Pentium Pro CPU@.
32381
32382@item i686
32383When used with @option{-march}, the Pentium Pro
32384instruction set is used, so the code runs on all i686 family chips.
32385When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32386
32387@item pentium2
32388Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32389set support.
32390
32391@item pentium3
32392@itemx pentium3m
32393Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32394instruction set support.
32395
32396@item pentium-m
32397Intel Pentium M; low-power version of Intel Pentium III CPU
32398with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32399notebooks.
32400
32401@item pentium4
32402@itemx pentium4m
32403Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32404
32405@item prescott
32406Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32407instruction set support.
32408
32409@item nocona
32410Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32411SSE2, SSE3 and FXSR instruction set support.
32412
32413@item core2
32414Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32415SAHF and FXSR instruction set support.
32416
32417@item nehalem
32418Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32419SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32420
32421@item westmere
32422Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32423SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32424
32425@item sandybridge
32426Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32427SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32428support.
32429
32430@item ivybridge
32431Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32432SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32433and F16C instruction set support.
32434
32435@item haswell
32436Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32437SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32438F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32439
32440@item broadwell
32441Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32442SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32443F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32444instruction set support.
32445
32446@item skylake
32447Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32448SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32449F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32450CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32451
32452@item bonnell
32453Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32454instruction set support.
32455
32456@item silvermont
32457Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32458SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32459instruction set support.
32460
32461@item goldmont
32462Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32463SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32464RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32465set support.
32466
32467@item goldmont-plus
32468Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32469SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32470SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32471RDPID and SGX instruction set support.
32472
32473@item tremont
32474Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32475SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32476RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32477SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32478support.
32479
32480@item sierraforest
32481Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32482SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32483XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32484MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32485PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32486AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32487
32488@item grandridge
32489Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32490SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32491XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32492MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32493PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32494AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set
32495support.
32496
32497@item knl
32498Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32499SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32500RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32501AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32502
32503@item knm
32504Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32505SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32506RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32507AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32508AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32509
32510@item skylake-avx512
32511Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32512SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32513RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32514AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32515AVX512DQ and AVX512CD instruction set support.
32516
32517@item cannonlake
32518Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32519SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32520FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32521PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32522AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32523support.
32524
32525@item icelake-client
32526Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32527SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32528RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32529AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32530AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32531, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32532
32533@item icelake-server
32534Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32535SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32536RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32537AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32538AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32539, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32540instruction set support.
32541
32542@item cascadelake
32543Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32544SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32545F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32546CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32547AVX512CD and AVX512VNNI instruction set support.
32548
32549@item cooperlake
32550Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32551SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32552F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32553CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32554AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32555
32556@item tigerlake
32557Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32558SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32559F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32560CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32561PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32562VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32563AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32564
32565@item sapphirerapids
32566Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32567SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32568RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32569AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32570AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32571VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32572MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
29ecb952 32573UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
d77de738
ML
32574instruction set support.
32575
32576@item alderlake
32577Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32578SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32579XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32580CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32581VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32582support.
32583
32584@item rocketlake
32585Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32586, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32587F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32588CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32589PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32590VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32591
32592@item graniterapids
32593Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32594SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32595RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32596AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32597AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32598VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32599MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
29ecb952 32600SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16,
d77de738
ML
32601AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
32602
32603@item k6
32604AMD K6 CPU with MMX instruction set support.
32605
32606@item k6-2
32607@itemx k6-3
32608Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
32609
32610@item athlon
32611@itemx athlon-tbird
32612AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
32613support.
32614
32615@item athlon-4
32616@itemx athlon-xp
32617@itemx athlon-mp
32618Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
32619instruction set support.
32620
32621@item k8
32622@itemx opteron
32623@itemx athlon64
32624@itemx athlon-fx
32625Processors based on the AMD K8 core with x86-64 instruction set support,
32626including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
32627(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
32628instruction set extensions.)
32629
32630@item k8-sse3
32631@itemx opteron-sse3
32632@itemx athlon64-sse3
32633Improved versions of AMD K8 cores with SSE3 instruction set support.
32634
32635@item amdfam10
32636@itemx barcelona
32637CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
32638supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
32639instruction set extensions.)
32640
32641@item bdver1
32642CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
32643supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
32644SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
32645
32646@item bdver2
32647AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32648supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
32649SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
32650extensions.)
32651
32652@item bdver3
32653AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32654supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
32655PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3265664-bit instruction set extensions.)
32657
32658@item bdver4
32659AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32660supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
32661AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
32662SSE4.2, ABM and 64-bit instruction set extensions.)
32663
32664@item znver1
32665AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32666supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
32667SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
32668SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
32669instruction set extensions.)
32670
32671@item znver2
32672AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32673supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32674MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32675SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32676WBNOINVD, and 64-bit instruction set extensions.)
32677
32678@item znver3
32679AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32680supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32681MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32682SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32683WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
32684
32685@item znver4
32686AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32687supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32688MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32689SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32690WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
32691AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
32692AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
32693
32694@item btver1
32695CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
32696supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
32697instruction set extensions.)
32698
32699@item btver2
32700CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
32701includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
32702SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
32703
32704@item winchip-c6
32705IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
32706set support.
32707
32708@item winchip2
32709IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
32710instruction set support.
32711
32712@item c3
32713VIA C3 CPU with MMX and 3DNow!@: instruction set support.
32714(No scheduling is implemented for this chip.)
32715
32716@item c3-2
32717VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
32718(No scheduling is implemented for this chip.)
32719
32720@item c7
32721VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32722(No scheduling is implemented for this chip.)
32723
32724@item samuel-2
32725VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
32726(No scheduling is implemented for this chip.)
32727
32728@item nehemiah
32729VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
32730(No scheduling is implemented for this chip.)
32731
32732@item esther
32733VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32734(No scheduling is implemented for this chip.)
32735
32736@item eden-x2
32737VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
32738(No scheduling is implemented for this chip.)
32739
32740@item eden-x4
32741VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
32742AVX and AVX2 instruction set support.
32743(No scheduling is implemented for this chip.)
32744
32745@item nano
32746Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32747instruction set support.
32748(No scheduling is implemented for this chip.)
32749
32750@item nano-1000
32751VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32752instruction set support.
32753(No scheduling is implemented for this chip.)
32754
32755@item nano-2000
32756VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32757instruction set support.
32758(No scheduling is implemented for this chip.)
32759
32760@item nano-3000
32761VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32762instruction set support.
32763(No scheduling is implemented for this chip.)
32764
32765@item nano-x2
32766VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32767instruction set support.
32768(No scheduling is implemented for this chip.)
32769
32770@item nano-x4
32771VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32772instruction set support.
32773(No scheduling is implemented for this chip.)
32774
32775@item lujiazui
32776ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
32777SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
32778ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
32779
32780@item geode
32781AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
32782@end table
32783
d77de738 32784@opindex mtune
ddf6fe37 32785@item -mtune=@var{cpu-type}
d77de738
ML
32786Tune to @var{cpu-type} everything applicable about the generated code, except
32787for the ABI and the set of available instructions.
32788While picking a specific @var{cpu-type} schedules things appropriately
32789for that particular chip, the compiler does not generate any code that
32790cannot run on the default machine type unless you use a
32791@option{-march=@var{cpu-type}} option.
32792For example, if GCC is configured for i686-pc-linux-gnu
32793then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
32794but still runs on i686 machines.
32795
32796The choices for @var{cpu-type} are the same as for @option{-march}.
32797In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
32798
32799@table @samp
32800@item generic
32801Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
32802If you know the CPU on which your code will run, then you should use
32803the corresponding @option{-mtune} or @option{-march} option instead of
32804@option{-mtune=generic}. But, if you do not know exactly what CPU users
32805of your application will have, then you should use this option.
32806
32807As new processors are deployed in the marketplace, the behavior of this
32808option will change. Therefore, if you upgrade to a newer version of
32809GCC, code generation controlled by this option will change to reflect
32810the processors
32811that are most common at the time that version of GCC is released.
32812
32813There is no @option{-march=generic} option because @option{-march}
32814indicates the instruction set the compiler can use, and there is no
32815generic instruction set applicable to all processors. In contrast,
32816@option{-mtune} indicates the processor (or, in this case, collection of
32817processors) for which the code is optimized.
32818
32819@item intel
32820Produce code optimized for the most current Intel processors, which are
32821Haswell and Silvermont for this version of GCC. If you know the CPU
32822on which your code will run, then you should use the corresponding
32823@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
32824But, if you want your application performs better on both Haswell and
32825Silvermont, then you should use this option.
32826
32827As new Intel processors are deployed in the marketplace, the behavior of
32828this option will change. Therefore, if you upgrade to a newer version of
32829GCC, code generation controlled by this option will change to reflect
32830the most current Intel processors at the time that version of GCC is
32831released.
32832
32833There is no @option{-march=intel} option because @option{-march} indicates
32834the instruction set the compiler can use, and there is no common
32835instruction set applicable to all processors. In contrast,
32836@option{-mtune} indicates the processor (or, in this case, collection of
32837processors) for which the code is optimized.
32838@end table
32839
d77de738 32840@opindex mcpu
ddf6fe37 32841@item -mcpu=@var{cpu-type}
d77de738
ML
32842A deprecated synonym for @option{-mtune}.
32843
d77de738 32844@opindex mfpmath
ddf6fe37 32845@item -mfpmath=@var{unit}
d77de738
ML
32846Generate floating-point arithmetic for selected unit @var{unit}. The choices
32847for @var{unit} are:
32848
32849@table @samp
32850@item 387
32851Use the standard 387 floating-point coprocessor present on the majority of chips and
32852emulated otherwise. Code compiled with this option runs almost everywhere.
32853The temporary results are computed in 80-bit precision instead of the precision
32854specified by the type, resulting in slightly different results compared to most
32855of other chips. See @option{-ffloat-store} for more detailed description.
32856
32857This is the default choice for non-Darwin x86-32 targets.
32858
32859@item sse
32860Use scalar floating-point instructions present in the SSE instruction set.
32861This instruction set is supported by Pentium III and newer chips,
32862and in the AMD line
32863by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
32864instruction set supports only single-precision arithmetic, thus the double and
32865extended-precision arithmetic are still done using 387. A later version, present
32866only in Pentium 4 and AMD x86-64 chips, supports double-precision
32867arithmetic too.
32868
32869For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
32870or @option{-msse2} switches to enable SSE extensions and make this option
32871effective. For the x86-64 compiler, these extensions are enabled by default.
32872
32873The resulting code should be considerably faster in the majority of cases and avoid
32874the numerical instability problems of 387 code, but may break some existing
32875code that expects temporaries to be 80 bits.
32876
32877This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
32878and the default choice for x86-32 targets with the SSE2 instruction set
32879when @option{-ffast-math} is enabled.
32880
32881@item sse,387
32882@itemx sse+387
32883@itemx both
32884Attempt to utilize both instruction sets at once. This effectively doubles the
32885amount of available registers, and on chips with separate execution units for
32886387 and SSE the execution resources too. Use this option with care, as it is
32887still experimental, because the GCC register allocator does not model separate
32888functional units well, resulting in unstable performance.
32889@end table
32890
d77de738 32891@opindex masm=@var{dialect}
ddf6fe37 32892@item -masm=@var{dialect}
d77de738
ML
32893Output assembly instructions using selected @var{dialect}. Also affects
32894which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
32895extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
32896order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
32897not support @samp{intel}.
32898
d77de738
ML
32899@opindex mieee-fp
32900@opindex mno-ieee-fp
ddf6fe37
AA
32901@item -mieee-fp
32902@itemx -mno-ieee-fp
d77de738
ML
32903Control whether or not the compiler uses IEEE floating-point
32904comparisons. These correctly handle the case where the result of a
32905comparison is unordered.
32906
30348d30 32907@opindex m80387
d77de738 32908@opindex mhard-float
ddf6fe37
AA
32909@item -m80387
32910@itemx -mhard-float
d77de738
ML
32911Generate output containing 80387 instructions for floating point.
32912
d77de738
ML
32913@opindex no-80387
32914@opindex msoft-float
ddf6fe37
AA
32915@item -mno-80387
32916@itemx -msoft-float
d77de738
ML
32917Generate output containing library calls for floating point.
32918
32919@strong{Warning:} the requisite libraries are not part of GCC@.
32920Normally the facilities of the machine's usual C compiler are used, but
32921this cannot be done directly in cross-compilation. You must make your
32922own arrangements to provide suitable library functions for
32923cross-compilation.
32924
32925On machines where a function returns floating-point results in the 80387
32926register stack, some floating-point opcodes may be emitted even if
32927@option{-msoft-float} is used.
32928
d77de738
ML
32929@opindex mno-fp-ret-in-387
32930@opindex mfp-ret-in-387
ddf6fe37 32931@item -mno-fp-ret-in-387
d77de738
ML
32932Do not use the FPU registers for return values of functions.
32933
32934The usual calling convention has functions return values of types
32935@code{float} and @code{double} in an FPU register, even if there
32936is no FPU@. The idea is that the operating system should emulate
32937an FPU@.
32938
32939The option @option{-mno-fp-ret-in-387} causes such values to be returned
32940in ordinary CPU registers instead.
32941
d77de738
ML
32942@opindex mno-fancy-math-387
32943@opindex mfancy-math-387
ddf6fe37 32944@item -mno-fancy-math-387
d77de738
ML
32945Some 387 emulators do not support the @code{sin}, @code{cos} and
32946@code{sqrt} instructions for the 387. Specify this option to avoid
32947generating those instructions.
32948This option is overridden when @option{-march}
32949indicates that the target CPU always has an FPU and so the
32950instruction does not need emulation. These
32951instructions are not generated unless you also use the
32952@option{-funsafe-math-optimizations} switch.
32953
d77de738
ML
32954@opindex malign-double
32955@opindex mno-align-double
ddf6fe37
AA
32956@item -malign-double
32957@itemx -mno-align-double
d77de738
ML
32958Control whether GCC aligns @code{double}, @code{long double}, and
32959@code{long long} variables on a two-word boundary or a one-word
32960boundary. Aligning @code{double} variables on a two-word boundary
32961produces code that runs somewhat faster on a Pentium at the
32962expense of more memory.
32963
32964On x86-64, @option{-malign-double} is enabled by default.
32965
32966@strong{Warning:} if you use the @option{-malign-double} switch,
32967structures containing the above types are aligned differently than
32968the published application binary interface specifications for the x86-32
32969and are not binary compatible with structures in code compiled
32970without that switch.
32971
d77de738
ML
32972@opindex m96bit-long-double
32973@opindex m128bit-long-double
ddf6fe37
AA
32974@item -m96bit-long-double
32975@itemx -m128bit-long-double
d77de738
ML
32976These switches control the size of @code{long double} type. The x86-32
32977application binary interface specifies the size to be 96 bits,
32978so @option{-m96bit-long-double} is the default in 32-bit mode.
32979
32980Modern architectures (Pentium and newer) prefer @code{long double}
32981to be aligned to an 8- or 16-byte boundary. In arrays or structures
32982conforming to the ABI, this is not possible. So specifying
32983@option{-m128bit-long-double} aligns @code{long double}
32984to a 16-byte boundary by padding the @code{long double} with an additional
3298532-bit zero.
32986
32987In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
32988its ABI specifies that @code{long double} is aligned on 16-byte boundary.
32989
32990Notice that neither of these options enable any extra precision over the x87
32991standard of 80 bits for a @code{long double}.
32992
32993@strong{Warning:} if you override the default value for your target ABI, this
32994changes the size of
32995structures and arrays containing @code{long double} variables,
32996as well as modifying the function calling convention for functions taking
32997@code{long double}. Hence they are not binary-compatible
32998with code compiled without that switch.
32999
d77de738
ML
33000@opindex mlong-double-64
33001@opindex mlong-double-80
33002@opindex mlong-double-128
ddf6fe37
AA
33003@item -mlong-double-64
33004@itemx -mlong-double-80
33005@itemx -mlong-double-128
d77de738
ML
33006These switches control the size of @code{long double} type. A size
33007of 64 bits makes the @code{long double} type equivalent to the @code{double}
33008type. This is the default for 32-bit Bionic C library. A size
33009of 128 bits makes the @code{long double} type equivalent to the
33010@code{__float128} type. This is the default for 64-bit Bionic C library.
33011
33012@strong{Warning:} if you override the default value for your target ABI, this
33013changes the size of
33014structures and arrays containing @code{long double} variables,
33015as well as modifying the function calling convention for functions taking
33016@code{long double}. Hence they are not binary-compatible
33017with code compiled without that switch.
33018
d77de738 33019@opindex malign-data
ddf6fe37 33020@item -malign-data=@var{type}
d77de738
ML
33021Control how GCC aligns variables. Supported values for @var{type} are
33022@samp{compat} uses increased alignment value compatible uses GCC 4.8
33023and earlier, @samp{abi} uses alignment value as specified by the
33024psABI, and @samp{cacheline} uses increased alignment value to match
33025the cache line size. @samp{compat} is the default.
33026
d77de738 33027@opindex mlarge-data-threshold
ddf6fe37 33028@item -mlarge-data-threshold=@var{threshold}
d77de738
ML
33029When @option{-mcmodel=medium} is specified, data objects larger than
33030@var{threshold} are placed in the large data section. This value must be the
33031same across all objects linked into the binary, and defaults to 65535.
33032
d77de738 33033@opindex mrtd
ddf6fe37 33034@item -mrtd
d77de738
ML
33035Use a different function-calling convention, in which functions that
33036take a fixed number of arguments return with the @code{ret @var{num}}
33037instruction, which pops their arguments while returning. This saves one
33038instruction in the caller since there is no need to pop the arguments
33039there.
33040
33041You can specify that an individual function is called with this calling
33042sequence with the function attribute @code{stdcall}. You can also
33043override the @option{-mrtd} option by using the function attribute
33044@code{cdecl}. @xref{Function Attributes}.
33045
33046@strong{Warning:} this calling convention is incompatible with the one
33047normally used on Unix, so you cannot use it if you need to call
33048libraries compiled with the Unix compiler.
33049
33050Also, you must provide function prototypes for all functions that
33051take variable numbers of arguments (including @code{printf});
33052otherwise incorrect code is generated for calls to those
33053functions.
33054
33055In addition, seriously incorrect code results if you call a
33056function with too many arguments. (Normally, extra arguments are
33057harmlessly ignored.)
33058
d77de738 33059@opindex mregparm
ddf6fe37 33060@item -mregparm=@var{num}
d77de738
ML
33061Control how many registers are used to pass integer arguments. By
33062default, no registers are used to pass arguments, and at most 3
33063registers can be used. You can control this behavior for a specific
33064function by using the function attribute @code{regparm}.
33065@xref{Function Attributes}.
33066
33067@strong{Warning:} if you use this switch, and
33068@var{num} is nonzero, then you must build all modules with the same
33069value, including any libraries. This includes the system libraries and
33070startup modules.
33071
d77de738 33072@opindex msseregparm
ddf6fe37 33073@item -msseregparm
d77de738
ML
33074Use SSE register passing conventions for float and double arguments
33075and return values. You can control this behavior for a specific
33076function by using the function attribute @code{sseregparm}.
33077@xref{Function Attributes}.
33078
33079@strong{Warning:} if you use this switch then you must build all
33080modules with the same value, including any libraries. This includes
33081the system libraries and startup modules.
33082
d77de738 33083@opindex mvect8-ret-in-mem
ddf6fe37 33084@item -mvect8-ret-in-mem
d77de738
ML
33085Return 8-byte vectors in memory instead of MMX registers. This is the
33086default on VxWorks to match the ABI of the Sun Studio compilers until
33087version 12. @emph{Only} use this option if you need to remain
33088compatible with existing code produced by those previous compiler
33089versions or older versions of GCC@.
33090
d77de738
ML
33091@opindex mpc32
33092@opindex mpc64
33093@opindex mpc80
ddf6fe37
AA
33094@item -mpc32
33095@itemx -mpc64
33096@itemx -mpc80
d77de738
ML
33097
33098Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
33099is specified, the significands of results of floating-point operations are
33100rounded to 24 bits (single precision); @option{-mpc64} rounds the
33101significands of results of floating-point operations to 53 bits (double
33102precision) and @option{-mpc80} rounds the significands of results of
33103floating-point operations to 64 bits (extended double precision), which is
33104the default. When this option is used, floating-point operations in higher
33105precisions are not available to the programmer without setting the FPU
33106control word explicitly.
33107
33108Setting the rounding of floating-point operations to less than the default
3310980 bits can speed some programs by 2% or more. Note that some mathematical
33110libraries assume that extended-precision (80-bit) floating-point operations
33111are enabled by default; routines in such libraries could suffer significant
33112loss of accuracy, typically through so-called ``catastrophic cancellation'',
33113when this option is used to set the precision to less than extended precision.
33114
e54375d8 33115@opindex mdaz-ftz
ddf6fe37 33116@item -mdaz-ftz
e54375d8 33117
33118The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
33119are used to control floating-point calculations.SSE and AVX instructions
33120including scalar and vector instructions could benefit from enabling the FTZ
33121and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
33122when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
33123will set FTZ/DAZ flags even with @option{-shared}.
33124
d77de738 33125@opindex mstackrealign
ddf6fe37 33126@item -mstackrealign
d77de738
ML
33127Realign the stack at entry. On the x86, the @option{-mstackrealign}
33128option generates an alternate prologue and epilogue that realigns the
33129run-time stack if necessary. This supports mixing legacy codes that keep
331304-byte stack alignment with modern codes that keep 16-byte stack alignment for
33131SSE compatibility. See also the attribute @code{force_align_arg_pointer},
33132applicable to individual functions.
33133
d77de738 33134@opindex mpreferred-stack-boundary
ddf6fe37 33135@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
33136Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
33137byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
33138the default is 4 (16 bytes or 128 bits).
33139
33140@strong{Warning:} When generating code for the x86-64 architecture with
33141SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
33142used to keep the stack boundary aligned to 8 byte boundary. Since
33143x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
33144intended to be used in controlled environment where stack space is
33145important limitation. This option leads to wrong code when functions
33146compiled with 16 byte stack alignment (such as functions from a standard
33147library) are called with misaligned stack. In this case, SSE
33148instructions may lead to misaligned memory access traps. In addition,
33149variable arguments are handled incorrectly for 16 byte aligned
33150objects (including x87 long double and __int128), leading to wrong
33151results. You must build all modules with
33152@option{-mpreferred-stack-boundary=3}, including any libraries. This
33153includes the system libraries and startup modules.
33154
d77de738 33155@opindex mincoming-stack-boundary
ddf6fe37 33156@item -mincoming-stack-boundary=@var{num}
d77de738
ML
33157Assume the incoming stack is aligned to a 2 raised to @var{num} byte
33158boundary. If @option{-mincoming-stack-boundary} is not specified,
33159the one specified by @option{-mpreferred-stack-boundary} is used.
33160
33161On Pentium and Pentium Pro, @code{double} and @code{long double} values
33162should be aligned to an 8-byte boundary (see @option{-malign-double}) or
33163suffer significant run time performance penalties. On Pentium III, the
33164Streaming SIMD Extension (SSE) data type @code{__m128} may not work
33165properly if it is not 16-byte aligned.
33166
33167To ensure proper alignment of this values on the stack, the stack boundary
33168must be as aligned as that required by any value stored on the stack.
33169Further, every function must be generated such that it keeps the stack
33170aligned. Thus calling a function compiled with a higher preferred
33171stack boundary from a function compiled with a lower preferred stack
33172boundary most likely misaligns the stack. It is recommended that
33173libraries that use callbacks always use the default setting.
33174
33175This extra alignment does consume extra stack space, and generally
33176increases code size. Code that is sensitive to stack space usage, such
33177as embedded systems and operating system kernels, may want to reduce the
33178preferred alignment to @option{-mpreferred-stack-boundary=2}.
33179
33180@need 200
d77de738 33181@opindex mmmx
ddf6fe37 33182@item -mmmx
d77de738 33183@need 200
d77de738 33184@opindex msse
ddf6fe37 33185@itemx -msse
d77de738 33186@need 200
d77de738 33187@opindex msse2
ddf6fe37 33188@itemx -msse2
d77de738 33189@need 200
d77de738 33190@opindex msse3
ddf6fe37 33191@itemx -msse3
d77de738 33192@need 200
d77de738 33193@opindex mssse3
ddf6fe37 33194@itemx -mssse3
d77de738 33195@need 200
d77de738 33196@opindex msse4
ddf6fe37 33197@itemx -msse4
d77de738 33198@need 200
d77de738 33199@opindex msse4a
ddf6fe37 33200@itemx -msse4a
d77de738 33201@need 200
d77de738 33202@opindex msse4.1
ddf6fe37 33203@itemx -msse4.1
d77de738 33204@need 200
d77de738 33205@opindex msse4.2
ddf6fe37 33206@itemx -msse4.2
d77de738 33207@need 200
d77de738 33208@opindex mavx
ddf6fe37 33209@itemx -mavx
d77de738 33210@need 200
d77de738 33211@opindex mavx2
ddf6fe37 33212@itemx -mavx2
d77de738 33213@need 200
d77de738 33214@opindex mavx512f
ddf6fe37 33215@itemx -mavx512f
d77de738 33216@need 200
d77de738 33217@opindex mavx512pf
ddf6fe37 33218@itemx -mavx512pf
d77de738 33219@need 200
d77de738 33220@opindex mavx512er
ddf6fe37 33221@itemx -mavx512er
d77de738 33222@need 200
d77de738 33223@opindex mavx512cd
ddf6fe37 33224@itemx -mavx512cd
d77de738 33225@need 200
d77de738 33226@opindex mavx512vl
ddf6fe37 33227@itemx -mavx512vl
d77de738 33228@need 200
d77de738 33229@opindex mavx512bw
ddf6fe37 33230@itemx -mavx512bw
d77de738 33231@need 200
d77de738 33232@opindex mavx512dq
ddf6fe37 33233@itemx -mavx512dq
d77de738 33234@need 200
d77de738 33235@opindex mavx512ifma
ddf6fe37 33236@itemx -mavx512ifma
d77de738 33237@need 200
d77de738 33238@opindex mavx512vbmi
ddf6fe37 33239@itemx -mavx512vbmi
d77de738 33240@need 200
d77de738 33241@opindex msha
ddf6fe37 33242@itemx -msha
d77de738 33243@need 200
d77de738 33244@opindex maes
ddf6fe37 33245@itemx -maes
d77de738 33246@need 200
d77de738 33247@opindex mpclmul
ddf6fe37 33248@itemx -mpclmul
d77de738 33249@need 200
d77de738 33250@opindex mclflushopt
ddf6fe37 33251@itemx -mclflushopt
d77de738 33252@need 200
d77de738 33253@opindex mclwb
ddf6fe37 33254@itemx -mclwb
d77de738 33255@need 200
d77de738 33256@opindex mfsgsbase
ddf6fe37 33257@itemx -mfsgsbase
d77de738 33258@need 200
d77de738 33259@opindex mptwrite
ddf6fe37 33260@itemx -mptwrite
d77de738 33261@need 200
d77de738 33262@opindex mrdrnd
ddf6fe37 33263@itemx -mrdrnd
d77de738 33264@need 200
d77de738 33265@opindex mf16c
ddf6fe37 33266@itemx -mf16c
d77de738 33267@need 200
d77de738 33268@opindex mfma
ddf6fe37 33269@itemx -mfma
d77de738 33270@need 200
d77de738 33271@opindex mpconfig
ddf6fe37 33272@itemx -mpconfig
d77de738 33273@need 200
d77de738 33274@opindex mwbnoinvd
ddf6fe37 33275@itemx -mwbnoinvd
d77de738 33276@need 200
d77de738 33277@opindex mfma4
ddf6fe37 33278@itemx -mfma4
d77de738 33279@need 200
d77de738 33280@opindex mprfchw
ddf6fe37 33281@itemx -mprfchw
d77de738 33282@need 200
d77de738 33283@opindex mrdpid
ddf6fe37 33284@itemx -mrdpid
d77de738 33285@need 200
d77de738 33286@opindex mprefetchwt1
ddf6fe37 33287@itemx -mprefetchwt1
d77de738 33288@need 200
d77de738 33289@opindex mrdseed
ddf6fe37 33290@itemx -mrdseed
d77de738 33291@need 200
d77de738 33292@opindex msgx
ddf6fe37 33293@itemx -msgx
d77de738 33294@need 200
d77de738 33295@opindex mxop
ddf6fe37 33296@itemx -mxop
d77de738 33297@need 200
d77de738 33298@opindex mlwp
ddf6fe37 33299@itemx -mlwp
d77de738 33300@need 200
d77de738 33301@opindex m3dnow
ddf6fe37 33302@itemx -m3dnow
d77de738 33303@need 200
d77de738 33304@opindex m3dnowa
ddf6fe37 33305@itemx -m3dnowa
d77de738 33306@need 200
d77de738 33307@opindex mpopcnt
ddf6fe37 33308@itemx -mpopcnt
d77de738 33309@need 200
d77de738 33310@opindex mabm
ddf6fe37 33311@itemx -mabm
d77de738 33312@need 200
d77de738 33313@opindex madx
ddf6fe37 33314@itemx -madx
d77de738 33315@need 200
d77de738 33316@opindex mbmi
ddf6fe37 33317@itemx -mbmi
d77de738 33318@need 200
d77de738 33319@opindex mbmi2
ddf6fe37 33320@itemx -mbmi2
d77de738 33321@need 200
d77de738 33322@opindex mlzcnt
ddf6fe37 33323@itemx -mlzcnt
d77de738 33324@need 200
d77de738 33325@opindex mfxsr
ddf6fe37 33326@itemx -mfxsr
d77de738 33327@need 200
d77de738 33328@opindex mxsave
ddf6fe37 33329@itemx -mxsave
d77de738 33330@need 200
d77de738 33331@opindex mxsaveopt
ddf6fe37 33332@itemx -mxsaveopt
d77de738 33333@need 200
d77de738 33334@opindex mxsavec
ddf6fe37 33335@itemx -mxsavec
d77de738 33336@need 200
d77de738 33337@opindex mxsaves
ddf6fe37 33338@itemx -mxsaves
d77de738 33339@need 200
d77de738 33340@opindex mrtm
ddf6fe37 33341@itemx -mrtm
d77de738 33342@need 200
d77de738 33343@opindex mhle
ddf6fe37 33344@itemx -mhle
d77de738 33345@need 200
d77de738 33346@opindex mtbm
ddf6fe37 33347@itemx -mtbm
d77de738 33348@need 200
d77de738 33349@opindex mmwaitx
ddf6fe37 33350@itemx -mmwaitx
d77de738 33351@need 200
d77de738 33352@opindex mclzero
ddf6fe37 33353@itemx -mclzero
d77de738 33354@need 200
d77de738 33355@opindex mpku
ddf6fe37 33356@itemx -mpku
d77de738 33357@need 200
d77de738 33358@opindex mavx512vbmi2
ddf6fe37 33359@itemx -mavx512vbmi2
d77de738 33360@need 200
d77de738 33361@opindex mavx512bf16
ddf6fe37 33362@itemx -mavx512bf16
d77de738 33363@need 200
d77de738 33364@opindex mavx512fp16
ddf6fe37 33365@itemx -mavx512fp16
d77de738 33366@need 200
d77de738 33367@opindex mgfni
ddf6fe37 33368@itemx -mgfni
d77de738 33369@need 200
d77de738 33370@opindex mvaes
ddf6fe37 33371@itemx -mvaes
d77de738 33372@need 200
d77de738 33373@opindex mwaitpkg
ddf6fe37 33374@itemx -mwaitpkg
d77de738 33375@need 200
d77de738 33376@opindex mvpclmulqdq
ddf6fe37 33377@itemx -mvpclmulqdq
d77de738 33378@need 200
d77de738 33379@opindex mavx512bitalg
ddf6fe37 33380@itemx -mavx512bitalg
d77de738 33381@need 200
d77de738 33382@opindex mmovdiri
ddf6fe37 33383@itemx -mmovdiri
d77de738 33384@need 200
d77de738 33385@opindex mmovdir64b
ddf6fe37 33386@itemx -mmovdir64b
d77de738 33387@need 200
d77de738 33388@opindex menqcmd
d77de738 33389@opindex muintr
ddf6fe37
AA
33390@itemx -menqcmd
33391@itemx -muintr
d77de738 33392@need 200
d77de738 33393@opindex mtsxldtrk
ddf6fe37 33394@itemx -mtsxldtrk
d77de738 33395@need 200
d77de738 33396@opindex mavx512vpopcntdq
ddf6fe37 33397@itemx -mavx512vpopcntdq
d77de738 33398@need 200
d77de738 33399@opindex mavx512vp2intersect
ddf6fe37 33400@itemx -mavx512vp2intersect
d77de738 33401@need 200
d77de738 33402@opindex mavx5124fmaps
ddf6fe37 33403@itemx -mavx5124fmaps
d77de738 33404@need 200
d77de738 33405@opindex mavx512vnni
ddf6fe37 33406@itemx -mavx512vnni
d77de738 33407@need 200
d77de738 33408@opindex mavxvnni
ddf6fe37 33409@itemx -mavxvnni
d77de738 33410@need 200
d77de738 33411@opindex mavx5124vnniw
ddf6fe37 33412@itemx -mavx5124vnniw
d77de738 33413@need 200
d77de738 33414@opindex mcldemote
ddf6fe37 33415@itemx -mcldemote
d77de738 33416@need 200
d77de738 33417@opindex mserialize
ddf6fe37 33418@itemx -mserialize
d77de738 33419@need 200
d77de738 33420@opindex mamx-tile
ddf6fe37 33421@itemx -mamx-tile
d77de738 33422@need 200
d77de738 33423@opindex mamx-int8
ddf6fe37 33424@itemx -mamx-int8
d77de738 33425@need 200
d77de738 33426@opindex mamx-bf16
ddf6fe37 33427@itemx -mamx-bf16
d77de738 33428@need 200
d77de738 33429@opindex mhreset
d77de738 33430@opindex mkl
ddf6fe37
AA
33431@itemx -mhreset
33432@itemx -mkl
d77de738 33433@need 200
d77de738 33434@opindex mwidekl
ddf6fe37 33435@itemx -mwidekl
d77de738 33436@need 200
d77de738 33437@opindex mavxifma
ddf6fe37 33438@itemx -mavxifma
d77de738 33439@need 200
d77de738 33440@opindex mavxvnniint8
ddf6fe37 33441@itemx -mavxvnniint8
d77de738 33442@need 200
d77de738 33443@opindex mavxneconvert
ddf6fe37 33444@itemx -mavxneconvert
d77de738 33445@need 200
d77de738 33446@opindex mcmpccxadd
ddf6fe37 33447@itemx -mcmpccxadd
d77de738 33448@need 200
d77de738 33449@opindex mamx-fp16
ddf6fe37 33450@itemx -mamx-fp16
d77de738 33451@need 200
d77de738 33452@opindex mprefetchi
ddf6fe37 33453@itemx -mprefetchi
d77de738 33454@need 200
d77de738 33455@opindex mraoint
ddf6fe37 33456@itemx -mraoint
efa6a82b
HJ
33457@need 200
33458@opindex mamx-complex
33459@itemx -mamx-complex
d77de738
ML
33460These switches enable the use of instructions in the MMX, SSE,
33461SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
33462AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33463AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33464WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
334653DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33466XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33467GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33468ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
29ecb952 33469UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
efa6a82b
HJ
33470AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT,
33471AMX-COMPLEX or CLDEMOTE extended instruction sets. Each has a corresponding
33472@option{-mno-} option to disable use of these instructions.
d77de738
ML
33473
33474These extensions are also available as built-in functions: see
33475@ref{x86 Built-in Functions}, for details of the functions enabled and
33476disabled by these switches.
33477
33478To generate SSE/SSE2 instructions automatically from floating-point
33479code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33480
33481GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33482generates new AVX instructions or AVX equivalence for all SSEx instructions
33483when needed.
33484
33485These options enable GCC to use these extended instructions in
33486generated code, even without @option{-mfpmath=sse}. Applications that
33487perform run-time CPU detection must compile separate files for each
33488supported architecture, using the appropriate flags. In particular,
33489the file containing the CPU detection code should be compiled without
33490these options.
33491
d77de738 33492@opindex mdump-tune-features
ddf6fe37 33493@item -mdump-tune-features
d77de738
ML
33494This option instructs GCC to dump the names of the x86 performance
33495tuning features and default settings. The names can be used in
33496@option{-mtune-ctrl=@var{feature-list}}.
33497
d77de738 33498@opindex mtune-ctrl=@var{feature-list}
ddf6fe37 33499@item -mtune-ctrl=@var{feature-list}
d77de738
ML
33500This option is used to do fine grain control of x86 code generation features.
33501@var{feature-list} is a comma separated list of @var{feature} names. See also
33502@option{-mdump-tune-features}. When specified, the @var{feature} is turned
33503on if it is not preceded with @samp{^}, otherwise, it is turned off.
33504@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33505developers. Using it may lead to code paths not covered by testing and can
33506potentially result in compiler ICEs or runtime errors.
33507
d77de738 33508@opindex mno-default
ddf6fe37 33509@item -mno-default
d77de738
ML
33510This option instructs GCC to turn off all tunable features. See also
33511@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33512
d77de738 33513@opindex mcld
ddf6fe37 33514@item -mcld
d77de738
ML
33515This option instructs GCC to emit a @code{cld} instruction in the prologue
33516of functions that use string instructions. String instructions depend on
33517the DF flag to select between autoincrement or autodecrement mode. While the
33518ABI specifies the DF flag to be cleared on function entry, some operating
33519systems violate this specification by not clearing the DF flag in their
33520exception dispatchers. The exception handler can be invoked with the DF flag
33521set, which leads to wrong direction mode when string instructions are used.
33522This option can be enabled by default on 32-bit x86 targets by configuring
33523GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33524instructions can be suppressed with the @option{-mno-cld} compiler option
33525in this case.
33526
d77de738 33527@opindex mvzeroupper
ddf6fe37 33528@item -mvzeroupper
d77de738
ML
33529This option instructs GCC to emit a @code{vzeroupper} instruction
33530before a transfer of control flow out of the function to minimize
33531the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33532intrinsics.
33533
d77de738 33534@opindex mprefer-avx128
ddf6fe37 33535@item -mprefer-avx128
d77de738
ML
33536This option instructs GCC to use 128-bit AVX instructions instead of
33537256-bit AVX instructions in the auto-vectorizer.
33538
d77de738 33539@opindex mprefer-vector-width
ddf6fe37 33540@item -mprefer-vector-width=@var{opt}
d77de738
ML
33541This option instructs GCC to use @var{opt}-bit vector width in instructions
33542instead of default on the selected platform.
33543
d77de738 33544@opindex mmove-max
ddf6fe37 33545@item -mmove-max=@var{bits}
d77de738
ML
33546This option instructs GCC to set the maximum number of bits can be
33547moved from memory to memory efficiently to @var{bits}. The valid
33548@var{bits} are 128, 256 and 512.
33549
d77de738 33550@opindex mstore-max
ddf6fe37 33551@item -mstore-max=@var{bits}
d77de738
ML
33552This option instructs GCC to set the maximum number of bits can be
33553stored to memory efficiently to @var{bits}. The valid @var{bits} are
33554128, 256 and 512.
33555
33556@table @samp
33557@item none
33558No extra limitations applied to GCC other than defined by the selected platform.
33559
33560@item 128
33561Prefer 128-bit vector width for instructions.
33562
33563@item 256
33564Prefer 256-bit vector width for instructions.
33565
33566@item 512
33567Prefer 512-bit vector width for instructions.
33568@end table
33569
d77de738 33570@opindex mcx16
ddf6fe37 33571@item -mcx16
d77de738
ML
33572This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
33573code to implement compare-and-exchange operations on 16-byte aligned 128-bit
33574objects. This is useful for atomic updates of data structures exceeding one
33575machine word in size. The compiler uses this instruction to implement
33576@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
33577128-bit integers, a library call is always used.
33578
d77de738 33579@opindex msahf
ddf6fe37 33580@item -msahf
d77de738
ML
33581This option enables generation of @code{SAHF} instructions in 64-bit code.
33582Early Intel Pentium 4 CPUs with Intel 64 support,
33583prior to the introduction of Pentium 4 G1 step in December 2005,
33584lacked the @code{LAHF} and @code{SAHF} instructions
33585which are supported by AMD64.
33586These are load and store instructions, respectively, for certain status flags.
33587In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
33588@code{drem}, and @code{remainder} built-in functions;
33589see @ref{Other Builtins} for details.
33590
d77de738 33591@opindex mmovbe
ddf6fe37 33592@item -mmovbe
d77de738
ML
33593This option enables use of the @code{movbe} instruction to implement
33594@code{__builtin_bswap32} and @code{__builtin_bswap64}.
33595
d77de738 33596@opindex mshstk
ddf6fe37 33597@item -mshstk
d77de738
ML
33598The @option{-mshstk} option enables shadow stack built-in functions
33599from x86 Control-flow Enforcement Technology (CET).
33600
d77de738 33601@opindex mcrc32
ddf6fe37 33602@item -mcrc32
d77de738
ML
33603This option enables built-in functions @code{__builtin_ia32_crc32qi},
33604@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
33605@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
33606
d77de738 33607@opindex mmwait
ddf6fe37 33608@item -mmwait
d77de738
ML
33609This option enables built-in functions @code{__builtin_ia32_monitor},
33610and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
33611@code{mwait} machine instructions.
33612
d77de738 33613@opindex mrecip
ddf6fe37 33614@item -mrecip
d77de738
ML
33615This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
33616(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
33617with an additional Newton-Raphson step
33618to increase precision instead of @code{DIVSS} and @code{SQRTSS}
33619(and their vectorized
33620variants) for single-precision floating-point arguments. These instructions
33621are generated only when @option{-funsafe-math-optimizations} is enabled
33622together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
33623Note that while the throughput of the sequence is higher than the throughput
33624of the non-reciprocal instruction, the precision of the sequence can be
33625decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
33626
33627Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
33628(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
33629combination), and doesn't need @option{-mrecip}.
33630
33631Also note that GCC emits the above sequence with additional Newton-Raphson step
33632for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
33633already with @option{-ffast-math} (or the above option combination), and
33634doesn't need @option{-mrecip}.
33635
d77de738 33636@opindex mrecip=opt
ddf6fe37 33637@item -mrecip=@var{opt}
d77de738
ML
33638This option controls which reciprocal estimate instructions
33639may be used. @var{opt} is a comma-separated list of options, which may
33640be preceded by a @samp{!} to invert the option:
33641
33642@table @samp
33643@item all
33644Enable all estimate instructions.
33645
33646@item default
33647Enable the default instructions, equivalent to @option{-mrecip}.
33648
33649@item none
33650Disable all estimate instructions, equivalent to @option{-mno-recip}.
33651
33652@item div
33653Enable the approximation for scalar division.
33654
33655@item vec-div
33656Enable the approximation for vectorized division.
33657
33658@item sqrt
33659Enable the approximation for scalar square root.
33660
33661@item vec-sqrt
33662Enable the approximation for vectorized square root.
33663@end table
33664
33665So, for example, @option{-mrecip=all,!sqrt} enables
33666all of the reciprocal approximations, except for square root.
33667
d77de738 33668@opindex mveclibabi
ddf6fe37 33669@item -mveclibabi=@var{type}
d77de738
ML
33670Specifies the ABI type to use for vectorizing intrinsics using an
33671external library. Supported values for @var{type} are @samp{svml}
33672for the Intel short
33673vector math library and @samp{acml} for the AMD math core library.
33674To use this option, both @option{-ftree-vectorize} and
33675@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
33676ABI-compatible library must be specified at link time.
33677
33678GCC currently emits calls to @code{vmldExp2},
33679@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
33680@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
33681@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
33682@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
33683@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
33684@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
33685@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
33686@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
33687@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
33688function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
33689@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
33690@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
33691@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
33692@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
33693when @option{-mveclibabi=acml} is used.
33694
d77de738 33695@opindex mabi
ddf6fe37 33696@item -mabi=@var{name}
d77de738
ML
33697Generate code for the specified calling convention. Permissible values
33698are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
33699@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
33700ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
33701You can control this behavior for specific functions by
33702using the function attributes @code{ms_abi} and @code{sysv_abi}.
33703@xref{Function Attributes}.
33704
d77de738 33705@opindex mforce-indirect-call
ddf6fe37 33706@item -mforce-indirect-call
d77de738
ML
33707Force all calls to functions to be indirect. This is useful
33708when using Intel Processor Trace where it generates more precise timing
33709information for function calls.
33710
d77de738 33711@opindex mmanual-endbr
ddf6fe37 33712@item -mmanual-endbr
d77de738
ML
33713Insert ENDBR instruction at function entry only via the @code{cf_check}
33714function attribute. This is useful when used with the option
33715@option{-fcf-protection=branch} to control ENDBR insertion at the
33716function entry.
33717
d77de738 33718@opindex mcet-switch
ddf6fe37 33719@item -mcet-switch
d77de738
ML
33720By default, CET instrumentation is turned off on switch statements that
33721use a jump table and indirect branch track is disabled. Since jump
33722tables are stored in read-only memory, this does not result in a direct
33723loss of hardening. But if the jump table index is attacker-controlled,
33724the indirect jump may not be constrained by CET. This option turns on
33725CET instrumentation to enable indirect branch track for switch statements
33726with jump tables which leads to the jump targets reachable via any indirect
33727jumps.
33728
d77de738
ML
33729@opindex mcall-ms2sysv-xlogues
33730@opindex mno-call-ms2sysv-xlogues
ddf6fe37 33731@item -mcall-ms2sysv-xlogues
d77de738
ML
33732Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
33733System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
33734default, the code for saving and restoring these registers is emitted inline,
33735resulting in fairly lengthy prologues and epilogues. Using
33736@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
33737use stubs in the static portion of libgcc to perform these saves and restores,
33738thus reducing function size at the cost of a few extra instructions.
33739
d77de738 33740@opindex mtls-dialect
ddf6fe37 33741@item -mtls-dialect=@var{type}
d77de738
ML
33742Generate code to access thread-local storage using the @samp{gnu} or
33743@samp{gnu2} conventions. @samp{gnu} is the conservative default;
33744@samp{gnu2} is more efficient, but it may add compile- and run-time
33745requirements that cannot be satisfied on all systems.
33746
d77de738
ML
33747@opindex mpush-args
33748@opindex mno-push-args
ddf6fe37
AA
33749@item -mpush-args
33750@itemx -mno-push-args
d77de738
ML
33751Use PUSH operations to store outgoing parameters. This method is shorter
33752and usually equally fast as method using SUB/MOV operations and is enabled
33753by default. In some cases disabling it may improve performance because of
33754improved scheduling and reduced dependencies.
33755
d77de738 33756@opindex maccumulate-outgoing-args
ddf6fe37 33757@item -maccumulate-outgoing-args
d77de738
ML
33758If enabled, the maximum amount of space required for outgoing arguments is
33759computed in the function prologue. This is faster on most modern CPUs
33760because of reduced dependencies, improved scheduling and reduced stack usage
33761when the preferred stack boundary is not equal to 2. The drawback is a notable
33762increase in code size. This switch implies @option{-mno-push-args}.
33763
d77de738 33764@opindex mthreads
ddf6fe37 33765@item -mthreads
d77de738
ML
33766Support thread-safe exception handling on MinGW. Programs that rely
33767on thread-safe exception handling must compile and link all code with the
33768@option{-mthreads} option. When compiling, @option{-mthreads} defines
33769@option{-D_MT}; when linking, it links in a special thread helper library
33770@option{-lmingwthrd} which cleans up per-thread exception-handling data.
33771
d77de738
ML
33772@opindex mms-bitfields
33773@opindex mno-ms-bitfields
ddf6fe37
AA
33774@item -mms-bitfields
33775@itemx -mno-ms-bitfields
d77de738
ML
33776
33777Enable/disable bit-field layout compatible with the native Microsoft
33778Windows compiler.
33779
33780If @code{packed} is used on a structure, or if bit-fields are used,
33781it may be that the Microsoft ABI lays out the structure differently
33782than the way GCC normally does. Particularly when moving packed
33783data between functions compiled with GCC and the native Microsoft compiler
33784(either via function call or as data in a file), it may be necessary to access
33785either format.
33786
33787This option is enabled by default for Microsoft Windows
33788targets. This behavior can also be controlled locally by use of variable
33789or type attributes. For more information, see @ref{x86 Variable Attributes}
33790and @ref{x86 Type Attributes}.
33791
33792The Microsoft structure layout algorithm is fairly simple with the exception
33793of the bit-field packing.
33794The padding and alignment of members of structures and whether a bit-field
33795can straddle a storage-unit boundary are determine by these rules:
33796
33797@enumerate
33798@item Structure members are stored sequentially in the order in which they are
33799declared: the first member has the lowest memory address and the last member
33800the highest.
33801
33802@item Every data object has an alignment requirement. The alignment requirement
33803for all data except structures, unions, and arrays is either the size of the
33804object or the current packing size (specified with either the
33805@code{aligned} attribute or the @code{pack} pragma),
33806whichever is less. For structures, unions, and arrays,
33807the alignment requirement is the largest alignment requirement of its members.
33808Every object is allocated an offset so that:
33809
33810@smallexample
33811offset % alignment_requirement == 0
33812@end smallexample
33813
33814@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
33815unit if the integral types are the same size and if the next bit-field fits
33816into the current allocation unit without crossing the boundary imposed by the
33817common alignment requirements of the bit-fields.
33818@end enumerate
33819
33820MSVC interprets zero-length bit-fields in the following ways:
33821
33822@enumerate
33823@item If a zero-length bit-field is inserted between two bit-fields that
33824are normally coalesced, the bit-fields are not coalesced.
33825
33826For example:
33827
33828@smallexample
33829struct
33830 @{
33831 unsigned long bf_1 : 12;
33832 unsigned long : 0;
33833 unsigned long bf_2 : 12;
33834 @} t1;
33835@end smallexample
33836
33837@noindent
33838The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
33839zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
33840
33841@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
33842alignment of the zero-length bit-field is greater than the member that follows it,
33843@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
33844
33845For example:
33846
33847@smallexample
33848struct
33849 @{
33850 char foo : 4;
33851 short : 0;
33852 char bar;
33853 @} t2;
33854
33855struct
33856 @{
33857 char foo : 4;
33858 short : 0;
33859 double bar;
33860 @} t3;
33861@end smallexample
33862
33863@noindent
33864For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
33865Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
33866bit-field does not affect the alignment of @code{bar} or, as a result, the size
33867of the structure.
33868
33869Taking this into account, it is important to note the following:
33870
33871@enumerate
33872@item If a zero-length bit-field follows a normal bit-field, the type of the
33873zero-length bit-field may affect the alignment of the structure as whole. For
33874example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
33875normal bit-field, and is of type short.
33876
33877@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
33878still affect the alignment of the structure:
33879
33880@smallexample
33881struct
33882 @{
33883 char foo : 6;
33884 long : 0;
33885 @} t4;
33886@end smallexample
33887
33888@noindent
33889Here, @code{t4} takes up 4 bytes.
33890@end enumerate
33891
33892@item Zero-length bit-fields following non-bit-field members are ignored:
33893
33894@smallexample
33895struct
33896 @{
33897 char foo;
33898 long : 0;
33899 char bar;
33900 @} t5;
33901@end smallexample
33902
33903@noindent
33904Here, @code{t5} takes up 2 bytes.
33905@end enumerate
33906
33907
d77de738
ML
33908@opindex mno-align-stringops
33909@opindex malign-stringops
ddf6fe37 33910@item -mno-align-stringops
d77de738
ML
33911Do not align the destination of inlined string operations. This switch reduces
33912code size and improves performance in case the destination is already aligned,
33913but GCC doesn't know about it.
33914
d77de738 33915@opindex minline-all-stringops
ddf6fe37 33916@item -minline-all-stringops
d77de738
ML
33917By default GCC inlines string operations only when the destination is
33918known to be aligned to least a 4-byte boundary.
33919This enables more inlining and increases code
33920size, but may improve performance of code that depends on fast
33921@code{memcpy} and @code{memset} for short lengths.
33922The option enables inline expansion of @code{strlen} for all
33923pointer alignments.
33924
d77de738 33925@opindex minline-stringops-dynamically
ddf6fe37 33926@item -minline-stringops-dynamically
d77de738
ML
33927For string operations of unknown size, use run-time checks with
33928inline code for small blocks and a library call for large blocks.
33929
d77de738 33930@opindex mstringop-strategy=@var{alg}
ddf6fe37 33931@item -mstringop-strategy=@var{alg}
d77de738
ML
33932Override the internal decision heuristic for the particular algorithm to use
33933for inlining string operations. The allowed values for @var{alg} are:
33934
33935@table @samp
33936@item rep_byte
33937@itemx rep_4byte
33938@itemx rep_8byte
33939Expand using i386 @code{rep} prefix of the specified size.
33940
33941@item byte_loop
33942@itemx loop
33943@itemx unrolled_loop
33944Expand into an inline loop.
33945
33946@item libcall
33947Always use a library call.
33948@end table
33949
d77de738 33950@opindex mmemcpy-strategy=@var{strategy}
ddf6fe37 33951@item -mmemcpy-strategy=@var{strategy}
d77de738
ML
33952Override the internal decision heuristic to decide if @code{__builtin_memcpy}
33953should be inlined and what inline algorithm to use when the expected size
33954of the copy operation is known. @var{strategy}
33955is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
33956@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
33957the max byte size with which inline algorithm @var{alg} is allowed. For the last
33958triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
33959in the list must be specified in increasing order. The minimal byte size for
33960@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
33961preceding range.
33962
d77de738 33963@opindex mmemset-strategy=@var{strategy}
ddf6fe37 33964@item -mmemset-strategy=@var{strategy}
d77de738
ML
33965The option is similar to @option{-mmemcpy-strategy=} except that it is to control
33966@code{__builtin_memset} expansion.
33967
d77de738 33968@opindex momit-leaf-frame-pointer
ddf6fe37 33969@item -momit-leaf-frame-pointer
d77de738
ML
33970Don't keep the frame pointer in a register for leaf functions. This
33971avoids the instructions to save, set up, and restore frame pointers and
33972makes an extra register available in leaf functions. The option
33973@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
33974which might make debugging harder.
33975
ddf6fe37 33976@opindex mtls-direct-seg-refs
d77de738
ML
33977@item -mtls-direct-seg-refs
33978@itemx -mno-tls-direct-seg-refs
d77de738
ML
33979Controls whether TLS variables may be accessed with offsets from the
33980TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
33981or whether the thread base pointer must be added. Whether or not this
33982is valid depends on the operating system, and whether it maps the
33983segment to cover the entire TLS area.
33984
33985For systems that use the GNU C Library, the default is on.
33986
ddf6fe37 33987@opindex msse2avx
d77de738
ML
33988@item -msse2avx
33989@itemx -mno-sse2avx
d77de738
ML
33990Specify that the assembler should encode SSE instructions with VEX
33991prefix. The option @option{-mavx} turns this on by default.
33992
ddf6fe37 33993@opindex mfentry
d77de738
ML
33994@item -mfentry
33995@itemx -mno-fentry
d77de738
ML
33996If profiling is active (@option{-pg}), put the profiling
33997counter call before the prologue.
33998Note: On x86 architectures the attribute @code{ms_hook_prologue}
33999isn't possible at the moment for @option{-mfentry} and @option{-pg}.
34000
ddf6fe37 34001@opindex mrecord-mcount
d77de738
ML
34002@item -mrecord-mcount
34003@itemx -mno-record-mcount
d77de738
ML
34004If profiling is active (@option{-pg}), generate a __mcount_loc section
34005that contains pointers to each profiling call. This is useful for
34006automatically patching and out calls.
34007
ddf6fe37 34008@opindex mnop-mcount
d77de738
ML
34009@item -mnop-mcount
34010@itemx -mno-nop-mcount
d77de738
ML
34011If profiling is active (@option{-pg}), generate the calls to
34012the profiling functions as NOPs. This is useful when they
34013should be patched in later dynamically. This is likely only
34014useful together with @option{-mrecord-mcount}.
34015
d77de738 34016@opindex minstrument-return
ddf6fe37 34017@item -minstrument-return=@var{type}
d77de738
ML
34018Instrument function exit in -pg -mfentry instrumented functions with
34019call to specified function. This only instruments true returns ending
34020with ret, but not sibling calls ending with jump. Valid types
34021are @var{none} to not instrument, @var{call} to generate a call to __return__,
34022or @var{nop5} to generate a 5 byte nop.
34023
ddf6fe37 34024@opindex mrecord-return
d77de738
ML
34025@item -mrecord-return
34026@itemx -mno-record-return
d77de738
ML
34027Generate a __return_loc section pointing to all return instrumentation code.
34028
d77de738 34029@opindex mfentry-name
ddf6fe37 34030@item -mfentry-name=@var{name}
d77de738
ML
34031Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
34032
d77de738 34033@opindex mfentry-section
ddf6fe37 34034@item -mfentry-section=@var{name}
d77de738
ML
34035Set name of section to record -mrecord-mcount calls (default __mcount_loc).
34036
ddf6fe37 34037@opindex mskip-rax-setup
d77de738
ML
34038@item -mskip-rax-setup
34039@itemx -mno-skip-rax-setup
d77de738
ML
34040When generating code for the x86-64 architecture with SSE extensions
34041disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
34042register when there are no variable arguments passed in vector registers.
34043
34044@strong{Warning:} Since RAX register is used to avoid unnecessarily
34045saving vector registers on stack when passing variable arguments, the
34046impacts of this option are callees may waste some stack space,
34047misbehave or jump to a random location. GCC 4.4 or newer don't have
34048those issues, regardless the RAX register value.
34049
ddf6fe37 34050@opindex m8bit-idiv
d77de738
ML
34051@item -m8bit-idiv
34052@itemx -mno-8bit-idiv
d77de738
ML
34053On some processors, like Intel Atom, 8-bit unsigned integer divide is
34054much faster than 32-bit/64-bit integer divide. This option generates a
34055run-time check. If both dividend and divisor are within range of 0
34056to 255, 8-bit unsigned integer divide is used instead of
3405732-bit/64-bit integer divide.
34058
d77de738
ML
34059@opindex mavx256-split-unaligned-load
34060@opindex mavx256-split-unaligned-store
ddf6fe37
AA
34061@item -mavx256-split-unaligned-load
34062@itemx -mavx256-split-unaligned-store
d77de738
ML
34063Split 32-byte AVX unaligned load and store.
34064
d77de738
ML
34065@opindex mstack-protector-guard
34066@opindex mstack-protector-guard-reg
34067@opindex mstack-protector-guard-offset
ddf6fe37
AA
34068@item -mstack-protector-guard=@var{guard}
34069@itemx -mstack-protector-guard-reg=@var{reg}
34070@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
34071Generate stack protection code using canary at @var{guard}. Supported
34072locations are @samp{global} for global canary or @samp{tls} for per-thread
34073canary in the TLS block (the default). This option has effect only when
34074@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
34075
34076With the latter choice the options
34077@option{-mstack-protector-guard-reg=@var{reg}} and
34078@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
34079which segment register (@code{%fs} or @code{%gs}) to use as base register
34080for reading the canary, and from what offset from that base register.
34081The default for those is as specified in the relevant ABI.
34082
d77de738 34083@opindex mgeneral-regs-only
ddf6fe37 34084@item -mgeneral-regs-only
d77de738
ML
34085Generate code that uses only the general-purpose registers. This
34086prevents the compiler from using floating-point, vector, mask and bound
34087registers.
34088
d77de738 34089@opindex mrelax-cmpxchg-loop
ddf6fe37 34090@item -mrelax-cmpxchg-loop
85966f0d
AM
34091When emitting a compare-and-swap loop for @ref{__sync Builtins}
34092and @ref{__atomic Builtins} lacking a native instruction, optimize
34093for the highly contended case by issuing an atomic load before the
34094@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
34095to save CPU power when restarting the loop.
d77de738 34096
d77de738 34097@opindex mindirect-branch
ddf6fe37 34098@item -mindirect-branch=@var{choice}
d77de738
ML
34099Convert indirect call and jump with @var{choice}. The default is
34100@samp{keep}, which keeps indirect call and jump unmodified.
34101@samp{thunk} converts indirect call and jump to call and return thunk.
34102@samp{thunk-inline} converts indirect call and jump to inlined call
34103and return thunk. @samp{thunk-extern} converts indirect call and jump
34104to external call and return thunk provided in a separate object file.
34105You can control this behavior for a specific function by using the
34106function attribute @code{indirect_branch}. @xref{Function Attributes}.
34107
34108Note that @option{-mcmodel=large} is incompatible with
34109@option{-mindirect-branch=thunk} and
34110@option{-mindirect-branch=thunk-extern} since the thunk function may
34111not be reachable in the large code model.
34112
34113Note that @option{-mindirect-branch=thunk-extern} is compatible with
34114@option{-fcf-protection=branch} since the external thunk can be made
34115to enable control-flow check.
34116
d77de738 34117@opindex mfunction-return
ddf6fe37 34118@item -mfunction-return=@var{choice}
d77de738
ML
34119Convert function return with @var{choice}. The default is @samp{keep},
34120which keeps function return unmodified. @samp{thunk} converts function
34121return to call and return thunk. @samp{thunk-inline} converts function
34122return to inlined call and return thunk. @samp{thunk-extern} converts
34123function return to external call and return thunk provided in a separate
34124object file. You can control this behavior for a specific function by
34125using the function attribute @code{function_return}.
34126@xref{Function Attributes}.
34127
34128Note that @option{-mindirect-return=thunk-extern} is compatible with
34129@option{-fcf-protection=branch} since the external thunk can be made
34130to enable control-flow check.
34131
34132Note that @option{-mcmodel=large} is incompatible with
34133@option{-mfunction-return=thunk} and
34134@option{-mfunction-return=thunk-extern} since the thunk function may
34135not be reachable in the large code model.
34136
34137
d77de738 34138@opindex mindirect-branch-register
ddf6fe37 34139@item -mindirect-branch-register
d77de738
ML
34140Force indirect call and jump via register.
34141
d77de738 34142@opindex mharden-sls
ddf6fe37 34143@item -mharden-sls=@var{choice}
d77de738
ML
34144Generate code to mitigate against straight line speculation (SLS) with
34145@var{choice}. The default is @samp{none} which disables all SLS
34146hardening. @samp{return} enables SLS hardening for function returns.
34147@samp{indirect-jmp} enables SLS hardening for indirect jumps.
34148@samp{all} enables all SLS hardening.
34149
d77de738 34150@opindex mindirect-branch-cs-prefix
ddf6fe37 34151@item -mindirect-branch-cs-prefix
d77de738
ML
34152Add CS prefix to call and jmp to indirect thunk with branch target in
34153r8-r15 registers so that the call and jmp instruction length is 6 bytes
34154to allow them to be replaced with @samp{lfence; call *%r8-r15} or
34155@samp{lfence; jmp *%r8-r15} at run-time.
34156
34157@end table
34158
34159These @samp{-m} switches are supported in addition to the above
34160on x86-64 processors in 64-bit environments.
34161
34162@table @gcctabopt
d77de738
ML
34163@opindex m32
34164@opindex m64
34165@opindex mx32
34166@opindex m16
34167@opindex miamcu
ddf6fe37
AA
34168@item -m32
34169@itemx -m64
34170@itemx -mx32
34171@itemx -m16
34172@itemx -miamcu
d77de738
ML
34173Generate code for a 16-bit, 32-bit or 64-bit environment.
34174The @option{-m32} option sets @code{int}, @code{long}, and pointer types
34175to 32 bits, and
eeb92704 34176generates code that runs in 32-bit mode.
d77de738
ML
34177
34178The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
34179types to 64 bits, and generates code for the x86-64 architecture.
34180For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
34181and @option{-mdynamic-no-pic} options.
34182
34183The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
34184to 32 bits, and
34185generates code for the x86-64 architecture.
34186
34187The @option{-m16} option is the same as @option{-m32}, except for that
34188it outputs the @code{.code16gcc} assembly directive at the beginning of
34189the assembly output so that the binary can run in 16-bit mode.
34190
34191The @option{-miamcu} option generates code which conforms to Intel MCU
34192psABI. It requires the @option{-m32} option to be turned on.
34193
d77de738
ML
34194@opindex mno-red-zone
34195@opindex mred-zone
ddf6fe37 34196@item -mno-red-zone
d77de738
ML
34197Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
34198by the x86-64 ABI; it is a 128-byte area beyond the location of the
34199stack pointer that is not modified by signal or interrupt handlers
34200and therefore can be used for temporary data without adjusting the stack
34201pointer. The flag @option{-mno-red-zone} disables this red zone.
34202
d77de738 34203@opindex mcmodel=small
ddf6fe37 34204@item -mcmodel=small
d77de738
ML
34205Generate code for the small code model: the program and its symbols must
34206be linked in the lower 2 GB of the address space. Pointers are 64 bits.
34207Programs can be statically or dynamically linked. This is the default
34208code model.
34209
d77de738 34210@opindex mcmodel=kernel
ddf6fe37 34211@item -mcmodel=kernel
d77de738
ML
34212Generate code for the kernel code model. The kernel runs in the
34213negative 2 GB of the address space.
34214This model has to be used for Linux kernel code.
34215
d77de738 34216@opindex mcmodel=medium
ddf6fe37 34217@item -mcmodel=medium
d77de738
ML
34218Generate code for the medium model: the program is linked in the lower 2
34219GB of the address space. Small symbols are also placed there. Symbols
34220with sizes larger than @option{-mlarge-data-threshold} are put into
34221large data or BSS sections and can be located above 2GB. Programs can
34222be statically or dynamically linked.
34223
d77de738 34224@opindex mcmodel=large
ddf6fe37 34225@item -mcmodel=large
d77de738
ML
34226Generate code for the large model. This model makes no assumptions
34227about addresses and sizes of sections.
34228
d77de738 34229@opindex maddress-mode=long
ddf6fe37 34230@item -maddress-mode=long
d77de738
ML
34231Generate code for long address mode. This is only supported for 64-bit
34232and x32 environments. It is the default address mode for 64-bit
34233environments.
34234
d77de738 34235@opindex maddress-mode=short
ddf6fe37 34236@item -maddress-mode=short
d77de738
ML
34237Generate code for short address mode. This is only supported for 32-bit
34238and x32 environments. It is the default address mode for 32-bit and
34239x32 environments.
34240
ddf6fe37 34241@opindex mneeded
d77de738
ML
34242@item -mneeded
34243@itemx -mno-needed
d77de738
ML
34244Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
34245indicate the micro-architecture ISA level required to execute the binary.
34246
d77de738
ML
34247@opindex mno-direct-extern-access
34248@opindex mdirect-extern-access
ddf6fe37 34249@item -mno-direct-extern-access
d77de738
ML
34250Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
34251to access external symbols. With @option{-fpic} or @option{-fPIC},
34252treat access to protected symbols as local symbols. The default is
34253@option{-mdirect-extern-access}.
34254
34255@strong{Warning:} shared libraries compiled with
34256@option{-mno-direct-extern-access} and executable compiled with
34257@option{-mdirect-extern-access} may not be binary compatible if
34258protected symbols are used in shared libraries and executable.
ce51e843 34259
ce51e843
ML
34260@opindex munroll-only-small-loops
34261@opindex mno-unroll-only-small-loops
ddf6fe37 34262@item -munroll-only-small-loops
ce51e843
ML
34263Controls conservative small loop unrolling. It is default enabled by
34264O2, and unrolls loop with less than 4 insns by 1 time. Explicit
34265-f[no-]unroll-[all-]loops would disable this flag to avoid any
34266unintended unrolling behavior that user does not want.
bb576017 34267
bb576017 34268@opindex mlam
ddf6fe37 34269@item -mlam=@var{choice}
bb576017 34270LAM(linear-address masking) allows special bits in the pointer to be used
34271for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
34272positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
34273positions 62:57 can be used for metadata.
d77de738
ML
34274@end table
34275
34276@node x86 Windows Options
34277@subsection x86 Windows Options
34278@cindex x86 Windows Options
34279@cindex Windows Options for x86
34280
34281These additional options are available for Microsoft Windows targets:
34282
34283@table @gcctabopt
d77de738 34284@opindex mconsole
ddf6fe37 34285@item -mconsole
d77de738
ML
34286This option
34287specifies that a console application is to be generated, by
34288instructing the linker to set the PE header subsystem type
34289required for console applications.
34290This option is available for Cygwin and MinGW targets and is
34291enabled by default on those targets.
34292
d77de738 34293@opindex mdll
ddf6fe37 34294@item -mdll
d77de738
ML
34295This option is available for Cygwin and MinGW targets. It
34296specifies that a DLL---a dynamic link library---is to be
34297generated, enabling the selection of the required runtime
34298startup object and entry point.
34299
d77de738 34300@opindex mnop-fun-dllimport
ddf6fe37 34301@item -mnop-fun-dllimport
d77de738
ML
34302This option is available for Cygwin and MinGW targets. It
34303specifies that the @code{dllimport} attribute should be ignored.
34304
d77de738 34305@opindex mthreads
ddf6fe37 34306@item -mthreads
d77de738
ML
34307This option is available for MinGW targets. It specifies
34308that MinGW-specific thread support is to be used.
34309
d77de738 34310@opindex municode
ddf6fe37 34311@item -municode
d77de738
ML
34312This option is available for MinGW-w64 targets. It causes
34313the @code{UNICODE} preprocessor macro to be predefined, and
34314chooses Unicode-capable runtime startup code.
34315
d77de738 34316@opindex mwin32
ddf6fe37 34317@item -mwin32
d77de738
ML
34318This option is available for Cygwin and MinGW targets. It
34319specifies that the typical Microsoft Windows predefined macros are to
34320be set in the pre-processor, but does not influence the choice
34321of runtime library/startup code.
34322
d77de738 34323@opindex mwindows
ddf6fe37 34324@item -mwindows
d77de738
ML
34325This option is available for Cygwin and MinGW targets. It
34326specifies that a GUI application is to be generated by
34327instructing the linker to set the PE header subsystem type
34328appropriately.
34329
d77de738
ML
34330@opindex fno-set-stack-executable
34331@opindex fset-stack-executable
ddf6fe37 34332@item -fno-set-stack-executable
d77de738
ML
34333This option is available for MinGW targets. It specifies that
34334the executable flag for the stack used by nested functions isn't
34335set. This is necessary for binaries running in kernel mode of
34336Microsoft Windows, as there the User32 API, which is used to set executable
34337privileges, isn't available.
34338
d77de738
ML
34339@opindex fno-writable-relocated-rdata
34340@opindex fwritable-relocated-rdata
ddf6fe37 34341@item -fwritable-relocated-rdata
d77de738
ML
34342This option is available for MinGW and Cygwin targets. It specifies
34343that relocated-data in read-only section is put into the @code{.data}
34344section. This is a necessary for older runtimes not supporting
34345modification of @code{.rdata} sections for pseudo-relocation.
34346
d77de738 34347@opindex mpe-aligned-commons
ddf6fe37 34348@item -mpe-aligned-commons
d77de738
ML
34349This option is available for Cygwin and MinGW targets. It
34350specifies that the GNU extension to the PE file format that
34351permits the correct alignment of COMMON variables should be
34352used when generating code. It is enabled by default if
34353GCC detects that the target assembler found during configuration
34354supports the feature.
34355@end table
34356
34357See also under @ref{x86 Options} for standard options.
34358
34359@node Xstormy16 Options
34360@subsection Xstormy16 Options
34361@cindex Xstormy16 Options
34362
34363These options are defined for Xstormy16:
34364
34365@table @gcctabopt
d77de738 34366@opindex msim
ddf6fe37 34367@item -msim
d77de738
ML
34368Choose startup files and linker script suitable for the simulator.
34369@end table
34370
34371@node Xtensa Options
34372@subsection Xtensa Options
34373@cindex Xtensa Options
34374
34375These options are supported for Xtensa targets:
34376
34377@table @gcctabopt
d77de738
ML
34378@opindex mconst16
34379@opindex mno-const16
ddf6fe37
AA
34380@item -mconst16
34381@itemx -mno-const16
d77de738
ML
34382Enable or disable use of @code{CONST16} instructions for loading
34383constant values. The @code{CONST16} instruction is currently not a
34384standard option from Tensilica. When enabled, @code{CONST16}
34385instructions are always used in place of the standard @code{L32R}
34386instructions. The use of @code{CONST16} is enabled by default only if
34387the @code{L32R} instruction is not available.
34388
d77de738
ML
34389@opindex mfused-madd
34390@opindex mno-fused-madd
ddf6fe37
AA
34391@item -mfused-madd
34392@itemx -mno-fused-madd
d77de738
ML
34393Enable or disable use of fused multiply/add and multiply/subtract
34394instructions in the floating-point option. This has no effect if the
34395floating-point option is not also enabled. Disabling fused multiply/add
34396and multiply/subtract instructions forces the compiler to use separate
34397instructions for the multiply and add/subtract operations. This may be
34398desirable in some cases where strict IEEE 754-compliant results are
34399required: the fused multiply add/subtract instructions do not round the
34400intermediate result, thereby producing results with @emph{more} bits of
34401precision than specified by the IEEE standard. Disabling fused multiply
34402add/subtract instructions also ensures that the program output is not
34403sensitive to the compiler's ability to combine multiply and add/subtract
34404operations.
34405
d77de738
ML
34406@opindex mserialize-volatile
34407@opindex mno-serialize-volatile
ddf6fe37
AA
34408@item -mserialize-volatile
34409@itemx -mno-serialize-volatile
d77de738
ML
34410When this option is enabled, GCC inserts @code{MEMW} instructions before
34411@code{volatile} memory references to guarantee sequential consistency.
34412The default is @option{-mserialize-volatile}. Use
34413@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
34414
d77de738 34415@opindex mforce-no-pic
ddf6fe37 34416@item -mforce-no-pic
d77de738
ML
34417For targets, like GNU/Linux, where all user-mode Xtensa code must be
34418position-independent code (PIC), this option disables PIC for compiling
34419kernel code.
34420
d77de738
ML
34421@opindex mtext-section-literals
34422@opindex mno-text-section-literals
ddf6fe37
AA
34423@item -mtext-section-literals
34424@itemx -mno-text-section-literals
d77de738
ML
34425These options control the treatment of literal pools. The default is
34426@option{-mno-text-section-literals}, which places literals in a separate
34427section in the output file. This allows the literal pool to be placed
34428in a data RAM/ROM, and it also allows the linker to combine literal
34429pools from separate object files to remove redundant literals and
34430improve code size. With @option{-mtext-section-literals}, the literals
34431are interspersed in the text section in order to keep them as close as
34432possible to their references. This may be necessary for large assembly
34433files. Literals for each function are placed right before that function.
34434
d77de738
ML
34435@opindex mauto-litpools
34436@opindex mno-auto-litpools
ddf6fe37
AA
34437@item -mauto-litpools
34438@itemx -mno-auto-litpools
d77de738
ML
34439These options control the treatment of literal pools. The default is
34440@option{-mno-auto-litpools}, which places literals in a separate
34441section in the output file unless @option{-mtext-section-literals} is
34442used. With @option{-mauto-litpools} the literals are interspersed in
34443the text section by the assembler. Compiler does not produce explicit
34444@code{.literal} directives and loads literals into registers with
34445@code{MOVI} instructions instead of @code{L32R} to let the assembler
34446do relaxation and place literals as necessary. This option allows
34447assembler to create several literal pools per function and assemble
34448very big functions, which may not be possible with
34449@option{-mtext-section-literals}.
34450
d77de738
ML
34451@opindex mtarget-align
34452@opindex mno-target-align
ddf6fe37
AA
34453@item -mtarget-align
34454@itemx -mno-target-align
d77de738
ML
34455When this option is enabled, GCC instructs the assembler to
34456automatically align instructions to reduce branch penalties at the
34457expense of some code density. The assembler attempts to widen density
34458instructions to align branch targets and the instructions following call
34459instructions. If there are not enough preceding safe density
34460instructions to align a target, no widening is performed. The
34461default is @option{-mtarget-align}. These options do not affect the
34462treatment of auto-aligned instructions like @code{LOOP}, which the
34463assembler always aligns, either by widening density instructions or
34464by inserting NOP instructions.
34465
d77de738
ML
34466@opindex mlongcalls
34467@opindex mno-longcalls
ddf6fe37
AA
34468@item -mlongcalls
34469@itemx -mno-longcalls
d77de738
ML
34470When this option is enabled, GCC instructs the assembler to translate
34471direct calls to indirect calls unless it can determine that the target
34472of a direct call is in the range allowed by the call instruction. This
34473translation typically occurs for calls to functions in other source
34474files. Specifically, the assembler translates a direct @code{CALL}
34475instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34476The default is @option{-mno-longcalls}. This option should be used in
34477programs where the call target can potentially be out of range. This
34478option is implemented in the assembler, not the compiler, so the
34479assembly code generated by GCC still shows direct call
34480instructions---look at the disassembled object code to see the actual
34481instructions. Note that the assembler uses an indirect call for
34482every cross-file call, not just those that really are out of range.
34483
d77de738 34484@opindex mabi
ddf6fe37 34485@item -mabi=@var{name}
d77de738
ML
34486Generate code for the specified ABI@. Permissible values are: @samp{call0},
34487@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34488
d77de738 34489@opindex mabi=call0
ddf6fe37 34490@item -mabi=call0
d77de738
ML
34491When this option is enabled function parameters are passed in registers
34492@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34493caller-saved, and register @code{a15} may be used as a frame pointer.
34494When this version of the ABI is enabled the C preprocessor symbol
34495@code{__XTENSA_CALL0_ABI__} is defined.
34496
d77de738 34497@opindex mabi=windowed
ddf6fe37 34498@item -mabi=windowed
d77de738
ML
34499When this option is enabled function parameters are passed in registers
34500@code{a10} through @code{a15}, and called function rotates register window
34501by 8 registers on entry so that its arguments are found in registers
34502@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34503pointer. Register window is rotated 8 registers back upon return.
34504When this version of the ABI is enabled the C preprocessor symbol
34505@code{__XTENSA_WINDOWED_ABI__} is defined.
34506
d77de738 34507@opindex mextra-l32r-costs
ddf6fe37 34508@item -mextra-l32r-costs=@var{n}
d77de738
ML
34509Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34510instructions, in clock cycles. This affects, when optimizing for speed,
34511whether loading a constant from literal pool using @code{L32R} or
34512synthesizing the constant from a small one with a couple of arithmetic
34513instructions. The default value is 0.
675b390e
MF
34514
34515@opindex mstrict-align
34516@opindex mno-strict-align
34517@item -mstrict-align
34518@itemx -mno-strict-align
34519Avoid or allow generating memory accesses that may not be aligned on a natural
34520object boundary as described in the architecture specification.
34521The default is @option{-mno-strict-align} for cores that support both
34522unaligned loads and stores in hardware and @option{-mstrict-align} for all
34523other cores.
34524
d77de738
ML
34525@end table
34526
34527@node zSeries Options
34528@subsection zSeries Options
34529@cindex zSeries options
34530
34531These are listed under @xref{S/390 and zSeries Options}.
34532
34533
34534@c man end
34535
34536@node Spec Files
34537@section Specifying Subprocesses and the Switches to Pass to Them
34538@cindex Spec Files
34539
34540@command{gcc} is a driver program. It performs its job by invoking a
34541sequence of other programs to do the work of compiling, assembling and
34542linking. GCC interprets its command-line parameters and uses these to
34543deduce which programs it should invoke, and which command-line options
34544it ought to place on their command lines. This behavior is controlled
34545by @dfn{spec strings}. In most cases there is one spec string for each
34546program that GCC can invoke, but a few programs have multiple spec
34547strings to control their behavior. The spec strings built into GCC can
34548be overridden by using the @option{-specs=} command-line switch to specify
34549a spec file.
34550
34551@dfn{Spec files} are plain-text files that are used to construct spec
34552strings. They consist of a sequence of directives separated by blank
34553lines. The type of directive is determined by the first non-whitespace
34554character on the line, which can be one of the following:
34555
34556@table @code
34557@item %@var{command}
34558Issues a @var{command} to the spec file processor. The commands that can
34559appear here are:
34560
34561@table @code
d77de738 34562@cindex @code{%include}
f33d7a88 34563@item %include <@var{file}>
d77de738
ML
34564Search for @var{file} and insert its text at the current point in the
34565specs file.
34566
d77de738 34567@cindex @code{%include_noerr}
f33d7a88 34568@item %include_noerr <@var{file}>
d77de738
ML
34569Just like @samp{%include}, but do not generate an error message if the include
34570file cannot be found.
34571
d77de738 34572@cindex @code{%rename}
f33d7a88 34573@item %rename @var{old_name} @var{new_name}
d77de738
ML
34574Rename the spec string @var{old_name} to @var{new_name}.
34575
34576@end table
34577
34578@item *[@var{spec_name}]:
34579This tells the compiler to create, override or delete the named spec
34580string. All lines after this directive up to the next directive or
34581blank line are considered to be the text for the spec string. If this
34582results in an empty string then the spec is deleted. (Or, if the
34583spec did not exist, then nothing happens.) Otherwise, if the spec
34584does not currently exist a new spec is created. If the spec does
34585exist then its contents are overridden by the text of this
34586directive, unless the first character of that text is the @samp{+}
34587character, in which case the text is appended to the spec.
34588
34589@item [@var{suffix}]:
34590Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
34591and up to the next directive or blank line are considered to make up the
34592spec string for the indicated suffix. When the compiler encounters an
34593input file with the named suffix, it processes the spec string in
34594order to work out how to compile that file. For example:
34595
34596@smallexample
34597.ZZ:
34598z-compile -input %i
34599@end smallexample
34600
34601This says that any input file whose name ends in @samp{.ZZ} should be
34602passed to the program @samp{z-compile}, which should be invoked with the
34603command-line switch @option{-input} and with the result of performing the
34604@samp{%i} substitution. (See below.)
34605
34606As an alternative to providing a spec string, the text following a
34607suffix directive can be one of the following:
34608
34609@table @code
34610@item @@@var{language}
34611This says that the suffix is an alias for a known @var{language}. This is
34612similar to using the @option{-x} command-line switch to GCC to specify a
34613language explicitly. For example:
34614
34615@smallexample
34616.ZZ:
34617@@c++
34618@end smallexample
34619
34620Says that .ZZ files are, in fact, C++ source files.
34621
34622@item #@var{name}
34623This causes an error messages saying:
34624
34625@smallexample
34626@var{name} compiler not installed on this system.
34627@end smallexample
34628@end table
34629
34630GCC already has an extensive list of suffixes built into it.
34631This directive adds an entry to the end of the list of suffixes, but
34632since the list is searched from the end backwards, it is effectively
34633possible to override earlier entries using this technique.
34634
34635@end table
34636
34637GCC has the following spec strings built into it. Spec files can
34638override these strings or create their own. Note that individual
34639targets can also add their own spec strings to this list.
34640
34641@smallexample
34642asm Options to pass to the assembler
34643asm_final Options to pass to the assembler post-processor
34644cpp Options to pass to the C preprocessor
34645cc1 Options to pass to the C compiler
34646cc1plus Options to pass to the C++ compiler
34647endfile Object files to include at the end of the link
34648link Options to pass to the linker
34649lib Libraries to include on the command line to the linker
34650libgcc Decides which GCC support library to pass to the linker
34651linker Sets the name of the linker
34652predefines Defines to be passed to the C preprocessor
34653signed_char Defines to pass to CPP to say whether @code{char} is signed
34654 by default
34655startfile Object files to include at the start of the link
34656@end smallexample
34657
34658Here is a small example of a spec file:
34659
34660@smallexample
34661%rename lib old_lib
34662
34663*lib:
34664--start-group -lgcc -lc -leval1 --end-group %(old_lib)
34665@end smallexample
34666
34667This example renames the spec called @samp{lib} to @samp{old_lib} and
34668then overrides the previous definition of @samp{lib} with a new one.
34669The new definition adds in some extra command-line options before
34670including the text of the old definition.
34671
34672@dfn{Spec strings} are a list of command-line options to be passed to their
34673corresponding program. In addition, the spec strings can contain
34674@samp{%}-prefixed sequences to substitute variable text or to
34675conditionally insert text into the command line. Using these constructs
34676it is possible to generate quite complex command lines.
34677
34678Here is a table of all defined @samp{%}-sequences for spec
34679strings. Note that spaces are not generated automatically around the
34680results of expanding these sequences. Therefore you can concatenate them
34681together or combine them with constant text in a single argument.
34682
34683@table @code
34684@item %%
34685Substitute one @samp{%} into the program name or argument.
34686
34687@item %"
34688Substitute an empty argument.
34689
34690@item %i
34691Substitute the name of the input file being processed.
34692
34693@item %b
34694Substitute the basename for outputs related with the input file being
34695processed. This is often the substring up to (and not including) the
34696last period and not including the directory but, unless %w is active, it
34697expands to the basename for auxiliary outputs, which may be influenced
34698by an explicit output name, and by various other options that control
34699how auxiliary outputs are named.
34700
34701@item %B
34702This is the same as @samp{%b}, but include the file suffix (text after
34703the last period). Without %w, it expands to the basename for dump
34704outputs.
34705
34706@item %d
34707Marks the argument containing or following the @samp{%d} as a
34708temporary file name, so that that file is deleted if GCC exits
34709successfully. Unlike @samp{%g}, this contributes no text to the
34710argument.
34711
34712@item %g@var{suffix}
34713Substitute a file name that has suffix @var{suffix} and is chosen
34714once per compilation, and mark the argument in the same way as
34715@samp{%d}. To reduce exposure to denial-of-service attacks, the file
34716name is now chosen in a way that is hard to predict even when previously
34717chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
34718might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
34719the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
34720treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
34721was simply substituted with a file name chosen once per compilation,
34722without regard to any appended suffix (which was therefore treated
34723just like ordinary text), making such attacks more likely to succeed.
34724
34725@item %u@var{suffix}
34726Like @samp{%g}, but generates a new temporary file name
34727each time it appears instead of once per compilation.
34728
34729@item %U@var{suffix}
34730Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
34731new one if there is no such last file name. In the absence of any
34732@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
34733the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
34734involves the generation of two distinct file names, one
34735for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
34736simply substituted with a file name chosen for the previous @samp{%u},
34737without regard to any appended suffix.
34738
34739@item %j@var{suffix}
34740Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
34741writable, and if @option{-save-temps} is not used;
34742otherwise, substitute the name
34743of a temporary file, just like @samp{%u}. This temporary file is not
34744meant for communication between processes, but rather as a junk
34745disposal mechanism.
34746
34747@item %|@var{suffix}
34748@itemx %m@var{suffix}
34749Like @samp{%g}, except if @option{-pipe} is in effect. In that case
34750@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
34751all. These are the two most common ways to instruct a program that it
34752should read from standard input or write to standard output. If you
34753need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
34754construct: see for example @file{gcc/fortran/lang-specs.h}.
34755
34756@item %.@var{SUFFIX}
34757Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
34758when it is subsequently output with @samp{%*}. @var{SUFFIX} is
34759terminated by the next space or %.
34760
34761@item %w
34762Marks the argument containing or following the @samp{%w} as the
34763designated output file of this compilation. This puts the argument
34764into the sequence of arguments that @samp{%o} substitutes.
34765
34766@item %V
34767Indicates that this compilation produces no output file.
34768
34769@item %o
34770Substitutes the names of all the output files, with spaces
34771automatically placed around them. You should write spaces
34772around the @samp{%o} as well or the results are undefined.
34773@samp{%o} is for use in the specs for running the linker.
34774Input files whose names have no recognized suffix are not compiled
34775at all, but they are included among the output files, so they are
34776linked.
34777
34778@item %O
34779Substitutes the suffix for object files. Note that this is
34780handled specially when it immediately follows @samp{%g, %u, or %U},
34781because of the need for those to form complete file names. The
34782handling is such that @samp{%O} is treated exactly as if it had already
34783been substituted, except that @samp{%g, %u, and %U} do not currently
34784support additional @var{suffix} characters following @samp{%O} as they do
34785following, for example, @samp{.o}.
34786
34787@item %I
34788Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
34789@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
34790@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
34791and @option{-imultilib} as necessary.
34792
34793@item %s
34794Current argument is the name of a library or startup file of some sort.
34795Search for that file in a standard list of directories and substitute
34796the full name found. The current working directory is included in the
34797list of directories scanned.
34798
34799@item %T
34800Current argument is the name of a linker script. Search for that file
34801in the current list of directories to scan for libraries. If the file
34802is located insert a @option{--script} option into the command line
34803followed by the full path name found. If the file is not found then
34804generate an error message. Note: the current working directory is not
34805searched.
34806
34807@item %e@var{str}
34808Print @var{str} as an error message. @var{str} is terminated by a newline.
34809Use this when inconsistent options are detected.
34810
34811@item %n@var{str}
34812Print @var{str} as a notice. @var{str} is terminated by a newline.
34813
34814@item %(@var{name})
34815Substitute the contents of spec string @var{name} at this point.
34816
34817@item %x@{@var{option}@}
34818Accumulate an option for @samp{%X}.
34819
34820@item %X
34821Output the accumulated linker options specified by a @samp{%x} spec string.
34822
34823@item %Y
34824Output the accumulated assembler options specified by @option{-Wa}.
34825
34826@item %Z
34827Output the accumulated preprocessor options specified by @option{-Wp}.
34828
34829@item %M
34830Output @code{multilib_os_dir}.
34831
34832@item %R
34833Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
34834
34835@item %a
34836Process the @code{asm} spec. This is used to compute the
34837switches to be passed to the assembler.
34838
34839@item %A
34840Process the @code{asm_final} spec. This is a spec string for
34841passing switches to an assembler post-processor, if such a program is
34842needed.
34843
34844@item %l
34845Process the @code{link} spec. This is the spec for computing the
34846command line passed to the linker. Typically it makes use of the
34847@samp{%L %G %S %D and %E} sequences.
34848
34849@item %D
34850Dump out a @option{-L} option for each directory that GCC believes might
34851contain startup files. If the target supports multilibs then the
34852current multilib directory is prepended to each of these paths.
34853
34854@item %L
34855Process the @code{lib} spec. This is a spec string for deciding which
34856libraries are included on the command line to the linker.
34857
34858@item %G
34859Process the @code{libgcc} spec. This is a spec string for deciding
34860which GCC support library is included on the command line to the linker.
34861
34862@item %S
34863Process the @code{startfile} spec. This is a spec for deciding which
34864object files are the first ones passed to the linker. Typically
34865this might be a file named @file{crt0.o}.
34866
34867@item %E
34868Process the @code{endfile} spec. This is a spec string that specifies
34869the last object files that are passed to the linker.
34870
34871@item %C
34872Process the @code{cpp} spec. This is used to construct the arguments
34873to be passed to the C preprocessor.
34874
34875@item %1
34876Process the @code{cc1} spec. This is used to construct the options to be
34877passed to the actual C compiler (@command{cc1}).
34878
34879@item %2
34880Process the @code{cc1plus} spec. This is used to construct the options to be
34881passed to the actual C++ compiler (@command{cc1plus}).
34882
34883@item %*
34884Substitute the variable part of a matched option. See below.
34885Note that each comma in the substituted string is replaced by
34886a single space.
34887
34888@item %<S
34889Remove all occurrences of @code{-S} from the command line. Note---this
34890command is position dependent. @samp{%} commands in the spec string
34891before this one see @code{-S}, @samp{%} commands in the spec string
34892after this one do not.
34893
34894@item %<S*
34895Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
34896
34897@item %>S
34898Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
34899
34900@item %:@var{function}(@var{args})
34901Call the named function @var{function}, passing it @var{args}.
34902@var{args} is first processed as a nested spec string, then split
34903into an argument vector in the usual fashion. The function returns
34904a string which is processed as if it had appeared literally as part
34905of the current spec.
34906
34907The following built-in spec functions are provided:
34908
34909@table @code
34910@item @code{getenv}
34911The @code{getenv} spec function takes two arguments: an environment
34912variable name and a string. If the environment variable is not
34913defined, a fatal error is issued. Otherwise, the return value is the
34914value of the environment variable concatenated with the string. For
34915example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
34916
34917@smallexample
34918%:getenv(TOPDIR /include)
34919@end smallexample
34920
34921expands to @file{/path/to/top/include}.
34922
34923@item @code{if-exists}
34924The @code{if-exists} spec function takes one argument, an absolute
34925pathname to a file. If the file exists, @code{if-exists} returns the
34926pathname. Here is a small example of its usage:
34927
34928@smallexample
34929*startfile:
34930crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
34931@end smallexample
34932
34933@item @code{if-exists-else}
34934The @code{if-exists-else} spec function is similar to the @code{if-exists}
34935spec function, except that it takes two arguments. The first argument is
34936an absolute pathname to a file. If the file exists, @code{if-exists-else}
34937returns the pathname. If it does not exist, it returns the second argument.
34938This way, @code{if-exists-else} can be used to select one file or another,
34939based on the existence of the first. Here is a small example of its usage:
34940
34941@smallexample
34942*startfile:
34943crt0%O%s %:if-exists(crti%O%s) \
34944%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
34945@end smallexample
34946
34947@item @code{if-exists-then-else}
34948The @code{if-exists-then-else} spec function takes at least two arguments
34949and an optional third one. The first argument is an absolute pathname to a
34950file. If the file exists, the function returns the second argument.
34951If the file does not exist, the function returns the third argument if there
34952is one, or NULL otherwise. This can be used to expand one text, or optionally
34953another, based on the existence of a file. Here is a small example of its
34954usage:
34955
34956@smallexample
34957-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
34958@end smallexample
34959
34960@item @code{sanitize}
34961The @code{sanitize} spec function takes no arguments. It returns non-NULL if
34962any address, thread or undefined behavior sanitizers are active.
34963
34964@smallexample
34965%@{%:sanitize(address):-funwind-tables@}
34966@end smallexample
34967
34968@item @code{replace-outfile}
34969The @code{replace-outfile} spec function takes two arguments. It looks for the
34970first argument in the outfiles array and replaces it with the second argument. Here
34971is a small example of its usage:
34972
34973@smallexample
34974%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
34975@end smallexample
34976
34977@item @code{remove-outfile}
34978The @code{remove-outfile} spec function takes one argument. It looks for the
34979first argument in the outfiles array and removes it. Here is a small example
34980its usage:
34981
34982@smallexample
34983%:remove-outfile(-lm)
34984@end smallexample
34985
34986@item @code{version-compare}
34987The @code{version-compare} spec function takes four or five arguments of the following
34988form:
34989
34990@smallexample
34991<comparison-op> <arg1> [<arg2>] <switch> <result>
34992@end smallexample
34993
34994It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
34995The supported @code{comparison-op} values are:
34996
34997@table @code
34998@item >=
34999True if @code{switch} is a later (or same) version than @code{arg1}
35000
35001@item !>
35002Opposite of @code{>=}
35003
35004@item <
35005True if @code{switch} is an earlier version than @code{arg1}
35006
35007@item !<
35008Opposite of @code{<}
35009
35010@item ><
35011True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
35012
35013@item <>
35014True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
35015@end table
35016
35017If the @code{switch} is not present at all, the condition is false unless the first character
35018of the @code{comparison-op} is @code{!}.
35019
35020@smallexample
35021%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
35022@end smallexample
35023
35024The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
35025passed.
35026
35027@item @code{include}
35028The @code{include} spec function behaves much like @code{%include}, with the advantage
35029that it can be nested inside a spec and thus be conditionalized. It takes one argument,
35030the filename, and looks for it in the startfile path. It always returns NULL.
35031
35032@smallexample
35033%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
35034@end smallexample
35035
35036@item @code{pass-through-libs}
35037The @code{pass-through-libs} spec function takes any number of arguments. It
35038finds any @option{-l} options and any non-options ending in @file{.a} (which it
35039assumes are the names of linker input library archive files) and returns a
35040result containing all the found arguments each prepended by
35041@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
35042intended to be passed to the LTO linker plugin.
35043
35044@smallexample
35045%:pass-through-libs(%G %L %G)
35046@end smallexample
35047
35048@item @code{print-asm-header}
35049The @code{print-asm-header} function takes no arguments and simply
35050prints a banner like:
35051
35052@smallexample
35053Assembler options
35054=================
35055
35056Use "-Wa,OPTION" to pass "OPTION" to the assembler.
35057@end smallexample
35058
35059It is used to separate compiler options from assembler options
35060in the @option{--target-help} output.
35061
35062@item @code{gt}
35063The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
35064empty string) if the second-to-last argument is greater than the last argument, and NULL
35065otherwise. The following example inserts the @code{link_gomp} spec if the last
35066@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
35067
35068@smallexample
35069%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
35070@end smallexample
35071
35072@item @code{debug-level-gt}
35073The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
35074empty string) if @code{debug_info_level} is greater than the specified number, and NULL
35075otherwise.
35076
35077@smallexample
35078%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
35079@end smallexample
35080@end table
35081
35082@item %@{S@}
35083Substitutes the @code{-S} switch, if that switch is given to GCC@.
35084If that switch is not specified, this substitutes nothing. Note that
35085the leading dash is omitted when specifying this option, and it is
35086automatically inserted if the substitution is performed. Thus the spec
35087string @samp{%@{foo@}} matches the command-line option @option{-foo}
35088and outputs the command-line option @option{-foo}.
35089
35090@item %W@{S@}
35091Like %@{@code{S}@} but mark last argument supplied within as a file to be
35092deleted on failure.
35093
35094@item %@@@{S@}
35095Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
35096@code{@@FILE} if an @code{@@file} argument has been supplied.
35097
35098@item %@{S*@}
35099Substitutes all the switches specified to GCC whose names start
35100with @code{-S}, but which also take an argument. This is used for
35101switches like @option{-o}, @option{-D}, @option{-I}, etc.
35102GCC considers @option{-o foo} as being
35103one switch whose name starts with @samp{o}. %@{o*@} substitutes this
35104text, including the space. Thus two arguments are generated.
35105
35106@item %@{S*&T*@}
35107Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
35108(the order of @code{S} and @code{T} in the spec is not significant).
35109There can be any number of ampersand-separated variables; for each the
35110wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
35111
35112@item %@{S:X@}
35113Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
35114
35115@item %@{!S:X@}
35116Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
35117
35118@item %@{S*:X@}
35119Substitutes @code{X} if one or more switches whose names start with
35120@code{-S} are specified to GCC@. Normally @code{X} is substituted only
35121once, no matter how many such switches appeared. However, if @code{%*}
35122appears somewhere in @code{X}, then @code{X} is substituted once
35123for each matching switch, with the @code{%*} replaced by the part of
35124that switch matching the @code{*}.
35125
35126If @code{%*} appears as the last part of a spec sequence then a space
35127is added after the end of the last substitution. If there is more
35128text in the sequence, however, then a space is not generated. This
35129allows the @code{%*} substitution to be used as part of a larger
35130string. For example, a spec string like this:
35131
35132@smallexample
35133%@{mcu=*:--script=%*/memory.ld@}
35134@end smallexample
35135
35136@noindent
35137when matching an option like @option{-mcu=newchip} produces:
35138
35139@smallexample
35140--script=newchip/memory.ld
35141@end smallexample
35142
35143@item %@{.S:X@}
35144Substitutes @code{X}, if processing a file with suffix @code{S}.
35145
35146@item %@{!.S:X@}
35147Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
35148
35149@item %@{,S:X@}
35150Substitutes @code{X}, if processing a file for language @code{S}.
35151
35152@item %@{!,S:X@}
35153Substitutes @code{X}, if not processing a file for language @code{S}.
35154
35155@item %@{S|P:X@}
35156Substitutes @code{X} if either @code{-S} or @code{-P} is given to
35157GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
35158@code{*} sequences as well, although they have a stronger binding than
35159the @samp{|}. If @code{%*} appears in @code{X}, all of the
35160alternatives must be starred, and only the first matching alternative
35161is substituted.
35162
35163For example, a spec string like this:
35164
35165@smallexample
35166%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
35167@end smallexample
35168
35169@noindent
35170outputs the following command-line options from the following input
35171command-line options:
35172
35173@smallexample
35174fred.c -foo -baz
35175jim.d -bar -boggle
35176-d fred.c -foo -baz -boggle
35177-d jim.d -bar -baz -boggle
35178@end smallexample
35179
35180@item %@{%:@var{function}(@var{args}):X@}
35181
35182Call function named @var{function} with args @var{args}. If the
35183function returns non-NULL, then @code{X} is substituted, if it returns
35184NULL, it isn't substituted.
35185
35186@item %@{S:X; T:Y; :D@}
35187
35188If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
35189given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
35190be as many clauses as you need. This may be combined with @code{.},
35191@code{,}, @code{!}, @code{|}, and @code{*} as needed.
35192
35193
35194@end table
35195
35196The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
35197or similar construct can use a backslash to ignore the special meaning
35198of the character following it, thus allowing literal matching of a
35199character that is otherwise specially treated. For example,
35200@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
35201@option{-std=iso9899:1999} option is given.
35202
35203The conditional text @code{X} in a @samp{%@{S:X@}} or similar
35204construct may contain other nested @samp{%} constructs or spaces, or
35205even newlines. They are processed as usual, as described above.
35206Trailing white space in @code{X} is ignored. White space may also
35207appear anywhere on the left side of the colon in these constructs,
35208except between @code{.} or @code{*} and the corresponding word.
35209
35210The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
35211handled specifically in these constructs. If another value of
35212@option{-O} or the negated form of a @option{-f}, @option{-m}, or
35213@option{-W} switch is found later in the command line, the earlier
35214switch value is ignored, except with @{@code{S}*@} where @code{S} is
35215just one letter, which passes all matching options.
35216
35217The character @samp{|} at the beginning of the predicate text is used to
35218indicate that a command should be piped to the following command, but
35219only if @option{-pipe} is specified.
35220
35221It is built into GCC which switches take arguments and which do not.
35222(You might think it would be useful to generalize this to allow each
35223compiler's spec to say which switches take arguments. But this cannot
35224be done in a consistent fashion. GCC cannot even decide which input
35225files have been specified without knowing which switches take arguments,
35226and it must know which input files to compile in order to tell which
35227compilers to run).
35228
35229GCC also knows implicitly that arguments starting in @option{-l} are to be
35230treated as compiler output files, and passed to the linker in their
35231proper position among the other output files.
35232
35233@node Environment Variables
35234@section Environment Variables Affecting GCC
35235@cindex environment variables
35236
35237@c man begin ENVIRONMENT
35238This section describes several environment variables that affect how GCC
35239operates. Some of them work by specifying directories or prefixes to use
35240when searching for various kinds of files. Some are used to specify other
35241aspects of the compilation environment.
35242
35243Note that you can also specify places to search using options such as
35244@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
35245take precedence over places specified using environment variables, which
35246in turn take precedence over those specified by the configuration of GCC@.
35247@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
35248GNU Compiler Collection (GCC) Internals}.
35249
35250@table @env
f33d7a88
AA
35251@vindex LANG
35252@vindex LC_CTYPE
35253@c @vindex LC_COLLATE
35254@vindex LC_MESSAGES
35255@c @vindex LC_MONETARY
35256@c @vindex LC_NUMERIC
35257@c @vindex LC_TIME
35258@vindex LC_ALL
35259@cindex locale
d77de738
ML
35260@item LANG
35261@itemx LC_CTYPE
35262@c @itemx LC_COLLATE
35263@itemx LC_MESSAGES
35264@c @itemx LC_MONETARY
35265@c @itemx LC_NUMERIC
35266@c @itemx LC_TIME
35267@itemx LC_ALL
d77de738
ML
35268These environment variables control the way that GCC uses
35269localization information which allows GCC to work with different
35270national conventions. GCC inspects the locale categories
35271@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
35272so. These locale categories can be set to any value supported by your
35273installation. A typical value is @samp{en_GB.UTF-8} for English in the United
35274Kingdom encoded in UTF-8.
35275
35276The @env{LC_CTYPE} environment variable specifies character
35277classification. GCC uses it to determine the character boundaries in
35278a string; this is needed for some multibyte encodings that contain quote
35279and escape characters that are otherwise interpreted as a string
35280end or escape.
35281
35282The @env{LC_MESSAGES} environment variable specifies the language to
35283use in diagnostic messages.
35284
35285If the @env{LC_ALL} environment variable is set, it overrides the value
35286of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
35287and @env{LC_MESSAGES} default to the value of the @env{LANG}
35288environment variable. If none of these variables are set, GCC
35289defaults to traditional C English behavior.
35290
f33d7a88 35291@vindex TMPDIR
d77de738 35292@item TMPDIR
d77de738
ML
35293If @env{TMPDIR} is set, it specifies the directory to use for temporary
35294files. GCC uses temporary files to hold the output of one stage of
35295compilation which is to be used as input to the next stage: for example,
35296the output of the preprocessor, which is the input to the compiler
35297proper.
35298
f33d7a88 35299@vindex GCC_COMPARE_DEBUG
d77de738 35300@item GCC_COMPARE_DEBUG
d77de738
ML
35301Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
35302@option{-fcompare-debug} to the compiler driver. See the documentation
35303of this option for more details.
35304
f33d7a88 35305@vindex GCC_EXEC_PREFIX
d77de738 35306@item GCC_EXEC_PREFIX
d77de738
ML
35307If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
35308names of the subprograms executed by the compiler. No slash is added
35309when this prefix is combined with the name of a subprogram, but you can
35310specify a prefix that ends with a slash if you wish.
35311
35312If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
35313an appropriate prefix to use based on the pathname it is invoked with.
35314
35315If GCC cannot find the subprogram using the specified prefix, it
35316tries looking in the usual places for the subprogram.
35317
35318The default value of @env{GCC_EXEC_PREFIX} is
35319@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
35320the installed compiler. In many cases @var{prefix} is the value
35321of @code{prefix} when you ran the @file{configure} script.
35322
35323Other prefixes specified with @option{-B} take precedence over this prefix.
35324
35325This prefix is also used for finding files such as @file{crt0.o} that are
35326used for linking.
35327
35328In addition, the prefix is used in an unusual way in finding the
35329directories to search for header files. For each of the standard
35330directories whose name normally begins with @samp{/usr/local/lib/gcc}
35331(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
35332replacing that beginning with the specified prefix to produce an
35333alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
35334@file{foo/bar} just before it searches the standard directory
35335@file{/usr/local/lib/bar}.
35336If a standard directory begins with the configured
35337@var{prefix} then the value of @var{prefix} is replaced by
35338@env{GCC_EXEC_PREFIX} when looking for header files.
35339
f33d7a88 35340@vindex COMPILER_PATH
d77de738 35341@item COMPILER_PATH
d77de738
ML
35342The value of @env{COMPILER_PATH} is a colon-separated list of
35343directories, much like @env{PATH}. GCC tries the directories thus
35344specified when searching for subprograms, if it cannot find the
35345subprograms using @env{GCC_EXEC_PREFIX}.
35346
f33d7a88 35347@vindex LIBRARY_PATH
d77de738 35348@item LIBRARY_PATH
d77de738
ML
35349The value of @env{LIBRARY_PATH} is a colon-separated list of
35350directories, much like @env{PATH}. When configured as a native compiler,
35351GCC tries the directories thus specified when searching for special
35352linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35353using GCC also uses these directories when searching for ordinary
35354libraries for the @option{-l} option (but directories specified with
35355@option{-L} come first).
35356
f33d7a88 35357@vindex LANG
d77de738 35358@cindex locale definition
f33d7a88 35359@item LANG
d77de738
ML
35360This variable is used to pass locale information to the compiler. One way in
35361which this information is used is to determine the character set to be used
35362when character literals, string literals and comments are parsed in C and C++.
35363When the compiler is configured to allow multibyte characters,
35364the following values for @env{LANG} are recognized:
35365
35366@table @samp
35367@item C-JIS
35368Recognize JIS characters.
35369@item C-SJIS
35370Recognize SJIS characters.
35371@item C-EUCJP
35372Recognize EUCJP characters.
35373@end table
35374
35375If @env{LANG} is not defined, or if it has some other value, then the
35376compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35377recognize and translate multibyte characters.
35378
f33d7a88 35379@vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738 35380@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738
ML
35381If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
35382then additional text will be emitted to stderr when fix-it hints are
35383emitted. @option{-fdiagnostics-parseable-fixits} and
35384@option{-fno-diagnostics-parseable-fixits} take precedence over this
35385environment variable.
35386
35387@table @samp
35388@item fixits-v1
35389Emit parseable fix-it hints, equivalent to
35390@option{-fdiagnostics-parseable-fixits}. In particular, columns are
35391expressed as a count of bytes, starting at byte 1 for the initial column.
35392
35393@item fixits-v2
35394As @code{fixits-v1}, but columns are expressed as display columns,
35395as per @option{-fdiagnostics-column-unit=display}.
35396@end table
35397
35398@end table
35399
35400@noindent
35401Some additional environment variables affect the behavior of the
35402preprocessor.
35403
35404@include cppenv.texi
35405
35406@c man end
35407
35408@node Precompiled Headers
35409@section Using Precompiled Headers
35410@cindex precompiled headers
35411@cindex speed of compilation
35412
35413Often large projects have many header files that are included in every
35414source file. The time the compiler takes to process these header files
35415over and over again can account for nearly all of the time required to
35416build the project. To make builds faster, GCC allows you to
35417@dfn{precompile} a header file.
35418
35419To create a precompiled header file, simply compile it as you would any
35420other file, if necessary using the @option{-x} option to make the driver
35421treat it as a C or C++ header file. You may want to use a
35422tool like @command{make} to keep the precompiled header up-to-date when
35423the headers it contains change.
35424
35425A precompiled header file is searched for when @code{#include} is
35426seen in the compilation. As it searches for the included file
35427(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
35428compiler looks for a precompiled header in each directory just before it
35429looks for the include file in that directory. The name searched for is
35430the name specified in the @code{#include} with @samp{.gch} appended. If
35431the precompiled header file cannot be used, it is ignored.
35432
35433For instance, if you have @code{#include "all.h"}, and you have
35434@file{all.h.gch} in the same directory as @file{all.h}, then the
35435precompiled header file is used if possible, and the original
35436header is used otherwise.
35437
35438Alternatively, you might decide to put the precompiled header file in a
35439directory and use @option{-I} to ensure that directory is searched
35440before (or instead of) the directory containing the original header.
35441Then, if you want to check that the precompiled header file is always
35442used, you can put a file of the same name as the original header in this
35443directory containing an @code{#error} command.
35444
35445This also works with @option{-include}. So yet another way to use
35446precompiled headers, good for projects not designed with precompiled
35447header files in mind, is to simply take most of the header files used by
35448a project, include them from another header file, precompile that header
35449file, and @option{-include} the precompiled header. If the header files
35450have guards against multiple inclusion, they are skipped because
35451they've already been included (in the precompiled header).
35452
35453If you need to precompile the same header file for different
35454languages, targets, or compiler options, you can instead make a
35455@emph{directory} named like @file{all.h.gch}, and put each precompiled
35456header in the directory, perhaps using @option{-o}. It doesn't matter
35457what you call the files in the directory; every precompiled header in
35458the directory is considered. The first precompiled header
35459encountered in the directory that is valid for this compilation is
35460used; they're searched in no particular order.
35461
35462There are many other possibilities, limited only by your imagination,
35463good sense, and the constraints of your build system.
35464
35465A precompiled header file can be used only when these conditions apply:
35466
35467@itemize
35468@item
35469Only one precompiled header can be used in a particular compilation.
35470
35471@item
35472A precompiled header cannot be used once the first C token is seen. You
35473can have preprocessor directives before a precompiled header; you cannot
35474include a precompiled header from inside another header.
35475
35476@item
35477The precompiled header file must be produced for the same language as
35478the current compilation. You cannot use a C precompiled header for a C++
35479compilation.
35480
35481@item
35482The precompiled header file must have been produced by the same compiler
35483binary as the current compilation is using.
35484
35485@item
35486Any macros defined before the precompiled header is included must
35487either be defined in the same way as when the precompiled header was
35488generated, or must not affect the precompiled header, which usually
35489means that they don't appear in the precompiled header at all.
35490
35491The @option{-D} option is one way to define a macro before a
35492precompiled header is included; using a @code{#define} can also do it.
35493There are also some options that define macros implicitly, like
35494@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35495defined this way.
35496
35497@item If debugging information is output when using the precompiled
35498header, using @option{-g} or similar, the same kind of debugging information
35499must have been output when building the precompiled header. However,
35500a precompiled header built using @option{-g} can be used in a compilation
35501when no debugging information is being output.
35502
35503@item The same @option{-m} options must generally be used when building
35504and using the precompiled header. @xref{Submodel Options},
35505for any cases where this rule is relaxed.
35506
35507@item Each of the following options must be the same when building and using
35508the precompiled header:
35509
35510@gccoptlist{-fexceptions}
35511
35512@item
35513Some other command-line options starting with @option{-f},
35514@option{-p}, or @option{-O} must be defined in the same way as when
35515the precompiled header was generated. At present, it's not clear
35516which options are safe to change and which are not; the safest choice
35517is to use exactly the same options when generating and using the
35518precompiled header. The following are known to be safe:
35519
43b72ede
AA
35520@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
35521-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
35522-fsched-verbose=@var{number} -fschedule-insns -fvisibility=
d77de738
ML
35523-pedantic-errors}
35524
35525@item Address space layout randomization (ASLR) can lead to not binary identical
35526PCH files. If you rely on stable PCH file contents disable ASLR when generating
35527PCH files.
35528
35529@end itemize
35530
35531For all of these except the last, the compiler automatically
35532ignores the precompiled header if the conditions aren't met. If you
35533find an option combination that doesn't work and doesn't cause the
35534precompiled header to be ignored, please consider filing a bug report,
35535see @ref{Bugs}.
35536
35537If you do use differing options when generating and using the
35538precompiled header, the actual behavior is a mixture of the
35539behavior for the options. For instance, if you use @option{-g} to
35540generate the precompiled header but not when using it, you may or may
35541not get debugging information for routines in the precompiled header.
35542
35543@node C++ Modules
35544@section C++ Modules
35545@cindex speed of compilation
35546
35547Modules are a C++20 language feature. As the name suggests, they
35548provides a modular compilation system, intending to provide both
35549faster builds and better library isolation. The ``Merging Modules''
35550paper @uref{https://wg21.link/p1103}, provides the easiest to read set
35551of changes to the standard, although it does not capture later
35552changes.
35553
35554@emph{G++'s modules support is not complete.} Other than bugs, the
35555known missing pieces are:
35556
35557@table @emph
35558
35559@item Private Module Fragment
35560The Private Module Fragment is recognized, but an error is emitted.
35561
35562@item Partition definition visibility rules
35563Entities may be defined in implementation partitions, and those
35564definitions are not available outside of the module. This is not
35565implemented, and the definitions are available to extra-module use.
35566
35567@item Textual merging of reachable GM entities
35568Entities may be multiply defined across different header-units.
35569These must be de-duplicated, and this is implemented across imports,
35570or when an import redefines a textually-defined entity. However the
35571reverse is not implemented---textually redefining an entity that has
35572been defined in an imported header-unit. A redefinition error is
35573emitted.
35574
35575@item Translation-Unit local referencing rules
35576Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
35577(@uref{https://wg21.link/p2003}) add limitations on which entities an
35578exported region may reference (for instance, the entities an exported
35579template definition may reference). These are not fully implemented.
35580
35581@item Standard Library Header Units
35582The Standard Library is not provided as importable header units. If
35583you want to import such units, you must explicitly build them first.
35584If you do not do this with care, you may have multiple declarations,
35585which the module machinery must merge---compiler resource usage can be
35586affected by how you partition header files into header units.
35587
35588@end table
35589
35590Modular compilation is @emph{not} enabled with just the
35591@option{-std=c++20} option. You must explicitly enable it with the
35592@option{-fmodules-ts} option. It is independent of the language
35593version selected, although in pre-C++20 versions, it is of course an
35594extension.
35595
35596No new source file suffixes are required or supported. If you wish to
35597use a non-standard suffix (@pxref{Overall Options}), you also need
35598to provide a @option{-x c++} option too.@footnote{Some users like to
35599distinguish module interface files with a new suffix, such as naming
35600the source @code{module.cppm}, which involves
35601teaching all tools about the new suffix. A different scheme, such as
35602naming @code{module-m.cpp} would be less invasive.}
35603
35604Compiling a module interface unit produces an additional output (to
35605the assembly or object file), called a Compiled Module Interface
35606(CMI). This encodes the exported declarations of the module.
35607Importing a module reads in the CMI. The import graph is a Directed
35608Acyclic Graph (DAG). You must build imports before the importer.
35609
35610Header files may themselves be compiled to header units, which are a
35611transitional ability aiming at faster compilation. The
35612@option{-fmodule-header} option is used to enable this, and implies
35613the @option{-fmodules-ts} option. These CMIs are named by the fully
35614resolved underlying header file, and thus may be a complete pathname
35615containing subdirectories. If the header file is found at an absolute
35616pathname, the CMI location is still relative to a CMI root directory.
35617
35618As header files often have no suffix, you commonly have to specify a
35619@option{-x} option to tell the compiler the source is a header file.
35620You may use @option{-x c++-header}, @option{-x c++-user-header} or
35621@option{-x c++-system-header}. When used in conjunction with
35622@option{-fmodules-ts}, these all imply an appropriate
35623@option{-fmodule-header} option. The latter two variants use the
35624user or system include path to search for the file specified. This
35625allows you to, for instance, compile standard library header files as
35626header units, without needing to know exactly where they are
35627installed. Specifying the language as one of these variants also
35628inhibits output of the object file, as header files have no associated
35629object file.
35630
35631The @option{-fmodule-only} option disables generation of the
35632associated object file for compiling a module interface. Only the CMI
35633is generated. This option is implied when using the
35634@option{-fmodule-header} option.
35635
35636The @option{-flang-info-include-translate} and
35637@option{-flang-info-include-translate-not} options notes whether
35638include translation occurs or not. With no argument, the first will
35639note all include translation. The second will note all
35640non-translations of include files not known to intentionally be
35641textual. With an argument, queries about include translation of a
35642header files with that particular trailing pathname are noted. You
35643may repeat this form to cover several different header files. This
35644option may be helpful in determining whether include translation is
35645happening---if it is working correctly, it behaves as if it isn't
35646there at all.
35647
35648The @option{-flang-info-module-cmi} option can be used to determine
35649where the compiler is reading a CMI from. Without the option, the
35650compiler is silent when such a read is successful. This option has an
35651optional argument, which will restrict the notification to just the
35652set of named modules or header units specified.
35653
35654The @option{-Winvalid-imported-macros} option causes all imported macros
35655to be resolved at the end of compilation. Without this, imported
35656macros are only resolved when expanded or (re)defined. This option
35657detects conflicting import definitions for all macros.
35658
35659For details of the @option{-fmodule-mapper} family of options,
35660@pxref{C++ Module Mapper}.
35661
35662@menu
35663* C++ Module Mapper:: Module Mapper
35664* C++ Module Preprocessing:: Module Preprocessing
35665* C++ Compiled Module Interface:: Compiled Module Interface
35666@end menu
35667
35668@node C++ Module Mapper
35669@subsection Module Mapper
35670@cindex C++ Module Mapper
35671
35672A module mapper provides a server or file that the compiler queries to
35673determine the mapping between module names and CMI files. It is also
35674used to build CMIs on demand. @emph{Mapper functionality is in its
35675infancy and is intended for experimentation with build system
35676interactions.}
35677
35678You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
35679option or @env{CXX_MODULE_MAPPER} environment variable. The value may
35680have one of the following forms:
35681
35682@table @gcctabopt
35683
35684@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
35685An optional hostname and a numeric port number to connect to. If the
35686hostname is omitted, the loopback address is used. If the hostname
35687corresponds to multiple IPV6 addresses, these are tried in turn, until
35688one is successful. If your host lacks IPv6, this form is
35689non-functional. If you must use IPv4 use
35690@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
35691
35692@item =@var{socket}@r{[}?@var{ident}@r{]}
35693A local domain socket. If your host lacks local domain sockets, this
35694form is non-functional.
35695
35696@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
35697A program to spawn, and communicate with on its stdin/stdout streams.
35698Your @var{PATH} environment variable is searched for the program.
35699Arguments are separated by space characters, (it is not possible for
35700one of the arguments delivered to the program to contain a space). An
35701exception is if @var{program} begins with @@. In that case
35702@var{program} (sans @@) is looked for in the compiler's internal
35703binary directory. Thus the sample mapper-server can be specified
35704with @code{@@g++-mapper-server}.
35705
35706@item <>@r{[}?@var{ident}@r{]}
35707@item <>@var{inout}@r{[}?@var{ident}@r{]}
35708@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
35709Named pipes or file descriptors to communicate over. The first form,
35710@option{<>}, communicates over stdin and stdout. The other forms
35711allow you to specify a file descriptor or name a pipe. A numeric value
35712is interpreted as a file descriptor, otherwise named pipe is opened.
35713The second form specifies a bidirectional pipe and the last form
35714allows specifying two independent pipes. Using file descriptors
35715directly in this manner is fragile in general, as it can require the
35716cooperation of intermediate processes. In particular using stdin &
35717stdout is fraught with danger as other compiler options might also
35718cause the compiler to read stdin or write stdout, and it can have
35719unfortunate interactions with signal delivery from the terminal.
35720
35721@item @var{file}@r{[}?@var{ident}@r{]}
35722A mapping file consisting of space-separated module-name, filename
35723pairs, one per line. Only the mappings for the direct imports and any
35724module export name need be provided. If other mappings are provided,
35725they override those stored in any imported CMI files. A repository
35726root may be specified in the mapping file by using @samp{$root} as the
35727module name in the first active line. Use of this option will disable
35728any default module->CMI name mapping.
35729
35730@end table
35731
35732As shown, an optional @var{ident} may suffix the first word of the
35733option, indicated by a @samp{?} prefix. The value is used in the
35734initial handshake with the module server, or to specify a prefix on
35735mapping file lines. In the server case, the main source file name is
35736used if no @var{ident} is specified. In the file case, all non-blank
35737lines are significant, unless a value is specified, in which case only
35738lines beginning with @var{ident} are significant. The @var{ident}
35739must be separated by whitespace from the module name. Be aware that
35740@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
35741significant to the shell, and therefore may need quoting.
35742
35743The mapper is connected to or loaded lazily, when the first module
35744mapping is required. The networking protocols are only supported on
35745hosts that provide networking. If no mapper is specified a default is
35746provided.
35747
35748A project-specific mapper is expected to be provided by the build
35749system that invokes the compiler. It is not expected that a
35750general-purpose server is provided for all compilations. As such, the
35751server will know the build configuration, the compiler it invoked, and
35752the environment (such as working directory) in which that is
35753operating. As it may parallelize builds, several compilations may
35754connect to the same socket.
35755
35756The default mapper generates CMI files in a @samp{gcm.cache}
35757directory. CMI files have a @samp{.gcm} suffix. The module unit name
35758is used directly to provide the basename. Header units construct a
35759relative path using the underlying header file name. If the path is
35760already relative, a @samp{,} directory is prepended. Internal
35761@samp{..} components are translated to @samp{,,}. No attempt is made
35762to canonicalize these filenames beyond that done by the preprocessor's
35763include search algorithm, as in general it is ambiguous when symbolic
35764links are present.
35765
35766The mapper protocol was published as ``A Module Mapper''
35767@uref{https://wg21.link/p1184}. The implementation is provided by
35768@command{libcody}, @uref{https://github.com/urnathan/libcody},
35769which specifies the canonical protocol definition. A proof of concept
35770server implementation embedded in @command{make} was described in
35771''Make Me A Module'', @uref{https://wg21.link/p1602}.
35772
35773@node C++ Module Preprocessing
35774@subsection Module Preprocessing
35775@cindex C++ Module Preprocessing
35776
35777Modules affect preprocessing because of header units and include
35778translation. Some uses of the preprocessor as a separate step either
35779do not produce a correct output, or require CMIs to be available.
35780
35781Header units import macros. These macros can affect later conditional
35782inclusion, which therefore can cascade to differing import sets. When
35783preprocessing, it is necessary to load the CMI. If a header unit is
35784unavailable, the preprocessor issues a warning and continue (when
35785not just preprocessing, an error is emitted). Detecting such imports
35786requires preprocessor tokenization of the input stream to phase 4
35787(macro expansion).
35788
35789Include translation converts @code{#include}, @code{#include_next} and
35790@code{#import} directives to internal @code{import} declarations.
35791Whether a particular directive is translated is controlled by the
35792module mapper. Header unit names are canonicalized during
35793preprocessing.
35794
35795Dependency information can be emitted for macro import, extending the
35796functionality of @option{-MD} and @option{-MMD} options. Detection of
35797import declarations also requires phase 4 preprocessing, and thus
35798requires full preprocessing (or compilation).
35799
35800The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
35801preprocessing before phase 4.
35802
35803The @option{-save-temps} option uses @option{-fdirectives-only} for
35804preprocessing, and preserve the macro definitions in the preprocessed
35805output. Usually you also want to use this option when explicitly
35806preprocessing a header-unit, or consuming such preprocessed output:
35807
35808@smallexample
35809g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
35810g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
35811@end smallexample
35812
35813@node C++ Compiled Module Interface
35814@subsection Compiled Module Interface
35815@cindex C++ Compiled Module Interface
35816
35817CMIs are an additional artifact when compiling named module
35818interfaces, partitions or header units. These are read when
35819importing. CMI contents are implementation-specific, and in GCC's
35820case tied to the compiler version. Consider them a rebuildable cache
35821artifact, not a distributable object.
35822
35823When creating an output CMI, any missing directory components are
35824created in a manner that is safe for concurrent builds creating
35825multiple, different, CMIs within a common subdirectory tree.
35826
35827CMI contents are written to a temporary file, which is then atomically
35828renamed. Observers either see old contents (if there is an
35829existing file), or complete new contents. They do not observe the
35830CMI during its creation. This is unlike object file writing, which
35831may be observed by an external process.
35832
35833CMIs are read in lazily, if the host OS provides @code{mmap}
35834functionality. Generally blocks are read when name lookup or template
35835instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
35836option may be used.
35837
35838The @option{--param lazy-modules=@var{n}} parameter controls the limit
35839on the number of concurrently open module files during lazy loading.
35840Should more modules be imported, an LRU algorithm is used to determine
35841which files to close---until that file is needed again. This limit
35842may be exceeded with deep module dependency hierarchies. With large
35843code bases there may be more imports than the process limit of file
35844descriptors. By default, the limit is a few less than the per-process
35845file descriptor hard limit, if that is determinable.@footnote{Where
35846applicable the soft limit is incremented as needed towards the hard limit.}
35847
35848GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
35849You may use @command{readelf} to inspect them, although section
35850contents are largely undecipherable. There is a section named
35851@code{.gnu.c++.README}, which contains human-readable text. Other
35852than the first line, each line consists of @code{@var{tag}: @code{value}}
35853tuples.
35854
35855@smallexample
35856> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
35857
35858String dump of section '.gnu.c++.README':
35859 [ 0] GNU C++ primary module interface
35860 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
35861 [ 6f] version: 2020/11/16-04:54
35862 [ 89] module: foo
35863 [ 95] source: c_b.ii
35864 [ a4] dialect: C++20/coroutines
35865 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
35866 [ ee] repository: gcm.cache
35867 [ 104] buildtime: 2020/11/16 15:03:21 UTC
35868 [ 127] localtime: 2020/11/16 07:03:21 PST
35869 [ 14a] export: foo:part1 foo-part1.gcm
35870@end smallexample
35871
35872Amongst other things, this lists the source that was built, C++
35873dialect used and imports of the module.@footnote{The precise contents
35874of this output may change.} The timestamp is the same value as that
35875provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
35876explicitly specified with the environment variable
35877@code{SOURCE_DATE_EPOCH}. For further details
35878@pxref{Environment Variables}.
35879
35880A set of related CMIs may be copied, provided the relative pathnames
35881are preserved.
35882
35883The @code{.gnu.c++.README} contents do not affect CMI integrity, and
35884it may be removed or altered. The section numbering of the sections
35885whose names do not begin with @code{.gnu.c++.}, or are not the string
35886section is significant and must not be altered.