]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
testsuite: Skip powerpc tests on AIX.
[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
d77de738
ML
3704@opindex Wctad-maybe-unsupported
3705@opindex Wno-ctad-maybe-unsupported
ddf6fe37 3706@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
d77de738
ML
3707Warn when performing class template argument deduction (CTAD) on a type with
3708no explicitly written deduction guides. This warning will point out cases
3709where CTAD succeeded only because the compiler synthesized the implicit
3710deduction guides, which might not be what the programmer intended. Certain
3711style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3712types that are designed to support CTAD. This warning can be suppressed with
3713the following pattern:
3714
3715@smallexample
3716struct allow_ctad_t; // any name works
3717template <typename T> struct S @{
3718 S(T) @{ @}
3719@};
4ace81b6
SL
3720// Guide with incomplete parameter type will never be considered.
3721S(allow_ctad_t) -> S<void>;
d77de738
ML
3722@end smallexample
3723
d77de738
ML
3724@opindex Wctor-dtor-privacy
3725@opindex Wno-ctor-dtor-privacy
ddf6fe37 3726@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
d77de738
ML
3727Warn when a class seems unusable because all the constructors or
3728destructors in that class are private, and it has neither friends nor
3729public static member functions. Also warn if there are no non-private
3730methods, and there's at least one private member function that isn't
3731a constructor or destructor.
3732
d77de738
ML
3733@opindex Wdangling-reference
3734@opindex Wno-dangling-reference
ddf6fe37 3735@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
d77de738
ML
3736Warn when a reference is bound to a temporary whose lifetime has ended.
3737For example:
3738
3739@smallexample
3740int n = 1;
3741const int& r = std::max(n - 1, n + 1); // r is dangling
3742@end smallexample
3743
3744In the example above, two temporaries are created, one for each
3745argument, and a reference to one of the temporaries is returned.
3746However, both temporaries are destroyed at the end of the full
3747expression, so the reference @code{r} is dangling. This warning
3748also detects dangling references in member initializer lists:
3749
3750@smallexample
3751const int& f(const int& i) @{ return i; @}
3752struct S @{
3753 const int &r; // r is dangling
3754 S() : r(f(10)) @{ @}
3755@};
3756@end smallexample
3757
3758Member functions are checked as well, but only their object argument:
3759
3760@smallexample
3761struct S @{
3762 const S& self () @{ return *this; @}
3763@};
3764const S& s = S().self(); // s is dangling
3765@end smallexample
3766
3767Certain functions are safe in this respect, for example @code{std::use_facet}:
3768they take and return a reference, but they don't return one of its arguments,
3769which can fool the warning. Such functions can be excluded from the warning
3770by wrapping them in a @code{#pragma}:
3771
3772@smallexample
3773#pragma GCC diagnostic push
3774#pragma GCC diagnostic ignored "-Wdangling-reference"
3775const T& foo (const T&) @{ @dots{} @}
3776#pragma GCC diagnostic pop
3777@end smallexample
3778
ce51e843
ML
3779@option{-Wdangling-reference} also warns about code like
3780
3781@smallexample
3782auto p = std::minmax(1, 2);
3783@end smallexample
3784
3785where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3786both references dangle after the end of the full expression that contains
3787the call to @code{std::minmax}.
3788
d77de738
ML
3789This warning is enabled by @option{-Wall}.
3790
d77de738
ML
3791@opindex Wdelete-non-virtual-dtor
3792@opindex Wno-delete-non-virtual-dtor
ddf6fe37 3793@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
3794Warn when @code{delete} is used to destroy an instance of a class that
3795has virtual functions and non-virtual destructor. It is unsafe to delete
3796an instance of a derived class through a pointer to a base class if the
3797base class does not have a virtual destructor. This warning is enabled
3798by @option{-Wall}.
3799
d77de738
ML
3800@opindex Wdeprecated-copy
3801@opindex Wno-deprecated-copy
ddf6fe37 3802@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
d77de738
ML
3803Warn that the implicit declaration of a copy constructor or copy
3804assignment operator is deprecated if the class has a user-provided
3805copy constructor or copy assignment operator, in C++11 and up. This
3806warning is enabled by @option{-Wextra}. With
3807@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3808user-provided destructor.
3809
d77de738
ML
3810@opindex Wdeprecated-enum-enum-conversion
3811@opindex Wno-deprecated-enum-enum-conversion
ddf6fe37 3812@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3813Disable the warning about the case when the usual arithmetic conversions
3814are applied on operands where one is of enumeration type and the other is
3815of a different enumeration type. This conversion was deprecated in C++20.
3816For example:
3817
3818@smallexample
3819enum E1 @{ e @};
3820enum E2 @{ f @};
3821int k = f - e;
3822@end smallexample
3823
3824@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3825@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3826by @option{-Wenum-conversion}.
3827
d77de738
ML
3828@opindex Wdeprecated-enum-float-conversion
3829@opindex Wno-deprecated-enum-float-conversion
ddf6fe37 3830@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3831Disable the warning about the case when the usual arithmetic conversions
3832are applied on operands where one is of enumeration type and the other is
3833of a floating-point type. This conversion was deprecated in C++20. For
3834example:
3835
3836@smallexample
3837enum E1 @{ e @};
3838enum E2 @{ f @};
3839bool b = e <= 3.7;
3840@end smallexample
3841
3842@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3843@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3844by @option{-Wenum-conversion}.
3845
d77de738
ML
3846@opindex Winit-list-lifetime
3847@opindex Wno-init-list-lifetime
ddf6fe37 3848@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
d77de738
ML
3849Do not warn about uses of @code{std::initializer_list} that are likely
3850to result in dangling pointers. Since the underlying array for an
3851@code{initializer_list} is handled like a normal C++ temporary object,
3852it is easy to inadvertently keep a pointer to the array past the end
3853of the array's lifetime. For example:
3854
3855@itemize @bullet
3856@item
3857If a function returns a temporary @code{initializer_list}, or a local
3858@code{initializer_list} variable, the array's lifetime ends at the end
3859of the return statement, so the value returned has a dangling pointer.
3860
3861@item
3862If a new-expression creates an @code{initializer_list}, the array only
3863lives until the end of the enclosing full-expression, so the
3864@code{initializer_list} in the heap has a dangling pointer.
3865
3866@item
3867When an @code{initializer_list} variable is assigned from a
3868brace-enclosed initializer list, the temporary array created for the
3869right side of the assignment only lives until the end of the
3870full-expression, so at the next statement the @code{initializer_list}
3871variable has a dangling pointer.
3872
3873@smallexample
3874// li's initial underlying array lives as long as li
3875std::initializer_list<int> li = @{ 1,2,3 @};
3876// assignment changes li to point to a temporary array
3877li = @{ 4, 5 @};
3878// now the temporary is gone and li has a dangling pointer
3879int i = li.begin()[0] // undefined behavior
3880@end smallexample
3881
3882@item
3883When a list constructor stores the @code{begin} pointer from the
3884@code{initializer_list} argument, this doesn't extend the lifetime of
3885the array, so if a class variable is constructed from a temporary
3886@code{initializer_list}, the pointer is left dangling by the end of
3887the variable declaration statement.
3888
3889@end itemize
3890
c85f8dbb
MP
3891@opindex Winvalid-constexpr
3892@opindex Wno-invalid-constexpr
ddf6fe37 3893@item -Winvalid-constexpr
c85f8dbb
MP
3894
3895Warn when a function never produces a constant expression. In C++20
3896and earlier, for every @code{constexpr} function and function template,
3897there must be at least one set of function arguments in at least one
3898instantiation such that an invocation of the function or constructor
3899could be an evaluated subexpression of a core constant expression.
3900C++23 removed this restriction, so it's possible to have a function
3901or a function template marked @code{constexpr} for which no invocation
3902satisfies the requirements of a core constant expression.
3903
3904This warning is enabled as a pedantic warning by default in C++20 and
3905earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3906which case it will be an ordinary warning. For example:
3907
3908@smallexample
3909void f (int& i);
3910constexpr void
3911g (int& i)
3912@{
4ace81b6
SL
3913 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
3914 f(i);
c85f8dbb
MP
3915@}
3916@end smallexample
3917
d77de738
ML
3918@opindex Winvalid-imported-macros
3919@opindex Wno-invalid-imported-macros
ddf6fe37 3920@item -Winvalid-imported-macros
d77de738
ML
3921Verify all imported macro definitions are valid at the end of
3922compilation. This is not enabled by default, as it requires
3923additional processing to determine. It may be useful when preparing
3924sets of header-units to ensure consistent macros.
3925
d77de738
ML
3926@opindex Wliteral-suffix
3927@opindex Wno-literal-suffix
ddf6fe37 3928@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
d77de738
ML
3929Do not warn when a string or character literal is followed by a
3930ud-suffix which does not begin with an underscore. As a conforming
3931extension, GCC treats such suffixes as separate preprocessing tokens
3932in order to maintain backwards compatibility with code that uses
3933formatting macros from @code{<inttypes.h>}. For example:
3934
3935@smallexample
3936#define __STDC_FORMAT_MACROS
3937#include <inttypes.h>
3938#include <stdio.h>
3939
3940int main() @{
3941 int64_t i64 = 123;
3942 printf("My int64: %" PRId64"\n", i64);
3943@}
3944@end smallexample
3945
3946In this case, @code{PRId64} is treated as a separate preprocessing token.
3947
3948This option also controls warnings when a user-defined literal
3949operator is declared with a literal suffix identifier that doesn't
3950begin with an underscore. Literal suffix identifiers that don't begin
3951with an underscore are reserved for future standardization.
3952
3953These warnings are enabled by default.
3954
d77de738
ML
3955@opindex Wnarrowing
3956@opindex Wno-narrowing
ddf6fe37 3957@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
d77de738
ML
3958For C++11 and later standards, narrowing conversions are diagnosed by default,
3959as required by the standard. A narrowing conversion from a constant produces
3960an error, and a narrowing conversion from a non-constant produces a warning,
3961but @option{-Wno-narrowing} suppresses the diagnostic.
3962Note that this does not affect the meaning of well-formed code;
3963narrowing conversions are still considered ill-formed in SFINAE contexts.
3964
3965With @option{-Wnarrowing} in C++98, warn when a narrowing
3966conversion prohibited by C++11 occurs within
3967@samp{@{ @}}, e.g.
3968
3969@smallexample
3970int i = @{ 2.2 @}; // error: narrowing from double to int
3971@end smallexample
3972
3973This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3974
d77de738
ML
3975@opindex Wnoexcept
3976@opindex Wno-noexcept
ddf6fe37 3977@item -Wnoexcept @r{(C++ and Objective-C++ only)}
d77de738
ML
3978Warn when a noexcept-expression evaluates to false because of a call
3979to a function that does not have a non-throwing exception
3980specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3981the compiler to never throw an exception.
3982
d77de738
ML
3983@opindex Wnoexcept-type
3984@opindex Wno-noexcept-type
ddf6fe37 3985@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
d77de738
ML
3986Warn if the C++17 feature making @code{noexcept} part of a function
3987type changes the mangled name of a symbol relative to C++14. Enabled
3988by @option{-Wabi} and @option{-Wc++17-compat}.
3989
3990As an example:
3991
3992@smallexample
3993template <class T> void f(T t) @{ t(); @};
3994void g() noexcept;
3995void h() @{ f(g); @}
3996@end smallexample
3997
3998@noindent
3999In C++14, @code{f} calls @code{f<void(*)()>}, but in
4000C++17 it calls @code{f<void(*)()noexcept>}.
4001
d77de738
ML
4002@opindex Wclass-memaccess
4003@opindex Wno-class-memaccess
ddf6fe37 4004@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
d77de738
ML
4005Warn when the destination of a call to a raw memory function such as
4006@code{memset} or @code{memcpy} is an object of class type, and when writing
4007into such an object might bypass the class non-trivial or deleted constructor
4008or copy assignment, violate const-correctness or encapsulation, or corrupt
4009virtual table pointers. Modifying the representation of such objects may
4010violate invariants maintained by member functions of the class. For example,
4011the call to @code{memset} below is undefined because it modifies a non-trivial
4012class object and is, therefore, diagnosed. The safe way to either initialize
4013or clear the storage of objects of such types is by using the appropriate
4014constructor or assignment operator, if one is available.
4015@smallexample
4016std::string str = "abc";
4017memset (&str, 0, sizeof str);
4018@end smallexample
4019The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4020Explicitly casting the pointer to the class object to @code{void *} or
4021to a type that can be safely accessed by the raw memory function suppresses
4022the warning.
4023
d77de738
ML
4024@opindex Wnon-virtual-dtor
4025@opindex Wno-non-virtual-dtor
ddf6fe37 4026@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
4027Warn when a class has virtual functions and an accessible non-virtual
4028destructor itself or in an accessible polymorphic base class, in which
4029case it is possible but unsafe to delete an instance of a derived
4030class through a pointer to the class itself or base class. This
4031warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4032The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4033should be preferred because it warns about the unsafe cases without false
4034positives.
d77de738 4035
d77de738
ML
4036@opindex Wregister
4037@opindex Wno-register
ddf6fe37 4038@item -Wregister @r{(C++ and Objective-C++ only)}
d77de738
ML
4039Warn on uses of the @code{register} storage class specifier, except
4040when it is part of the GNU @ref{Explicit Register Variables} extension.
4041The use of the @code{register} keyword as storage class specifier has
4042been deprecated in C++11 and removed in C++17.
4043Enabled by default with @option{-std=c++17}.
4044
d77de738
ML
4045@opindex Wreorder
4046@opindex Wno-reorder
4047@cindex reordering, warning
4048@cindex warning for reordering of member initializers
f33d7a88 4049@item -Wreorder @r{(C++ and Objective-C++ only)}
d77de738
ML
4050Warn when the order of member initializers given in the code does not
4051match the order in which they must be executed. For instance:
4052
4053@smallexample
4054struct A @{
4055 int i;
4056 int j;
4057 A(): j (0), i (1) @{ @}
4058@};
4059@end smallexample
4060
4061@noindent
4062The compiler rearranges the member initializers for @code{i}
4063and @code{j} to match the declaration order of the members, emitting
4064a warning to that effect. This warning is enabled by @option{-Wall}.
4065
d77de738
ML
4066@opindex Wpessimizing-move
4067@opindex Wno-pessimizing-move
ddf6fe37 4068@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4069This warning warns when a call to @code{std::move} prevents copy
4070elision. A typical scenario when copy elision can occur is when returning in
4071a function with a class return type, when the expression being returned is the
4072name of a non-volatile automatic object, and is not a function parameter, and
4073has the same type as the function return type.
4074
4075@smallexample
4076struct T @{
4077@dots{}
4078@};
4079T fn()
4080@{
4081 T t;
4082 @dots{}
4083 return std::move (t);
4084@}
4085@end smallexample
4086
4087But in this example, the @code{std::move} call prevents copy elision.
4088
4089This warning is enabled by @option{-Wall}.
4090
d77de738
ML
4091@opindex Wredundant-move
4092@opindex Wno-redundant-move
ddf6fe37 4093@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4094This warning warns about redundant calls to @code{std::move}; that is, when
4095a move operation would have been performed even without the @code{std::move}
4096call. This happens because the compiler is forced to treat the object as if
4097it were an rvalue in certain situations such as returning a local variable,
4098where copy elision isn't applicable. Consider:
4099
4100@smallexample
4101struct T @{
4102@dots{}
4103@};
4104T fn(T t)
4105@{
4106 @dots{}
4107 return std::move (t);
4108@}
4109@end smallexample
4110
4111Here, the @code{std::move} call is redundant. Because G++ implements Core
4112Issue 1579, another example is:
4113
4114@smallexample
4115struct T @{ // convertible to U
4116@dots{}
4117@};
4118struct U @{
4119@dots{}
4120@};
4121U fn()
4122@{
4123 T t;
4124 @dots{}
4125 return std::move (t);
4126@}
4127@end smallexample
4128In this example, copy elision isn't applicable because the type of the
4129expression being returned and the function return type differ, yet G++
4130treats the return value as if it were designated by an rvalue.
4131
4132This warning is enabled by @option{-Wextra}.
4133
d77de738
ML
4134@opindex Wrange-loop-construct
4135@opindex Wno-range-loop-construct
ddf6fe37 4136@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
d77de738
ML
4137This warning warns when a C++ range-based for-loop is creating an unnecessary
4138copy. This can happen when the range declaration is not a reference, but
4139probably should be. For example:
4140
4141@smallexample
4142struct S @{ char arr[128]; @};
4143void fn () @{
4144 S arr[5];
4145 for (const auto x : arr) @{ @dots{} @}
4146@}
4147@end smallexample
4148
4149It does not warn when the type being copied is a trivially-copyable type whose
4150size is less than 64 bytes.
4151
4152This warning also warns when a loop variable in a range-based for-loop is
4153initialized with a value of a different type resulting in a copy. For example:
4154
4155@smallexample
4156void fn() @{
4157 int arr[10];
4158 for (const double &x : arr) @{ @dots{} @}
4159@}
4160@end smallexample
4161
4162In the example above, in every iteration of the loop a temporary value of
4163type @code{double} is created and destroyed, to which the reference
4164@code{const double &} is bound.
4165
4166This warning is enabled by @option{-Wall}.
4167
d77de738
ML
4168@opindex Wredundant-tags
4169@opindex Wno-redundant-tags
ddf6fe37 4170@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4171Warn about redundant class-key and enum-key in references to class types
4172and enumerated types in contexts where the key can be eliminated without
4173causing an ambiguity. For example:
4174
4175@smallexample
4176struct foo;
4177struct foo *p; // warn that keyword struct can be eliminated
4178@end smallexample
4179
4180@noindent
4181On the other hand, in this example there is no warning:
4182
4183@smallexample
4184struct foo;
4185void foo (); // "hides" struct foo
4186void bar (struct foo&); // no warning, keyword struct is necessary
4187@end smallexample
4188
d77de738
ML
4189@opindex Wsubobject-linkage
4190@opindex Wno-subobject-linkage
ddf6fe37 4191@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
d77de738
ML
4192Do not warn
4193if a class type has a base or a field whose type uses the anonymous
4194namespace or depends on a type with no linkage. If a type A depends on
4195a type B with no or internal linkage, defining it in multiple
4196translation units would be an ODR violation because the meaning of B
4197is different in each translation unit. If A only appears in a single
4198translation unit, the best way to silence the warning is to give it
4199internal linkage by putting it in an anonymous namespace as well. The
4200compiler doesn't give this warning for types defined in the main .C
4201file, as those are unlikely to have multiple definitions.
4202@option{-Wsubobject-linkage} is enabled by default.
4203
d77de738
ML
4204@opindex Weffc++
4205@opindex Wno-effc++
ddf6fe37 4206@item -Weffc++ @r{(C++ and Objective-C++ only)}
d77de738
ML
4207Warn about violations of the following style guidelines from Scott Meyers'
4208@cite{Effective C++} series of books:
4209
4210@itemize @bullet
4211@item
4212Define a copy constructor and an assignment operator for classes
4213with dynamically-allocated memory.
4214
4215@item
4216Prefer initialization to assignment in constructors.
4217
4218@item
4219Have @code{operator=} return a reference to @code{*this}.
4220
4221@item
4222Don't try to return a reference when you must return an object.
4223
4224@item
4225Distinguish between prefix and postfix forms of increment and
4226decrement operators.
4227
4228@item
4229Never overload @code{&&}, @code{||}, or @code{,}.
4230
4231@end itemize
4232
4233This option also enables @option{-Wnon-virtual-dtor}, which is also
4234one of the effective C++ recommendations. However, the check is
4235extended to warn about the lack of virtual destructor in accessible
4236non-polymorphic bases classes too.
4237
4238When selecting this option, be aware that the standard library
4239headers do not obey all of these guidelines; use @samp{grep -v}
4240to filter out those warnings.
4241
d77de738
ML
4242@opindex Wexceptions
4243@opindex Wno-exceptions
ddf6fe37 4244@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
d77de738
ML
4245Disable the warning about the case when an exception handler is shadowed by
4246another handler, which can point out a wrong ordering of exception handlers.
4247
d77de738
ML
4248@opindex Wstrict-null-sentinel
4249@opindex Wno-strict-null-sentinel
ddf6fe37 4250@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
d77de738
ML
4251Warn about the use of an uncasted @code{NULL} as sentinel. When
4252compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4253to @code{__null}. Although it is a null pointer constant rather than a
4254null pointer, it is guaranteed to be of the same size as a pointer.
4255But this use is not portable across different compilers.
4256
d77de738
ML
4257@opindex Wno-non-template-friend
4258@opindex Wnon-template-friend
ddf6fe37 4259@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
d77de738
ML
4260Disable warnings when non-template friend functions are declared
4261within a template. In very old versions of GCC that predate implementation
4262of the ISO standard, declarations such as
4263@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4264could be interpreted as a particular specialization of a template
4265function; the warning exists to diagnose compatibility problems,
4266and is enabled by default.
4267
d77de738
ML
4268@opindex Wold-style-cast
4269@opindex Wno-old-style-cast
ddf6fe37 4270@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4271Warn if an old-style (C-style) cast to a non-void type is used within
4272a C++ program. The new-style casts (@code{dynamic_cast},
4273@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4274less vulnerable to unintended effects and much easier to search for.
4275
d77de738
ML
4276@opindex Woverloaded-virtual
4277@opindex Wno-overloaded-virtual
4278@cindex overloaded virtual function, warning
4279@cindex warning for overloaded virtual function
f33d7a88
AA
4280@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4281@itemx -Woverloaded-virtual=@var{n}
d77de738
ML
4282Warn when a function declaration hides virtual functions from a
4283base class. For example, in:
4284
4285@smallexample
4286struct A @{
4287 virtual void f();
4288@};
4289
4290struct B: public A @{
4291 void f(int); // does not override
4292@};
4293@end smallexample
4294
4295the @code{A} class version of @code{f} is hidden in @code{B}, and code
4296like:
4297
4298@smallexample
4299B* b;
4300b->f();
4301@end smallexample
4302
4303@noindent
4304fails to compile.
4305
d82490d5
JW
4306In cases where the different signatures are not an accident, the
4307simplest solution is to add a using-declaration to the derived class
4308to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4309
d77de738
ML
4310The optional level suffix controls the behavior when all the
4311declarations in the derived class override virtual functions in the
4312base class, even if not all of the base functions are overridden:
4313
4314@smallexample
4315struct C @{
4316 virtual void f();
4317 virtual void f(int);
4318@};
4319
4320struct D: public C @{
4321 void f(int); // does override
4322@}
4323@end smallexample
4324
4325This pattern is less likely to be a mistake; if D is only used
4326virtually, the user might have decided that the base class semantics
4327for some of the overloads are fine.
4328
4329At level 1, this case does not warn; at level 2, it does.
4330@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4331included in @option{-Wall}.
4332
d77de738
ML
4333@opindex Wno-pmf-conversions
4334@opindex Wpmf-conversions
ddf6fe37 4335@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
d77de738
ML
4336Disable the diagnostic for converting a bound pointer to member function
4337to a plain pointer.
4338
d77de738
ML
4339@opindex Wsign-promo
4340@opindex Wno-sign-promo
ddf6fe37 4341@item -Wsign-promo @r{(C++ and Objective-C++ only)}
d77de738
ML
4342Warn when overload resolution chooses a promotion from unsigned or
4343enumerated type to a signed type, over a conversion to an unsigned type of
4344the same size. Previous versions of G++ tried to preserve
4345unsignedness, but the standard mandates the current behavior.
4346
d77de738
ML
4347@opindex Wtemplates
4348@opindex Wno-templates
ddf6fe37 4349@item -Wtemplates @r{(C++ and Objective-C++ only)}
d77de738
ML
4350Warn when a primary template declaration is encountered. Some coding
4351rules disallow templates, and this may be used to enforce that rule.
4352The warning is inactive inside a system header file, such as the STL, so
4353one can still use the STL. One may also instantiate or specialize
4354templates.
4355
d77de738
ML
4356@opindex Wmismatched-new-delete
4357@opindex Wno-mismatched-new-delete
ddf6fe37 4358@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
d77de738
ML
4359Warn for mismatches between calls to @code{operator new} or @code{operator
4360delete} and the corresponding call to the allocation or deallocation function.
4361This includes invocations of C++ @code{operator delete} with pointers
4362returned from either mismatched forms of @code{operator new}, or from other
4363functions that allocate objects for which the @code{operator delete} isn't
4364a suitable deallocator, as well as calls to other deallocation functions
4365with pointers returned from @code{operator new} for which the deallocation
4366function isn't suitable.
4367
4368For example, the @code{delete} expression in the function below is diagnosed
4369because it doesn't match the array form of the @code{new} expression
4370the pointer argument was returned from. Similarly, the call to @code{free}
4371is also diagnosed.
4372
4373@smallexample
4374void f ()
4375@{
4376 int *a = new int[n];
4377 delete a; // warning: mismatch in array forms of expressions
4378
4379 char *p = new char[n];
4380 free (p); // warning: mismatch between new and free
4381@}
4382@end smallexample
4383
4384The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4385involving allocation and deallocation functions other than @code{operator
4386new} and @code{operator delete}.
4387
4388@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4389
d77de738
ML
4390@opindex Wmismatched-tags
4391@opindex Wno-mismatched-tags
ddf6fe37 4392@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4393Warn for declarations of structs, classes, and class templates and their
4394specializations with a class-key that does not match either the definition
4395or the first declaration if no definition is provided.
4396
4397For example, the declaration of @code{struct Object} in the argument list
4398of @code{draw} triggers the warning. To avoid it, either remove the redundant
4399class-key @code{struct} or replace it with @code{class} to match its definition.
4400@smallexample
4401class Object @{
4402public:
4403 virtual ~Object () = 0;
4404@};
4405void draw (struct Object*);
4406@end smallexample
4407
4408It is not wrong to declare a class with the class-key @code{struct} as
4409the example above shows. The @option{-Wmismatched-tags} option is intended
4410to help achieve a consistent style of class declarations. In code that is
4411intended to be portable to Windows-based compilers the warning helps prevent
4412unresolved references due to the difference in the mangling of symbols
4413declared with different class-keys. The option can be used either on its
4414own or in conjunction with @option{-Wredundant-tags}.
4415
d77de738
ML
4416@opindex Wmultiple-inheritance
4417@opindex Wno-multiple-inheritance
ddf6fe37 4418@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
d77de738
ML
4419Warn when a class is defined with multiple direct base classes. Some
4420coding rules disallow multiple inheritance, and this may be used to
4421enforce that rule. The warning is inactive inside a system header file,
4422such as the STL, so one can still use the STL. One may also define
4423classes that indirectly use multiple inheritance.
4424
d77de738
ML
4425@opindex Wvirtual-inheritance
4426@opindex Wno-virtual-inheritance
ddf6fe37 4427@item -Wvirtual-inheritance
d77de738
ML
4428Warn when a class is defined with a virtual direct base class. Some
4429coding rules disallow multiple inheritance, and this may be used to
4430enforce that rule. The warning is inactive inside a system header file,
4431such as the STL, so one can still use the STL. One may also define
4432classes that indirectly use virtual inheritance.
4433
d77de738
ML
4434@opindex Wvirtual-move-assign
4435@opindex Wno-virtual-move-assign
ddf6fe37 4436@item -Wno-virtual-move-assign
d77de738
ML
4437Suppress warnings about inheriting from a virtual base with a
4438non-trivial C++11 move assignment operator. This is dangerous because
4439if the virtual base is reachable along more than one path, it is
4440moved multiple times, which can mean both objects end up in the
4441moved-from state. If the move assignment operator is written to avoid
4442moving from a moved-from object, this warning can be disabled.
4443
d77de738
ML
4444@opindex Wnamespaces
4445@opindex Wno-namespaces
ddf6fe37 4446@item -Wnamespaces
d77de738
ML
4447Warn when a namespace definition is opened. Some coding rules disallow
4448namespaces, and this may be used to enforce that rule. The warning is
4449inactive inside a system header file, such as the STL, so one can still
4450use the STL. One may also use using directives and qualified names.
4451
d77de738
ML
4452@opindex Wterminate
4453@opindex Wno-terminate
ddf6fe37 4454@item -Wno-terminate @r{(C++ and Objective-C++ only)}
d77de738
ML
4455Disable the warning about a throw-expression that will immediately
4456result in a call to @code{terminate}.
4457
d77de738
ML
4458@opindex Wvexing-parse
4459@opindex Wno-vexing-parse
ddf6fe37 4460@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
d77de738
ML
4461Warn about the most vexing parse syntactic ambiguity. This warns about
4462the cases when a declaration looks like a variable definition, but the
4463C++ language requires it to be interpreted as a function declaration.
4464For instance:
4465
4466@smallexample
4467void f(double a) @{
4468 int i(); // extern int i (void);
4469 int n(int(a)); // extern int n (int);
4470@}
4471@end smallexample
4472
4473Another example:
4474
4475@smallexample
4476struct S @{ S(int); @};
4477void f(double a) @{
4478 S x(int(a)); // extern struct S x (int);
4479 S y(int()); // extern struct S y (int (*) (void));
4480 S z(); // extern struct S z (void);
4481@}
4482@end smallexample
4483
4484The warning will suggest options how to deal with such an ambiguity; e.g.,
4485it can suggest removing the parentheses or using braces instead.
4486
4487This warning is enabled by default.
4488
d77de738
ML
4489@opindex Wno-class-conversion
4490@opindex Wclass-conversion
ddf6fe37 4491@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
4492Do not warn when a conversion function converts an
4493object to the same type, to a base class of that type, or to void; such
4494a conversion function will never be called.
4495
d77de738
ML
4496@opindex Wvolatile
4497@opindex Wno-volatile
ddf6fe37 4498@item -Wvolatile @r{(C++ and Objective-C++ only)}
d77de738
ML
4499Warn about deprecated uses of the @code{volatile} qualifier. This includes
4500postfix and prefix @code{++} and @code{--} expressions of
4501@code{volatile}-qualified types, using simple assignments where the left
4502operand is a @code{volatile}-qualified non-class type for their value,
4503compound assignments where the left operand is a @code{volatile}-qualified
4504non-class type, @code{volatile}-qualified function return type,
4505@code{volatile}-qualified parameter type, and structured bindings of a
4506@code{volatile}-qualified type. This usage was deprecated in C++20.
4507
4508Enabled by default with @option{-std=c++20}.
4509
d77de738
ML
4510@opindex Wzero-as-null-pointer-constant
4511@opindex Wno-zero-as-null-pointer-constant
ddf6fe37 4512@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
d77de738
ML
4513Warn when a literal @samp{0} is used as null pointer constant. This can
4514be useful to facilitate the conversion to @code{nullptr} in C++11.
4515
d77de738
ML
4516@opindex Waligned-new
4517@opindex Wno-aligned-new
ddf6fe37 4518@item -Waligned-new
d77de738
ML
4519Warn about a new-expression of a type that requires greater alignment
4520than the @code{alignof(std::max_align_t)} but uses an allocation
4521function without an explicit alignment parameter. This option is
4522enabled by @option{-Wall}.
4523
4524Normally this only warns about global allocation functions, but
4525@option{-Waligned-new=all} also warns about class member allocation
4526functions.
4527
d77de738
ML
4528@opindex Wplacement-new
4529@opindex Wno-placement-new
ddf6fe37
AA
4530@item -Wno-placement-new
4531@itemx -Wplacement-new=@var{n}
d77de738
ML
4532Warn about placement new expressions with undefined behavior, such as
4533constructing an object in a buffer that is smaller than the type of
4534the object. For example, the placement new expression below is diagnosed
4535because it attempts to construct an array of 64 integers in a buffer only
453664 bytes large.
4537@smallexample
4538char buf [64];
4539new (buf) int[64];
4540@end smallexample
4541This warning is enabled by default.
4542
4543@table @gcctabopt
4544@item -Wplacement-new=1
4545This is the default warning level of @option{-Wplacement-new}. At this
4546level the warning is not issued for some strictly undefined constructs that
4547GCC allows as extensions for compatibility with legacy code. For example,
4548the following @code{new} expression is not diagnosed at this level even
4549though it has undefined behavior according to the C++ standard because
4550it writes past the end of the one-element array.
4551@smallexample
4552struct S @{ int n, a[1]; @};
4553S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4554new (s->a)int [32]();
4555@end smallexample
4556
4557@item -Wplacement-new=2
4558At this level, in addition to diagnosing all the same constructs as at level
45591, a diagnostic is also issued for placement new expressions that construct
4560an object in the last member of structure whose type is an array of a single
4561element and whose size is less than the size of the object being constructed.
4562While the previous example would be diagnosed, the following construct makes
4563use of the flexible member array extension to avoid the warning at level 2.
4564@smallexample
4565struct S @{ int n, a[]; @};
4566S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4567new (s->a)int [32]();
4568@end smallexample
4569
4570@end table
4571
d77de738
ML
4572@opindex Wcatch-value
4573@opindex Wno-catch-value
ddf6fe37
AA
4574@item -Wcatch-value
4575@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
d77de738
ML
4576Warn about catch handlers that do not catch via reference.
4577With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4578warn about polymorphic class types that are caught by value.
4579With @option{-Wcatch-value=2} warn about all class types that are caught
4580by value. With @option{-Wcatch-value=3} warn about all types that are
4581not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4582
d77de738
ML
4583@opindex Wconditionally-supported
4584@opindex Wno-conditionally-supported
ddf6fe37 4585@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
d77de738
ML
4586Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4587
d77de738
ML
4588@opindex Wdelete-incomplete
4589@opindex Wno-delete-incomplete
ddf6fe37 4590@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
d77de738
ML
4591Do not warn when deleting a pointer to incomplete type, which may cause
4592undefined behavior at runtime. This warning is enabled by default.
4593
d77de738
ML
4594@opindex Wextra-semi
4595@opindex Wno-extra-semi
ddf6fe37 4596@item -Wextra-semi @r{(C++, Objective-C++ only)}
d77de738
ML
4597Warn about redundant semicolons after in-class function definitions.
4598
d77de738
ML
4599@opindex Winaccessible-base
4600@opindex Wno-inaccessible-base
ddf6fe37 4601@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
d77de738
ML
4602This option controls warnings
4603when a base class is inaccessible in a class derived from it due to
4604ambiguity. The warning is enabled by default.
4605Note that the warning for ambiguous virtual
4606bases is enabled by the @option{-Wextra} option.
4607@smallexample
4608@group
4609struct A @{ int a; @};
4610
4611struct B : A @{ @};
4612
4613struct C : B, A @{ @};
4614@end group
4615@end smallexample
4616
d77de738
ML
4617@opindex Winherited-variadic-ctor
4618@opindex Wno-inherited-variadic-ctor
ddf6fe37 4619@item -Wno-inherited-variadic-ctor
d77de738
ML
4620Suppress warnings about use of C++11 inheriting constructors when the
4621base class inherited from has a C variadic constructor; the warning is
4622on by default because the ellipsis is not inherited.
4623
d77de738
ML
4624@opindex Wno-invalid-offsetof
4625@opindex Winvalid-offsetof
ddf6fe37 4626@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
d77de738
ML
4627Suppress warnings from applying the @code{offsetof} macro to a non-POD
4628type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4629to a non-standard-layout type is undefined. In existing C++ implementations,
4630however, @code{offsetof} typically gives meaningful results.
4631This flag is for users who are aware that they are
4632writing nonportable code and who have deliberately chosen to ignore the
4633warning about it.
4634
4635The restrictions on @code{offsetof} may be relaxed in a future version
4636of the C++ standard.
4637
d77de738
ML
4638@opindex Wsized-deallocation
4639@opindex Wno-sized-deallocation
ddf6fe37 4640@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
d77de738
ML
4641Warn about a definition of an unsized deallocation function
4642@smallexample
4643void operator delete (void *) noexcept;
4644void operator delete[] (void *) noexcept;
4645@end smallexample
4646without a definition of the corresponding sized deallocation function
4647@smallexample
4648void operator delete (void *, std::size_t) noexcept;
4649void operator delete[] (void *, std::size_t) noexcept;
4650@end smallexample
4651or vice versa. Enabled by @option{-Wextra} along with
4652@option{-fsized-deallocation}.
4653
d77de738
ML
4654@opindex Wno-suggest-final-types
4655@opindex Wsuggest-final-types
ddf6fe37 4656@item -Wsuggest-final-types
d77de738
ML
4657Warn about types with virtual methods where code quality would be improved
4658if the type were declared with the C++11 @code{final} specifier,
4659or, if possible,
4660declared in an anonymous namespace. This allows GCC to more aggressively
4661devirtualize the polymorphic calls. This warning is more effective with
4662link-time optimization,
4663where the information about the class hierarchy graph is
4664more complete.
4665
d77de738
ML
4666@opindex Wno-suggest-final-methods
4667@opindex Wsuggest-final-methods
ddf6fe37 4668@item -Wsuggest-final-methods
d77de738
ML
4669Warn about virtual methods where code quality would be improved if the method
4670were declared with the C++11 @code{final} specifier,
4671or, if possible, its type were
4672declared in an anonymous namespace or with the @code{final} specifier.
4673This warning is
4674more effective with link-time optimization, where the information about the
4675class hierarchy graph is more complete. It is recommended to first consider
4676suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4677annotations.
4678
d77de738
ML
4679@opindex Wsuggest-override
4680@opindex Wno-suggest-override
ddf6fe37 4681@item -Wsuggest-override
d77de738
ML
4682Warn about overriding virtual functions that are not marked with the
4683@code{override} keyword.
4684
d77de738
ML
4685@opindex Wuse-after-free
4686@opindex Wno-use-after-free
ddf6fe37
AA
4687@item -Wuse-after-free
4688@itemx -Wuse-after-free=@var{n}
d77de738
ML
4689Warn about uses of pointers to dynamically allocated objects that have
4690been rendered indeterminate by a call to a deallocation function.
4691The warning is enabled at all optimization levels but may yield different
4692results with optimization than without.
4693
4694@table @gcctabopt
4695@item -Wuse-after-free=1
4696At level 1 the warning attempts to diagnose only unconditional uses
4697of pointers made indeterminate by a deallocation call or a successful
4698call to @code{realloc}, regardless of whether or not the call resulted
4699in an actual reallocatio of memory. This includes double-@code{free}
4700calls as well as uses in arithmetic and relational expressions. Although
4701undefined, uses of indeterminate pointers in equality (or inequality)
4702expressions are not diagnosed at this level.
4703@item -Wuse-after-free=2
4704At level 2, in addition to unconditional uses, the warning also diagnoses
4705conditional uses of pointers made indeterminate by a deallocation call.
4706As at level 2, uses in equality (or inequality) expressions are not
4707diagnosed. For example, the second call to @code{free} in the following
4708function is diagnosed at this level:
4709@smallexample
4710struct A @{ int refcount; void *data; @};
4711
4712void release (struct A *p)
4713@{
4714 int refcount = --p->refcount;
4715 free (p);
4716 if (refcount == 0)
4717 free (p->data); // warning: p may be used after free
4718@}
4719@end smallexample
4720@item -Wuse-after-free=3
4721At level 3, the warning also diagnoses uses of indeterminate pointers in
4722equality expressions. All uses of indeterminate pointers are undefined
4723but equality tests sometimes appear after calls to @code{realloc} as
4724an attempt to determine whether the call resulted in relocating the object
4725to a different address. They are diagnosed at a separate level to aid
4726legacy code gradually transition to safe alternatives. For example,
4727the equality test in the function below is diagnosed at this level:
4728@smallexample
4729void adjust_pointers (int**, int);
4730
4731void grow (int **p, int n)
4732@{
4733 int **q = (int**)realloc (p, n *= 2);
4734 if (q == p)
4735 return;
4736 adjust_pointers ((int**)q, n);
4737@}
4738@end smallexample
4739To avoid the warning at this level, store offsets into allocated memory
4740instead of pointers. This approach obviates needing to adjust the stored
4741pointers after reallocation.
4742@end table
4743
4744@option{-Wuse-after-free=2} is included in @option{-Wall}.
4745
d77de738
ML
4746@opindex Wuseless-cast
4747@opindex Wno-useless-cast
ddf6fe37 4748@item -Wuseless-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4749Warn when an expression is cast to its own type. This warning does not
4750occur when a class object is converted to a non-reference type as that
4751is a way to create a temporary:
4752
4753@smallexample
4754struct S @{ @};
4755void g (S&&);
4756void f (S&& arg)
4757@{
4758 g (S(arg)); // make arg prvalue so that it can bind to S&&
4759@}
4760@end smallexample
4761
d77de738
ML
4762@opindex Wconversion-null
4763@opindex Wno-conversion-null
ddf6fe37 4764@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
d77de738
ML
4765Do not warn for conversions between @code{NULL} and non-pointer
4766types. @option{-Wconversion-null} is enabled by default.
4767
4768@end table
4769
4770@node Objective-C and Objective-C++ Dialect Options
4771@section Options Controlling Objective-C and Objective-C++ Dialects
4772
4773@cindex compiler options, Objective-C and Objective-C++
4774@cindex Objective-C and Objective-C++ options, command-line
4775@cindex options, Objective-C and Objective-C++
4776(NOTE: This manual does not describe the Objective-C and Objective-C++
4777languages themselves. @xref{Standards,,Language Standards
4778Supported by GCC}, for references.)
4779
4780This section describes the command-line options that are only meaningful
4781for Objective-C and Objective-C++ programs. You can also use most of
4782the language-independent GNU compiler options.
4783For example, you might compile a file @file{some_class.m} like this:
4784
4785@smallexample
4786gcc -g -fgnu-runtime -O -c some_class.m
4787@end smallexample
4788
4789@noindent
4790In this example, @option{-fgnu-runtime} is an option meant only for
4791Objective-C and Objective-C++ programs; you can use the other options with
4792any language supported by GCC@.
4793
4794Note that since Objective-C is an extension of the C language, Objective-C
4795compilations may also use options specific to the C front-end (e.g.,
4796@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4797C++-specific options (e.g., @option{-Wabi}).
4798
4799Here is a list of options that are @emph{only} for compiling Objective-C
4800and Objective-C++ programs:
4801
4802@table @gcctabopt
d77de738 4803@opindex fconstant-string-class
ddf6fe37 4804@item -fconstant-string-class=@var{class-name}
d77de738
ML
4805Use @var{class-name} as the name of the class to instantiate for each
4806literal string specified with the syntax @code{@@"@dots{}"}. The default
4807class name is @code{NXConstantString} if the GNU runtime is being used, and
4808@code{NSConstantString} if the NeXT runtime is being used (see below). The
4809@option{-fconstant-cfstrings} option, if also present, overrides the
4810@option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4811to be laid out as constant CoreFoundation strings.
4812
d77de738 4813@opindex fgnu-runtime
ddf6fe37 4814@item -fgnu-runtime
d77de738
ML
4815Generate object code compatible with the standard GNU Objective-C
4816runtime. This is the default for most types of systems.
4817
d77de738 4818@opindex fnext-runtime
ddf6fe37 4819@item -fnext-runtime
d77de738
ML
4820Generate output compatible with the NeXT runtime. This is the default
4821for NeXT-based systems, including Darwin and Mac OS X@. The macro
4822@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4823used.
4824
d77de738
ML
4825@opindex fno-nil-receivers
4826@opindex fnil-receivers
ddf6fe37 4827@item -fno-nil-receivers
d77de738
ML
4828Assume that all Objective-C message dispatches (@code{[receiver
4829message:arg]}) in this translation unit ensure that the receiver is
4830not @code{nil}. This allows for more efficient entry points in the
4831runtime to be used. This option is only available in conjunction with
4832the NeXT runtime and ABI version 0 or 1.
4833
d77de738 4834@opindex fobjc-abi-version
ddf6fe37 4835@item -fobjc-abi-version=@var{n}
d77de738
ML
4836Use version @var{n} of the Objective-C ABI for the selected runtime.
4837This option is currently supported only for the NeXT runtime. In that
4838case, Version 0 is the traditional (32-bit) ABI without support for
4839properties and other Objective-C 2.0 additions. Version 1 is the
4840traditional (32-bit) ABI with support for properties and other
4841Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4842nothing is specified, the default is Version 0 on 32-bit target
4843machines, and Version 2 on 64-bit target machines.
4844
d77de738 4845@opindex fobjc-call-cxx-cdtors
ddf6fe37 4846@item -fobjc-call-cxx-cdtors
d77de738
ML
4847For each Objective-C class, check if any of its instance variables is a
4848C++ object with a non-trivial default constructor. If so, synthesize a
4849special @code{- (id) .cxx_construct} instance method which runs
4850non-trivial default constructors on any such instance variables, in order,
4851and then return @code{self}. Similarly, check if any instance variable
4852is a C++ object with a non-trivial destructor, and if so, synthesize a
4853special @code{- (void) .cxx_destruct} method which runs
4854all such default destructors, in reverse order.
4855
4856The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4857methods thusly generated only operate on instance variables
4858declared in the current Objective-C class, and not those inherited
4859from superclasses. It is the responsibility of the Objective-C
4860runtime to invoke all such methods in an object's inheritance
4861hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4862by the runtime immediately after a new object instance is allocated;
4863the @code{- (void) .cxx_destruct} methods are invoked immediately
4864before the runtime deallocates an object instance.
4865
4866As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4867support for invoking the @code{- (id) .cxx_construct} and
4868@code{- (void) .cxx_destruct} methods.
4869
d77de738 4870@opindex fobjc-direct-dispatch
ddf6fe37 4871@item -fobjc-direct-dispatch
d77de738
ML
4872Allow fast jumps to the message dispatcher. On Darwin this is
4873accomplished via the comm page.
4874
d77de738 4875@opindex fobjc-exceptions
ddf6fe37 4876@item -fobjc-exceptions
d77de738
ML
4877Enable syntactic support for structured exception handling in
4878Objective-C, similar to what is offered by C++. This option
4879is required to use the Objective-C keywords @code{@@try},
4880@code{@@throw}, @code{@@catch}, @code{@@finally} and
4881@code{@@synchronized}. This option is available with both the GNU
4882runtime and the NeXT runtime (but not available in conjunction with
4883the NeXT runtime on Mac OS X 10.2 and earlier).
4884
d77de738 4885@opindex fobjc-gc
ddf6fe37 4886@item -fobjc-gc
d77de738
ML
4887Enable garbage collection (GC) in Objective-C and Objective-C++
4888programs. This option is only available with the NeXT runtime; the
4889GNU runtime has a different garbage collection implementation that
4890does not require special compiler flags.
4891
d77de738 4892@opindex fobjc-nilcheck
ddf6fe37 4893@item -fobjc-nilcheck
d77de738
ML
4894For the NeXT runtime with version 2 of the ABI, check for a nil
4895receiver in method invocations before doing the actual method call.
4896This is the default and can be disabled using
4897@option{-fno-objc-nilcheck}. Class methods and super calls are never
4898checked for nil in this way no matter what this flag is set to.
4899Currently this flag does nothing when the GNU runtime, or an older
4900version of the NeXT runtime ABI, is used.
4901
d77de738 4902@opindex fobjc-std
ddf6fe37 4903@item -fobjc-std=objc1
d77de738
ML
4904Conform to the language syntax of Objective-C 1.0, the language
4905recognized by GCC 4.0. This only affects the Objective-C additions to
4906the C/C++ language; it does not affect conformance to C/C++ standards,
4907which is controlled by the separate C/C++ dialect option flags. When
4908this option is used with the Objective-C or Objective-C++ compiler,
4909any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4910This is useful if you need to make sure that your Objective-C code can
4911be compiled with older versions of GCC@.
4912
d77de738 4913@opindex freplace-objc-classes
ddf6fe37 4914@item -freplace-objc-classes
d77de738
ML
4915Emit a special marker instructing @command{ld(1)} not to statically link in
4916the resulting object file, and allow @command{dyld(1)} to load it in at
4917run time instead. This is used in conjunction with the Fix-and-Continue
4918debugging mode, where the object file in question may be recompiled and
4919dynamically reloaded in the course of program execution, without the need
4920to restart the program itself. Currently, Fix-and-Continue functionality
4921is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4922and later.
4923
d77de738 4924@opindex fzero-link
ddf6fe37 4925@item -fzero-link
d77de738
ML
4926When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4927to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4928compile time) with static class references that get initialized at load time,
4929which improves run-time performance. Specifying the @option{-fzero-link} flag
4930suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4931to be retained. This is useful in Zero-Link debugging mode, since it allows
4932for individual class implementations to be modified during program execution.
4933The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4934regardless of command-line options.
4935
d77de738
ML
4936@opindex fno-local-ivars
4937@opindex flocal-ivars
ddf6fe37 4938@item -fno-local-ivars
d77de738
ML
4939By default instance variables in Objective-C can be accessed as if
4940they were local variables from within the methods of the class they're
4941declared in. This can lead to shadowing between instance variables
4942and other variables declared either locally inside a class method or
4943globally with the same name. Specifying the @option{-fno-local-ivars}
4944flag disables this behavior thus avoiding variable shadowing issues.
4945
d77de738 4946@opindex fivar-visibility
ddf6fe37 4947@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
d77de738
ML
4948Set the default instance variable visibility to the specified option
4949so that instance variables declared outside the scope of any access
4950modifier directives default to the specified visibility.
4951
d77de738 4952@opindex gen-decls
ddf6fe37 4953@item -gen-decls
d77de738
ML
4954Dump interface declarations for all classes seen in the source file to a
4955file named @file{@var{sourcename}.decl}.
4956
d77de738
ML
4957@opindex Wassign-intercept
4958@opindex Wno-assign-intercept
ddf6fe37 4959@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4960Warn whenever an Objective-C assignment is being intercepted by the
4961garbage collector.
4962
d77de738
ML
4963@opindex Wproperty-assign-default
4964@opindex Wno-property-assign-default
ddf6fe37 4965@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4966Do not warn if a property for an Objective-C object has no assign
4967semantics specified.
4968
d77de738
ML
4969@opindex Wno-protocol
4970@opindex Wprotocol
ddf6fe37 4971@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4972If a class is declared to implement a protocol, a warning is issued for
4973every method in the protocol that is not implemented by the class. The
4974default behavior is to issue a warning for every method not explicitly
4975implemented in the class, even if a method implementation is inherited
4976from the superclass. If you use the @option{-Wno-protocol} option, then
4977methods inherited from the superclass are considered to be implemented,
4978and no warning is issued for them.
4979
d77de738 4980@opindex Wobjc-root-class
ddf6fe37 4981@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4982Warn if a class interface lacks a superclass. Most classes will inherit
4983from @code{NSObject} (or @code{Object}) for example. When declaring
4984classes intended to be root classes, the warning can be suppressed by
4985marking their interfaces with @code{__attribute__((objc_root_class))}.
4986
d77de738
ML
4987@opindex Wselector
4988@opindex Wno-selector
ddf6fe37 4989@item -Wselector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4990Warn if multiple methods of different types for the same selector are
4991found during compilation. The check is performed on the list of methods
4992in the final stage of compilation. Additionally, a check is performed
4993for each selector appearing in a @code{@@selector(@dots{})}
4994expression, and a corresponding method for that selector has been found
4995during compilation. Because these checks scan the method table only at
4996the end of compilation, these warnings are not produced if the final
4997stage of compilation is not reached, for example because an error is
4998found during compilation, or because the @option{-fsyntax-only} option is
4999being used.
5000
d77de738
ML
5001@opindex Wstrict-selector-match
5002@opindex Wno-strict-selector-match
ddf6fe37 5003@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5004Warn if multiple methods with differing argument and/or return types are
5005found for a given selector when attempting to send a message using this
5006selector to a receiver of type @code{id} or @code{Class}. When this flag
5007is off (which is the default behavior), the compiler omits such warnings
5008if any differences found are confined to types that share the same size
5009and alignment.
5010
d77de738
ML
5011@opindex Wundeclared-selector
5012@opindex Wno-undeclared-selector
ddf6fe37 5013@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5014Warn if a @code{@@selector(@dots{})} expression referring to an
5015undeclared selector is found. A selector is considered undeclared if no
5016method with that name has been declared before the
5017@code{@@selector(@dots{})} expression, either explicitly in an
5018@code{@@interface} or @code{@@protocol} declaration, or implicitly in
5019an @code{@@implementation} section. This option always performs its
5020checks as soon as a @code{@@selector(@dots{})} expression is found,
5021while @option{-Wselector} only performs its checks in the final stage of
5022compilation. This also enforces the coding style convention
5023that methods and selectors must be declared before being used.
5024
d77de738 5025@opindex print-objc-runtime-info
ddf6fe37 5026@item -print-objc-runtime-info
d77de738
ML
5027Generate C header describing the largest structure that is passed by
5028value, if any.
5029
5030@end table
5031
5032@node Diagnostic Message Formatting Options
5033@section Options to Control Diagnostic Messages Formatting
5034@cindex options to control diagnostics formatting
5035@cindex diagnostic messages
5036@cindex message formatting
5037
5038Traditionally, diagnostic messages have been formatted irrespective of
5039the output device's aspect (e.g.@: its width, @dots{}). You can use the
5040options described below
5041to control the formatting algorithm for diagnostic messages,
5042e.g.@: how many characters per line, how often source location
5043information should be reported. Note that some language front ends may not
5044honor these options.
5045
5046@table @gcctabopt
d77de738 5047@opindex fmessage-length
ddf6fe37 5048@item -fmessage-length=@var{n}
d77de738
ML
5049Try to format error messages so that they fit on lines of about
5050@var{n} characters. If @var{n} is zero, then no line-wrapping is
5051done; each error message appears on a single line. This is the
5052default for all front ends.
5053
5054Note - this option also affects the display of the @samp{#error} and
5055@samp{#warning} pre-processor directives, and the @samp{deprecated}
5056function/type/variable attribute. It does not however affect the
5057@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5058
5059@item -fdiagnostics-plain-output
5060This option requests that diagnostic output look as plain as possible, which
5061may be useful when running @command{dejagnu} or other utilities that need to
5062parse diagnostics output and prefer that it remain more stable over time.
5063@option{-fdiagnostics-plain-output} is currently equivalent to the following
5064options:
43b72ede
AA
5065@gccoptlist{-fno-diagnostics-show-caret
5066-fno-diagnostics-show-line-numbers
5067-fdiagnostics-color=never
5068-fdiagnostics-urls=never
d77de738
ML
5069-fdiagnostics-path-format=separate-events}
5070In the future, if GCC changes the default appearance of its diagnostics, the
5071corresponding option to disable the new behavior will be added to this list.
5072
d77de738 5073@opindex fdiagnostics-show-location
ddf6fe37 5074@item -fdiagnostics-show-location=once
d77de738
ML
5075Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5076reporter to emit source location information @emph{once}; that is, in
5077case the message is too long to fit on a single physical line and has to
5078be wrapped, the source location won't be emitted (as prefix) again,
5079over and over, in subsequent continuation lines. This is the default
5080behavior.
5081
5082@item -fdiagnostics-show-location=every-line
5083Only meaningful in line-wrapping mode. Instructs the diagnostic
5084messages reporter to emit the same source location information (as
5085prefix) for physical lines that result from the process of breaking
5086a message which is too long to fit on a single line.
5087
ddf6fe37 5088@opindex fdiagnostics-color
d77de738
ML
5089@cindex highlight, color
5090@vindex GCC_COLORS @r{environment variable}
f33d7a88
AA
5091@item -fdiagnostics-color[=@var{WHEN}]
5092@itemx -fno-diagnostics-color
d77de738
ML
5093Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5094or @samp{auto}. The default depends on how the compiler has been configured,
5095it can be any of the above @var{WHEN} options or also @samp{never}
5096if @env{GCC_COLORS} environment variable isn't present in the environment,
5097and @samp{auto} otherwise.
5098@samp{auto} makes GCC use color only when the standard error is a terminal,
5099and when not executing in an emacs shell.
5100The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5101aliases for @option{-fdiagnostics-color=always} and
5102@option{-fdiagnostics-color=never}, respectively.
5103
5104The colors are defined by the environment variable @env{GCC_COLORS}.
5105Its value is a colon-separated list of capabilities and Select Graphic
5106Rendition (SGR) substrings. SGR commands are interpreted by the
5107terminal or terminal emulator. (See the section in the documentation
5108of your text terminal for permitted values and their meanings as
5109character attributes.) These substring values are integers in decimal
5110representation and can be concatenated with semicolons.
5111Common values to concatenate include
5112@samp{1} for bold,
5113@samp{4} for underline,
5114@samp{5} for blink,
5115@samp{7} for inverse,
5116@samp{39} for default foreground color,
5117@samp{30} to @samp{37} for foreground colors,
5118@samp{90} to @samp{97} for 16-color mode foreground colors,
5119@samp{38;5;0} to @samp{38;5;255}
5120for 88-color and 256-color modes foreground colors,
5121@samp{49} for default background color,
5122@samp{40} to @samp{47} for background colors,
5123@samp{100} to @samp{107} for 16-color mode background colors,
5124and @samp{48;5;0} to @samp{48;5;255}
5125for 88-color and 256-color modes background colors.
5126
5127The default @env{GCC_COLORS} is
5128@smallexample
5129error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5130quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5131diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5132type-diff=01;32:fnname=01;32:targs=35
5133@end smallexample
5134@noindent
5135where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5136@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5137@samp{01} is bold, and @samp{31} is red.
5138Setting @env{GCC_COLORS} to the empty string disables colors.
5139Supported capabilities are as follows.
5140
5141@table @code
d77de738 5142@vindex error GCC_COLORS @r{capability}
f33d7a88 5143@item error=
d77de738
ML
5144SGR substring for error: markers.
5145
d77de738 5146@vindex warning GCC_COLORS @r{capability}
f33d7a88 5147@item warning=
d77de738
ML
5148SGR substring for warning: markers.
5149
d77de738 5150@vindex note GCC_COLORS @r{capability}
f33d7a88 5151@item note=
d77de738
ML
5152SGR substring for note: markers.
5153
d77de738 5154@vindex path GCC_COLORS @r{capability}
f33d7a88 5155@item path=
d77de738
ML
5156SGR substring for colorizing paths of control-flow events as printed
5157via @option{-fdiagnostics-path-format=}, such as the identifiers of
5158individual events and lines indicating interprocedural calls and returns.
5159
d77de738 5160@vindex range1 GCC_COLORS @r{capability}
f33d7a88 5161@item range1=
d77de738
ML
5162SGR substring for first additional range.
5163
d77de738 5164@vindex range2 GCC_COLORS @r{capability}
f33d7a88 5165@item range2=
d77de738
ML
5166SGR substring for second additional range.
5167
d77de738 5168@vindex locus GCC_COLORS @r{capability}
f33d7a88 5169@item locus=
d77de738
ML
5170SGR substring for location information, @samp{file:line} or
5171@samp{file:line:column} etc.
5172
d77de738 5173@vindex quote GCC_COLORS @r{capability}
f33d7a88 5174@item quote=
d77de738
ML
5175SGR substring for information printed within quotes.
5176
d77de738 5177@vindex fnname GCC_COLORS @r{capability}
f33d7a88 5178@item fnname=
d77de738
ML
5179SGR substring for names of C++ functions.
5180
d77de738 5181@vindex targs GCC_COLORS @r{capability}
f33d7a88 5182@item targs=
d77de738
ML
5183SGR substring for C++ function template parameter bindings.
5184
d77de738 5185@vindex fixit-insert GCC_COLORS @r{capability}
f33d7a88 5186@item fixit-insert=
d77de738
ML
5187SGR substring for fix-it hints suggesting text to
5188be inserted or replaced.
5189
d77de738 5190@vindex fixit-delete GCC_COLORS @r{capability}
f33d7a88 5191@item fixit-delete=
d77de738
ML
5192SGR substring for fix-it hints suggesting text to
5193be deleted.
5194
d77de738 5195@vindex diff-filename GCC_COLORS @r{capability}
f33d7a88 5196@item diff-filename=
d77de738
ML
5197SGR substring for filename headers within generated patches.
5198
d77de738 5199@vindex diff-hunk GCC_COLORS @r{capability}
f33d7a88 5200@item diff-hunk=
d77de738
ML
5201SGR substring for the starts of hunks within generated patches.
5202
d77de738 5203@vindex diff-delete GCC_COLORS @r{capability}
f33d7a88 5204@item diff-delete=
d77de738
ML
5205SGR substring for deleted lines within generated patches.
5206
d77de738 5207@vindex diff-insert GCC_COLORS @r{capability}
f33d7a88 5208@item diff-insert=
d77de738
ML
5209SGR substring for inserted lines within generated patches.
5210
d77de738 5211@vindex type-diff GCC_COLORS @r{capability}
f33d7a88 5212@item type-diff=
d77de738
ML
5213SGR substring for highlighting mismatching types within template
5214arguments in the C++ frontend.
5215@end table
5216
d77de738
ML
5217@opindex fdiagnostics-urls
5218@cindex urls
5219@vindex GCC_URLS @r{environment variable}
5220@vindex TERM_URLS @r{environment variable}
f33d7a88 5221@item -fdiagnostics-urls[=@var{WHEN}]
d77de738
ML
5222Use escape sequences to embed URLs in diagnostics. For example, when
5223@option{-fdiagnostics-show-option} emits text showing the command-line
5224option controlling a diagnostic, embed a URL for documentation of that
5225option.
5226
5227@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5228@samp{auto} makes GCC use URL escape sequences only when the standard error
5229is a terminal, and when not executing in an emacs shell or any graphical
5230terminal which is known to be incompatible with this feature, see below.
5231
5232The default depends on how the compiler has been configured.
5233It can be any of the above @var{WHEN} options.
5234
5235GCC can also be configured (via the
5236@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5237so that the default is affected by environment variables.
5238Under such a configuration, GCC defaults to using @samp{auto}
5239if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5240present and non-empty in the environment of the compiler, or @samp{never}
5241if neither are.
5242
5243However, even with @option{-fdiagnostics-urls=always} the behavior is
5244dependent on those environment variables:
5245If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5246diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5247If set to @samp{bel}, the default, URLs use BEL escape sequences.
5248Any other non-empty value enables the feature.
5249If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5250Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5251BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5252
5253At this time GCC tries to detect also a few terminals that are known to
5254not implement the URL feature, and have bugs or at least had bugs in
5255some versions that are still in use, where the URL escapes are likely
5256to misbehave, i.e. print garbage on the screen.
5257That list is currently xfce4-terminal, certain known to be buggy
5258gnome-terminal versions, the linux console, and mingw.
5259This check can be skipped with the @option{-fdiagnostics-urls=always}.
5260
d77de738
ML
5261@opindex fno-diagnostics-show-option
5262@opindex fdiagnostics-show-option
ddf6fe37 5263@item -fno-diagnostics-show-option
d77de738
ML
5264By default, each diagnostic emitted includes text indicating the
5265command-line option that directly controls the diagnostic (if such an
5266option is known to the diagnostic machinery). Specifying the
5267@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5268
d77de738
ML
5269@opindex fno-diagnostics-show-caret
5270@opindex fdiagnostics-show-caret
ddf6fe37 5271@item -fno-diagnostics-show-caret
d77de738
ML
5272By default, each diagnostic emitted includes the original source line
5273and a caret @samp{^} indicating the column. This option suppresses this
5274information. The source line is truncated to @var{n} characters, if
5275the @option{-fmessage-length=n} option is given. When the output is done
5276to the terminal, the width is limited to the width given by the
5277@env{COLUMNS} environment variable or, if not set, to the terminal width.
5278
d77de738
ML
5279@opindex fno-diagnostics-show-labels
5280@opindex fdiagnostics-show-labels
ddf6fe37 5281@item -fno-diagnostics-show-labels
d77de738
ML
5282By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5283diagnostics can label ranges of source code with pertinent information, such
5284as the types of expressions:
5285
5286@smallexample
5287 printf ("foo %s bar", long_i + long_j);
5288 ~^ ~~~~~~~~~~~~~~~
5289 | |
5290 char * long int
5291@end smallexample
5292
5293This option suppresses the printing of these labels (in the example above,
5294the vertical bars and the ``char *'' and ``long int'' text).
5295
d77de738
ML
5296@opindex fno-diagnostics-show-cwe
5297@opindex fdiagnostics-show-cwe
ddf6fe37 5298@item -fno-diagnostics-show-cwe
d77de738
ML
5299Diagnostic messages can optionally have an associated
5300@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5301GCC itself only provides such metadata for some of the @option{-fanalyzer}
5302diagnostics. GCC plugins may also provide diagnostics with such metadata.
5303By default, if this information is present, it will be printed with
5304the diagnostic. This option suppresses the printing of this metadata.
5305
d77de738
ML
5306@opindex fno-diagnostics-show-rules
5307@opindex fdiagnostics-show-rules
ddf6fe37 5308@item -fno-diagnostics-show-rules
d77de738
ML
5309Diagnostic messages can optionally have rules associated with them, such
5310as from a coding standard, or a specification.
5311GCC itself does not do this for any of its diagnostics, but plugins may do so.
5312By default, if this information is present, it will be printed with
5313the diagnostic. This option suppresses the printing of this metadata.
5314
d77de738
ML
5315@opindex fno-diagnostics-show-line-numbers
5316@opindex fdiagnostics-show-line-numbers
ddf6fe37 5317@item -fno-diagnostics-show-line-numbers
d77de738
ML
5318By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5319a left margin is printed, showing line numbers. This option suppresses this
5320left margin.
5321
d77de738 5322@opindex fdiagnostics-minimum-margin-width
ddf6fe37 5323@item -fdiagnostics-minimum-margin-width=@var{width}
d77de738
ML
5324This option controls the minimum width of the left margin printed by
5325@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5326
d77de738 5327@opindex fdiagnostics-parseable-fixits
ddf6fe37 5328@item -fdiagnostics-parseable-fixits
d77de738
ML
5329Emit fix-it hints in a machine-parseable format, suitable for consumption
5330by IDEs. For each fix-it, a line will be printed after the relevant
5331diagnostic, starting with the string ``fix-it:''. For example:
5332
5333@smallexample
5334fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5335@end smallexample
5336
5337The location is expressed as a half-open range, expressed as a count of
5338bytes, starting at byte 1 for the initial column. In the above example,
5339bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5340given string:
5341
5342@smallexample
534300000000011111111112222222222
534412345678901234567890123456789
5345 gtk_widget_showall (dlg);
5346 ^^^^^^^^^^^^^^^^^^
5347 gtk_widget_show_all
5348@end smallexample
5349
5350The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5351newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5352(e.g. vertical tab as ``\013'').
5353
5354An empty replacement string indicates that the given range is to be removed.
5355An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5356be inserted at the given position.
5357
d77de738 5358@opindex fdiagnostics-generate-patch
ddf6fe37 5359@item -fdiagnostics-generate-patch
d77de738
ML
5360Print fix-it hints to stderr in unified diff format, after any diagnostics
5361are printed. For example:
5362
5363@smallexample
5364--- test.c
5365+++ test.c
5366@@ -42,5 +42,5 @@
5367
5368 void show_cb(GtkDialog *dlg)
5369 @{
5370- gtk_widget_showall(dlg);
5371+ gtk_widget_show_all(dlg);
5372 @}
5373
5374@end smallexample
5375
5376The diff may or may not be colorized, following the same rules
5377as for diagnostics (see @option{-fdiagnostics-color}).
5378
d77de738 5379@opindex fdiagnostics-show-template-tree
ddf6fe37 5380@item -fdiagnostics-show-template-tree
d77de738
ML
5381
5382In the C++ frontend, when printing diagnostics showing mismatching
5383template types, such as:
5384
5385@smallexample
5386 could not convert 'std::map<int, std::vector<double> >()'
5387 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5388@end smallexample
5389
5390the @option{-fdiagnostics-show-template-tree} flag enables printing a
5391tree-like structure showing the common and differing parts of the types,
5392such as:
5393
5394@smallexample
5395 map<
5396 [...],
5397 vector<
5398 [double != float]>>
5399@end smallexample
5400
5401The parts that differ are highlighted with color (``double'' and
5402``float'' in this case).
5403
d77de738
ML
5404@opindex fno-elide-type
5405@opindex felide-type
ddf6fe37 5406@item -fno-elide-type
d77de738
ML
5407By default when the C++ frontend prints diagnostics showing mismatching
5408template types, common parts of the types are printed as ``[...]'' to
5409simplify the error message. For example:
5410
5411@smallexample
5412 could not convert 'std::map<int, std::vector<double> >()'
5413 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5414@end smallexample
5415
5416Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5417This flag also affects the output of the
5418@option{-fdiagnostics-show-template-tree} flag.
5419
d77de738 5420@opindex fdiagnostics-path-format
ddf6fe37 5421@item -fdiagnostics-path-format=@var{KIND}
d77de738
ML
5422Specify how to print paths of control-flow events for diagnostics that
5423have such a path associated with them.
5424
5425@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5426the default.
5427
5428@samp{none} means to not print diagnostic paths.
5429
5430@samp{separate-events} means to print a separate ``note'' diagnostic for
5431each event within the diagnostic. For example:
5432
5433@smallexample
5434test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5435test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5436test.c:27:3: note: (2) when 'i < count'
5437test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5438@end smallexample
5439
5440@samp{inline-events} means to print the events ``inline'' within the source
5441code. This view attempts to consolidate the events into runs of
5442sufficiently-close events, printing them as labelled ranges within the source.
5443
5444For example, the same events as above might be printed as:
5445
5446@smallexample
5447 'test': events 1-3
5448 |
5449 | 25 | list = PyList_New(0);
5450 | | ^~~~~~~~~~~~~
5451 | | |
5452 | | (1) when 'PyList_New' fails, returning NULL
5453 | 26 |
5454 | 27 | for (i = 0; i < count; i++) @{
5455 | | ~~~
5456 | | |
5457 | | (2) when 'i < count'
5458 | 28 | item = PyLong_FromLong(random());
5459 | 29 | PyList_Append(list, item);
5460 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5461 | | |
5462 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5463 |
5464@end smallexample
5465
5466Interprocedural control flow is shown by grouping the events by stack frame,
5467and using indentation to show how stack frames are nested, pushed, and popped.
5468
5469For example:
5470
5471@smallexample
5472 'test': events 1-2
5473 |
5474 | 133 | @{
5475 | | ^
5476 | | |
5477 | | (1) entering 'test'
5478 | 134 | boxed_int *obj = make_boxed_int (i);
5479 | | ~~~~~~~~~~~~~~~~~~
5480 | | |
5481 | | (2) calling 'make_boxed_int'
5482 |
5483 +--> 'make_boxed_int': events 3-4
5484 |
5485 | 120 | @{
5486 | | ^
5487 | | |
5488 | | (3) entering 'make_boxed_int'
5489 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5490 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5491 | | |
5492 | | (4) calling 'wrapped_malloc'
5493 |
5494 +--> 'wrapped_malloc': events 5-6
5495 |
5496 | 7 | @{
5497 | | ^
5498 | | |
5499 | | (5) entering 'wrapped_malloc'
5500 | 8 | return malloc (size);
5501 | | ~~~~~~~~~~~~~
5502 | | |
5503 | | (6) calling 'malloc'
5504 |
5505 <-------------+
5506 |
5507 'test': event 7
5508 |
5509 | 138 | free_boxed_int (obj);
5510 | | ^~~~~~~~~~~~~~~~~~~~
5511 | | |
5512 | | (7) calling 'free_boxed_int'
5513 |
5514(etc)
5515@end smallexample
5516
d77de738 5517@opindex fdiagnostics-show-path-depths
ddf6fe37 5518@item -fdiagnostics-show-path-depths
d77de738
ML
5519This option provides additional information when printing control-flow paths
5520associated with a diagnostic.
5521
5522If this is option is provided then the stack depth will be printed for
5523each run of events within @option{-fdiagnostics-path-format=inline-events}.
5524If provided with @option{-fdiagnostics-path-format=separate-events}, then
5525the stack depth and function declaration will be appended when printing
5526each event.
5527
5528This is intended for use by GCC developers and plugin developers when
5529debugging diagnostics that report interprocedural control flow.
5530
d77de738
ML
5531@opindex fno-show-column
5532@opindex fshow-column
ddf6fe37 5533@item -fno-show-column
d77de738
ML
5534Do not print column numbers in diagnostics. This may be necessary if
5535diagnostics are being scanned by a program that does not understand the
5536column numbers, such as @command{dejagnu}.
5537
d77de738 5538@opindex fdiagnostics-column-unit
ddf6fe37 5539@item -fdiagnostics-column-unit=@var{UNIT}
d77de738
ML
5540Select the units for the column number. This affects traditional diagnostics
5541(in the absence of @option{-fno-show-column}), as well as JSON format
5542diagnostics if requested.
5543
5544The default @var{UNIT}, @samp{display}, considers the number of display
5545columns occupied by each character. This may be larger than the number
5546of bytes required to encode the character, in the case of tab
5547characters, or it may be smaller, in the case of multibyte characters.
5548For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5549display column, and its UTF-8 encoding requires two bytes; the character
5550``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5551its UTF-8 encoding requires four bytes.
5552
5553Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5554count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5555
d77de738 5556@opindex fdiagnostics-column-origin
ddf6fe37 5557@item -fdiagnostics-column-origin=@var{ORIGIN}
d77de738
ML
5558Select the origin for column numbers, i.e. the column number assigned to the
5559first column. The default value of 1 corresponds to traditional GCC
5560behavior and to the GNU style guide. Some utilities may perform better with an
5561origin of 0; any non-negative value may be specified.
5562
d77de738 5563@opindex fdiagnostics-escape-format
ddf6fe37 5564@item -fdiagnostics-escape-format=@var{FORMAT}
d77de738
ML
5565When GCC prints pertinent source lines for a diagnostic it normally attempts
5566to print the source bytes directly. However, some diagnostics relate to encoding
5567issues in the source file, such as malformed UTF-8, or issues with Unicode
5568normalization. These diagnostics are flagged so that GCC will escape bytes
5569that are not printable ASCII when printing their pertinent source lines.
5570
5571This option controls how such bytes should be escaped.
5572
5573The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5574are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5575correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5576displayed as hexadecimal in the form @samp{<XX>}.
5577
5578For example, a source line containing the string @samp{before} followed by the
5579Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
55800xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5581the string @samp{after} will be printed for such a diagnostic as:
5582
5583@smallexample
5584 before<U+03C0><BF>after
5585@end smallexample
5586
5587Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5588in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5589Unicode characters. For the example above, the following will be printed:
5590
5591@smallexample
5592 before<CF><80><BF>after
5593@end smallexample
5594
d77de738 5595@opindex fdiagnostics-format
ddf6fe37 5596@item -fdiagnostics-format=@var{FORMAT}
d77de738
ML
5597Select a different format for printing diagnostics.
5598@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5599@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5600
5601The default is @samp{text}.
5602
5603The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5604diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5605named @file{@var{source}.sarif}, respectively.
5606
5607The @samp{json} format is a synonym for @samp{json-stderr}.
5608The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5609where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5610whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5611
5612The emitted JSON consists of a top-level JSON array containing JSON objects
5613representing the diagnostics. The JSON is emitted as one line, without
5614formatting; the examples below have been formatted for clarity.
5615
5616Diagnostics can have child diagnostics. For example, this error and note:
5617
5618@smallexample
5619misleading-indentation.c:15:3: warning: this 'if' clause does not
5620 guard... [-Wmisleading-indentation]
5621 15 | if (flag)
5622 | ^~
5623misleading-indentation.c:17:5: note: ...this statement, but the latter
5624 is misleadingly indented as if it were guarded by the 'if'
5625 17 | y = 2;
5626 | ^
5627@end smallexample
5628
5629@noindent
5630might be printed in JSON form (after formatting) like this:
5631
5632@smallexample
5633[
5634 @{
5635 "kind": "warning",
5636 "locations": [
5637 @{
5638 "caret": @{
5639 "display-column": 3,
5640 "byte-column": 3,
5641 "column": 3,
5642 "file": "misleading-indentation.c",
5643 "line": 15
5644 @},
5645 "finish": @{
5646 "display-column": 4,
5647 "byte-column": 4,
5648 "column": 4,
5649 "file": "misleading-indentation.c",
5650 "line": 15
5651 @}
5652 @}
5653 ],
5654 "message": "this \u2018if\u2019 clause does not guard...",
5655 "option": "-Wmisleading-indentation",
5656 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5657 "children": [
5658 @{
5659 "kind": "note",
5660 "locations": [
5661 @{
5662 "caret": @{
5663 "display-column": 5,
5664 "byte-column": 5,
5665 "column": 5,
5666 "file": "misleading-indentation.c",
5667 "line": 17
5668 @}
5669 @}
5670 ],
5671 "escape-source": false,
5672 "message": "...this statement, but the latter is @dots{}"
5673 @}
5674 ]
5675 "escape-source": false,
5676 "column-origin": 1,
5677 @}
5678]
5679@end smallexample
5680
5681@noindent
5682where the @code{note} is a child of the @code{warning}.
5683
5684A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5685an @code{option} key describing the command-line option controlling the
5686warning.
5687
5688A diagnostic can contain zero or more locations. Each location has an
5689optional @code{label} string and up to three positions within it: a
5690@code{caret} position and optional @code{start} and @code{finish} positions.
5691A position is described by a @code{file} name, a @code{line} number, and
5692three numbers indicating a column position:
5693@itemize @bullet
5694
5695@item
5696@code{display-column} counts display columns, accounting for tabs and
5697multibyte characters.
5698
5699@item
5700@code{byte-column} counts raw bytes.
5701
5702@item
5703@code{column} is equal to one of
5704the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5705option.
5706
5707@end itemize
5708All three columns are relative to the origin specified by
5709@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5710be set, for instance, to 0 for compatibility with other utilities that
5711number columns from 0. The column origin is recorded in the JSON output in
5712the @code{column-origin} tag. In the remaining examples below, the extra
5713column number outputs have been omitted for brevity.
5714
5715For example, this error:
5716
5717@smallexample
5718bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5719 'struct s'@} and 'T' @{aka 'struct t'@})
5720 64 | return callee_4a () + callee_4b ();
5721 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5722 | | |
5723 | | T @{aka struct t@}
5724 | S @{aka struct s@}
5725@end smallexample
5726
5727@noindent
5728has three locations. Its primary location is at the ``+'' token at column
572923. It has two secondary locations, describing the left and right-hand sides
5730of the expression, which have labels. It might be printed in JSON form as:
5731
5732@smallexample
5733 @{
5734 "children": [],
5735 "kind": "error",
5736 "locations": [
5737 @{
5738 "caret": @{
5739 "column": 23, "file": "bad-binary-ops.c", "line": 64
5740 @}
5741 @},
5742 @{
5743 "caret": @{
5744 "column": 10, "file": "bad-binary-ops.c", "line": 64
5745 @},
5746 "finish": @{
5747 "column": 21, "file": "bad-binary-ops.c", "line": 64
5748 @},
5749 "label": "S @{aka struct s@}"
5750 @},
5751 @{
5752 "caret": @{
5753 "column": 25, "file": "bad-binary-ops.c", "line": 64
5754 @},
5755 "finish": @{
5756 "column": 36, "file": "bad-binary-ops.c", "line": 64
5757 @},
5758 "label": "T @{aka struct t@}"
5759 @}
5760 ],
5761 "escape-source": false,
5762 "message": "invalid operands to binary + @dots{}"
5763 @}
5764@end smallexample
5765
5766If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5767consisting of half-open intervals, similar to the output of
5768@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5769with a replacement fix-it hint:
5770
5771@smallexample
5772demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5773 mean 'color'?
5774 8 | return ptr->colour;
5775 | ^~~~~~
5776 | color
5777@end smallexample
5778
5779@noindent
5780might be printed in JSON form as:
5781
5782@smallexample
5783 @{
5784 "children": [],
5785 "fixits": [
5786 @{
5787 "next": @{
5788 "column": 21,
5789 "file": "demo.c",
5790 "line": 8
5791 @},
5792 "start": @{
5793 "column": 15,
5794 "file": "demo.c",
5795 "line": 8
5796 @},
5797 "string": "color"
5798 @}
5799 ],
5800 "kind": "error",
5801 "locations": [
5802 @{
5803 "caret": @{
5804 "column": 15,
5805 "file": "demo.c",
5806 "line": 8
5807 @},
5808 "finish": @{
5809 "column": 20,
5810 "file": "demo.c",
5811 "line": 8
5812 @}
5813 @}
5814 ],
5815 "escape-source": false,
5816 "message": "\u2018struct s\u2019 has no member named @dots{}"
5817 @}
5818@end smallexample
5819
5820@noindent
5821where the fix-it hint suggests replacing the text from @code{start} up
5822to but not including @code{next} with @code{string}'s value. Deletions
5823are expressed via an empty value for @code{string}, insertions by
5824having @code{start} equal @code{next}.
5825
5826If the diagnostic has a path of control-flow events associated with it,
5827it has a @code{path} array of objects representing the events. Each
5828event object has a @code{description} string, a @code{location} object,
5829along with a @code{function} string and a @code{depth} number for
5830representing interprocedural paths. The @code{function} represents the
5831current function at that event, and the @code{depth} represents the
5832stack depth relative to some baseline: the higher, the more frames are
5833within the stack.
5834
5835For example, the intraprocedural example shown for
5836@option{-fdiagnostics-path-format=} might have this JSON for its path:
5837
5838@smallexample
5839 "path": [
5840 @{
5841 "depth": 0,
5842 "description": "when 'PyList_New' fails, returning NULL",
5843 "function": "test",
5844 "location": @{
5845 "column": 10,
5846 "file": "test.c",
5847 "line": 25
5848 @}
5849 @},
5850 @{
5851 "depth": 0,
5852 "description": "when 'i < count'",
5853 "function": "test",
5854 "location": @{
5855 "column": 3,
5856 "file": "test.c",
5857 "line": 27
5858 @}
5859 @},
5860 @{
5861 "depth": 0,
5862 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5863 "function": "test",
5864 "location": @{
5865 "column": 5,
5866 "file": "test.c",
5867 "line": 29
5868 @}
5869 @}
5870 ]
5871@end smallexample
5872
5873Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5874non-ASCII bytes should be escaped when printing the pertinent lines of
5875source code (@code{true} for diagnostics involving source encoding issues).
5876
5877@end table
5878
5879@node Warning Options
5880@section Options to Request or Suppress Warnings
5881@cindex options to control warnings
5882@cindex warning messages
5883@cindex messages, warning
5884@cindex suppressing warnings
5885
5886Warnings are diagnostic messages that report constructions that
5887are not inherently erroneous but that are risky or suggest there
5888may have been an error.
5889
5890The following language-independent options do not enable specific
5891warnings but control the kinds of diagnostics produced by GCC@.
5892
5893@table @gcctabopt
5894@cindex syntax checking
d77de738 5895@opindex fsyntax-only
ddf6fe37 5896@item -fsyntax-only
d77de738
ML
5897Check the code for syntax errors, but don't do anything beyond that.
5898
d77de738 5899@opindex fmax-errors
ddf6fe37 5900@item -fmax-errors=@var{n}
d77de738
ML
5901Limits the maximum number of error messages to @var{n}, at which point
5902GCC bails out rather than attempting to continue processing the source
5903code. If @var{n} is 0 (the default), there is no limit on the number
5904of error messages produced. If @option{-Wfatal-errors} is also
5905specified, then @option{-Wfatal-errors} takes precedence over this
5906option.
5907
d77de738 5908@opindex w
ddf6fe37 5909@item -w
d77de738
ML
5910Inhibit all warning messages.
5911
d77de738
ML
5912@opindex Werror
5913@opindex Wno-error
ddf6fe37 5914@item -Werror
d77de738
ML
5915Make all warnings into errors.
5916
d77de738
ML
5917@opindex Werror=
5918@opindex Wno-error=
ddf6fe37 5919@item -Werror=
d77de738
ML
5920Make the specified warning into an error. The specifier for a warning
5921is appended; for example @option{-Werror=switch} turns the warnings
5922controlled by @option{-Wswitch} into errors. This switch takes a
5923negative form, to be used to negate @option{-Werror} for specific
5924warnings; for example @option{-Wno-error=switch} makes
5925@option{-Wswitch} warnings not be errors, even when @option{-Werror}
5926is in effect.
5927
5928The warning message for each controllable warning includes the
5929option that controls the warning. That option can then be used with
5930@option{-Werror=} and @option{-Wno-error=} as described above.
5931(Printing of the option in the warning message can be disabled using the
5932@option{-fno-diagnostics-show-option} flag.)
5933
5934Note that specifying @option{-Werror=}@var{foo} automatically implies
5935@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5936imply anything.
5937
d77de738
ML
5938@opindex Wfatal-errors
5939@opindex Wno-fatal-errors
ddf6fe37 5940@item -Wfatal-errors
d77de738
ML
5941This option causes the compiler to abort compilation on the first error
5942occurred rather than trying to keep going and printing further error
5943messages.
5944
5945@end table
5946
5947You can request many specific warnings with options beginning with
5948@samp{-W}, for example @option{-Wimplicit} to request warnings on
5949implicit declarations. Each of these specific warning options also
5950has a negative form beginning @samp{-Wno-} to turn off warnings; for
5951example, @option{-Wno-implicit}. This manual lists only one of the
5952two forms, whichever is not the default. For further
5953language-specific options also refer to @ref{C++ Dialect Options} and
5954@ref{Objective-C and Objective-C++ Dialect Options}.
5955Additional warnings can be produced by enabling the static analyzer;
5956@xref{Static Analyzer Options}.
5957
5958Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5959options, such as @option{-Wunused}, which may turn on further options,
5960such as @option{-Wunused-value}. The combined effect of positive and
5961negative forms is that more specific options have priority over less
5962specific ones, independently of their position in the command-line. For
5963options of the same specificity, the last one takes effect. Options
5964enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5965as if they appeared at the end of the command-line.
5966
5967When an unrecognized warning option is requested (e.g.,
5968@option{-Wunknown-warning}), GCC emits a diagnostic stating
5969that the option is not recognized. However, if the @option{-Wno-} form
5970is used, the behavior is slightly different: no diagnostic is
5971produced for @option{-Wno-unknown-warning} unless other diagnostics
5972are being produced. This allows the use of new @option{-Wno-} options
5973with old compilers, but if something goes wrong, the compiler
5974warns that an unrecognized option is present.
5975
5976The effectiveness of some warnings depends on optimizations also being
5977enabled. For example @option{-Wsuggest-final-types} is more effective
5978with link-time optimization and some instances of other warnings may
5979not be issued at all unless optimization is enabled. While optimization
5980in general improves the efficacy of control and data flow sensitive
5981warnings, in some cases it may also cause false positives.
5982
5983@table @gcctabopt
d77de738
ML
5984@opindex pedantic
5985@opindex Wpedantic
5986@opindex Wno-pedantic
ddf6fe37
AA
5987@item -Wpedantic
5988@itemx -pedantic
d77de738
ML
5989Issue all the warnings demanded by strict ISO C and ISO C++;
5990reject all programs that use forbidden extensions, and some other
5991programs that do not follow ISO C and ISO C++. For ISO C, follows the
5992version of the ISO C standard specified by any @option{-std} option used.
5993
5994Valid ISO C and ISO C++ programs should compile properly with or without
5995this option (though a rare few require @option{-ansi} or a
5996@option{-std} option specifying the required version of ISO C)@. However,
5997without this option, certain GNU extensions and traditional C and C++
5998features are supported as well. With this option, they are rejected.
5999
6000@option{-Wpedantic} does not cause warning messages for use of the
6001alternate keywords whose names begin and end with @samp{__}. This alternate
6002format can also be used to disable warnings for non-ISO @samp{__intN} types,
6003i.e. @samp{__intN__}.
6004Pedantic warnings are also disabled in the expression that follows
6005@code{__extension__}. However, only system header files should use
6006these escape routes; application programs should avoid them.
6007@xref{Alternate Keywords}.
6008
6009Some users try to use @option{-Wpedantic} to check programs for strict ISO
6010C conformance. They soon find that it does not do quite what they want:
6011it finds some non-ISO practices, but not all---only those for which
6012ISO C @emph{requires} a diagnostic, and some others for which
6013diagnostics have been added.
6014
6015A feature to report any failure to conform to ISO C might be useful in
6016some instances, but would require considerable additional work and would
6017be quite different from @option{-Wpedantic}. We don't have plans to
6018support such a feature in the near future.
6019
6020Where the standard specified with @option{-std} represents a GNU
6021extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6022corresponding @dfn{base standard}, the version of ISO C on which the GNU
6023extended dialect is based. Warnings from @option{-Wpedantic} are given
6024where they are required by the base standard. (It does not make sense
6025for such warnings to be given only for features not in the specified GNU
6026C dialect, since by definition the GNU dialects of C include all
6027features the compiler supports with the given option, and there would be
6028nothing to warn about.)
6029
d77de738 6030@opindex pedantic-errors
ddf6fe37 6031@item -pedantic-errors
d77de738
ML
6032Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6033requires a diagnostic, in some cases where there is undefined behavior
6034at compile-time and in some other cases that do not prevent compilation
6035of programs that are valid according to the standard. This is not
6036equivalent to @option{-Werror=pedantic}, since there are errors enabled
6037by this option and not enabled by the latter and vice versa.
6038
d77de738
ML
6039@opindex Wall
6040@opindex Wno-all
ddf6fe37 6041@item -Wall
d77de738
ML
6042This enables all the warnings about constructions that some users
6043consider questionable, and that are easy to avoid (or modify to
6044prevent the warning), even in conjunction with macros. This also
6045enables some language-specific warnings described in @ref{C++ Dialect
6046Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6047
6048@option{-Wall} turns on the following warning flags:
6049
43b72ede
AA
6050@gccoptlist{-Waddress
6051-Warray-bounds=1 @r{(only with} @option{-O2}@r{)}
6052-Warray-compare
6053-Warray-parameter=2 @r{(C and Objective-C only)}
6054-Wbool-compare
6055-Wbool-operation
6056-Wc++11-compat -Wc++14-compat
6057-Wcatch-value @r{(C++ and Objective-C++ only)}
6058-Wchar-subscripts
6059-Wcomment
6060-Wdangling-pointer=2
6061-Wduplicate-decl-specifier @r{(C and Objective-C only)}
6062-Wenum-compare @r{(in C/ObjC; this is on by default in C++)}
6063-Wenum-int-mismatch @r{(C and Objective-C only)}
6064-Wformat
6065-Wformat-overflow
6066-Wformat-truncation
6067-Wint-in-bool-context
6068-Wimplicit @r{(C and Objective-C only)}
6069-Wimplicit-int @r{(C and Objective-C only)}
6070-Wimplicit-function-declaration @r{(C and Objective-C only)}
6071-Winit-self @r{(only for C++)}
6072-Wlogical-not-parentheses
6073-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)}
6074-Wmaybe-uninitialized
6075-Wmemset-elt-size
6076-Wmemset-transposed-args
6077-Wmisleading-indentation @r{(only for C/C++)}
6078-Wmismatched-dealloc
6079-Wmismatched-new-delete @r{(only for C/C++)}
6080-Wmissing-attributes
6081-Wmissing-braces @r{(only for C/ObjC)}
6082-Wmultistatement-macros
6083-Wnarrowing @r{(only for C++)}
6084-Wnonnull
6085-Wnonnull-compare
6086-Wopenmp-simd
6087-Wparentheses
6088-Wpessimizing-move @r{(only for C++)}
6089-Wpointer-sign
6090-Wrange-loop-construct @r{(only for C++)}
6091-Wreorder
6092-Wrestrict
6093-Wreturn-type
6094-Wself-move @r{(only for C++)}
6095-Wsequence-point
6096-Wsign-compare @r{(only in C++)}
6097-Wsizeof-array-div
6098-Wsizeof-pointer-div
6099-Wsizeof-pointer-memaccess
6100-Wstrict-aliasing
6101-Wstrict-overflow=1
6102-Wswitch
6103-Wtautological-compare
6104-Wtrigraphs
6105-Wuninitialized
6106-Wunknown-pragmas
6107-Wunused-function
6108-Wunused-label
6109-Wunused-value
6110-Wunused-variable
6111-Wuse-after-free=2
6112-Wvla-parameter @r{(C and Objective-C only)}
6113-Wvolatile-register-var
d77de738
ML
6114-Wzero-length-bounds}
6115
6116Note that some warning flags are not implied by @option{-Wall}. Some of
6117them warn about constructions that users generally do not consider
6118questionable, but which occasionally you might wish to check for;
6119others warn about constructions that are necessary or hard to avoid in
6120some cases, and there is no simple way to modify the code to suppress
6121the warning. Some of them are enabled by @option{-Wextra} but many of
6122them must be enabled individually.
6123
d77de738
ML
6124@opindex W
6125@opindex Wextra
6126@opindex Wno-extra
ddf6fe37 6127@item -Wextra
d77de738
ML
6128This enables some extra warning flags that are not enabled by
6129@option{-Wall}. (This option used to be called @option{-W}. The older
6130name is still supported, but the newer name is more descriptive.)
6131
43b72ede
AA
6132@gccoptlist{-Wclobbered
6133-Wcast-function-type
6134-Wdeprecated-copy @r{(C++ only)}
6135-Wempty-body
6136-Wenum-conversion @r{(C only)}
6137-Wignored-qualifiers
6138-Wimplicit-fallthrough=3
6139-Wmissing-field-initializers
6140-Wmissing-parameter-type @r{(C only)}
6141-Wold-style-declaration @r{(C only)}
6142-Woverride-init
6143-Wsign-compare @r{(C only)}
6144-Wstring-compare
6145-Wredundant-move @r{(only for C++)}
6146-Wtype-limits
6147-Wuninitialized
6148-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)}
6149-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}
d77de738
ML
6150-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6151
6152
6153The option @option{-Wextra} also prints warning messages for the
6154following cases:
6155
6156@itemize @bullet
6157
6158@item
6159A pointer is compared against integer zero with @code{<}, @code{<=},
6160@code{>}, or @code{>=}.
6161
6162@item
6163(C++ only) An enumerator and a non-enumerator both appear in a
6164conditional expression.
6165
6166@item
6167(C++ only) Ambiguous virtual bases.
6168
6169@item
6170(C++ only) Subscripting an array that has been declared @code{register}.
6171
6172@item
6173(C++ only) Taking the address of a variable that has been declared
6174@code{register}.
6175
6176@item
6177(C++ only) A base class is not initialized in the copy constructor
6178of a derived class.
6179
6180@end itemize
6181
d77de738
ML
6182@opindex Wabi
6183@opindex Wno-abi
ddf6fe37 6184@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
6185
6186Warn about code affected by ABI changes. This includes code that may
6187not be compatible with the vendor-neutral C++ ABI as well as the psABI
6188for the particular target.
6189
6190Since G++ now defaults to updating the ABI with each major release,
6191normally @option{-Wabi} warns only about C++ ABI compatibility
6192problems if there is a check added later in a release series for an
6193ABI issue discovered since the initial release. @option{-Wabi} warns
6194about more things if an older ABI version is selected (with
6195@option{-fabi-version=@var{n}}).
6196
6197@option{-Wabi} can also be used with an explicit version number to
6198warn about C++ ABI compatibility with a particular @option{-fabi-version}
6199level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6200@option{-fabi-version=2}.
6201
6202If an explicit version number is provided and
6203@option{-fabi-compat-version} is not specified, the version number
6204from this option is used for compatibility aliases. If no explicit
6205version number is provided with this option, but
6206@option{-fabi-compat-version} is specified, that version number is
6207used for C++ ABI warnings.
6208
6209Although an effort has been made to warn about
6210all such cases, there are probably some cases that are not warned about,
6211even though G++ is generating incompatible code. There may also be
6212cases where warnings are emitted even though the code that is generated
6213is compatible.
6214
6215You should rewrite your code to avoid these warnings if you are
6216concerned about the fact that code generated by G++ may not be binary
6217compatible with code generated by other compilers.
6218
6219Known incompatibilities in @option{-fabi-version=2} (which was the
6220default from GCC 3.4 to 4.9) include:
6221
6222@itemize @bullet
6223
6224@item
6225A template with a non-type template parameter of reference type was
6226mangled incorrectly:
6227@smallexample
6228extern int N;
6229template <int &> struct S @{@};
6230void n (S<N>) @{2@}
6231@end smallexample
6232
6233This was fixed in @option{-fabi-version=3}.
6234
6235@item
6236SIMD vector types declared using @code{__attribute ((vector_size))} were
6237mangled in a non-standard way that does not allow for overloading of
6238functions taking vectors of different sizes.
6239
6240The mangling was changed in @option{-fabi-version=4}.
6241
6242@item
6243@code{__attribute ((const))} and @code{noreturn} were mangled as type
6244qualifiers, and @code{decltype} of a plain declaration was folded away.
6245
6246These mangling issues were fixed in @option{-fabi-version=5}.
6247
6248@item
6249Scoped enumerators passed as arguments to a variadic function are
6250promoted like unscoped enumerators, causing @code{va_arg} to complain.
6251On most targets this does not actually affect the parameter passing
6252ABI, as there is no way to pass an argument smaller than @code{int}.
6253
6254Also, the ABI changed the mangling of template argument packs,
6255@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6256a class scope function used as a template argument.
6257
6258These issues were corrected in @option{-fabi-version=6}.
6259
6260@item
6261Lambdas in default argument scope were mangled incorrectly, and the
6262ABI changed the mangling of @code{nullptr_t}.
6263
6264These issues were corrected in @option{-fabi-version=7}.
6265
6266@item
6267When mangling a function type with function-cv-qualifiers, the
6268un-qualified function type was incorrectly treated as a substitution
6269candidate.
6270
6271This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6272
6273@item
6274@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6275unaligned accesses. Note that this did not affect the ABI of a
6276function with a @code{nullptr_t} parameter, as parameters have a
6277minimum alignment.
6278
6279This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6280
6281@item
6282Target-specific attributes that affect the identity of a type, such as
6283ia32 calling conventions on a function type (stdcall, regparm, etc.),
6284did not affect the mangled name, leading to name collisions when
6285function pointers were used as template arguments.
6286
6287This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6288
6289@end itemize
6290
6291This option also enables warnings about psABI-related changes.
6292The known psABI changes at this point include:
6293
6294@itemize @bullet
6295
6296@item
6297For SysV/x86-64, unions with @code{long double} members are
6298passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6299the case. For example:
6300
6301@smallexample
6302union U @{
6303 long double ld;
6304 int i;
6305@};
6306@end smallexample
6307
6308@noindent
6309@code{union U} is now always passed in memory.
6310
6311@end itemize
6312
e2f939d3
JM
6313@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6314C++ requires that unqualified uses of a name within a class have the
6315same meaning in the complete scope of the class, so declaring the name
6316after using it is ill-formed:
6317@smallexample
6318struct A;
6319struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6320struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6321@end smallexample
6322By default, the B1 case is only a warning because the two declarations
6323have the same type, while the B2 case is an error. Both diagnostics
6324can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6325error case can be reduced to a warning with
6326@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6327
6328Both diagnostics are also suppressed by @option{-fms-extensions}.
6329
d77de738
ML
6330@opindex Wchar-subscripts
6331@opindex Wno-char-subscripts
ddf6fe37 6332@item -Wchar-subscripts
d77de738
ML
6333Warn if an array subscript has type @code{char}. This is a common cause
6334of error, as programmers often forget that this type is signed on some
6335machines.
6336This warning is enabled by @option{-Wall}.
6337
d77de738
ML
6338@opindex Wno-coverage-mismatch
6339@opindex Wcoverage-mismatch
ddf6fe37 6340@item -Wno-coverage-mismatch
d77de738
ML
6341Warn if feedback profiles do not match when using the
6342@option{-fprofile-use} option.
6343If a source file is changed between compiling with @option{-fprofile-generate}
6344and with @option{-fprofile-use}, the files with the profile feedback can fail
6345to match the source file and GCC cannot use the profile feedback
6346information. By default, this warning is enabled and is treated as an
6347error. @option{-Wno-coverage-mismatch} can be used to disable the
6348warning or @option{-Wno-error=coverage-mismatch} can be used to
6349disable the error. Disabling the error for this warning can result in
6350poorly optimized code and is useful only in the
6351case of very minor changes such as bug fixes to an existing code-base.
6352Completely disabling the warning is not recommended.
6353
d77de738
ML
6354@opindex Wno-coverage-invalid-line-number
6355@opindex Wcoverage-invalid-line-number
ddf6fe37 6356@item -Wno-coverage-invalid-line-number
d77de738
ML
6357Warn in case a function ends earlier than it begins due
6358to an invalid linenum macros. The warning is emitted only
6359with @option{--coverage} enabled.
6360
6361By default, this warning is enabled and is treated as an
6362error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6363warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6364disable the error.
6365
d77de738
ML
6366@opindex Wno-cpp
6367@opindex Wcpp
ddf6fe37 6368@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
d77de738
ML
6369Suppress warning messages emitted by @code{#warning} directives.
6370
d77de738
ML
6371@opindex Wdouble-promotion
6372@opindex Wno-double-promotion
ddf6fe37 6373@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6374Give a warning when a value of type @code{float} is implicitly
6375promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6376floating-point unit implement @code{float} in hardware, but emulate
6377@code{double} in software. On such a machine, doing computations
6378using @code{double} values is much more expensive because of the
6379overhead required for software emulation.
6380
6381It is easy to accidentally do computations with @code{double} because
6382floating-point literals are implicitly of type @code{double}. For
6383example, in:
6384@smallexample
6385@group
6386float area(float radius)
6387@{
6388 return 3.14159 * radius * radius;
6389@}
6390@end group
6391@end smallexample
6392the compiler performs the entire computation with @code{double}
6393because the floating-point literal is a @code{double}.
6394
d77de738
ML
6395@opindex Wduplicate-decl-specifier
6396@opindex Wno-duplicate-decl-specifier
ddf6fe37 6397@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
d77de738
ML
6398Warn if a declaration has duplicate @code{const}, @code{volatile},
6399@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6400@option{-Wall}.
6401
d77de738
ML
6402@opindex Wformat
6403@opindex Wno-format
6404@opindex ffreestanding
6405@opindex fno-builtin
6406@opindex Wformat=
ddf6fe37
AA
6407@item -Wformat
6408@itemx -Wformat=@var{n}
d77de738
ML
6409Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6410the arguments supplied have types appropriate to the format string
6411specified, and that the conversions specified in the format string make
6412sense. This includes standard functions, and others specified by format
6413attributes (@pxref{Function Attributes}), in the @code{printf},
6414@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6415not in the C standard) families (or other target-specific families).
6416Which functions are checked without format attributes having been
6417specified depends on the standard version selected, and such checks of
6418functions without the attribute specified are disabled by
6419@option{-ffreestanding} or @option{-fno-builtin}.
6420
6421The formats are checked against the format features supported by GNU
6422libc version 2.2. These include all ISO C90 and C99 features, as well
6423as features from the Single Unix Specification and some BSD and GNU
6424extensions. Other library implementations may not support all these
6425features; GCC does not support warning about features that go beyond a
6426particular library's limitations. However, if @option{-Wpedantic} is used
6427with @option{-Wformat}, warnings are given about format features not
6428in the selected standard version (but not for @code{strfmon} formats,
6429since those are not in any version of the C standard). @xref{C Dialect
6430Options,,Options Controlling C Dialect}.
6431
6432@table @gcctabopt
d77de738
ML
6433@opindex Wformat
6434@opindex Wformat=1
ddf6fe37
AA
6435@item -Wformat=1
6436@itemx -Wformat
d77de738
ML
6437Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6438@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6439@option{-Wformat} also checks for null format arguments for several
6440functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6441aspects of this level of format checking can be disabled by the
6442options: @option{-Wno-format-contains-nul},
6443@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6444@option{-Wformat} is enabled by @option{-Wall}.
6445
d77de738 6446@opindex Wformat=2
ddf6fe37 6447@item -Wformat=2
d77de738
ML
6448Enable @option{-Wformat} plus additional format checks. Currently
6449equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6450-Wformat-y2k}.
6451@end table
6452
d77de738
ML
6453@opindex Wno-format-contains-nul
6454@opindex Wformat-contains-nul
ddf6fe37 6455@item -Wno-format-contains-nul
d77de738
ML
6456If @option{-Wformat} is specified, do not warn about format strings that
6457contain NUL bytes.
6458
d77de738
ML
6459@opindex Wno-format-extra-args
6460@opindex Wformat-extra-args
ddf6fe37 6461@item -Wno-format-extra-args
d77de738
ML
6462If @option{-Wformat} is specified, do not warn about excess arguments to a
6463@code{printf} or @code{scanf} format function. The C standard specifies
6464that such arguments are ignored.
6465
6466Where the unused arguments lie between used arguments that are
6467specified with @samp{$} operand number specifications, normally
6468warnings are still given, since the implementation could not know what
6469type to pass to @code{va_arg} to skip the unused arguments. However,
6470in the case of @code{scanf} formats, this option suppresses the
6471warning if the unused arguments are all pointers, since the Single
6472Unix Specification says that such unused arguments are allowed.
6473
d77de738
ML
6474@opindex Wformat-overflow
6475@opindex Wno-format-overflow
ddf6fe37
AA
6476@item -Wformat-overflow
6477@itemx -Wformat-overflow=@var{level}
d77de738
ML
6478Warn about calls to formatted input/output functions such as @code{sprintf}
6479and @code{vsprintf} that might overflow the destination buffer. When the
6480exact number of bytes written by a format directive cannot be determined
6481at compile-time it is estimated based on heuristics that depend on the
6482@var{level} argument and on optimization. While enabling optimization
6483will in most cases improve the accuracy of the warning, it may also
6484result in false positives.
6485
6486@table @gcctabopt
d77de738
ML
6487@opindex Wformat-overflow
6488@opindex Wno-format-overflow
ddf6fe37
AA
6489@item -Wformat-overflow
6490@itemx -Wformat-overflow=1
d77de738
ML
6491Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6492employs a conservative approach that warns only about calls that most
6493likely overflow the buffer. At this level, numeric arguments to format
6494directives with unknown values are assumed to have the value of one, and
6495strings of unknown length to be empty. Numeric arguments that are known
6496to be bounded to a subrange of their type, or string arguments whose output
6497is bounded either by their directive's precision or by a finite set of
6498string literals, are assumed to take on the value within the range that
6499results in the most bytes on output. For example, the call to @code{sprintf}
6500below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6501the terminating NUL character (@code{'\0'}) appended by the function
6502to the destination buffer will be written past its end. Increasing
6503the size of the buffer by a single byte is sufficient to avoid the
6504warning, though it may not be sufficient to avoid the overflow.
6505
6506@smallexample
6507void f (int a, int b)
6508@{
6509 char buf [13];
6510 sprintf (buf, "a = %i, b = %i\n", a, b);
6511@}
6512@end smallexample
6513
6514@item -Wformat-overflow=2
6515Level @var{2} warns also about calls that might overflow the destination
6516buffer given an argument of sufficient length or magnitude. At level
6517@var{2}, unknown numeric arguments are assumed to have the minimum
6518representable value for signed types with a precision greater than 1, and
6519the maximum representable value otherwise. Unknown string arguments whose
6520length cannot be assumed to be bounded either by the directive's precision,
6521or by a finite set of string literals they may evaluate to, or the character
6522array they may point to, are assumed to be 1 character long.
6523
6524At level @var{2}, the call in the example above is again diagnosed, but
6525this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6526@code{%i} directive will write some of its digits beyond the end of
6527the destination buffer. To make the call safe regardless of the values
6528of the two variables, the size of the destination buffer must be increased
6529to at least 34 bytes. GCC includes the minimum size of the buffer in
6530an informational note following the warning.
6531
6532An alternative to increasing the size of the destination buffer is to
6533constrain the range of formatted values. The maximum length of string
6534arguments can be bounded by specifying the precision in the format
6535directive. When numeric arguments of format directives can be assumed
6536to be bounded by less than the precision of their type, choosing
6537an appropriate length modifier to the format specifier will reduce
6538the required buffer size. For example, if @var{a} and @var{b} in the
6539example above can be assumed to be within the precision of
6540the @code{short int} type then using either the @code{%hi} format
6541directive or casting the argument to @code{short} reduces the maximum
6542required size of the buffer to 24 bytes.
6543
6544@smallexample
6545void f (int a, int b)
6546@{
6547 char buf [23];
6548 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6549@}
6550@end smallexample
6551@end table
6552
d77de738
ML
6553@opindex Wno-format-zero-length
6554@opindex Wformat-zero-length
ddf6fe37 6555@item -Wno-format-zero-length
d77de738
ML
6556If @option{-Wformat} is specified, do not warn about zero-length formats.
6557The C standard specifies that zero-length formats are allowed.
6558
d77de738
ML
6559@opindex Wformat-nonliteral
6560@opindex Wno-format-nonliteral
ddf6fe37 6561@item -Wformat-nonliteral
d77de738
ML
6562If @option{-Wformat} is specified, also warn if the format string is not a
6563string literal and so cannot be checked, unless the format function
6564takes its format arguments as a @code{va_list}.
6565
d77de738
ML
6566@opindex Wformat-security
6567@opindex Wno-format-security
ddf6fe37 6568@item -Wformat-security
d77de738
ML
6569If @option{-Wformat} is specified, also warn about uses of format
6570functions that represent possible security problems. At present, this
6571warns about calls to @code{printf} and @code{scanf} functions where the
6572format string is not a string literal and there are no format arguments,
6573as in @code{printf (foo);}. This may be a security hole if the format
6574string came from untrusted input and contains @samp{%n}. (This is
6575currently a subset of what @option{-Wformat-nonliteral} warns about, but
6576in future warnings may be added to @option{-Wformat-security} that are not
6577included in @option{-Wformat-nonliteral}.)
6578
d77de738
ML
6579@opindex Wformat-signedness
6580@opindex Wno-format-signedness
ddf6fe37 6581@item -Wformat-signedness
d77de738
ML
6582If @option{-Wformat} is specified, also warn if the format string
6583requires an unsigned argument and the argument is signed and vice versa.
6584
d77de738
ML
6585@opindex Wformat-truncation
6586@opindex Wno-format-truncation
ddf6fe37
AA
6587@item -Wformat-truncation
6588@itemx -Wformat-truncation=@var{level}
d77de738
ML
6589Warn about calls to formatted input/output functions such as @code{snprintf}
6590and @code{vsnprintf} that might result in output truncation. When the exact
6591number of bytes written by a format directive cannot be determined at
6592compile-time it is estimated based on heuristics that depend on
6593the @var{level} argument and on optimization. While enabling optimization
6594will in most cases improve the accuracy of the warning, it may also result
6595in false positives. Except as noted otherwise, the option uses the same
6596logic @option{-Wformat-overflow}.
6597
6598@table @gcctabopt
d77de738
ML
6599@opindex Wformat-truncation
6600@opindex Wno-format-truncation
ddf6fe37
AA
6601@item -Wformat-truncation
6602@itemx -Wformat-truncation=1
d77de738
ML
6603Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6604employs a conservative approach that warns only about calls to bounded
6605functions whose return value is unused and that will most likely result
6606in output truncation.
6607
6608@item -Wformat-truncation=2
6609Level @var{2} warns also about calls to bounded functions whose return
6610value is used and that might result in truncation given an argument of
6611sufficient length or magnitude.
6612@end table
6613
d77de738
ML
6614@opindex Wformat-y2k
6615@opindex Wno-format-y2k
ddf6fe37 6616@item -Wformat-y2k
d77de738
ML
6617If @option{-Wformat} is specified, also warn about @code{strftime}
6618formats that may yield only a two-digit year.
6619
d77de738
ML
6620@opindex Wnonnull
6621@opindex Wno-nonnull
ddf6fe37 6622@item -Wnonnull
d77de738
ML
6623Warn about passing a null pointer for arguments marked as
6624requiring a non-null value by the @code{nonnull} function attribute.
6625
6626@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6627can be disabled with the @option{-Wno-nonnull} option.
6628
d77de738
ML
6629@opindex Wnonnull-compare
6630@opindex Wno-nonnull-compare
ddf6fe37 6631@item -Wnonnull-compare
d77de738
ML
6632Warn when comparing an argument marked with the @code{nonnull}
6633function attribute against null inside the function.
6634
6635@option{-Wnonnull-compare} is included in @option{-Wall}. It
6636can be disabled with the @option{-Wno-nonnull-compare} option.
6637
d77de738
ML
6638@opindex Wnull-dereference
6639@opindex Wno-null-dereference
ddf6fe37 6640@item -Wnull-dereference
d77de738
ML
6641Warn if the compiler detects paths that trigger erroneous or
6642undefined behavior due to dereferencing a null pointer. This option
6643is only active when @option{-fdelete-null-pointer-checks} is active,
6644which is enabled by optimizations in most targets. The precision of
6645the warnings depends on the optimization options used.
6646
d77de738
ML
6647@opindex Winfinite-recursion
6648@opindex Wno-infinite-recursion
ddf6fe37 6649@item -Winfinite-recursion
d77de738
ML
6650Warn about infinitely recursive calls. The warning is effective at all
6651optimization levels but requires optimization in order to detect infinite
6652recursion in calls between two or more functions.
6653@option{-Winfinite-recursion} is included in @option{-Wall}.
6654
ce51e843
ML
6655Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6656similar diagnostic, but is implemented in a different way (as part of
6657@option{-fanalyzer}).
6658
d77de738
ML
6659@opindex Winit-self
6660@opindex Wno-init-self
ddf6fe37 6661@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6662Warn about uninitialized variables that are initialized with themselves.
6663Note this option can only be used with the @option{-Wuninitialized} option.
6664
6665For example, GCC warns about @code{i} being uninitialized in the
6666following snippet only when @option{-Winit-self} has been specified:
6667@smallexample
6668@group
6669int f()
6670@{
6671 int i = i;
6672 return i;
6673@}
6674@end group
6675@end smallexample
6676
6677This warning is enabled by @option{-Wall} in C++.
6678
d77de738
ML
6679@opindex Wimplicit-int
6680@opindex Wno-implicit-int
ddf6fe37 6681@item -Wno-implicit-int @r{(C and Objective-C only)}
d77de738
ML
6682This option controls warnings when a declaration does not specify a type.
6683This warning is enabled by default in C99 and later dialects of C,
6684and also by @option{-Wall}.
6685
d77de738
ML
6686@opindex Wimplicit-function-declaration
6687@opindex Wno-implicit-function-declaration
ddf6fe37 6688@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
d77de738
ML
6689This option controls warnings when a function is used before being declared.
6690This warning is enabled by default in C99 and later dialects of C,
6691and also by @option{-Wall}.
6692The warning is made into an error by @option{-pedantic-errors}.
6693
d77de738
ML
6694@opindex Wimplicit
6695@opindex Wno-implicit
ddf6fe37 6696@item -Wimplicit @r{(C and Objective-C only)}
d77de738
ML
6697Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6698This warning is enabled by @option{-Wall}.
6699
d77de738
ML
6700@opindex Wimplicit-fallthrough
6701@opindex Wno-implicit-fallthrough
ddf6fe37 6702@item -Wimplicit-fallthrough
d77de738
ML
6703@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6704and @option{-Wno-implicit-fallthrough} is the same as
6705@option{-Wimplicit-fallthrough=0}.
6706
d77de738 6707@opindex Wimplicit-fallthrough=
ddf6fe37 6708@item -Wimplicit-fallthrough=@var{n}
d77de738
ML
6709Warn when a switch case falls through. For example:
6710
6711@smallexample
6712@group
6713switch (cond)
6714 @{
6715 case 1:
6716 a = 1;
6717 break;
6718 case 2:
6719 a = 2;
6720 case 3:
6721 a = 3;
6722 break;
6723 @}
6724@end group
6725@end smallexample
6726
6727This warning does not warn when the last statement of a case cannot
6728fall through, e.g. when there is a return statement or a call to function
6729declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6730also takes into account control flow statements, such as ifs, and only
6731warns when appropriate. E.g.@:
6732
6733@smallexample
6734@group
6735switch (cond)
6736 @{
6737 case 1:
6738 if (i > 3) @{
6739 bar (5);
6740 break;
6741 @} else if (i < 1) @{
6742 bar (0);
6743 @} else
6744 return;
6745 default:
6746 @dots{}
6747 @}
6748@end group
6749@end smallexample
6750
6751Since there are occasions where a switch case fall through is desirable,
6752GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6753to be used along with a null statement to suppress this warning that
6754would normally occur:
6755
6756@smallexample
6757@group
6758switch (cond)
6759 @{
6760 case 1:
6761 bar (0);
6762 __attribute__ ((fallthrough));
6763 default:
6764 @dots{}
6765 @}
6766@end group
6767@end smallexample
6768
6769C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6770warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6771or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6772Instead of these attributes, it is also possible to add a fallthrough comment
6773to silence the warning. The whole body of the C or C++ style comment should
6774match the given regular expressions listed below. The option argument @var{n}
6775specifies what kind of comments are accepted:
6776
6777@itemize @bullet
6778
6779@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6780
6781@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6782expression, any comment is used as fallthrough comment.
6783
6784@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6785@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6786
6787@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6788following regular expressions:
6789
6790@itemize @bullet
6791
6792@item @code{-fallthrough}
6793
6794@item @code{@@fallthrough@@}
6795
6796@item @code{lint -fallthrough[ \t]*}
6797
6798@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6799
6800@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6801
6802@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6803
6804@end itemize
6805
6806@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6807following regular expressions:
6808
6809@itemize @bullet
6810
6811@item @code{-fallthrough}
6812
6813@item @code{@@fallthrough@@}
6814
6815@item @code{lint -fallthrough[ \t]*}
6816
6817@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6818
6819@end itemize
6820
6821@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6822fallthrough comments, only attributes disable the warning.
6823
6824@end itemize
6825
6826The comment needs to be followed after optional whitespace and other comments
6827by @code{case} or @code{default} keywords or by a user label that precedes some
6828@code{case} or @code{default} label.
6829
6830@smallexample
6831@group
6832switch (cond)
6833 @{
6834 case 1:
6835 bar (0);
6836 /* FALLTHRU */
6837 default:
6838 @dots{}
6839 @}
6840@end group
6841@end smallexample
6842
6843The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6844
d77de738
ML
6845@opindex Wif-not-aligned
6846@opindex Wno-if-not-aligned
ddf6fe37 6847@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6848Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6849should be issued. These warnings are enabled by default.
6850
d77de738
ML
6851@opindex Wignored-qualifiers
6852@opindex Wno-ignored-qualifiers
ddf6fe37 6853@item -Wignored-qualifiers @r{(C and C++ only)}
d77de738
ML
6854Warn if the return type of a function has a type qualifier
6855such as @code{const}. For ISO C such a type qualifier has no effect,
6856since the value returned by a function is not an lvalue.
6857For C++, the warning is only emitted for scalar types or @code{void}.
6858ISO C prohibits qualified @code{void} return types on function
6859definitions, so such return types always receive a warning
6860even without this option.
6861
6862This warning is also enabled by @option{-Wextra}.
6863
d77de738
ML
6864@opindex Wignored-attributes
6865@opindex Wno-ignored-attributes
ddf6fe37 6866@item -Wno-ignored-attributes @r{(C and C++ only)}
d77de738
ML
6867This option controls warnings when an attribute is ignored.
6868This is different from the
6869@option{-Wattributes} option in that it warns whenever the compiler decides
6870to drop an attribute, not that the attribute is either unknown, used in a
6871wrong place, etc. This warning is enabled by default.
6872
d77de738
ML
6873@opindex Wmain
6874@opindex Wno-main
ddf6fe37 6875@item -Wmain
d77de738
ML
6876Warn if the type of @code{main} is suspicious. @code{main} should be
6877a function with external linkage, returning int, taking either zero
6878arguments, two, or three arguments of appropriate types. This warning
6879is enabled by default in C++ and is enabled by either @option{-Wall}
6880or @option{-Wpedantic}.
6881
d77de738
ML
6882@opindex Wmisleading-indentation
6883@opindex Wno-misleading-indentation
ddf6fe37 6884@item -Wmisleading-indentation @r{(C and C++ only)}
d77de738
ML
6885Warn when the indentation of the code does not reflect the block structure.
6886Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6887@code{for} clauses with a guarded statement that does not use braces,
6888followed by an unguarded statement with the same indentation.
6889
6890In the following example, the call to ``bar'' is misleadingly indented as
6891if it were guarded by the ``if'' conditional.
6892
6893@smallexample
6894 if (some_condition ())
6895 foo ();
6896 bar (); /* Gotcha: this is not guarded by the "if". */
6897@end smallexample
6898
6899In the case of mixed tabs and spaces, the warning uses the
6900@option{-ftabstop=} option to determine if the statements line up
6901(defaulting to 8).
6902
6903The warning is not issued for code involving multiline preprocessor logic
6904such as the following example.
6905
6906@smallexample
6907 if (flagA)
6908 foo (0);
6909#if SOME_CONDITION_THAT_DOES_NOT_HOLD
6910 if (flagB)
6911#endif
6912 foo (1);
6913@end smallexample
6914
6915The warning is not issued after a @code{#line} directive, since this
6916typically indicates autogenerated code, and no assumptions can be made
6917about the layout of the file that the directive references.
6918
6919This warning is enabled by @option{-Wall} in C and C++.
6920
d77de738
ML
6921@opindex Wmissing-attributes
6922@opindex Wno-missing-attributes
ddf6fe37 6923@item -Wmissing-attributes
d77de738
ML
6924Warn when a declaration of a function is missing one or more attributes
6925that a related function is declared with and whose absence may adversely
6926affect the correctness or efficiency of generated code. For example,
6927the warning is issued for declarations of aliases that use attributes
6928to specify less restrictive requirements than those of their targets.
6929This typically represents a potential optimization opportunity.
6930By contrast, the @option{-Wattribute-alias=2} option controls warnings
6931issued when the alias is more restrictive than the target, which could
6932lead to incorrect code generation.
6933Attributes considered include @code{alloc_align}, @code{alloc_size},
6934@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6935@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6936@code{returns_nonnull}, and @code{returns_twice}.
6937
6938In C++, the warning is issued when an explicit specialization of a primary
6939template declared with attribute @code{alloc_align}, @code{alloc_size},
6940@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6941or @code{nonnull} is declared without it. Attributes @code{deprecated},
6942@code{error}, and @code{warning} suppress the warning.
6943(@pxref{Function Attributes}).
6944
6945You can use the @code{copy} attribute to apply the same
6946set of attributes to a declaration as that on another declaration without
6947explicitly enumerating the attributes. This attribute can be applied
6948to declarations of functions (@pxref{Common Function Attributes}),
6949variables (@pxref{Common Variable Attributes}), or types
6950(@pxref{Common Type Attributes}).
6951
6952@option{-Wmissing-attributes} is enabled by @option{-Wall}.
6953
6954For example, since the declaration of the primary function template
6955below makes use of both attribute @code{malloc} and @code{alloc_size}
6956the declaration of the explicit specialization of the template is
6957diagnosed because it is missing one of the attributes.
6958
6959@smallexample
6960template <class T>
6961T* __attribute__ ((malloc, alloc_size (1)))
6962allocate (size_t);
6963
6964template <>
6965void* __attribute__ ((malloc)) // missing alloc_size
6966allocate<void> (size_t);
6967@end smallexample
6968
d77de738
ML
6969@opindex Wmissing-braces
6970@opindex Wno-missing-braces
ddf6fe37 6971@item -Wmissing-braces
d77de738
ML
6972Warn if an aggregate or union initializer is not fully bracketed. In
6973the following example, the initializer for @code{a} is not fully
6974bracketed, but that for @code{b} is fully bracketed.
6975
6976@smallexample
6977int a[2][2] = @{ 0, 1, 2, 3 @};
6978int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
6979@end smallexample
6980
6981This warning is enabled by @option{-Wall}.
6982
d77de738
ML
6983@opindex Wmissing-include-dirs
6984@opindex Wno-missing-include-dirs
ddf6fe37 6985@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
d77de738
ML
6986Warn if a user-supplied include directory does not exist. This opions is disabled
6987by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
6988enabled by default by warning for -I and -J, only.
6989
d77de738
ML
6990@opindex Wmissing-profile
6991@opindex Wno-missing-profile
ddf6fe37 6992@item -Wno-missing-profile
d77de738
ML
6993This option controls warnings if feedback profiles are missing when using the
6994@option{-fprofile-use} option.
6995This option diagnoses those cases where a new function or a new file is added
6996between compiling with @option{-fprofile-generate} and with
6997@option{-fprofile-use}, without regenerating the profiles.
6998In these cases, the profile feedback data files do not contain any
6999profile feedback information for
7000the newly added function or file respectively. Also, in the case when profile
7001count data (.gcda) files are removed, GCC cannot use any profile feedback
7002information. In all these cases, warnings are issued to inform you that a
7003profile generation step is due.
7004Ignoring the warning can result in poorly optimized code.
7005@option{-Wno-missing-profile} can be used to
7006disable the warning, but this is not recommended and should be done only
7007when non-existent profile data is justified.
7008
d77de738
ML
7009@opindex Wmismatched-dealloc
7010@opindex Wno-mismatched-dealloc
ddf6fe37 7011@item -Wmismatched-dealloc
d77de738
ML
7012
7013Warn for calls to deallocation functions with pointer arguments returned
7014from from allocations functions for which the former isn't a suitable
7015deallocator. A pair of functions can be associated as matching allocators
7016and deallocators by use of attribute @code{malloc}. Unless disabled by
7017the @option{-fno-builtin} option the standard functions @code{calloc},
7018@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7019forms of C++ @code{operator new} and @code{operator delete} are implicitly
7020associated as matching allocators and deallocators. In the following
7021example @code{mydealloc} is the deallocator for pointers returned from
7022@code{myalloc}.
7023
7024@smallexample
7025void mydealloc (void*);
7026
7027__attribute__ ((malloc (mydealloc, 1))) void*
7028myalloc (size_t);
7029
7030void f (void)
7031@{
7032 void *p = myalloc (32);
7033 // @dots{}use p@dots{}
7034 free (p); // warning: not a matching deallocator for myalloc
7035 mydealloc (p); // ok
7036@}
7037@end smallexample
7038
7039In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7040mismatches involving either @code{operator new} or @code{operator delete}.
7041
7042Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7043
d77de738
ML
7044@opindex Wmultistatement-macros
7045@opindex Wno-multistatement-macros
ddf6fe37 7046@item -Wmultistatement-macros
d77de738
ML
7047Warn about unsafe multiple statement macros that appear to be guarded
7048by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7049@code{while}, in which only the first statement is actually guarded after
7050the macro is expanded.
7051
7052For example:
7053
7054@smallexample
7055#define DOIT x++; y++
7056if (c)
7057 DOIT;
7058@end smallexample
7059
7060will increment @code{y} unconditionally, not just when @code{c} holds.
7061The can usually be fixed by wrapping the macro in a do-while loop:
7062@smallexample
7063#define DOIT do @{ x++; y++; @} while (0)
7064if (c)
7065 DOIT;
7066@end smallexample
7067
7068This warning is enabled by @option{-Wall} in C and C++.
7069
d77de738
ML
7070@opindex Wparentheses
7071@opindex Wno-parentheses
ddf6fe37 7072@item -Wparentheses
d77de738
ML
7073Warn if parentheses are omitted in certain contexts, such
7074as when there is an assignment in a context where a truth value
7075is expected, or when operators are nested whose precedence people
7076often get confused about.
7077
7078Also warn if a comparison like @code{x<=y<=z} appears; this is
7079equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7080interpretation from that of ordinary mathematical notation.
7081
7082Also warn for dangerous uses of the GNU extension to
7083@code{?:} with omitted middle operand. When the condition
7084in the @code{?}: operator is a boolean expression, the omitted value is
7085always 1. Often programmers expect it to be a value computed
7086inside the conditional expression instead.
7087
7088For C++ this also warns for some cases of unnecessary parentheses in
7089declarations, which can indicate an attempt at a function call instead
7090of a declaration:
7091@smallexample
7092@{
7093 // Declares a local variable called mymutex.
7094 std::unique_lock<std::mutex> (mymutex);
7095 // User meant std::unique_lock<std::mutex> lock (mymutex);
7096@}
7097@end smallexample
7098
7099This warning is enabled by @option{-Wall}.
7100
d77de738
ML
7101@opindex Wself-move
7102@opindex Wno-self-move
ddf6fe37 7103@item -Wno-self-move @r{(C++ and Objective-C++ only)}
d77de738
ML
7104This warning warns when a value is moved to itself with @code{std::move}.
7105Such a @code{std::move} typically has no effect.
7106
7107@smallexample
7108struct T @{
7109@dots{}
7110@};
7111void fn()
7112@{
7113 T t;
7114 @dots{}
7115 t = std::move (t);
7116@}
7117@end smallexample
7118
7119This warning is enabled by @option{-Wall}.
7120
d77de738
ML
7121@opindex Wsequence-point
7122@opindex Wno-sequence-point
ddf6fe37 7123@item -Wsequence-point
d77de738
ML
7124Warn about code that may have undefined semantics because of violations
7125of sequence point rules in the C and C++ standards.
7126
7127The C and C++ standards define the order in which expressions in a C/C++
7128program are evaluated in terms of @dfn{sequence points}, which represent
7129a partial ordering between the execution of parts of the program: those
7130executed before the sequence point, and those executed after it. These
7131occur after the evaluation of a full expression (one which is not part
7132of a larger expression), after the evaluation of the first operand of a
7133@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7134function is called (but after the evaluation of its arguments and the
7135expression denoting the called function), and in certain other places.
7136Other than as expressed by the sequence point rules, the order of
7137evaluation of subexpressions of an expression is not specified. All
7138these rules describe only a partial order rather than a total order,
7139since, for example, if two functions are called within one expression
7140with no sequence point between them, the order in which the functions
7141are called is not specified. However, the standards committee have
7142ruled that function calls do not overlap.
7143
7144It is not specified when between sequence points modifications to the
7145values of objects take effect. Programs whose behavior depends on this
7146have undefined behavior; the C and C++ standards specify that ``Between
7147the previous and next sequence point an object shall have its stored
7148value modified at most once by the evaluation of an expression.
7149Furthermore, the prior value shall be read only to determine the value
7150to be stored.''. If a program breaks these rules, the results on any
7151particular implementation are entirely unpredictable.
7152
7153Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7154= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7155diagnosed by this option, and it may give an occasional false positive
7156result, but in general it has been found fairly effective at detecting
7157this sort of problem in programs.
7158
7159The C++17 standard will define the order of evaluation of operands in
7160more cases: in particular it requires that the right-hand side of an
7161assignment be evaluated before the left-hand side, so the above
7162examples are no longer undefined. But this option will still warn
7163about them, to help people avoid writing code that is undefined in C
7164and earlier revisions of C++.
7165
7166The standard is worded confusingly, therefore there is some debate
7167over the precise meaning of the sequence point rules in subtle cases.
7168Links to discussions of the problem, including proposed formal
7169definitions, may be found on the GCC readings page, at
7170@uref{https://gcc.gnu.org/@/readings.html}.
7171
7172This warning is enabled by @option{-Wall} for C and C++.
7173
d77de738
ML
7174@opindex Wno-return-local-addr
7175@opindex Wreturn-local-addr
ddf6fe37 7176@item -Wno-return-local-addr
d77de738
ML
7177Do not warn about returning a pointer (or in C++, a reference) to a
7178variable that goes out of scope after the function returns.
7179
d77de738
ML
7180@opindex Wreturn-type
7181@opindex Wno-return-type
ddf6fe37 7182@item -Wreturn-type
d77de738
ML
7183Warn whenever a function is defined with a return type that defaults
7184to @code{int}. Also warn about any @code{return} statement with no
7185return value in a function whose return type is not @code{void}
7186(falling off the end of the function body is considered returning
7187without a value).
7188
7189For C only, warn about a @code{return} statement with an expression in a
7190function whose return type is @code{void}, unless the expression type is
7191also @code{void}. As a GNU extension, the latter case is accepted
7192without a warning unless @option{-Wpedantic} is used. Attempting
7193to use the return value of a non-@code{void} function other than @code{main}
7194that flows off the end by reaching the closing curly brace that terminates
7195the function is undefined.
7196
7197Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7198than @code{main} results in undefined behavior even when the value of
7199the function is not used.
7200
7201This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7202
d77de738
ML
7203@opindex Wshift-count-negative
7204@opindex Wno-shift-count-negative
ddf6fe37 7205@item -Wno-shift-count-negative
d77de738
ML
7206Controls warnings if a shift count is negative.
7207This warning is enabled by default.
7208
d77de738
ML
7209@opindex Wshift-count-overflow
7210@opindex Wno-shift-count-overflow
ddf6fe37 7211@item -Wno-shift-count-overflow
d77de738
ML
7212Controls warnings if a shift count is greater than or equal to the bit width
7213of the type. This warning is enabled by default.
7214
d77de738
ML
7215@opindex Wshift-negative-value
7216@opindex Wno-shift-negative-value
ddf6fe37 7217@item -Wshift-negative-value
d77de738
ML
7218Warn if left shifting a negative value. This warning is enabled by
7219@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7220
d77de738
ML
7221@opindex Wshift-overflow
7222@opindex Wno-shift-overflow
ddf6fe37
AA
7223@item -Wno-shift-overflow
7224@itemx -Wshift-overflow=@var{n}
d77de738
ML
7225These options control warnings about left shift overflows.
7226
7227@table @gcctabopt
7228@item -Wshift-overflow=1
7229This is the warning level of @option{-Wshift-overflow} and is enabled
7230by default in C99 and C++11 modes (and newer). This warning level does
7231not warn about left-shifting 1 into the sign bit. (However, in C, such
7232an overflow is still rejected in contexts where an integer constant expression
7233is required.) No warning is emitted in C++20 mode (and newer), as signed left
7234shifts always wrap.
7235
7236@item -Wshift-overflow=2
7237This warning level also warns about left-shifting 1 into the sign bit,
7238unless C++14 mode (or newer) is active.
7239@end table
7240
d77de738
ML
7241@opindex Wswitch
7242@opindex Wno-switch
ddf6fe37 7243@item -Wswitch
d77de738
ML
7244Warn whenever a @code{switch} statement has an index of enumerated type
7245and lacks a @code{case} for one or more of the named codes of that
7246enumeration. (The presence of a @code{default} label prevents this
7247warning.) @code{case} labels outside the enumeration range also
7248provoke warnings when this option is used (even if there is a
7249@code{default} label).
7250This warning is enabled by @option{-Wall}.
7251
d77de738
ML
7252@opindex Wswitch-default
7253@opindex Wno-switch-default
ddf6fe37 7254@item -Wswitch-default
d77de738
ML
7255Warn whenever a @code{switch} statement does not have a @code{default}
7256case.
7257
d77de738
ML
7258@opindex Wswitch-enum
7259@opindex Wno-switch-enum
ddf6fe37 7260@item -Wswitch-enum
d77de738
ML
7261Warn whenever a @code{switch} statement has an index of enumerated type
7262and lacks a @code{case} for one or more of the named codes of that
7263enumeration. @code{case} labels outside the enumeration range also
7264provoke warnings when this option is used. The only difference
7265between @option{-Wswitch} and this option is that this option gives a
7266warning about an omitted enumeration code even if there is a
7267@code{default} label.
7268
d77de738
ML
7269@opindex Wswitch-bool
7270@opindex Wno-switch-bool
ddf6fe37 7271@item -Wno-switch-bool
d77de738
ML
7272Do not warn when a @code{switch} statement has an index of boolean type
7273and the case values are outside the range of a boolean type.
7274It is possible to suppress this warning by casting the controlling
7275expression to a type other than @code{bool}. For example:
7276@smallexample
7277@group
7278switch ((int) (a == 4))
7279 @{
7280 @dots{}
7281 @}
7282@end group
7283@end smallexample
7284This warning is enabled by default for C and C++ programs.
7285
d77de738
ML
7286@opindex Wswitch-outside-range
7287@opindex Wno-switch-outside-range
ddf6fe37 7288@item -Wno-switch-outside-range
d77de738
ML
7289This option controls warnings when a @code{switch} case has a value
7290that is outside of its
7291respective type range. This warning is enabled by default for
7292C and C++ programs.
7293
d77de738
ML
7294@opindex Wswitch-unreachable
7295@opindex Wno-switch-unreachable
ddf6fe37 7296@item -Wno-switch-unreachable
d77de738
ML
7297Do not warn when a @code{switch} statement contains statements between the
7298controlling expression and the first case label, which will never be
7299executed. For example:
7300@smallexample
7301@group
7302switch (cond)
7303 @{
7304 i = 15;
7305 @dots{}
7306 case 5:
7307 @dots{}
7308 @}
7309@end group
7310@end smallexample
7311@option{-Wswitch-unreachable} does not warn if the statement between the
7312controlling expression and the first case label is just a declaration:
7313@smallexample
7314@group
7315switch (cond)
7316 @{
7317 int i;
7318 @dots{}
7319 case 5:
7320 i = 5;
7321 @dots{}
7322 @}
7323@end group
7324@end smallexample
7325This warning is enabled by default for C and C++ programs.
7326
d77de738
ML
7327@opindex Wsync-nand
7328@opindex Wno-sync-nand
ddf6fe37 7329@item -Wsync-nand @r{(C and C++ only)}
d77de738
ML
7330Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7331built-in functions are used. These functions changed semantics in GCC 4.4.
7332
d77de738
ML
7333@opindex Wtrivial-auto-var-init
7334@opindex Wno-trivial-auto-var-init
ddf6fe37 7335@item -Wtrivial-auto-var-init
d77de738
ML
7336Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7337variable. A common situation is an automatic variable that is declared
7338between the controlling expression and the first case label of a @code{switch}
7339statement.
7340
d77de738
ML
7341@opindex Wunused-but-set-parameter
7342@opindex Wno-unused-but-set-parameter
ddf6fe37 7343@item -Wunused-but-set-parameter
d77de738
ML
7344Warn whenever a function parameter is assigned to, but otherwise unused
7345(aside from its declaration).
7346
7347To suppress this warning use the @code{unused} attribute
7348(@pxref{Variable Attributes}).
7349
7350This warning is also enabled by @option{-Wunused} together with
7351@option{-Wextra}.
7352
d77de738
ML
7353@opindex Wunused-but-set-variable
7354@opindex Wno-unused-but-set-variable
ddf6fe37 7355@item -Wunused-but-set-variable
d77de738
ML
7356Warn whenever a local variable is assigned to, but otherwise unused
7357(aside from its declaration).
7358This warning is enabled by @option{-Wall}.
7359
7360To suppress this warning use the @code{unused} attribute
7361(@pxref{Variable Attributes}).
7362
7363This warning is also enabled by @option{-Wunused}, which is enabled
7364by @option{-Wall}.
7365
d77de738
ML
7366@opindex Wunused-function
7367@opindex Wno-unused-function
ddf6fe37 7368@item -Wunused-function
d77de738
ML
7369Warn whenever a static function is declared but not defined or a
7370non-inline static function is unused.
7371This warning is enabled by @option{-Wall}.
7372
d77de738
ML
7373@opindex Wunused-label
7374@opindex Wno-unused-label
ddf6fe37 7375@item -Wunused-label
d77de738
ML
7376Warn whenever a label is declared but not used.
7377This warning is enabled by @option{-Wall}.
7378
7379To suppress this warning use the @code{unused} attribute
7380(@pxref{Variable Attributes}).
7381
d77de738
ML
7382@opindex Wunused-local-typedefs
7383@opindex Wno-unused-local-typedefs
ddf6fe37 7384@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
7385Warn when a typedef locally defined in a function is not used.
7386This warning is enabled by @option{-Wall}.
7387
d77de738
ML
7388@opindex Wunused-parameter
7389@opindex Wno-unused-parameter
ddf6fe37 7390@item -Wunused-parameter
d77de738
ML
7391Warn whenever a function parameter is unused aside from its declaration.
7392
7393To suppress this warning use the @code{unused} attribute
7394(@pxref{Variable Attributes}).
7395
d77de738
ML
7396@opindex Wunused-result
7397@opindex Wno-unused-result
ddf6fe37 7398@item -Wno-unused-result
d77de738
ML
7399Do not warn if a caller of a function marked with attribute
7400@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7401its return value. The default is @option{-Wunused-result}.
7402
d77de738
ML
7403@opindex Wunused-variable
7404@opindex Wno-unused-variable
ddf6fe37 7405@item -Wunused-variable
d77de738
ML
7406Warn whenever a local or static variable is unused aside from its
7407declaration. This option implies @option{-Wunused-const-variable=1} for C,
7408but not for C++. This warning is enabled by @option{-Wall}.
7409
7410To suppress this warning use the @code{unused} attribute
7411(@pxref{Variable Attributes}).
7412
d77de738
ML
7413@opindex Wunused-const-variable
7414@opindex Wno-unused-const-variable
ddf6fe37
AA
7415@item -Wunused-const-variable
7416@itemx -Wunused-const-variable=@var{n}
d77de738
ML
7417Warn whenever a constant static variable is unused aside from its declaration.
7418@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7419for C, but not for C++. In C this declares variable storage, but in C++ this
7420is not an error since const variables take the place of @code{#define}s.
7421
7422To suppress this warning use the @code{unused} attribute
7423(@pxref{Variable Attributes}).
7424
7425@table @gcctabopt
7426@item -Wunused-const-variable=1
7427This is the warning level that is enabled by @option{-Wunused-variable} for
7428C. It warns only about unused static const variables defined in the main
7429compilation unit, but not about static const variables declared in any
7430header included.
7431
7432@item -Wunused-const-variable=2
7433This warning level also warns for unused constant static variables in
7434headers (excluding system headers). This is the warning level of
7435@option{-Wunused-const-variable} and must be explicitly requested since
7436in C++ this isn't an error and in C it might be harder to clean up all
7437headers included.
7438@end table
7439
d77de738
ML
7440@opindex Wunused-value
7441@opindex Wno-unused-value
ddf6fe37 7442@item -Wunused-value
d77de738
ML
7443Warn whenever a statement computes a result that is explicitly not
7444used. To suppress this warning cast the unused expression to
7445@code{void}. This includes an expression-statement or the left-hand
7446side of a comma expression that contains no side effects. For example,
7447an expression such as @code{x[i,j]} causes a warning, while
7448@code{x[(void)i,j]} does not.
7449
7450This warning is enabled by @option{-Wall}.
7451
d77de738
ML
7452@opindex Wunused
7453@opindex Wno-unused
ddf6fe37 7454@item -Wunused
d77de738
ML
7455All the above @option{-Wunused} options combined.
7456
7457In order to get a warning about an unused function parameter, you must
7458either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7459@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7460
d77de738
ML
7461@opindex Wuninitialized
7462@opindex Wno-uninitialized
ddf6fe37 7463@item -Wuninitialized
d77de738
ML
7464Warn if an object with automatic or allocated storage duration is used
7465without having been initialized. In C++, also warn if a non-static
7466reference or non-static @code{const} member appears in a class without
7467constructors.
7468
7469In addition, passing a pointer (or in C++, a reference) to an uninitialized
7470object to a @code{const}-qualified argument of a built-in function known to
7471read the object is also diagnosed by this warning.
7472(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7473
7474If you want to warn about code that uses the uninitialized value of the
7475variable in its own initializer, use the @option{-Winit-self} option.
7476
7477These warnings occur for individual uninitialized elements of
7478structure, union or array variables as well as for variables that are
7479uninitialized as a whole. They do not occur for variables or elements
7480declared @code{volatile}. Because these warnings depend on
7481optimization, the exact variables or elements for which there are
7482warnings depend on the precise optimization options and version of GCC
7483used.
7484
7485Note that there may be no warning about a variable that is used only
7486to compute a value that itself is never used, because such
7487computations may be deleted by data flow analysis before the warnings
7488are printed.
7489
7490In C++, this warning also warns about using uninitialized objects in
7491member-initializer-lists. For example, GCC warns about @code{b} being
7492uninitialized in the following snippet:
7493
7494@smallexample
7495struct A @{
7496 int a;
7497 int b;
7498 A() : a(b) @{ @}
7499@};
7500@end smallexample
7501
d77de738
ML
7502@opindex Winvalid-memory-model
7503@opindex Wno-invalid-memory-model
ddf6fe37 7504@item -Wno-invalid-memory-model
d77de738
ML
7505This option controls warnings
7506for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7507and the C11 atomic generic functions with a memory consistency argument
7508that is either invalid for the operation or outside the range of values
7509of the @code{memory_order} enumeration. For example, since the
7510@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7511defined for the relaxed, release, and sequentially consistent memory
7512orders the following code is diagnosed:
7513
7514@smallexample
7515void store (int *i)
7516@{
7517 __atomic_store_n (i, 0, memory_order_consume);
7518@}
7519@end smallexample
7520
7521@option{-Winvalid-memory-model} is enabled by default.
7522
d77de738
ML
7523@opindex Wmaybe-uninitialized
7524@opindex Wno-maybe-uninitialized
ddf6fe37 7525@item -Wmaybe-uninitialized
d77de738
ML
7526For an object with automatic or allocated storage duration, if there exists
7527a path from the function entry to a use of the object that is initialized,
7528but there exist some other paths for which the object is not initialized,
7529the compiler emits a warning if it cannot prove the uninitialized paths
7530are not executed at run time.
7531
7532In addition, passing a pointer (or in C++, a reference) to an uninitialized
7533object to a @code{const}-qualified function argument is also diagnosed by
7534this warning. (@option{-Wuninitialized} is issued for built-in functions
7535known to read the object.) Annotating the function with attribute
7536@code{access (none)} indicates that the argument isn't used to access
7537the object and avoids the warning (@pxref{Common Function Attributes}).
7538
7539These warnings are only possible in optimizing compilation, because otherwise
7540GCC does not keep track of the state of variables.
7541
7542These warnings are made optional because GCC may not be able to determine when
7543the code is correct in spite of appearing to have an error. Here is one
7544example of how this can happen:
7545
7546@smallexample
7547@group
7548@{
7549 int x;
7550 switch (y)
7551 @{
7552 case 1: x = 1;
7553 break;
7554 case 2: x = 4;
7555 break;
7556 case 3: x = 5;
7557 @}
7558 foo (x);
7559@}
7560@end group
7561@end smallexample
7562
7563@noindent
7564If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7565always initialized, but GCC doesn't know this. To suppress the
7566warning, you need to provide a default case with assert(0) or
7567similar code.
7568
7569@cindex @code{longjmp} warnings
7570This option also warns when a non-volatile automatic variable might be
7571changed by a call to @code{longjmp}.
7572The compiler sees only the calls to @code{setjmp}. It cannot know
7573where @code{longjmp} will be called; in fact, a signal handler could
7574call it at any point in the code. As a result, you may get a warning
7575even when there is in fact no problem because @code{longjmp} cannot
7576in fact be called at the place that would cause a problem.
7577
7578Some spurious warnings can be avoided if you declare all the functions
7579you use that never return as @code{noreturn}. @xref{Function
7580Attributes}.
7581
7582This warning is enabled by @option{-Wall} or @option{-Wextra}.
7583
d77de738
ML
7584@opindex Wunknown-pragmas
7585@opindex Wno-unknown-pragmas
7586@cindex warning for unknown pragmas
7587@cindex unknown pragmas, warning
7588@cindex pragmas, warning of unknown
f33d7a88 7589@item -Wunknown-pragmas
d77de738
ML
7590Warn when a @code{#pragma} directive is encountered that is not understood by
7591GCC@. If this command-line option is used, warnings are even issued
7592for unknown pragmas in system header files. This is not the case if
7593the warnings are only enabled by the @option{-Wall} command-line option.
7594
d77de738
ML
7595@opindex Wno-pragmas
7596@opindex Wpragmas
ddf6fe37 7597@item -Wno-pragmas
d77de738
ML
7598Do not warn about misuses of pragmas, such as incorrect parameters,
7599invalid syntax, or conflicts between pragmas. See also
7600@option{-Wunknown-pragmas}.
7601
d77de738
ML
7602@opindex Wno-prio-ctor-dtor
7603@opindex Wprio-ctor-dtor
ddf6fe37 7604@item -Wno-prio-ctor-dtor
d77de738
ML
7605Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7606The use of constructor and destructor attributes allow you to assign a
7607priority to the constructor/destructor to control its order of execution
7608before @code{main} is called or after it returns. The priority values must be
7609greater than 100 as the compiler reserves priority values between 0--100 for
7610the implementation.
7611
d77de738
ML
7612@opindex Wstrict-aliasing
7613@opindex Wno-strict-aliasing
ddf6fe37 7614@item -Wstrict-aliasing
d77de738
ML
7615This option is only active when @option{-fstrict-aliasing} is active.
7616It warns about code that might break the strict aliasing rules that the
7617compiler is using for optimization. The warning does not catch all
7618cases, but does attempt to catch the more common pitfalls. It is
7619included in @option{-Wall}.
7620It is equivalent to @option{-Wstrict-aliasing=3}
7621
d77de738 7622@opindex Wstrict-aliasing=n
ddf6fe37 7623@item -Wstrict-aliasing=n
d77de738
ML
7624This option is only active when @option{-fstrict-aliasing} is active.
7625It warns about code that might break the strict aliasing rules that the
7626compiler is using for optimization.
7627Higher levels correspond to higher accuracy (fewer false positives).
7628Higher levels also correspond to more effort, similar to the way @option{-O}
7629works.
7630@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7631
7632Level 1: Most aggressive, quick, least accurate.
7633Possibly useful when higher levels
7634do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7635false negatives. However, it has many false positives.
7636Warns for all pointer conversions between possibly incompatible types,
7637even if never dereferenced. Runs in the front end only.
7638
7639Level 2: Aggressive, quick, not too precise.
7640May still have many false positives (not as many as level 1 though),
7641and few false negatives (but possibly more than level 1).
7642Unlike level 1, it only warns when an address is taken. Warns about
7643incomplete types. Runs in the front end only.
7644
7645Level 3 (default for @option{-Wstrict-aliasing}):
7646Should have very few false positives and few false
7647negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7648Takes care of the common pun+dereference pattern in the front end:
7649@code{*(int*)&some_float}.
7650If optimization is enabled, it also runs in the back end, where it deals
7651with multiple statement cases using flow-sensitive points-to information.
7652Only warns when the converted pointer is dereferenced.
7653Does not warn about incomplete types.
7654
d77de738
ML
7655@opindex Wstrict-overflow
7656@opindex Wno-strict-overflow
ddf6fe37
AA
7657@item -Wstrict-overflow
7658@itemx -Wstrict-overflow=@var{n}
d77de738
ML
7659This option is only active when signed overflow is undefined.
7660It warns about cases where the compiler optimizes based on the
7661assumption that signed overflow does not occur. Note that it does not
7662warn about all cases where the code might overflow: it only warns
7663about cases where the compiler implements some optimization. Thus
7664this warning depends on the optimization level.
7665
7666An optimization that assumes that signed overflow does not occur is
7667perfectly safe if the values of the variables involved are such that
7668overflow never does, in fact, occur. Therefore this warning can
7669easily give a false positive: a warning about code that is not
7670actually a problem. To help focus on important issues, several
7671warning levels are defined. No warnings are issued for the use of
7672undefined signed overflow when estimating how many iterations a loop
7673requires, in particular when determining whether a loop will be
7674executed at all.
7675
7676@table @gcctabopt
7677@item -Wstrict-overflow=1
7678Warn about cases that are both questionable and easy to avoid. For
7679example the compiler simplifies
7680@code{x + 1 > x} to @code{1}. This level of
7681@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7682are not, and must be explicitly requested.
7683
7684@item -Wstrict-overflow=2
7685Also warn about other cases where a comparison is simplified to a
7686constant. For example: @code{abs (x) >= 0}. This can only be
7687simplified when signed integer overflow is undefined, because
7688@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7689zero. @option{-Wstrict-overflow} (with no level) is the same as
7690@option{-Wstrict-overflow=2}.
7691
7692@item -Wstrict-overflow=3
7693Also warn about other cases where a comparison is simplified. For
7694example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7695
7696@item -Wstrict-overflow=4
7697Also warn about other simplifications not covered by the above cases.
7698For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7699
7700@item -Wstrict-overflow=5
7701Also warn about cases where the compiler reduces the magnitude of a
7702constant involved in a comparison. For example: @code{x + 2 > y} is
7703simplified to @code{x + 1 >= y}. This is reported only at the
7704highest warning level because this simplification applies to many
7705comparisons, so this warning level gives a very large number of
7706false positives.
7707@end table
7708
d77de738
ML
7709@opindex Wstring-compare
7710@opindex Wno-string-compare
ddf6fe37 7711@item -Wstring-compare
d77de738
ML
7712Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7713determined to be either zero or non-zero in tests for such equality
7714owing to the length of one argument being greater than the size of
7715the array the other argument is stored in (or the bound in the case
7716of @code{strncmp}). Such calls could be mistakes. For example,
7717the call to @code{strcmp} below is diagnosed because its result is
7718necessarily non-zero irrespective of the contents of the array @code{a}.
7719
7720@smallexample
7721extern char a[4];
7722void f (char *d)
7723@{
7724 strcpy (d, "string");
7725 @dots{}
7726 if (0 == strcmp (a, d)) // cannot be true
7727 puts ("a and d are the same");
7728@}
7729@end smallexample
7730
7731@option{-Wstring-compare} is enabled by @option{-Wextra}.
7732
ddf6fe37
AA
7733@opindex Wstringop-overflow
7734@opindex Wno-stringop-overflow
d77de738
ML
7735@item -Wno-stringop-overflow
7736@item -Wstringop-overflow
7737@itemx -Wstringop-overflow=@var{type}
d77de738
ML
7738Warn for calls to string manipulation functions such as @code{memcpy} and
7739@code{strcpy} that are determined to overflow the destination buffer. The
7740optional argument is one greater than the type of Object Size Checking to
7741perform to determine the size of the destination. @xref{Object Size Checking}.
7742The argument is meaningful only for functions that operate on character arrays
7743but not for raw memory functions like @code{memcpy} which always make use
7744of Object Size type-0. The option also warns for calls that specify a size
7745in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7746The option produces the best results with optimization enabled but can detect
7747a small subset of simple buffer overflows even without optimization in
7748calls to the GCC built-in functions like @code{__builtin_memcpy} that
7749correspond to the standard functions. In any case, the option warns about
7750just a subset of buffer overflows detected by the corresponding overflow
7751checking built-ins. For example, the option issues a warning for
7752the @code{strcpy} call below because it copies at least 5 characters
7753(the string @code{"blue"} including the terminating NUL) into the buffer
7754of size 4.
7755
7756@smallexample
7757enum Color @{ blue, purple, yellow @};
7758const char* f (enum Color clr)
7759@{
7760 static char buf [4];
7761 const char *str;
7762 switch (clr)
7763 @{
7764 case blue: str = "blue"; break;
7765 case purple: str = "purple"; break;
7766 case yellow: str = "yellow"; break;
7767 @}
7768
7769 return strcpy (buf, str); // warning here
7770@}
7771@end smallexample
7772
7773Option @option{-Wstringop-overflow=2} is enabled by default.
7774
7775@table @gcctabopt
d77de738
ML
7776@opindex Wstringop-overflow
7777@opindex Wno-stringop-overflow
ddf6fe37
AA
7778@item -Wstringop-overflow
7779@itemx -Wstringop-overflow=1
d77de738
ML
7780The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7781to determine the sizes of destination objects. At this setting the option
7782does not warn for writes past the end of subobjects of larger objects accessed
7783by pointers unless the size of the largest surrounding object is known. When
7784the destination may be one of several objects it is assumed to be the largest
7785one of them. On Linux systems, when optimization is enabled at this setting
7786the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7787is defined to a non-zero value.
7788
7789@item -Wstringop-overflow=2
7790The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7791to determine the sizes of destination objects. At this setting the option
7792warns about overflows when writing to members of the largest complete
7793objects whose exact size is known. However, it does not warn for excessive
7794writes to the same members of unknown objects referenced by pointers since
7795they may point to arrays containing unknown numbers of elements. This is
7796the default setting of the option.
7797
7798@item -Wstringop-overflow=3
7799The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7800to determine the sizes of destination objects. At this setting the option
7801warns about overflowing the smallest object or data member. This is the
7802most restrictive setting of the option that may result in warnings for safe
7803code.
7804
7805@item -Wstringop-overflow=4
7806The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7807to determine the sizes of destination objects. At this setting the option
7808warns about overflowing any data members, and when the destination is
7809one of several objects it uses the size of the largest of them to decide
7810whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7811setting of the option may result in warnings for benign code.
7812@end table
7813
d77de738
ML
7814@opindex Wstringop-overread
7815@opindex Wno-stringop-overread
ddf6fe37 7816@item -Wno-stringop-overread
d77de738
ML
7817Warn for calls to string manipulation functions such as @code{memchr}, or
7818@code{strcpy} that are determined to read past the end of the source
7819sequence.
7820
7821Option @option{-Wstringop-overread} is enabled by default.
7822
d77de738
ML
7823@opindex Wstringop-truncation
7824@opindex Wno-stringop-truncation
ddf6fe37 7825@item -Wno-stringop-truncation
d77de738
ML
7826Do not warn for calls to bounded string manipulation functions
7827such as @code{strncat},
7828@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7829or leave the destination unchanged.
7830
7831In the following example, the call to @code{strncat} specifies a bound that
7832is less than the length of the source string. As a result, the copy of
7833the source will be truncated and so the call is diagnosed. To avoid the
7834warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7835
7836@smallexample
7837void append (char *buf, size_t bufsize)
7838@{
7839 strncat (buf, ".txt", 3);
7840@}
7841@end smallexample
7842
7843As another example, the following call to @code{strncpy} results in copying
7844to @code{d} just the characters preceding the terminating NUL, without
7845appending the NUL to the end. Assuming the result of @code{strncpy} is
7846necessarily a NUL-terminated string is a common mistake, and so the call
7847is diagnosed. To avoid the warning when the result is not expected to be
7848NUL-terminated, call @code{memcpy} instead.
7849
7850@smallexample
7851void copy (char *d, const char *s)
7852@{
7853 strncpy (d, s, strlen (s));
7854@}
7855@end smallexample
7856
7857In the following example, the call to @code{strncpy} specifies the size
7858of the destination buffer as the bound. If the length of the source
7859string is equal to or greater than this size the result of the copy will
7860not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7861the warning, specify @code{sizeof buf - 1} as the bound and set the last
7862element of the buffer to @code{NUL}.
7863
7864@smallexample
7865void copy (const char *s)
7866@{
7867 char buf[80];
7868 strncpy (buf, s, sizeof buf);
7869 @dots{}
7870@}
7871@end smallexample
7872
7873In situations where a character array is intended to store a sequence
7874of bytes with no terminating @code{NUL} such an array may be annotated
7875with attribute @code{nonstring} to avoid this warning. Such arrays,
7876however, are not suitable arguments to functions that expect
7877@code{NUL}-terminated strings. To help detect accidental misuses of
7878such arrays GCC issues warnings unless it can prove that the use is
7879safe. @xref{Common Variable Attributes}.
7880
2a27ae32
QZ
7881@opindex Wstrict-flex-arrays
7882@opindex Wno-strict-flex-arrays
ddf6fe37 7883@item -Wstrict-flex-arrays
2a27ae32
QZ
7884Warn about inproper usages of flexible array members
7885according to the @var{level} of the @code{strict_flex_array (@var{level})}
7886attribute attached to the trailing array field of a structure if it's
7887available, otherwise according to the @var{level} of the option
7888@option{-fstrict-flex-arrays=@var{level}}.
7889
7890This option is effective only when @var{level} is bigger than 0. Otherwise,
7891it will be ignored with a warning.
7892
7893when @var{level}=1, warnings will be issued for a trailing array reference
7894of a structure that have 2 or more elements if the trailing array is referenced
7895as a flexible array member.
7896
7897when @var{level}=2, in addition to @var{level}=1, additional warnings will be
7898issued for a trailing one-element array reference of a structure
7899if the array is referenced as a flexible array member.
7900
7901when @var{level}=3, in addition to @var{level}=2, additional warnings will be
7902issued for a trailing zero-length array reference of a structure
7903if the array is referenced as a flexible array member.
7904
7905
d77de738
ML
7906@opindex Wsuggest-attribute=
7907@opindex Wno-suggest-attribute=
ddf6fe37 7908@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
d77de738
ML
7909Warn for cases where adding an attribute may be beneficial. The
7910attributes currently supported are listed below.
7911
7912@table @gcctabopt
d77de738
ML
7913@opindex Wsuggest-attribute=pure
7914@opindex Wno-suggest-attribute=pure
7915@opindex Wsuggest-attribute=const
7916@opindex Wno-suggest-attribute=const
7917@opindex Wsuggest-attribute=noreturn
7918@opindex Wno-suggest-attribute=noreturn
7919@opindex Wmissing-noreturn
7920@opindex Wno-missing-noreturn
7921@opindex Wsuggest-attribute=malloc
7922@opindex Wno-suggest-attribute=malloc
ddf6fe37
AA
7923@item -Wsuggest-attribute=pure
7924@itemx -Wsuggest-attribute=const
7925@itemx -Wsuggest-attribute=noreturn
7926@itemx -Wmissing-noreturn
7927@itemx -Wsuggest-attribute=malloc
d77de738
ML
7928
7929Warn about functions that might be candidates for attributes
7930@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7931only warns for functions visible in other compilation units or (in the case of
7932@code{pure} and @code{const}) if it cannot prove that the function returns
7933normally. A function returns normally if it doesn't contain an infinite loop or
7934return abnormally by throwing, calling @code{abort} or trapping. This analysis
7935requires option @option{-fipa-pure-const}, which is enabled by default at
7936@option{-O} and higher. Higher optimization levels improve the accuracy
7937of the analysis.
7938
d77de738
ML
7939@opindex Wsuggest-attribute=format
7940@opindex Wmissing-format-attribute
7941@opindex Wno-suggest-attribute=format
7942@opindex Wno-missing-format-attribute
7943@opindex Wformat
7944@opindex Wno-format
ddf6fe37
AA
7945@item -Wsuggest-attribute=format
7946@itemx -Wmissing-format-attribute
d77de738
ML
7947
7948Warn about function pointers that might be candidates for @code{format}
7949attributes. Note these are only possible candidates, not absolute ones.
7950GCC guesses that function pointers with @code{format} attributes that
7951are used in assignment, initialization, parameter passing or return
7952statements should have a corresponding @code{format} attribute in the
7953resulting type. I.e.@: the left-hand side of the assignment or
7954initialization, the type of the parameter variable, or the return type
7955of the containing function respectively should also have a @code{format}
7956attribute to avoid the warning.
7957
7958GCC also warns about function definitions that might be
7959candidates for @code{format} attributes. Again, these are only
7960possible candidates. GCC guesses that @code{format} attributes
7961might be appropriate for any function that calls a function like
7962@code{vprintf} or @code{vscanf}, but this might not always be the
7963case, and some functions for which @code{format} attributes are
7964appropriate may not be detected.
7965
d77de738
ML
7966@opindex Wsuggest-attribute=cold
7967@opindex Wno-suggest-attribute=cold
ddf6fe37 7968@item -Wsuggest-attribute=cold
d77de738
ML
7969
7970Warn about functions that might be candidates for @code{cold} attribute. This
7971is based on static detection and generally only warns about functions which
7972always leads to a call to another @code{cold} function such as wrappers of
7973C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
7974@end table
7975
d77de738
ML
7976@opindex Wno-alloc-zero
7977@opindex Walloc-zero
ddf6fe37 7978@item -Walloc-zero
d77de738
ML
7979Warn about calls to allocation functions decorated with attribute
7980@code{alloc_size} that specify zero bytes, including those to the built-in
7981forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
7982@code{malloc}, and @code{realloc}. Because the behavior of these functions
7983when called with a zero size differs among implementations (and in the case
7984of @code{realloc} has been deprecated) relying on it may result in subtle
7985portability bugs and should be avoided.
7986
d77de738
ML
7987@opindex Walloc-size-larger-than=
7988@opindex Wno-alloc-size-larger-than
ddf6fe37 7989@item -Walloc-size-larger-than=@var{byte-size}
d77de738
ML
7990Warn about calls to functions decorated with attribute @code{alloc_size}
7991that attempt to allocate objects larger than the specified number of bytes,
7992or where the result of the size computation in an integer type with infinite
7993precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
7994@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
7995Warnings controlled by the option can be disabled either by specifying
7996@var{byte-size} of @samp{SIZE_MAX} or more or by
7997@option{-Wno-alloc-size-larger-than}.
7998@xref{Function Attributes}.
7999
d77de738 8000@opindex Wno-alloc-size-larger-than
ddf6fe37 8001@item -Wno-alloc-size-larger-than
d77de738
ML
8002Disable @option{-Walloc-size-larger-than=} warnings. The option is
8003equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
8004larger.
8005
d77de738
ML
8006@opindex Wno-alloca
8007@opindex Walloca
ddf6fe37 8008@item -Walloca
d77de738
ML
8009This option warns on all uses of @code{alloca} in the source.
8010
d77de738
ML
8011@opindex Walloca-larger-than=
8012@opindex Wno-alloca-larger-than
ddf6fe37 8013@item -Walloca-larger-than=@var{byte-size}
d77de738
ML
8014This option warns on calls to @code{alloca} with an integer argument whose
8015value is either zero, or that is not bounded by a controlling predicate
8016that limits its value to at most @var{byte-size}. It also warns for calls
8017to @code{alloca} where the bound value is unknown. Arguments of non-integer
8018types are considered unbounded even if they appear to be constrained to
8019the expected range.
8020
8021For example, a bounded case of @code{alloca} could be:
8022
8023@smallexample
8024void func (size_t n)
8025@{
8026 void *p;
8027 if (n <= 1000)
8028 p = alloca (n);
8029 else
8030 p = malloc (n);
8031 f (p);
8032@}
8033@end smallexample
8034
8035In the above example, passing @code{-Walloca-larger-than=1000} would not
8036issue a warning because the call to @code{alloca} is known to be at most
80371000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8038the compiler would emit a warning.
8039
8040Unbounded uses, on the other hand, are uses of @code{alloca} with no
8041controlling predicate constraining its integer argument. For example:
8042
8043@smallexample
8044void func ()
8045@{
8046 void *p = alloca (n);
8047 f (p);
8048@}
8049@end smallexample
8050
8051If @code{-Walloca-larger-than=500} were passed, the above would trigger
8052a warning, but this time because of the lack of bounds checking.
8053
8054Note, that even seemingly correct code involving signed integers could
8055cause a warning:
8056
8057@smallexample
8058void func (signed int n)
8059@{
8060 if (n < 500)
8061 @{
8062 p = alloca (n);
8063 f (p);
8064 @}
8065@}
8066@end smallexample
8067
8068In the above example, @var{n} could be negative, causing a larger than
8069expected argument to be implicitly cast into the @code{alloca} call.
8070
8071This option also warns when @code{alloca} is used in a loop.
8072
8073@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8074but is usually only effective when @option{-ftree-vrp} is active (default
8075for @option{-O2} and above).
8076
8077See also @option{-Wvla-larger-than=}@samp{byte-size}.
8078
d77de738 8079@opindex Wno-alloca-larger-than
ddf6fe37 8080@item -Wno-alloca-larger-than
d77de738
ML
8081Disable @option{-Walloca-larger-than=} warnings. The option is
8082equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8083
d77de738
ML
8084@opindex Warith-conversion
8085@opindex Wno-arith-conversion
ddf6fe37 8086@item -Warith-conversion
d77de738
ML
8087Do warn about implicit conversions from arithmetic operations even
8088when conversion of the operands to the same type cannot change their
8089values. This affects warnings from @option{-Wconversion},
8090@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8091
8092@smallexample
8093@group
8094void f (char c, int i)
8095@{
8096 c = c + i; // warns with @option{-Wconversion}
8097 c = c + 1; // only warns with @option{-Warith-conversion}
8098@}
8099@end group
8100@end smallexample
8101
d77de738
ML
8102@opindex Wno-array-bounds
8103@opindex Warray-bounds
ddf6fe37
AA
8104@item -Warray-bounds
8105@itemx -Warray-bounds=@var{n}
d77de738
ML
8106Warn about out of bounds subscripts or offsets into arrays. This warning
8107is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8108is active (the default for @option{-O2} and above) but a subset of instances
8109are issued even without optimization.
8110
710c9676
QZ
8111By default, the trailing array of a structure will be treated as a flexible
8112array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8113if it is declared as either a flexible array member per C99 standard onwards
8114(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8115array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8116zero-length arrays or one-element arrays are not warned by default.
8117
8118You can add the option @option{-fstrict-flex-arrays} or
8119@option{-fstrict-flex-arrays=@var{level}} to control how this
8120option treat trailing array of a structure as a flexible array member:
8121
8122when @var{level}<=1, no change to the default behavior.
8123
8124when @var{level}=2, additional warnings will be issued for out of bounds
8125subscripts or offsets into one-element arrays;
8126
8127when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8128issued for out of bounds subscripts or offsets into zero-length arrays.
8129
d77de738
ML
8130@table @gcctabopt
8131@item -Warray-bounds=1
8132This is the default warning level of @option{-Warray-bounds} and is enabled
8133by @option{-Wall}; higher levels are not, and must be explicitly requested.
8134
8135@item -Warray-bounds=2
710c9676
QZ
8136This warning level also warns about the intermediate results of pointer
8137arithmetic that may yield out of bounds values. This warning level may
8138give a larger number of false positives and is deactivated by default.
d77de738
ML
8139@end table
8140
d77de738
ML
8141@opindex Warray-compare
8142@opindex Wno-array-compare
ddf6fe37 8143@item -Warray-compare
d77de738
ML
8144Warn about equality and relational comparisons between two operands of array
8145type. This comparison was deprecated in C++20. For example:
8146
8147@smallexample
8148int arr1[5];
8149int arr2[5];
8150bool same = arr1 == arr2;
8151@end smallexample
8152
8153@option{-Warray-compare} is enabled by @option{-Wall}.
8154
ddf6fe37 8155@opindex Wno-array-parameter
d77de738
ML
8156@item -Warray-parameter
8157@itemx -Warray-parameter=@var{n}
d77de738
ML
8158Warn about redeclarations of functions involving arguments of array or
8159pointer types of inconsistent kinds or forms, and enable the detection
8160of out-of-bounds accesses to such parameters by warnings such as
8161@option{-Warray-bounds}.
8162
8163If the first function declaration uses the array form the bound specified
8164in the array is assumed to be the minimum number of elements expected to
8165be provided in calls to the function and the maximum number of elements
8166accessed by it. Failing to provide arguments of sufficient size or accessing
8167more than the maximum number of elements may be diagnosed by warnings such
8168as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8169involving array parameters declared using the @code{T[static N]} form.
8170
8171For example, the warning triggers for the following redeclarations because
8172the first one allows an array of any size to be passed to @code{f} while
8173the second one with the keyword @code{static} specifies that the array
8174argument must have at least four elements.
8175
8176@smallexample
8177void f (int[static 4]);
8178void f (int[]); // warning (inconsistent array form)
8179
8180void g (void)
8181@{
8182 int *p = (int *)malloc (4);
8183 f (p); // warning (array too small)
8184 @dots{}
8185@}
8186@end smallexample
8187
8188At level 2 the warning also triggers for redeclarations involving any other
8189inconsistency in array or pointer argument forms denoting array sizes.
8190Pointers and arrays of unspecified bound are considered equivalent and do
8191not trigger a warning.
8192
8193@smallexample
8194void g (int*);
8195void g (int[]); // no warning
8196void g (int[8]); // warning (inconsistent array bound)
8197@end smallexample
8198
8199@option{-Warray-parameter=2} is included in @option{-Wall}. The
8200@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8201involving Variable Length Array arguments.
8202
d77de738
ML
8203@opindex Wattribute-alias
8204@opindex Wno-attribute-alias
ddf6fe37
AA
8205@item -Wattribute-alias=@var{n}
8206@itemx -Wno-attribute-alias
d77de738
ML
8207Warn about declarations using the @code{alias} and similar attributes whose
8208target is incompatible with the type of the alias.
8209@xref{Function Attributes,,Declaring Attributes of Functions}.
8210
8211@table @gcctabopt
8212@item -Wattribute-alias=1
8213The default warning level of the @option{-Wattribute-alias} option diagnoses
8214incompatibilities between the type of the alias declaration and that of its
8215target. Such incompatibilities are typically indicative of bugs.
8216
8217@item -Wattribute-alias=2
8218
8219At this level @option{-Wattribute-alias} also diagnoses cases where
8220the attributes of the alias declaration are more restrictive than the
8221attributes applied to its target. These mismatches can potentially
8222result in incorrect code generation. In other cases they may be
8223benign and could be resolved simply by adding the missing attribute to
8224the target. For comparison, see the @option{-Wmissing-attributes}
8225option, which controls diagnostics when the alias declaration is less
8226restrictive than the target, rather than more restrictive.
8227
8228Attributes considered include @code{alloc_align}, @code{alloc_size},
8229@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8230@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8231@code{returns_nonnull}, and @code{returns_twice}.
8232@end table
8233
8234@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8235This is the default. You can disable these warnings with either
8236@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8237
d77de738
ML
8238@opindex Wbidi-chars=
8239@opindex Wbidi-chars
8240@opindex Wno-bidi-chars
ddf6fe37 8241@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
d77de738
ML
8242Warn about possibly misleading UTF-8 bidirectional control characters in
8243comments, string literals, character constants, and identifiers. Such
8244characters can change left-to-right writing direction into right-to-left
8245(and vice versa), which can cause confusion between the logical order and
8246visual order. This may be dangerous; for instance, it may seem that a piece
8247of code is not commented out, whereas it in fact is.
8248
8249There are three levels of warning supported by GCC@. The default is
8250@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8251bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8252@option{-Wbidi-chars=any} warns about any use of bidirectional control
8253characters.
8254
8255By default, this warning does not warn about UCNs. It is, however, possible
8256to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8257@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8258and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8259@option{-Wbidi-chars=any} was specified.
8260
d77de738
ML
8261@opindex Wno-bool-compare
8262@opindex Wbool-compare
ddf6fe37 8263@item -Wbool-compare
d77de738
ML
8264Warn about boolean expression compared with an integer value different from
8265@code{true}/@code{false}. For instance, the following comparison is
8266always false:
8267@smallexample
8268int n = 5;
8269@dots{}
8270if ((n > 1) == 2) @{ @dots{} @}
8271@end smallexample
8272This warning is enabled by @option{-Wall}.
8273
d77de738
ML
8274@opindex Wno-bool-operation
8275@opindex Wbool-operation
ddf6fe37 8276@item -Wbool-operation
d77de738
ML
8277Warn about suspicious operations on expressions of a boolean type. For
8278instance, bitwise negation of a boolean is very likely a bug in the program.
8279For C, this warning also warns about incrementing or decrementing a boolean,
8280which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8281Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8282
8283This warning is enabled by @option{-Wall}.
8284
d77de738
ML
8285@opindex Wno-duplicated-branches
8286@opindex Wduplicated-branches
ddf6fe37 8287@item -Wduplicated-branches
d77de738
ML
8288Warn when an if-else has identical branches. This warning detects cases like
8289@smallexample
8290if (p != NULL)
8291 return 0;
8292else
8293 return 0;
8294@end smallexample
8295It doesn't warn when both branches contain just a null statement. This warning
8296also warn for conditional operators:
8297@smallexample
8298 int i = x ? *p : *p;
8299@end smallexample
8300
d77de738
ML
8301@opindex Wno-duplicated-cond
8302@opindex Wduplicated-cond
ddf6fe37 8303@item -Wduplicated-cond
d77de738
ML
8304Warn about duplicated conditions in an if-else-if chain. For instance,
8305warn for the following code:
8306@smallexample
8307if (p->q != NULL) @{ @dots{} @}
8308else if (p->q != NULL) @{ @dots{} @}
8309@end smallexample
8310
d77de738
ML
8311@opindex Wno-frame-address
8312@opindex Wframe-address
ddf6fe37 8313@item -Wframe-address
d77de738
ML
8314Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8315is called with an argument greater than 0. Such calls may return indeterminate
8316values or crash the program. The warning is included in @option{-Wall}.
8317
d77de738
ML
8318@opindex Wno-discarded-qualifiers
8319@opindex Wdiscarded-qualifiers
ddf6fe37 8320@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8321Do not warn if type qualifiers on pointers are being discarded.
8322Typically, the compiler warns if a @code{const char *} variable is
8323passed to a function that takes a @code{char *} parameter. This option
8324can be used to suppress such a warning.
8325
d77de738
ML
8326@opindex Wno-discarded-array-qualifiers
8327@opindex Wdiscarded-array-qualifiers
ddf6fe37 8328@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8329Do not warn if type qualifiers on arrays which are pointer targets
8330are being discarded. Typically, the compiler warns if a
8331@code{const int (*)[]} variable is passed to a function that
8332takes a @code{int (*)[]} parameter. This option can be used to
8333suppress such a warning.
8334
d77de738
ML
8335@opindex Wno-incompatible-pointer-types
8336@opindex Wincompatible-pointer-types
ddf6fe37 8337@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
d77de738
ML
8338Do not warn when there is a conversion between pointers that have incompatible
8339types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8340which warns for pointer argument passing or assignment with different
8341signedness.
8342
d77de738
ML
8343@opindex Wno-int-conversion
8344@opindex Wint-conversion
ddf6fe37 8345@item -Wno-int-conversion @r{(C and Objective-C only)}
d77de738
ML
8346Do not warn about incompatible integer to pointer and pointer to integer
8347conversions. This warning is about implicit conversions; for explicit
8348conversions the warnings @option{-Wno-int-to-pointer-cast} and
8349@option{-Wno-pointer-to-int-cast} may be used.
8350
d77de738
ML
8351@opindex Wzero-length-bounds
8352@opindex Wzero-length-bounds
ddf6fe37 8353@item -Wzero-length-bounds
d77de738
ML
8354Warn about accesses to elements of zero-length array members that might
8355overlap other members of the same object. Declaring interior zero-length
8e9c65d3 8356arrays is discouraged because accesses to them are undefined.
d77de738
ML
8357@xref{Zero Length}.
8358
8359For example, the first two stores in function @code{bad} are diagnosed
8360because the array elements overlap the subsequent members @code{b} and
8361@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8362because it is beyond the bounds of the enclosing object.
8363
8364@smallexample
8365struct X @{ int a[0]; int b, c; @};
8366struct X x;
8367
8368void bad (void)
8369@{
8370 x.a[0] = 0; // -Wzero-length-bounds
8371 x.a[1] = 1; // -Wzero-length-bounds
8372 x.a[2] = 2; // -Warray-bounds
8373@}
8374@end smallexample
8375
8376Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8377
d77de738
ML
8378@opindex Wno-div-by-zero
8379@opindex Wdiv-by-zero
ddf6fe37 8380@item -Wno-div-by-zero
d77de738
ML
8381Do not warn about compile-time integer division by zero. Floating-point
8382division by zero is not warned about, as it can be a legitimate way of
8383obtaining infinities and NaNs.
8384
d77de738
ML
8385@opindex Wsystem-headers
8386@opindex Wno-system-headers
8387@cindex warnings from system headers
8388@cindex system headers, warnings from
f33d7a88 8389@item -Wsystem-headers
d77de738
ML
8390Print warning messages for constructs found in system header files.
8391Warnings from system headers are normally suppressed, on the assumption
8392that they usually do not indicate real problems and would only make the
8393compiler output harder to read. Using this command-line option tells
8394GCC to emit warnings from system headers as if they occurred in user
8395code. However, note that using @option{-Wall} in conjunction with this
8396option does @emph{not} warn about unknown pragmas in system
8397headers---for that, @option{-Wunknown-pragmas} must also be used.
8398
d77de738
ML
8399@opindex Wtautological-compare
8400@opindex Wno-tautological-compare
ddf6fe37 8401@item -Wtautological-compare
d77de738
ML
8402Warn if a self-comparison always evaluates to true or false. This
8403warning detects various mistakes such as:
8404@smallexample
8405int i = 1;
8406@dots{}
8407if (i > i) @{ @dots{} @}
8408@end smallexample
8409
8410This warning also warns about bitwise comparisons that always evaluate
8411to true or false, for instance:
8412@smallexample
8413if ((a & 16) == 10) @{ @dots{} @}
8414@end smallexample
8415will always be false.
8416
8417This warning is enabled by @option{-Wall}.
8418
d77de738
ML
8419@opindex Wtrampolines
8420@opindex Wno-trampolines
ddf6fe37 8421@item -Wtrampolines
d77de738
ML
8422Warn about trampolines generated for pointers to nested functions.
8423A trampoline is a small piece of data or code that is created at run
8424time on the stack when the address of a nested function is taken, and is
8425used to call the nested function indirectly. For some targets, it is
8426made up of data only and thus requires no special treatment. But, for
8427most targets, it is made up of code and thus requires the stack to be
8428made executable in order for the program to work properly.
8429
d77de738
ML
8430@opindex Wfloat-equal
8431@opindex Wno-float-equal
ddf6fe37 8432@item -Wfloat-equal
d77de738
ML
8433Warn if floating-point values are used in equality comparisons.
8434
8435The idea behind this is that sometimes it is convenient (for the
8436programmer) to consider floating-point values as approximations to
8437infinitely precise real numbers. If you are doing this, then you need
8438to compute (by analyzing the code, or in some other way) the maximum or
8439likely maximum error that the computation introduces, and allow for it
8440when performing comparisons (and when producing output, but that's a
8441different problem). In particular, instead of testing for equality, you
8442should check to see whether the two values have ranges that overlap; and
8443this is done with the relational operators, so equality comparisons are
8444probably mistaken.
8445
d77de738
ML
8446@opindex Wtraditional
8447@opindex Wno-traditional
ddf6fe37 8448@item -Wtraditional @r{(C and Objective-C only)}
d77de738
ML
8449Warn about certain constructs that behave differently in traditional and
8450ISO C@. Also warn about ISO C constructs that have no traditional C
8451equivalent, and/or problematic constructs that should be avoided.
8452
8453@itemize @bullet
8454@item
8455Macro parameters that appear within string literals in the macro body.
8456In traditional C macro replacement takes place within string literals,
8457but in ISO C it does not.
8458
8459@item
8460In traditional C, some preprocessor directives did not exist.
8461Traditional preprocessors only considered a line to be a directive
8462if the @samp{#} appeared in column 1 on the line. Therefore
8463@option{-Wtraditional} warns about directives that traditional C
8464understands but ignores because the @samp{#} does not appear as the
8465first character on the line. It also suggests you hide directives like
8466@code{#pragma} not understood by traditional C by indenting them. Some
8467traditional implementations do not recognize @code{#elif}, so this option
8468suggests avoiding it altogether.
8469
8470@item
8471A function-like macro that appears without arguments.
8472
8473@item
8474The unary plus operator.
8475
8476@item
8477The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8478constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8479constants.) Note, these suffixes appear in macros defined in the system
8480headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8481Use of these macros in user code might normally lead to spurious
8482warnings, however GCC's integrated preprocessor has enough context to
8483avoid warning in these cases.
8484
8485@item
8486A function declared external in one block and then used after the end of
8487the block.
8488
8489@item
8490A @code{switch} statement has an operand of type @code{long}.
8491
8492@item
8493A non-@code{static} function declaration follows a @code{static} one.
8494This construct is not accepted by some traditional C compilers.
8495
8496@item
8497The ISO type of an integer constant has a different width or
8498signedness from its traditional type. This warning is only issued if
8499the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8500typically represent bit patterns, are not warned about.
8501
8502@item
8503Usage of ISO string concatenation is detected.
8504
8505@item
8506Initialization of automatic aggregates.
8507
8508@item
8509Identifier conflicts with labels. Traditional C lacks a separate
8510namespace for labels.
8511
8512@item
8513Initialization of unions. If the initializer is zero, the warning is
8514omitted. This is done under the assumption that the zero initializer in
8515user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8516initializer warnings and relies on default initialization to zero in the
8517traditional C case.
8518
8519@item
8520Conversions by prototypes between fixed/floating-point values and vice
8521versa. The absence of these prototypes when compiling with traditional
8522C causes serious problems. This is a subset of the possible
8523conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8524
8525@item
8526Use of ISO C style function definitions. This warning intentionally is
8527@emph{not} issued for prototype declarations or variadic functions
8528because these ISO C features appear in your code when using
8529libiberty's traditional C compatibility macros, @code{PARAMS} and
8530@code{VPARAMS}. This warning is also bypassed for nested functions
8531because that feature is already a GCC extension and thus not relevant to
8532traditional C compatibility.
8533@end itemize
8534
d77de738
ML
8535@opindex Wtraditional-conversion
8536@opindex Wno-traditional-conversion
ddf6fe37 8537@item -Wtraditional-conversion @r{(C and Objective-C only)}
d77de738
ML
8538Warn if a prototype causes a type conversion that is different from what
8539would happen to the same argument in the absence of a prototype. This
8540includes conversions of fixed point to floating and vice versa, and
8541conversions changing the width or signedness of a fixed-point argument
8542except when the same as the default promotion.
8543
d77de738
ML
8544@opindex Wdeclaration-after-statement
8545@opindex Wno-declaration-after-statement
ddf6fe37 8546@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
d77de738
ML
8547Warn when a declaration is found after a statement in a block. This
8548construct, known from C++, was introduced with ISO C99 and is by default
8549allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8550
d77de738
ML
8551@opindex Wshadow
8552@opindex Wno-shadow
ddf6fe37 8553@item -Wshadow
d77de738
ML
8554Warn whenever a local variable or type declaration shadows another
8555variable, parameter, type, class member (in C++), or instance variable
8556(in Objective-C) or whenever a built-in function is shadowed. Note
8557that in C++, the compiler warns if a local variable shadows an
8558explicit typedef, but not if it shadows a struct/class/enum.
8559If this warning is enabled, it includes also all instances of
8560local shadowing. This means that @option{-Wno-shadow=local}
8561and @option{-Wno-shadow=compatible-local} are ignored when
8562@option{-Wshadow} is used.
8563Same as @option{-Wshadow=global}.
8564
d77de738
ML
8565@opindex Wno-shadow-ivar
8566@opindex Wshadow-ivar
ddf6fe37 8567@item -Wno-shadow-ivar @r{(Objective-C only)}
d77de738
ML
8568Do not warn whenever a local variable shadows an instance variable in an
8569Objective-C method.
8570
d77de738 8571@opindex Wshadow=global
ddf6fe37 8572@item -Wshadow=global
d77de738
ML
8573Warn for any shadowing.
8574Same as @option{-Wshadow}.
8575
d77de738 8576@opindex Wshadow=local
ddf6fe37 8577@item -Wshadow=local
d77de738
ML
8578Warn when a local variable shadows another local variable or parameter.
8579
d77de738 8580@opindex Wshadow=compatible-local
ddf6fe37 8581@item -Wshadow=compatible-local
d77de738
ML
8582Warn when a local variable shadows another local variable or parameter
8583whose type is compatible with that of the shadowing variable. In C++,
8584type compatibility here means the type of the shadowing variable can be
8585converted to that of the shadowed variable. The creation of this flag
8586(in addition to @option{-Wshadow=local}) is based on the idea that when
8587a local variable shadows another one of incompatible type, it is most
8588likely intentional, not a bug or typo, as shown in the following example:
8589
8590@smallexample
8591@group
8592for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8593@{
8594 for (int i = 0; i < N; ++i)
8595 @{
8596 ...
8597 @}
8598 ...
8599@}
8600@end group
8601@end smallexample
8602
8603Since the two variable @code{i} in the example above have incompatible types,
8604enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8605Because their types are incompatible, if a programmer accidentally uses one
8606in place of the other, type checking is expected to catch that and emit an
8607error or warning. Use of this flag instead of @option{-Wshadow=local} can
8608possibly reduce the number of warnings triggered by intentional shadowing.
8609Note that this also means that shadowing @code{const char *i} by
8610@code{char *i} does not emit a warning.
8611
8612This warning is also enabled by @option{-Wshadow=local}.
8613
d77de738
ML
8614@opindex Wlarger-than=
8615@opindex Wlarger-than-@var{byte-size}
ddf6fe37 8616@item -Wlarger-than=@var{byte-size}
d77de738
ML
8617Warn whenever an object is defined whose size exceeds @var{byte-size}.
8618@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8619Warnings controlled by the option can be disabled either by specifying
8620@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8621
8622Also warn for calls to bounded functions such as @code{memchr} or
8623@code{strnlen} that specify a bound greater than the largest possible
8624object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8625can only be disabled by @option{-Wno-larger-than}.
8626
d77de738 8627@opindex Wno-larger-than
ddf6fe37 8628@item -Wno-larger-than
d77de738
ML
8629Disable @option{-Wlarger-than=} warnings. The option is equivalent
8630to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8631
d77de738
ML
8632@opindex Wframe-larger-than=
8633@opindex Wno-frame-larger-than
ddf6fe37 8634@item -Wframe-larger-than=@var{byte-size}
d77de738
ML
8635Warn if the size of a function frame exceeds @var{byte-size}.
8636The computation done to determine the stack frame size is approximate
8637and not conservative.
8638The actual requirements may be somewhat greater than @var{byte-size}
8639even if you do not get a warning. In addition, any space allocated
8640via @code{alloca}, variable-length arrays, or related constructs
8641is not included by the compiler when determining
8642whether or not to issue a warning.
8643@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8644Warnings controlled by the option can be disabled either by specifying
8645@var{byte-size} of @samp{SIZE_MAX} or more or by
8646@option{-Wno-frame-larger-than}.
8647
d77de738 8648@opindex Wno-frame-larger-than
ddf6fe37 8649@item -Wno-frame-larger-than
d77de738
ML
8650Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8651to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8652
d77de738
ML
8653@opindex Wfree-nonheap-object
8654@opindex Wno-free-nonheap-object
ddf6fe37 8655@item -Wfree-nonheap-object
d77de738
ML
8656Warn when attempting to deallocate an object that was either not allocated
8657on the heap, or by using a pointer that was not returned from a prior call
8658to the corresponding allocation function. For example, because the call
8659to @code{stpcpy} returns a pointer to the terminating nul character and
8660not to the beginning of the object, the call to @code{free} below is
8661diagnosed.
8662
8663@smallexample
8664void f (char *p)
8665@{
8666 p = stpcpy (p, "abc");
8667 // ...
8668 free (p); // warning
8669@}
8670@end smallexample
8671
8672@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8673
d77de738
ML
8674@opindex Wstack-usage
8675@opindex Wno-stack-usage
ddf6fe37 8676@item -Wstack-usage=@var{byte-size}
d77de738
ML
8677Warn if the stack usage of a function might exceed @var{byte-size}.
8678The computation done to determine the stack usage is conservative.
8679Any space allocated via @code{alloca}, variable-length arrays, or related
8680constructs is included by the compiler when determining whether or not to
8681issue a warning.
8682
8683The message is in keeping with the output of @option{-fstack-usage}.
8684
8685@itemize
8686@item
8687If the stack usage is fully static but exceeds the specified amount, it's:
8688
8689@smallexample
8690 warning: stack usage is 1120 bytes
8691@end smallexample
8692@item
8693If the stack usage is (partly) dynamic but bounded, it's:
8694
8695@smallexample
8696 warning: stack usage might be 1648 bytes
8697@end smallexample
8698@item
8699If the stack usage is (partly) dynamic and not bounded, it's:
8700
8701@smallexample
8702 warning: stack usage might be unbounded
8703@end smallexample
8704@end itemize
8705
8706@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8707Warnings controlled by the option can be disabled either by specifying
8708@var{byte-size} of @samp{SIZE_MAX} or more or by
8709@option{-Wno-stack-usage}.
8710
d77de738 8711@opindex Wno-stack-usage
ddf6fe37 8712@item -Wno-stack-usage
d77de738
ML
8713Disable @option{-Wstack-usage=} warnings. The option is equivalent
8714to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8715
d77de738
ML
8716@opindex Wunsafe-loop-optimizations
8717@opindex Wno-unsafe-loop-optimizations
ddf6fe37 8718@item -Wunsafe-loop-optimizations
d77de738
ML
8719Warn if the loop cannot be optimized because the compiler cannot
8720assume anything on the bounds of the loop indices. With
8721@option{-funsafe-loop-optimizations} warn if the compiler makes
8722such assumptions.
8723
d77de738
ML
8724@opindex Wno-pedantic-ms-format
8725@opindex Wpedantic-ms-format
ddf6fe37 8726@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
d77de738
ML
8727When used in combination with @option{-Wformat}
8728and @option{-pedantic} without GNU extensions, this option
8729disables the warnings about non-ISO @code{printf} / @code{scanf} format
8730width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8731which depend on the MS runtime.
8732
d77de738
ML
8733@opindex Wpointer-arith
8734@opindex Wno-pointer-arith
ddf6fe37 8735@item -Wpointer-arith
d77de738
ML
8736Warn about anything that depends on the ``size of'' a function type or
8737of @code{void}. GNU C assigns these types a size of 1, for
8738convenience in calculations with @code{void *} pointers and pointers
8739to functions. In C++, warn also when an arithmetic operation involves
8740@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8741
d77de738
ML
8742@opindex Wpointer-compare
8743@opindex Wno-pointer-compare
ddf6fe37 8744@item -Wno-pointer-compare
d77de738
ML
8745Do not warn if a pointer is compared with a zero character constant.
8746This usually
8747means that the pointer was meant to be dereferenced. For example:
8748
8749@smallexample
8750const char *p = foo ();
8751if (p == '\0')
8752 return 42;
8753@end smallexample
8754
8755Note that the code above is invalid in C++11.
8756
8757This warning is enabled by default.
8758
d77de738
ML
8759@opindex Wtsan
8760@opindex Wno-tsan
ddf6fe37 8761@item -Wtsan
d77de738
ML
8762Warn about unsupported features in ThreadSanitizer.
8763
8764ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8765can report false positives.
8766
8767This warning is enabled by default.
8768
d77de738
ML
8769@opindex Wtype-limits
8770@opindex Wno-type-limits
ddf6fe37 8771@item -Wtype-limits
d77de738
ML
8772Warn if a comparison is always true or always false due to the limited
8773range of the data type, but do not warn for constant expressions. For
8774example, warn if an unsigned variable is compared against zero with
8775@code{<} or @code{>=}. This warning is also enabled by
8776@option{-Wextra}.
8777
d77de738
ML
8778@opindex Wabsolute-value
8779@opindex Wno-absolute-value
ddf6fe37 8780@item -Wabsolute-value @r{(C and Objective-C only)}
d77de738
ML
8781Warn for calls to standard functions that compute the absolute value
8782of an argument when a more appropriate standard function is available.
8783For example, calling @code{abs(3.14)} triggers the warning because the
8784appropriate function to call to compute the absolute value of a double
8785argument is @code{fabs}. The option also triggers warnings when the
8786argument in a call to such a function has an unsigned type. This
8787warning can be suppressed with an explicit type cast and it is also
8788enabled by @option{-Wextra}.
8789
8790@include cppwarnopts.texi
8791
d77de738
ML
8792@opindex Wbad-function-cast
8793@opindex Wno-bad-function-cast
ddf6fe37 8794@item -Wbad-function-cast @r{(C and Objective-C only)}
d77de738
ML
8795Warn when a function call is cast to a non-matching type.
8796For example, warn if a call to a function returning an integer type
8797is cast to a pointer type.
8798
d77de738
ML
8799@opindex Wc90-c99-compat
8800@opindex Wno-c90-c99-compat
ddf6fe37 8801@item -Wc90-c99-compat @r{(C and Objective-C only)}
d77de738
ML
8802Warn about features not present in ISO C90, but present in ISO C99.
8803For instance, warn about use of variable length arrays, @code{long long}
8804type, @code{bool} type, compound literals, designated initializers, and so
8805on. This option is independent of the standards mode. Warnings are disabled
8806in the expression that follows @code{__extension__}.
8807
d77de738
ML
8808@opindex Wc99-c11-compat
8809@opindex Wno-c99-c11-compat
ddf6fe37 8810@item -Wc99-c11-compat @r{(C and Objective-C only)}
d77de738
ML
8811Warn about features not present in ISO C99, but present in ISO C11.
8812For instance, warn about use of anonymous structures and unions,
8813@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8814@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8815and so on. This option is independent of the standards mode. Warnings are
8816disabled in the expression that follows @code{__extension__}.
8817
d77de738
ML
8818@opindex Wc11-c2x-compat
8819@opindex Wno-c11-c2x-compat
ddf6fe37 8820@item -Wc11-c2x-compat @r{(C and Objective-C only)}
d77de738
ML
8821Warn about features not present in ISO C11, but present in ISO C2X.
8822For instance, warn about omitting the string in @code{_Static_assert},
8823use of @samp{[[]]} syntax for attributes, use of decimal
8824floating-point types, and so on. This option is independent of the
8825standards mode. Warnings are disabled in the expression that follows
8826@code{__extension__}.
8827
d77de738
ML
8828@opindex Wc++-compat
8829@opindex Wno-c++-compat
ddf6fe37 8830@item -Wc++-compat @r{(C and Objective-C only)}
d77de738
ML
8831Warn about ISO C constructs that are outside of the common subset of
8832ISO C and ISO C++, e.g.@: request for implicit conversion from
8833@code{void *} to a pointer to non-@code{void} type.
8834
d77de738
ML
8835@opindex Wc++11-compat
8836@opindex Wno-c++11-compat
ddf6fe37 8837@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8838Warn about C++ constructs whose meaning differs between ISO C++ 1998
8839and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8840in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8841enabled by @option{-Wall}.
8842
d77de738
ML
8843@opindex Wc++14-compat
8844@opindex Wno-c++14-compat
ddf6fe37 8845@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8846Warn about C++ constructs whose meaning differs between ISO C++ 2011
8847and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8848
d77de738
ML
8849@opindex Wc++17-compat
8850@opindex Wno-c++17-compat
ddf6fe37 8851@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8852Warn about C++ constructs whose meaning differs between ISO C++ 2014
8853and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8854
d77de738
ML
8855@opindex Wc++20-compat
8856@opindex Wno-c++20-compat
ddf6fe37 8857@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8858Warn about C++ constructs whose meaning differs between ISO C++ 2017
8859and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8860
d77de738
ML
8861@opindex Wc++11-extensions
8862@opindex Wno-c++11-extensions
ddf6fe37 8863@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8864Do not warn about C++11 constructs in code being compiled using
8865an older C++ standard. Even without this option, some C++11 constructs
8866will only be diagnosed if @option{-Wpedantic} is used.
8867
d77de738
ML
8868@opindex Wc++14-extensions
8869@opindex Wno-c++14-extensions
ddf6fe37 8870@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8871Do not warn about C++14 constructs in code being compiled using
8872an older C++ standard. Even without this option, some C++14 constructs
8873will only be diagnosed if @option{-Wpedantic} is used.
8874
d77de738
ML
8875@opindex Wc++17-extensions
8876@opindex Wno-c++17-extensions
ddf6fe37 8877@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8878Do not warn about C++17 constructs in code being compiled using
8879an older C++ standard. Even without this option, some C++17 constructs
8880will only be diagnosed if @option{-Wpedantic} is used.
8881
d77de738
ML
8882@opindex Wc++20-extensions
8883@opindex Wno-c++20-extensions
ddf6fe37 8884@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8885Do not warn about C++20 constructs in code being compiled using
8886an older C++ standard. Even without this option, some C++20 constructs
8887will only be diagnosed if @option{-Wpedantic} is used.
8888
d77de738
ML
8889@opindex Wc++23-extensions
8890@opindex Wno-c++23-extensions
ddf6fe37 8891@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8892Do not warn about C++23 constructs in code being compiled using
8893an older C++ standard. Even without this option, some C++23 constructs
8894will only be diagnosed if @option{-Wpedantic} is used.
8895
d77de738
ML
8896@opindex Wcast-qual
8897@opindex Wno-cast-qual
ddf6fe37 8898@item -Wcast-qual
d77de738
ML
8899Warn whenever a pointer is cast so as to remove a type qualifier from
8900the target type. For example, warn if a @code{const char *} is cast
8901to an ordinary @code{char *}.
8902
8903Also warn when making a cast that introduces a type qualifier in an
8904unsafe way. For example, casting @code{char **} to @code{const char **}
8905is unsafe, as in this example:
8906
8907@smallexample
8908 /* p is char ** value. */
8909 const char **q = (const char **) p;
8910 /* Assignment of readonly string to const char * is OK. */
8911 *q = "string";
8912 /* Now char** pointer points to read-only memory. */
8913 **p = 'b';
8914@end smallexample
8915
d77de738
ML
8916@opindex Wcast-align
8917@opindex Wno-cast-align
ddf6fe37 8918@item -Wcast-align
d77de738
ML
8919Warn whenever a pointer is cast such that the required alignment of the
8920target is increased. For example, warn if a @code{char *} is cast to
8921an @code{int *} on machines where integers can only be accessed at
8922two- or four-byte boundaries.
8923
d77de738 8924@opindex Wcast-align=strict
ddf6fe37 8925@item -Wcast-align=strict
d77de738
ML
8926Warn whenever a pointer is cast such that the required alignment of the
8927target is increased. For example, warn if a @code{char *} is cast to
8928an @code{int *} regardless of the target machine.
8929
d77de738
ML
8930@opindex Wcast-function-type
8931@opindex Wno-cast-function-type
ddf6fe37 8932@item -Wcast-function-type
d77de738
ML
8933Warn when a function pointer is cast to an incompatible function pointer.
8934In a cast involving function types with a variable argument list only
8935the types of initial arguments that are provided are considered.
8936Any parameter of pointer-type matches any other pointer-type. Any benign
8937differences in integral types are ignored, like @code{int} vs.@: @code{long}
8938on ILP32 targets. Likewise type qualifiers are ignored. The function
8939type @code{void (*) (void)} is special and matches everything, which can
8940be used to suppress this warning.
8941In a cast involving pointer to member types this warning warns whenever
8942the type cast is changing the pointer to member type.
8943This warning is enabled by @option{-Wextra}.
8944
d77de738
ML
8945@opindex Wwrite-strings
8946@opindex Wno-write-strings
ddf6fe37 8947@item -Wwrite-strings
d77de738
ML
8948When compiling C, give string constants the type @code{const
8949char[@var{length}]} so that copying the address of one into a
8950non-@code{const} @code{char *} pointer produces a warning. These
8951warnings help you find at compile time code that can try to write
8952into a string constant, but only if you have been very careful about
8953using @code{const} in declarations and prototypes. Otherwise, it is
8954just a nuisance. This is why we did not make @option{-Wall} request
8955these warnings.
8956
8957When compiling C++, warn about the deprecated conversion from string
8958literals to @code{char *}. This warning is enabled by default for C++
8959programs.
8960
d77de738
ML
8961@opindex Wclobbered
8962@opindex Wno-clobbered
f33d7a88 8963@item -Wclobbered
d77de738
ML
8964Warn for variables that might be changed by @code{longjmp} or
8965@code{vfork}. This warning is also enabled by @option{-Wextra}.
8966
320dc51c
TS
8967@opindex Wcomplain-wrong-lang
8968@opindex Wno-complain-wrong-lang
f33d7a88 8969@item -Wno-complain-wrong-lang
320dc51c
TS
8970By default, language front ends complain when a command-line option is
8971valid, but not applicable to that front end.
8972This may be disabled with @option{-Wno-complain-wrong-lang},
8973which is mostly useful when invoking a single compiler driver for
8974multiple source files written in different languages, for example:
8975
8976@smallexample
8977$ g++ -fno-rtti a.cc b.f90
8978@end smallexample
8979
8980The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
8981and the Fortran front end to compile @file{b.f90}.
8982The latter front end diagnoses
8983@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
8984which may be disabled with @option{-Wno-complain-wrong-lang}.
8985
d77de738
ML
8986@opindex Wconversion
8987@opindex Wno-conversion
f33d7a88 8988@item -Wconversion
d77de738
ML
8989Warn for implicit conversions that may alter a value. This includes
8990conversions between real and integer, like @code{abs (x)} when
8991@code{x} is @code{double}; conversions between signed and unsigned,
8992like @code{unsigned ui = -1}; and conversions to smaller types, like
8993@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
8994((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
8995changed by the conversion like in @code{abs (2.0)}. Warnings about
8996conversions between signed and unsigned integers can be disabled by
8997using @option{-Wno-sign-conversion}.
8998
8999For C++, also warn for confusing overload resolution for user-defined
9000conversions; and conversions that never use a type conversion
9001operator: conversions to @code{void}, the same type, a base class or a
9002reference to them. Warnings about conversions between signed and
9003unsigned integers are disabled by default in C++ unless
9004@option{-Wsign-conversion} is explicitly enabled.
9005
9006Warnings about conversion from arithmetic on a small type back to that
9007type are only given with @option{-Warith-conversion}.
9008
d77de738
ML
9009@opindex Wdangling-else
9010@opindex Wno-dangling-else
ddf6fe37 9011@item -Wdangling-else
d77de738
ML
9012Warn about constructions where there may be confusion to which
9013@code{if} statement an @code{else} branch belongs. Here is an example of
9014such a case:
9015
9016@smallexample
9017@group
9018@{
9019 if (a)
9020 if (b)
9021 foo ();
9022 else
9023 bar ();
9024@}
9025@end group
9026@end smallexample
9027
9028In C/C++, every @code{else} branch belongs to the innermost possible
9029@code{if} statement, which in this example is @code{if (b)}. This is
9030often not what the programmer expected, as illustrated in the above
9031example by indentation the programmer chose. When there is the
9032potential for this confusion, GCC issues a warning when this flag
9033is specified. To eliminate the warning, add explicit braces around
9034the innermost @code{if} statement so there is no way the @code{else}
9035can belong to the enclosing @code{if}. The resulting code
9036looks like this:
9037
9038@smallexample
9039@group
9040@{
9041 if (a)
9042 @{
9043 if (b)
9044 foo ();
9045 else
9046 bar ();
9047 @}
9048@}
9049@end group
9050@end smallexample
9051
9052This warning is enabled by @option{-Wparentheses}.
9053
d77de738
ML
9054@opindex Wdangling-pointer
9055@opindex Wno-dangling-pointer
ddf6fe37
AA
9056@item -Wdangling-pointer
9057@itemx -Wdangling-pointer=@var{n}
d77de738
ML
9058Warn about uses of pointers (or C++ references) to objects with automatic
9059storage duration after their lifetime has ended. This includes local
9060variables declared in nested blocks, compound literals and other unnamed
9061temporary objects. In addition, warn about storing the address of such
9062objects in escaped pointers. The warning is enabled at all optimization
9063levels but may yield different results with optimization than without.
9064
9065@table @gcctabopt
9066@item -Wdangling-pointer=1
9067At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9068For example
9069@smallexample
9070int f (int c1, int c2, x)
9071@{
9072 char *p = strchr ((char[])@{ c1, c2 @}, c3);
4ace81b6
SL
9073 // warning: dangling pointer to a compound literal
9074 return p ? *p : 'x';
d77de738
ML
9075@}
9076@end smallexample
9077In the following function the store of the address of the local variable
9078@code{x} in the escaped pointer @code{*p} also triggers the warning.
9079@smallexample
9080void g (int **p)
9081@{
9082 int x = 7;
4ace81b6
SL
9083 // warning: storing the address of a local variable in *p
9084 *p = &x;
d77de738
ML
9085@}
9086@end smallexample
9087
9088@item -Wdangling-pointer=2
9089At level 2, in addition to unconditional uses the warning also diagnoses
9090conditional uses of dangling pointers.
9091
9092For example, because the array @var{a} in the following function is out of
9093scope when the pointer @var{s} that was set to point is used, the warning
9094triggers at this level.
9095
9096@smallexample
9097void f (char *s)
9098@{
9099 if (!s)
9100 @{
9101 char a[12] = "tmpname";
9102 s = a;
9103 @}
4ace81b6
SL
9104 // warning: dangling pointer to a may be used
9105 strcat (s, ".tmp");
d77de738
ML
9106 ...
9107@}
9108@end smallexample
9109@end table
9110
9111@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9112
d77de738
ML
9113@opindex Wdate-time
9114@opindex Wno-date-time
ddf6fe37 9115@item -Wdate-time
d77de738
ML
9116Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9117are encountered as they might prevent bit-wise-identical reproducible
9118compilations.
9119
d77de738
ML
9120@opindex Wempty-body
9121@opindex Wno-empty-body
ddf6fe37 9122@item -Wempty-body
d77de738
ML
9123Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9124while} statement. This warning is also enabled by @option{-Wextra}.
9125
d77de738
ML
9126@opindex Wendif-labels
9127@opindex Wno-endif-labels
ddf6fe37 9128@item -Wno-endif-labels
d77de738
ML
9129Do not warn about stray tokens after @code{#else} and @code{#endif}.
9130
d77de738
ML
9131@opindex Wenum-compare
9132@opindex Wno-enum-compare
ddf6fe37 9133@item -Wenum-compare
d77de738
ML
9134Warn about a comparison between values of different enumerated types.
9135In C++ enumerated type mismatches in conditional expressions are also
9136diagnosed and the warning is enabled by default. In C this warning is
9137enabled by @option{-Wall}.
9138
d77de738
ML
9139@opindex Wenum-conversion
9140@opindex Wno-enum-conversion
ddf6fe37 9141@item -Wenum-conversion
d77de738
ML
9142Warn when a value of enumerated type is implicitly converted to a
9143different enumerated type. This warning is enabled by @option{-Wextra}
9144in C@.
9145
d77de738
ML
9146@opindex Wenum-int-mismatch
9147@opindex Wno-enum-int-mismatch
ddf6fe37 9148@item -Wenum-int-mismatch @r{(C and Objective-C only)}
d77de738
ML
9149Warn about mismatches between an enumerated type and an integer type in
9150declarations. For example:
9151
9152@smallexample
9153enum E @{ l = -1, z = 0, g = 1 @};
9154int foo(void);
9155enum E foo(void);
9156@end smallexample
9157
9158In C, an enumerated type is compatible with @code{char}, a signed
9159integer type, or an unsigned integer type. However, since the choice
9160of the underlying type of an enumerated type is implementation-defined,
9161such mismatches may cause portability issues. In C++, such mismatches
9162are an error. In C, this warning is enabled by @option{-Wall} and
9163@option{-Wc++-compat}.
9164
d77de738
ML
9165@opindex Wjump-misses-init
9166@opindex Wno-jump-misses-init
ddf6fe37 9167@item -Wjump-misses-init @r{(C, Objective-C only)}
d77de738
ML
9168Warn if a @code{goto} statement or a @code{switch} statement jumps
9169forward across the initialization of a variable, or jumps backward to a
9170label after the variable has been initialized. This only warns about
9171variables that are initialized when they are declared. This warning is
9172only supported for C and Objective-C; in C++ this sort of branch is an
9173error in any case.
9174
9175@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9176can be disabled with the @option{-Wno-jump-misses-init} option.
9177
d77de738
ML
9178@opindex Wsign-compare
9179@opindex Wno-sign-compare
9180@cindex warning for comparison of signed and unsigned values
9181@cindex comparison of signed and unsigned values, warning
9182@cindex signed and unsigned values, comparison warning
f33d7a88 9183@item -Wsign-compare
d77de738
ML
9184Warn when a comparison between signed and unsigned values could produce
9185an incorrect result when the signed value is converted to unsigned.
9186In C++, this warning is also enabled by @option{-Wall}. In C, it is
9187also enabled by @option{-Wextra}.
9188
d77de738
ML
9189@opindex Wsign-conversion
9190@opindex Wno-sign-conversion
ddf6fe37 9191@item -Wsign-conversion
d77de738
ML
9192Warn for implicit conversions that may change the sign of an integer
9193value, like assigning a signed integer expression to an unsigned
9194integer variable. An explicit cast silences the warning. In C, this
9195option is enabled also by @option{-Wconversion}.
9196
d77de738
ML
9197@opindex Wfloat-conversion
9198@opindex Wno-float-conversion
ddf6fe37 9199@item -Wfloat-conversion
d77de738
ML
9200Warn for implicit conversions that reduce the precision of a real value.
9201This includes conversions from real to integer, and from higher precision
9202real to lower precision real values. This option is also enabled by
9203@option{-Wconversion}.
9204
d77de738
ML
9205@opindex Wno-scalar-storage-order
9206@opindex Wscalar-storage-order
ddf6fe37 9207@item -Wno-scalar-storage-order
d77de738
ML
9208Do not warn on suspicious constructs involving reverse scalar storage order.
9209
d77de738
ML
9210@opindex Wsizeof-array-div
9211@opindex Wno-sizeof-array-div
ddf6fe37 9212@item -Wsizeof-array-div
d77de738
ML
9213Warn about divisions of two sizeof operators when the first one is applied
9214to an array and the divisor does not equal the size of the array element.
9215In such a case, the computation will not yield the number of elements in the
9216array, which is likely what the user intended. This warning warns e.g. about
9217@smallexample
9218int fn ()
9219@{
9220 int arr[10];
9221 return sizeof (arr) / sizeof (short);
9222@}
9223@end smallexample
9224
9225This warning is enabled by @option{-Wall}.
9226
d77de738
ML
9227@opindex Wsizeof-pointer-div
9228@opindex Wno-sizeof-pointer-div
ddf6fe37 9229@item -Wsizeof-pointer-div
d77de738
ML
9230Warn for suspicious divisions of two sizeof expressions that divide
9231the pointer size by the element size, which is the usual way to compute
9232the array size but won't work out correctly with pointers. This warning
9233warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9234not an array, but a pointer. This warning is enabled by @option{-Wall}.
9235
d77de738
ML
9236@opindex Wsizeof-pointer-memaccess
9237@opindex Wno-sizeof-pointer-memaccess
ddf6fe37 9238@item -Wsizeof-pointer-memaccess
d77de738
ML
9239Warn for suspicious length parameters to certain string and memory built-in
9240functions if the argument uses @code{sizeof}. This warning triggers for
9241example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9242an array, but a pointer, and suggests a possible fix, or about
9243@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9244also warns about calls to bounded string copy functions like @code{strncat}
9245or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9246the source array. For example, in the following function the call to
9247@code{strncat} specifies the size of the source string as the bound. That
9248is almost certainly a mistake and so the call is diagnosed.
9249@smallexample
9250void make_file (const char *name)
9251@{
9252 char path[PATH_MAX];
9253 strncpy (path, name, sizeof path - 1);
9254 strncat (path, ".text", sizeof ".text");
9255 @dots{}
9256@}
9257@end smallexample
9258
9259The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9260
d77de738
ML
9261@opindex Wsizeof-array-argument
9262@opindex Wno-sizeof-array-argument
ddf6fe37 9263@item -Wno-sizeof-array-argument
d77de738
ML
9264Do not warn when the @code{sizeof} operator is applied to a parameter that is
9265declared as an array in a function definition. This warning is enabled by
9266default for C and C++ programs.
9267
d77de738
ML
9268@opindex Wmemset-elt-size
9269@opindex Wno-memset-elt-size
ddf6fe37 9270@item -Wmemset-elt-size
d77de738
ML
9271Warn for suspicious calls to the @code{memset} built-in function, if the
9272first argument references an array, and the third argument is a number
9273equal to the number of elements, but not equal to the size of the array
9274in memory. This indicates that the user has omitted a multiplication by
9275the element size. This warning is enabled by @option{-Wall}.
9276
d77de738
ML
9277@opindex Wmemset-transposed-args
9278@opindex Wno-memset-transposed-args
ddf6fe37 9279@item -Wmemset-transposed-args
d77de738
ML
9280Warn for suspicious calls to the @code{memset} built-in function where
9281the second argument is not zero and the third argument is zero. For
9282example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9283@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9284is only emitted if the third argument is a literal zero. Otherwise, if
9285it is an expression that is folded to zero, or a cast of zero to some
9286type, it is far less likely that the arguments have been mistakenly
9287transposed and no warning is emitted. This warning is enabled
9288by @option{-Wall}.
9289
d77de738
ML
9290@opindex Waddress
9291@opindex Wno-address
ddf6fe37 9292@item -Waddress
d77de738
ML
9293Warn about suspicious uses of address expressions. These include comparing
9294the address of a function or a declared object to the null pointer constant
9295such as in
9296@smallexample
9297void f (void);
9298void g (void)
9299@{
9300 if (!f) // warning: expression evaluates to false
9301 abort ();
9302@}
9303@end smallexample
9304comparisons of a pointer to a string literal, such as in
9305@smallexample
9306void f (const char *x)
9307@{
9308 if (x == "abc") // warning: expression evaluates to false
9309 puts ("equal");
9310@}
9311@end smallexample
9312and tests of the results of pointer addition or subtraction for equality
9313to null, such as in
9314@smallexample
9315void f (const int *p, int i)
9316@{
9317 return p + i == NULL;
9318@}
9319@end smallexample
9320Such uses typically indicate a programmer error: the address of most
9321functions and objects necessarily evaluates to true (the exception are
9322weak symbols), so their use in a conditional might indicate missing
9323parentheses in a function call or a missing dereference in an array
9324expression. The subset of the warning for object pointers can be
9325suppressed by casting the pointer operand to an integer type such
9326as @code{intptr_t} or @code{uintptr_t}.
9327Comparisons against string literals result in unspecified behavior
9328and are not portable, and suggest the intent was to call @code{strcmp}.
9329The warning is suppressed if the suspicious expression is the result
9330of macro expansion.
9331@option{-Waddress} warning is enabled by @option{-Wall}.
9332
d77de738
ML
9333@opindex Waddress-of-packed-member
9334@opindex Wno-address-of-packed-member
ddf6fe37 9335@item -Wno-address-of-packed-member
d77de738
ML
9336Do not warn when the address of packed member of struct or union is taken,
9337which usually results in an unaligned pointer value. This is
9338enabled by default.
9339
d77de738
ML
9340@opindex Wlogical-op
9341@opindex Wno-logical-op
ddf6fe37 9342@item -Wlogical-op
d77de738
ML
9343Warn about suspicious uses of logical operators in expressions.
9344This includes using logical operators in contexts where a
9345bit-wise operator is likely to be expected. Also warns when
9346the operands of a logical operator are the same:
9347@smallexample
9348extern int a;
9349if (a < 0 && a < 0) @{ @dots{} @}
9350@end smallexample
9351
d77de738
ML
9352@opindex Wlogical-not-parentheses
9353@opindex Wno-logical-not-parentheses
ddf6fe37 9354@item -Wlogical-not-parentheses
d77de738
ML
9355Warn about logical not used on the left hand side operand of a comparison.
9356This option does not warn if the right operand is considered to be a boolean
9357expression. Its purpose is to detect suspicious code like the following:
9358@smallexample
9359int a;
9360@dots{}
9361if (!a > 1) @{ @dots{} @}
9362@end smallexample
9363
9364It is possible to suppress the warning by wrapping the LHS into
9365parentheses:
9366@smallexample
9367if ((!a) > 1) @{ @dots{} @}
9368@end smallexample
9369
9370This warning is enabled by @option{-Wall}.
9371
d77de738
ML
9372@opindex Waggregate-return
9373@opindex Wno-aggregate-return
ddf6fe37 9374@item -Waggregate-return
d77de738
ML
9375Warn if any functions that return structures or unions are defined or
9376called. (In languages where you can return an array, this also elicits
9377a warning.)
9378
d77de738
ML
9379@opindex Wno-aggressive-loop-optimizations
9380@opindex Waggressive-loop-optimizations
ddf6fe37 9381@item -Wno-aggressive-loop-optimizations
d77de738
ML
9382Warn if in a loop with constant number of iterations the compiler detects
9383undefined behavior in some statement during one or more of the iterations.
9384
d77de738
ML
9385@opindex Wno-attributes
9386@opindex Wattributes
ddf6fe37 9387@item -Wno-attributes
d77de738
ML
9388Do not warn if an unexpected @code{__attribute__} is used, such as
9389unrecognized attributes, function attributes applied to variables,
9390etc. This does not stop errors for incorrect use of supported
9391attributes.
9392
9393Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9394warnings about unknown scoped attributes (in C++11 and C2X). For example,
9395@option{-Wno-attributes=vendor::attr} disables warning about the following
9396declaration:
9397
9398@smallexample
9399[[vendor::attr]] void f();
9400@end smallexample
9401
9402It is also possible to disable warning about all attributes in a namespace
9403using @option{-Wno-attributes=vendor::} which prevents warning about both
9404of these declarations:
9405
9406@smallexample
9407[[vendor::safe]] void f();
9408[[vendor::unsafe]] void f2();
9409@end smallexample
9410
9411Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9412
d77de738
ML
9413@opindex Wno-builtin-declaration-mismatch
9414@opindex Wbuiltin-declaration-mismatch
ddf6fe37 9415@item -Wno-builtin-declaration-mismatch
d77de738
ML
9416Warn if a built-in function is declared with an incompatible signature
9417or as a non-function, or when a built-in function declared with a type
9418that does not include a prototype is called with arguments whose promoted
9419types do not match those expected by the function. When @option{-Wextra}
9420is specified, also warn when a built-in function that takes arguments is
9421declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9422warning is enabled by default. To avoid the warning include the appropriate
9423header to bring the prototypes of built-in functions into scope.
9424
9425For example, the call to @code{memset} below is diagnosed by the warning
9426because the function expects a value of type @code{size_t} as its argument
9427but the type of @code{32} is @code{int}. With @option{-Wextra},
9428the declaration of the function is diagnosed as well.
9429@smallexample
9430extern void* memset ();
9431void f (void *d)
9432@{
9433 memset (d, '\0', 32);
9434@}
9435@end smallexample
9436
d77de738
ML
9437@opindex Wno-builtin-macro-redefined
9438@opindex Wbuiltin-macro-redefined
ddf6fe37 9439@item -Wno-builtin-macro-redefined
d77de738
ML
9440Do not warn if certain built-in macros are redefined. This suppresses
9441warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9442@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9443
d77de738
ML
9444@opindex Wstrict-prototypes
9445@opindex Wno-strict-prototypes
ddf6fe37 9446@item -Wstrict-prototypes @r{(C and Objective-C only)}
d77de738
ML
9447Warn if a function is declared or defined without specifying the
9448argument types. (An old-style function definition is permitted without
9449a warning if preceded by a declaration that specifies the argument
9450types.)
9451
d77de738
ML
9452@opindex Wold-style-declaration
9453@opindex Wno-old-style-declaration
ddf6fe37 9454@item -Wold-style-declaration @r{(C and Objective-C only)}
d77de738
ML
9455Warn for obsolescent usages, according to the C Standard, in a
9456declaration. For example, warn if storage-class specifiers like
9457@code{static} are not the first things in a declaration. This warning
9458is also enabled by @option{-Wextra}.
9459
d77de738
ML
9460@opindex Wold-style-definition
9461@opindex Wno-old-style-definition
ddf6fe37 9462@item -Wold-style-definition @r{(C and Objective-C only)}
d77de738
ML
9463Warn if an old-style function definition is used. A warning is given
9464even if there is a previous prototype. A definition using @samp{()}
9465is not considered an old-style definition in C2X mode, because it is
9466equivalent to @samp{(void)} in that case, but is considered an
9467old-style definition for older standards.
9468
d77de738
ML
9469@opindex Wmissing-parameter-type
9470@opindex Wno-missing-parameter-type
ddf6fe37 9471@item -Wmissing-parameter-type @r{(C and Objective-C only)}
d77de738
ML
9472A function parameter is declared without a type specifier in K&R-style
9473functions:
9474
9475@smallexample
9476void foo(bar) @{ @}
9477@end smallexample
9478
9479This warning is also enabled by @option{-Wextra}.
9480
d77de738
ML
9481@opindex Wmissing-prototypes
9482@opindex Wno-missing-prototypes
ddf6fe37 9483@item -Wmissing-prototypes @r{(C and Objective-C only)}
d77de738
ML
9484Warn if a global function is defined without a previous prototype
9485declaration. This warning is issued even if the definition itself
9486provides a prototype. Use this option to detect global functions
9487that do not have a matching prototype declaration in a header file.
9488This option is not valid for C++ because all function declarations
9489provide prototypes and a non-matching declaration declares an
9490overload rather than conflict with an earlier declaration.
9491Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9492
d77de738
ML
9493@opindex Wmissing-declarations
9494@opindex Wno-missing-declarations
ddf6fe37 9495@item -Wmissing-declarations
d77de738
ML
9496Warn if a global function is defined without a previous declaration.
9497Do so even if the definition itself provides a prototype.
9498Use this option to detect global functions that are not declared in
9499header files. In C, no warnings are issued for functions with previous
9500non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9501missing prototypes. In C++, no warnings are issued for function templates,
9502or for inline functions, or for functions in anonymous namespaces.
9503
d77de738
ML
9504@opindex Wmissing-field-initializers
9505@opindex Wno-missing-field-initializers
9506@opindex W
9507@opindex Wextra
9508@opindex Wno-extra
ddf6fe37 9509@item -Wmissing-field-initializers
d77de738
ML
9510Warn if a structure's initializer has some fields missing. For
9511example, the following code causes such a warning, because
9512@code{x.h} is implicitly zero:
9513
9514@smallexample
9515struct s @{ int f, g, h; @};
9516struct s x = @{ 3, 4 @};
9517@end smallexample
9518
9519This option does not warn about designated initializers, so the following
9520modification does not trigger a warning:
9521
9522@smallexample
9523struct s @{ int f, g, h; @};
9524struct s x = @{ .f = 3, .g = 4 @};
9525@end smallexample
9526
9527In C this option does not warn about the universal zero initializer
9528@samp{@{ 0 @}}:
9529
9530@smallexample
9531struct s @{ int f, g, h; @};
9532struct s x = @{ 0 @};
9533@end smallexample
9534
9535Likewise, in C++ this option does not warn about the empty @{ @}
9536initializer, for example:
9537
9538@smallexample
9539struct s @{ int f, g, h; @};
9540s x = @{ @};
9541@end smallexample
9542
9543This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9544warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9545
d77de738
ML
9546@opindex Wmissing-requires
9547@opindex Wno-missing-requires
ddf6fe37 9548@item -Wno-missing-requires
d77de738
ML
9549
9550By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9551
9552@smallexample
9553bool satisfied = requires @{ C<T> @};
9554@end smallexample
9555
9556Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9557expression, which it is for all T. Presumably the user meant to write
9558
9559@smallexample
9560bool satisfied = requires @{ requires C<T> @};
9561@end smallexample
9562
9563so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9564type @samp{T}.
9565
9566This warning can be disabled with @option{-Wno-missing-requires}.
9567
d77de738
ML
9568@opindex Wmissing-template-keyword
9569@opindex Wno-missing-template-keyword
ddf6fe37 9570@item -Wno-missing-template-keyword
d77de738
ML
9571
9572The member access tokens ., -> and :: must be followed by the @code{template}
9573keyword if the parent object is dependent and the member being named is a
9574template.
9575
9576@smallexample
9577template <class X>
9578void DoStuff (X x)
9579@{
9580 x.template DoSomeOtherStuff<X>(); // Good.
9581 x.DoMoreStuff<X>(); // Warning, x is dependent.
9582@}
9583@end smallexample
9584
9585In rare cases it is possible to get false positives. To silence this, wrap
9586the expression in parentheses. For example, the following is treated as a
9587template, even where m and N are integers:
9588
9589@smallexample
9590void NotATemplate (my_class t)
9591@{
9592 int N = 5;
9593
9594 bool test = t.m < N > (0); // Treated as a template.
9595 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9596@}
9597@end smallexample
9598
9599This warning can be disabled with @option{-Wno-missing-template-keyword}.
9600
d77de738
ML
9601@opindex Wno-multichar
9602@opindex Wmultichar
ddf6fe37 9603@item -Wno-multichar
d77de738
ML
9604Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9605Usually they indicate a typo in the user's code, as they have
9606implementation-defined values, and should not be used in portable code.
9607
d77de738
ML
9608@opindex Wnormalized=
9609@opindex Wnormalized
9610@opindex Wno-normalized
9611@cindex NFC
9612@cindex NFKC
9613@cindex character set, input normalization
f33d7a88 9614@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
d77de738
ML
9615In ISO C and ISO C++, two identifiers are different if they are
9616different sequences of characters. However, sometimes when characters
9617outside the basic ASCII character set are used, you can have two
9618different character sequences that look the same. To avoid confusion,
9619the ISO 10646 standard sets out some @dfn{normalization rules} which
9620when applied ensure that two sequences that look the same are turned into
9621the same sequence. GCC can warn you if you are using identifiers that
9622have not been normalized; this option controls that warning.
9623
9624There are four levels of warning supported by GCC@. The default is
9625@option{-Wnormalized=nfc}, which warns about any identifier that is
9626not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9627recommended form for most uses. It is equivalent to
9628@option{-Wnormalized}.
9629
9630Unfortunately, there are some characters allowed in identifiers by
9631ISO C and ISO C++ that, when turned into NFC, are not allowed in
9632identifiers. That is, there's no way to use these symbols in portable
9633ISO C or C++ and have all your identifiers in NFC@.
9634@option{-Wnormalized=id} suppresses the warning for these characters.
9635It is hoped that future versions of the standards involved will correct
9636this, which is why this option is not the default.
9637
9638You can switch the warning off for all characters by writing
9639@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9640only do this if you are using some other normalization scheme (like
9641``D''), because otherwise you can easily create bugs that are
9642literally impossible to see.
9643
9644Some characters in ISO 10646 have distinct meanings but look identical
9645in some fonts or display methodologies, especially once formatting has
9646been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9647LETTER N'', displays just like a regular @code{n} that has been
9648placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9649normalization scheme to convert all these into a standard form as
9650well, and GCC warns if your code is not in NFKC if you use
9651@option{-Wnormalized=nfkc}. This warning is comparable to warning
9652about every identifier that contains the letter O because it might be
9653confused with the digit 0, and so is not the default, but may be
9654useful as a local coding convention if the programming environment
9655cannot be fixed to display these characters distinctly.
9656
d77de738
ML
9657@opindex Wno-attribute-warning
9658@opindex Wattribute-warning
ddf6fe37 9659@item -Wno-attribute-warning
d77de738
ML
9660Do not warn about usage of functions (@pxref{Function Attributes})
9661declared with @code{warning} attribute. By default, this warning is
9662enabled. @option{-Wno-attribute-warning} can be used to disable the
9663warning or @option{-Wno-error=attribute-warning} can be used to
9664disable the error when compiled with @option{-Werror} flag.
9665
d77de738
ML
9666@opindex Wno-deprecated
9667@opindex Wdeprecated
ddf6fe37 9668@item -Wno-deprecated
d77de738
ML
9669Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9670
d77de738
ML
9671@opindex Wno-deprecated-declarations
9672@opindex Wdeprecated-declarations
ddf6fe37 9673@item -Wno-deprecated-declarations
d77de738
ML
9674Do not warn about uses of functions (@pxref{Function Attributes}),
9675variables (@pxref{Variable Attributes}), and types (@pxref{Type
9676Attributes}) marked as deprecated by using the @code{deprecated}
9677attribute.
9678
d77de738
ML
9679@opindex Wno-overflow
9680@opindex Woverflow
ddf6fe37 9681@item -Wno-overflow
d77de738
ML
9682Do not warn about compile-time overflow in constant expressions.
9683
d77de738
ML
9684@opindex Wno-odr
9685@opindex Wodr
ddf6fe37 9686@item -Wno-odr
d77de738
ML
9687Warn about One Definition Rule violations during link-time optimization.
9688Enabled by default.
9689
d77de738
ML
9690@opindex Wopenacc-parallelism
9691@opindex Wno-openacc-parallelism
9692@cindex OpenACC accelerator programming
f33d7a88 9693@item -Wopenacc-parallelism
d77de738
ML
9694Warn about potentially suboptimal choices related to OpenACC parallelism.
9695
d77de738
ML
9696@opindex Wopenmp-simd
9697@opindex Wno-openmp-simd
ddf6fe37 9698@item -Wopenmp-simd
d77de738
ML
9699Warn if the vectorizer cost model overrides the OpenMP
9700simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9701option can be used to relax the cost model.
9702
d77de738
ML
9703@opindex Woverride-init
9704@opindex Wno-override-init
9705@opindex W
9706@opindex Wextra
9707@opindex Wno-extra
ddf6fe37 9708@item -Woverride-init @r{(C and Objective-C only)}
d77de738
ML
9709Warn if an initialized field without side effects is overridden when
9710using designated initializers (@pxref{Designated Inits, , Designated
9711Initializers}).
9712
9713This warning is included in @option{-Wextra}. To get other
9714@option{-Wextra} warnings without this one, use @option{-Wextra
9715-Wno-override-init}.
9716
d77de738
ML
9717@opindex Woverride-init-side-effects
9718@opindex Wno-override-init-side-effects
ddf6fe37 9719@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
d77de738
ML
9720Do not warn if an initialized field with side effects is overridden when
9721using designated initializers (@pxref{Designated Inits, , Designated
9722Initializers}). This warning is enabled by default.
9723
d77de738
ML
9724@opindex Wpacked
9725@opindex Wno-packed
ddf6fe37 9726@item -Wpacked
d77de738
ML
9727Warn if a structure is given the packed attribute, but the packed
9728attribute has no effect on the layout or size of the structure.
9729Such structures may be mis-aligned for little benefit. For
9730instance, in this code, the variable @code{f.x} in @code{struct bar}
9731is misaligned even though @code{struct bar} does not itself
9732have the packed attribute:
9733
9734@smallexample
9735@group
9736struct foo @{
9737 int x;
9738 char a, b, c, d;
9739@} __attribute__((packed));
9740struct bar @{
9741 char z;
9742 struct foo f;
9743@};
9744@end group
9745@end smallexample
9746
d77de738
ML
9747@opindex Wpacked-bitfield-compat
9748@opindex Wno-packed-bitfield-compat
ddf6fe37 9749@item -Wnopacked-bitfield-compat
d77de738
ML
9750The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9751on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9752the change can lead to differences in the structure layout. GCC
9753informs you when the offset of such a field has changed in GCC 4.4.
9754For example there is no longer a 4-bit padding between field @code{a}
9755and @code{b} in this structure:
9756
9757@smallexample
9758struct foo
9759@{
9760 char a:4;
9761 char b:8;
9762@} __attribute__ ((packed));
9763@end smallexample
9764
9765This warning is enabled by default. Use
9766@option{-Wno-packed-bitfield-compat} to disable this warning.
9767
d77de738
ML
9768@opindex Wpacked-not-aligned
9769@opindex Wno-packed-not-aligned
ddf6fe37 9770@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
9771Warn if a structure field with explicitly specified alignment in a
9772packed struct or union is misaligned. For example, a warning will
9773be issued on @code{struct S}, like, @code{warning: alignment 1 of
9774'struct S' is less than 8}, in this code:
9775
9776@smallexample
9777@group
9778struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9779struct __attribute__ ((packed)) S @{
9780 struct S8 s8;
9781@};
9782@end group
9783@end smallexample
9784
9785This warning is enabled by @option{-Wall}.
9786
d77de738
ML
9787@opindex Wpadded
9788@opindex Wno-padded
ddf6fe37 9789@item -Wpadded
d77de738
ML
9790Warn if padding is included in a structure, either to align an element
9791of the structure or to align the whole structure. Sometimes when this
9792happens it is possible to rearrange the fields of the structure to
9793reduce the padding and so make the structure smaller.
9794
d77de738
ML
9795@opindex Wredundant-decls
9796@opindex Wno-redundant-decls
ddf6fe37 9797@item -Wredundant-decls
d77de738
ML
9798Warn if anything is declared more than once in the same scope, even in
9799cases where multiple declaration is valid and changes nothing.
9800
d77de738
ML
9801@opindex Wrestrict
9802@opindex Wno-restrict
ddf6fe37 9803@item -Wrestrict
d77de738
ML
9804Warn when an object referenced by a @code{restrict}-qualified parameter
9805(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9806argument, or when copies between such objects overlap. For example,
9807the call to the @code{strcpy} function below attempts to truncate the string
9808by replacing its initial characters with the last four. However, because
9809the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9810the call is diagnosed.
9811
9812@smallexample
9813void foo (void)
9814@{
9815 char a[] = "abcd1234";
9816 strcpy (a, a + 4);
9817 @dots{}
9818@}
9819@end smallexample
9820The @option{-Wrestrict} option detects some instances of simple overlap
9821even without optimization but works best at @option{-O2} and above. It
9822is included in @option{-Wall}.
9823
d77de738
ML
9824@opindex Wnested-externs
9825@opindex Wno-nested-externs
ddf6fe37 9826@item -Wnested-externs @r{(C and Objective-C only)}
d77de738
ML
9827Warn if an @code{extern} declaration is encountered within a function.
9828
d77de738
ML
9829@opindex Winline
9830@opindex Wno-inline
ddf6fe37 9831@item -Winline
d77de738
ML
9832Warn if a function that is declared as inline cannot be inlined.
9833Even with this option, the compiler does not warn about failures to
9834inline functions declared in system headers.
9835
9836The compiler uses a variety of heuristics to determine whether or not
9837to inline a function. For example, the compiler takes into account
9838the size of the function being inlined and the amount of inlining
9839that has already been done in the current function. Therefore,
9840seemingly insignificant changes in the source program can cause the
9841warnings produced by @option{-Winline} to appear or disappear.
9842
d77de738 9843@opindex Winterference-size
ddf6fe37 9844@item -Winterference-size
d77de738
ML
9845Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9846without specifying its value with @option{--param destructive-interference-size}.
9847Also warn about questionable values for that option.
9848
9849This variable is intended to be used for controlling class layout, to
9850avoid false sharing in concurrent code:
9851
9852@smallexample
9853struct independent_fields @{
4ace81b6
SL
9854 alignas(std::hardware_destructive_interference_size)
9855 std::atomic<int> one;
9856 alignas(std::hardware_destructive_interference_size)
9857 std::atomic<int> two;
d77de738
ML
9858@};
9859@end smallexample
9860
9861Here @samp{one} and @samp{two} are intended to be far enough apart
9862that stores to one won't require accesses to the other to reload the
9863cache line.
9864
9865By default, @option{--param destructive-interference-size} and
9866@option{--param constructive-interference-size} are set based on the
9867current @option{-mtune} option, typically to the L1 cache line size
9868for the particular target CPU, sometimes to a range if tuning for a
9869generic target. So all translation units that depend on ABI
9870compatibility for the use of these variables must be compiled with
9871the same @option{-mtune} (or @option{-mcpu}).
9872
9873If ABI stability is important, such as if the use is in a header for a
9874library, you should probably not use the hardware interference size
9875variables at all. Alternatively, you can force a particular value
9876with @option{--param}.
9877
9878If you are confident that your use of the variable does not affect ABI
9879outside a single build of your project, you can turn off the warning
9880with @option{-Wno-interference-size}.
9881
d77de738
ML
9882@opindex Wint-in-bool-context
9883@opindex Wno-int-in-bool-context
ddf6fe37 9884@item -Wint-in-bool-context
d77de738
ML
9885Warn for suspicious use of integer values where boolean values are expected,
9886such as conditional expressions (?:) using non-boolean integer constants in
9887boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9888integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9889for all kinds of multiplications regardless of the data type.
9890This warning is enabled by @option{-Wall}.
9891
d77de738
ML
9892@opindex Wno-int-to-pointer-cast
9893@opindex Wint-to-pointer-cast
ddf6fe37 9894@item -Wno-int-to-pointer-cast
d77de738
ML
9895Suppress warnings from casts to pointer type of an integer of a
9896different size. In C++, casting to a pointer type of smaller size is
9897an error. @option{Wint-to-pointer-cast} is enabled by default.
9898
9899
d77de738
ML
9900@opindex Wno-pointer-to-int-cast
9901@opindex Wpointer-to-int-cast
ddf6fe37 9902@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
d77de738
ML
9903Suppress warnings from casts from a pointer to an integer type of a
9904different size.
9905
d77de738
ML
9906@opindex Winvalid-pch
9907@opindex Wno-invalid-pch
ddf6fe37 9908@item -Winvalid-pch
d77de738
ML
9909Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9910the search path but cannot be used.
9911
d77de738
ML
9912@opindex Winvalid-utf8
9913@opindex Wno-invalid-utf8
ddf6fe37 9914@item -Winvalid-utf8
d77de738
ML
9915Warn if an invalid UTF-8 character is found.
9916This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
9917is used and turned into error with @option{-pedantic-errors}.
9918
d77de738
ML
9919@opindex Wunicode
9920@opindex Wno-unicode
ddf6fe37 9921@item -Wno-unicode
d77de738
ML
9922Don't diagnose invalid forms of delimited or named escape sequences which are
9923treated as separate tokens. @option{Wunicode} is enabled by default.
9924
d77de738
ML
9925@opindex Wlong-long
9926@opindex Wno-long-long
ddf6fe37 9927@item -Wlong-long
d77de738
ML
9928Warn if @code{long long} type is used. This is enabled by either
9929@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
9930modes. To inhibit the warning messages, use @option{-Wno-long-long}.
9931
d77de738
ML
9932@opindex Wvariadic-macros
9933@opindex Wno-variadic-macros
ddf6fe37 9934@item -Wvariadic-macros
d77de738
ML
9935Warn if variadic macros are used in ISO C90 mode, or if the GNU
9936alternate syntax is used in ISO C99 mode. This is enabled by either
9937@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
9938messages, use @option{-Wno-variadic-macros}.
9939
d77de738
ML
9940@opindex Wvarargs
9941@opindex Wno-varargs
ddf6fe37 9942@item -Wno-varargs
d77de738
ML
9943Do not warn upon questionable usage of the macros used to handle variable
9944arguments like @code{va_start}. These warnings are enabled by default.
9945
d77de738
ML
9946@opindex Wvector-operation-performance
9947@opindex Wno-vector-operation-performance
ddf6fe37 9948@item -Wvector-operation-performance
d77de738
ML
9949Warn if vector operation is not implemented via SIMD capabilities of the
9950architecture. Mainly useful for the performance tuning.
9951Vector operation can be implemented @code{piecewise}, which means that the
9952scalar operation is performed on every vector element;
9953@code{in parallel}, which means that the vector operation is implemented
9954using scalars of wider type, which normally is more performance efficient;
9955and @code{as a single scalar}, which means that vector fits into a
9956scalar type.
9957
d77de738
ML
9958@opindex Wvla
9959@opindex Wno-vla
ddf6fe37 9960@item -Wvla
d77de738
ML
9961Warn if a variable-length array is used in the code.
9962@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
9963the variable-length array.
9964
d77de738
ML
9965@opindex Wvla-larger-than=
9966@opindex Wno-vla-larger-than
ddf6fe37 9967@item -Wvla-larger-than=@var{byte-size}
d77de738
ML
9968If this option is used, the compiler warns for declarations of
9969variable-length arrays whose size is either unbounded, or bounded
9970by an argument that allows the array size to exceed @var{byte-size}
9971bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
9972works, but with variable-length arrays.
9973
9974Note that GCC may optimize small variable-length arrays of a known
9975value into plain arrays, so this warning may not get triggered for
9976such arrays.
9977
9978@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
9979is typically only effective when @option{-ftree-vrp} is active (default
9980for @option{-O2} and above).
9981
9982See also @option{-Walloca-larger-than=@var{byte-size}}.
9983
d77de738 9984@opindex Wno-vla-larger-than
ddf6fe37 9985@item -Wno-vla-larger-than
d77de738
ML
9986Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
9987to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
9988
d77de738 9989@opindex Wno-vla-parameter
ddf6fe37 9990@item -Wvla-parameter
d77de738
ML
9991Warn about redeclarations of functions involving arguments of Variable
9992Length Array types of inconsistent kinds or forms, and enable the detection
9993of out-of-bounds accesses to such parameters by warnings such as
9994@option{-Warray-bounds}.
9995
9996If the first function declaration uses the VLA form the bound specified
9997in the array is assumed to be the minimum number of elements expected to
9998be provided in calls to the function and the maximum number of elements
9999accessed by it. Failing to provide arguments of sufficient size or
10000accessing more than the maximum number of elements may be diagnosed.
10001
10002For example, the warning triggers for the following redeclarations because
10003the first one allows an array of any size to be passed to @code{f} while
10004the second one specifies that the array argument must have at least @code{n}
10005elements. In addition, calling @code{f} with the associated VLA bound
10006parameter in excess of the actual VLA bound triggers a warning as well.
10007
10008@smallexample
10009void f (int n, int[n]);
4ace81b6
SL
10010// warning: argument 2 previously declared as a VLA
10011void f (int, int[]);
d77de738
ML
10012
10013void g (int n)
10014@{
10015 if (n > 4)
10016 return;
10017 int a[n];
4ace81b6
SL
10018 // warning: access to a by f may be out of bounds
10019 f (sizeof a, a);
d77de738
ML
10020 @dots{}
10021@}
10022
10023@end smallexample
10024
10025@option{-Wvla-parameter} is included in @option{-Wall}. The
10026@option{-Warray-parameter} option triggers warnings for similar problems
10027involving ordinary array arguments.
10028
d77de738
ML
10029@opindex Wvolatile-register-var
10030@opindex Wno-volatile-register-var
ddf6fe37 10031@item -Wvolatile-register-var
d77de738
ML
10032Warn if a register variable is declared volatile. The volatile
10033modifier does not inhibit all optimizations that may eliminate reads
10034and/or writes to register variables. This warning is enabled by
10035@option{-Wall}.
10036
d77de738
ML
10037@opindex Wxor-used-as-pow
10038@opindex Wno-xor-used-as-pow
ddf6fe37 10039@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10040Warn about uses of @code{^}, the exclusive or operator, where it appears
10041the user meant exponentiation. Specifically, the warning occurs when the
10042left-hand side is the decimal constant 2 or 10 and the right-hand side
10043is also a decimal constant.
10044
10045In C and C++, @code{^} means exclusive or, whereas in some other languages
10046(e.g. TeX and some versions of BASIC) it means exponentiation.
10047
10048This warning is enabled by default. It can be silenced by converting one
10049of the operands to hexadecimal.
10050
d77de738
ML
10051@opindex Wdisabled-optimization
10052@opindex Wno-disabled-optimization
ddf6fe37 10053@item -Wdisabled-optimization
d77de738
ML
10054Warn if a requested optimization pass is disabled. This warning does
10055not generally indicate that there is anything wrong with your code; it
10056merely indicates that GCC's optimizers are unable to handle the code
10057effectively. Often, the problem is that your code is too big or too
10058complex; GCC refuses to optimize programs when the optimization
10059itself is likely to take inordinate amounts of time.
10060
d77de738
ML
10061@opindex Wpointer-sign
10062@opindex Wno-pointer-sign
ddf6fe37 10063@item -Wpointer-sign @r{(C and Objective-C only)}
d77de738
ML
10064Warn for pointer argument passing or assignment with different signedness.
10065This option is only supported for C and Objective-C@. It is implied by
10066@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10067@option{-Wno-pointer-sign}.
10068
d77de738
ML
10069@opindex Wstack-protector
10070@opindex Wno-stack-protector
ddf6fe37 10071@item -Wstack-protector
d77de738
ML
10072This option is only active when @option{-fstack-protector} is active. It
10073warns about functions that are not protected against stack smashing.
10074
d77de738
ML
10075@opindex Woverlength-strings
10076@opindex Wno-overlength-strings
ddf6fe37 10077@item -Woverlength-strings
d77de738
ML
10078Warn about string constants that are longer than the ``minimum
10079maximum'' length specified in the C standard. Modern compilers
10080generally allow string constants that are much longer than the
10081standard's minimum limit, but very portable programs should avoid
10082using longer strings.
10083
10084The limit applies @emph{after} string constant concatenation, and does
10085not count the trailing NUL@. In C90, the limit was 509 characters; in
10086C99, it was raised to 4095. C++98 does not specify a normative
10087minimum maximum, so we do not diagnose overlength strings in C++@.
10088
10089This option is implied by @option{-Wpedantic}, and can be disabled with
10090@option{-Wno-overlength-strings}.
10091
d77de738
ML
10092@opindex Wunsuffixed-float-constants
10093@opindex Wno-unsuffixed-float-constants
ddf6fe37 10094@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
d77de738
ML
10095
10096Issue a warning for any floating constant that does not have
10097a suffix. When used together with @option{-Wsystem-headers} it
10098warns about such constants in system header files. This can be useful
10099when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10100from the decimal floating-point extension to C99.
10101
d77de738
ML
10102@opindex Wlto-type-mismatch
10103@opindex Wno-lto-type-mismatch
ddf6fe37 10104@item -Wno-lto-type-mismatch
d77de738
ML
10105
10106During the link-time optimization, do not warn about type mismatches in
10107global declarations from different compilation units.
10108Requires @option{-flto} to be enabled. Enabled by default.
10109
d77de738
ML
10110@opindex Wdesignated-init
10111@opindex Wno-designated-init
ddf6fe37 10112@item -Wno-designated-init @r{(C and Objective-C only)}
d77de738
ML
10113Suppress warnings when a positional initializer is used to initialize
10114a structure that has been marked with the @code{designated_init}
10115attribute.
10116
10117@end table
10118
10119@node Static Analyzer Options
10120@section Options That Control Static Analysis
10121
10122@table @gcctabopt
d77de738
ML
10123@opindex analyzer
10124@opindex fanalyzer
10125@opindex fno-analyzer
ddf6fe37 10126@item -fanalyzer
d77de738
ML
10127This option enables an static analysis of program flow which looks
10128for ``interesting'' interprocedural paths through the
10129code, and issues warnings for problems found on them.
10130
10131This analysis is much more expensive than other GCC warnings.
10132
a90316c6
DM
10133In technical terms, it performs coverage-guided symbolic execution of
10134the code being compiled. It is neither sound nor complete: it can
10135have false positives and false negatives. It is a bug-finding tool,
10136rather than a tool for proving program correctness.
10137
10138The analyzer is only suitable for use on C code in this release.
10139
d77de738
ML
10140Enabling this option effectively enables the following warnings:
10141
43b72ede
AA
10142@gccoptlist{
10143-Wanalyzer-allocation-size
10144-Wanalyzer-deref-before-check
10145-Wanalyzer-double-fclose
10146-Wanalyzer-double-free
10147-Wanalyzer-exposure-through-output-file
10148-Wanalyzer-exposure-through-uninit-copy
10149-Wanalyzer-fd-access-mode-mismatch
10150-Wanalyzer-fd-double-close
10151-Wanalyzer-fd-leak
10152-Wanalyzer-fd-phase-mismatch
10153-Wanalyzer-fd-type-mismatch
10154-Wanalyzer-fd-use-after-close
10155-Wanalyzer-fd-use-without-check
10156-Wanalyzer-file-leak
10157-Wanalyzer-free-of-non-heap
10158-Wanalyzer-imprecise-fp-arithmetic
10159-Wanalyzer-infinite-recursion
10160-Wanalyzer-jump-through-null
10161-Wanalyzer-malloc-leak
10162-Wanalyzer-mismatching-deallocation
10163-Wanalyzer-null-argument
10164-Wanalyzer-null-dereference
10165-Wanalyzer-out-of-bounds
10166-Wanalyzer-possible-null-argument
10167-Wanalyzer-possible-null-dereference
10168-Wanalyzer-putenv-of-auto-var
10169-Wanalyzer-shift-count-negative
10170-Wanalyzer-shift-count-overflow
10171-Wanalyzer-stale-setjmp-buffer
10172-Wanalyzer-unsafe-call-within-signal-handler
10173-Wanalyzer-use-after-free
10174-Wanalyzer-use-of-pointer-in-stale-stack-frame
10175-Wanalyzer-use-of-uninitialized-value
10176-Wanalyzer-va-arg-type-mismatch
10177-Wanalyzer-va-list-exhausted
10178-Wanalyzer-va-list-leak
10179-Wanalyzer-va-list-use-after-va-end
10180-Wanalyzer-write-to-const
10181-Wanalyzer-write-to-string-literal
d77de738
ML
10182}
10183@ignore
43b72ede
AA
10184-Wanalyzer-tainted-allocation-size
10185-Wanalyzer-tainted-array-index
10186-Wanalyzer-tainted-divisor
10187-Wanalyzer-tainted-offset
10188-Wanalyzer-tainted-size
d77de738
ML
10189@end ignore
10190
10191This option is only available if GCC was configured with analyzer
10192support enabled.
10193
d77de738
ML
10194@opindex Wanalyzer-too-complex
10195@opindex Wno-analyzer-too-complex
ddf6fe37 10196@item -Wanalyzer-too-complex
d77de738
ML
10197If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10198to attempt to explore the control flow and data flow in the program,
10199but these can be defeated by sufficiently complicated code.
10200
10201By default, the analysis silently stops if the code is too
10202complicated for the analyzer to fully explore and it reaches an internal
10203limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10204
d77de738
ML
10205@opindex Wanalyzer-allocation-size
10206@opindex Wno-analyzer-allocation-size
ddf6fe37 10207@item -Wno-analyzer-allocation-size
4ace81b6
SL
10208This warning requires @option{-fanalyzer}, which enables it;
10209to disable it, use @option{-Wno-analyzer-allocation-size}.
d77de738
ML
10210
10211This diagnostic warns for paths through the code in which a pointer to
10212a buffer is assigned to point at a buffer with a size that is not a
10213multiple of @code{sizeof (*pointer)}.
10214
10215See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10216
ce51e843
ML
10217@opindex Wanalyzer-deref-before-check
10218@opindex Wno-analyzer-deref-before-check
ddf6fe37 10219@item -Wno-analyzer-deref-before-check
ce51e843
ML
10220This warning requires @option{-fanalyzer}, which enables it; use
10221@option{-Wno-analyzer-deref-before-check}
10222to disable it.
10223
10224This diagnostic warns for paths through the code in which a pointer
10225is checked for @code{NULL} *after* it has already been
10226dereferenced, suggesting that the pointer could have been NULL.
10227Such cases suggest that the check for NULL is either redundant,
10228or that it needs to be moved to before the pointer is dereferenced.
10229
10230This diagnostic also considers values passed to a function argument
10231marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10232value, and thus will complain if such values are checked for @code{NULL}
10233after returning from such a function call.
10234
10235This diagnostic is unlikely to be reported when any level of optimization
10236is enabled, as GCC's optimization logic will typically consider such
10237checks for NULL as being redundant, and optimize them away before the
10238analyzer "sees" them. Hence optimization should be disabled when
10239attempting to trigger this diagnostic.
10240
d77de738
ML
10241@opindex Wanalyzer-double-fclose
10242@opindex Wno-analyzer-double-fclose
ddf6fe37 10243@item -Wno-analyzer-double-fclose
d77de738
ML
10244This warning requires @option{-fanalyzer}, which enables it; use
10245@option{-Wno-analyzer-double-fclose} to disable it.
10246
10247This diagnostic warns for paths through the code in which a @code{FILE *}
10248can have @code{fclose} called on it more than once.
10249
10250See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10251
d77de738
ML
10252@opindex Wanalyzer-double-free
10253@opindex Wno-analyzer-double-free
ddf6fe37 10254@item -Wno-analyzer-double-free
d77de738
ML
10255This warning requires @option{-fanalyzer}, which enables it; use
10256@option{-Wno-analyzer-double-free} to disable it.
10257
10258This diagnostic warns for paths through the code in which a pointer
10259can have a deallocator called on it more than once, either @code{free},
10260or a deallocator referenced by attribute @code{malloc}.
10261
10262See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10263
d77de738
ML
10264@opindex Wanalyzer-exposure-through-output-file
10265@opindex Wno-analyzer-exposure-through-output-file
ddf6fe37 10266@item -Wno-analyzer-exposure-through-output-file
d77de738
ML
10267This warning requires @option{-fanalyzer}, which enables it; use
10268@option{-Wno-analyzer-exposure-through-output-file}
10269to disable it.
10270
10271This diagnostic warns for paths through the code in which a
10272security-sensitive value is written to an output file
10273(such as writing a password to a log file).
10274
10275See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10276
d77de738
ML
10277@opindex Wanalyzer-exposure-through-uninit-copy
10278@opindex Wno-analyzer-exposure-through-uninit-copy
ddf6fe37 10279@item -Wanalyzer-exposure-through-uninit-copy
d77de738
ML
10280This warning requires both @option{-fanalyzer} and the use of a plugin
10281to specify a function that copies across a ``trust boundary''. Use
10282@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10283
10284This diagnostic warns for ``infoleaks'' - paths through the code in which
10285uninitialized values are copied across a security boundary
10286(such as code within an OS kernel that copies a partially-initialized
10287struct on the stack to user space).
10288
10289See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10290
d77de738
ML
10291@opindex Wanalyzer-fd-access-mode-mismatch
10292@opindex Wno-analyzer-fd-access-mode-mismatch
ddf6fe37 10293@item -Wno-analyzer-fd-access-mode-mismatch
d77de738
ML
10294This warning requires @option{-fanalyzer}, which enables it; use
10295@option{-Wno-analyzer-fd-access-mode-mismatch}
10296to disable it.
10297
10298This diagnostic warns for paths through code in which a
10299@code{read} on a write-only file descriptor is attempted, or vice versa.
10300
10301This diagnostic also warns for code paths in a which a function with attribute
10302@code{fd_arg_read (N)} is called with a file descriptor opened with
10303@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10304@code{fd_arg_write (N)} is called with a file descriptor opened with
10305@code{O_RDONLY} at referenced argument @var{N}.
10306
d77de738
ML
10307@opindex Wanalyzer-fd-double-close
10308@opindex Wno-analyzer-fd-double-close
ddf6fe37 10309@item -Wno-analyzer-fd-double-close
d77de738
ML
10310This warning requires @option{-fanalyzer}, which enables it; use
10311@option{-Wno-analyzer-fd-double-close}
10312to disable it.
10313
10314This diagnostic warns for paths through code in which a
10315file descriptor can be closed more than once.
10316
10317See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10318
d77de738
ML
10319@opindex Wanalyzer-fd-leak
10320@opindex Wno-analyzer-fd-leak
ddf6fe37 10321@item -Wno-analyzer-fd-leak
d77de738
ML
10322This warning requires @option{-fanalyzer}, which enables it; use
10323@option{-Wno-analyzer-fd-leak}
10324to disable it.
10325
10326This diagnostic warns for paths through code in which an
10327open file descriptor is leaked.
10328
10329See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10330
86a90006
DM
10331@opindex Wanalyzer-fd-phase-mismatch
10332@opindex Wno-analyzer-fd-phase-mismatch
ddf6fe37 10333@item -Wno-analyzer-fd-phase-mismatch
86a90006
DM
10334This warning requires @option{-fanalyzer}, which enables it; use
10335@option{-Wno-analyzer-fd-phase-mismatch}
10336to disable it.
10337
10338This diagnostic warns for paths through code in which an operation is
10339attempted in the wrong phase of a file descriptor's lifetime.
10340For example, it will warn on attempts to call @code{accept} on a stream
10341socket that has not yet had @code{listen} successfully called on it.
10342
10343See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10344
86a90006
DM
10345@opindex Wanalyzer-fd-type-mismatch
10346@opindex Wno-analyzer-fd-type-mismatch
ddf6fe37 10347@item -Wno-analyzer-fd-type-mismatch
86a90006
DM
10348This warning requires @option{-fanalyzer}, which enables it; use
10349@option{-Wno-analyzer-fd-type-mismatch}
10350to disable it.
10351
10352This diagnostic warns for paths through code in which an
10353operation is attempted on the wrong type of file descriptor.
10354For example, it will warn on attempts to use socket operations
10355on a file descriptor obtained via @code{open}, or when attempting
10356to use a stream socket operation on a datagram socket.
10357
d77de738
ML
10358@opindex Wanalyzer-fd-use-after-close
10359@opindex Wno-analyzer-fd-use-after-close
ddf6fe37 10360@item -Wno-analyzer-fd-use-after-close
d77de738
ML
10361This warning requires @option{-fanalyzer}, which enables it; use
10362@option{-Wno-analyzer-fd-use-after-close}
10363to disable it.
10364
10365This diagnostic warns for paths through code in which a
10366read or write is called on a closed file descriptor.
10367
10368This diagnostic also warns for paths through code in which
10369a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10370or @code{fd_arg_write (N)} is called with a closed file descriptor at
10371referenced argument @code{N}.
10372
d77de738
ML
10373@opindex Wanalyzer-fd-use-without-check
10374@opindex Wno-analyzer-fd-use-without-check
ddf6fe37 10375@item -Wno-analyzer-fd-use-without-check
d77de738
ML
10376This warning requires @option{-fanalyzer}, which enables it; use
10377@option{-Wno-analyzer-fd-use-without-check}
10378to disable it.
10379
10380This diagnostic warns for paths through code in which a
10381file descriptor is used without being checked for validity.
10382
10383This diagnostic also warns for paths through code in which
10384a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10385or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10386argument @code{N}, without being checked for validity.
10387
d77de738
ML
10388@opindex Wanalyzer-file-leak
10389@opindex Wno-analyzer-file-leak
ddf6fe37 10390@item -Wno-analyzer-file-leak
d77de738
ML
10391This warning requires @option{-fanalyzer}, which enables it; use
10392@option{-Wno-analyzer-file-leak}
10393to disable it.
10394
10395This diagnostic warns for paths through the code in which a
10396@code{<stdio.h>} @code{FILE *} stream object is leaked.
10397
10398See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10399
d77de738
ML
10400@opindex Wanalyzer-free-of-non-heap
10401@opindex Wno-analyzer-free-of-non-heap
ddf6fe37 10402@item -Wno-analyzer-free-of-non-heap
d77de738
ML
10403This warning requires @option{-fanalyzer}, which enables it; use
10404@option{-Wno-analyzer-free-of-non-heap}
10405to disable it.
10406
10407This diagnostic warns for paths through the code in which @code{free}
10408is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10409
10410See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10411
d77de738
ML
10412@opindex Wanalyzer-imprecise-fp-arithmetic
10413@opindex Wno-analyzer-imprecise-fp-arithmetic
ddf6fe37 10414@item -Wno-analyzer-imprecise-fp-arithmetic
d77de738
ML
10415This warning requires @option{-fanalyzer}, which enables it; use
10416@option{-Wno-analyzer-imprecise-fp-arithmetic}
10417to disable it.
10418
10419This diagnostic warns for paths through the code in which floating-point
10420arithmetic is used in locations where precise computation is needed. This
10421diagnostic only warns on use of floating-point operands inside the
10422calculation of an allocation size at the moment.
10423
ce51e843
ML
10424@opindex Wanalyzer-infinite-recursion
10425@opindex Wno-analyzer-infinite-recursion
ddf6fe37 10426@item -Wno-analyzer-infinite-recursion
ce51e843
ML
10427This warning requires @option{-fanalyzer}, which enables it; use
10428@option{-Wno-analyzer-infinite-recursion} to disable it.
10429
10430This diagnostics warns for paths through the code which appear to
10431lead to infinite recursion.
10432
10433Specifically, when the analyzer "sees" a recursive call, it will compare
10434the state of memory at the entry to the new frame with that at the entry
10435to the previous frame of that function on the stack. The warning is
10436issued if nothing in memory appears to be changing; any changes observed
10437to parameters or globals are assumed to lead to termination of the
10438recursion and thus suppress the warning.
10439
10440This diagnostic is likely to miss cases of infinite recursion that
10441are convered to iteration by the optimizer before the analyzer "sees"
10442them. Hence optimization should be disabled when attempting to trigger
10443this diagnostic.
10444
10445Compare with @option{-Winfinite-recursion}, which provides a similar
10446diagnostic, but is implemented in a different way.
10447
d77de738
ML
10448@opindex Wanalyzer-jump-through-null
10449@opindex Wno-analyzer-jump-through-null
ddf6fe37 10450@item -Wno-analyzer-jump-through-null
d77de738
ML
10451This warning requires @option{-fanalyzer}, which enables it; use
10452@option{-Wno-analyzer-jump-through-null}
10453to disable it.
10454
10455This diagnostic warns for paths through the code in which a @code{NULL}
10456function pointer is called.
10457
d77de738
ML
10458@opindex Wanalyzer-malloc-leak
10459@opindex Wno-analyzer-malloc-leak
ddf6fe37 10460@item -Wno-analyzer-malloc-leak
d77de738
ML
10461This warning requires @option{-fanalyzer}, which enables it; use
10462@option{-Wno-analyzer-malloc-leak}
10463to disable it.
10464
10465This diagnostic warns for paths through the code in which a
10466pointer allocated via an allocator is leaked: either @code{malloc},
10467or a function marked with attribute @code{malloc}.
10468
10469See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10470
d77de738
ML
10471@opindex Wanalyzer-mismatching-deallocation
10472@opindex Wno-analyzer-mismatching-deallocation
ddf6fe37 10473@item -Wno-analyzer-mismatching-deallocation
d77de738
ML
10474This warning requires @option{-fanalyzer}, which enables it; use
10475@option{-Wno-analyzer-mismatching-deallocation}
10476to disable it.
10477
10478This diagnostic warns for paths through the code in which the
10479wrong deallocation function is called on a pointer value, based on
10480which function was used to allocate the pointer value. The diagnostic
10481will warn about mismatches between @code{free}, scalar @code{delete}
10482and vector @code{delete[]}, and those marked as allocator/deallocator
10483pairs using attribute @code{malloc}.
10484
10485See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10486
d77de738
ML
10487@opindex Wanalyzer-out-of-bounds
10488@opindex Wno-analyzer-out-of-bounds
ddf6fe37 10489@item -Wno-analyzer-out-of-bounds
4ace81b6 10490This warning requires @option{-fanalyzer}, which enables it; use
d77de738
ML
10491@option{-Wno-analyzer-out-of-bounds} to disable it.
10492
4ace81b6 10493This diagnostic warns for paths through the code in which a buffer is
d77de738
ML
10494definitely read or written out-of-bounds. The diagnostic applies for
10495cases where the analyzer is able to determine a constant offset and for
10496accesses past the end of a buffer, also a constant capacity. Further,
10497the diagnostic does limited checking for accesses past the end when the
10498offset as well as the capacity is symbolic.
10499
10500See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10501
d77de738
ML
10502@opindex Wanalyzer-possible-null-argument
10503@opindex Wno-analyzer-possible-null-argument
ddf6fe37 10504@item -Wno-analyzer-possible-null-argument
d77de738
ML
10505This warning requires @option{-fanalyzer}, which enables it; use
10506@option{-Wno-analyzer-possible-null-argument} to disable it.
10507
10508This diagnostic warns for paths through the code in which a
10509possibly-NULL value is passed to a function argument marked
10510with @code{__attribute__((nonnull))} as requiring a non-NULL
10511value.
10512
10513See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10514
d77de738
ML
10515@opindex Wanalyzer-possible-null-dereference
10516@opindex Wno-analyzer-possible-null-dereference
ddf6fe37 10517@item -Wno-analyzer-possible-null-dereference
d77de738
ML
10518This warning requires @option{-fanalyzer}, which enables it; use
10519@option{-Wno-analyzer-possible-null-dereference} to disable it.
10520
10521This diagnostic warns for paths through the code in which a
10522possibly-NULL value is dereferenced.
10523
10524See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10525
d77de738
ML
10526@opindex Wanalyzer-null-argument
10527@opindex Wno-analyzer-null-argument
ddf6fe37 10528@item -Wno-analyzer-null-argument
d77de738
ML
10529This warning requires @option{-fanalyzer}, which enables it; use
10530@option{-Wno-analyzer-null-argument} to disable it.
10531
10532This diagnostic warns for paths through the code in which a
10533value known to be NULL is passed to a function argument marked
10534with @code{__attribute__((nonnull))} as requiring a non-NULL
10535value.
10536
10537See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10538
d77de738
ML
10539@opindex Wanalyzer-null-dereference
10540@opindex Wno-analyzer-null-dereference
ddf6fe37 10541@item -Wno-analyzer-null-dereference
d77de738
ML
10542This warning requires @option{-fanalyzer}, which enables it; use
10543@option{-Wno-analyzer-null-dereference} to disable it.
10544
10545This diagnostic warns for paths through the code in which a
10546value known to be NULL is dereferenced.
10547
10548See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10549
d77de738
ML
10550@opindex Wanalyzer-putenv-of-auto-var
10551@opindex Wno-analyzer-putenv-of-auto-var
ddf6fe37 10552@item -Wno-analyzer-putenv-of-auto-var
d77de738
ML
10553This warning requires @option{-fanalyzer}, which enables it; use
10554@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10555
10556This diagnostic warns for paths through the code in which a
10557call to @code{putenv} is passed a pointer to an automatic variable
10558or an on-stack buffer.
10559
10560See @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}.
10561
d77de738
ML
10562@opindex Wanalyzer-shift-count-negative
10563@opindex Wno-analyzer-shift-count-negative
ddf6fe37 10564@item -Wno-analyzer-shift-count-negative
d77de738
ML
10565This warning requires @option{-fanalyzer}, which enables it; use
10566@option{-Wno-analyzer-shift-count-negative} to disable it.
10567
10568This diagnostic warns for paths through the code in which a
10569shift is attempted with a negative count. It is analogous to
10570the @option{-Wshift-count-negative} diagnostic implemented in
10571the C/C++ front ends, but is implemented based on analyzing
10572interprocedural paths, rather than merely parsing the syntax tree.
10573However, the analyzer does not prioritize detection of such paths, so
10574false negatives are more likely relative to other warnings.
10575
d77de738
ML
10576@opindex Wanalyzer-shift-count-overflow
10577@opindex Wno-analyzer-shift-count-overflow
ddf6fe37 10578@item -Wno-analyzer-shift-count-overflow
d77de738
ML
10579This warning requires @option{-fanalyzer}, which enables it; use
10580@option{-Wno-analyzer-shift-count-overflow} to disable it.
10581
10582This diagnostic warns for paths through the code in which a
10583shift is attempted with a count greater than or equal to the
10584precision of the operand's type. It is analogous to
10585the @option{-Wshift-count-overflow} diagnostic implemented in
10586the C/C++ front ends, but is implemented based on analyzing
10587interprocedural paths, rather than merely parsing the syntax tree.
10588However, the analyzer does not prioritize detection of such paths, so
10589false negatives are more likely relative to other warnings.
10590
d77de738
ML
10591@opindex Wanalyzer-stale-setjmp-buffer
10592@opindex Wno-analyzer-stale-setjmp-buffer
ddf6fe37 10593@item -Wno-analyzer-stale-setjmp-buffer
d77de738
ML
10594This warning requires @option{-fanalyzer}, which enables it; use
10595@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10596
10597This diagnostic warns for paths through the code in which
10598@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10599to a @code{setjmp} call in a function that has returned.
10600
10601When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10602location, it records the stack frame. The stack frame becomes invalid
10603when the function containing the @code{setjmp} call returns. Attempting
10604to rewind to it via @code{longjmp} would reference a stack frame that
10605no longer exists, and likely lead to a crash (or worse).
10606
d77de738
ML
10607@opindex Wanalyzer-tainted-allocation-size
10608@opindex Wno-analyzer-tainted-allocation-size
ddf6fe37 10609@item -Wno-analyzer-tainted-allocation-size
d77de738
ML
10610This warning requires both @option{-fanalyzer} and
10611@option{-fanalyzer-checker=taint} to enable it;
10612use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10613
10614This diagnostic warns for paths through the code in which a value
10615that could be under an attacker's control is used as the size
10616of an allocation without being sanitized, so that an attacker could
10617inject an excessively large allocation and potentially cause a denial
10618of service attack.
10619
10620See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10621
ce51e843
ML
10622@opindex Wanalyzer-tainted-assertion
10623@opindex Wno-analyzer-tainted-assertion
ddf6fe37 10624@item -Wno-analyzer-tainted-assertion
ce51e843
ML
10625
10626This warning requires both @option{-fanalyzer} and
10627@option{-fanalyzer-checker=taint} to enable it;
10628use @option{-Wno-analyzer-tainted-assertion} to disable it.
10629
10630This diagnostic warns for paths through the code in which a value
10631that could be under an attacker's control is used as part of a
10632condition without being first sanitized, and that condition guards a
10633call to a function marked with attribute @code{noreturn}
10634(such as the function @code{__builtin_unreachable}). Such functions
10635typically indicate abnormal termination of the program, such as for
10636assertion failure handlers. For example:
10637
10638@smallexample
10639assert (some_tainted_value < SOME_LIMIT);
10640@end smallexample
10641
10642In such cases:
10643
10644@itemize
10645@item
10646when assertion-checking is enabled: an attacker could trigger
10647a denial of service by injecting an assertion failure
10648
10649@item
10650when assertion-checking is disabled, such as by defining @code{NDEBUG},
10651an attacker could inject data that subverts the process, since it
10652presumably violates a precondition that is being assumed by the code.
10653
10654@end itemize
10655
10656Note that when assertion-checking is disabled, the assertions are
10657typically removed by the preprocessor before the analyzer has a chance
10658to "see" them, so this diagnostic can only generate warnings on builds
10659in which assertion-checking is enabled.
10660
10661For the purpose of this warning, any function marked with attribute
10662@code{noreturn} is considered as a possible assertion failure
10663handler, including @code{__builtin_unreachable}. Note that these functions
10664are sometimes removed by the optimizer before the analyzer "sees" them.
10665Hence optimization should be disabled when attempting to trigger this
10666diagnostic.
10667
10668See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10669
10670The warning can also report problematic constructions such as
10671
10672@smallexample
10673switch (some_tainted_value) @{
10674case 0:
10675 /* [...etc; various valid cases omitted...] */
10676 break;
10677
10678default:
10679 __builtin_unreachable (); /* BUG: attacker can trigger this */
10680@}
10681@end smallexample
10682
10683despite the above not being an assertion failure, strictly speaking.
10684
d77de738
ML
10685@opindex Wanalyzer-tainted-array-index
10686@opindex Wno-analyzer-tainted-array-index
ddf6fe37 10687@item -Wno-analyzer-tainted-array-index
d77de738
ML
10688This warning requires both @option{-fanalyzer} and
10689@option{-fanalyzer-checker=taint} to enable it;
10690use @option{-Wno-analyzer-tainted-array-index} to disable it.
10691
10692This diagnostic warns for paths through the code in which a value
10693that could be under an attacker's control is used as the index
10694of an array access without being sanitized, so that an attacker
10695could inject an out-of-bounds access.
10696
10697See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10698
d77de738
ML
10699@opindex Wanalyzer-tainted-divisor
10700@opindex Wno-analyzer-tainted-divisor
ddf6fe37 10701@item -Wno-analyzer-tainted-divisor
d77de738
ML
10702This warning requires both @option{-fanalyzer} and
10703@option{-fanalyzer-checker=taint} to enable it;
10704use @option{-Wno-analyzer-tainted-divisor} to disable it.
10705
10706This diagnostic warns for paths through the code in which a value
10707that could be under an attacker's control is used as the divisor
10708in a division or modulus operation without being sanitized, so that
10709an attacker could inject a division-by-zero.
10710
10711See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10712
d77de738
ML
10713@opindex Wanalyzer-tainted-offset
10714@opindex Wno-analyzer-tainted-offset
ddf6fe37 10715@item -Wno-analyzer-tainted-offset
d77de738
ML
10716This warning requires both @option{-fanalyzer} and
10717@option{-fanalyzer-checker=taint} to enable it;
10718use @option{-Wno-analyzer-tainted-offset} to disable it.
10719
10720This diagnostic warns for paths through the code in which a value
10721that could be under an attacker's control is used as a pointer offset
10722without being sanitized, so that an attacker could inject an out-of-bounds
10723access.
10724
10725See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10726
d77de738
ML
10727@opindex Wanalyzer-tainted-size
10728@opindex Wno-analyzer-tainted-size
ddf6fe37 10729@item -Wno-analyzer-tainted-size
d77de738
ML
10730This warning requires both @option{-fanalyzer} and
10731@option{-fanalyzer-checker=taint} to enable it;
10732use @option{-Wno-analyzer-tainted-size} to disable it.
10733
10734This diagnostic warns for paths through the code in which a value
10735that could be under an attacker's control is used as the size of
10736an operation such as @code{memset} without being sanitized, so that an
10737attacker could inject an out-of-bounds access.
10738
10739See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10740
d77de738
ML
10741@opindex Wanalyzer-unsafe-call-within-signal-handler
10742@opindex Wno-analyzer-unsafe-call-within-signal-handler
ddf6fe37 10743@item -Wno-analyzer-unsafe-call-within-signal-handler
d77de738
ML
10744This warning requires @option{-fanalyzer}, which enables it; use
10745@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10746
10747This diagnostic warns for paths through the code in which a
10748function known to be async-signal-unsafe (such as @code{fprintf}) is
10749called from a signal handler.
10750
10751See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10752
d77de738
ML
10753@opindex Wanalyzer-use-after-free
10754@opindex Wno-analyzer-use-after-free
ddf6fe37 10755@item -Wno-analyzer-use-after-free
d77de738
ML
10756This warning requires @option{-fanalyzer}, which enables it; use
10757@option{-Wno-analyzer-use-after-free} to disable it.
10758
10759This diagnostic warns for paths through the code in which a
10760pointer is used after a deallocator is called on it: either @code{free},
10761or a deallocator referenced by attribute @code{malloc}.
10762
10763See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
10764
d77de738
ML
10765@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
10766@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
ddf6fe37 10767@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
d77de738
ML
10768This warning requires @option{-fanalyzer}, which enables it; use
10769@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
10770to disable it.
10771
10772This diagnostic warns for paths through the code in which a pointer
10773is dereferenced that points to a variable in a stale stack frame.
10774
d77de738
ML
10775@opindex Wanalyzer-va-arg-type-mismatch
10776@opindex Wno-analyzer-va-arg-type-mismatch
ddf6fe37 10777@item -Wno-analyzer-va-arg-type-mismatch
d77de738
ML
10778This warning requires @option{-fanalyzer}, which enables it; use
10779@option{-Wno-analyzer-va-arg-type-mismatch}
10780to disable it.
10781
10782This diagnostic warns for interprocedural paths through the code for which
10783the analyzer detects an attempt to use @code{va_arg} to extract a value
10784passed to a variadic call, but uses a type that does not match that of
10785the expression passed to the call.
10786
10787See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
10788
d77de738
ML
10789@opindex Wanalyzer-va-list-exhausted
10790@opindex Wno-analyzer-va-list-exhausted
ddf6fe37 10791@item -Wno-analyzer-va-list-exhausted
d77de738
ML
10792This warning requires @option{-fanalyzer}, which enables it; use
10793@option{-Wno-analyzer-va-list-exhausted}
10794to disable it.
10795
10796This diagnostic warns for interprocedural paths through the code for which
10797the analyzer detects an attempt to use @code{va_arg} to access the next
10798value passed to a variadic call, but all of the values in the
10799@code{va_list} have already been consumed.
10800
10801See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
10802
d77de738
ML
10803@opindex Wanalyzer-va-list-leak
10804@opindex Wno-analyzer-va-list-leak
ddf6fe37 10805@item -Wno-analyzer-va-list-leak
d77de738
ML
10806This warning requires @option{-fanalyzer}, which enables it; use
10807@option{-Wno-analyzer-va-list-leak}
10808to disable it.
10809
10810This diagnostic warns for interprocedural paths through the code for which
10811the analyzer detects that @code{va_start} or @code{va_copy} has been called
10812on a @code{va_list} without a corresponding call to @code{va_end}.
10813
d77de738
ML
10814@opindex Wanalyzer-va-list-use-after-va-end
10815@opindex Wno-analyzer-va-list-use-after-va-end
ddf6fe37 10816@item -Wno-analyzer-va-list-use-after-va-end
d77de738
ML
10817This warning requires @option{-fanalyzer}, which enables it; use
10818@option{-Wno-analyzer-va-list-use-after-va-end}
10819to disable it.
10820
10821This diagnostic warns for interprocedural paths through the code for which
10822the analyzer detects an attempt to use a @code{va_list} after
10823@code{va_end} has been called on it.
10824@code{va_list}.
10825
d77de738
ML
10826@opindex Wanalyzer-write-to-const
10827@opindex Wno-analyzer-write-to-const
ddf6fe37 10828@item -Wno-analyzer-write-to-const
d77de738
ML
10829This warning requires @option{-fanalyzer}, which enables it; use
10830@option{-Wno-analyzer-write-to-const}
10831to disable it.
10832
10833This diagnostic warns for paths through the code in which the analyzer
10834detects an attempt to write through a pointer to a @code{const} object.
10835However, the analyzer does not prioritize detection of such paths, so
10836false negatives are more likely relative to other warnings.
10837
d77de738
ML
10838@opindex Wanalyzer-write-to-string-literal
10839@opindex Wno-analyzer-write-to-string-literal
ddf6fe37 10840@item -Wno-analyzer-write-to-string-literal
d77de738
ML
10841This warning requires @option{-fanalyzer}, which enables it; use
10842@option{-Wno-analyzer-write-to-string-literal}
10843to disable it.
10844
10845This diagnostic warns for paths through the code in which the analyzer
10846detects an attempt to write through a pointer to a string literal.
10847However, the analyzer does not prioritize detection of such paths, so
10848false negatives are more likely relative to other warnings.
10849
d77de738
ML
10850@opindex Wanalyzer-use-of-uninitialized-value
10851@opindex Wno-analyzer-use-of-uninitialized-value
ddf6fe37 10852@item -Wno-analyzer-use-of-uninitialized-value
d77de738
ML
10853This warning requires @option{-fanalyzer}, which enables it; use
10854@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
10855
10856This diagnostic warns for paths through the code in which an uninitialized
10857value is used.
10858
10859See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
10860
10861@end table
10862
10863The analyzer has hardcoded knowledge about the behavior of the following
10864memory-management functions:
10865
10866@itemize @bullet
10867@item @code{alloca}
10868@item The built-in functions @code{__builtin_alloc},
10869@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
10870@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
10871@code{__builtin_memcpy_chk}, @code{__builtin_memset},
10872@code{__builtin_memset_chk}, @code{__builtin_realloc},
10873@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
10874@item @code{calloc}
10875@item @code{free}
10876@item @code{malloc}
10877@item @code{memset}
10878@item @code{operator delete}
10879@item @code{operator delete []}
10880@item @code{operator new}
10881@item @code{operator new []}
10882@item @code{realloc}
10883@item @code{strdup}
10884@item @code{strndup}
10885@end itemize
10886
4ace81b6 10887@noindent
d77de738
ML
10888of the following functions for working with file descriptors:
10889
10890@itemize @bullet
10891@item @code{open}
10892@item @code{close}
10893@item @code{creat}
10894@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 10895@item @code{isatty}
d77de738
ML
10896@item @code{pipe}, and @code{pipe2}
10897@item @code{read}
10898@item @code{write}
86a90006 10899@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
10900@end itemize
10901
4ace81b6 10902@noindent
d77de738
ML
10903of the following functions for working with @code{<stdio.h>} streams:
10904@itemize @bullet
10905@item The built-in functions @code{__builtin_fprintf},
10906@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
10907@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
10908@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
10909@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
10910@code{__builtin_printf_unlocked}, @code{__builtin_putc},
10911@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
10912@code{__builtin_putc_unlocked}, @code{__builtin_puts},
10913@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
10914@code{__builtin_vprintf}
10915@item @code{fopen}
10916@item @code{fclose}
78a17f44 10917@item @code{ferror}
d77de738
ML
10918@item @code{fgets}
10919@item @code{fgets_unlocked}
78a17f44 10920@item @code{fileno}
d77de738 10921@item @code{fread}
78a17f44 10922@item @code{getc}
d77de738
ML
10923@item @code{getchar}
10924@item @code{fprintf}
10925@item @code{printf}
10926@item @code{fwrite}
10927@end itemize
10928
4ace81b6 10929@noindent
d77de738
ML
10930and of the following functions:
10931
10932@itemize @bullet
10933@item The built-in functions @code{__builtin_expect},
10934@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
10935@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
10936@code{__builtin_strlen}, @code{__builtin_va_copy}, and
10937@code{__builtin_va_start}
10938@item The GNU extensions @code{error} and @code{error_at_line}
10939@item @code{getpass}
10940@item @code{longjmp}
10941@item @code{putenv}
10942@item @code{setjmp}
10943@item @code{siglongjmp}
10944@item @code{signal}
10945@item @code{sigsetjmp}
10946@item @code{strchr}
10947@item @code{strlen}
10948@end itemize
10949
10950In addition, various functions with an @code{__analyzer_} prefix have
10951special meaning to the analyzer, described in the GCC Internals manual.
10952
10953Pertinent parameters for controlling the exploration are:
4ace81b6
SL
10954@itemize @bullet
10955@item @option{--param analyzer-bb-explosion-factor=@var{value}}
10956@item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
10957@item @option{--param analyzer-max-recursion-depth=@var{value}}
10958@item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
10959@end itemize
d77de738
ML
10960
10961The following options control the analyzer.
10962
10963@table @gcctabopt
10964
d77de738
ML
10965@opindex fanalyzer-call-summaries
10966@opindex fno-analyzer-call-summaries
ddf6fe37 10967@item -fanalyzer-call-summaries
d77de738
ML
10968Simplify interprocedural analysis by computing the effect of certain calls,
10969rather than exploring all paths through the function from callsite to each
10970possible return.
10971
10972If enabled, call summaries are only used for functions with more than one
10973call site, and that are sufficiently complicated (as per
10974@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
10975
d77de738 10976@opindex fanalyzer-checker
ddf6fe37 10977@item -fanalyzer-checker=@var{name}
d77de738
ML
10978Restrict the analyzer to run just the named checker, and enable it.
10979
10980Some checkers are disabled by default (even with @option{-fanalyzer}),
10981such as the @code{taint} checker that implements
10982@option{-Wanalyzer-tainted-array-index}, and this option is required
10983to enable them.
10984
10985@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
10986following warnings from @option{-fanalyzer}:
10987
43b72ede
AA
10988@gccoptlist{
10989-Wanalyzer-deref-before-check
10990-Wanalyzer-double-fclose
10991-Wanalyzer-double-free
10992-Wanalyzer-exposure-through-output-file
10993-Wanalyzer-fd-access-mode-mismatch
10994-Wanalyzer-fd-double-close
10995-Wanalyzer-fd-leak
10996-Wanalyzer-fd-use-after-close
10997-Wanalyzer-fd-use-without-check
10998-Wanalyzer-file-leak
10999-Wanalyzer-free-of-non-heap
11000-Wanalyzer-malloc-leak
11001-Wanalyzer-mismatching-deallocation
11002-Wanalyzer-null-argument
11003-Wanalyzer-null-dereference
11004-Wanalyzer-possible-null-argument
11005-Wanalyzer-possible-null-dereference
11006-Wanalyzer-unsafe-call-within-signal-handler
11007-Wanalyzer-use-after-free
11008-Wanalyzer-va-list-leak
11009-Wanalyzer-va-list-use-after-va-end
d77de738
ML
11010}
11011
d77de738
ML
11012@opindex fanalyzer-feasibility
11013@opindex fno-analyzer-feasibility
ddf6fe37 11014@item -fno-analyzer-feasibility
d77de738
ML
11015This option is intended for analyzer developers.
11016
11017By default the analyzer verifies that there is a feasible control flow path
11018for each diagnostic it emits: that the conditions that hold are not mutually
11019exclusive. Diagnostics for which no feasible path can be found are rejected.
11020This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
11021debugging issues in this code.
11022
d77de738
ML
11023@opindex fanalyzer-fine-grained
11024@opindex fno-analyzer-fine-grained
ddf6fe37 11025@item -fanalyzer-fine-grained
d77de738
ML
11026This option is intended for analyzer developers.
11027
11028Internally the analyzer builds an ``exploded graph'' that combines
11029control flow graphs with data flow information.
11030
11031By default, an edge in this graph can contain the effects of a run
11032of multiple statements within a basic block. With
11033@option{-fanalyzer-fine-grained}, each statement gets its own edge.
11034
d77de738
ML
11035@opindex fanalyzer-show-duplicate-count
11036@opindex fno-analyzer-show-duplicate-count
ddf6fe37 11037@item -fanalyzer-show-duplicate-count
d77de738
ML
11038This option is intended for analyzer developers: if multiple diagnostics
11039have been detected as being duplicates of each other, it emits a note when
11040reporting the best diagnostic, giving the number of additional diagnostics
11041that were suppressed by the deduplication logic.
11042
d77de738
ML
11043@opindex fanalyzer-state-merge
11044@opindex fno-analyzer-state-merge
ddf6fe37 11045@item -fno-analyzer-state-merge
d77de738
ML
11046This option is intended for analyzer developers.
11047
11048By default the analyzer attempts to simplify analysis by merging
11049sufficiently similar states at each program point as it builds its
11050``exploded graph''. With @option{-fno-analyzer-state-merge} this
11051merging can be suppressed, for debugging state-handling issues.
11052
d77de738
ML
11053@opindex fanalyzer-state-purge
11054@opindex fno-analyzer-state-purge
ddf6fe37 11055@item -fno-analyzer-state-purge
d77de738
ML
11056This option is intended for analyzer developers.
11057
11058By default the analyzer attempts to simplify analysis by purging
11059aspects of state at a program point that appear to no longer be relevant
11060e.g. the values of locals that aren't accessed later in the function
11061and which aren't relevant to leak analysis.
11062
11063With @option{-fno-analyzer-state-purge} this purging of state can
11064be suppressed, for debugging state-handling issues.
11065
8f636915
DM
11066@opindex fanalyzer-suppress-followups
11067@opindex fno-analyzer-suppress-followups
f33d7a88 11068@item -fno-analyzer-suppress-followups
8f636915
DM
11069This option is intended for analyzer developers.
11070
11071By default the analyzer will stop exploring an execution path after
11072encountering certain diagnostics, in order to avoid potentially issuing a
11073cascade of follow-up diagnostics.
11074
11075The diagnostics that terminate analysis along a path are:
11076
11077@itemize
11078@item @option{-Wanalyzer-null-argument}
11079@item @option{-Wanalyzer-null-dereference}
11080@item @option{-Wanalyzer-use-after-free}
11081@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11082@item @option{-Wanalyzer-use-of-uninitialized-value}
11083@end itemize
11084
11085With @option{-fno-analyzer-suppress-followups} the analyzer will
11086continue to explore such paths even after such diagnostics, which may
11087be helpful for debugging issues in the analyzer, or for microbenchmarks
11088for detecting undefined behavior.
11089
d77de738
ML
11090@opindex fanalyzer-transitivity
11091@opindex fno-analyzer-transitivity
ddf6fe37 11092@item -fanalyzer-transitivity
d77de738
ML
11093This option enables transitivity of constraints within the analyzer.
11094
d77de738
ML
11095@opindex fanalyzer-undo-inlining
11096@opindex fno-analyzer-undo-inlining
ddf6fe37 11097@item -fno-analyzer-undo-inlining
d77de738
ML
11098This option is intended for analyzer developers.
11099
11100@option{-fanalyzer} runs relatively late compared to other code analysis
11101tools, and some optimizations have already been applied to the code. In
11102particular function inlining may have occurred, leading to the
11103interprocedural execution paths emitted by the analyzer containing
11104function frames that don't correspond to those in the original source
11105code.
11106
11107By default the analyzer attempts to reconstruct the original function
11108frames, and to emit events showing the inlined calls.
11109
11110With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11111the original frame information can be be disabled, which may be of help
11112when debugging issues in the analyzer.
11113
11114@item -fanalyzer-verbose-edges
11115This option is intended for analyzer developers. It enables more
11116verbose, lower-level detail in the descriptions of control flow
11117within diagnostic paths.
11118
11119@item -fanalyzer-verbose-state-changes
11120This option is intended for analyzer developers. It enables more
11121verbose, lower-level detail in the descriptions of events relating
11122to state machines within diagnostic paths.
11123
11124@item -fanalyzer-verbosity=@var{level}
11125This option controls the complexity of the control flow paths that are
11126emitted for analyzer diagnostics.
11127
11128The @var{level} can be one of:
11129
11130@table @samp
11131@item 0
11132At this level, interprocedural call and return events are displayed,
11133along with the most pertinent state-change events relating to
11134a diagnostic. For example, for a double-@code{free} diagnostic,
11135both calls to @code{free} will be shown.
11136
11137@item 1
11138As per the previous level, but also show events for the entry
11139to each function.
11140
11141@item 2
11142As per the previous level, but also show events relating to
11143control flow that are significant to triggering the issue
11144(e.g. ``true path taken'' at a conditional).
11145
11146This level is the default.
11147
11148@item 3
11149As per the previous level, but show all control flow events, not
11150just significant ones.
11151
11152@item 4
11153This level is intended for analyzer developers; it adds various
11154other events intended for debugging the analyzer.
11155
11156@end table
11157
d77de738 11158@opindex fdump-analyzer
ddf6fe37 11159@item -fdump-analyzer
d77de738
ML
11160Dump internal details about what the analyzer is doing to
11161@file{@var{file}.analyzer.txt}.
4ace81b6 11162@option{-fdump-analyzer-stderr} overrides this option.
d77de738 11163
d77de738 11164@opindex fdump-analyzer-stderr
ddf6fe37 11165@item -fdump-analyzer-stderr
d77de738
ML
11166Dump internal details about what the analyzer is doing to stderr.
11167This option overrides @option{-fdump-analyzer}.
11168
d77de738 11169@opindex fdump-analyzer-callgraph
ddf6fe37 11170@item -fdump-analyzer-callgraph
d77de738
ML
11171Dump a representation of the call graph suitable for viewing with
11172GraphViz to @file{@var{file}.callgraph.dot}.
11173
d77de738 11174@opindex fdump-analyzer-exploded-graph
ddf6fe37 11175@item -fdump-analyzer-exploded-graph
d77de738
ML
11176Dump a representation of the ``exploded graph'' suitable for viewing with
11177GraphViz to @file{@var{file}.eg.dot}.
11178Nodes are color-coded based on state-machine states to emphasize
11179state changes.
11180
d77de738 11181@opindex dump-analyzer-exploded-nodes
ddf6fe37 11182@item -fdump-analyzer-exploded-nodes
d77de738
ML
11183Emit diagnostics showing where nodes in the ``exploded graph'' are
11184in relation to the program source.
11185
d77de738 11186@opindex dump-analyzer-exploded-nodes-2
ddf6fe37 11187@item -fdump-analyzer-exploded-nodes-2
d77de738
ML
11188Dump a textual representation of the ``exploded graph'' to
11189@file{@var{file}.eg.txt}.
11190
d77de738 11191@opindex dump-analyzer-exploded-nodes-3
ddf6fe37 11192@item -fdump-analyzer-exploded-nodes-3
d77de738
ML
11193Dump a textual representation of the ``exploded graph'' to
11194one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11195This is typically a large number of dump files.
11196
d77de738 11197@opindex fdump-analyzer-exploded-paths
ddf6fe37 11198@item -fdump-analyzer-exploded-paths
d77de738
ML
11199Dump a textual representation of the ``exploded path'' for each
11200diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11201
d77de738 11202@opindex dump-analyzer-feasibility
ddf6fe37 11203@item -fdump-analyzer-feasibility
d77de738
ML
11204Dump internal details about the analyzer's search for feasible paths.
11205The details are written in a form suitable for viewing with GraphViz
11206to filenames of the form @file{@var{file}.*.fg.dot},
11207@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11208
d77de738 11209@opindex fdump-analyzer-json
ddf6fe37 11210@item -fdump-analyzer-json
d77de738
ML
11211Dump a compressed JSON representation of analyzer internals to
11212@file{@var{file}.analyzer.json.gz}. The precise format is subject
11213to change.
11214
d77de738 11215@opindex fdump-analyzer-state-purge
ddf6fe37 11216@item -fdump-analyzer-state-purge
d77de738
ML
11217As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11218``supergraph'' suitable for viewing with GraphViz, but annotate the
11219graph with information on what state will be purged at each node.
11220The graph is written to @file{@var{file}.state-purge.dot}.
11221
d77de738 11222@opindex fdump-analyzer-supergraph
ddf6fe37 11223@item -fdump-analyzer-supergraph
d77de738
ML
11224Dump representations of the ``supergraph'' suitable for viewing with
11225GraphViz to @file{@var{file}.supergraph.dot} and to
11226@file{@var{file}.supergraph-eg.dot}. These show all of the
11227control flow graphs in the program, with interprocedural edges for
11228calls and returns. The second dump contains annotations showing nodes
11229in the ``exploded graph'' and diagnostics associated with them.
11230
d77de738 11231@opindex fdump-analyzer-untracked
ddf6fe37 11232@item -fdump-analyzer-untracked
d77de738
ML
11233Emit custom warnings with internal details intended for analyzer developers.
11234
11235@end table
11236
11237@node Debugging Options
11238@section Options for Debugging Your Program
11239@cindex options, debugging
11240@cindex debugging information options
11241
11242To tell GCC to emit extra information for use by a debugger, in almost
11243all cases you need only to add @option{-g} to your other options. Some debug
11244formats can co-exist (like DWARF with CTF) when each of them is enabled
11245explicitly by adding the respective command line option to your other options.
11246
11247GCC allows you to use @option{-g} with
11248@option{-O}. The shortcuts taken by optimized code may occasionally
11249be surprising: some variables you declared may not exist
11250at all; flow of control may briefly move where you did not expect it;
11251some statements may not be executed because they compute constant
11252results or their values are already at hand; some statements may
11253execute in different places because they have been moved out of loops.
11254Nevertheless it is possible to debug optimized output. This makes
11255it reasonable to use the optimizer for programs that might have bugs.
11256
11257If you are not using some other optimization option, consider
11258using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11259With no @option{-O} option at all, some compiler passes that collect
11260information useful for debugging do not run at all, so that
11261@option{-Og} may result in a better debugging experience.
11262
11263@table @gcctabopt
d77de738 11264@opindex g
ddf6fe37 11265@item -g
d77de738
ML
11266Produce debugging information in the operating system's native format
11267(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11268information.
11269
11270On most systems that use stabs format, @option{-g} enables use of extra
11271debugging information that only GDB can use; this extra information
11272makes debugging work better in GDB but probably makes other debuggers
11273crash or refuse to read the program. If you want to control for certain whether
11274to generate the extra information, use @option{-gvms} (see below).
11275
d77de738 11276@opindex ggdb
ddf6fe37 11277@item -ggdb
d77de738
ML
11278Produce debugging information for use by GDB@. This means to use the
11279most expressive format available (DWARF, stabs, or the native format
11280if neither of those are supported), including GDB extensions if at all
11281possible.
11282
ddf6fe37 11283@opindex gdwarf
d77de738
ML
11284@item -gdwarf
11285@itemx -gdwarf-@var{version}
d77de738
ML
11286Produce debugging information in DWARF format (if that is supported).
11287The value of @var{version} may be either 2, 3, 4 or 5; the default
11288version for most targets is 5 (with the exception of VxWorks, TPF and
11289Darwin/Mac OS X, which default to version 2, and AIX, which defaults
11290to version 4).
11291
11292Note that with DWARF Version 2, some ports require and always
11293use some non-conflicting DWARF 3 extensions in the unwind tables.
11294
11295Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11296for maximum benefit. Version 5 requires GDB 8.0 or higher.
11297
11298GCC no longer supports DWARF Version 1, which is substantially
11299different than Version 2 and later. For historical reasons, some
11300other DWARF-related options such as
11301@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11302in their names, but apply to all currently-supported versions of DWARF.
11303
d77de738 11304@opindex gbtf
ddf6fe37 11305@item -gbtf
d77de738
ML
11306Request BTF debug information. BTF is the default debugging format for the
11307eBPF target. On other targets, like x86, BTF debug information can be
11308generated along with DWARF debug information when both of the debug formats are
11309enabled explicitly via their respective command line options.
11310
ddf6fe37 11311@opindex gctf
d77de738
ML
11312@item -gctf
11313@itemx -gctf@var{level}
d77de738
ML
11314Request CTF debug information and use level to specify how much CTF debug
11315information should be produced. If @option{-gctf} is specified
11316without a value for level, the default level of CTF debug information is 2.
11317
11318CTF debug information can be generated along with DWARF debug information when
11319both of the debug formats are enabled explicitly via their respective command
11320line options.
11321
11322Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11323negates @option{-gctf}.
11324
11325Level 1 produces CTF information for tracebacks only. This includes callsite
11326information, but does not include type information.
11327
11328Level 2 produces type information for entities (functions, data objects etc.)
11329at file-scope or global-scope only.
11330
d77de738 11331@opindex gvms
ddf6fe37 11332@item -gvms
d77de738
ML
11333Produce debugging information in Alpha/VMS debug format (if that is
11334supported). This is the format used by DEBUG on Alpha/VMS systems.
11335
2f7e7bfa
MH
11336@item -gcodeview
11337@opindex gcodeview
11338Produce debugging information in CodeView debug format (if that is
11339supported). This is the format used by Microsoft Visual C++ on
11340Windows.
11341
d77de738
ML
11342@item -g@var{level}
11343@itemx -ggdb@var{level}
11344@itemx -gvms@var{level}
11345Request debugging information and also use @var{level} to specify how
11346much information. The default level is 2.
11347
11348Level 0 produces no debug information at all. Thus, @option{-g0} negates
11349@option{-g}.
11350
11351Level 1 produces minimal information, enough for making backtraces in
11352parts of the program that you don't plan to debug. This includes
11353descriptions of functions and external variables, and line number
11354tables, but no information about local variables.
11355
11356Level 3 includes extra information, such as all the macro definitions
11357present in the program. Some debuggers support macro expansion when
11358you use @option{-g3}.
11359
11360If you use multiple @option{-g} options, with or without level numbers,
11361the last such option is the one that is effective.
11362
11363@option{-gdwarf} does not accept a concatenated debug level, to avoid
11364confusion with @option{-gdwarf-@var{level}}.
11365Instead use an additional @option{-g@var{level}} option to change the
11366debug level for DWARF.
11367
d77de738
ML
11368@opindex feliminate-unused-debug-symbols
11369@opindex fno-eliminate-unused-debug-symbols
ddf6fe37 11370@item -fno-eliminate-unused-debug-symbols
d77de738
ML
11371By default, no debug information is produced for symbols that are not actually
11372used. Use this option if you want debug information for all symbols.
11373
d77de738 11374@opindex femit-class-debug-always
ddf6fe37 11375@item -femit-class-debug-always
d77de738
ML
11376Instead of emitting debugging information for a C++ class in only one
11377object file, emit it in all object files using the class. This option
11378should be used only with debuggers that are unable to handle the way GCC
11379normally emits debugging information for classes because using this
11380option increases the size of debugging information by as much as a
11381factor of two.
11382
d77de738
ML
11383@opindex fmerge-debug-strings
11384@opindex fno-merge-debug-strings
ddf6fe37 11385@item -fno-merge-debug-strings
d77de738
ML
11386Direct the linker to not merge together strings in the debugging
11387information that are identical in different object files. Merging is
11388not supported by all assemblers or linkers. Merging decreases the size
11389of the debug information in the output file at the cost of increasing
11390link processing time. Merging is enabled by default.
11391
d77de738 11392@opindex fdebug-prefix-map
ddf6fe37 11393@item -fdebug-prefix-map=@var{old}=@var{new}
d77de738
ML
11394When compiling files residing in directory @file{@var{old}}, record
11395debugging information describing them as if the files resided in
11396directory @file{@var{new}} instead. This can be used to replace a
11397build-time path with an install-time path in the debug info. It can
11398also be used to change an absolute path to a relative path by using
11399@file{.} for @var{new}. This can give more reproducible builds, which
11400are location independent, but may require an extra command to tell GDB
2eb0191a
JJ
11401where to find the source files. See also @option{-ffile-prefix-map}
11402and @option{-fcanon-prefix-map}.
d77de738 11403
d77de738 11404@opindex fvar-tracking
ddf6fe37 11405@item -fvar-tracking
d77de738
ML
11406Run variable tracking pass. It computes where variables are stored at each
11407position in code. Better debugging information is then generated
11408(if the debugging information format supports this information).
11409
11410It is enabled by default when compiling with optimization (@option{-Os},
11411@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11412the debug info format supports it.
11413
d77de738
ML
11414@opindex fvar-tracking-assignments
11415@opindex fno-var-tracking-assignments
ddf6fe37 11416@item -fvar-tracking-assignments
d77de738
ML
11417Annotate assignments to user variables early in the compilation and
11418attempt to carry the annotations over throughout the compilation all the
11419way to the end, in an attempt to improve debug information while
11420optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11421
11422It can be enabled even if var-tracking is disabled, in which case
11423annotations are created and maintained, but discarded at the end.
11424By default, this flag is enabled together with @option{-fvar-tracking},
11425except when selective scheduling is enabled.
11426
d77de738 11427@opindex gsplit-dwarf
ddf6fe37 11428@item -gsplit-dwarf
d77de738
ML
11429If DWARF debugging information is enabled, separate as much debugging
11430information as possible into a separate output file with the extension
11431@file{.dwo}. This option allows the build system to avoid linking files with
11432debug information. To be useful, this option requires a debugger capable of
11433reading @file{.dwo} files.
11434
d77de738
ML
11435@opindex gdwarf32
11436@opindex gdwarf64
ddf6fe37
AA
11437@item -gdwarf32
11438@itemx -gdwarf64
d77de738
ML
11439If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11440the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11441DWARF format. The default is target specific, on most targets it is
11442@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11443can't support more than 2GiB of debug information in any of the DWARF
11444debug information sections. The 64-bit DWARF format allows larger debug
11445information and might not be well supported by all consumers yet.
11446
d77de738 11447@opindex gdescribe-dies
ddf6fe37 11448@item -gdescribe-dies
d77de738
ML
11449Add description attributes to some DWARF DIEs that have no name attribute,
11450such as artificial variables, external references and call site
11451parameter DIEs.
11452
d77de738 11453@opindex gpubnames
ddf6fe37 11454@item -gpubnames
d77de738
ML
11455Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11456
d77de738 11457@opindex ggnu-pubnames
ddf6fe37 11458@item -ggnu-pubnames
d77de738
ML
11459Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11460suitable for conversion into a GDB@ index. This option is only useful
11461with a linker that can produce GDB@ index version 7.
11462
d77de738
ML
11463@opindex fdebug-types-section
11464@opindex fno-debug-types-section
ddf6fe37 11465@item -fdebug-types-section
d77de738
ML
11466When using DWARF Version 4 or higher, type DIEs can be put into
11467their own @code{.debug_types} section instead of making them part of the
11468@code{.debug_info} section. It is more efficient to put them in a separate
11469comdat section since the linker can then remove duplicates.
11470But not all DWARF consumers support @code{.debug_types} sections yet
11471and on some objects @code{.debug_types} produces larger instead of smaller
11472debugging information.
11473
d77de738
ML
11474@opindex grecord-gcc-switches
11475@opindex gno-record-gcc-switches
ddf6fe37
AA
11476@item -grecord-gcc-switches
11477@itemx -gno-record-gcc-switches
d77de738
ML
11478This switch causes the command-line options used to invoke the
11479compiler that may affect code generation to be appended to the
11480DW_AT_producer attribute in DWARF debugging information. The options
11481are concatenated with spaces separating them from each other and from
11482the compiler version.
11483It is enabled by default.
11484See also @option{-frecord-gcc-switches} for another
11485way of storing compiler options into the object file.
11486
d77de738 11487@opindex gstrict-dwarf
ddf6fe37 11488@item -gstrict-dwarf
d77de738
ML
11489Disallow using extensions of later DWARF standard version than selected
11490with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11491DWARF extensions from later standard versions is allowed.
11492
d77de738 11493@opindex gno-strict-dwarf
ddf6fe37 11494@item -gno-strict-dwarf
d77de738
ML
11495Allow using extensions of later DWARF standard version than selected with
11496@option{-gdwarf-@var{version}}.
11497
d77de738 11498@opindex gas-loc-support
ddf6fe37 11499@item -gas-loc-support
d77de738
ML
11500Inform the compiler that the assembler supports @code{.loc} directives.
11501It may then use them for the assembler to generate DWARF2+ line number
11502tables.
11503
11504This is generally desirable, because assembler-generated line-number
11505tables are a lot more compact than those the compiler can generate
11506itself.
11507
11508This option will be enabled by default if, at GCC configure time, the
11509assembler was found to support such directives.
11510
d77de738 11511@opindex gno-as-loc-support
ddf6fe37 11512@item -gno-as-loc-support
d77de738
ML
11513Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11514line number tables are to be generated.
11515
d77de738 11516@opindex gas-locview-support
ddf6fe37 11517@item -gas-locview-support
d77de738
ML
11518Inform the compiler that the assembler supports @code{view} assignment
11519and reset assertion checking in @code{.loc} directives.
11520
11521This option will be enabled by default if, at GCC configure time, the
11522assembler was found to support them.
11523
11524@item -gno-as-locview-support
11525Force GCC to assign view numbers internally, if
11526@option{-gvariable-location-views} are explicitly requested.
11527
d77de738
ML
11528@opindex gcolumn-info
11529@opindex gno-column-info
ddf6fe37
AA
11530@item -gcolumn-info
11531@itemx -gno-column-info
d77de738
ML
11532Emit location column information into DWARF debugging information, rather
11533than just file and line.
11534This option is enabled by default.
11535
d77de738
ML
11536@opindex gstatement-frontiers
11537@opindex gno-statement-frontiers
ddf6fe37
AA
11538@item -gstatement-frontiers
11539@itemx -gno-statement-frontiers
d77de738
ML
11540This option causes GCC to create markers in the internal representation
11541at the beginning of statements, and to keep them roughly in place
11542throughout compilation, using them to guide the output of @code{is_stmt}
11543markers in the line number table. This is enabled by default when
11544compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11545@dots{}), and outputting DWARF 2 debug information at the normal level.
11546
d77de738
ML
11547@opindex gvariable-location-views
11548@opindex gvariable-location-views=incompat5
11549@opindex gno-variable-location-views
ddf6fe37
AA
11550@item -gvariable-location-views
11551@itemx -gvariable-location-views=incompat5
11552@itemx -gno-variable-location-views
d77de738
ML
11553Augment variable location lists with progressive view numbers implied
11554from the line number table. This enables debug information consumers to
11555inspect state at certain points of the program, even if no instructions
11556associated with the corresponding source locations are present at that
11557point. If the assembler lacks support for view numbers in line number
11558tables, this will cause the compiler to emit the line number table,
11559which generally makes them somewhat less compact. The augmented line
11560number tables and location lists are fully backward-compatible, so they
11561can be consumed by debug information consumers that are not aware of
11562these augmentations, but they won't derive any benefit from them either.
11563
11564This is enabled by default when outputting DWARF 2 debug information at
11565the normal level, as long as there is assembler support,
11566@option{-fvar-tracking-assignments} is enabled and
11567@option{-gstrict-dwarf} is not. When assembler support is not
11568available, this may still be enabled, but it will force GCC to output
11569internal line number tables, and if
11570@option{-ginternal-reset-location-views} is not enabled, that will most
11571certainly lead to silently mismatching location views.
11572
11573There is a proposed representation for view numbers that is not backward
11574compatible with the location list format introduced in DWARF 5, that can
11575be enabled with @option{-gvariable-location-views=incompat5}. This
11576option may be removed in the future, is only provided as a reference
11577implementation of the proposed representation. Debug information
11578consumers are not expected to support this extended format, and they
11579would be rendered unable to decode location lists using it.
11580
d77de738
ML
11581@opindex ginternal-reset-location-views
11582@opindex gno-internal-reset-location-views
ddf6fe37
AA
11583@item -ginternal-reset-location-views
11584@itemx -gno-internal-reset-location-views
d77de738
ML
11585Attempt to determine location views that can be omitted from location
11586view lists. This requires the compiler to have very accurate insn
11587length estimates, which isn't always the case, and it may cause
11588incorrect view lists to be generated silently when using an assembler
11589that does not support location view lists. The GNU assembler will flag
11590any such error as a @code{view number mismatch}. This is only enabled
11591on ports that define a reliable estimation function.
11592
d77de738
ML
11593@opindex ginline-points
11594@opindex gno-inline-points
ddf6fe37
AA
11595@item -ginline-points
11596@itemx -gno-inline-points
d77de738
ML
11597Generate extended debug information for inlined functions. Location
11598view tracking markers are inserted at inlined entry points, so that
11599address and view numbers can be computed and output in debug
11600information. This can be enabled independently of location views, in
11601which case the view numbers won't be output, but it can only be enabled
11602along with statement frontiers, and it is only enabled by default if
11603location views are enabled.
11604
d77de738 11605@opindex gz
ddf6fe37 11606@item -gz@r{[}=@var{type}@r{]}
d77de738
ML
11607Produce compressed debug sections in DWARF format, if that is supported.
11608If @var{type} is not given, the default type depends on the capabilities
11609of the assembler and linker used. @var{type} may be one of
11610@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11611compression in ELF gABI format). If the linker doesn't support writing
11612compressed debug sections, the option is rejected. Otherwise, if the
11613assembler does not support them, @option{-gz} is silently ignored when
11614producing object files.
11615
d77de738 11616@opindex femit-struct-debug-baseonly
ddf6fe37 11617@item -femit-struct-debug-baseonly
d77de738
ML
11618Emit debug information for struct-like types
11619only when the base name of the compilation source file
11620matches the base name of file in which the struct is defined.
11621
11622This option substantially reduces the size of debugging information,
11623but at significant potential loss in type information to the debugger.
11624See @option{-femit-struct-debug-reduced} for a less aggressive option.
11625See @option{-femit-struct-debug-detailed} for more detailed control.
11626
11627This option works only with DWARF debug output.
11628
d77de738 11629@opindex femit-struct-debug-reduced
ddf6fe37 11630@item -femit-struct-debug-reduced
d77de738
ML
11631Emit debug information for struct-like types
11632only when the base name of the compilation source file
11633matches the base name of file in which the type is defined,
11634unless the struct is a template or defined in a system header.
11635
11636This option significantly reduces the size of debugging information,
11637with some potential loss in type information to the debugger.
11638See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11639See @option{-femit-struct-debug-detailed} for more detailed control.
11640
11641This option works only with DWARF debug output.
11642
d77de738 11643@opindex femit-struct-debug-detailed
ddf6fe37 11644@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
d77de738
ML
11645Specify the struct-like types
11646for which the compiler generates debug information.
11647The intent is to reduce duplicate struct debug information
11648between different object files within the same program.
11649
11650This option is a detailed version of
11651@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11652which serves for most needs.
11653
11654A specification has the syntax@*
11655[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11656
11657The optional first word limits the specification to
11658structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11659A struct type is used directly when it is the type of a variable, member.
11660Indirect uses arise through pointers to structs.
11661That is, when use of an incomplete struct is valid, the use is indirect.
11662An example is
11663@samp{struct one direct; struct two * indirect;}.
11664
11665The optional second word limits the specification to
11666ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11667Generic structs are a bit complicated to explain.
11668For C++, these are non-explicit specializations of template classes,
11669or non-template classes within the above.
11670Other programming languages have generics,
11671but @option{-femit-struct-debug-detailed} does not yet implement them.
11672
11673The third word specifies the source files for those
11674structs for which the compiler should emit debug information.
11675The values @samp{none} and @samp{any} have the normal meaning.
11676The value @samp{base} means that
11677the base of name of the file in which the type declaration appears
11678must match the base of the name of the main compilation file.
11679In practice, this means that when compiling @file{foo.c}, debug information
11680is generated for types declared in that file and @file{foo.h},
11681but not other header files.
11682The value @samp{sys} means those types satisfying @samp{base}
11683or declared in system or compiler headers.
11684
11685You may need to experiment to determine the best settings for your application.
11686
11687The default is @option{-femit-struct-debug-detailed=all}.
11688
11689This option works only with DWARF debug output.
11690
d77de738
ML
11691@opindex fdwarf2-cfi-asm
11692@opindex fno-dwarf2-cfi-asm
ddf6fe37 11693@item -fno-dwarf2-cfi-asm
d77de738
ML
11694Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11695instead of using GAS @code{.cfi_*} directives.
11696
d77de738
ML
11697@opindex feliminate-unused-debug-types
11698@opindex fno-eliminate-unused-debug-types
ddf6fe37 11699@item -fno-eliminate-unused-debug-types
d77de738
ML
11700Normally, when producing DWARF output, GCC avoids producing debug symbol
11701output for types that are nowhere used in the source file being compiled.
11702Sometimes it is useful to have GCC emit debugging
11703information for all types declared in a compilation
11704unit, regardless of whether or not they are actually used
11705in that compilation unit, for example
11706if, in the debugger, you want to cast a value to a type that is
11707not actually used in your program (but is declared). More often,
11708however, this results in a significant amount of wasted space.
11709@end table
11710
11711@node Optimize Options
11712@section Options That Control Optimization
11713@cindex optimize options
11714@cindex options, optimization
11715
11716These options control various sorts of optimizations.
11717
11718Without any optimization option, the compiler's goal is to reduce the
11719cost of compilation and to make debugging produce the expected
11720results. Statements are independent: if you stop the program with a
11721breakpoint between statements, you can then assign a new value to any
11722variable or change the program counter to any other statement in the
11723function and get exactly the results you expect from the source
11724code.
11725
11726Turning on optimization flags makes the compiler attempt to improve
11727the performance and/or code size at the expense of compilation time
11728and possibly the ability to debug the program.
11729
11730The compiler performs optimization based on the knowledge it has of the
11731program. Compiling multiple files at once to a single output file mode allows
11732the compiler to use information gained from all of the files when compiling
11733each of them.
11734
11735Not all optimizations are controlled directly by a flag. Only
11736optimizations that have a flag are listed in this section.
11737
11738Most optimizations are completely disabled at @option{-O0} or if an
11739@option{-O} level is not set on the command line, even if individual
11740optimization flags are specified. Similarly, @option{-Og} suppresses
11741many optimization passes.
11742
11743Depending on the target and how GCC was configured, a slightly different
11744set of optimizations may be enabled at each @option{-O} level than
11745those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11746to find out the exact set of optimizations that are enabled at each level.
11747@xref{Overall Options}, for examples.
11748
11749@table @gcctabopt
d77de738
ML
11750@opindex O
11751@opindex O1
ddf6fe37
AA
11752@item -O
11753@itemx -O1
d77de738
ML
11754Optimize. Optimizing compilation takes somewhat more time, and a lot
11755more memory for a large function.
11756
11757With @option{-O}, the compiler tries to reduce code size and execution
11758time, without performing any optimizations that take a great deal of
11759compilation time.
11760
11761@c Note that in addition to the default_options_table list in opts.cc,
11762@c several optimization flags default to true but control optimization
11763@c passes that are explicitly disabled at -O0.
11764
11765@option{-O} turns on the following optimization flags:
11766
11767@c Please keep the following list alphabetized.
43b72ede
AA
11768@gccoptlist{-fauto-inc-dec
11769-fbranch-count-reg
11770-fcombine-stack-adjustments
11771-fcompare-elim
11772-fcprop-registers
11773-fdce
11774-fdefer-pop
11775-fdelayed-branch
11776-fdse
11777-fforward-propagate
11778-fguess-branch-probability
11779-fif-conversion
11780-fif-conversion2
11781-finline-functions-called-once
11782-fipa-modref
11783-fipa-profile
11784-fipa-pure-const
11785-fipa-reference
11786-fipa-reference-addressable
11787-fmerge-constants
11788-fmove-loop-invariants
11789-fmove-loop-stores
11790-fomit-frame-pointer
11791-freorder-blocks
11792-fshrink-wrap
11793-fshrink-wrap-separate
11794-fsplit-wide-types
11795-fssa-backprop
11796-fssa-phiopt
11797-ftree-bit-ccp
11798-ftree-ccp
11799-ftree-ch
11800-ftree-coalesce-vars
11801-ftree-copy-prop
11802-ftree-dce
11803-ftree-dominator-opts
11804-ftree-dse
11805-ftree-forwprop
11806-ftree-fre
11807-ftree-phiprop
11808-ftree-pta
11809-ftree-scev-cprop
11810-ftree-sink
11811-ftree-slsr
11812-ftree-sra
11813-ftree-ter
d77de738
ML
11814-funit-at-a-time}
11815
d77de738 11816@opindex O2
ddf6fe37 11817@item -O2
d77de738
ML
11818Optimize even more. GCC performs nearly all supported optimizations
11819that do not involve a space-speed tradeoff.
11820As compared to @option{-O}, this option increases both compilation time
11821and the performance of the generated code.
11822
11823@option{-O2} turns on all optimization flags specified by @option{-O1}. It
11824also turns on the following optimization flags:
11825
11826@c Please keep the following list alphabetized!
43b72ede
AA
11827@gccoptlist{-falign-functions -falign-jumps
11828-falign-labels -falign-loops
11829-fcaller-saves
11830-fcode-hoisting
11831-fcrossjumping
11832-fcse-follow-jumps -fcse-skip-blocks
11833-fdelete-null-pointer-checks
11834-fdevirtualize -fdevirtualize-speculatively
11835-fexpensive-optimizations
11836-ffinite-loops
11837-fgcse -fgcse-lm
11838-fhoist-adjacent-loads
11839-finline-functions
11840-finline-small-functions
11841-findirect-inlining
11842-fipa-bit-cp -fipa-cp -fipa-icf
11843-fipa-ra -fipa-sra -fipa-vrp
11844-fisolate-erroneous-paths-dereference
11845-flra-remat
11846-foptimize-sibling-calls
11847-foptimize-strlen
11848-fpartial-inlining
11849-fpeephole2
11850-freorder-blocks-algorithm=stc
11851-freorder-blocks-and-partition -freorder-functions
11852-frerun-cse-after-loop
11853-fschedule-insns -fschedule-insns2
11854-fsched-interblock -fsched-spec
11855-fstore-merging
11856-fstrict-aliasing
11857-fthread-jumps
11858-ftree-builtin-call-dce
11859-ftree-loop-vectorize
11860-ftree-pre
11861-ftree-slp-vectorize
11862-ftree-switch-conversion -ftree-tail-merge
11863-ftree-vrp
d77de738
ML
11864-fvect-cost-model=very-cheap}
11865
11866Please note the warning under @option{-fgcse} about
11867invoking @option{-O2} on programs that use computed gotos.
11868
d77de738 11869@opindex O3
ddf6fe37 11870@item -O3
d77de738
ML
11871Optimize yet more. @option{-O3} turns on all optimizations specified
11872by @option{-O2} and also turns on the following optimization flags:
11873
11874@c Please keep the following list alphabetized!
43b72ede 11875@gccoptlist{-fgcse-after-reload
d77de738 11876-fipa-cp-clone
43b72ede
AA
11877-floop-interchange
11878-floop-unroll-and-jam
11879-fpeel-loops
11880-fpredictive-commoning
11881-fsplit-loops
11882-fsplit-paths
11883-ftree-loop-distribution
11884-ftree-partial-pre
11885-funswitch-loops
11886-fvect-cost-model=dynamic
d77de738
ML
11887-fversion-loops-for-strides}
11888
d77de738 11889@opindex O0
ddf6fe37 11890@item -O0
d77de738
ML
11891Reduce compilation time and make debugging produce the expected
11892results. This is the default.
11893
d77de738 11894@opindex Os
ddf6fe37 11895@item -Os
d77de738
ML
11896Optimize for size. @option{-Os} enables all @option{-O2} optimizations
11897except those that often increase code size:
11898
43b72ede
AA
11899@gccoptlist{-falign-functions -falign-jumps
11900-falign-labels -falign-loops
d77de738
ML
11901-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
11902
11903It also enables @option{-finline-functions}, causes the compiler to tune for
11904code size rather than execution speed, and performs further optimizations
11905designed to reduce code size.
11906
d77de738 11907@opindex Ofast
ddf6fe37 11908@item -Ofast
d77de738
ML
11909Disregard strict standards compliance. @option{-Ofast} enables all
11910@option{-O3} optimizations. It also enables optimizations that are not
11911valid for all standard-compliant programs.
11912It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
11913and the Fortran-specific @option{-fstack-arrays}, unless
11914@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
11915It turns off @option{-fsemantic-interposition}.
11916
d77de738 11917@opindex Og
ddf6fe37 11918@item -Og
d77de738
ML
11919Optimize debugging experience. @option{-Og} should be the optimization
11920level of choice for the standard edit-compile-debug cycle, offering
11921a reasonable level of optimization while maintaining fast compilation
11922and a good debugging experience. It is a better choice than @option{-O0}
11923for producing debuggable code because some compiler passes
11924that collect debug information are disabled at @option{-O0}.
11925
11926Like @option{-O0}, @option{-Og} completely disables a number of
11927optimization passes so that individual options controlling them have
11928no effect. Otherwise @option{-Og} enables all @option{-O1}
11929optimization flags except for those that may interfere with debugging:
11930
43b72ede
AA
11931@gccoptlist{-fbranch-count-reg -fdelayed-branch
11932-fdse -fif-conversion -fif-conversion2
11933-finline-functions-called-once
11934-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt
d77de738
ML
11935-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
11936
d77de738 11937@opindex Oz
ddf6fe37 11938@item -Oz
d77de738
ML
11939Optimize aggressively for size rather than speed. This may increase
11940the number of instructions executed if those instructions require
11941fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
11942including enabling most @option{-O2} optimizations.
11943
11944@end table
11945
11946If you use multiple @option{-O} options, with or without level numbers,
11947the last such option is the one that is effective.
11948
11949Options of the form @option{-f@var{flag}} specify machine-independent
11950flags. Most flags have both positive and negative forms; the negative
11951form of @option{-ffoo} is @option{-fno-foo}. In the table
11952below, only one of the forms is listed---the one you typically
11953use. You can figure out the other form by either removing @samp{no-}
11954or adding it.
11955
11956The following options control specific optimizations. They are either
11957activated by @option{-O} options or are related to ones that are. You
11958can use the following flags in the rare cases when ``fine-tuning'' of
11959optimizations to be performed is desired.
11960
11961@table @gcctabopt
d77de738
ML
11962@opindex fno-defer-pop
11963@opindex fdefer-pop
ddf6fe37 11964@item -fno-defer-pop
d77de738
ML
11965For machines that must pop arguments after a function call, always pop
11966the arguments as soon as each function returns.
11967At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
11968this allows the compiler to let arguments accumulate on the stack for several
11969function calls and pop them all at once.
11970
d77de738 11971@opindex fforward-propagate
ddf6fe37 11972@item -fforward-propagate
d77de738
ML
11973Perform a forward propagation pass on RTL@. The pass tries to combine two
11974instructions and checks if the result can be simplified. If loop unrolling
11975is active, two passes are performed and the second is scheduled after
11976loop unrolling.
11977
11978This option is enabled by default at optimization levels @option{-O1},
11979@option{-O2}, @option{-O3}, @option{-Os}.
11980
d77de738 11981@opindex ffp-contract
ddf6fe37 11982@item -ffp-contract=@var{style}
d77de738
ML
11983@option{-ffp-contract=off} disables floating-point expression contraction.
11984@option{-ffp-contract=fast} enables floating-point expression contraction
11985such as forming of fused multiply-add operations if the target has
11986native support for them.
11987@option{-ffp-contract=on} enables floating-point expression contraction
11988if allowed by the language standard. This is currently not implemented
11989and treated equal to @option{-ffp-contract=off}.
11990
11991The default is @option{-ffp-contract=fast}.
11992
d77de738 11993@opindex fomit-frame-pointer
ddf6fe37 11994@item -fomit-frame-pointer
d77de738
ML
11995Omit the frame pointer in functions that don't need one. This avoids the
11996instructions to save, set up and restore the frame pointer; on many targets
11997it also makes an extra register available.
11998
11999On some targets this flag has no effect because the standard calling sequence
12000always uses a frame pointer, so it cannot be omitted.
12001
12002Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
12003is used in all functions. Several targets always omit the frame pointer in
12004leaf functions.
12005
12006Enabled by default at @option{-O1} and higher.
12007
d77de738 12008@opindex foptimize-sibling-calls
ddf6fe37 12009@item -foptimize-sibling-calls
d77de738
ML
12010Optimize sibling and tail recursive calls.
12011
12012Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12013
d77de738 12014@opindex foptimize-strlen
ddf6fe37 12015@item -foptimize-strlen
d77de738
ML
12016Optimize various standard C string functions (e.g.@: @code{strlen},
12017@code{strchr} or @code{strcpy}) and
12018their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
12019
12020Enabled at levels @option{-O2}, @option{-O3}.
12021
d77de738
ML
12022@opindex fno-inline
12023@opindex finline
ddf6fe37 12024@item -fno-inline
d77de738
ML
12025Do not expand any functions inline apart from those marked with
12026the @code{always_inline} attribute. This is the default when not
12027optimizing.
12028
12029Single functions can be exempted from inlining by marking them
12030with the @code{noinline} attribute.
12031
d77de738 12032@opindex finline-small-functions
ddf6fe37 12033@item -finline-small-functions
d77de738
ML
12034Integrate functions into their callers when their body is smaller than expected
12035function call code (so overall size of program gets smaller). The compiler
12036heuristically decides which functions are simple enough to be worth integrating
12037in this way. This inlining applies to all functions, even those not declared
12038inline.
12039
12040Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12041
d77de738 12042@opindex findirect-inlining
ddf6fe37 12043@item -findirect-inlining
d77de738
ML
12044Inline also indirect calls that are discovered to be known at compile
12045time thanks to previous inlining. This option has any effect only
12046when inlining itself is turned on by the @option{-finline-functions}
12047or @option{-finline-small-functions} options.
12048
12049Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12050
d77de738 12051@opindex finline-functions
ddf6fe37 12052@item -finline-functions
d77de738
ML
12053Consider all functions for inlining, even if they are not declared inline.
12054The compiler heuristically decides which functions are worth integrating
12055in this way.
12056
12057If all calls to a given function are integrated, and the function is
12058declared @code{static}, then the function is normally not output as
12059assembler code in its own right.
12060
12061Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12062by @option{-fprofile-use} and @option{-fauto-profile}.
12063
d77de738 12064@opindex finline-functions-called-once
ddf6fe37 12065@item -finline-functions-called-once
d77de738
ML
12066Consider all @code{static} functions called once for inlining into their
12067caller even if they are not marked @code{inline}. If a call to a given
12068function is integrated, then the function is not output as assembler code
12069in its own right.
12070
12071Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12072but not @option{-Og}.
12073
d77de738 12074@opindex fearly-inlining
ddf6fe37 12075@item -fearly-inlining
d77de738
ML
12076Inline functions marked by @code{always_inline} and functions whose body seems
12077smaller than the function call overhead early before doing
12078@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12079makes profiling significantly cheaper and usually inlining faster on programs
12080having large chains of nested wrapper functions.
12081
12082Enabled by default.
12083
d77de738 12084@opindex fipa-sra
ddf6fe37 12085@item -fipa-sra
d77de738
ML
12086Perform interprocedural scalar replacement of aggregates, removal of
12087unused parameters and replacement of parameters passed by reference
12088by parameters passed by value.
12089
12090Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12091
d77de738 12092@opindex finline-limit
ddf6fe37 12093@item -finline-limit=@var{n}
d77de738
ML
12094By default, GCC limits the size of functions that can be inlined. This flag
12095allows coarse control of this limit. @var{n} is the size of functions that
12096can be inlined in number of pseudo instructions.
12097
12098Inlining is actually controlled by a number of parameters, which may be
12099specified individually by using @option{--param @var{name}=@var{value}}.
12100The @option{-finline-limit=@var{n}} option sets some of these parameters
12101as follows:
12102
12103@table @gcctabopt
12104@item max-inline-insns-single
12105is set to @var{n}/2.
12106@item max-inline-insns-auto
12107is set to @var{n}/2.
12108@end table
12109
12110See below for a documentation of the individual
12111parameters controlling inlining and for the defaults of these parameters.
12112
12113@emph{Note:} there may be no value to @option{-finline-limit} that results
12114in default behavior.
12115
12116@emph{Note:} pseudo instruction represents, in this particular context, an
12117abstract measurement of function's size. In no way does it represent a count
12118of assembly instructions and as such its exact meaning might change from one
12119release to an another.
12120
d77de738
ML
12121@opindex fno-keep-inline-dllexport
12122@opindex fkeep-inline-dllexport
ddf6fe37 12123@item -fno-keep-inline-dllexport
d77de738
ML
12124This is a more fine-grained version of @option{-fkeep-inline-functions},
12125which applies only to functions that are declared using the @code{dllexport}
12126attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12127Functions}.
12128
d77de738 12129@opindex fkeep-inline-functions
ddf6fe37 12130@item -fkeep-inline-functions
d77de738
ML
12131In C, emit @code{static} functions that are declared @code{inline}
12132into the object file, even if the function has been inlined into all
12133of its callers. This switch does not affect functions using the
12134@code{extern inline} extension in GNU C90@. In C++, emit any and all
12135inline functions into the object file.
12136
d77de738 12137@opindex fkeep-static-functions
ddf6fe37 12138@item -fkeep-static-functions
d77de738
ML
12139Emit @code{static} functions into the object file, even if the function
12140is never used.
12141
d77de738 12142@opindex fkeep-static-consts
ddf6fe37 12143@item -fkeep-static-consts
d77de738
ML
12144Emit variables declared @code{static const} when optimization isn't turned
12145on, even if the variables aren't referenced.
12146
12147GCC enables this option by default. If you want to force the compiler to
12148check if a variable is referenced, regardless of whether or not
12149optimization is turned on, use the @option{-fno-keep-static-consts} option.
12150
d77de738 12151@opindex fmerge-constants
ddf6fe37 12152@item -fmerge-constants
d77de738
ML
12153Attempt to merge identical constants (string constants and floating-point
12154constants) across compilation units.
12155
12156This option is the default for optimized compilation if the assembler and
12157linker support it. Use @option{-fno-merge-constants} to inhibit this
12158behavior.
12159
12160Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12161
d77de738 12162@opindex fmerge-all-constants
ddf6fe37 12163@item -fmerge-all-constants
d77de738
ML
12164Attempt to merge identical constants and identical variables.
12165
12166This option implies @option{-fmerge-constants}. In addition to
12167@option{-fmerge-constants} this considers e.g.@: even constant initialized
12168arrays or initialized constant variables with integral or floating-point
12169types. Languages like C or C++ require each variable, including multiple
12170instances of the same variable in recursive calls, to have distinct locations,
12171so using this option results in non-conforming
12172behavior.
12173
d77de738 12174@opindex fmodulo-sched
ddf6fe37 12175@item -fmodulo-sched
d77de738
ML
12176Perform swing modulo scheduling immediately before the first scheduling
12177pass. This pass looks at innermost loops and reorders their
12178instructions by overlapping different iterations.
12179
d77de738 12180@opindex fmodulo-sched-allow-regmoves
ddf6fe37 12181@item -fmodulo-sched-allow-regmoves
d77de738
ML
12182Perform more aggressive SMS-based modulo scheduling with register moves
12183allowed. By setting this flag certain anti-dependences edges are
12184deleted, which triggers the generation of reg-moves based on the
12185life-range analysis. This option is effective only with
12186@option{-fmodulo-sched} enabled.
12187
d77de738
ML
12188@opindex fno-branch-count-reg
12189@opindex fbranch-count-reg
ddf6fe37 12190@item -fno-branch-count-reg
d77de738
ML
12191Disable the optimization pass that scans for opportunities to use
12192``decrement and branch'' instructions on a count register instead of
12193instruction sequences that decrement a register, compare it against zero, and
12194then branch based upon the result. This option is only meaningful on
12195architectures that support such instructions, which include x86, PowerPC,
12196IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12197doesn't remove the decrement and branch instructions from the generated
12198instruction stream introduced by other optimization passes.
12199
12200The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12201except for @option{-Og}.
12202
d77de738
ML
12203@opindex fno-function-cse
12204@opindex ffunction-cse
ddf6fe37 12205@item -fno-function-cse
d77de738
ML
12206Do not put function addresses in registers; make each instruction that
12207calls a constant function contain the function's address explicitly.
12208
12209This option results in less efficient code, but some strange hacks
12210that alter the assembler output may be confused by the optimizations
12211performed when this option is not used.
12212
12213The default is @option{-ffunction-cse}
12214
d77de738
ML
12215@opindex fno-zero-initialized-in-bss
12216@opindex fzero-initialized-in-bss
ddf6fe37 12217@item -fno-zero-initialized-in-bss
d77de738
ML
12218If the target supports a BSS section, GCC by default puts variables that
12219are initialized to zero into BSS@. This can save space in the resulting
12220code.
12221
12222This option turns off this behavior because some programs explicitly
12223rely on variables going to the data section---e.g., so that the
12224resulting executable can find the beginning of that section and/or make
12225assumptions based on that.
12226
12227The default is @option{-fzero-initialized-in-bss}.
12228
d77de738 12229@opindex fthread-jumps
ddf6fe37 12230@item -fthread-jumps
d77de738
ML
12231Perform optimizations that check to see if a jump branches to a
12232location where another comparison subsumed by the first is found. If
12233so, the first branch is redirected to either the destination of the
12234second branch or a point immediately following it, depending on whether
12235the condition is known to be true or false.
12236
12237Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12238
d77de738 12239@opindex fsplit-wide-types
ddf6fe37 12240@item -fsplit-wide-types
d77de738
ML
12241When using a type that occupies multiple registers, such as @code{long
12242long} on a 32-bit system, split the registers apart and allocate them
12243independently. This normally generates better code for those types,
12244but may make debugging more difficult.
12245
12246Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12247@option{-Os}.
12248
d77de738 12249@opindex fsplit-wide-types-early
ddf6fe37 12250@item -fsplit-wide-types-early
d77de738
ML
12251Fully split wide types early, instead of very late.
12252This option has no effect unless @option{-fsplit-wide-types} is turned on.
12253
12254This is the default on some targets.
12255
d77de738 12256@opindex fcse-follow-jumps
ddf6fe37 12257@item -fcse-follow-jumps
d77de738
ML
12258In common subexpression elimination (CSE), scan through jump instructions
12259when the target of the jump is not reached by any other path. For
12260example, when CSE encounters an @code{if} statement with an
12261@code{else} clause, CSE follows the jump when the condition
12262tested is false.
12263
12264Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12265
d77de738 12266@opindex fcse-skip-blocks
ddf6fe37 12267@item -fcse-skip-blocks
d77de738
ML
12268This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12269follow jumps that conditionally skip over blocks. When CSE
12270encounters a simple @code{if} statement with no else clause,
12271@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12272body of the @code{if}.
12273
12274Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12275
d77de738 12276@opindex frerun-cse-after-loop
ddf6fe37 12277@item -frerun-cse-after-loop
d77de738
ML
12278Re-run common subexpression elimination after loop optimizations are
12279performed.
12280
12281Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12282
d77de738 12283@opindex fgcse
ddf6fe37 12284@item -fgcse
d77de738
ML
12285Perform a global common subexpression elimination pass.
12286This pass also performs global constant and copy propagation.
12287
12288@emph{Note:} When compiling a program using computed gotos, a GCC
12289extension, you may get better run-time performance if you disable
12290the global common subexpression elimination pass by adding
12291@option{-fno-gcse} to the command line.
12292
12293Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12294
d77de738 12295@opindex fgcse-lm
ddf6fe37 12296@item -fgcse-lm
d77de738
ML
12297When @option{-fgcse-lm} is enabled, global common subexpression elimination
12298attempts to move loads that are only killed by stores into themselves. This
12299allows a loop containing a load/store sequence to be changed to a load outside
12300the loop, and a copy/store within the loop.
12301
12302Enabled by default when @option{-fgcse} is enabled.
12303
d77de738 12304@opindex fgcse-sm
ddf6fe37 12305@item -fgcse-sm
d77de738
ML
12306When @option{-fgcse-sm} is enabled, a store motion pass is run after
12307global common subexpression elimination. This pass attempts to move
12308stores out of loops. When used in conjunction with @option{-fgcse-lm},
12309loops containing a load/store sequence can be changed to a load before
12310the loop and a store after the loop.
12311
12312Not enabled at any optimization level.
12313
d77de738 12314@opindex fgcse-las
ddf6fe37 12315@item -fgcse-las
d77de738
ML
12316When @option{-fgcse-las} is enabled, the global common subexpression
12317elimination pass eliminates redundant loads that come after stores to the
12318same memory location (both partial and full redundancies).
12319
12320Not enabled at any optimization level.
12321
d77de738 12322@opindex fgcse-after-reload
ddf6fe37 12323@item -fgcse-after-reload
d77de738
ML
12324When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12325pass is performed after reload. The purpose of this pass is to clean up
12326redundant spilling.
12327
12328Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12329
d77de738 12330@opindex faggressive-loop-optimizations
ddf6fe37 12331@item -faggressive-loop-optimizations
d77de738
ML
12332This option tells the loop optimizer to use language constraints to
12333derive bounds for the number of iterations of a loop. This assumes that
12334loop code does not invoke undefined behavior by for example causing signed
12335integer overflows or out-of-bound array accesses. The bounds for the
12336number of iterations of a loop are used to guide loop unrolling and peeling
12337and loop exit test optimizations.
12338This option is enabled by default.
12339
d77de738 12340@opindex funconstrained-commons
ddf6fe37 12341@item -funconstrained-commons
d77de738
ML
12342This option tells the compiler that variables declared in common blocks
12343(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12344prevents certain optimizations that depend on knowing the array bounds.
12345
d77de738 12346@opindex fcrossjumping
ddf6fe37 12347@item -fcrossjumping
d77de738
ML
12348Perform cross-jumping transformation.
12349This transformation unifies equivalent code and saves code size. The
12350resulting code may or may not perform better than without cross-jumping.
12351
12352Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12353
d77de738 12354@opindex fauto-inc-dec
ddf6fe37 12355@item -fauto-inc-dec
d77de738
ML
12356Combine increments or decrements of addresses with memory accesses.
12357This pass is always skipped on architectures that do not have
12358instructions to support this. Enabled by default at @option{-O1} and
12359higher on architectures that support this.
12360
d77de738 12361@opindex fdce
ddf6fe37 12362@item -fdce
d77de738
ML
12363Perform dead code elimination (DCE) on RTL@.
12364Enabled by default at @option{-O1} and higher.
12365
d77de738 12366@opindex fdse
ddf6fe37 12367@item -fdse
d77de738
ML
12368Perform dead store elimination (DSE) on RTL@.
12369Enabled by default at @option{-O1} and higher.
12370
d77de738 12371@opindex fif-conversion
ddf6fe37 12372@item -fif-conversion
d77de738
ML
12373Attempt to transform conditional jumps into branch-less equivalents. This
12374includes use of conditional moves, min, max, set flags and abs instructions, and
12375some tricks doable by standard arithmetics. The use of conditional execution
12376on chips where it is available is controlled by @option{-fif-conversion2}.
12377
12378Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12379not with @option{-Og}.
12380
d77de738 12381@opindex fif-conversion2
ddf6fe37 12382@item -fif-conversion2
d77de738
ML
12383Use conditional execution (where available) to transform conditional jumps into
12384branch-less equivalents.
12385
12386Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12387not with @option{-Og}.
12388
d77de738 12389@opindex fdeclone-ctor-dtor
ddf6fe37 12390@item -fdeclone-ctor-dtor
d77de738
ML
12391The C++ ABI requires multiple entry points for constructors and
12392destructors: one for a base subobject, one for a complete object, and
12393one for a virtual destructor that calls operator delete afterwards.
12394For a hierarchy with virtual bases, the base and complete variants are
12395clones, which means two copies of the function. With this option, the
12396base and complete variants are changed to be thunks that call a common
12397implementation.
12398
12399Enabled by @option{-Os}.
12400
d77de738 12401@opindex fdelete-null-pointer-checks
ddf6fe37 12402@item -fdelete-null-pointer-checks
d77de738
ML
12403Assume that programs cannot safely dereference null pointers, and that
12404no code or data element resides at address zero.
12405This option enables simple constant
12406folding optimizations at all optimization levels. In addition, other
12407optimization passes in GCC use this flag to control global dataflow
12408analyses that eliminate useless checks for null pointers; these assume
12409that a memory access to address zero always results in a trap, so
12410that if a pointer is checked after it has already been dereferenced,
12411it cannot be null.
12412
12413Note however that in some environments this assumption is not true.
12414Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12415for programs that depend on that behavior.
12416
12417This option is enabled by default on most targets. On Nios II ELF, it
12418defaults to off. On AVR and MSP430, this option is completely disabled.
12419
12420Passes that use the dataflow information
12421are enabled independently at different optimization levels.
12422
d77de738 12423@opindex fdevirtualize
ddf6fe37 12424@item -fdevirtualize
d77de738
ML
12425Attempt to convert calls to virtual functions to direct calls. This
12426is done both within a procedure and interprocedurally as part of
12427indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12428propagation (@option{-fipa-cp}).
12429Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12430
d77de738 12431@opindex fdevirtualize-speculatively
ddf6fe37 12432@item -fdevirtualize-speculatively
d77de738
ML
12433Attempt to convert calls to virtual functions to speculative direct calls.
12434Based on the analysis of the type inheritance graph, determine for a given call
12435the set of likely targets. If the set is small, preferably of size 1, change
12436the call into a conditional deciding between direct and indirect calls. The
12437speculative calls enable more optimizations, such as inlining. When they seem
12438useless after further optimization, they are converted back into original form.
12439
d77de738 12440@opindex fdevirtualize-at-ltrans
ddf6fe37 12441@item -fdevirtualize-at-ltrans
d77de738
ML
12442Stream extra information needed for aggressive devirtualization when running
12443the link-time optimizer in local transformation mode.
12444This option enables more devirtualization but
12445significantly increases the size of streamed data. For this reason it is
12446disabled by default.
12447
d77de738 12448@opindex fexpensive-optimizations
ddf6fe37 12449@item -fexpensive-optimizations
d77de738
ML
12450Perform a number of minor optimizations that are relatively expensive.
12451
12452Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12453
d77de738 12454@opindex free
ddf6fe37 12455@item -free
d77de738
ML
12456Attempt to remove redundant extension instructions. This is especially
12457helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12458registers after writing to their lower 32-bit half.
12459
9417b304
AKA
12460Enabled for Alpha, AArch64, PowerPC, RISC-V, SPARC, h83000 and x86 at levels
12461@option{-O2}, @option{-O3}, @option{-Os}.
d77de738 12462
d77de738
ML
12463@opindex fno-lifetime-dse
12464@opindex flifetime-dse
ddf6fe37 12465@item -fno-lifetime-dse
d77de738
ML
12466In C++ the value of an object is only affected by changes within its
12467lifetime: when the constructor begins, the object has an indeterminate
12468value, and any changes during the lifetime of the object are dead when
12469the object is destroyed. Normally dead store elimination will take
12470advantage of this; if your code relies on the value of the object
12471storage persisting beyond the lifetime of the object, you can use this
12472flag to disable this optimization. To preserve stores before the
12473constructor starts (e.g.@: because your operator new clears the object
12474storage) but still treat the object as dead after the destructor, you
12475can use @option{-flifetime-dse=1}. The default behavior can be
12476explicitly selected with @option{-flifetime-dse=2}.
12477@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12478
d77de738 12479@opindex flive-range-shrinkage
ddf6fe37 12480@item -flive-range-shrinkage
d77de738
ML
12481Attempt to decrease register pressure through register live range
12482shrinkage. This is helpful for fast processors with small or moderate
12483size register sets.
12484
d77de738 12485@opindex fira-algorithm
ddf6fe37 12486@item -fira-algorithm=@var{algorithm}
d77de738
ML
12487Use the specified coloring algorithm for the integrated register
12488allocator. The @var{algorithm} argument can be @samp{priority}, which
12489specifies Chow's priority coloring, or @samp{CB}, which specifies
12490Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12491for all architectures, but for those targets that do support it, it is
12492the default because it generates better code.
12493
d77de738 12494@opindex fira-region
ddf6fe37 12495@item -fira-region=@var{region}
d77de738
ML
12496Use specified regions for the integrated register allocator. The
12497@var{region} argument should be one of the following:
12498
12499@table @samp
12500
12501@item all
12502Use all loops as register allocation regions.
12503This can give the best results for machines with a small and/or
12504irregular register set.
12505
12506@item mixed
12507Use all loops except for loops with small register pressure
12508as the regions. This value usually gives
12509the best results in most cases and for most architectures,
12510and is enabled by default when compiling with optimization for speed
12511(@option{-O}, @option{-O2}, @dots{}).
12512
12513@item one
12514Use all functions as a single region.
12515This typically results in the smallest code size, and is enabled by default for
12516@option{-Os} or @option{-O0}.
12517
12518@end table
12519
d77de738 12520@opindex fira-hoist-pressure
ddf6fe37 12521@item -fira-hoist-pressure
d77de738
ML
12522Use IRA to evaluate register pressure in the code hoisting pass for
12523decisions to hoist expressions. This option usually results in smaller
12524code, but it can slow the compiler down.
12525
12526This option is enabled at level @option{-Os} for all targets.
12527
d77de738 12528@opindex fira-loop-pressure
ddf6fe37 12529@item -fira-loop-pressure
d77de738
ML
12530Use IRA to evaluate register pressure in loops for decisions to move
12531loop invariants. This option usually results in generation
12532of faster and smaller code on machines with large register files (>= 32
12533registers), but it can slow the compiler down.
12534
12535This option is enabled at level @option{-O3} for some targets.
12536
d77de738
ML
12537@opindex fno-ira-share-save-slots
12538@opindex fira-share-save-slots
ddf6fe37 12539@item -fno-ira-share-save-slots
d77de738
ML
12540Disable sharing of stack slots used for saving call-used hard
12541registers living through a call. Each hard register gets a
12542separate stack slot, and as a result function stack frames are
12543larger.
12544
d77de738
ML
12545@opindex fno-ira-share-spill-slots
12546@opindex fira-share-spill-slots
ddf6fe37 12547@item -fno-ira-share-spill-slots
d77de738
ML
12548Disable sharing of stack slots allocated for pseudo-registers. Each
12549pseudo-register that does not get a hard register gets a separate
12550stack slot, and as a result function stack frames are larger.
12551
d77de738 12552@opindex flra-remat
ddf6fe37 12553@item -flra-remat
d77de738
ML
12554Enable CFG-sensitive rematerialization in LRA. Instead of loading
12555values of spilled pseudos, LRA tries to rematerialize (recalculate)
12556values if it is profitable.
12557
12558Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12559
d77de738 12560@opindex fdelayed-branch
ddf6fe37 12561@item -fdelayed-branch
d77de738
ML
12562If supported for the target machine, attempt to reorder instructions
12563to exploit instruction slots available after delayed branch
12564instructions.
12565
12566Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12567but not at @option{-Og}.
12568
d77de738 12569@opindex fschedule-insns
ddf6fe37 12570@item -fschedule-insns
d77de738
ML
12571If supported for the target machine, attempt to reorder instructions to
12572eliminate execution stalls due to required data being unavailable. This
12573helps machines that have slow floating point or memory load instructions
12574by allowing other instructions to be issued until the result of the load
12575or floating-point instruction is required.
12576
12577Enabled at levels @option{-O2}, @option{-O3}.
12578
d77de738 12579@opindex fschedule-insns2
ddf6fe37 12580@item -fschedule-insns2
d77de738
ML
12581Similar to @option{-fschedule-insns}, but requests an additional pass of
12582instruction scheduling after register allocation has been done. This is
12583especially useful on machines with a relatively small number of
12584registers and where memory load instructions take more than one cycle.
12585
12586Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12587
d77de738
ML
12588@opindex fno-sched-interblock
12589@opindex fsched-interblock
ddf6fe37 12590@item -fno-sched-interblock
d77de738
ML
12591Disable instruction scheduling across basic blocks, which
12592is normally enabled when scheduling before register allocation, i.e.@:
12593with @option{-fschedule-insns} or at @option{-O2} or higher.
12594
d77de738
ML
12595@opindex fno-sched-spec
12596@opindex fsched-spec
ddf6fe37 12597@item -fno-sched-spec
d77de738
ML
12598Disable speculative motion of non-load instructions, which
12599is normally enabled when scheduling before register allocation, i.e.@:
12600with @option{-fschedule-insns} or at @option{-O2} or higher.
12601
d77de738 12602@opindex fsched-pressure
ddf6fe37 12603@item -fsched-pressure
d77de738
ML
12604Enable register pressure sensitive insn scheduling before register
12605allocation. This only makes sense when scheduling before register
12606allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12607@option{-O2} or higher. Usage of this option can improve the
12608generated code and decrease its size by preventing register pressure
12609increase above the number of available hard registers and subsequent
12610spills in register allocation.
12611
d77de738 12612@opindex fsched-spec-load
ddf6fe37 12613@item -fsched-spec-load
d77de738
ML
12614Allow speculative motion of some load instructions. This only makes
12615sense when scheduling before register allocation, i.e.@: with
12616@option{-fschedule-insns} or at @option{-O2} or higher.
12617
d77de738 12618@opindex fsched-spec-load-dangerous
ddf6fe37 12619@item -fsched-spec-load-dangerous
d77de738
ML
12620Allow speculative motion of more load instructions. This only makes
12621sense when scheduling before register allocation, i.e.@: with
12622@option{-fschedule-insns} or at @option{-O2} or higher.
12623
ddf6fe37 12624@opindex fsched-stalled-insns
d77de738
ML
12625@item -fsched-stalled-insns
12626@itemx -fsched-stalled-insns=@var{n}
d77de738
ML
12627Define how many insns (if any) can be moved prematurely from the queue
12628of stalled insns into the ready list during the second scheduling pass.
12629@option{-fno-sched-stalled-insns} means that no insns are moved
12630prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12631on how many queued insns can be moved prematurely.
12632@option{-fsched-stalled-insns} without a value is equivalent to
12633@option{-fsched-stalled-insns=1}.
12634
ddf6fe37 12635@opindex fsched-stalled-insns-dep
d77de738
ML
12636@item -fsched-stalled-insns-dep
12637@itemx -fsched-stalled-insns-dep=@var{n}
d77de738
ML
12638Define how many insn groups (cycles) are examined for a dependency
12639on a stalled insn that is a candidate for premature removal from the queue
12640of stalled insns. This has an effect only during the second scheduling pass,
12641and only if @option{-fsched-stalled-insns} is used.
12642@option{-fno-sched-stalled-insns-dep} is equivalent to
12643@option{-fsched-stalled-insns-dep=0}.
12644@option{-fsched-stalled-insns-dep} without a value is equivalent to
12645@option{-fsched-stalled-insns-dep=1}.
12646
d77de738 12647@opindex fsched2-use-superblocks
ddf6fe37 12648@item -fsched2-use-superblocks
d77de738
ML
12649When scheduling after register allocation, use superblock scheduling.
12650This allows motion across basic block boundaries,
12651resulting in faster schedules. This option is experimental, as not all machine
12652descriptions used by GCC model the CPU closely enough to avoid unreliable
12653results from the algorithm.
12654
12655This only makes sense when scheduling after register allocation, i.e.@: with
12656@option{-fschedule-insns2} or at @option{-O2} or higher.
12657
d77de738 12658@opindex fsched-group-heuristic
ddf6fe37 12659@item -fsched-group-heuristic
d77de738
ML
12660Enable the group heuristic in the scheduler. This heuristic favors
12661the instruction that belongs to a schedule group. This is enabled
12662by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12663or @option{-fschedule-insns2} or at @option{-O2} or higher.
12664
d77de738 12665@opindex fsched-critical-path-heuristic
ddf6fe37 12666@item -fsched-critical-path-heuristic
d77de738
ML
12667Enable the critical-path heuristic in the scheduler. This heuristic favors
12668instructions on the critical path. This is enabled by default when
12669scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12670or @option{-fschedule-insns2} or at @option{-O2} or higher.
12671
d77de738 12672@opindex fsched-spec-insn-heuristic
ddf6fe37 12673@item -fsched-spec-insn-heuristic
d77de738
ML
12674Enable the speculative instruction heuristic in the scheduler. This
12675heuristic favors speculative instructions with greater dependency weakness.
12676This is enabled by default when scheduling is enabled, i.e.@:
12677with @option{-fschedule-insns} or @option{-fschedule-insns2}
12678or at @option{-O2} or higher.
12679
d77de738 12680@opindex fsched-rank-heuristic
ddf6fe37 12681@item -fsched-rank-heuristic
d77de738
ML
12682Enable the rank heuristic in the scheduler. This heuristic favors
12683the instruction belonging to a basic block with greater size or frequency.
12684This is enabled by default when scheduling is enabled, i.e.@:
12685with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12686at @option{-O2} or higher.
12687
d77de738 12688@opindex fsched-last-insn-heuristic
ddf6fe37 12689@item -fsched-last-insn-heuristic
d77de738
ML
12690Enable the last-instruction heuristic in the scheduler. This heuristic
12691favors the instruction that is less dependent on the last instruction
12692scheduled. This is enabled by default when scheduling is enabled,
12693i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12694at @option{-O2} or higher.
12695
d77de738 12696@opindex fsched-dep-count-heuristic
ddf6fe37 12697@item -fsched-dep-count-heuristic
d77de738
ML
12698Enable the dependent-count heuristic in the scheduler. This heuristic
12699favors the instruction that has more instructions depending on it.
12700This is enabled by default when scheduling is enabled, i.e.@:
12701with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12702at @option{-O2} or higher.
12703
d77de738 12704@opindex freschedule-modulo-scheduled-loops
ddf6fe37 12705@item -freschedule-modulo-scheduled-loops
d77de738
ML
12706Modulo scheduling is performed before traditional scheduling. If a loop
12707is modulo scheduled, later scheduling passes may change its schedule.
12708Use this option to control that behavior.
12709
d77de738 12710@opindex fselective-scheduling
ddf6fe37 12711@item -fselective-scheduling
d77de738
ML
12712Schedule instructions using selective scheduling algorithm. Selective
12713scheduling runs instead of the first scheduler pass.
12714
d77de738 12715@opindex fselective-scheduling2
ddf6fe37 12716@item -fselective-scheduling2
d77de738
ML
12717Schedule instructions using selective scheduling algorithm. Selective
12718scheduling runs instead of the second scheduler pass.
12719
d77de738 12720@opindex fsel-sched-pipelining
ddf6fe37 12721@item -fsel-sched-pipelining
d77de738
ML
12722Enable software pipelining of innermost loops during selective scheduling.
12723This option has no effect unless one of @option{-fselective-scheduling} or
12724@option{-fselective-scheduling2} is turned on.
12725
d77de738 12726@opindex fsel-sched-pipelining-outer-loops
ddf6fe37 12727@item -fsel-sched-pipelining-outer-loops
d77de738
ML
12728When pipelining loops during selective scheduling, also pipeline outer loops.
12729This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12730
d77de738 12731@opindex fsemantic-interposition
ddf6fe37 12732@item -fsemantic-interposition
d77de738
ML
12733Some object formats, like ELF, allow interposing of symbols by the
12734dynamic linker.
12735This means that for symbols exported from the DSO, the compiler cannot perform
12736interprocedural propagation, inlining and other optimizations in anticipation
12737that the function or variable in question may change. While this feature is
12738useful, for example, to rewrite memory allocation functions by a debugging
12739implementation, it is expensive in the terms of code quality.
12740With @option{-fno-semantic-interposition} the compiler assumes that
12741if interposition happens for functions the overwriting function will have
12742precisely the same semantics (and side effects).
12743Similarly if interposition happens
12744for variables, the constructor of the variable will be the same. The flag
12745has no effect for functions explicitly declared inline
12746(where it is never allowed for interposition to change semantics)
12747and for symbols explicitly declared weak.
12748
d77de738 12749@opindex fshrink-wrap
ddf6fe37 12750@item -fshrink-wrap
d77de738
ML
12751Emit function prologues only before parts of the function that need it,
12752rather than at the top of the function. This flag is enabled by default at
12753@option{-O} and higher.
12754
d77de738 12755@opindex fshrink-wrap-separate
ddf6fe37 12756@item -fshrink-wrap-separate
d77de738
ML
12757Shrink-wrap separate parts of the prologue and epilogue separately, so that
12758those parts are only executed when needed.
12759This option is on by default, but has no effect unless @option{-fshrink-wrap}
12760is also turned on and the target supports this.
12761
d77de738 12762@opindex fcaller-saves
ddf6fe37 12763@item -fcaller-saves
d77de738
ML
12764Enable allocation of values to registers that are clobbered by
12765function calls, by emitting extra instructions to save and restore the
12766registers around such calls. Such allocation is done only when it
12767seems to result in better code.
12768
12769This option is always enabled by default on certain machines, usually
12770those which have no call-preserved registers to use instead.
12771
12772Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12773
d77de738 12774@opindex fcombine-stack-adjustments
ddf6fe37 12775@item -fcombine-stack-adjustments
d77de738
ML
12776Tracks stack adjustments (pushes and pops) and stack memory references
12777and then tries to find ways to combine them.
12778
12779Enabled by default at @option{-O1} and higher.
12780
d77de738 12781@opindex fipa-ra
ddf6fe37 12782@item -fipa-ra
d77de738
ML
12783Use caller save registers for allocation if those registers are not used by
12784any called function. In that case it is not necessary to save and restore
12785them around calls. This is only possible if called functions are part of
12786same compilation unit as current function and they are compiled before it.
12787
12788Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
12789is disabled if generated code will be instrumented for profiling
12790(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
12791exactly (this happens on targets that do not expose prologues
12792and epilogues in RTL).
12793
d77de738 12794@opindex fconserve-stack
ddf6fe37 12795@item -fconserve-stack
d77de738
ML
12796Attempt to minimize stack usage. The compiler attempts to use less
12797stack space, even if that makes the program slower. This option
12798implies setting the @option{large-stack-frame} parameter to 100
12799and the @option{large-stack-frame-growth} parameter to 400.
12800
d77de738 12801@opindex ftree-reassoc
ddf6fe37 12802@item -ftree-reassoc
d77de738
ML
12803Perform reassociation on trees. This flag is enabled by default
12804at @option{-O1} and higher.
12805
d77de738 12806@opindex fcode-hoisting
ddf6fe37 12807@item -fcode-hoisting
d77de738
ML
12808Perform code hoisting. Code hoisting tries to move the
12809evaluation of expressions executed on all paths to the function exit
12810as early as possible. This is especially useful as a code size
12811optimization, but it often helps for code speed as well.
12812This flag is enabled by default at @option{-O2} and higher.
12813
d77de738 12814@opindex ftree-pre
ddf6fe37 12815@item -ftree-pre
d77de738
ML
12816Perform partial redundancy elimination (PRE) on trees. This flag is
12817enabled by default at @option{-O2} and @option{-O3}.
12818
d77de738 12819@opindex ftree-partial-pre
ddf6fe37 12820@item -ftree-partial-pre
d77de738
ML
12821Make partial redundancy elimination (PRE) more aggressive. This flag is
12822enabled by default at @option{-O3}.
12823
d77de738 12824@opindex ftree-forwprop
ddf6fe37 12825@item -ftree-forwprop
d77de738
ML
12826Perform forward propagation on trees. This flag is enabled by default
12827at @option{-O1} and higher.
12828
d77de738 12829@opindex ftree-fre
ddf6fe37 12830@item -ftree-fre
d77de738
ML
12831Perform full redundancy elimination (FRE) on trees. The difference
12832between FRE and PRE is that FRE only considers expressions
12833that are computed on all paths leading to the redundant computation.
12834This analysis is faster than PRE, though it exposes fewer redundancies.
12835This flag is enabled by default at @option{-O1} and higher.
12836
d77de738 12837@opindex ftree-phiprop
ddf6fe37 12838@item -ftree-phiprop
d77de738
ML
12839Perform hoisting of loads from conditional pointers on trees. This
12840pass is enabled by default at @option{-O1} and higher.
12841
d77de738 12842@opindex fhoist-adjacent-loads
ddf6fe37 12843@item -fhoist-adjacent-loads
d77de738
ML
12844Speculatively hoist loads from both branches of an if-then-else if the
12845loads are from adjacent locations in the same structure and the target
12846architecture has a conditional move instruction. This flag is enabled
12847by default at @option{-O2} and higher.
12848
d77de738 12849@opindex ftree-copy-prop
ddf6fe37 12850@item -ftree-copy-prop
d77de738
ML
12851Perform copy propagation on trees. This pass eliminates unnecessary
12852copy operations. This flag is enabled by default at @option{-O1} and
12853higher.
12854
d77de738 12855@opindex fipa-pure-const
ddf6fe37 12856@item -fipa-pure-const
d77de738
ML
12857Discover which functions are pure or constant.
12858Enabled by default at @option{-O1} and higher.
12859
d77de738 12860@opindex fipa-reference
ddf6fe37 12861@item -fipa-reference
d77de738
ML
12862Discover which static variables do not escape the
12863compilation unit.
12864Enabled by default at @option{-O1} and higher.
12865
d77de738 12866@opindex fipa-reference-addressable
ddf6fe37 12867@item -fipa-reference-addressable
d77de738
ML
12868Discover read-only, write-only and non-addressable static variables.
12869Enabled by default at @option{-O1} and higher.
12870
d77de738 12871@opindex fipa-stack-alignment
ddf6fe37 12872@item -fipa-stack-alignment
d77de738
ML
12873Reduce stack alignment on call sites if possible.
12874Enabled by default.
12875
d77de738 12876@opindex fipa-pta
ddf6fe37 12877@item -fipa-pta
d77de738
ML
12878Perform interprocedural pointer analysis and interprocedural modification
12879and reference analysis. This option can cause excessive memory and
12880compile-time usage on large compilation units. It is not enabled by
12881default at any optimization level.
12882
d77de738 12883@opindex fipa-profile
ddf6fe37 12884@item -fipa-profile
d77de738
ML
12885Perform interprocedural profile propagation. The functions called only from
12886cold functions are marked as cold. Also functions executed once (such as
12887@code{cold}, @code{noreturn}, static constructors or destructors) are
12888identified. Cold functions and loop less parts of functions executed once are
12889then optimized for size.
12890Enabled by default at @option{-O1} and higher.
12891
d77de738 12892@opindex fipa-modref
ddf6fe37 12893@item -fipa-modref
d77de738
ML
12894Perform interprocedural mod/ref analysis. This optimization analyzes the side
12895effects of functions (memory locations that are modified or referenced) and
12896enables better optimization across the function call boundary. This flag is
12897enabled by default at @option{-O1} and higher.
12898
d77de738 12899@opindex fipa-cp
ddf6fe37 12900@item -fipa-cp
d77de738
ML
12901Perform interprocedural constant propagation.
12902This optimization analyzes the program to determine when values passed
12903to functions are constants and then optimizes accordingly.
12904This optimization can substantially increase performance
12905if the application has constants passed to functions.
12906This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
12907It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12908
d77de738 12909@opindex fipa-cp-clone
ddf6fe37 12910@item -fipa-cp-clone
d77de738
ML
12911Perform function cloning to make interprocedural constant propagation stronger.
12912When enabled, interprocedural constant propagation performs function cloning
12913when externally visible function can be called with constant arguments.
12914Because this optimization can create multiple copies of functions,
12915it may significantly increase code size
12916(see @option{--param ipa-cp-unit-growth=@var{value}}).
12917This flag is enabled by default at @option{-O3}.
12918It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12919
d77de738 12920@opindex fipa-bit-cp
ddf6fe37 12921@item -fipa-bit-cp
d77de738
ML
12922When enabled, perform interprocedural bitwise constant
12923propagation. This flag is enabled by default at @option{-O2} and
12924by @option{-fprofile-use} and @option{-fauto-profile}.
12925It requires that @option{-fipa-cp} is enabled.
12926
d77de738 12927@opindex fipa-vrp
ddf6fe37 12928@item -fipa-vrp
d77de738
ML
12929When enabled, perform interprocedural propagation of value
12930ranges. This flag is enabled by default at @option{-O2}. It requires
12931that @option{-fipa-cp} is enabled.
12932
d77de738 12933@opindex fipa-icf
ddf6fe37 12934@item -fipa-icf
d77de738
ML
12935Perform Identical Code Folding for functions and read-only variables.
12936The optimization reduces code size and may disturb unwind stacks by replacing
12937a function by equivalent one with a different name. The optimization works
12938more effectively with link-time optimization enabled.
12939
12940Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
12941works on different levels and thus the optimizations are not same - there are
12942equivalences that are found only by GCC and equivalences found only by Gold.
12943
12944This flag is enabled by default at @option{-O2} and @option{-Os}.
12945
d77de738 12946@opindex flive-patching
ddf6fe37 12947@item -flive-patching=@var{level}
d77de738
ML
12948Control GCC's optimizations to produce output suitable for live-patching.
12949
12950If the compiler's optimization uses a function's body or information extracted
12951from its body to optimize/change another function, the latter is called an
12952impacted function of the former. If a function is patched, its impacted
12953functions should be patched too.
12954
12955The impacted functions are determined by the compiler's interprocedural
12956optimizations. For example, a caller is impacted when inlining a function
12957into its caller,
12958cloning a function and changing its caller to call this new clone,
12959or extracting a function's pureness/constness information to optimize
12960its direct or indirect callers, etc.
12961
12962Usually, the more IPA optimizations enabled, the larger the number of
12963impacted functions for each function. In order to control the number of
12964impacted functions and more easily compute the list of impacted function,
12965IPA optimizations can be partially enabled at two different levels.
12966
12967The @var{level} argument should be one of the following:
12968
12969@table @samp
12970
12971@item inline-clone
12972
12973Only enable inlining and cloning optimizations, which includes inlining,
12974cloning, interprocedural scalar replacement of aggregates and partial inlining.
12975As a result, when patching a function, all its callers and its clones'
12976callers are impacted, therefore need to be patched as well.
12977
12978@option{-flive-patching=inline-clone} disables the following optimization flags:
43b72ede
AA
12979@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra
12980-fipa-icf -fipa-icf-functions -fipa-icf-variables
12981-fipa-bit-cp -fipa-vrp -fipa-pure-const
12982-fipa-reference-addressable
d77de738
ML
12983-fipa-stack-alignment -fipa-modref}
12984
12985@item inline-only-static
12986
12987Only enable inlining of static functions.
12988As a result, when patching a static function, all its callers are impacted
12989and so need to be patched as well.
12990
12991In addition to all the flags that @option{-flive-patching=inline-clone}
12992disables,
12993@option{-flive-patching=inline-only-static} disables the following additional
12994optimization flags:
12995@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
12996
12997@end table
12998
12999When @option{-flive-patching} is specified without any value, the default value
13000is @var{inline-clone}.
13001
13002This flag is disabled by default.
13003
13004Note that @option{-flive-patching} is not supported with link-time optimization
13005(@option{-flto}).
13006
d77de738 13007@opindex fisolate-erroneous-paths-dereference
ddf6fe37 13008@item -fisolate-erroneous-paths-dereference
d77de738
ML
13009Detect paths that trigger erroneous or undefined behavior due to
13010dereferencing a null pointer. Isolate those paths from the main control
13011flow and turn the statement with erroneous or undefined behavior into a trap.
13012This flag is enabled by default at @option{-O2} and higher and depends on
13013@option{-fdelete-null-pointer-checks} also being enabled.
13014
d77de738 13015@opindex fisolate-erroneous-paths-attribute
ddf6fe37 13016@item -fisolate-erroneous-paths-attribute
d77de738
ML
13017Detect paths that trigger erroneous or undefined behavior due to a null value
13018being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
13019attribute. Isolate those paths from the main control flow and turn the
13020statement with erroneous or undefined behavior into a trap. This is not
13021currently enabled, but may be enabled by @option{-O2} in the future.
13022
d77de738 13023@opindex ftree-sink
ddf6fe37 13024@item -ftree-sink
d77de738
ML
13025Perform forward store motion on trees. This flag is
13026enabled by default at @option{-O1} and higher.
13027
d77de738 13028@opindex ftree-bit-ccp
ddf6fe37 13029@item -ftree-bit-ccp
d77de738
ML
13030Perform sparse conditional bit constant propagation on trees and propagate
13031pointer alignment information.
13032This pass only operates on local scalar variables and is enabled by default
13033at @option{-O1} and higher, except for @option{-Og}.
13034It requires that @option{-ftree-ccp} is enabled.
13035
d77de738 13036@opindex ftree-ccp
ddf6fe37 13037@item -ftree-ccp
d77de738
ML
13038Perform sparse conditional constant propagation (CCP) on trees. This
13039pass only operates on local scalar variables and is enabled by default
13040at @option{-O1} and higher.
13041
d77de738 13042@opindex fssa-backprop
ddf6fe37 13043@item -fssa-backprop
d77de738
ML
13044Propagate information about uses of a value up the definition chain
13045in order to simplify the definitions. For example, this pass strips
13046sign operations if the sign of a value never matters. The flag is
13047enabled by default at @option{-O1} and higher.
13048
d77de738 13049@opindex fssa-phiopt
ddf6fe37 13050@item -fssa-phiopt
d77de738
ML
13051Perform pattern matching on SSA PHI nodes to optimize conditional
13052code. This pass is enabled by default at @option{-O1} and higher,
13053except for @option{-Og}.
13054
d77de738 13055@opindex ftree-switch-conversion
ddf6fe37 13056@item -ftree-switch-conversion
d77de738
ML
13057Perform conversion of simple initializations in a switch to
13058initializations from a scalar array. This flag is enabled by default
13059at @option{-O2} and higher.
13060
d77de738 13061@opindex ftree-tail-merge
ddf6fe37 13062@item -ftree-tail-merge
d77de738
ML
13063Look for identical code sequences. When found, replace one with a jump to the
13064other. This optimization is known as tail merging or cross jumping. This flag
13065is enabled by default at @option{-O2} and higher. The compilation time
13066in this pass can
13067be limited using @option{max-tail-merge-comparisons} parameter and
13068@option{max-tail-merge-iterations} parameter.
13069
d77de738 13070@opindex ftree-dce
ddf6fe37 13071@item -ftree-dce
d77de738
ML
13072Perform dead code elimination (DCE) on trees. This flag is enabled by
13073default at @option{-O1} and higher.
13074
d77de738 13075@opindex ftree-builtin-call-dce
ddf6fe37 13076@item -ftree-builtin-call-dce
d77de738
ML
13077Perform conditional dead code elimination (DCE) for calls to built-in functions
13078that may set @code{errno} but are otherwise free of side effects. This flag is
13079enabled by default at @option{-O2} and higher if @option{-Os} is not also
13080specified.
13081
d77de738
ML
13082@opindex ffinite-loops
13083@opindex fno-finite-loops
ddf6fe37 13084@item -ffinite-loops
d77de738
ML
13085Assume that a loop with an exit will eventually take the exit and not loop
13086indefinitely. This allows the compiler to remove loops that otherwise have
13087no side-effects, not considering eventual endless looping as such.
13088
13089This option is enabled by default at @option{-O2} for C++ with -std=c++11
13090or higher.
13091
d77de738 13092@opindex ftree-dominator-opts
ddf6fe37 13093@item -ftree-dominator-opts
d77de738
ML
13094Perform a variety of simple scalar cleanups (constant/copy
13095propagation, redundancy elimination, range propagation and expression
13096simplification) based on a dominator tree traversal. This also
13097performs jump threading (to reduce jumps to jumps). This flag is
13098enabled by default at @option{-O1} and higher.
13099
d77de738 13100@opindex ftree-dse
ddf6fe37 13101@item -ftree-dse
d77de738
ML
13102Perform dead store elimination (DSE) on trees. A dead store is a store into
13103a memory location that is later overwritten by another store without
13104any intervening loads. In this case the earlier store can be deleted. This
13105flag is enabled by default at @option{-O1} and higher.
13106
d77de738 13107@opindex ftree-ch
ddf6fe37 13108@item -ftree-ch
d77de738
ML
13109Perform loop header copying on trees. This is beneficial since it increases
13110effectiveness of code motion optimizations. It also saves one jump. This flag
13111is enabled by default at @option{-O1} and higher. It is not enabled
13112for @option{-Os}, since it usually increases code size.
13113
d77de738 13114@opindex ftree-loop-optimize
ddf6fe37 13115@item -ftree-loop-optimize
d77de738
ML
13116Perform loop optimizations on trees. This flag is enabled by default
13117at @option{-O1} and higher.
13118
d77de738
ML
13119@opindex ftree-loop-linear
13120@opindex floop-strip-mine
13121@opindex floop-block
ddf6fe37
AA
13122@item -ftree-loop-linear
13123@itemx -floop-strip-mine
13124@itemx -floop-block
d77de738
ML
13125Perform loop nest optimizations. Same as
13126@option{-floop-nest-optimize}. To use this code transformation, GCC has
13127to be configured with @option{--with-isl} to enable the Graphite loop
13128transformation infrastructure.
13129
d77de738 13130@opindex fgraphite-identity
ddf6fe37 13131@item -fgraphite-identity
d77de738
ML
13132Enable the identity transformation for graphite. For every SCoP we generate
13133the polyhedral representation and transform it back to gimple. Using
13134@option{-fgraphite-identity} we can check the costs or benefits of the
13135GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13136are also performed by the code generator isl, like index splitting and
13137dead code elimination in loops.
13138
d77de738 13139@opindex floop-nest-optimize
ddf6fe37 13140@item -floop-nest-optimize
d77de738
ML
13141Enable the isl based loop nest optimizer. This is a generic loop nest
13142optimizer based on the Pluto optimization algorithms. It calculates a loop
13143structure optimized for data-locality and parallelism. This option
13144is experimental.
13145
d77de738 13146@opindex floop-parallelize-all
ddf6fe37 13147@item -floop-parallelize-all
d77de738
ML
13148Use the Graphite data dependence analysis to identify loops that can
13149be parallelized. Parallelize all the loops that can be analyzed to
13150not contain loop carried dependences without checking that it is
13151profitable to parallelize the loops.
13152
d77de738 13153@opindex ftree-coalesce-vars
ddf6fe37 13154@item -ftree-coalesce-vars
d77de738
ML
13155While transforming the program out of the SSA representation, attempt to
13156reduce copying by coalescing versions of different user-defined
13157variables, instead of just compiler temporaries. This may severely
13158limit the ability to debug an optimized program compiled with
13159@option{-fno-var-tracking-assignments}. In the negated form, this flag
13160prevents SSA coalescing of user variables. This option is enabled by
13161default if optimization is enabled, and it does very little otherwise.
13162
d77de738 13163@opindex ftree-loop-if-convert
ddf6fe37 13164@item -ftree-loop-if-convert
d77de738
ML
13165Attempt to transform conditional jumps in the innermost loops to
13166branch-less equivalents. The intent is to remove control-flow from
13167the innermost loops in order to improve the ability of the
13168vectorization pass to handle these loops. This is enabled by default
13169if vectorization is enabled.
13170
d77de738 13171@opindex ftree-loop-distribution
ddf6fe37 13172@item -ftree-loop-distribution
d77de738
ML
13173Perform loop distribution. This flag can improve cache performance on
13174big loop bodies and allow further loop optimizations, like
13175parallelization or vectorization, to take place. For example, the loop
13176@smallexample
13177DO I = 1, N
13178 A(I) = B(I) + C
13179 D(I) = E(I) * F
13180ENDDO
13181@end smallexample
13182is transformed to
13183@smallexample
13184DO I = 1, N
13185 A(I) = B(I) + C
13186ENDDO
13187DO I = 1, N
13188 D(I) = E(I) * F
13189ENDDO
13190@end smallexample
13191This flag is enabled by default at @option{-O3}.
13192It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13193
d77de738 13194@opindex ftree-loop-distribute-patterns
ddf6fe37 13195@item -ftree-loop-distribute-patterns
d77de738
ML
13196Perform loop distribution of patterns that can be code generated with
13197calls to a library. This flag is enabled by default at @option{-O2} and
13198higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13199
13200This pass distributes the initialization loops and generates a call to
13201memset zero. For example, the loop
13202@smallexample
13203DO I = 1, N
13204 A(I) = 0
13205 B(I) = A(I) + I
13206ENDDO
13207@end smallexample
13208is transformed to
13209@smallexample
13210DO I = 1, N
13211 A(I) = 0
13212ENDDO
13213DO I = 1, N
13214 B(I) = A(I) + I
13215ENDDO
13216@end smallexample
13217and the initialization loop is transformed into a call to memset zero.
13218This flag is enabled by default at @option{-O3}.
13219It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13220
d77de738 13221@opindex floop-interchange
ddf6fe37 13222@item -floop-interchange
d77de738
ML
13223Perform loop interchange outside of graphite. This flag can improve cache
13224performance on loop nest and allow further loop optimizations, like
13225vectorization, to take place. For example, the loop
13226@smallexample
13227for (int i = 0; i < N; i++)
13228 for (int j = 0; j < N; j++)
13229 for (int k = 0; k < N; k++)
13230 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13231@end smallexample
13232is transformed to
13233@smallexample
13234for (int i = 0; i < N; i++)
13235 for (int k = 0; k < N; k++)
13236 for (int j = 0; j < N; j++)
13237 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13238@end smallexample
13239This flag is enabled by default at @option{-O3}.
13240It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13241
d77de738 13242@opindex floop-unroll-and-jam
ddf6fe37 13243@item -floop-unroll-and-jam
d77de738
ML
13244Apply unroll and jam transformations on feasible loops. In a loop
13245nest this unrolls the outer loop by some factor and fuses the resulting
13246multiple inner loops. This flag is enabled by default at @option{-O3}.
13247It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13248
d77de738 13249@opindex ftree-loop-im
ddf6fe37 13250@item -ftree-loop-im
d77de738
ML
13251Perform loop invariant motion on trees. This pass moves only invariants that
13252are hard to handle at RTL level (function calls, operations that expand to
13253nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13254operands of conditions that are invariant out of the loop, so that we can use
13255just trivial invariantness analysis in loop unswitching. The pass also includes
13256store motion.
13257
d77de738 13258@opindex ftree-loop-ivcanon
ddf6fe37 13259@item -ftree-loop-ivcanon
d77de738
ML
13260Create a canonical counter for number of iterations in loops for which
13261determining number of iterations requires complicated analysis. Later
13262optimizations then may determine the number easily. Useful especially
13263in connection with unrolling.
13264
d77de738 13265@opindex ftree-scev-cprop
ddf6fe37 13266@item -ftree-scev-cprop
d77de738
ML
13267Perform final value replacement. If a variable is modified in a loop
13268in such a way that its value when exiting the loop can be determined using
13269only its initial value and the number of loop iterations, replace uses of
13270the final value by such a computation, provided it is sufficiently cheap.
13271This reduces data dependencies and may allow further simplifications.
13272Enabled by default at @option{-O1} and higher.
13273
d77de738 13274@opindex fivopts
ddf6fe37 13275@item -fivopts
d77de738
ML
13276Perform induction variable optimizations (strength reduction, induction
13277variable merging and induction variable elimination) on trees.
13278
d77de738 13279@opindex ftree-parallelize-loops
ddf6fe37 13280@item -ftree-parallelize-loops=n
d77de738
ML
13281Parallelize loops, i.e., split their iteration space to run in n threads.
13282This is only possible for loops whose iterations are independent
13283and can be arbitrarily reordered. The optimization is only
13284profitable on multiprocessor machines, for loops that are CPU-intensive,
13285rather than constrained e.g.@: by memory bandwidth. This option
13286implies @option{-pthread}, and thus is only supported on targets
13287that have support for @option{-pthread}.
13288
d77de738 13289@opindex ftree-pta
ddf6fe37 13290@item -ftree-pta
d77de738
ML
13291Perform function-local points-to analysis on trees. This flag is
13292enabled by default at @option{-O1} and higher, except for @option{-Og}.
13293
d77de738 13294@opindex ftree-sra
ddf6fe37 13295@item -ftree-sra
d77de738
ML
13296Perform scalar replacement of aggregates. This pass replaces structure
13297references with scalars to prevent committing structures to memory too
13298early. This flag is enabled by default at @option{-O1} and higher,
13299except for @option{-Og}.
13300
d77de738 13301@opindex fstore-merging
ddf6fe37 13302@item -fstore-merging
d77de738
ML
13303Perform merging of narrow stores to consecutive memory addresses. This pass
13304merges contiguous stores of immediate values narrower than a word into fewer
13305wider stores to reduce the number of instructions. This is enabled by default
13306at @option{-O2} and higher as well as @option{-Os}.
13307
d77de738 13308@opindex ftree-ter
ddf6fe37 13309@item -ftree-ter
d77de738
ML
13310Perform temporary expression replacement during the SSA->normal phase. Single
13311use/single def temporaries are replaced at their use location with their
13312defining expression. This results in non-GIMPLE code, but gives the expanders
13313much more complex trees to work on resulting in better RTL generation. This is
13314enabled by default at @option{-O1} and higher.
13315
d77de738 13316@opindex ftree-slsr
ddf6fe37 13317@item -ftree-slsr
d77de738
ML
13318Perform straight-line strength reduction on trees. This recognizes related
13319expressions involving multiplications and replaces them by less expensive
13320calculations when possible. This is enabled by default at @option{-O1} and
13321higher.
13322
d77de738 13323@opindex ftree-vectorize
ddf6fe37 13324@item -ftree-vectorize
d77de738
ML
13325Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13326and @option{-ftree-slp-vectorize} if not explicitly specified.
13327
d77de738 13328@opindex ftree-loop-vectorize
ddf6fe37 13329@item -ftree-loop-vectorize
d77de738
ML
13330Perform loop vectorization on trees. This flag is enabled by default at
13331@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13332and @option{-fauto-profile}.
13333
d77de738 13334@opindex ftree-slp-vectorize
ddf6fe37 13335@item -ftree-slp-vectorize
d77de738
ML
13336Perform basic block vectorization on trees. This flag is enabled by default at
13337@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13338and @option{-fauto-profile}.
13339
d77de738 13340@opindex ftrivial-auto-var-init
ddf6fe37 13341@item -ftrivial-auto-var-init=@var{choice}
d77de738
ML
13342Initialize automatic variables with either a pattern or with zeroes to increase
13343the security and predictability of a program by preventing uninitialized memory
13344disclosure and use.
13345GCC still considers an automatic variable that doesn't have an explicit
13346initializer as uninitialized, @option{-Wuninitialized} and
13347@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13348warning messages on such automatic variables and the compiler will
13349perform optimization as if the variable were uninitialized.
d77de738
ML
13350With this option, GCC will also initialize any padding of automatic variables
13351that have structure or union types to zeroes.
13352However, the current implementation cannot initialize automatic variables that
13353are declared between the controlling expression and the first case of a
13354@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13355such cases.
13356
13357The three values of @var{choice} are:
13358
13359@itemize @bullet
13360@item
13361@samp{uninitialized} doesn't initialize any automatic variables.
13362This is C and C++'s default.
13363
13364@item
13365@samp{pattern} Initialize automatic variables with values which will likely
13366transform logic bugs into crashes down the line, are easily recognized in a
13367crash dump and without being values that programmers can rely on for useful
13368program semantics.
13369The current value is byte-repeatable pattern with byte "0xFE".
13370The values used for pattern initialization might be changed in the future.
13371
13372@item
13373@samp{zero} Initialize automatic variables with zeroes.
13374@end itemize
13375
13376The default is @samp{uninitialized}.
13377
13378You can control this behavior for a specific variable by using the variable
13379attribute @code{uninitialized} (@pxref{Variable Attributes}).
13380
d77de738 13381@opindex fvect-cost-model
ddf6fe37 13382@item -fvect-cost-model=@var{model}
d77de738
ML
13383Alter the cost model used for vectorization. The @var{model} argument
13384should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13385@samp{very-cheap}.
13386With the @samp{unlimited} model the vectorized code-path is assumed
13387to be profitable while with the @samp{dynamic} model a runtime check
13388guards the vectorized code-path to enable it only for iteration
13389counts that will likely execute faster than when executing the original
13390scalar loop. The @samp{cheap} model disables vectorization of
13391loops where doing so would be cost prohibitive for example due to
13392required runtime checks for data dependence or alignment but otherwise
13393is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13394allows vectorization if the vector code would entirely replace the
13395scalar code that is being vectorized. For example, if each iteration
13396of a vectorized loop would only be able to handle exactly four iterations
13397of the scalar loop, the @samp{very-cheap} model would only allow
13398vectorization if the scalar iteration count is known to be a multiple
13399of four.
13400
13401The default cost model depends on other optimization flags and is
13402either @samp{dynamic} or @samp{cheap}.
13403
d77de738 13404@opindex fsimd-cost-model
ddf6fe37 13405@item -fsimd-cost-model=@var{model}
d77de738
ML
13406Alter the cost model used for vectorization of loops marked with the OpenMP
13407simd directive. The @var{model} argument should be one of
13408@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13409have the same meaning as described in @option{-fvect-cost-model} and by
13410default a cost model defined with @option{-fvect-cost-model} is used.
13411
d77de738 13412@opindex ftree-vrp
ddf6fe37 13413@item -ftree-vrp
d77de738
ML
13414Perform Value Range Propagation on trees. This is similar to the
13415constant propagation pass, but instead of values, ranges of values are
13416propagated. This allows the optimizers to remove unnecessary range
13417checks like array bound checks and null pointer checks. This is
13418enabled by default at @option{-O2} and higher. Null pointer check
13419elimination is only done if @option{-fdelete-null-pointer-checks} is
13420enabled.
13421
d77de738 13422@opindex fsplit-paths
ddf6fe37 13423@item -fsplit-paths
d77de738
ML
13424Split paths leading to loop backedges. This can improve dead code
13425elimination and common subexpression elimination. This is enabled by
13426default at @option{-O3} and above.
13427
d77de738 13428@opindex fsplit-ivs-in-unroller
ddf6fe37 13429@item -fsplit-ivs-in-unroller
d77de738
ML
13430Enables expression of values of induction variables in later iterations
13431of the unrolled loop using the value in the first iteration. This breaks
13432long dependency chains, thus improving efficiency of the scheduling passes.
13433
13434A combination of @option{-fweb} and CSE is often sufficient to obtain the
13435same effect. However, that is not reliable in cases where the loop body
13436is more complicated than a single basic block. It also does not work at all
13437on some architectures due to restrictions in the CSE pass.
13438
13439This optimization is enabled by default.
13440
d77de738 13441@opindex fvariable-expansion-in-unroller
ddf6fe37 13442@item -fvariable-expansion-in-unroller
d77de738
ML
13443With this option, the compiler creates multiple copies of some
13444local variables when unrolling a loop, which can result in superior code.
13445
13446This optimization is enabled by default for PowerPC targets, but disabled
13447by default otherwise.
13448
d77de738 13449@opindex fpartial-inlining
ddf6fe37 13450@item -fpartial-inlining
d77de738
ML
13451Inline parts of functions. This option has any effect only
13452when inlining itself is turned on by the @option{-finline-functions}
13453or @option{-finline-small-functions} options.
13454
13455Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13456
d77de738 13457@opindex fpredictive-commoning
ddf6fe37 13458@item -fpredictive-commoning
d77de738
ML
13459Perform predictive commoning optimization, i.e., reusing computations
13460(especially memory loads and stores) performed in previous
13461iterations of loops.
13462
13463This option is enabled at level @option{-O3}.
13464It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13465
d77de738 13466@opindex fprefetch-loop-arrays
ddf6fe37 13467@item -fprefetch-loop-arrays
d77de738
ML
13468If supported by the target machine, generate instructions to prefetch
13469memory to improve the performance of loops that access large arrays.
13470
13471This option may generate better or worse code; results are highly
13472dependent on the structure of loops within the source code.
13473
13474Disabled at level @option{-Os}.
13475
d77de738
ML
13476@opindex fno-printf-return-value
13477@opindex fprintf-return-value
ddf6fe37 13478@item -fno-printf-return-value
d77de738
ML
13479Do not substitute constants for known return value of formatted output
13480functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13481@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13482transformation allows GCC to optimize or even eliminate branches based
13483on the known return value of these functions called with arguments that
13484are either constant, or whose values are known to be in a range that
13485makes determining the exact return value possible. For example, when
13486@option{-fprintf-return-value} is in effect, both the branch and the
13487body of the @code{if} statement (but not the call to @code{snprint})
13488can be optimized away when @code{i} is a 32-bit or smaller integer
13489because the return value is guaranteed to be at most 8.
13490
13491@smallexample
13492char buf[9];
13493if (snprintf (buf, "%08x", i) >= sizeof buf)
13494 @dots{}
13495@end smallexample
13496
13497The @option{-fprintf-return-value} option relies on other optimizations
13498and yields best results with @option{-O2} and above. It works in tandem
13499with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13500options. The @option{-fprintf-return-value} option is enabled by default.
13501
d77de738
ML
13502@opindex fno-peephole
13503@opindex fpeephole
13504@opindex fno-peephole2
13505@opindex fpeephole2
ddf6fe37
AA
13506@item -fno-peephole
13507@itemx -fno-peephole2
d77de738
ML
13508Disable any machine-specific peephole optimizations. The difference
13509between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13510are implemented in the compiler; some targets use one, some use the
13511other, a few use both.
13512
13513@option{-fpeephole} is enabled by default.
13514@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13515
d77de738
ML
13516@opindex fno-guess-branch-probability
13517@opindex fguess-branch-probability
ddf6fe37 13518@item -fno-guess-branch-probability
d77de738
ML
13519Do not guess branch probabilities using heuristics.
13520
13521GCC uses heuristics to guess branch probabilities if they are
13522not provided by profiling feedback (@option{-fprofile-arcs}). These
13523heuristics are based on the control flow graph. If some branch probabilities
13524are specified by @code{__builtin_expect}, then the heuristics are
13525used to guess branch probabilities for the rest of the control flow graph,
13526taking the @code{__builtin_expect} info into account. The interactions
13527between the heuristics and @code{__builtin_expect} can be complex, and in
13528some cases, it may be useful to disable the heuristics so that the effects
13529of @code{__builtin_expect} are easier to understand.
13530
13531It is also possible to specify expected probability of the expression
13532with @code{__builtin_expect_with_probability} built-in function.
13533
13534The default is @option{-fguess-branch-probability} at levels
13535@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13536
d77de738 13537@opindex freorder-blocks
ddf6fe37 13538@item -freorder-blocks
d77de738
ML
13539Reorder basic blocks in the compiled function in order to reduce number of
13540taken branches and improve code locality.
13541
13542Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13543
d77de738 13544@opindex freorder-blocks-algorithm
ddf6fe37 13545@item -freorder-blocks-algorithm=@var{algorithm}
d77de738
ML
13546Use the specified algorithm for basic block reordering. The
13547@var{algorithm} argument can be @samp{simple}, which does not increase
13548code size (except sometimes due to secondary effects like alignment),
13549or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13550put all often executed code together, minimizing the number of branches
13551executed by making extra copies of code.
13552
13553The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13554@samp{stc} at levels @option{-O2}, @option{-O3}.
13555
d77de738 13556@opindex freorder-blocks-and-partition
ddf6fe37 13557@item -freorder-blocks-and-partition
d77de738
ML
13558In addition to reordering basic blocks in the compiled function, in order
13559to reduce number of taken branches, partitions hot and cold basic blocks
13560into separate sections of the assembly and @file{.o} files, to improve
13561paging and cache locality performance.
13562
13563This optimization is automatically turned off in the presence of
13564exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13565section attribute and on any architecture that does not support named
13566sections. When @option{-fsplit-stack} is used this option is not
13567enabled by default (to avoid linker errors), but may be enabled
13568explicitly (if using a working linker).
13569
13570Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13571
d77de738 13572@opindex freorder-functions
ddf6fe37 13573@item -freorder-functions
d77de738
ML
13574Reorder functions in the object file in order to
13575improve code locality. This is implemented by using special
13576subsections @code{.text.hot} for most frequently executed functions and
13577@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13578the linker so object file format must support named sections and linker must
13579place them in a reasonable way.
13580
13581This option isn't effective unless you either provide profile feedback
13582(see @option{-fprofile-arcs} for details) or manually annotate functions with
13583@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13584
13585Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13586
d77de738 13587@opindex fstrict-aliasing
ddf6fe37 13588@item -fstrict-aliasing
d77de738
ML
13589Allow the compiler to assume the strictest aliasing rules applicable to
13590the language being compiled. For C (and C++), this activates
13591optimizations based on the type of expressions. In particular, an
13592object of one type is assumed never to reside at the same address as an
13593object of a different type, unless the types are almost the same. For
13594example, an @code{unsigned int} can alias an @code{int}, but not a
13595@code{void*} or a @code{double}. A character type may alias any other
13596type.
13597
13598@anchor{Type-punning}Pay special attention to code like this:
13599@smallexample
13600union a_union @{
13601 int i;
13602 double d;
13603@};
13604
13605int f() @{
13606 union a_union t;
13607 t.d = 3.0;
13608 return t.i;
13609@}
13610@end smallexample
13611The practice of reading from a different union member than the one most
13612recently written to (called ``type-punning'') is common. Even with
13613@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13614is accessed through the union type. So, the code above works as
13615expected. @xref{Structures unions enumerations and bit-fields
13616implementation}. However, this code might not:
13617@smallexample
13618int f() @{
13619 union a_union t;
13620 int* ip;
13621 t.d = 3.0;
13622 ip = &t.i;
13623 return *ip;
13624@}
13625@end smallexample
13626
13627Similarly, access by taking the address, casting the resulting pointer
13628and dereferencing the result has undefined behavior, even if the cast
13629uses a union type, e.g.:
13630@smallexample
13631int f() @{
13632 double d = 3.0;
13633 return ((union a_union *) &d)->i;
13634@}
13635@end smallexample
13636
13637The @option{-fstrict-aliasing} option is enabled at levels
13638@option{-O2}, @option{-O3}, @option{-Os}.
13639
d77de738 13640@opindex fipa-strict-aliasing
ddf6fe37 13641@item -fipa-strict-aliasing
d77de738
ML
13642Controls whether rules of @option{-fstrict-aliasing} are applied across
13643function boundaries. Note that if multiple functions gets inlined into a
13644single function the memory accesses are no longer considered to be crossing a
13645function boundary.
13646
13647The @option{-fipa-strict-aliasing} option is enabled by default and is
13648effective only in combination with @option{-fstrict-aliasing}.
13649
ddf6fe37 13650@opindex falign-functions
d77de738
ML
13651@item -falign-functions
13652@itemx -falign-functions=@var{n}
13653@itemx -falign-functions=@var{n}:@var{m}
13654@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13655@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13656Align the start of functions to the next power-of-two greater than or
13657equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13658least the first @var{m} bytes of the function can be fetched by the CPU
13659without crossing an @var{n}-byte alignment boundary.
13660
13661If @var{m} is not specified, it defaults to @var{n}.
13662
13663Examples: @option{-falign-functions=32} aligns functions to the next
1366432-byte boundary, @option{-falign-functions=24} aligns to the next
1366532-byte boundary only if this can be done by skipping 23 bytes or less,
13666@option{-falign-functions=32:7} aligns to the next
1366732-byte boundary only if this can be done by skipping 6 bytes or less.
13668
13669The second pair of @var{n2}:@var{m2} values allows you to specify
13670a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13671the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13672otherwise aligns to the next 32-byte boundary if this can be done
13673by skipping 2 bytes or less.
13674If @var{m2} is not specified, it defaults to @var{n2}.
13675
13676Some assemblers only support this flag when @var{n} is a power of two;
13677in that case, it is rounded up.
13678
13679@option{-fno-align-functions} and @option{-falign-functions=1} are
13680equivalent and mean that functions are not aligned.
13681
13682If @var{n} is not specified or is zero, use a machine-dependent default.
13683The maximum allowed @var{n} option value is 65536.
13684
13685Enabled at levels @option{-O2}, @option{-O3}.
13686
13687@item -flimit-function-alignment
13688If this option is enabled, the compiler tries to avoid unnecessarily
13689overaligning functions. It attempts to instruct the assembler to align
13690by the amount specified by @option{-falign-functions}, but not to
13691skip more bytes than the size of the function.
13692
ddf6fe37 13693@opindex falign-labels
d77de738
ML
13694@item -falign-labels
13695@itemx -falign-labels=@var{n}
13696@itemx -falign-labels=@var{n}:@var{m}
13697@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13698@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13699Align all branch targets to a power-of-two boundary.
13700
13701Parameters of this option are analogous to the @option{-falign-functions} option.
13702@option{-fno-align-labels} and @option{-falign-labels=1} are
13703equivalent and mean that labels are not aligned.
13704
13705If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13706are greater than this value, then their values are used instead.
13707
13708If @var{n} is not specified or is zero, use a machine-dependent default
13709which is very likely to be @samp{1}, meaning no alignment.
13710The maximum allowed @var{n} option value is 65536.
13711
13712Enabled at levels @option{-O2}, @option{-O3}.
13713
ddf6fe37 13714@opindex falign-loops
d77de738
ML
13715@item -falign-loops
13716@itemx -falign-loops=@var{n}
13717@itemx -falign-loops=@var{n}:@var{m}
13718@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13719@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13720Align loops to a power-of-two boundary. If the loops are executed
13721many times, this makes up for any execution of the dummy padding
13722instructions.
13723
13724If @option{-falign-labels} is greater than this value, then its value
13725is used instead.
13726
13727Parameters of this option are analogous to the @option{-falign-functions} option.
13728@option{-fno-align-loops} and @option{-falign-loops=1} are
13729equivalent and mean that loops are not aligned.
13730The maximum allowed @var{n} option value is 65536.
13731
13732If @var{n} is not specified or is zero, use a machine-dependent default.
13733
13734Enabled at levels @option{-O2}, @option{-O3}.
13735
ddf6fe37 13736@opindex falign-jumps
d77de738
ML
13737@item -falign-jumps
13738@itemx -falign-jumps=@var{n}
13739@itemx -falign-jumps=@var{n}:@var{m}
13740@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13741@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13742Align branch targets to a power-of-two boundary, for branch targets
13743where the targets can only be reached by jumping. In this case,
13744no dummy operations need be executed.
13745
13746If @option{-falign-labels} is greater than this value, then its value
13747is used instead.
13748
13749Parameters of this option are analogous to the @option{-falign-functions} option.
13750@option{-fno-align-jumps} and @option{-falign-jumps=1} are
13751equivalent and mean that loops are not aligned.
13752
13753If @var{n} is not specified or is zero, use a machine-dependent default.
13754The maximum allowed @var{n} option value is 65536.
13755
13756Enabled at levels @option{-O2}, @option{-O3}.
13757
d77de738 13758@opindex fno-allocation-dce
ddf6fe37 13759@item -fno-allocation-dce
d77de738
ML
13760Do not remove unused C++ allocations in dead code elimination.
13761
d77de738 13762@opindex fallow-store-data-races
ddf6fe37 13763@item -fallow-store-data-races
d77de738
ML
13764Allow the compiler to perform optimizations that may introduce new data races
13765on stores, without proving that the variable cannot be concurrently accessed
13766by other threads. Does not affect optimization of local data. It is safe to
13767use this option if it is known that global data will not be accessed by
13768multiple threads.
13769
13770Examples of optimizations enabled by @option{-fallow-store-data-races} include
13771hoisting or if-conversions that may cause a value that was already in memory
13772to be re-written with that same value. Such re-writing is safe in a single
13773threaded context but may be unsafe in a multi-threaded context. Note that on
13774some processors, if-conversions may be required in order to enable
13775vectorization.
13776
13777Enabled at level @option{-Ofast}.
13778
d77de738 13779@opindex funit-at-a-time
ddf6fe37 13780@item -funit-at-a-time
d77de738
ML
13781This option is left for compatibility reasons. @option{-funit-at-a-time}
13782has no effect, while @option{-fno-unit-at-a-time} implies
13783@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
13784
13785Enabled by default.
13786
d77de738
ML
13787@opindex fno-toplevel-reorder
13788@opindex ftoplevel-reorder
ddf6fe37 13789@item -fno-toplevel-reorder
d77de738
ML
13790Do not reorder top-level functions, variables, and @code{asm}
13791statements. Output them in the same order that they appear in the
13792input file. When this option is used, unreferenced static variables
13793are not removed. This option is intended to support existing code
13794that relies on a particular ordering. For new code, it is better to
13795use attributes when possible.
13796
13797@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
13798also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
13799Additionally @option{-fno-toplevel-reorder} implies
13800@option{-fno-section-anchors}.
13801
d77de738 13802@opindex funreachable-traps
ddf6fe37 13803@item -funreachable-traps
d77de738
ML
13804With this option, the compiler turns calls to
13805@code{__builtin_unreachable} into traps, instead of using them for
13806optimization. This also affects any such calls implicitly generated
13807by the compiler.
13808
13809This option has the same effect as @option{-fsanitize=unreachable
13810-fsanitize-trap=unreachable}, but does not affect the values of those
13811options. If @option{-fsanitize=unreachable} is enabled, that option
13812takes priority over this one.
13813
13814This option is enabled by default at @option{-O0} and @option{-Og}.
13815
d77de738 13816@opindex fweb
ddf6fe37 13817@item -fweb
d77de738
ML
13818Constructs webs as commonly used for register allocation purposes and assign
13819each web individual pseudo register. This allows the register allocation pass
13820to operate on pseudos directly, but also strengthens several other optimization
13821passes, such as CSE, loop optimizer and trivial dead code remover. It can,
13822however, make debugging impossible, since variables no longer stay in a
13823``home register''.
13824
13825Enabled by default with @option{-funroll-loops}.
13826
d77de738 13827@opindex fwhole-program
ddf6fe37 13828@item -fwhole-program
d77de738
ML
13829Assume that the current compilation unit represents the whole program being
13830compiled. All public functions and variables with the exception of @code{main}
13831and those merged by attribute @code{externally_visible} become static functions
13832and in effect are optimized more aggressively by interprocedural optimizers.
13833
39ebd3a9
JH
13834With @option{-flto} this option has a limited use. In most cases the
13835precise list of symbols used or exported from the binary is known the
13836resolution info passed to the link-time optimizer by the linker plugin. It is
13837still useful if no linker plugin is used or during incremental link step when
13838final code is produced (with @option{-flto}
13839@option{-flinker-output=nolto-rel}).
d77de738 13840
d77de738 13841@opindex flto
ddf6fe37 13842@item -flto[=@var{n}]
d77de738
ML
13843This option runs the standard link-time optimizer. When invoked
13844with source code, it generates GIMPLE (one of GCC's internal
13845representations) and writes it to special ELF sections in the object
13846file. When the object files are linked together, all the function
13847bodies are read from these ELF sections and instantiated as if they
13848had been part of the same translation unit.
13849
13850To use the link-time optimizer, @option{-flto} and optimization
13851options should be specified at compile time and during the final link.
13852It is recommended that you compile all the files participating in the
13853same link with the same options and also specify those options at
13854link time.
13855For example:
13856
13857@smallexample
13858gcc -c -O2 -flto foo.c
13859gcc -c -O2 -flto bar.c
13860gcc -o myprog -flto -O2 foo.o bar.o
13861@end smallexample
13862
13863The first two invocations to GCC save a bytecode representation
13864of GIMPLE into special ELF sections inside @file{foo.o} and
13865@file{bar.o}. The final invocation reads the GIMPLE bytecode from
13866@file{foo.o} and @file{bar.o}, merges the two files into a single
13867internal image, and compiles the result as usual. Since both
13868@file{foo.o} and @file{bar.o} are merged into a single image, this
13869causes all the interprocedural analyses and optimizations in GCC to
13870work across the two files as if they were a single one. This means,
13871for example, that the inliner is able to inline functions in
13872@file{bar.o} into functions in @file{foo.o} and vice-versa.
13873
13874Another (simpler) way to enable link-time optimization is:
13875
13876@smallexample
13877gcc -o myprog -flto -O2 foo.c bar.c
13878@end smallexample
13879
13880The above generates bytecode for @file{foo.c} and @file{bar.c},
13881merges them together into a single GIMPLE representation and optimizes
13882them as usual to produce @file{myprog}.
13883
13884The important thing to keep in mind is that to enable link-time
13885optimizations you need to use the GCC driver to perform the link step.
13886GCC automatically performs link-time optimization if any of the
13887objects involved were compiled with the @option{-flto} command-line option.
13888You can always override
13889the automatic decision to do link-time optimization
13890by passing @option{-fno-lto} to the link command.
13891
13892To make whole program optimization effective, it is necessary to make
13893certain whole program assumptions. The compiler needs to know
13894what functions and variables can be accessed by libraries and runtime
13895outside of the link-time optimized unit. When supported by the linker,
13896the linker plugin (see @option{-fuse-linker-plugin}) passes information
13897to the compiler about used and externally visible symbols. When
13898the linker plugin is not available, @option{-fwhole-program} should be
13899used to allow the compiler to make these assumptions, which leads
13900to more aggressive optimization decisions.
13901
13902When a file is compiled with @option{-flto} without
13903@option{-fuse-linker-plugin}, the generated object file is larger than
13904a regular object file because it contains GIMPLE bytecodes and the usual
13905final code (see @option{-ffat-lto-objects}). This means that
13906object files with LTO information can be linked as normal object
13907files; if @option{-fno-lto} is passed to the linker, no
13908interprocedural optimizations are applied. Note that when
13909@option{-fno-fat-lto-objects} is enabled the compile stage is faster
13910but you cannot perform a regular, non-LTO link on them.
13911
13912When producing the final binary, GCC only
13913applies link-time optimizations to those files that contain bytecode.
13914Therefore, you can mix and match object files and libraries with
13915GIMPLE bytecodes and final object code. GCC automatically selects
13916which files to optimize in LTO mode and which files to link without
13917further processing.
13918
13919Generally, options specified at link time override those
13920specified at compile time, although in some cases GCC attempts to infer
13921link-time options from the settings used to compile the input files.
13922
13923If you do not specify an optimization level option @option{-O} at
13924link time, then GCC uses the highest optimization level
13925used when compiling the object files. Note that it is generally
13926ineffective to specify an optimization level option only at link time and
13927not at compile time, for two reasons. First, compiling without
13928optimization suppresses compiler passes that gather information
13929needed for effective optimization at link time. Second, some early
13930optimization passes can be performed only at compile time and
13931not at link time.
13932
13933There are some code generation flags preserved by GCC when
13934generating bytecodes, as they need to be used during the final link.
13935Currently, the following options and their settings are taken from
13936the first object file that explicitly specifies them:
13937@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
13938@option{-fgnu-tm} and all the @option{-m} target flags.
13939
13940The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
13941@option{-fPIE} are combined based on the following scheme:
13942
13943@smallexample
13944@option{-fPIC} + @option{-fpic} = @option{-fpic}
13945@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
13946@option{-fpic/-fPIC} + (no option) = (no option)
13947@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
13948@option{-fpic} + @option{-fPIE} = @option{-fpie}
13949@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
13950@end smallexample
13951
13952Certain ABI-changing flags are required to match in all compilation units,
13953and trying to override this at link time with a conflicting value
13954is ignored. This includes options such as @option{-freg-struct-return}
13955and @option{-fpcc-struct-return}.
13956
13957Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
13958@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
13959are passed through to the link stage and merged conservatively for
13960conflicting translation units. Specifically
13961@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
13962precedence; and for example @option{-ffp-contract=off} takes precedence
13963over @option{-ffp-contract=fast}. You can override them at link time.
13964
13965Diagnostic options such as @option{-Wstringop-overflow} are passed
13966through to the link stage and their setting matches that of the
13967compile-step at function granularity. Note that this matters only
13968for diagnostics emitted during optimization. Note that code
13969transforms such as inlining can lead to warnings being enabled
13970or disabled for regions if code not consistent with the setting
13971at compile time.
13972
13973When you need to pass options to the assembler via @option{-Wa} or
13974@option{-Xassembler} make sure to either compile such translation
13975units with @option{-fno-lto} or consistently use the same assembler
13976options on all translation units. You can alternatively also
13977specify assembler options at LTO link time.
13978
13979To enable debug info generation you need to supply @option{-g} at
13980compile time. If any of the input files at link time were built
13981with debug info generation enabled the link will enable debug info
13982generation as well. Any elaborate debug info settings
13983like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
13984at the linker command line and mixing different settings in different
13985translation units is discouraged.
13986
13987If LTO encounters objects with C linkage declared with incompatible
13988types in separate translation units to be linked together (undefined
13989behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
13990issued. The behavior is still undefined at run time. Similar
13991diagnostics may be raised for other languages.
13992
13993Another feature of LTO is that it is possible to apply interprocedural
13994optimizations on files written in different languages:
13995
13996@smallexample
13997gcc -c -flto foo.c
13998g++ -c -flto bar.cc
13999gfortran -c -flto baz.f90
14000g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
14001@end smallexample
14002
14003Notice that the final link is done with @command{g++} to get the C++
14004runtime libraries and @option{-lgfortran} is added to get the Fortran
14005runtime libraries. In general, when mixing languages in LTO mode, you
14006should use the same link command options as when mixing languages in a
14007regular (non-LTO) compilation.
14008
14009If object files containing GIMPLE bytecode are stored in a library archive, say
14010@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
14011are using a linker with plugin support. To create static libraries suitable
14012for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
14013and @command{ranlib};
14014to show the symbols of object files with GIMPLE bytecode, use
14015@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
14016and @command{nm} have been compiled with plugin support. At link time, use the
14017flag @option{-fuse-linker-plugin} to ensure that the library participates in
14018the LTO optimization process:
14019
14020@smallexample
14021gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
14022@end smallexample
14023
14024With the linker plugin enabled, the linker extracts the needed
14025GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
14026to make them part of the aggregated GIMPLE image to be optimized.
14027
14028If you are not using a linker with plugin support and/or do not
14029enable the linker plugin, then the objects inside @file{libfoo.a}
14030are extracted and linked as usual, but they do not participate
14031in the LTO optimization process. In order to make a static library suitable
14032for both LTO optimization and usual linkage, compile its object files with
14033@option{-flto} @option{-ffat-lto-objects}.
14034
14035Link-time optimizations do not require the presence of the whole program to
14036operate. If the program does not require any symbols to be exported, it is
14037possible to combine @option{-flto} and @option{-fwhole-program} to allow
14038the interprocedural optimizers to use more aggressive assumptions which may
14039lead to improved optimization opportunities.
14040Use of @option{-fwhole-program} is not needed when linker plugin is
14041active (see @option{-fuse-linker-plugin}).
14042
14043The current implementation of LTO makes no
14044attempt to generate bytecode that is portable between different
14045types of hosts. The bytecode files are versioned and there is a
14046strict version check, so bytecode files generated in one version of
14047GCC do not work with an older or newer version of GCC.
14048
14049Link-time optimization does not work well with generation of debugging
14050information on systems other than those using a combination of ELF and
14051DWARF.
14052
14053If you specify the optional @var{n}, the optimization and code
14054generation done at link time is executed in parallel using @var{n}
14055parallel jobs by utilizing an installed @command{make} program. The
14056environment variable @env{MAKE} may be used to override the program
14057used.
14058
14059You can also specify @option{-flto=jobserver} to use GNU make's
14060job server mode to determine the number of parallel jobs. This
14061is useful when the Makefile calling GCC is already executing in parallel.
14062You must prepend a @samp{+} to the command recipe in the parent Makefile
14063for this to work. This option likely only works if @env{MAKE} is
14064GNU make. Even without the option value, GCC tries to automatically
14065detect a running GNU make's job server.
14066
14067Use @option{-flto=auto} to use GNU make's job server, if available,
14068or otherwise fall back to autodetection of the number of CPU threads
14069present in your system.
14070
d77de738 14071@opindex flto-partition
ddf6fe37 14072@item -flto-partition=@var{alg}
d77de738
ML
14073Specify the partitioning algorithm used by the link-time optimizer.
14074The value is either @samp{1to1} to specify a partitioning mirroring
14075the original source files or @samp{balanced} to specify partitioning
14076into equally sized chunks (whenever possible) or @samp{max} to create
14077new partition for every symbol where possible. Specifying @samp{none}
14078as an algorithm disables partitioning and streaming completely.
14079The default value is @samp{balanced}. While @samp{1to1} can be used
14080as an workaround for various code ordering issues, the @samp{max}
14081partitioning is intended for internal testing only.
14082The value @samp{one} specifies that exactly one partition should be
14083used while the value @samp{none} bypasses partitioning and executes
14084the link-time optimization step directly from the WPA phase.
14085
d77de738 14086@opindex flto-compression-level
ddf6fe37 14087@item -flto-compression-level=@var{n}
d77de738
ML
14088This option specifies the level of compression used for intermediate
14089language written to LTO object files, and is only meaningful in
14090conjunction with LTO mode (@option{-flto}). GCC currently supports two
14091LTO compression algorithms. For zstd, valid values are 0 (no compression)
14092to 19 (maximum compression), while zlib supports values from 0 to 9.
14093Values outside this range are clamped to either minimum or maximum
14094of the supported values. If the option is not given,
14095a default balanced compression setting is used.
14096
d77de738 14097@opindex fuse-linker-plugin
ddf6fe37 14098@item -fuse-linker-plugin
d77de738
ML
14099Enables the use of a linker plugin during link-time optimization. This
14100option relies on plugin support in the linker, which is available in gold
14101or in GNU ld 2.21 or newer.
14102
14103This option enables the extraction of object files with GIMPLE bytecode out
14104of library archives. This improves the quality of optimization by exposing
14105more code to the link-time optimizer. This information specifies what
14106symbols can be accessed externally (by non-LTO object or during dynamic
14107linking). Resulting code quality improvements on binaries (and shared
14108libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14109See @option{-flto} for a description of the effect of this flag and how to
14110use it.
14111
14112This option is enabled by default when LTO support in GCC is enabled
14113and GCC was configured for use with
14114a linker supporting plugins (GNU ld 2.21 or newer or gold).
14115
d77de738 14116@opindex ffat-lto-objects
ddf6fe37 14117@item -ffat-lto-objects
d77de738
ML
14118Fat LTO objects are object files that contain both the intermediate language
14119and the object code. This makes them usable for both LTO linking and normal
14120linking. This option is effective only when compiling with @option{-flto}
14121and is ignored at link time.
14122
14123@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14124requires the complete toolchain to be aware of LTO. It requires a linker with
14125linker plugin support for basic functionality. Additionally,
14126@command{nm}, @command{ar} and @command{ranlib}
14127need to support linker plugins to allow a full-featured build environment
14128(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14129@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14130to these tools. With non fat LTO makefiles need to be modified to use them.
14131
14132Note that modern binutils provide plugin auto-load mechanism.
14133Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14134effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14135@command{gcc-ranlib}).
14136
14137The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14138support.
14139
d77de738 14140@opindex fcompare-elim
ddf6fe37 14141@item -fcompare-elim
d77de738
ML
14142After register allocation and post-register allocation instruction splitting,
14143identify arithmetic instructions that compute processor flags similar to a
14144comparison operation based on that arithmetic. If possible, eliminate the
14145explicit comparison operation.
14146
14147This pass only applies to certain targets that cannot explicitly represent
14148the comparison operation before register allocation is complete.
14149
14150Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14151
d77de738 14152@opindex fcprop-registers
ddf6fe37 14153@item -fcprop-registers
d77de738
ML
14154After register allocation and post-register allocation instruction splitting,
14155perform a copy-propagation pass to try to reduce scheduling dependencies
14156and occasionally eliminate the copy.
14157
14158Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14159
d77de738 14160@opindex fprofile-correction
ddf6fe37 14161@item -fprofile-correction
d77de738
ML
14162Profiles collected using an instrumented binary for multi-threaded programs may
14163be inconsistent due to missed counter updates. When this option is specified,
14164GCC uses heuristics to correct or smooth out such inconsistencies. By
14165default, GCC emits an error message when an inconsistent profile is detected.
14166
14167This option is enabled by @option{-fauto-profile}.
14168
d77de738 14169@opindex fprofile-partial-training
ddf6fe37 14170@item -fprofile-partial-training
d77de738
ML
14171With @code{-fprofile-use} all portions of programs not executed during train
14172run are optimized agressively for size rather than speed. In some cases it is
14173not practical to train all possible hot paths in the program. (For
14174example, program may contain functions specific for a given hardware and
14175trianing may not cover all hardware configurations program is run on.) With
14176@code{-fprofile-partial-training} profile feedback will be ignored for all
14177functions not executed during the train run leading them to be optimized as if
14178they were compiled without profile feedback. This leads to better performance
14179when train run is not representative but also leads to significantly bigger
14180code.
14181
ddf6fe37 14182@opindex fprofile-use
d77de738
ML
14183@item -fprofile-use
14184@itemx -fprofile-use=@var{path}
d77de738
ML
14185Enable profile feedback-directed optimizations,
14186and the following optimizations, many of which
14187are generally profitable only with profile feedback available:
14188
43b72ede
AA
14189@gccoptlist{-fbranch-probabilities -fprofile-values
14190-funroll-loops -fpeel-loops -ftracer -fvpt
14191-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14192-fpredictive-commoning -fsplit-loops -funswitch-loops
14193-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14194-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14195-fprofile-reorder-functions}
14196
14197Before you can use this option, you must first generate profiling information.
14198@xref{Instrumentation Options}, for information about the
14199@option{-fprofile-generate} option.
14200
14201By default, GCC emits an error message if the feedback profiles do not
14202match the source code. This error can be turned into a warning by using
14203@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14204optimized code. Additionally, by default, GCC also emits a warning message if
14205the feedback profiles do not exist (see @option{-Wmissing-profile}).
14206
14207If @var{path} is specified, GCC looks at the @var{path} to find
14208the profile feedback data files. See @option{-fprofile-dir}.
14209
ddf6fe37 14210@opindex fauto-profile
d77de738
ML
14211@item -fauto-profile
14212@itemx -fauto-profile=@var{path}
d77de738
ML
14213Enable sampling-based feedback-directed optimizations,
14214and the following optimizations,
14215many of which are generally profitable only with profile feedback available:
14216
43b72ede
AA
14217@gccoptlist{-fbranch-probabilities -fprofile-values
14218-funroll-loops -fpeel-loops -ftracer -fvpt
14219-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp
14220-fpredictive-commoning -fsplit-loops -funswitch-loops
14221-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize
14222-fvect-cost-model=dynamic -ftree-loop-distribute-patterns
d77de738
ML
14223-fprofile-correction}
14224
14225@var{path} is the name of a file containing AutoFDO profile information.
14226If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14227
14228Producing an AutoFDO profile data file requires running your program
14229with the @command{perf} utility on a supported GNU/Linux target system.
14230For more information, see @uref{https://perf.wiki.kernel.org/}.
14231
14232E.g.
14233@smallexample
14234perf record -e br_inst_retired:near_taken -b -o perf.data \
14235 -- your_program
14236@end smallexample
14237
14238Then use the @command{create_gcov} tool to convert the raw profile data
14239to a format that can be used by GCC.@ You must also supply the
14240unstripped binary for your program to this tool.
14241See @uref{https://github.com/google/autofdo}.
14242
14243E.g.
14244@smallexample
14245create_gcov --binary=your_program.unstripped --profile=perf.data \
14246 --gcov=profile.afdo
14247@end smallexample
14248@end table
14249
14250The following options control compiler behavior regarding floating-point
14251arithmetic. These options trade off between speed and
14252correctness. All must be specifically enabled.
14253
14254@table @gcctabopt
d77de738 14255@opindex ffloat-store
ddf6fe37 14256@item -ffloat-store
d77de738
ML
14257Do not store floating-point variables in registers, and inhibit other
14258options that might change whether a floating-point value is taken from a
14259register or memory.
14260
14261@cindex floating-point precision
14262This option prevents undesirable excess precision on machines such as
14263the 68000 where the floating registers (of the 68881) keep more
14264precision than a @code{double} is supposed to have. Similarly for the
14265x86 architecture. For most programs, the excess precision does only
14266good, but a few programs rely on the precise definition of IEEE floating
14267point. Use @option{-ffloat-store} for such programs, after modifying
14268them to store all pertinent intermediate computations into variables.
14269
d77de738 14270@opindex fexcess-precision
ddf6fe37 14271@item -fexcess-precision=@var{style}
d77de738
ML
14272This option allows further control over excess precision on machines
14273where floating-point operations occur in a format with more precision or
14274range than the IEEE standard and interchange floating-point types. By
14275default, @option{-fexcess-precision=fast} is in effect; this means that
14276operations may be carried out in a wider precision than the types specified
14277in the source if that would result in faster code, and it is unpredictable
14278when rounding to the types specified in the source code takes place.
14279When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14280then excess precision follows the rules specified in ISO C99 or C++; in particular,
14281both casts and assignments cause values to be rounded to their
14282semantic types (whereas @option{-ffloat-store} only affects
14283assignments). This option is enabled by default for C or C++ if a strict
14284conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14285@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14286regardless of whether a strict conformance option is used.
14287
14288@opindex mfpmath
14289@option{-fexcess-precision=standard} is not implemented for languages
14290other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14291or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14292semantics apply without excess precision, and in the latter, rounding
14293is unpredictable.
14294
d77de738 14295@opindex ffast-math
ddf6fe37 14296@item -ffast-math
d77de738
ML
14297Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14298@option{-ffinite-math-only}, @option{-fno-rounding-math},
14299@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14300@option{-fexcess-precision=fast}.
14301
14302This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14303
14304This option is not turned on by any @option{-O} option besides
14305@option{-Ofast} since it can result in incorrect output for programs
14306that depend on an exact implementation of IEEE or ISO rules/specifications
14307for math functions. It may, however, yield faster code for programs
14308that do not require the guarantees of these specifications.
14309
d77de738
ML
14310@opindex fno-math-errno
14311@opindex fmath-errno
ddf6fe37 14312@item -fno-math-errno
d77de738
ML
14313Do not set @code{errno} after calling math functions that are executed
14314with a single instruction, e.g., @code{sqrt}. A program that relies on
14315IEEE exceptions for math error handling may want to use this flag
14316for speed while maintaining IEEE arithmetic compatibility.
14317
14318This option is not turned on by any @option{-O} option since
14319it can result in incorrect output for programs that depend on
14320an exact implementation of IEEE or ISO rules/specifications for
14321math functions. It may, however, yield faster code for programs
14322that do not require the guarantees of these specifications.
14323
14324The default is @option{-fmath-errno}.
14325
14326On Darwin systems, the math library never sets @code{errno}. There is
14327therefore no reason for the compiler to consider the possibility that
14328it might, and @option{-fno-math-errno} is the default.
14329
d77de738 14330@opindex funsafe-math-optimizations
ddf6fe37 14331@item -funsafe-math-optimizations
d77de738
ML
14332
14333Allow optimizations for floating-point arithmetic that (a) assume
14334that arguments and results are valid and (b) may violate IEEE or
14335ANSI standards. When used at link time, it may include libraries
14336or startup files that change the default FPU control word or other
14337similar optimizations.
14338
14339This option is not turned on by any @option{-O} option since
14340it can result in incorrect output for programs that depend on
14341an exact implementation of IEEE or ISO rules/specifications for
14342math functions. It may, however, yield faster code for programs
14343that do not require the guarantees of these specifications.
14344Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14345@option{-fassociative-math} and @option{-freciprocal-math}.
14346
14347The default is @option{-fno-unsafe-math-optimizations}.
14348
d77de738 14349@opindex fassociative-math
ddf6fe37 14350@item -fassociative-math
d77de738
ML
14351
14352Allow re-association of operands in series of floating-point operations.
14353This violates the ISO C and C++ language standard by possibly changing
14354computation result. NOTE: re-ordering may change the sign of zero as
14355well as ignore NaNs and inhibit or create underflow or overflow (and
14356thus cannot be used on code that relies on rounding behavior like
14357@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14358and thus may not be used when ordered comparisons are required.
14359This option requires that both @option{-fno-signed-zeros} and
14360@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14361much sense with @option{-frounding-math}. For Fortran the option
14362is automatically enabled when both @option{-fno-signed-zeros} and
14363@option{-fno-trapping-math} are in effect.
14364
14365The default is @option{-fno-associative-math}.
14366
d77de738 14367@opindex freciprocal-math
ddf6fe37 14368@item -freciprocal-math
d77de738
ML
14369
14370Allow the reciprocal of a value to be used instead of dividing by
14371the value if this enables optimizations. For example @code{x / y}
14372can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14373is subject to common subexpression elimination. Note that this loses
14374precision and increases the number of flops operating on the value.
14375
14376The default is @option{-fno-reciprocal-math}.
14377
d77de738 14378@opindex ffinite-math-only
ddf6fe37 14379@item -ffinite-math-only
d77de738
ML
14380Allow optimizations for floating-point arithmetic that assume
14381that arguments and results are not NaNs or +-Infs.
14382
14383This option is not turned on by any @option{-O} option since
14384it can result in incorrect output for programs that depend on
14385an exact implementation of IEEE or ISO rules/specifications for
14386math functions. It may, however, yield faster code for programs
14387that do not require the guarantees of these specifications.
14388
14389The default is @option{-fno-finite-math-only}.
14390
d77de738
ML
14391@opindex fno-signed-zeros
14392@opindex fsigned-zeros
ddf6fe37 14393@item -fno-signed-zeros
d77de738
ML
14394Allow optimizations for floating-point arithmetic that ignore the
14395signedness of zero. IEEE arithmetic specifies the behavior of
14396distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14397of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14398This option implies that the sign of a zero result isn't significant.
14399
14400The default is @option{-fsigned-zeros}.
14401
d77de738
ML
14402@opindex fno-trapping-math
14403@opindex ftrapping-math
ddf6fe37 14404@item -fno-trapping-math
d77de738
ML
14405Compile code assuming that floating-point operations cannot generate
14406user-visible traps. These traps include division by zero, overflow,
14407underflow, inexact result and invalid operation. This option requires
14408that @option{-fno-signaling-nans} be in effect. Setting this option may
14409allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14410
14411This option should never be turned on by any @option{-O} option since
14412it can result in incorrect output for programs that depend on
14413an exact implementation of IEEE or ISO rules/specifications for
14414math functions.
14415
14416The default is @option{-ftrapping-math}.
14417
14418Future versions of GCC may provide finer control of this setting
14419using C99's @code{FENV_ACCESS} pragma. This command-line option
14420will be used along with @option{-frounding-math} to specify the
14421default state for @code{FENV_ACCESS}.
14422
d77de738 14423@opindex frounding-math
ddf6fe37 14424@item -frounding-math
d77de738
ML
14425Disable transformations and optimizations that assume default floating-point
14426rounding behavior. This is round-to-zero for all floating point
14427to integer conversions, and round-to-nearest for all other arithmetic
14428truncations. This option should be specified for programs that change
14429the FP rounding mode dynamically, or that may be executed with a
14430non-default rounding mode. This option disables constant folding of
14431floating-point expressions at compile time (which may be affected by
14432rounding mode) and arithmetic transformations that are unsafe in the
14433presence of sign-dependent rounding modes.
14434
14435The default is @option{-fno-rounding-math}.
14436
14437This option is experimental and does not currently guarantee to
14438disable all GCC optimizations that are affected by rounding mode.
14439Future versions of GCC may provide finer control of this setting
14440using C99's @code{FENV_ACCESS} pragma. This command-line option
14441will be used along with @option{-ftrapping-math} to specify the
14442default state for @code{FENV_ACCESS}.
14443
d77de738 14444@opindex fsignaling-nans
ddf6fe37 14445@item -fsignaling-nans
d77de738
ML
14446Compile code assuming that IEEE signaling NaNs may generate user-visible
14447traps during floating-point operations. Setting this option disables
14448optimizations that may change the number of exceptions visible with
14449signaling NaNs. This option implies @option{-ftrapping-math}.
14450
14451This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14452be defined.
14453
14454The default is @option{-fno-signaling-nans}.
14455
14456This option is experimental and does not currently guarantee to
14457disable all GCC optimizations that affect signaling NaN behavior.
14458
d77de738
ML
14459@opindex fno-fp-int-builtin-inexact
14460@opindex ffp-int-builtin-inexact
ddf6fe37 14461@item -fno-fp-int-builtin-inexact
d77de738
ML
14462Do not allow the built-in functions @code{ceil}, @code{floor},
14463@code{round} and @code{trunc}, and their @code{float} and @code{long
14464double} variants, to generate code that raises the ``inexact''
14465floating-point exception for noninteger arguments. ISO C99 and C11
14466allow these functions to raise the ``inexact'' exception, but ISO/IEC
14467TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14468ISO C2X, does not allow these functions to do so.
14469
14470The default is @option{-ffp-int-builtin-inexact}, allowing the
14471exception to be raised, unless C2X or a later C standard is selected.
14472This option does nothing unless @option{-ftrapping-math} is in effect.
14473
14474Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14475generate a call to a library function then the ``inexact'' exception
14476may be raised if the library implementation does not follow TS 18661.
14477
d77de738 14478@opindex fsingle-precision-constant
ddf6fe37 14479@item -fsingle-precision-constant
d77de738
ML
14480Treat floating-point constants as single precision instead of
14481implicitly converting them to double-precision constants.
14482
d77de738 14483@opindex fcx-limited-range
ddf6fe37 14484@item -fcx-limited-range
d77de738
ML
14485When enabled, this option states that a range reduction step is not
14486needed when performing complex division. Also, there is no checking
14487whether the result of a complex multiplication or division is @code{NaN
14488+ I*NaN}, with an attempt to rescue the situation in that case. The
14489default is @option{-fno-cx-limited-range}, but is enabled by
14490@option{-ffast-math}.
14491
14492This option controls the default setting of the ISO C99
14493@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14494all languages.
14495
d77de738 14496@opindex fcx-fortran-rules
ddf6fe37 14497@item -fcx-fortran-rules
d77de738
ML
14498Complex multiplication and division follow Fortran rules. Range
14499reduction is done as part of complex division, but there is no checking
14500whether the result of a complex multiplication or division is @code{NaN
14501+ I*NaN}, with an attempt to rescue the situation in that case.
14502
14503The default is @option{-fno-cx-fortran-rules}.
14504
14505@end table
14506
14507The following options control optimizations that may improve
14508performance, but are not enabled by any @option{-O} options. This
14509section includes experimental options that may produce broken code.
14510
14511@table @gcctabopt
d77de738 14512@opindex fbranch-probabilities
ddf6fe37 14513@item -fbranch-probabilities
d77de738
ML
14514After running a program compiled with @option{-fprofile-arcs}
14515(@pxref{Instrumentation Options}),
14516you can compile it a second time using
14517@option{-fbranch-probabilities}, to improve optimizations based on
14518the number of times each branch was taken. When a program
14519compiled with @option{-fprofile-arcs} exits, it saves arc execution
14520counts to a file called @file{@var{sourcename}.gcda} for each source
14521file. The information in this data file is very dependent on the
14522structure of the generated code, so you must use the same source code
14523and the same optimization options for both compilations.
14524See details about the file naming in @option{-fprofile-arcs}.
14525
14526With @option{-fbranch-probabilities}, GCC puts a
14527@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14528These can be used to improve optimization. Currently, they are only
14529used in one place: in @file{reorg.cc}, instead of guessing which path a
14530branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14531exactly determine which path is taken more often.
14532
14533Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14534
d77de738 14535@opindex fprofile-values
ddf6fe37 14536@item -fprofile-values
d77de738
ML
14537If combined with @option{-fprofile-arcs}, it adds code so that some
14538data about values of expressions in the program is gathered.
14539
14540With @option{-fbranch-probabilities}, it reads back the data gathered
14541from profiling values of expressions for usage in optimizations.
14542
14543Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14544@option{-fauto-profile}.
14545
d77de738 14546@opindex fprofile-reorder-functions
ddf6fe37 14547@item -fprofile-reorder-functions
d77de738
ML
14548Function reordering based on profile instrumentation collects
14549first time of execution of a function and orders these functions
14550in ascending order.
14551
14552Enabled with @option{-fprofile-use}.
14553
d77de738 14554@opindex fvpt
ddf6fe37 14555@item -fvpt
d77de738
ML
14556If combined with @option{-fprofile-arcs}, this option instructs the compiler
14557to add code to gather information about values of expressions.
14558
14559With @option{-fbranch-probabilities}, it reads back the data gathered
14560and actually performs the optimizations based on them.
14561Currently the optimizations include specialization of division operations
14562using the knowledge about the value of the denominator.
14563
14564Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14565
d77de738 14566@opindex frename-registers
ddf6fe37 14567@item -frename-registers
d77de738
ML
14568Attempt to avoid false dependencies in scheduled code by making use
14569of registers left over after register allocation. This optimization
14570most benefits processors with lots of registers. Depending on the
14571debug information format adopted by the target, however, it can
14572make debugging impossible, since variables no longer stay in
14573a ``home register''.
14574
14575Enabled by default with @option{-funroll-loops}.
14576
d77de738 14577@opindex fschedule-fusion
ddf6fe37 14578@item -fschedule-fusion
d77de738
ML
14579Performs a target dependent pass over the instruction stream to schedule
14580instructions of same type together because target machine can execute them
14581more efficiently if they are adjacent to each other in the instruction flow.
14582
14583Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14584
d77de738 14585@opindex ftracer
ddf6fe37 14586@item -ftracer
d77de738
ML
14587Perform tail duplication to enlarge superblock size. This transformation
14588simplifies the control flow of the function allowing other optimizations to do
14589a better job.
14590
14591Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14592
d77de738 14593@opindex funroll-loops
ddf6fe37 14594@item -funroll-loops
d77de738
ML
14595Unroll loops whose number of iterations can be determined at compile time or
14596upon entry to the loop. @option{-funroll-loops} implies
14597@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14598It also turns on complete loop peeling (i.e.@: complete removal of loops with
14599a small constant number of iterations). This option makes code larger, and may
14600or may not make it run faster.
14601
14602Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14603
d77de738 14604@opindex funroll-all-loops
ddf6fe37 14605@item -funroll-all-loops
d77de738
ML
14606Unroll all loops, even if their number of iterations is uncertain when
14607the loop is entered. This usually makes programs run more slowly.
14608@option{-funroll-all-loops} implies the same options as
14609@option{-funroll-loops}.
14610
d77de738 14611@opindex fpeel-loops
ddf6fe37 14612@item -fpeel-loops
d77de738
ML
14613Peels loops for which there is enough information that they do not
14614roll much (from profile feedback or static analysis). It also turns on
14615complete loop peeling (i.e.@: complete removal of loops with small constant
14616number of iterations).
14617
14618Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14619
d77de738 14620@opindex fmove-loop-invariants
ddf6fe37 14621@item -fmove-loop-invariants
d77de738
ML
14622Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14623at level @option{-O1} and higher, except for @option{-Og}.
14624
d77de738 14625@opindex fmove-loop-stores
ddf6fe37 14626@item -fmove-loop-stores
d77de738
ML
14627Enables the loop store motion pass in the GIMPLE loop optimizer. This
14628moves invariant stores to after the end of the loop in exchange for
14629carrying the stored value in a register across the iteration.
14630Note for this option to have an effect @option{-ftree-loop-im} has to
14631be enabled as well. Enabled at level @option{-O1} and higher, except
14632for @option{-Og}.
14633
d77de738 14634@opindex fsplit-loops
ddf6fe37 14635@item -fsplit-loops
d77de738
ML
14636Split a loop into two if it contains a condition that's always true
14637for one side of the iteration space and false for the other.
14638
14639Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14640
d77de738 14641@opindex funswitch-loops
ddf6fe37 14642@item -funswitch-loops
d77de738
ML
14643Move branches with loop invariant conditions out of the loop, with duplicates
14644of the loop on both branches (modified according to result of the condition).
14645
14646Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14647
d77de738 14648@opindex fversion-loops-for-strides
ddf6fe37 14649@item -fversion-loops-for-strides
d77de738
ML
14650If a loop iterates over an array with a variable stride, create another
14651version of the loop that assumes the stride is always one. For example:
14652
14653@smallexample
14654for (int i = 0; i < n; ++i)
14655 x[i * stride] = @dots{};
14656@end smallexample
14657
14658becomes:
14659
14660@smallexample
14661if (stride == 1)
14662 for (int i = 0; i < n; ++i)
14663 x[i] = @dots{};
14664else
14665 for (int i = 0; i < n; ++i)
14666 x[i * stride] = @dots{};
14667@end smallexample
14668
14669This is particularly useful for assumed-shape arrays in Fortran where
14670(for example) it allows better vectorization assuming contiguous accesses.
14671This flag is enabled by default at @option{-O3}.
14672It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14673
d77de738
ML
14674@opindex ffunction-sections
14675@opindex fdata-sections
ddf6fe37
AA
14676@item -ffunction-sections
14677@itemx -fdata-sections
d77de738
ML
14678Place each function or data item into its own section in the output
14679file if the target supports arbitrary sections. The name of the
14680function or the name of the data item determines the section's name
14681in the output file.
14682
14683Use these options on systems where the linker can perform optimizations to
14684improve locality of reference in the instruction space. Most systems using the
14685ELF object format have linkers with such optimizations. On AIX, the linker
14686rearranges sections (CSECTs) based on the call graph. The performance impact
14687varies.
14688
14689Together with a linker garbage collection (linker @option{--gc-sections}
14690option) these options may lead to smaller statically-linked executables (after
14691stripping).
14692
14693On ELF/DWARF systems these options do not degenerate the quality of the debug
14694information. There could be issues with other object files/debug info formats.
14695
14696Only use these options when there are significant benefits from doing so. When
14697you specify these options, the assembler and linker create larger object and
14698executable files and are also slower. These options affect code generation.
14699They prevent optimizations by the compiler and assembler using relative
14700locations inside a translation unit since the locations are unknown until
14701link time. An example of such an optimization is relaxing calls to short call
14702instructions.
14703
d77de738 14704@opindex fstdarg-opt
ddf6fe37 14705@item -fstdarg-opt
d77de738
ML
14706Optimize the prologue of variadic argument functions with respect to usage of
14707those arguments.
14708
d77de738 14709@opindex fsection-anchors
ddf6fe37 14710@item -fsection-anchors
d77de738
ML
14711Try to reduce the number of symbolic address calculations by using
14712shared ``anchor'' symbols to address nearby objects. This transformation
14713can help to reduce the number of GOT entries and GOT accesses on some
14714targets.
14715
14716For example, the implementation of the following function @code{foo}:
14717
14718@smallexample
14719static int a, b, c;
14720int foo (void) @{ return a + b + c; @}
14721@end smallexample
14722
14723@noindent
14724usually calculates the addresses of all three variables, but if you
14725compile it with @option{-fsection-anchors}, it accesses the variables
14726from a common anchor point instead. The effect is similar to the
14727following pseudocode (which isn't valid C):
14728
14729@smallexample
14730int foo (void)
14731@{
14732 register int *xr = &x;
14733 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14734@}
14735@end smallexample
14736
14737Not all targets support this option.
14738
d77de738 14739@opindex fzero-call-used-regs
ddf6fe37 14740@item -fzero-call-used-regs=@var{choice}
d77de738
ML
14741Zero call-used registers at function return to increase program
14742security by either mitigating Return-Oriented Programming (ROP)
14743attacks or preventing information leakage through registers.
14744
14745The possible values of @var{choice} are the same as for the
14746@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
14747The default is @samp{skip}.
14748
14749You can control this behavior for a specific function by using the function
14750attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
14751
d77de738 14752@opindex param
ddf6fe37 14753@item --param @var{name}=@var{value}
d77de738
ML
14754In some places, GCC uses various constants to control the amount of
14755optimization that is done. For example, GCC does not inline functions
14756that contain more than a certain number of instructions. You can
14757control some of these constants on the command line using the
14758@option{--param} option.
14759
14760The names of specific parameters, and the meaning of the values, are
14761tied to the internals of the compiler, and are subject to change
14762without notice in future releases.
14763
c381327d
GP
14764In order to get the minimal, maximal and default values of a parameter,
14765use the @option{--help=param -Q} options.
d77de738
ML
14766
14767In each case, the @var{value} is an integer. The following choices
14768of @var{name} are recognized for all targets:
14769
14770@table @gcctabopt
14771@item predictable-branch-outcome
14772When branch is predicted to be taken with probability lower than this threshold
14773(in percent), then it is considered well predictable.
14774
14775@item max-rtl-if-conversion-insns
14776RTL if-conversion tries to remove conditional branches around a block and
14777replace them with conditionally executed instructions. This parameter
14778gives the maximum number of instructions in a block which should be
14779considered for if-conversion. The compiler will
14780also use other heuristics to decide whether if-conversion is likely to be
14781profitable.
14782
14783@item max-rtl-if-conversion-predictable-cost
14784RTL if-conversion will try to remove conditional branches around a block
14785and replace them with conditionally executed instructions. These parameters
14786give the maximum permissible cost for the sequence that would be generated
14787by if-conversion depending on whether the branch is statically determined
14788to be predictable or not. The units for this parameter are the same as
14789those for the GCC internal seq_cost metric. The compiler will try to
14790provide a reasonable default for this parameter using the BRANCH_COST
14791target macro.
14792
14793@item max-crossjump-edges
14794The maximum number of incoming edges to consider for cross-jumping.
14795The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
14796the number of edges incoming to each block. Increasing values mean
14797more aggressive optimization, making the compilation time increase with
14798probably small improvement in executable size.
14799
14800@item min-crossjump-insns
14801The minimum number of instructions that must be matched at the end
14802of two blocks before cross-jumping is performed on them. This
14803value is ignored in the case where all instructions in the block being
14804cross-jumped from are matched.
14805
14806@item max-grow-copy-bb-insns
14807The maximum code size expansion factor when copying basic blocks
14808instead of jumping. The expansion is relative to a jump instruction.
14809
14810@item max-goto-duplication-insns
14811The maximum number of instructions to duplicate to a block that jumps
14812to a computed goto. To avoid @math{O(N^2)} behavior in a number of
14813passes, GCC factors computed gotos early in the compilation process,
14814and unfactors them as late as possible. Only computed jumps at the
14815end of a basic blocks with no more than max-goto-duplication-insns are
14816unfactored.
14817
14818@item max-delay-slot-insn-search
14819The maximum number of instructions to consider when looking for an
14820instruction to fill a delay slot. If more than this arbitrary number of
14821instructions are searched, the time savings from filling the delay slot
14822are minimal, so stop searching. Increasing values mean more
14823aggressive optimization, making the compilation time increase with probably
14824small improvement in execution time.
14825
14826@item max-delay-slot-live-search
14827When trying to fill delay slots, the maximum number of instructions to
14828consider when searching for a block with valid live register
14829information. Increasing this arbitrarily chosen value means more
14830aggressive optimization, increasing the compilation time. This parameter
14831should be removed when the delay slot code is rewritten to maintain the
14832control-flow graph.
14833
14834@item max-gcse-memory
14835The approximate maximum amount of memory in @code{kB} that can be allocated in
14836order to perform the global common subexpression elimination
14837optimization. If more memory than specified is required, the
14838optimization is not done.
14839
14840@item max-gcse-insertion-ratio
14841If the ratio of expression insertions to deletions is larger than this value
14842for any expression, then RTL PRE inserts or removes the expression and thus
14843leaves partially redundant computations in the instruction stream.
14844
14845@item max-pending-list-length
14846The maximum number of pending dependencies scheduling allows
14847before flushing the current state and starting over. Large functions
14848with few branches or calls can create excessively large lists which
14849needlessly consume memory and resources.
14850
14851@item max-modulo-backtrack-attempts
14852The maximum number of backtrack attempts the scheduler should make
14853when modulo scheduling a loop. Larger values can exponentially increase
14854compilation time.
14855
14856@item max-inline-functions-called-once-loop-depth
14857Maximal loop depth of a call considered by inline heuristics that tries to
14858inline all functions called once.
14859
14860@item max-inline-functions-called-once-insns
14861Maximal estimated size of functions produced while inlining functions called
14862once.
14863
14864@item max-inline-insns-single
14865Several parameters control the tree inliner used in GCC@. This number sets the
14866maximum number of instructions (counted in GCC's internal representation) in a
14867single function that the tree inliner considers for inlining. This only
14868affects functions declared inline and methods implemented in a class
14869declaration (C++).
14870
14871
14872@item max-inline-insns-auto
14873When you use @option{-finline-functions} (included in @option{-O3}),
14874a lot of functions that would otherwise not be considered for inlining
14875by the compiler are investigated. To those functions, a different
14876(more restrictive) limit compared to functions declared inline can
14877be applied (@option{--param max-inline-insns-auto}).
14878
14879@item max-inline-insns-small
14880This is bound applied to calls which are considered relevant with
14881@option{-finline-small-functions}.
14882
14883@item max-inline-insns-size
14884This is bound applied to calls which are optimized for size. Small growth
14885may be desirable to anticipate optimization oppurtunities exposed by inlining.
14886
14887@item uninlined-function-insns
14888Number of instructions accounted by inliner for function overhead such as
14889function prologue and epilogue.
14890
14891@item uninlined-function-time
14892Extra time accounted by inliner for function overhead such as time needed to
14893execute function prologue and epilogue.
14894
14895@item inline-heuristics-hint-percent
14896The scale (in percents) applied to @option{inline-insns-single},
14897@option{inline-insns-single-O2}, @option{inline-insns-auto}
14898when inline heuristics hints that inlining is
14899very profitable (will enable later optimizations).
14900
14901@item uninlined-thunk-insns
14902@item uninlined-thunk-time
14903Same as @option{--param uninlined-function-insns} and
14904@option{--param uninlined-function-time} but applied to function thunks.
14905
14906@item inline-min-speedup
14907When estimated performance improvement of caller + callee runtime exceeds this
14908threshold (in percent), the function can be inlined regardless of the limit on
14909@option{--param max-inline-insns-single} and @option{--param
14910max-inline-insns-auto}.
14911
14912@item large-function-insns
14913The limit specifying really large functions. For functions larger than this
14914limit after inlining, inlining is constrained by
14915@option{--param large-function-growth}. This parameter is useful primarily
14916to avoid extreme compilation time caused by non-linear algorithms used by the
14917back end.
14918
14919@item large-function-growth
14920Specifies maximal growth of large function caused by inlining in percents.
14921For example, parameter value 100 limits large function growth to 2.0 times
14922the original size.
14923
14924@item large-unit-insns
14925The limit specifying large translation unit. Growth caused by inlining of
14926units larger than this limit is limited by @option{--param inline-unit-growth}.
14927For small units this might be too tight.
14928For example, consider a unit consisting of function A
14929that is inline and B that just calls A three times. If B is small relative to
14930A, the growth of unit is 300\% and yet such inlining is very sane. For very
14931large units consisting of small inlineable functions, however, the overall unit
14932growth limit is needed to avoid exponential explosion of code size. Thus for
14933smaller units, the size is increased to @option{--param large-unit-insns}
14934before applying @option{--param inline-unit-growth}.
14935
14936@item lazy-modules
14937Maximum number of concurrently open C++ module files when lazy loading.
14938
14939@item inline-unit-growth
14940Specifies maximal overall growth of the compilation unit caused by inlining.
14941For example, parameter value 20 limits unit growth to 1.2 times the original
14942size. Cold functions (either marked cold via an attribute or by profile
14943feedback) are not accounted into the unit size.
14944
14945@item ipa-cp-unit-growth
14946Specifies maximal overall growth of the compilation unit caused by
14947interprocedural constant propagation. For example, parameter value 10 limits
14948unit growth to 1.1 times the original size.
14949
14950@item ipa-cp-large-unit-insns
14951The size of translation unit that IPA-CP pass considers large.
14952
14953@item large-stack-frame
14954The limit specifying large stack frames. While inlining the algorithm is trying
14955to not grow past this limit too much.
14956
14957@item large-stack-frame-growth
14958Specifies maximal growth of large stack frames caused by inlining in percents.
14959For example, parameter value 1000 limits large stack frame growth to 11 times
14960the original size.
14961
14962@item max-inline-insns-recursive
14963@itemx max-inline-insns-recursive-auto
14964Specifies the maximum number of instructions an out-of-line copy of a
14965self-recursive inline
14966function can grow into by performing recursive inlining.
14967
14968@option{--param max-inline-insns-recursive} applies to functions
14969declared inline.
14970For functions not declared inline, recursive inlining
14971happens only when @option{-finline-functions} (included in @option{-O3}) is
14972enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
14973
14974@item max-inline-recursive-depth
14975@itemx max-inline-recursive-depth-auto
14976Specifies the maximum recursion depth used for recursive inlining.
14977
14978@option{--param max-inline-recursive-depth} applies to functions
14979declared inline. For functions not declared inline, recursive inlining
14980happens only when @option{-finline-functions} (included in @option{-O3}) is
14981enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
14982
14983@item min-inline-recursive-probability
14984Recursive inlining is profitable only for function having deep recursion
14985in average and can hurt for function having little recursion depth by
14986increasing the prologue size or complexity of function body to other
14987optimizers.
14988
14989When profile feedback is available (see @option{-fprofile-generate}) the actual
14990recursion depth can be guessed from the probability that function recurses
14991via a given call expression. This parameter limits inlining only to call
14992expressions whose probability exceeds the given threshold (in percents).
14993
14994@item early-inlining-insns
14995Specify growth that the early inliner can make. In effect it increases
14996the amount of inlining for code having a large abstraction penalty.
14997
14998@item max-early-inliner-iterations
14999Limit of iterations of the early inliner. This basically bounds
15000the number of nested indirect calls the early inliner can resolve.
15001Deeper chains are still handled by late inlining.
15002
15003@item comdat-sharing-probability
15004Probability (in percent) that C++ inline function with comdat visibility
15005are shared across multiple compilation units.
15006
15007@item modref-max-bases
15008@item modref-max-refs
15009@item modref-max-accesses
15010Specifies the maximal number of base pointers, references and accesses stored
15011for a single function by mod/ref analysis.
15012
15013@item modref-max-tests
15014Specifies the maxmal number of tests alias oracle can perform to disambiguate
15015memory locations using the mod/ref information. This parameter ought to be
15016bigger than @option{--param modref-max-bases} and @option{--param
15017modref-max-refs}.
15018
15019@item modref-max-depth
15020Specifies the maximum depth of DFS walk used by modref escape analysis.
15021Setting to 0 disables the analysis completely.
15022
15023@item modref-max-escape-points
15024Specifies the maximum number of escape points tracked by modref per SSA-name.
15025
15026@item modref-max-adjustments
15027Specifies the maximum number the access range is enlarged during modref dataflow
15028analysis.
15029
15030@item profile-func-internal-id
15031A parameter to control whether to use function internal id in profile
15032database lookup. If the value is 0, the compiler uses an id that
15033is based on function assembler name and filename, which makes old profile
15034data more tolerant to source changes such as function reordering etc.
15035
15036@item min-vect-loop-bound
15037The minimum number of iterations under which loops are not vectorized
15038when @option{-ftree-vectorize} is used. The number of iterations after
15039vectorization needs to be greater than the value specified by this option
15040to allow vectorization.
15041
15042@item gcse-cost-distance-ratio
15043Scaling factor in calculation of maximum distance an expression
15044can be moved by GCSE optimizations. This is currently supported only in the
15045code hoisting pass. The bigger the ratio, the more aggressive code hoisting
15046is with simple expressions, i.e., the expressions that have cost
15047less than @option{gcse-unrestricted-cost}. Specifying 0 disables
15048hoisting of simple expressions.
15049
15050@item gcse-unrestricted-cost
15051Cost, roughly measured as the cost of a single typical machine
15052instruction, at which GCSE optimizations do not constrain
15053the distance an expression can travel. This is currently
15054supported only in the code hoisting pass. The lesser the cost,
15055the more aggressive code hoisting is. Specifying 0
15056allows all expressions to travel unrestricted distances.
15057
15058@item max-hoist-depth
15059The depth of search in the dominator tree for expressions to hoist.
15060This is used to avoid quadratic behavior in hoisting algorithm.
15061The value of 0 does not limit on the search, but may slow down compilation
15062of huge functions.
15063
15064@item max-tail-merge-comparisons
15065The maximum amount of similar bbs to compare a bb with. This is used to
15066avoid quadratic behavior in tree tail merging.
15067
15068@item max-tail-merge-iterations
15069The maximum amount of iterations of the pass over the function. This is used to
15070limit compilation time in tree tail merging.
15071
15072@item store-merging-allow-unaligned
15073Allow the store merging pass to introduce unaligned stores if it is legal to
15074do so.
15075
15076@item max-stores-to-merge
15077The maximum number of stores to attempt to merge into wider stores in the store
15078merging pass.
15079
15080@item max-store-chains-to-track
15081The maximum number of store chains to track at the same time in the attempt
15082to merge them into wider stores in the store merging pass.
15083
15084@item max-stores-to-track
15085The maximum number of stores to track at the same time in the attemt to
15086to merge them into wider stores in the store merging pass.
15087
15088@item max-unrolled-insns
15089The maximum number of instructions that a loop may have to be unrolled.
15090If a loop is unrolled, this parameter also determines how many times
15091the loop code is unrolled.
15092
15093@item max-average-unrolled-insns
15094The maximum number of instructions biased by probabilities of their execution
15095that a loop may have to be unrolled. If a loop is unrolled,
15096this parameter also determines how many times the loop code is unrolled.
15097
15098@item max-unroll-times
15099The maximum number of unrollings of a single loop.
15100
15101@item max-peeled-insns
15102The maximum number of instructions that a loop may have to be peeled.
15103If a loop is peeled, this parameter also determines how many times
15104the loop code is peeled.
15105
15106@item max-peel-times
15107The maximum number of peelings of a single loop.
15108
15109@item max-peel-branches
15110The maximum number of branches on the hot path through the peeled sequence.
15111
15112@item max-completely-peeled-insns
15113The maximum number of insns of a completely peeled loop.
15114
15115@item max-completely-peel-times
15116The maximum number of iterations of a loop to be suitable for complete peeling.
15117
15118@item max-completely-peel-loop-nest-depth
15119The maximum depth of a loop nest suitable for complete peeling.
15120
15121@item max-unswitch-insns
15122The maximum number of insns of an unswitched loop.
15123
5b50850c
RB
15124@item max-unswitch-depth
15125The maximum depth of a loop nest to be unswitched.
15126
d77de738
ML
15127@item lim-expensive
15128The minimum cost of an expensive expression in the loop invariant motion.
15129
15130@item min-loop-cond-split-prob
15131When FDO profile information is available, @option{min-loop-cond-split-prob}
15132specifies minimum threshold for probability of semi-invariant condition
15133statement to trigger loop split.
15134
15135@item iv-consider-all-candidates-bound
15136Bound on number of candidates for induction variables, below which
15137all candidates are considered for each use in induction variable
15138optimizations. If there are more candidates than this,
15139only the most relevant ones are considered to avoid quadratic time complexity.
15140
15141@item iv-max-considered-uses
15142The induction variable optimizations give up on loops that contain more
15143induction variable uses.
15144
15145@item iv-always-prune-cand-set-bound
15146If the number of candidates in the set is smaller than this value,
15147always try to remove unnecessary ivs from the set
15148when adding a new one.
15149
15150@item avg-loop-niter
15151Average number of iterations of a loop.
15152
15153@item dse-max-object-size
15154Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15155Larger values may result in larger compilation times.
15156
15157@item dse-max-alias-queries-per-store
15158Maximum number of queries into the alias oracle per store.
15159Larger values result in larger compilation times and may result in more
15160removed dead stores.
15161
15162@item scev-max-expr-size
15163Bound on size of expressions used in the scalar evolutions analyzer.
15164Large expressions slow the analyzer.
15165
15166@item scev-max-expr-complexity
15167Bound on the complexity of the expressions in the scalar evolutions analyzer.
15168Complex expressions slow the analyzer.
15169
15170@item max-tree-if-conversion-phi-args
15171Maximum number of arguments in a PHI supported by TREE if conversion
15172unless the loop is marked with simd pragma.
15173
15174@item vect-max-layout-candidates
15175The maximum number of possible vector layouts (such as permutations)
15176to consider when optimizing to-be-vectorized code.
15177
15178@item vect-max-version-for-alignment-checks
15179The maximum number of run-time checks that can be performed when
15180doing loop versioning for alignment in the vectorizer.
15181
15182@item vect-max-version-for-alias-checks
15183The maximum number of run-time checks that can be performed when
15184doing loop versioning for alias in the vectorizer.
15185
15186@item vect-max-peeling-for-alignment
15187The maximum number of loop peels to enhance access alignment
15188for vectorizer. Value -1 means no limit.
15189
15190@item max-iterations-to-track
15191The maximum number of iterations of a loop the brute-force algorithm
15192for analysis of the number of iterations of the loop tries to evaluate.
15193
15194@item hot-bb-count-fraction
15195The denominator n of fraction 1/n of the maximal execution count of a
15196basic block in the entire program that a basic block needs to at least
15197have in order to be considered hot. The default is 10000, which means
15198that a basic block is considered hot if its execution count is greater
15199than 1/10000 of the maximal execution count. 0 means that it is never
15200considered hot. Used in non-LTO mode.
15201
15202@item hot-bb-count-ws-permille
15203The number of most executed permilles, ranging from 0 to 1000, of the
15204profiled execution of the entire program to which the execution count
15205of a basic block must be part of in order to be considered hot. The
15206default is 990, which means that a basic block is considered hot if
15207its execution count contributes to the upper 990 permilles, or 99.0%,
15208of the profiled execution of the entire program. 0 means that it is
15209never considered hot. Used in LTO mode.
15210
15211@item hot-bb-frequency-fraction
15212The denominator n of fraction 1/n of the execution frequency of the
15213entry block of a function that a basic block of this function needs
15214to at least have in order to be considered hot. The default is 1000,
15215which means that a basic block is considered hot in a function if it
15216is executed more frequently than 1/1000 of the frequency of the entry
15217block of the function. 0 means that it is never considered hot.
15218
15219@item unlikely-bb-count-fraction
15220The denominator n of fraction 1/n of the number of profiled runs of
15221the entire program below which the execution count of a basic block
15222must be in order for the basic block to be considered unlikely executed.
15223The default is 20, which means that a basic block is considered unlikely
15224executed if it is executed in fewer than 1/20, or 5%, of the runs of
15225the program. 0 means that it is always considered unlikely executed.
15226
15227@item max-predicted-iterations
15228The maximum number of loop iterations we predict statically. This is useful
15229in cases where a function contains a single loop with known bound and
15230another loop with unknown bound.
15231The known number of iterations is predicted correctly, while
15232the unknown number of iterations average to roughly 10. This means that the
15233loop without bounds appears artificially cold relative to the other one.
15234
15235@item builtin-expect-probability
15236Control the probability of the expression having the specified value. This
15237parameter takes a percentage (i.e.@: 0 ... 100) as input.
15238
15239@item builtin-string-cmp-inline-length
15240The maximum length of a constant string for a builtin string cmp call
15241eligible for inlining.
15242
15243@item align-threshold
15244
15245Select fraction of the maximal frequency of executions of a basic block in
15246a function to align the basic block.
15247
15248@item align-loop-iterations
15249
15250A loop expected to iterate at least the selected number of iterations is
15251aligned.
15252
15253@item tracer-dynamic-coverage
15254@itemx tracer-dynamic-coverage-feedback
15255
15256This value is used to limit superblock formation once the given percentage of
15257executed instructions is covered. This limits unnecessary code size
15258expansion.
15259
15260The @option{tracer-dynamic-coverage-feedback} parameter
15261is used only when profile
15262feedback is available. The real profiles (as opposed to statically estimated
15263ones) are much less balanced allowing the threshold to be larger value.
15264
15265@item tracer-max-code-growth
15266Stop tail duplication once code growth has reached given percentage. This is
15267a rather artificial limit, as most of the duplicates are eliminated later in
15268cross jumping, so it may be set to much higher values than is the desired code
15269growth.
15270
15271@item tracer-min-branch-ratio
15272
15273Stop reverse growth when the reverse probability of best edge is less than this
15274threshold (in percent).
15275
15276@item tracer-min-branch-probability
15277@itemx tracer-min-branch-probability-feedback
15278
15279Stop forward growth if the best edge has probability lower than this
15280threshold.
15281
15282Similarly to @option{tracer-dynamic-coverage} two parameters are
15283provided. @option{tracer-min-branch-probability-feedback} is used for
15284compilation with profile feedback and @option{tracer-min-branch-probability}
15285compilation without. The value for compilation with profile feedback
15286needs to be more conservative (higher) in order to make tracer
15287effective.
15288
15289@item stack-clash-protection-guard-size
15290Specify the size of the operating system provided stack guard as
152912 raised to @var{num} bytes. Higher values may reduce the
15292number of explicit probes, but a value larger than the operating system
15293provided guard will leave code vulnerable to stack clash style attacks.
15294
15295@item stack-clash-protection-probe-interval
15296Stack clash protection involves probing stack space as it is allocated. This
15297param controls the maximum distance between probes into the stack as 2 raised
15298to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15299larger than the operating system provided guard will leave code vulnerable to
15300stack clash style attacks.
15301
15302@item max-cse-path-length
15303
15304The maximum number of basic blocks on path that CSE considers.
15305
15306@item max-cse-insns
15307The maximum number of instructions CSE processes before flushing.
15308
15309@item ggc-min-expand
15310
15311GCC uses a garbage collector to manage its own memory allocation. This
15312parameter specifies the minimum percentage by which the garbage
15313collector's heap should be allowed to expand between collections.
15314Tuning this may improve compilation speed; it has no effect on code
15315generation.
15316
15317The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15318RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15319the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15320GCC is not able to calculate RAM on a particular platform, the lower
15321bound of 30% is used. Setting this parameter and
15322@option{ggc-min-heapsize} to zero causes a full collection to occur at
15323every opportunity. This is extremely slow, but can be useful for
15324debugging.
15325
15326@item ggc-min-heapsize
15327
15328Minimum size of the garbage collector's heap before it begins bothering
15329to collect garbage. The first collection occurs after the heap expands
15330by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15331tuning this may improve compilation speed, and has no effect on code
15332generation.
15333
15334The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15335tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15336with a lower bound of 4096 (four megabytes) and an upper bound of
15337131072 (128 megabytes). If GCC is not able to calculate RAM on a
15338particular platform, the lower bound is used. Setting this parameter
15339very large effectively disables garbage collection. Setting this
15340parameter and @option{ggc-min-expand} to zero causes a full collection
15341to occur at every opportunity.
15342
15343@item max-reload-search-insns
15344The maximum number of instruction reload should look backward for equivalent
15345register. Increasing values mean more aggressive optimization, making the
15346compilation time increase with probably slightly better performance.
15347
15348@item max-cselib-memory-locations
15349The maximum number of memory locations cselib should take into account.
15350Increasing values mean more aggressive optimization, making the compilation time
15351increase with probably slightly better performance.
15352
15353@item max-sched-ready-insns
15354The maximum number of instructions ready to be issued the scheduler should
15355consider at any given time during the first scheduling pass. Increasing
15356values mean more thorough searches, making the compilation time increase
15357with probably little benefit.
15358
15359@item max-sched-region-blocks
15360The maximum number of blocks in a region to be considered for
15361interblock scheduling.
15362
15363@item max-pipeline-region-blocks
15364The maximum number of blocks in a region to be considered for
15365pipelining in the selective scheduler.
15366
15367@item max-sched-region-insns
15368The maximum number of insns in a region to be considered for
15369interblock scheduling.
15370
15371@item max-pipeline-region-insns
15372The maximum number of insns in a region to be considered for
15373pipelining in the selective scheduler.
15374
15375@item min-spec-prob
15376The minimum probability (in percents) of reaching a source block
15377for interblock speculative scheduling.
15378
15379@item max-sched-extend-regions-iters
15380The maximum number of iterations through CFG to extend regions.
15381A value of 0 disables region extensions.
15382
15383@item max-sched-insn-conflict-delay
15384The maximum conflict delay for an insn to be considered for speculative motion.
15385
15386@item sched-spec-prob-cutoff
15387The minimal probability of speculation success (in percents), so that
15388speculative insns are scheduled.
15389
15390@item sched-state-edge-prob-cutoff
15391The minimum probability an edge must have for the scheduler to save its
15392state across it.
15393
15394@item sched-mem-true-dep-cost
15395Minimal distance (in CPU cycles) between store and load targeting same
15396memory locations.
15397
15398@item selsched-max-lookahead
15399The maximum size of the lookahead window of selective scheduling. It is a
15400depth of search for available instructions.
15401
15402@item selsched-max-sched-times
15403The maximum number of times that an instruction is scheduled during
15404selective scheduling. This is the limit on the number of iterations
15405through which the instruction may be pipelined.
15406
15407@item selsched-insns-to-rename
15408The maximum number of best instructions in the ready list that are considered
15409for renaming in the selective scheduler.
15410
15411@item sms-min-sc
15412The minimum value of stage count that swing modulo scheduler
15413generates.
15414
15415@item max-last-value-rtl
15416The maximum size measured as number of RTLs that can be recorded in an expression
15417in combiner for a pseudo register as last known value of that register.
15418
15419@item max-combine-insns
15420The maximum number of instructions the RTL combiner tries to combine.
15421
15422@item integer-share-limit
15423Small integer constants can use a shared data structure, reducing the
15424compiler's memory usage and increasing its speed. This sets the maximum
15425value of a shared integer constant.
15426
15427@item ssp-buffer-size
15428The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15429protection when @option{-fstack-protector} is used.
15430
15431@item min-size-for-stack-sharing
15432The minimum size of variables taking part in stack slot sharing when not
15433optimizing.
15434
15435@item max-jump-thread-duplication-stmts
15436Maximum number of statements allowed in a block that needs to be
15437duplicated when threading jumps.
15438
15439@item max-jump-thread-paths
15440The maximum number of paths to consider when searching for jump threading
15441opportunities. When arriving at a block, incoming edges are only considered
15442if the number of paths to be searched so far multiplied by the number of
15443incoming edges does not exhaust the specified maximum number of paths to
15444consider.
15445
15446@item max-fields-for-field-sensitive
15447Maximum number of fields in a structure treated in
15448a field sensitive manner during pointer analysis.
15449
15450@item prefetch-latency
15451Estimate on average number of instructions that are executed before
15452prefetch finishes. The distance prefetched ahead is proportional
15453to this constant. Increasing this number may also lead to less
15454streams being prefetched (see @option{simultaneous-prefetches}).
15455
15456@item simultaneous-prefetches
15457Maximum number of prefetches that can run at the same time.
15458
15459@item l1-cache-line-size
15460The size of cache line in L1 data cache, in bytes.
15461
15462@item l1-cache-size
15463The size of L1 data cache, in kilobytes.
15464
15465@item l2-cache-size
15466The size of L2 data cache, in kilobytes.
15467
15468@item prefetch-dynamic-strides
15469Whether the loop array prefetch pass should issue software prefetch hints
15470for strides that are non-constant. In some cases this may be
15471beneficial, though the fact the stride is non-constant may make it
15472hard to predict when there is clear benefit to issuing these hints.
15473
15474Set to 1 if the prefetch hints should be issued for non-constant
15475strides. Set to 0 if prefetch hints should be issued only for strides that
15476are known to be constant and below @option{prefetch-minimum-stride}.
15477
15478@item prefetch-minimum-stride
15479Minimum constant stride, in bytes, to start using prefetch hints for. If
15480the stride is less than this threshold, prefetch hints will not be issued.
15481
15482This setting is useful for processors that have hardware prefetchers, in
15483which case there may be conflicts between the hardware prefetchers and
15484the software prefetchers. If the hardware prefetchers have a maximum
15485stride they can handle, it should be used here to improve the use of
15486software prefetchers.
15487
15488A value of -1 means we don't have a threshold and therefore
15489prefetch hints can be issued for any constant stride.
15490
15491This setting is only useful for strides that are known and constant.
15492
15493@item destructive-interference-size
15494@item constructive-interference-size
15495The values for the C++17 variables
15496@code{std::hardware_destructive_interference_size} and
15497@code{std::hardware_constructive_interference_size}. The destructive
15498interference size is the minimum recommended offset between two
15499independent concurrently-accessed objects; the constructive
15500interference size is the maximum recommended size of contiguous memory
15501accessed together. Typically both will be the size of an L1 cache
15502line for the target, in bytes. For a generic target covering a range of L1
15503cache line sizes, typically the constructive interference size will be
15504the small end of the range and the destructive size will be the large
15505end.
15506
15507The destructive interference size is intended to be used for layout,
15508and thus has ABI impact. The default value is not expected to be
15509stable, and on some targets varies with @option{-mtune}, so use of
15510this variable in a context where ABI stability is important, such as
15511the public interface of a library, is strongly discouraged; if it is
15512used in that context, users can stabilize the value using this
15513option.
15514
15515The constructive interference size is less sensitive, as it is
15516typically only used in a @samp{static_assert} to make sure that a type
15517fits within a cache line.
15518
15519See also @option{-Winterference-size}.
15520
15521@item loop-interchange-max-num-stmts
15522The maximum number of stmts in a loop to be interchanged.
15523
15524@item loop-interchange-stride-ratio
15525The minimum ratio between stride of two loops for interchange to be profitable.
15526
15527@item min-insn-to-prefetch-ratio
15528The minimum ratio between the number of instructions and the
15529number of prefetches to enable prefetching in a loop.
15530
15531@item prefetch-min-insn-to-mem-ratio
15532The minimum ratio between the number of instructions and the
15533number of memory references to enable prefetching in a loop.
15534
15535@item use-canonical-types
15536Whether the compiler should use the ``canonical'' type system.
15537Should always be 1, which uses a more efficient internal
15538mechanism for comparing types in C++ and Objective-C++. However, if
15539bugs in the canonical type system are causing compilation failures,
15540set this value to 0 to disable canonical types.
15541
15542@item switch-conversion-max-branch-ratio
15543Switch initialization conversion refuses to create arrays that are
15544bigger than @option{switch-conversion-max-branch-ratio} times the number of
15545branches in the switch.
15546
15547@item max-partial-antic-length
15548Maximum length of the partial antic set computed during the tree
15549partial redundancy elimination optimization (@option{-ftree-pre}) when
15550optimizing at @option{-O3} and above. For some sorts of source code
15551the enhanced partial redundancy elimination optimization can run away,
15552consuming all of the memory available on the host machine. This
15553parameter sets a limit on the length of the sets that are computed,
15554which prevents the runaway behavior. Setting a value of 0 for
15555this parameter allows an unlimited set length.
15556
15557@item rpo-vn-max-loop-depth
15558Maximum loop depth that is value-numbered optimistically.
15559When the limit hits the innermost
15560@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15561loop nest are value-numbered optimistically and the remaining ones not.
15562
15563@item sccvn-max-alias-queries-per-access
15564Maximum number of alias-oracle queries we perform when looking for
15565redundancies for loads and stores. If this limit is hit the search
15566is aborted and the load or store is not considered redundant. The
15567number of queries is algorithmically limited to the number of
15568stores on all paths from the load to the function entry.
15569
15570@item ira-max-loops-num
15571IRA uses regional register allocation by default. If a function
15572contains more loops than the number given by this parameter, only at most
15573the given number of the most frequently-executed loops form regions
15574for regional register allocation.
15575
15576@item ira-max-conflict-table-size
15577Although IRA uses a sophisticated algorithm to compress the conflict
15578table, the table can still require excessive amounts of memory for
15579huge functions. If the conflict table for a function could be more
15580than the size in MB given by this parameter, the register allocator
15581instead uses a faster, simpler, and lower-quality
15582algorithm that does not require building a pseudo-register conflict table.
15583
15584@item ira-loop-reserved-regs
15585IRA can be used to evaluate more accurate register pressure in loops
15586for decisions to move loop invariants (see @option{-O3}). The number
15587of available registers reserved for some other purposes is given
15588by this parameter. Default of the parameter
15589is the best found from numerous experiments.
15590
15591@item ira-consider-dup-in-all-alts
15592Make IRA to consider matching constraint (duplicated operand number)
15593heavily in all available alternatives for preferred register class.
15594If it is set as zero, it means IRA only respects the matching
15595constraint when it's in the only available alternative with an
15596appropriate register class. Otherwise, it means IRA will check all
15597available alternatives for preferred register class even if it has
15598found some choice with an appropriate register class and respect the
15599found qualified matching constraint.
15600
9847c753
ML
15601@item ira-simple-lra-insn-threshold
15602Approximate function insn number in 1K units triggering simple local RA.
15603
d77de738
ML
15604@item lra-inheritance-ebb-probability-cutoff
15605LRA tries to reuse values reloaded in registers in subsequent insns.
15606This optimization is called inheritance. EBB is used as a region to
15607do this optimization. The parameter defines a minimal fall-through
15608edge probability in percentage used to add BB to inheritance EBB in
15609LRA. The default value was chosen
15610from numerous runs of SPEC2000 on x86-64.
15611
15612@item loop-invariant-max-bbs-in-loop
15613Loop invariant motion can be very expensive, both in compilation time and
15614in amount of needed compile-time memory, with very large loops. Loops
15615with more basic blocks than this parameter won't have loop invariant
15616motion optimization performed on them.
15617
15618@item loop-max-datarefs-for-datadeps
15619Building data dependencies is expensive for very large loops. This
15620parameter limits the number of data references in loops that are
15621considered for data dependence analysis. These large loops are no
15622handled by the optimizations using loop data dependencies.
15623
15624@item max-vartrack-size
15625Sets a maximum number of hash table slots to use during variable
15626tracking dataflow analysis of any function. If this limit is exceeded
15627with variable tracking at assignments enabled, analysis for that
15628function is retried without it, after removing all debug insns from
15629the function. If the limit is exceeded even without debug insns, var
15630tracking analysis is completely disabled for the function. Setting
15631the parameter to zero makes it unlimited.
15632
15633@item max-vartrack-expr-depth
15634Sets a maximum number of recursion levels when attempting to map
15635variable names or debug temporaries to value expressions. This trades
15636compilation time for more complete debug information. If this is set too
15637low, value expressions that are available and could be represented in
15638debug information may end up not being used; setting this higher may
15639enable the compiler to find more complex debug expressions, but compile
15640time and memory use may grow.
15641
15642@item max-debug-marker-count
15643Sets a threshold on the number of debug markers (e.g.@: begin stmt
15644markers) to avoid complexity explosion at inlining or expanding to RTL.
15645If a function has more such gimple stmts than the set limit, such stmts
15646will be dropped from the inlined copy of a function, and from its RTL
15647expansion.
15648
15649@item min-nondebug-insn-uid
15650Use uids starting at this parameter for nondebug insns. The range below
15651the parameter is reserved exclusively for debug insns created by
15652@option{-fvar-tracking-assignments}, but debug insns may get
15653(non-overlapping) uids above it if the reserved range is exhausted.
15654
10478270
MJ
15655@item ipa-sra-deref-prob-threshold
15656IPA-SRA replaces a pointer which is known not be NULL with one or more
15657new parameters only when the probability (in percent, relative to
15658function entry) of it being dereferenced is higher than this parameter.
15659
d77de738
ML
15660@item ipa-sra-ptr-growth-factor
15661IPA-SRA replaces a pointer to an aggregate with one or more new
15662parameters only when their cumulative size is less or equal to
15663@option{ipa-sra-ptr-growth-factor} times the size of the original
15664pointer parameter.
15665
69363825
ML
15666@item ipa-sra-ptrwrap-growth-factor
15667Additional maximum allowed growth of total size of new parameters
15668that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
15669if it points to a local variable that the caller only writes to and
15670passes it as an argument to other functions.
69363825 15671
d77de738
ML
15672@item ipa-sra-max-replacements
15673Maximum pieces of an aggregate that IPA-SRA tracks. As a
15674consequence, it is also the maximum number of replacements of a formal
15675parameter.
15676
15677@item sra-max-scalarization-size-Ospeed
15678@itemx sra-max-scalarization-size-Osize
15679The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15680replace scalar parts of aggregates with uses of independent scalar
15681variables. These parameters control the maximum size, in storage units,
15682of aggregate which is considered for replacement when compiling for
15683speed
15684(@option{sra-max-scalarization-size-Ospeed}) or size
15685(@option{sra-max-scalarization-size-Osize}) respectively.
15686
15687@item sra-max-propagations
15688The maximum number of artificial accesses that Scalar Replacement of
15689Aggregates (SRA) will track, per one local variable, in order to
15690facilitate copy propagation.
15691
15692@item tm-max-aggregate-size
15693When making copies of thread-local variables in a transaction, this
15694parameter specifies the size in bytes after which variables are
15695saved with the logging functions as opposed to save/restore code
15696sequence pairs. This option only applies when using
15697@option{-fgnu-tm}.
15698
15699@item graphite-max-nb-scop-params
15700To avoid exponential effects in the Graphite loop transforms, the
15701number of parameters in a Static Control Part (SCoP) is bounded.
15702A value of zero can be used to lift
15703the bound. A variable whose value is unknown at compilation time and
15704defined outside a SCoP is a parameter of the SCoP.
15705
15706@item loop-block-tile-size
15707Loop blocking or strip mining transforms, enabled with
15708@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15709loop in the loop nest by a given number of iterations. The strip
15710length can be changed using the @option{loop-block-tile-size}
15711parameter.
15712
15713@item ipa-jump-function-lookups
15714Specifies number of statements visited during jump function offset discovery.
15715
15716@item ipa-cp-value-list-size
15717IPA-CP attempts to track all possible values and types passed to a function's
15718parameter in order to propagate them and perform devirtualization.
15719@option{ipa-cp-value-list-size} is the maximum number of values and types it
15720stores per one formal parameter of a function.
15721
15722@item ipa-cp-eval-threshold
15723IPA-CP calculates its own score of cloning profitability heuristics
15724and performs those cloning opportunities with scores that exceed
15725@option{ipa-cp-eval-threshold}.
15726
15727@item ipa-cp-max-recursive-depth
15728Maximum depth of recursive cloning for self-recursive function.
15729
15730@item ipa-cp-min-recursive-probability
15731Recursive cloning only when the probability of call being executed exceeds
15732the parameter.
15733
15734@item ipa-cp-profile-count-base
15735When using @option{-fprofile-use} option, IPA-CP will consider the measured
15736execution count of a call graph edge at this percentage position in their
15737histogram as the basis for its heuristics calculation.
15738
15739@item ipa-cp-recursive-freq-factor
15740The number of times interprocedural copy propagation expects recursive
15741functions to call themselves.
15742
15743@item ipa-cp-recursion-penalty
15744Percentage penalty the recursive functions will receive when they
15745are evaluated for cloning.
15746
15747@item ipa-cp-single-call-penalty
15748Percentage penalty functions containing a single call to another
15749function will receive when they are evaluated for cloning.
15750
15751@item ipa-max-agg-items
15752IPA-CP is also capable to propagate a number of scalar values passed
15753in an aggregate. @option{ipa-max-agg-items} controls the maximum
15754number of such values per one parameter.
15755
15756@item ipa-cp-loop-hint-bonus
15757When IPA-CP determines that a cloning candidate would make the number
15758of iterations of a loop known, it adds a bonus of
15759@option{ipa-cp-loop-hint-bonus} to the profitability score of
15760the candidate.
15761
15762@item ipa-max-loop-predicates
15763The maximum number of different predicates IPA will use to describe when
15764loops in a function have known properties.
15765
15766@item ipa-max-aa-steps
15767During its analysis of function bodies, IPA-CP employs alias analysis
15768in order to track values pointed to by function parameters. In order
15769not spend too much time analyzing huge functions, it gives up and
15770consider all memory clobbered after examining
15771@option{ipa-max-aa-steps} statements modifying memory.
15772
15773@item ipa-max-switch-predicate-bounds
15774Maximal number of boundary endpoints of case ranges of switch statement.
15775For switch exceeding this limit, IPA-CP will not construct cloning cost
15776predicate, which is used to estimate cloning benefit, for default case
15777of the switch statement.
15778
15779@item ipa-max-param-expr-ops
15780IPA-CP will analyze conditional statement that references some function
15781parameter to estimate benefit for cloning upon certain constant value.
15782But if number of operations in a parameter expression exceeds
15783@option{ipa-max-param-expr-ops}, the expression is treated as complicated
15784one, and is not handled by IPA analysis.
15785
15786@item lto-partitions
15787Specify desired number of partitions produced during WHOPR compilation.
15788The number of partitions should exceed the number of CPUs used for compilation.
15789
15790@item lto-min-partition
15791Size of minimal partition for WHOPR (in estimated instructions).
15792This prevents expenses of splitting very small programs into too many
15793partitions.
15794
15795@item lto-max-partition
15796Size of max partition for WHOPR (in estimated instructions).
15797to provide an upper bound for individual size of partition.
15798Meant to be used only with balanced partitioning.
15799
15800@item lto-max-streaming-parallelism
15801Maximal number of parallel processes used for LTO streaming.
15802
15803@item cxx-max-namespaces-for-diagnostic-help
15804The maximum number of namespaces to consult for suggestions when C++
15805name lookup fails for an identifier.
15806
15807@item sink-frequency-threshold
15808The maximum relative execution frequency (in percents) of the target block
15809relative to a statement's original block to allow statement sinking of a
15810statement. Larger numbers result in more aggressive statement sinking.
15811A small positive adjustment is applied for
15812statements with memory operands as those are even more profitable so sink.
15813
15814@item max-stores-to-sink
15815The maximum number of conditional store pairs that can be sunk. Set to 0
15816if either vectorization (@option{-ftree-vectorize}) or if-conversion
15817(@option{-ftree-loop-if-convert}) is disabled.
15818
15819@item case-values-threshold
15820The smallest number of different values for which it is best to use a
15821jump-table instead of a tree of conditional branches. If the value is
158220, use the default for the machine.
15823
15824@item jump-table-max-growth-ratio-for-size
15825The maximum code size growth ratio when expanding
15826into a jump table (in percent). The parameter is used when
15827optimizing for size.
15828
15829@item jump-table-max-growth-ratio-for-speed
15830The maximum code size growth ratio when expanding
15831into a jump table (in percent). The parameter is used when
15832optimizing for speed.
15833
15834@item tree-reassoc-width
15835Set the maximum number of instructions executed in parallel in
15836reassociated tree. This parameter overrides target dependent
15837heuristics used by default if has non zero value.
15838
15839@item sched-pressure-algorithm
15840Choose between the two available implementations of
15841@option{-fsched-pressure}. Algorithm 1 is the original implementation
15842and is the more likely to prevent instructions from being reordered.
15843Algorithm 2 was designed to be a compromise between the relatively
15844conservative approach taken by algorithm 1 and the rather aggressive
15845approach taken by the default scheduler. It relies more heavily on
15846having a regular register file and accurate register pressure classes.
15847See @file{haifa-sched.cc} in the GCC sources for more details.
15848
15849The default choice depends on the target.
15850
15851@item max-slsr-cand-scan
15852Set the maximum number of existing candidates that are considered when
15853seeking a basis for a new straight-line strength reduction candidate.
15854
15855@item asan-globals
15856Enable buffer overflow detection for global objects. This kind
15857of protection is enabled by default if you are using
15858@option{-fsanitize=address} option.
15859To disable global objects protection use @option{--param asan-globals=0}.
15860
15861@item asan-stack
15862Enable buffer overflow detection for stack objects. This kind of
15863protection is enabled by default when using @option{-fsanitize=address}.
15864To disable stack protection use @option{--param asan-stack=0} option.
15865
15866@item asan-instrument-reads
15867Enable buffer overflow detection for memory reads. This kind of
15868protection is enabled by default when using @option{-fsanitize=address}.
15869To disable memory reads protection use
15870@option{--param asan-instrument-reads=0}.
15871
15872@item asan-instrument-writes
15873Enable buffer overflow detection for memory writes. This kind of
15874protection is enabled by default when using @option{-fsanitize=address}.
15875To disable memory writes protection use
15876@option{--param asan-instrument-writes=0} option.
15877
15878@item asan-memintrin
15879Enable detection for built-in functions. This kind of protection
15880is enabled by default when using @option{-fsanitize=address}.
15881To disable built-in functions protection use
15882@option{--param asan-memintrin=0}.
15883
15884@item asan-use-after-return
15885Enable detection of use-after-return. This kind of protection
15886is enabled by default when using the @option{-fsanitize=address} option.
15887To disable it use @option{--param asan-use-after-return=0}.
15888
15889Note: By default the check is disabled at run time. To enable it,
15890add @code{detect_stack_use_after_return=1} to the environment variable
15891@env{ASAN_OPTIONS}.
15892
15893@item asan-instrumentation-with-call-threshold
15894If number of memory accesses in function being instrumented
15895is greater or equal to this number, use callbacks instead of inline checks.
15896E.g. to disable inline code use
15897@option{--param asan-instrumentation-with-call-threshold=0}.
15898
545c9f8b 15899@item asan-kernel-mem-intrinsic-prefix
f56ed5b3
SL
15900If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
15901with @samp{__asan_} or @samp{__hwasan_}
15902for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
15903respectively.
545c9f8b 15904
d77de738
ML
15905@item hwasan-instrument-stack
15906Enable hwasan instrumentation of statically sized stack-allocated variables.
15907This kind of instrumentation is enabled by default when using
15908@option{-fsanitize=hwaddress} and disabled by default when using
15909@option{-fsanitize=kernel-hwaddress}.
15910To disable stack instrumentation use
15911@option{--param hwasan-instrument-stack=0}, and to enable it use
15912@option{--param hwasan-instrument-stack=1}.
15913
15914@item hwasan-random-frame-tag
15915When using stack instrumentation, decide tags for stack variables using a
15916deterministic sequence beginning at a random tag for each frame. With this
15917parameter unset tags are chosen using the same sequence but beginning from 1.
15918This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
15919for @option{-fsanitize=kernel-hwaddress}.
15920To disable it use @option{--param hwasan-random-frame-tag=0}.
15921
15922@item hwasan-instrument-allocas
15923Enable hwasan instrumentation of dynamically sized stack-allocated variables.
15924This kind of instrumentation is enabled by default when using
15925@option{-fsanitize=hwaddress} and disabled by default when using
15926@option{-fsanitize=kernel-hwaddress}.
15927To disable instrumentation of such variables use
15928@option{--param hwasan-instrument-allocas=0}, and to enable it use
15929@option{--param hwasan-instrument-allocas=1}.
15930
15931@item hwasan-instrument-reads
15932Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
15933default for both @option{-fsanitize=hwaddress} and
15934@option{-fsanitize=kernel-hwaddress}.
15935To disable checking memory reads use
15936@option{--param hwasan-instrument-reads=0}.
15937
15938@item hwasan-instrument-writes
15939Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
15940default for both @option{-fsanitize=hwaddress} and
15941@option{-fsanitize=kernel-hwaddress}.
15942To disable checking memory writes use
15943@option{--param hwasan-instrument-writes=0}.
15944
15945@item hwasan-instrument-mem-intrinsics
15946Enable hwasan instrumentation of builtin functions. Instrumentation of these
15947builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
15948and @option{-fsanitize=kernel-hwaddress}.
15949To disable instrumentation of builtin functions use
15950@option{--param hwasan-instrument-mem-intrinsics=0}.
15951
15952@item use-after-scope-direct-emission-threshold
15953If the size of a local variable in bytes is smaller or equal to this
15954number, directly poison (or unpoison) shadow memory instead of using
15955run-time callbacks.
15956
15957@item tsan-distinguish-volatile
15958Emit special instrumentation for accesses to volatiles.
15959
15960@item tsan-instrument-func-entry-exit
15961Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
15962
15963@item max-fsm-thread-path-insns
15964Maximum number of instructions to copy when duplicating blocks on a
15965finite state automaton jump thread path.
15966
15967@item threader-debug
15968threader-debug=[none|all] Enables verbose dumping of the threader solver.
15969
15970@item parloops-chunk-size
15971Chunk size of omp schedule for loops parallelized by parloops.
15972
15973@item parloops-schedule
15974Schedule type of omp schedule for loops parallelized by parloops (static,
15975dynamic, guided, auto, runtime).
15976
15977@item parloops-min-per-thread
15978The minimum number of iterations per thread of an innermost parallelized
15979loop for which the parallelized variant is preferred over the single threaded
15980one. Note that for a parallelized loop nest the
15981minimum number of iterations of the outermost loop per thread is two.
15982
15983@item max-ssa-name-query-depth
15984Maximum depth of recursion when querying properties of SSA names in things
15985like fold routines. One level of recursion corresponds to following a
15986use-def chain.
15987
15988@item max-speculative-devirt-maydefs
15989The maximum number of may-defs we analyze when looking for a must-def
15990specifying the dynamic type of an object that invokes a virtual call
15991we may be able to devirtualize speculatively.
15992
d77de738
ML
15993@item ranger-debug
15994Specifies the type of debug output to be issued for ranges.
15995
d77de738
ML
15996@item unroll-jam-min-percent
15997The minimum percentage of memory references that must be optimized
15998away for the unroll-and-jam transformation to be considered profitable.
15999
16000@item unroll-jam-max-unroll
16001The maximum number of times the outer loop should be unrolled by
16002the unroll-and-jam transformation.
16003
16004@item max-rtl-if-conversion-unpredictable-cost
16005Maximum permissible cost for the sequence that would be generated
16006by the RTL if-conversion pass for a branch that is considered unpredictable.
16007
16008@item max-variable-expansions-in-unroller
16009If @option{-fvariable-expansion-in-unroller} is used, the maximum number
16010of times that an individual variable will be expanded during loop unrolling.
16011
16012@item partial-inlining-entry-probability
16013Maximum probability of the entry BB of split region
16014(in percent relative to entry BB of the function)
16015to make partial inlining happen.
16016
16017@item max-tracked-strlens
16018Maximum number of strings for which strlen optimization pass will
16019track string lengths.
16020
16021@item gcse-after-reload-partial-fraction
16022The threshold ratio for performing partial redundancy
16023elimination after reload.
16024
16025@item gcse-after-reload-critical-fraction
16026The threshold ratio of critical edges execution count that
16027permit performing redundancy elimination after reload.
16028
16029@item max-loop-header-insns
16030The maximum number of insns in loop header duplicated
16031by the copy loop headers pass.
16032
16033@item vect-epilogues-nomask
16034Enable loop epilogue vectorization using smaller vector size.
16035
16036@item vect-partial-vector-usage
16037Controls when the loop vectorizer considers using partial vector loads
16038and stores as an alternative to falling back to scalar code. 0 stops
16039the vectorizer from ever using partial vector loads and stores. 1 allows
16040partial vector loads and stores if vectorization removes the need for the
16041code to iterate. 2 allows partial vector loads and stores in all loops.
16042The parameter only has an effect on targets that support partial
16043vector loads and stores.
16044
16045@item vect-inner-loop-cost-factor
16046The maximum factor which the loop vectorizer applies to the cost of statements
16047in an inner loop relative to the loop being vectorized. The factor applied
16048is the maximum of the estimated number of iterations of the inner loop and
16049this parameter. The default value of this parameter is 50.
16050
16051@item vect-induction-float
16052Enable loop vectorization of floating point inductions.
16053
cbe32d38
ML
16054@item vrp-sparse-threshold
16055Maximum number of basic blocks before VRP uses a sparse bitmap cache.
16056
16057@item vrp-switch-limit
16058Maximum number of outgoing edges in a switch before VRP will not process it.
16059
16060@item vrp-vector-threshold
16061Maximum number of basic blocks for VRP to use a basic cache vector.
16062
d77de738
ML
16063@item avoid-fma-max-bits
16064Maximum number of bits for which we avoid creating FMAs.
16065
16066@item sms-loop-average-count-threshold
16067A threshold on the average loop count considered by the swing modulo scheduler.
16068
16069@item sms-dfa-history
16070The number of cycles the swing modulo scheduler considers when checking
16071conflicts using DFA.
16072
16073@item graphite-allow-codegen-errors
16074Whether codegen errors should be ICEs when @option{-fchecking}.
16075
16076@item sms-max-ii-factor
16077A factor for tuning the upper bound that swing modulo scheduler
16078uses for scheduling a loop.
16079
16080@item lra-max-considered-reload-pseudos
16081The max number of reload pseudos which are considered during
16082spilling a non-reload pseudo.
16083
16084@item max-pow-sqrt-depth
16085Maximum depth of sqrt chains to use when synthesizing exponentiation
16086by a real constant.
16087
16088@item max-dse-active-local-stores
16089Maximum number of active local stores in RTL dead store elimination.
16090
16091@item asan-instrument-allocas
16092Enable asan allocas/VLAs protection.
16093
16094@item max-iterations-computation-cost
16095Bound on the cost of an expression to compute the number of iterations.
16096
16097@item max-isl-operations
16098Maximum number of isl operations, 0 means unlimited.
16099
16100@item graphite-max-arrays-per-scop
16101Maximum number of arrays per scop.
16102
16103@item max-vartrack-reverse-op-size
16104Max. size of loc list for which reverse ops should be added.
16105
16106@item fsm-scale-path-stmts
16107Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
16108crossing a loop backedge when comparing to
16109@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
16110
16111@item uninit-control-dep-attempts
16112Maximum number of nested calls to search for control dependencies
16113during uninitialized variable analysis.
16114
d77de738
ML
16115@item sched-autopref-queue-depth
16116Hardware autoprefetcher scheduler model control flag.
16117Number of lookahead cycles the model looks into; at '
16118' only enable instruction sorting heuristic.
16119
16120@item loop-versioning-max-inner-insns
16121The maximum number of instructions that an inner loop can have
16122before the loop versioning pass considers it too big to copy.
16123
16124@item loop-versioning-max-outer-insns
16125The maximum number of instructions that an outer loop can have
16126before the loop versioning pass considers it too big to copy,
16127discounting any instructions in inner loops that directly benefit
16128from versioning.
16129
16130@item ssa-name-def-chain-limit
16131The maximum number of SSA_NAME assignments to follow in determining
16132a property of a variable such as its value. This limits the number
16133of iterations or recursive calls GCC performs when optimizing certain
16134statements or when determining their validity prior to issuing
16135diagnostics.
16136
16137@item store-merging-max-size
16138Maximum size of a single store merging region in bytes.
16139
16140@item hash-table-verification-limit
16141The number of elements for which hash table verification is done
16142for each searched element.
16143
16144@item max-find-base-term-values
16145Maximum number of VALUEs handled during a single find_base_term call.
16146
16147@item analyzer-max-enodes-per-program-point
16148The maximum number of exploded nodes per program point within
16149the analyzer, before terminating analysis of that point.
16150
16151@item analyzer-max-constraints
16152The maximum number of constraints per state.
16153
16154@item analyzer-min-snodes-for-call-summary
16155The minimum number of supernodes within a function for the
16156analyzer to consider summarizing its effects at call sites.
16157
16158@item analyzer-max-enodes-for-full-dump
16159The maximum depth of exploded nodes that should appear in a dot dump
16160before switching to a less verbose format.
16161
16162@item analyzer-max-recursion-depth
16163The maximum number of times a callsite can appear in a call stack
16164within the analyzer, before terminating analysis of a call that would
16165recurse deeper.
16166
16167@item analyzer-max-svalue-depth
16168The maximum depth of a symbolic value, before approximating
16169the value as unknown.
16170
16171@item analyzer-max-infeasible-edges
16172The maximum number of infeasible edges to reject before declaring
16173a diagnostic as infeasible.
16174
16175@item gimple-fe-computed-hot-bb-threshold
16176The number of executions of a basic block which is considered hot.
16177The parameter is used only in GIMPLE FE.
16178
16179@item analyzer-bb-explosion-factor
16180The maximum number of 'after supernode' exploded nodes within the analyzer
16181per supernode, before terminating analysis.
16182
16183@item ranger-logical-depth
16184Maximum depth of logical expression evaluation ranger will look through
16185when evaluating outgoing edge ranges.
16186
9fd6d83a
ML
16187@item ranger-recompute-depth
16188Maximum depth of instruction chains to consider for recomputation
16189in the outgoing range calculator.
16190
d77de738
ML
16191@item relation-block-limit
16192Maximum number of relations the oracle will register in a basic block.
16193
16194@item min-pagesize
16195Minimum page size for warning purposes.
16196
16197@item openacc-kernels
16198Specify mode of OpenACC `kernels' constructs handling.
16199With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16200constructs are decomposed into parts, a sequence of compute
16201constructs, each then handled individually.
16202This is work in progress.
16203With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16204constructs are handled by the @samp{parloops} pass, en bloc.
16205This is the current default.
16206
16207@item openacc-privatization
4ace81b6
SL
16208Control whether the @option{-fopt-info-omp-note} and applicable
16209@option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
d77de738
ML
16210With @option{--param=openacc-privatization=quiet}, don't diagnose.
16211This is the current default.
16212With @option{--param=openacc-privatization=noisy}, do diagnose.
16213
16214@end table
16215
16216The following choices of @var{name} are available on AArch64 targets:
16217
16218@table @gcctabopt
16219@item aarch64-sve-compare-costs
16220When vectorizing for SVE, consider using ``unpacked'' vectors for
16221smaller elements and use the cost model to pick the cheapest approach.
16222Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16223
16224Using unpacked vectors includes storing smaller elements in larger
16225containers and accessing elements with extending loads and truncating
16226stores.
16227
16228@item aarch64-float-recp-precision
16229The number of Newton iterations for calculating the reciprocal for float type.
16230The precision of division is proportional to this param when division
16231approximation is enabled. The default value is 1.
16232
16233@item aarch64-double-recp-precision
16234The number of Newton iterations for calculating the reciprocal for double type.
16235The precision of division is propotional to this param when division
16236approximation is enabled. The default value is 2.
16237
16238@item aarch64-autovec-preference
16239Force an ISA selection strategy for auto-vectorization. Accepts values from
162400 to 4, inclusive.
16241@table @samp
16242@item 0
16243Use the default heuristics.
16244@item 1
16245Use only Advanced SIMD for auto-vectorization.
16246@item 2
16247Use only SVE for auto-vectorization.
16248@item 3
16249Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16250deemed equal.
16251@item 4
16252Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16253@end table
16254The default value is 0.
16255
16256@item aarch64-loop-vect-issue-rate-niters
16257The tuning for some AArch64 CPUs tries to take both latencies and issue
16258rates into account when deciding whether a loop should be vectorized
16259using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16260If this parameter is set to @var{n}, GCC will not use this heuristic
16261for loops that are known to execute in fewer than @var{n} Advanced
16262SIMD iterations.
16263
16264@item aarch64-vect-unroll-limit
16265The vectorizer will use available tuning information to determine whether it
16266would be beneficial to unroll the main vectorized loop and by how much. This
16267parameter set's the upper bound of how much the vectorizer will unroll the main
16268loop. The default value is four.
16269
16270@end table
16271
16272The following choices of @var{name} are available on i386 and x86_64 targets:
16273
16274@table @gcctabopt
16275@item x86-stlf-window-ninsns
16276Instructions number above which STFL stall penalty can be compensated.
16277
60101899
RB
16278@item x86-stv-max-visits
16279The maximum number of use and def visits when discovering a STV chain before
16280the discovery is aborted.
16281
d77de738
ML
16282@end table
16283
16284@end table
16285
16286@node Instrumentation Options
16287@section Program Instrumentation Options
16288@cindex instrumentation options
16289@cindex program instrumentation options
16290@cindex run-time error checking options
16291@cindex profiling options
16292@cindex options, program instrumentation
16293@cindex options, run-time error checking
16294@cindex options, profiling
16295
16296GCC supports a number of command-line options that control adding
16297run-time instrumentation to the code it normally generates.
16298For example, one purpose of instrumentation is collect profiling
16299statistics for use in finding program hot spots, code coverage
16300analysis, or profile-guided optimizations.
16301Another class of program instrumentation is adding run-time checking
16302to detect programming errors like invalid pointer
16303dereferences or out-of-bounds array accesses, as well as deliberately
16304hostile attacks such as stack smashing or C++ vtable hijacking.
16305There is also a general hook which can be used to implement other
16306forms of tracing or function-level instrumentation for debug or
16307program analysis purposes.
16308
16309@table @gcctabopt
16310@cindex @command{prof}
16311@cindex @command{gprof}
d77de738
ML
16312@opindex p
16313@opindex pg
ddf6fe37
AA
16314@item -p
16315@itemx -pg
d77de738
ML
16316Generate extra code to write profile information suitable for the
16317analysis program @command{prof} (for @option{-p}) or @command{gprof}
16318(for @option{-pg}). You must use this option when compiling
16319the source files you want data about, and you must also use it when
16320linking.
16321
16322You can use the function attribute @code{no_instrument_function} to
16323suppress profiling of individual functions when compiling with these options.
16324@xref{Common Function Attributes}.
16325
d77de738 16326@opindex fprofile-arcs
ddf6fe37 16327@item -fprofile-arcs
d77de738
ML
16328Add code so that program flow @dfn{arcs} are instrumented. During
16329execution the program records how many times each branch and call is
16330executed and how many times it is taken or returns. On targets that support
16331constructors with priority support, profiling properly handles constructors,
16332destructors and C++ constructors (and destructors) of classes which are used
16333as a type of a global variable.
16334
16335When the compiled
16336program exits it saves this data to a file called
16337@file{@var{auxname}.gcda} for each source file. The data may be used for
16338profile-directed optimizations (@option{-fbranch-probabilities}), or for
16339test coverage analysis (@option{-ftest-coverage}). Each object file's
16340@var{auxname} is generated from the name of the output file, if
16341explicitly specified and it is not the final executable, otherwise it is
16342the basename of the source file. In both cases any suffix is removed
16343(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16344@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16345
16346Note that if a command line directly links source files, the corresponding
16347@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16348E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16349@file{binary-b.gcda} files.
16350
16351@xref{Cross-profiling}.
16352
16353@cindex @command{gcov}
d77de738 16354@opindex coverage
ddf6fe37 16355@item --coverage
d77de738
ML
16356
16357This option is used to compile and link code instrumented for coverage
16358analysis. The option is a synonym for @option{-fprofile-arcs}
16359@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16360linking). See the documentation for those options for more details.
16361
16362@itemize
16363
16364@item
16365Compile the source files with @option{-fprofile-arcs} plus optimization
16366and code generation options. For test coverage analysis, use the
16367additional @option{-ftest-coverage} option. You do not need to profile
16368every source file in a program.
16369
16370@item
16371Compile the source files additionally with @option{-fprofile-abs-path}
16372to create absolute path names in the @file{.gcno} files. This allows
16373@command{gcov} to find the correct sources in projects where compilations
16374occur with different working directories.
16375
16376@item
16377Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16378(the latter implies the former).
16379
16380@item
16381Run the program on a representative workload to generate the arc profile
16382information. This may be repeated any number of times. You can run
16383concurrent instances of your program, and provided that the file system
16384supports locking, the data files will be correctly updated. Unless
16385a strict ISO C dialect option is in effect, @code{fork} calls are
16386detected and correctly handled without double counting.
16387
16388Moreover, an object file can be recompiled multiple times
16389and the corresponding @file{.gcda} file merges as long as
16390the source file and the compiler options are unchanged.
16391
16392@item
16393For profile-directed optimizations, compile the source files again with
16394the same optimization and code generation options plus
16395@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16396Control Optimization}).
16397
16398@item
16399For test coverage analysis, use @command{gcov} to produce human readable
16400information from the @file{.gcno} and @file{.gcda} files. Refer to the
16401@command{gcov} documentation for further information.
16402
16403@end itemize
16404
16405With @option{-fprofile-arcs}, for each function of your program GCC
16406creates a program flow graph, then finds a spanning tree for the graph.
16407Only arcs that are not on the spanning tree have to be instrumented: the
16408compiler adds code to count the number of times that these arcs are
16409executed. When an arc is the only exit or only entrance to a block, the
16410instrumentation code can be added to the block; otherwise, a new basic
16411block must be created to hold the instrumentation code.
16412
16413@need 2000
d77de738 16414@opindex ftest-coverage
ddf6fe37 16415@item -ftest-coverage
d77de738
ML
16416Produce a notes file that the @command{gcov} code-coverage utility
16417(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16418show program coverage. Each source file's note file is called
16419@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16420above for a description of @var{auxname} and instructions on how to
16421generate test coverage data. Coverage data matches the source files
16422more closely if you do not optimize.
16423
d77de738 16424@opindex fprofile-abs-path
ddf6fe37 16425@item -fprofile-abs-path
d77de738
ML
16426Automatically convert relative source file names to absolute path names
16427in the @file{.gcno} files. This allows @command{gcov} to find the correct
16428sources in projects where compilations occur with different working
16429directories.
16430
d77de738 16431@opindex fprofile-dir
ddf6fe37 16432@item -fprofile-dir=@var{path}
d77de738
ML
16433
16434Set the directory to search for the profile data files in to @var{path}.
16435This option affects only the profile data generated by
16436@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16437and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16438and its related options. Both absolute and relative paths can be used.
16439By default, GCC uses the current directory as @var{path}, thus the
16440profile data file appears in the same directory as the object file.
16441In order to prevent the file name clashing, if the object file name is
16442not an absolute path, we mangle the absolute path of the
16443@file{@var{sourcename}.gcda} file and use it as the file name of a
16444@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16445See similar option @option{-fprofile-note}.
16446
16447When an executable is run in a massive parallel environment, it is recommended
16448to save profile to different folders. That can be done with variables
16449in @var{path} that are exported during run-time:
16450
16451@table @gcctabopt
16452
16453@item %p
16454process ID.
16455
16456@item %q@{VAR@}
16457value of environment variable @var{VAR}
16458
16459@end table
16460
ddf6fe37 16461@opindex fprofile-generate
d77de738
ML
16462@item -fprofile-generate
16463@itemx -fprofile-generate=@var{path}
d77de738
ML
16464
16465Enable options usually used for instrumenting application to produce
16466profile useful for later recompilation with profile feedback based
16467optimization. You must use @option{-fprofile-generate} both when
16468compiling and when linking your program.
16469
16470The following options are enabled:
16471@option{-fprofile-arcs}, @option{-fprofile-values},
16472@option{-finline-functions}, and @option{-fipa-bit-cp}.
16473
16474If @var{path} is specified, GCC looks at the @var{path} to find
16475the profile feedback data files. See @option{-fprofile-dir}.
16476
16477To optimize the program based on the collected profile information, use
16478@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16479
ddf6fe37 16480@opindex fprofile-info-section
d77de738
ML
16481@item -fprofile-info-section
16482@itemx -fprofile-info-section=@var{name}
d77de738
ML
16483
16484Register the profile information in the specified section instead of using a
16485constructor/destructor. The section name is @var{name} if it is specified,
16486otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16487profile information generated by @option{-fprofile-arcs} is placed in the
16488specified section for each translation unit. This option disables the profile
16489information registration through a constructor and it disables the profile
16490information processing through a destructor. This option is not intended to be
16491used in hosted environments such as GNU/Linux. It targets freestanding
16492environments (for example embedded systems) with limited resources which do not
16493support constructors/destructors or the C library file I/O.
16494
16495The linker could collect the input sections in a continuous memory block and
16496define start and end symbols. A GNU linker script example which defines a
16497linker output section follows:
16498
16499@smallexample
16500 .gcov_info :
16501 @{
16502 PROVIDE (__gcov_info_start = .);
16503 KEEP (*(.gcov_info))
16504 PROVIDE (__gcov_info_end = .);
16505 @}
16506@end smallexample
16507
16508The program could dump the profiling information registered in this linker set
16509for example like this:
16510
16511@smallexample
16512#include <gcov.h>
16513#include <stdio.h>
16514#include <stdlib.h>
16515
16516extern const struct gcov_info *const __gcov_info_start[];
16517extern const struct gcov_info *const __gcov_info_end[];
16518
16519static void
16520dump (const void *d, unsigned n, void *arg)
16521@{
16522 const unsigned char *c = d;
16523
16524 for (unsigned i = 0; i < n; ++i)
16525 printf ("%02x", c[i]);
16526@}
16527
16528static void
16529filename (const char *f, void *arg)
16530@{
16531 __gcov_filename_to_gcfn (f, dump, arg );
16532@}
16533
16534static void *
16535allocate (unsigned length, void *arg)
16536@{
16537 return malloc (length);
16538@}
16539
16540static void
16541dump_gcov_info (void)
16542@{
16543 const struct gcov_info *const *info = __gcov_info_start;
16544 const struct gcov_info *const *end = __gcov_info_end;
16545
16546 /* Obfuscate variable to prevent compiler optimizations. */
16547 __asm__ ("" : "+r" (info));
16548
16549 while (info != end)
16550 @{
16551 void *arg = NULL;
16552 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16553 putchar ('\n');
16554 ++info;
16555 @}
16556@}
16557
16558int
16559main (void)
16560@{
16561 dump_gcov_info ();
16562 return 0;
16563@}
16564@end smallexample
16565
16566The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16567deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16568@code{__gcov_info_to_gcda} functions and merge the profile information into
16569@file{.gcda} files on the host filesystem.
16570
d77de738 16571@opindex fprofile-note
ddf6fe37 16572@item -fprofile-note=@var{path}
d77de738
ML
16573
16574If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16575location. If you combine the option with multiple source files,
16576the @file{.gcno} file will be overwritten.
16577
d77de738 16578@opindex fprofile-prefix-path
ddf6fe37 16579@item -fprofile-prefix-path=@var{path}
d77de738
ML
16580
16581This option can be used in combination with
16582@option{profile-generate=}@var{profile_dir} and
16583@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16584directory of built source tree. By default @var{profile_dir} will contain
16585files with mangled absolute paths of all object files in the built project.
16586This is not desirable when directory used to build the instrumented binary
16587differs from the directory used to build the binary optimized with profile
16588feedback because the profile data will not be found during the optimized build.
16589In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16590pointing to the base directory of the build can be used to strip the irrelevant
16591part of the path and keep all file names relative to the main build directory.
16592
d77de738 16593@opindex fprofile-prefix-map
ddf6fe37 16594@item -fprofile-prefix-map=@var{old}=@var{new}
d77de738
ML
16595When compiling files residing in directory @file{@var{old}}, record
16596profiling information (with @option{--coverage})
16597describing them as if the files resided in
16598directory @file{@var{new}} instead.
2eb0191a 16599See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
d77de738 16600
d77de738 16601@opindex fprofile-update
ddf6fe37 16602@item -fprofile-update=@var{method}
d77de738
ML
16603
16604Alter the update method for an application instrumented for profile
16605feedback based optimization. The @var{method} argument should be one of
16606@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16607The first one is useful for single-threaded applications,
16608while the second one prevents profile corruption by emitting thread-safe code.
16609
16610@strong{Warning:} When an application does not properly join all threads
16611(or creates an detached thread), a profile file can be still corrupted.
16612
16613Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16614when supported by a target, or to @samp{single} otherwise. The GCC driver
16615automatically selects @samp{prefer-atomic} when @option{-pthread}
16616is present in the command line.
16617
d77de738 16618@opindex fprofile-filter-files
ddf6fe37 16619@item -fprofile-filter-files=@var{regex}
d77de738
ML
16620
16621Instrument only functions from files whose name matches
16622any of the regular expressions (separated by semi-colons).
16623
16624For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16625only @file{main.c} and all C files starting with 'module'.
16626
d77de738 16627@opindex fprofile-exclude-files
ddf6fe37 16628@item -fprofile-exclude-files=@var{regex}
d77de738
ML
16629
16630Instrument only functions from files whose name does not match
16631any of the regular expressions (separated by semi-colons).
16632
16633For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16634of all files that are located in the @file{/usr/} folder.
16635
d77de738 16636@opindex fprofile-reproducible
ddf6fe37 16637@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
d77de738
ML
16638Control level of reproducibility of profile gathered by
16639@code{-fprofile-generate}. This makes it possible to rebuild program
16640with same outcome which is useful, for example, for distribution
16641packages.
16642
16643With @option{-fprofile-reproducible=serial} the profile gathered by
16644@option{-fprofile-generate} is reproducible provided the trained program
16645behaves the same at each invocation of the train run, it is not
16646multi-threaded and profile data streaming is always done in the same
16647order. Note that profile streaming happens at the end of program run but
16648also before @code{fork} function is invoked.
16649
16650Note that it is quite common that execution counts of some part of
16651programs depends, for example, on length of temporary file names or
16652memory space randomization (that may affect hash-table collision rate).
16653Such non-reproducible part of programs may be annotated by
16654@code{no_instrument_function} function attribute. @command{gcov-dump} with
16655@option{-l} can be used to dump gathered data and verify that they are
16656indeed reproducible.
16657
16658With @option{-fprofile-reproducible=parallel-runs} collected profile
16659stays reproducible regardless the order of streaming of the data into
16660gcda files. This setting makes it possible to run multiple instances of
16661instrumented program in parallel (such as with @code{make -j}). This
16662reduces quality of gathered data, in particular of indirect call
16663profiling.
16664
d77de738 16665@opindex fsanitize=address
ddf6fe37 16666@item -fsanitize=address
d77de738
ML
16667Enable AddressSanitizer, a fast memory error detector.
16668Memory access instructions are instrumented to detect
16669out-of-bounds and use-after-free bugs.
16670The option enables @option{-fsanitize-address-use-after-scope}.
16671See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16672more details. The run-time behavior can be influenced using the
16673@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16674the available options are shown at startup of the instrumented program. See
16675@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16676for a list of supported options.
16677The option cannot be combined with @option{-fsanitize=thread} or
16678@option{-fsanitize=hwaddress}. Note that the only target
16679@option{-fsanitize=hwaddress} is currently supported on is AArch64.
16680
6a07798c
MP
16681To get more accurate stack traces, it is possible to use options such as
16682@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
16683most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
16684optimizing sibling and tail recursive calls; this option is implicit for
16685@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
16686disables Identical Code Folding for functions). Since multiple runs of the
16687program may yield backtraces with different addresses due to ASLR (Address
16688Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
16689this can be achieved with @samp{setarch `uname -m` -R ./prog}.
16690
d77de738 16691@opindex fsanitize=kernel-address
f33d7a88 16692@item -fsanitize=kernel-address
d77de738 16693Enable AddressSanitizer for Linux kernel.
a0bf71be 16694See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738 16695
d77de738 16696@opindex fsanitize=hwaddress
f33d7a88 16697@item -fsanitize=hwaddress
d77de738
ML
16698Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16699ignore the top byte of a pointer to allow the detection of memory errors with
16700a low memory overhead.
16701Memory access instructions are instrumented to detect out-of-bounds and
16702use-after-free bugs.
16703The option enables @option{-fsanitize-address-use-after-scope}.
16704See
16705@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
16706for more details. The run-time behavior can be influenced using the
16707@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
16708the available options are shown at startup of the instrumented program.
16709The option cannot be combined with @option{-fsanitize=thread} or
16710@option{-fsanitize=address}, and is currently only available on AArch64.
16711
d77de738 16712@opindex fsanitize=kernel-hwaddress
ddf6fe37 16713@item -fsanitize=kernel-hwaddress
d77de738
ML
16714Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
16715Similar to @option{-fsanitize=kernel-address} but using an alternate
16716instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
16717instrumentation differences necessary for compiling the Linux kernel.
16718These differences are to avoid hwasan library initialization calls and to
16719account for the stack pointer having a different value in its top byte.
16720
16721@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
16722Instrumenting the stack and alloca calls are not on by default but are still
16723possible by specifying the command-line options
16724@option{--param hwasan-instrument-stack=1} and
16725@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
16726tag is not implemented for kernel instrumentation.
16727
d77de738 16728@opindex fsanitize=pointer-compare
ddf6fe37 16729@item -fsanitize=pointer-compare
d77de738
ML
16730Instrument comparison operation (<, <=, >, >=) with pointer operands.
16731The option must be combined with either @option{-fsanitize=kernel-address} or
16732@option{-fsanitize=address}
16733The option cannot be combined with @option{-fsanitize=thread}.
16734Note: By default the check is disabled at run time. To enable it,
16735add @code{detect_invalid_pointer_pairs=2} to the environment variable
16736@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16737invalid operation only when both pointers are non-null.
16738
d77de738 16739@opindex fsanitize=pointer-subtract
ddf6fe37 16740@item -fsanitize=pointer-subtract
d77de738
ML
16741Instrument subtraction with pointer operands.
16742The option must be combined with either @option{-fsanitize=kernel-address} or
16743@option{-fsanitize=address}
16744The option cannot be combined with @option{-fsanitize=thread}.
16745Note: By default the check is disabled at run time. To enable it,
16746add @code{detect_invalid_pointer_pairs=2} to the environment variable
16747@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16748invalid operation only when both pointers are non-null.
16749
d77de738 16750@opindex fsanitize=shadow-call-stack
ddf6fe37 16751@item -fsanitize=shadow-call-stack
d77de738
ML
16752Enable ShadowCallStack, a security enhancement mechanism used to protect
16753programs against return address overwrites (e.g. stack buffer overflows.)
16754It works by saving a function's return address to a separately allocated
16755shadow call stack in the function prologue and restoring the return address
16756from the shadow call stack in the function epilogue. Instrumentation only
16757occurs in functions that need to save the return address to the stack.
16758
16759Currently it only supports the aarch64 platform. It is specifically
16760designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
16761For the user space programs, runtime support is not currently provided
16762in libc and libgcc. Users who want to use this feature in user space need
16763to provide their own support for the runtime. It should be noted that
16764this may cause the ABI rules to be broken.
16765
16766On aarch64, the instrumentation makes use of the platform register @code{x18}.
16767This generally means that any code that may run on the same thread as code
16768compiled with ShadowCallStack must be compiled with the flag
16769@option{-ffixed-x18}, otherwise functions compiled without
16770@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
16771stack pointer.
16772
16773Also, because there is no userspace runtime support, code compiled with
16774ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
16775to turn off exceptions.
16776
16777See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
16778details.
16779
d77de738 16780@opindex fsanitize=thread
ddf6fe37 16781@item -fsanitize=thread
d77de738
ML
16782Enable ThreadSanitizer, a fast data race detector.
16783Memory access instructions are instrumented to detect
16784data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
16785details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
16786environment variable; see
16787@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
16788supported options.
16789The option cannot be combined with @option{-fsanitize=address},
16790@option{-fsanitize=leak}.
16791
16792Note that sanitized atomic builtins cannot throw exceptions when
16793operating on invalid memory addresses with non-call exceptions
16794(@option{-fnon-call-exceptions}).
16795
d77de738 16796@opindex fsanitize=leak
ddf6fe37 16797@item -fsanitize=leak
d77de738 16798Enable LeakSanitizer, a memory leak detector.
c5c4fdac
JG
16799This option only matters for linking of executables.
16800The executable is linked against a library that overrides @code{malloc}
d77de738
ML
16801and other allocator functions. See
16802@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
16803details. The run-time behavior can be influenced using the
16804@env{LSAN_OPTIONS} environment variable.
16805The option cannot be combined with @option{-fsanitize=thread}.
16806
d77de738 16807@opindex fsanitize=undefined
ddf6fe37 16808@item -fsanitize=undefined
d77de738
ML
16809Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
16810Various computations are instrumented to detect undefined behavior
16811at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
16812@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
16813
16814@table @gcctabopt
16815
d77de738 16816@opindex fsanitize=shift
ddf6fe37 16817@item -fsanitize=shift
d77de738
ML
16818This option enables checking that the result of a shift operation is
16819not undefined. Note that what exactly is considered undefined differs
16820slightly between C and C++, as well as between ISO C90 and C99, etc.
16821This option has two suboptions, @option{-fsanitize=shift-base} and
16822@option{-fsanitize=shift-exponent}.
16823
d77de738 16824@opindex fsanitize=shift-exponent
ddf6fe37 16825@item -fsanitize=shift-exponent
d77de738
ML
16826This option enables checking that the second argument of a shift operation
16827is not negative and is smaller than the precision of the promoted first
16828argument.
16829
d77de738 16830@opindex fsanitize=shift-base
ddf6fe37 16831@item -fsanitize=shift-base
d77de738
ML
16832If the second argument of a shift operation is within range, check that the
16833result of a shift operation is not undefined. Note that what exactly is
16834considered undefined differs slightly between C and C++, as well as between
16835ISO C90 and C99, etc.
16836
d77de738 16837@opindex fsanitize=integer-divide-by-zero
ddf6fe37 16838@item -fsanitize=integer-divide-by-zero
d77de738
ML
16839Detect integer division by zero.
16840
d77de738 16841@opindex fsanitize=unreachable
ddf6fe37 16842@item -fsanitize=unreachable
d77de738
ML
16843With this option, the compiler turns the @code{__builtin_unreachable}
16844call into a diagnostics message call instead. When reaching the
16845@code{__builtin_unreachable} call, the behavior is undefined.
16846
d77de738 16847@opindex fsanitize=vla-bound
ddf6fe37 16848@item -fsanitize=vla-bound
d77de738
ML
16849This option instructs the compiler to check that the size of a variable
16850length array is positive.
16851
d77de738 16852@opindex fsanitize=null
ddf6fe37 16853@item -fsanitize=null
d77de738
ML
16854This option enables pointer checking. Particularly, the application
16855built with this option turned on will issue an error message when it
16856tries to dereference a NULL pointer, or if a reference (possibly an
16857rvalue reference) is bound to a NULL pointer, or if a method is invoked
16858on an object pointed by a NULL pointer.
16859
d77de738 16860@opindex fsanitize=return
ddf6fe37 16861@item -fsanitize=return
d77de738
ML
16862This option enables return statement checking. Programs
16863built with this option turned on will issue an error message
16864when the end of a non-void function is reached without actually
16865returning a value. This option works in C++ only.
16866
d77de738 16867@opindex fsanitize=signed-integer-overflow
ddf6fe37 16868@item -fsanitize=signed-integer-overflow
d77de738
ML
16869This option enables signed integer overflow checking. We check that
16870the result of @code{+}, @code{*}, and both unary and binary @code{-}
16871does not overflow in the signed arithmetics. This also detects
16872@code{INT_MIN / -1} signed division. Note, integer promotion
16873rules must be taken into account. That is, the following is not an
16874overflow:
16875@smallexample
16876signed char a = SCHAR_MAX;
16877a++;
16878@end smallexample
16879
d77de738 16880@opindex fsanitize=bounds
ddf6fe37 16881@item -fsanitize=bounds
d77de738
ML
16882This option enables instrumentation of array bounds. Various out of bounds
16883accesses are detected. Flexible array members, flexible array member-like
c7728805
JJ
16884arrays, and initializers of variables with static storage are not
16885instrumented, with the exception of flexible array member-like arrays
16886for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
16887options or @code{strict_flex_array} attributes say they shouldn't be treated
16888like flexible array member-like arrays.
d77de738 16889
d77de738 16890@opindex fsanitize=bounds-strict
ddf6fe37 16891@item -fsanitize=bounds-strict
d77de738 16892This option enables strict instrumentation of array bounds. Most out of bounds
c7728805
JJ
16893accesses are detected, including flexible array member-like arrays.
16894Initializers of variables with static storage are not instrumented.
d77de738 16895
d77de738 16896@opindex fsanitize=alignment
ddf6fe37 16897@item -fsanitize=alignment
d77de738
ML
16898
16899This option enables checking of alignment of pointers when they are
16900dereferenced, or when a reference is bound to insufficiently aligned target,
16901or when a method or constructor is invoked on insufficiently aligned object.
16902
d77de738 16903@opindex fsanitize=object-size
ddf6fe37 16904@item -fsanitize=object-size
d77de738 16905This option enables instrumentation of memory references using the
7283380a
SP
16906@code{__builtin_dynamic_object_size} function. Various out of bounds
16907pointer accesses are detected.
d77de738 16908
d77de738 16909@opindex fsanitize=float-divide-by-zero
ddf6fe37 16910@item -fsanitize=float-divide-by-zero
d77de738
ML
16911Detect floating-point division by zero. Unlike other similar options,
16912@option{-fsanitize=float-divide-by-zero} is not enabled by
16913@option{-fsanitize=undefined}, since floating-point division by zero can
16914be a legitimate way of obtaining infinities and NaNs.
16915
d77de738 16916@opindex fsanitize=float-cast-overflow
ddf6fe37 16917@item -fsanitize=float-cast-overflow
d77de738
ML
16918This option enables floating-point type to integer conversion checking.
16919We check that the result of the conversion does not overflow.
16920Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
16921not enabled by @option{-fsanitize=undefined}.
16922This option does not work well with @code{FE_INVALID} exceptions enabled.
16923
d77de738 16924@opindex fsanitize=nonnull-attribute
ddf6fe37 16925@item -fsanitize=nonnull-attribute
d77de738
ML
16926
16927This option enables instrumentation of calls, checking whether null values
16928are not passed to arguments marked as requiring a non-null value by the
16929@code{nonnull} function attribute.
16930
d77de738 16931@opindex fsanitize=returns-nonnull-attribute
ddf6fe37 16932@item -fsanitize=returns-nonnull-attribute
d77de738
ML
16933
16934This option enables instrumentation of return statements in functions
16935marked with @code{returns_nonnull} function attribute, to detect returning
16936of null values from such functions.
16937
d77de738 16938@opindex fsanitize=bool
ddf6fe37 16939@item -fsanitize=bool
d77de738
ML
16940
16941This option enables instrumentation of loads from bool. If a value other
16942than 0/1 is loaded, a run-time error is issued.
16943
d77de738 16944@opindex fsanitize=enum
ddf6fe37 16945@item -fsanitize=enum
d77de738
ML
16946
16947This option enables instrumentation of loads from an enum type. If
16948a value outside the range of values for the enum type is loaded,
16949a run-time error is issued.
16950
d77de738 16951@opindex fsanitize=vptr
ddf6fe37 16952@item -fsanitize=vptr
d77de738
ML
16953
16954This option enables instrumentation of C++ member function calls, member
16955accesses and some conversions between pointers to base and derived classes,
16956to verify the referenced object has the correct dynamic type.
16957
d77de738 16958@opindex fsanitize=pointer-overflow
ddf6fe37 16959@item -fsanitize=pointer-overflow
d77de738
ML
16960
16961This option enables instrumentation of pointer arithmetics. If the pointer
16962arithmetics overflows, a run-time error is issued.
16963
d77de738 16964@opindex fsanitize=builtin
ddf6fe37 16965@item -fsanitize=builtin
d77de738
ML
16966
16967This option enables instrumentation of arguments to selected builtin
16968functions. If an invalid value is passed to such arguments, a run-time
16969error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
16970or @code{__builtin_clz} invokes undefined behavior and is diagnosed
16971by this option.
16972
16973@end table
16974
16975Note that sanitizers tend to increase the rate of false positive
16976warnings, most notably those around @option{-Wmaybe-uninitialized}.
16977We recommend against combining @option{-Werror} and [the use of]
16978sanitizers.
16979
16980While @option{-ftrapv} causes traps for signed overflows to be emitted,
16981@option{-fsanitize=undefined} gives a diagnostic message.
16982This currently works only for the C family of languages.
16983
d77de738 16984@opindex fno-sanitize=all
ddf6fe37 16985@item -fno-sanitize=all
d77de738
ML
16986
16987This option disables all previously enabled sanitizers.
16988@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
16989together.
16990
d77de738 16991@opindex fasan-shadow-offset
ddf6fe37 16992@item -fasan-shadow-offset=@var{number}
d77de738
ML
16993This option forces GCC to use custom shadow offset in AddressSanitizer checks.
16994It is useful for experimenting with different shadow memory layouts in
16995Kernel AddressSanitizer.
16996
d77de738 16997@opindex fsanitize-sections
ddf6fe37 16998@item -fsanitize-sections=@var{s1},@var{s2},...
d77de738
ML
16999Sanitize global variables in selected user-defined sections. @var{si} may
17000contain wildcards.
17001
d77de738
ML
17002@opindex fsanitize-recover
17003@opindex fno-sanitize-recover
ddf6fe37 17004@item -fsanitize-recover@r{[}=@var{opts}@r{]}
d77de738
ML
17005@option{-fsanitize-recover=} controls error recovery mode for sanitizers
17006mentioned in comma-separated list of @var{opts}. Enabling this option
17007for a sanitizer component causes it to attempt to continue
17008running the program as if no error happened. This means multiple
17009runtime errors can be reported in a single program run, and the exit
17010code of the program may indicate success even when errors
17011have been reported. The @option{-fno-sanitize-recover=} option
17012can be used to alter
17013this behavior: only the first detected error is reported
17014and program then exits with a non-zero exit code.
17015
17016Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
17017except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
17018@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
17019@option{-fsanitize=bounds-strict},
17020@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
17021For these sanitizers error recovery is turned on by default,
17022except @option{-fsanitize=address}, for which this feature is experimental.
17023@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
17024accepted, the former enables recovery for all sanitizers that support it,
17025the latter disables recovery for all sanitizers that support it.
17026
17027Even if a recovery mode is turned on the compiler side, it needs to be also
17028enabled on the runtime library side, otherwise the failures are still fatal.
17029The runtime library defaults to @code{halt_on_error=0} for
17030ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
17031AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
17032setting the @code{halt_on_error} flag in the corresponding environment variable.
17033
17034Syntax without an explicit @var{opts} parameter is deprecated. It is
17035equivalent to specifying an @var{opts} list of:
17036
17037@smallexample
17038undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
17039@end smallexample
17040
d77de738 17041@opindex fsanitize-address-use-after-scope
ddf6fe37 17042@item -fsanitize-address-use-after-scope
d77de738
ML
17043Enable sanitization of local variables to detect use-after-scope bugs.
17044The option sets @option{-fstack-reuse} to @samp{none}.
17045
d77de738
ML
17046@opindex fsanitize-trap
17047@opindex fno-sanitize-trap
ddf6fe37 17048@item -fsanitize-trap@r{[}=@var{opts}@r{]}
d77de738
ML
17049The @option{-fsanitize-trap=} option instructs the compiler to
17050report for sanitizers mentioned in comma-separated list of @var{opts}
17051undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
17052library routine. If this option is enabled for certain sanitizer,
17053it takes precedence over the @option{-fsanitizer-recover=} for that
17054sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
17055of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
17056
17057The advantage of this is that the @code{libubsan} library is not needed
17058and is not linked in, so this is usable even in freestanding environments.
17059
17060Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
17061except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
17062@option{-fsanitize=float-divide-by-zero} and
17063@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
17064specified, which enables it for @code{undefined} suboptions,
17065@option{-fsanitize=float-cast-overflow},
17066@option{-fsanitize=float-divide-by-zero} and
17067@option{-fsanitize=bounds-strict}.
17068If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
17069and @code{-fsanitize=vptr} is enabled on the command line, the
17070instrumentation is silently ignored as the instrumentation always needs
17071@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
17072
d77de738 17073@opindex fsanitize-undefined-trap-on-error
ddf6fe37 17074@item -fsanitize-undefined-trap-on-error
d77de738
ML
17075The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17076equivalent of @option{-fsanitize-trap=all}.
17077
d77de738 17078@opindex fsanitize-coverage=trace-pc
ddf6fe37 17079@item -fsanitize-coverage=trace-pc
d77de738
ML
17080Enable coverage-guided fuzzing code instrumentation.
17081Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17082
d77de738 17083@opindex fsanitize-coverage=trace-cmp
ddf6fe37 17084@item -fsanitize-coverage=trace-cmp
d77de738
ML
17085Enable dataflow guided fuzzing code instrumentation.
17086Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17087@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17088@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17089variable or @code{__sanitizer_cov_trace_const_cmp1},
17090@code{__sanitizer_cov_trace_const_cmp2},
17091@code{__sanitizer_cov_trace_const_cmp4} or
17092@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17093operand constant, @code{__sanitizer_cov_trace_cmpf} or
17094@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17095@code{__sanitizer_cov_trace_switch} for switch statements.
17096
d77de738 17097@opindex fcf-protection
ddf6fe37 17098@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
d77de738
ML
17099Enable code instrumentation of control-flow transfers to increase
17100program security by checking that target addresses of control-flow
17101transfer instructions (such as indirect function call, function return,
17102indirect jump) are valid. This prevents diverting the flow of control
17103to an unexpected target. This is intended to protect against such
17104threats as Return-oriented Programming (ROP), and similarly
17105call/jmp-oriented programming (COP/JOP).
17106
17107The value @code{branch} tells the compiler to implement checking of
17108validity of control-flow transfer at the point of indirect branch
17109instructions, i.e.@: call/jmp instructions. The value @code{return}
17110implements checking of validity at the point of returning from a
17111function. The value @code{full} is an alias for specifying both
17112@code{branch} and @code{return}. The value @code{none} turns off
17113instrumentation.
17114
17115The value @code{check} is used for the final link with link-time
17116optimization (LTO). An error is issued if LTO object files are
17117compiled with different @option{-fcf-protection} values. The
17118value @code{check} is ignored at the compile time.
17119
17120The macro @code{__CET__} is defined when @option{-fcf-protection} is
17121used. The first bit of @code{__CET__} is set to 1 for the value
17122@code{branch} and the second bit of @code{__CET__} is set to 1 for
17123the @code{return}.
17124
17125You can also use the @code{nocf_check} attribute to identify
17126which functions and calls should be skipped from instrumentation
17127(@pxref{Function Attributes}).
17128
17129Currently the x86 GNU/Linux target provides an implementation based
17130on Intel Control-flow Enforcement Technology (CET) which works for
17131i686 processor or newer.
17132
d77de738 17133@opindex fharden-compares
ddf6fe37 17134@item -fharden-compares
d77de738
ML
17135For every logical test that survives gimple optimizations and is
17136@emph{not} the condition in a conditional branch (for example,
17137conditions tested for conditional moves, or to store in boolean
17138variables), emit extra code to compute and verify the reversed
17139condition, and to call @code{__builtin_trap} if the results do not
17140match. Use with @samp{-fharden-conditional-branches} to cover all
17141conditionals.
17142
d77de738 17143@opindex fharden-conditional-branches
ddf6fe37 17144@item -fharden-conditional-branches
d77de738
ML
17145For every non-vectorized conditional branch that survives gimple
17146optimizations, emit extra code to compute and verify the reversed
17147condition, and to call @code{__builtin_trap} if the result is
17148unexpected. Use with @samp{-fharden-compares} to cover all
17149conditionals.
17150
d77de738 17151@opindex fstack-protector
ddf6fe37 17152@item -fstack-protector
d77de738
ML
17153Emit extra code to check for buffer overflows, such as stack smashing
17154attacks. This is done by adding a guard variable to functions with
17155vulnerable objects. This includes functions that call @code{alloca}, and
17156functions with buffers larger than or equal to 8 bytes. The guards are
17157initialized when a function is entered and then checked when the function
17158exits. If a guard check fails, an error message is printed and the program
17159exits. Only variables that are actually allocated on the stack are
17160considered, optimized away variables or variables allocated in registers
17161don't count.
17162
d77de738 17163@opindex fstack-protector-all
ddf6fe37 17164@item -fstack-protector-all
d77de738
ML
17165Like @option{-fstack-protector} except that all functions are protected.
17166
d77de738 17167@opindex fstack-protector-strong
ddf6fe37 17168@item -fstack-protector-strong
d77de738
ML
17169Like @option{-fstack-protector} but includes additional functions to
17170be protected --- those that have local array definitions, or have
17171references to local frame addresses. Only variables that are actually
17172allocated on the stack are considered, optimized away variables or variables
17173allocated in registers don't count.
17174
d77de738 17175@opindex fstack-protector-explicit
ddf6fe37 17176@item -fstack-protector-explicit
d77de738
ML
17177Like @option{-fstack-protector} but only protects those functions which
17178have the @code{stack_protect} attribute.
17179
d77de738 17180@opindex fstack-check
ddf6fe37 17181@item -fstack-check
d77de738
ML
17182Generate code to verify that you do not go beyond the boundary of the
17183stack. You should specify this flag if you are running in an
17184environment with multiple threads, but you only rarely need to specify it in
17185a single-threaded environment since stack overflow is automatically
17186detected on nearly all systems if there is only one stack.
17187
17188Note that this switch does not actually cause checking to be done; the
17189operating system or the language runtime must do that. The switch causes
17190generation of code to ensure that they see the stack being extended.
17191
17192You can additionally specify a string parameter: @samp{no} means no
17193checking, @samp{generic} means force the use of old-style checking,
17194@samp{specific} means use the best checking method and is equivalent
17195to bare @option{-fstack-check}.
17196
17197Old-style checking is a generic mechanism that requires no specific
17198target support in the compiler but comes with the following drawbacks:
17199
17200@enumerate
17201@item
17202Modified allocation strategy for large objects: they are always
17203allocated dynamically if their size exceeds a fixed threshold. Note this
17204may change the semantics of some code.
17205
17206@item
17207Fixed limit on the size of the static frame of functions: when it is
17208topped by a particular function, stack checking is not reliable and
17209a warning is issued by the compiler.
17210
17211@item
17212Inefficiency: because of both the modified allocation strategy and the
17213generic implementation, code performance is hampered.
17214@end enumerate
17215
17216Note that old-style stack checking is also the fallback method for
17217@samp{specific} if no target support has been added in the compiler.
17218
17219@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17220and stack overflows. @samp{specific} is an excellent choice when compiling
17221Ada code. It is not generally sufficient to protect against stack-clash
17222attacks. To protect against those you want @samp{-fstack-clash-protection}.
17223
d77de738 17224@opindex fstack-clash-protection
ddf6fe37 17225@item -fstack-clash-protection
d77de738
ML
17226Generate code to prevent stack clash style attacks. When this option is
17227enabled, the compiler will only allocate one page of stack space at a time
17228and each page is accessed immediately after allocation. Thus, it prevents
17229allocations from jumping over any stack guard page provided by the
17230operating system.
17231
17232Most targets do not fully support stack clash protection. However, on
17233those targets @option{-fstack-clash-protection} will protect dynamic stack
17234allocations. @option{-fstack-clash-protection} may also provide limited
17235protection for static stack allocations if the target supports
17236@option{-fstack-check=specific}.
17237
d77de738
ML
17238@opindex fstack-limit-register
17239@opindex fstack-limit-symbol
17240@opindex fno-stack-limit
ddf6fe37
AA
17241@item -fstack-limit-register=@var{reg}
17242@itemx -fstack-limit-symbol=@var{sym}
17243@itemx -fno-stack-limit
d77de738
ML
17244Generate code to ensure that the stack does not grow beyond a certain value,
17245either the value of a register or the address of a symbol. If a larger
17246stack is required, a signal is raised at run time. For most targets,
17247the signal is raised before the stack overruns the boundary, so
17248it is possible to catch the signal without taking special precautions.
17249
17250For instance, if the stack starts at absolute address @samp{0x80000000}
17251and grows downwards, you can use the flags
17252@option{-fstack-limit-symbol=__stack_limit} and
17253@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17254of 128KB@. Note that this may only work with the GNU linker.
17255
17256You can locally override stack limit checking by using the
17257@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17258
d77de738 17259@opindex fsplit-stack
ddf6fe37 17260@item -fsplit-stack
d77de738
ML
17261Generate code to automatically split the stack before it overflows.
17262The resulting program has a discontiguous stack which can only
17263overflow if the program is unable to allocate any more memory. This
17264is most useful when running threaded programs, as it is no longer
17265necessary to calculate a good stack size to use for each thread. This
17266is currently only implemented for the x86 targets running
17267GNU/Linux.
17268
17269When code compiled with @option{-fsplit-stack} calls code compiled
17270without @option{-fsplit-stack}, there may not be much stack space
17271available for the latter code to run. If compiling all code,
17272including library code, with @option{-fsplit-stack} is not an option,
17273then the linker can fix up these calls so that the code compiled
17274without @option{-fsplit-stack} always has a large stack. Support for
17275this is implemented in the gold linker in GNU binutils release 2.21
17276and later.
17277
d77de738 17278@opindex fvtable-verify
ddf6fe37 17279@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
d77de738
ML
17280This option is only available when compiling C++ code.
17281It turns on (or off, if using @option{-fvtable-verify=none}) the security
17282feature that verifies at run time, for every virtual call, that
17283the vtable pointer through which the call is made is valid for the type of
17284the object, and has not been corrupted or overwritten. If an invalid vtable
17285pointer is detected at run time, an error is reported and execution of the
17286program is immediately halted.
17287
17288This option causes run-time data structures to be built at program startup,
17289which are used for verifying the vtable pointers.
17290The options @samp{std} and @samp{preinit}
17291control the timing of when these data structures are built. In both cases the
17292data structures are built before execution reaches @code{main}. Using
17293@option{-fvtable-verify=std} causes the data structures to be built after
17294shared libraries have been loaded and initialized.
17295@option{-fvtable-verify=preinit} causes them to be built before shared
17296libraries have been loaded and initialized.
17297
17298If this option appears multiple times in the command line with different
17299values specified, @samp{none} takes highest priority over both @samp{std} and
17300@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17301
d77de738 17302@opindex fvtv-debug
ddf6fe37 17303@item -fvtv-debug
d77de738
ML
17304When used in conjunction with @option{-fvtable-verify=std} or
17305@option{-fvtable-verify=preinit}, causes debug versions of the
17306runtime functions for the vtable verification feature to be called.
17307This flag also causes the compiler to log information about which
17308vtable pointers it finds for each class.
17309This information is written to a file named @file{vtv_set_ptr_data.log}
17310in the directory named by the environment variable @env{VTV_LOGS_DIR}
17311if that is defined or the current working directory otherwise.
17312
17313Note: This feature @emph{appends} data to the log file. If you want a fresh log
17314file, be sure to delete any existing one.
17315
d77de738 17316@opindex fvtv-counts
ddf6fe37 17317@item -fvtv-counts
d77de738
ML
17318This is a debugging flag. When used in conjunction with
17319@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17320causes the compiler to keep track of the total number of virtual calls
17321it encounters and the number of verifications it inserts. It also
17322counts the number of calls to certain run-time library functions
17323that it inserts and logs this information for each compilation unit.
17324The compiler writes this information to a file named
17325@file{vtv_count_data.log} in the directory named by the environment
17326variable @env{VTV_LOGS_DIR} if that is defined or the current working
17327directory otherwise. It also counts the size of the vtable pointer sets
17328for each class, and writes this information to @file{vtv_class_set_sizes.log}
17329in the same directory.
17330
17331Note: This feature @emph{appends} data to the log files. To get fresh log
17332files, be sure to delete any existing ones.
17333
d77de738 17334@opindex finstrument-functions
ddf6fe37 17335@item -finstrument-functions
d77de738
ML
17336Generate instrumentation calls for entry and exit to functions. Just
17337after function entry and just before function exit, the following
17338profiling functions are called with the address of the current
17339function and its call site. (On some platforms,
17340@code{__builtin_return_address} does not work beyond the current
17341function, so the call site information may not be available to the
17342profiling functions otherwise.)
17343
17344@smallexample
17345void __cyg_profile_func_enter (void *this_fn,
17346 void *call_site);
17347void __cyg_profile_func_exit (void *this_fn,
17348 void *call_site);
17349@end smallexample
17350
17351The first argument is the address of the start of the current function,
17352which may be looked up exactly in the symbol table.
17353
17354This instrumentation is also done for functions expanded inline in other
17355functions. The profiling calls indicate where, conceptually, the
17356inline function is entered and exited. This means that addressable
17357versions of such functions must be available. If all your uses of a
17358function are expanded inline, this may mean an additional expansion of
17359code size. If you use @code{extern inline} in your C code, an
17360addressable version of such functions must be provided. (This is
17361normally the case anyway, but if you get lucky and the optimizer always
17362expands the functions inline, you might have gotten away without
17363providing static copies.)
17364
17365A function may be given the attribute @code{no_instrument_function}, in
17366which case this instrumentation is not done. This can be used, for
17367example, for the profiling functions listed above, high-priority
17368interrupt routines, and any functions from which the profiling functions
17369cannot safely be called (perhaps signal handlers, if the profiling
17370routines generate output or allocate memory).
17371@xref{Common Function Attributes}.
17372
9c19597c 17373@opindex finstrument-functions-once
ddf6fe37 17374@item -finstrument-functions-once
d77de738
ML
17375This is similar to @option{-finstrument-functions}, but the profiling
17376functions are called only once per instrumented function, i.e. the first
17377profiling function is called after the first entry into the instrumented
17378function and the second profiling function is called before the exit
17379corresponding to this first entry.
17380
17381The definition of @code{once} for the purpose of this option is a little
17382vague because the implementation is not protected against data races.
17383As a result, the implementation only guarantees that the profiling
17384functions are called at @emph{least} once per process and at @emph{most}
17385once per thread, but the calls are always paired, that is to say, if a
17386thread calls the first function, then it will call the second function,
17387unless it never reaches the exit of the instrumented function.
17388
d77de738 17389@opindex finstrument-functions-exclude-file-list
ddf6fe37 17390@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
d77de738
ML
17391
17392Set the list of functions that are excluded from instrumentation (see
17393the description of @option{-finstrument-functions}). If the file that
17394contains a function definition matches with one of @var{file}, then
17395that function is not instrumented. The match is done on substrings:
17396if the @var{file} parameter is a substring of the file name, it is
17397considered to be a match.
17398
17399For example:
17400
17401@smallexample
17402-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17403@end smallexample
17404
17405@noindent
17406excludes any inline function defined in files whose pathnames
17407contain @file{/bits/stl} or @file{include/sys}.
17408
17409If, for some reason, you want to include letter @samp{,} in one of
17410@var{sym}, write @samp{\,}. For example,
17411@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17412(note the single quote surrounding the option).
17413
d77de738 17414@opindex finstrument-functions-exclude-function-list
ddf6fe37 17415@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
d77de738
ML
17416
17417This is similar to @option{-finstrument-functions-exclude-file-list},
17418but this option sets the list of function names to be excluded from
17419instrumentation. The function name to be matched is its user-visible
17420name, such as @code{vector<int> blah(const vector<int> &)}, not the
17421internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17422match is done on substrings: if the @var{sym} parameter is a substring
17423of the function name, it is considered to be a match. For C99 and C++
17424extended identifiers, the function name must be given in UTF-8, not
17425using universal character names.
17426
d77de738 17427@opindex fpatchable-function-entry
ddf6fe37 17428@item -fpatchable-function-entry=@var{N}[,@var{M}]
d77de738
ML
17429Generate @var{N} NOPs right at the beginning
17430of each function, with the function entry point before the @var{M}th NOP.
17431If @var{M} is omitted, it defaults to @code{0} so the
17432function entry points to the address just at the first NOP.
17433The NOP instructions reserve extra space which can be used to patch in
17434any desired instrumentation at run time, provided that the code segment
17435is writable. The amount of space is controllable indirectly via
17436the number of NOPs; the NOP instruction used corresponds to the instruction
17437emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17438is target-specific and may also depend on the architecture variant and/or
17439other compilation options.
17440
17441For run-time identification, the starting addresses of these areas,
17442which correspond to their respective function entries minus @var{M},
17443are additionally collected in the @code{__patchable_function_entries}
17444section of the resulting binary.
17445
17446Note that the value of @code{__attribute__ ((patchable_function_entry
17447(N,M)))} takes precedence over command-line option
17448@option{-fpatchable-function-entry=N,M}. This can be used to increase
17449the area size or to remove it completely on a single function.
17450If @code{N=0}, no pad location is recorded.
17451
17452The NOP instructions are inserted at---and maybe before, depending on
17453@var{M}---the function entry address, even before the prologue. On
17454PowerPC with the ELFv2 ABI, for a function with dual entry points,
17455the local entry point is this function entry address.
17456
17457The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17458ELFv2 ABI, for a function with dual entry points, the supported values
17459for @var{M} are 0, 2, 6 and 14.
17460@end table
17461
17462
17463@node Preprocessor Options
17464@section Options Controlling the Preprocessor
17465@cindex preprocessor options
17466@cindex options, preprocessor
17467
17468These options control the C preprocessor, which is run on each C source
17469file before actual compilation.
17470
17471If you use the @option{-E} option, nothing is done except preprocessing.
17472Some of these options make sense only together with @option{-E} because
17473they cause the preprocessor output to be unsuitable for actual
17474compilation.
17475
17476In addition to the options listed here, there are a number of options
17477to control search paths for include files documented in
17478@ref{Directory Options}.
17479Options to control preprocessor diagnostics are listed in
17480@ref{Warning Options}.
17481
17482@table @gcctabopt
17483@include cppopts.texi
17484
d77de738 17485@opindex Wp
ddf6fe37 17486@item -Wp,@var{option}
d77de738
ML
17487You can use @option{-Wp,@var{option}} to bypass the compiler driver
17488and pass @var{option} directly through to the preprocessor. If
17489@var{option} contains commas, it is split into multiple options at the
17490commas. However, many options are modified, translated or interpreted
17491by the compiler driver before being passed to the preprocessor, and
17492@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17493interface is undocumented and subject to change, so whenever possible
17494you should avoid using @option{-Wp} and let the driver handle the
17495options instead.
17496
d77de738 17497@opindex Xpreprocessor
ddf6fe37 17498@item -Xpreprocessor @var{option}
d77de738
ML
17499Pass @var{option} as an option to the preprocessor. You can use this to
17500supply system-specific preprocessor options that GCC does not
17501recognize.
17502
17503If you want to pass an option that takes an argument, you must use
17504@option{-Xpreprocessor} twice, once for the option and once for the argument.
17505
d77de738 17506@opindex no-integrated-cpp
ddf6fe37 17507@item -no-integrated-cpp
d77de738
ML
17508Perform preprocessing as a separate pass before compilation.
17509By default, GCC performs preprocessing as an integrated part of
17510input tokenization and parsing.
17511If this option is provided, the appropriate language front end
17512(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17513and Objective-C, respectively) is instead invoked twice,
17514once for preprocessing only and once for actual compilation
17515of the preprocessed input.
17516This option may be useful in conjunction with the @option{-B} or
17517@option{-wrapper} options to specify an alternate preprocessor or
17518perform additional processing of the program source between
17519normal preprocessing and compilation.
17520
d77de738 17521@opindex flarge-source-files
ddf6fe37 17522@item -flarge-source-files
d77de738
ML
17523Adjust GCC to expect large source files, at the expense of slower
17524compilation and higher memory usage.
17525
17526Specifically, GCC normally tracks both column numbers and line numbers
17527within source files and it normally prints both of these numbers in
17528diagnostics. However, once it has processed a certain number of source
17529lines, it stops tracking column numbers and only tracks line numbers.
17530This means that diagnostics for later lines do not include column numbers.
17531It also means that options like @option{-Wmisleading-indentation} cease to work
17532at that point, although the compiler prints a note if this happens.
17533Passing @option{-flarge-source-files} significantly increases the number
17534of source lines that GCC can process before it stops tracking columns.
17535
17536@end table
17537
17538@node Assembler Options
17539@section Passing Options to the Assembler
17540
17541@c prevent bad page break with this line
17542You can pass options to the assembler.
17543
17544@table @gcctabopt
d77de738 17545@opindex Wa
ddf6fe37 17546@item -Wa,@var{option}
d77de738
ML
17547Pass @var{option} as an option to the assembler. If @var{option}
17548contains commas, it is split into multiple options at the commas.
17549
d77de738 17550@opindex Xassembler
ddf6fe37 17551@item -Xassembler @var{option}
d77de738
ML
17552Pass @var{option} as an option to the assembler. You can use this to
17553supply system-specific assembler options that GCC does not
17554recognize.
17555
17556If you want to pass an option that takes an argument, you must use
17557@option{-Xassembler} twice, once for the option and once for the argument.
17558
17559@end table
17560
17561@node Link Options
17562@section Options for Linking
17563@cindex link options
17564@cindex options, linking
17565
17566These options come into play when the compiler links object files into
17567an executable output file. They are meaningless if the compiler is
17568not doing a link step.
17569
17570@table @gcctabopt
17571@cindex file names
17572@item @var{object-file-name}
17573A file name that does not end in a special recognized suffix is
17574considered to name an object file or library. (Object files are
17575distinguished from libraries by the linker according to the file
17576contents.) If linking is done, these object files are used as input
17577to the linker.
17578
d77de738
ML
17579@opindex c
17580@opindex S
17581@opindex E
ddf6fe37
AA
17582@item -c
17583@itemx -S
17584@itemx -E
d77de738
ML
17585If any of these options is used, then the linker is not run, and
17586object file names should not be used as arguments. @xref{Overall
17587Options}.
17588
d77de738 17589@opindex flinker-output
ddf6fe37 17590@item -flinker-output=@var{type}
d77de738
ML
17591This option controls code generation of the link-time optimizer. By
17592default the linker output is automatically determined by the linker
17593plugin. For debugging the compiler and if incremental linking with a
17594non-LTO object file is desired, it may be useful to control the type
17595manually.
17596
17597If @var{type} is @samp{exec}, code generation produces a static
17598binary. In this case @option{-fpic} and @option{-fpie} are both
17599disabled.
17600
17601If @var{type} is @samp{dyn}, code generation produces a shared
17602library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17603but not enabled automatically. This allows to build shared libraries
17604without position-independent code on architectures where this is
17605possible, i.e.@: on x86.
17606
17607If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17608executable. This results in similar optimizations as @samp{exec}
17609except that @option{-fpie} is not disabled if specified at compilation
17610time.
17611
17612If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17613done. The sections containing intermediate code for link-time optimization are
17614merged, pre-optimized, and output to the resulting object file. In addition, if
17615@option{-ffat-lto-objects} is specified, binary code is produced for future
17616non-LTO linking. The object file produced by incremental linking is smaller
17617than a static library produced from the same object files. At link time the
17618result of incremental linking also loads faster than a static
17619library assuming that the majority of objects in the library are used.
17620
17621Finally @samp{nolto-rel} configures the compiler for incremental linking where
17622code generation is forced, a final binary is produced, and the intermediate
17623code for later link-time optimization is stripped. When multiple object files
17624are linked together the resulting code is better optimized than with
17625link-time optimizations disabled (for example, cross-module inlining
17626happens), but most of benefits of whole program optimizations are lost.
17627
17628During the incremental link (by @option{-r}) the linker plugin defaults to
17629@option{rel}. With current interfaces to GNU Binutils it is however not
17630possible to incrementally link LTO objects and non-LTO objects into a single
17631mixed object file. If any of object files in incremental link cannot
17632be used for link-time optimization, the linker plugin issues a warning and
17633uses @samp{nolto-rel}. To maintain whole program optimization, it is
17634recommended to link such objects into static library instead. Alternatively it
17635is possible to use H.J. Lu's binutils with support for mixed objects.
17636
d77de738 17637@opindex fuse-ld=bfd
ddf6fe37 17638@item -fuse-ld=bfd
d77de738
ML
17639Use the @command{bfd} linker instead of the default linker.
17640
d77de738 17641@opindex fuse-ld=gold
ddf6fe37 17642@item -fuse-ld=gold
d77de738
ML
17643Use the @command{gold} linker instead of the default linker.
17644
d77de738 17645@opindex fuse-ld=lld
ddf6fe37 17646@item -fuse-ld=lld
d77de738
ML
17647Use the LLVM @command{lld} linker instead of the default linker.
17648
d77de738 17649@opindex fuse-ld=mold
ddf6fe37 17650@item -fuse-ld=mold
d77de738
ML
17651Use the Modern Linker (@command{mold}) instead of the default linker.
17652
17653@cindex Libraries
ddf6fe37 17654@opindex l
d77de738
ML
17655@item -l@var{library}
17656@itemx -l @var{library}
d77de738
ML
17657Search the library named @var{library} when linking. (The second
17658alternative with the library as a separate argument is only for
17659POSIX compliance and is not recommended.)
17660
17661The @option{-l} option is passed directly to the linker by GCC. Refer
17662to your linker documentation for exact details. The general
17663description below applies to the GNU linker.
17664
17665The linker searches a standard list of directories for the library.
17666The directories searched include several standard system directories
17667plus any that you specify with @option{-L}.
17668
17669Static libraries are archives of object files, and have file names
17670like @file{lib@var{library}.a}. Some targets also support shared
17671libraries, which typically have names like @file{lib@var{library}.so}.
17672If both static and shared libraries are found, the linker gives
17673preference to linking with the shared library unless the
17674@option{-static} option is used.
17675
17676It makes a difference where in the command you write this option; the
17677linker searches and processes libraries and object files in the order they
17678are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17679after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17680to functions in @samp{z}, those functions may not be loaded.
17681
d77de738 17682@opindex lobjc
ddf6fe37 17683@item -lobjc
d77de738
ML
17684You need this special case of the @option{-l} option in order to
17685link an Objective-C or Objective-C++ program.
17686
d77de738 17687@opindex nostartfiles
ddf6fe37 17688@item -nostartfiles
d77de738
ML
17689Do not use the standard system startup files when linking.
17690The standard system libraries are used normally, unless @option{-nostdlib},
17691@option{-nolibc}, or @option{-nodefaultlibs} is used.
17692
d77de738 17693@opindex nodefaultlibs
ddf6fe37 17694@item -nodefaultlibs
d77de738
ML
17695Do not use the standard system libraries when linking.
17696Only the libraries you specify are passed to the linker, and options
17697specifying linkage of the system libraries, such as @option{-static-libgcc}
17698or @option{-shared-libgcc}, are ignored.
17699The standard startup files are used normally, unless @option{-nostartfiles}
17700is used.
17701
17702The compiler may generate calls to @code{memcmp},
17703@code{memset}, @code{memcpy} and @code{memmove}.
17704These entries are usually resolved by entries in
17705libc. These entry points should be supplied through some other
17706mechanism when this option is specified.
17707
d77de738 17708@opindex nolibc
ddf6fe37 17709@item -nolibc
d77de738
ML
17710Do not use the C library or system libraries tightly coupled with it when
17711linking. Still link with the startup files, @file{libgcc} or toolchain
17712provided language support libraries such as @file{libgnat}, @file{libgfortran}
17713or @file{libstdc++} unless options preventing their inclusion are used as
17714well. This typically removes @option{-lc} from the link command line, as well
17715as system libraries that normally go with it and become meaningless when
17716absence of a C library is assumed, for example @option{-lpthread} or
17717@option{-lm} in some configurations. This is intended for bare-board
17718targets when there is indeed no C library available.
17719
d77de738 17720@opindex nostdlib
ddf6fe37 17721@item -nostdlib
d77de738
ML
17722Do not use the standard system startup files or libraries when linking.
17723No startup files and only the libraries you specify are passed to
17724the linker, and options specifying linkage of the system libraries, such as
17725@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
17726
17727The compiler may generate calls to @code{memcmp}, @code{memset},
17728@code{memcpy} and @code{memmove}.
17729These entries are usually resolved by entries in
17730libc. These entry points should be supplied through some other
17731mechanism when this option is specified.
17732
17733@cindex @option{-lgcc}, use with @option{-nostdlib}
17734@cindex @option{-nostdlib} and unresolved references
17735@cindex unresolved references and @option{-nostdlib}
17736@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
17737@cindex @option{-nodefaultlibs} and unresolved references
17738@cindex unresolved references and @option{-nodefaultlibs}
17739One of the standard libraries bypassed by @option{-nostdlib} and
17740@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
17741which GCC uses to overcome shortcomings of particular machines, or special
17742needs for some languages.
17743(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
17744Collection (GCC) Internals},
17745for more discussion of @file{libgcc.a}.)
17746In most cases, you need @file{libgcc.a} even when you want to avoid
17747other standard libraries. In other words, when you specify @option{-nostdlib}
17748or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
17749This ensures that you have no unresolved references to internal GCC
17750library subroutines.
17751(An example of such an internal subroutine is @code{__main}, used to ensure C++
17752constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
17753GNU Compiler Collection (GCC) Internals}.)
17754
d77de738 17755@opindex nostdlib++
ddf6fe37 17756@item -nostdlib++
d77de738
ML
17757Do not implicitly link with standard C++ libraries.
17758
d77de738
ML
17759@opindex e
17760@opindex entry
ddf6fe37
AA
17761@item -e @var{entry}
17762@itemx --entry=@var{entry}
d77de738
ML
17763
17764Specify that the program entry point is @var{entry}. The argument is
17765interpreted by the linker; the GNU linker accepts either a symbol name
17766or an address.
17767
d77de738 17768@opindex pie
ddf6fe37 17769@item -pie
d77de738
ML
17770Produce a dynamically linked position independent executable on targets
17771that support it. For predictable results, you must also specify the same
17772set of options used for compilation (@option{-fpie}, @option{-fPIE},
17773or model suboptions) when you specify this linker option.
17774
d77de738 17775@opindex no-pie
ddf6fe37 17776@item -no-pie
d77de738
ML
17777Don't produce a dynamically linked position independent executable.
17778
d77de738 17779@opindex static-pie
ddf6fe37 17780@item -static-pie
d77de738
ML
17781Produce a static position independent executable on targets that support
17782it. A static position independent executable is similar to a static
17783executable, but can be loaded at any address without a dynamic linker.
17784For predictable results, you must also specify the same set of options
17785used for compilation (@option{-fpie}, @option{-fPIE}, or model
17786suboptions) when you specify this linker option.
17787
d77de738 17788@opindex pthread
ddf6fe37 17789@item -pthread
d77de738
ML
17790Link with the POSIX threads library. This option is supported on
17791GNU/Linux targets, most other Unix derivatives, and also on
17792x86 Cygwin and MinGW targets. On some targets this option also sets
17793flags for the preprocessor, so it should be used consistently for both
17794compilation and linking.
17795
d77de738 17796@opindex r
ddf6fe37 17797@item -r
d77de738
ML
17798Produce a relocatable object as output. This is also known as partial
17799linking.
17800
d77de738 17801@opindex rdynamic
ddf6fe37 17802@item -rdynamic
d77de738
ML
17803Pass the flag @option{-export-dynamic} to the ELF linker, on targets
17804that support it. This instructs the linker to add all symbols, not
17805only used ones, to the dynamic symbol table. This option is needed
17806for some uses of @code{dlopen} or to allow obtaining backtraces
17807from within a program.
17808
d77de738 17809@opindex s
ddf6fe37 17810@item -s
d77de738
ML
17811Remove all symbol table and relocation information from the executable.
17812
d77de738 17813@opindex static
ddf6fe37 17814@item -static
d77de738
ML
17815On systems that support dynamic linking, this overrides @option{-pie}
17816and prevents linking with the shared libraries. On other systems, this
17817option has no effect.
17818
d77de738 17819@opindex shared
ddf6fe37 17820@item -shared
d77de738
ML
17821Produce a shared object which can then be linked with other objects to
17822form an executable. Not all systems support this option. For predictable
17823results, you must also specify the same set of options used for compilation
17824(@option{-fpic}, @option{-fPIC}, or model suboptions) when
17825you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
17826needs to build supplementary stub code for constructors to work. On
17827multi-libbed systems, @samp{gcc -shared} must select the correct support
17828libraries to link against. Failing to supply the correct flags may lead
17829to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
17830is innocuous. @option{-shared} suppresses the addition of startup code
17831to alter the floating-point environment as done with @option{-ffast-math},
17832@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738 17833
d77de738
ML
17834@opindex shared-libgcc
17835@opindex static-libgcc
ddf6fe37
AA
17836@item -shared-libgcc
17837@itemx -static-libgcc
d77de738
ML
17838On systems that provide @file{libgcc} as a shared library, these options
17839force the use of either the shared or static version, respectively.
17840If no shared version of @file{libgcc} was built when the compiler was
17841configured, these options have no effect.
17842
17843There are several situations in which an application should use the
17844shared @file{libgcc} instead of the static version. The most common
17845of these is when the application wishes to throw and catch exceptions
17846across different shared libraries. In that case, each of the libraries
17847as well as the application itself should use the shared @file{libgcc}.
17848
17849Therefore, the G++ driver automatically adds @option{-shared-libgcc}
17850whenever you build a shared library or a main executable, because C++
17851programs typically use exceptions, so this is the right thing to do.
17852
17853If, instead, you use the GCC driver to create shared libraries, you may
17854find that they are not always linked with the shared @file{libgcc}.
17855If GCC finds, at its configuration time, that you have a non-GNU linker
17856or a GNU linker that does not support option @option{--eh-frame-hdr},
17857it links the shared version of @file{libgcc} into shared libraries
17858by default. Otherwise, it takes advantage of the linker and optimizes
17859away the linking with the shared version of @file{libgcc}, linking with
17860the static version of libgcc by default. This allows exceptions to
17861propagate through such shared libraries, without incurring relocation
17862costs at library load time.
17863
17864However, if a library or main executable is supposed to throw or catch
17865exceptions, you must link it using the G++ driver, or using the option
17866@option{-shared-libgcc}, such that it is linked with the shared
17867@file{libgcc}.
17868
d77de738 17869@opindex static-libasan
ddf6fe37 17870@item -static-libasan
d77de738
ML
17871When the @option{-fsanitize=address} option is used to link a program,
17872the GCC driver automatically links against @option{libasan}. If
17873@file{libasan} is available as a shared library, and the @option{-static}
17874option is not used, then this links against the shared version of
17875@file{libasan}. The @option{-static-libasan} option directs the GCC
17876driver to link @file{libasan} statically, without necessarily linking
17877other libraries statically.
17878
d77de738 17879@opindex static-libtsan
ddf6fe37 17880@item -static-libtsan
d77de738
ML
17881When the @option{-fsanitize=thread} option is used to link a program,
17882the GCC driver automatically links against @option{libtsan}. If
17883@file{libtsan} is available as a shared library, and the @option{-static}
17884option is not used, then this links against the shared version of
17885@file{libtsan}. The @option{-static-libtsan} option directs the GCC
17886driver to link @file{libtsan} statically, without necessarily linking
17887other libraries statically.
17888
d77de738 17889@opindex static-liblsan
ddf6fe37 17890@item -static-liblsan
d77de738
ML
17891When the @option{-fsanitize=leak} option is used to link a program,
17892the GCC driver automatically links against @option{liblsan}. If
17893@file{liblsan} is available as a shared library, and the @option{-static}
17894option is not used, then this links against the shared version of
17895@file{liblsan}. The @option{-static-liblsan} option directs the GCC
17896driver to link @file{liblsan} statically, without necessarily linking
17897other libraries statically.
17898
d77de738 17899@opindex static-libubsan
ddf6fe37 17900@item -static-libubsan
d77de738
ML
17901When the @option{-fsanitize=undefined} option is used to link a program,
17902the GCC driver automatically links against @option{libubsan}. If
17903@file{libubsan} is available as a shared library, and the @option{-static}
17904option is not used, then this links against the shared version of
17905@file{libubsan}. The @option{-static-libubsan} option directs the GCC
17906driver to link @file{libubsan} statically, without necessarily linking
17907other libraries statically.
17908
d77de738 17909@opindex static-libstdc++
ddf6fe37 17910@item -static-libstdc++
d77de738
ML
17911When the @command{g++} program is used to link a C++ program, it
17912normally automatically links against @option{libstdc++}. If
17913@file{libstdc++} is available as a shared library, and the
17914@option{-static} option is not used, then this links against the
17915shared version of @file{libstdc++}. That is normally fine. However, it
17916is sometimes useful to freeze the version of @file{libstdc++} used by
17917the program without going all the way to a fully static link. The
17918@option{-static-libstdc++} option directs the @command{g++} driver to
17919link @file{libstdc++} statically, without necessarily linking other
17920libraries statically.
17921
d77de738 17922@opindex symbolic
ddf6fe37 17923@item -symbolic
d77de738
ML
17924Bind references to global symbols when building a shared object. Warn
17925about any unresolved references (unless overridden by the link editor
17926option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
17927this option.
17928
d77de738
ML
17929@opindex T
17930@cindex linker script
f33d7a88 17931@item -T @var{script}
d77de738
ML
17932Use @var{script} as the linker script. This option is supported by most
17933systems using the GNU linker. On some targets, such as bare-board
17934targets without an operating system, the @option{-T} option may be required
17935when linking to avoid references to undefined symbols.
17936
d77de738 17937@opindex Xlinker
ddf6fe37 17938@item -Xlinker @var{option}
d77de738
ML
17939Pass @var{option} as an option to the linker. You can use this to
17940supply system-specific linker options that GCC does not recognize.
17941
17942If you want to pass an option that takes a separate argument, you must use
17943@option{-Xlinker} twice, once for the option and once for the argument.
17944For example, to pass @option{-assert definitions}, you must write
17945@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
17946@option{-Xlinker "-assert definitions"}, because this passes the entire
17947string as a single argument, which is not what the linker expects.
17948
17949When using the GNU linker, it is usually more convenient to pass
17950arguments to linker options using the @option{@var{option}=@var{value}}
17951syntax than as separate arguments. For example, you can specify
17952@option{-Xlinker -Map=output.map} rather than
17953@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
17954this syntax for command-line options.
17955
d77de738 17956@opindex Wl
ddf6fe37 17957@item -Wl,@var{option}
d77de738
ML
17958Pass @var{option} as an option to the linker. If @var{option} contains
17959commas, it is split into multiple options at the commas. You can use this
17960syntax to pass an argument to the option.
17961For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
17962linker. When using the GNU linker, you can also get the same effect with
17963@option{-Wl,-Map=output.map}.
17964
d77de738 17965@opindex u
ddf6fe37 17966@item -u @var{symbol}
d77de738
ML
17967Pretend the symbol @var{symbol} is undefined, to force linking of
17968library modules to define it. You can use @option{-u} multiple times with
17969different symbols to force loading of additional library modules.
17970
d77de738 17971@opindex z
ddf6fe37 17972@item -z @var{keyword}
d77de738
ML
17973@option{-z} is passed directly on to the linker along with the keyword
17974@var{keyword}. See the section in the documentation of your linker for
17975permitted values and their meanings.
17976@end table
17977
17978@node Directory Options
17979@section Options for Directory Search
17980@cindex directory options
17981@cindex options, directory search
17982@cindex search path
17983
17984These options specify directories to search for header files, for
17985libraries and for parts of the compiler:
17986
17987@table @gcctabopt
17988@include cppdiropts.texi
17989
d77de738 17990@opindex iplugindir=
ddf6fe37 17991@item -iplugindir=@var{dir}
d77de738
ML
17992Set the directory to search for plugins that are passed
17993by @option{-fplugin=@var{name}} instead of
17994@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
17995to be used by the user, but only passed by the driver.
17996
d77de738 17997@opindex L
ddf6fe37 17998@item -L@var{dir}
d77de738
ML
17999Add directory @var{dir} to the list of directories to be searched
18000for @option{-l}.
18001
d77de738 18002@opindex B
ddf6fe37 18003@item -B@var{prefix}
d77de738
ML
18004This option specifies where to find the executables, libraries,
18005include files, and data files of the compiler itself.
18006
18007The compiler driver program runs one or more of the subprograms
18008@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
18009@var{prefix} as a prefix for each program it tries to run, both with and
18010without @samp{@var{machine}/@var{version}/} for the corresponding target
18011machine and compiler version.
18012
18013For each subprogram to be run, the compiler driver first tries the
18014@option{-B} prefix, if any. If that name is not found, or if @option{-B}
18015is not specified, the driver tries two standard prefixes,
18016@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
18017those results in a file name that is found, the unmodified program
18018name is searched for using the directories specified in your
18019@env{PATH} environment variable.
18020
18021The compiler checks to see if the path provided by @option{-B}
18022refers to a directory, and if necessary it adds a directory
18023separator character at the end of the path.
18024
18025@option{-B} prefixes that effectively specify directory names also apply
18026to libraries in the linker, because the compiler translates these
18027options into @option{-L} options for the linker. They also apply to
18028include files in the preprocessor, because the compiler translates these
18029options into @option{-isystem} options for the preprocessor. In this case,
18030the compiler appends @samp{include} to the prefix.
18031
18032The runtime support file @file{libgcc.a} can also be searched for using
18033the @option{-B} prefix, if needed. If it is not found there, the two
18034standard prefixes above are tried, and that is all. The file is left
18035out of the link if it is not found by those means.
18036
18037Another way to specify a prefix much like the @option{-B} prefix is to use
18038the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
18039Variables}.
18040
18041As a special kludge, if the path provided by @option{-B} is
18042@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
180439, then it is replaced by @file{[dir/]include}. This is to help
18044with boot-strapping the compiler.
18045
d77de738 18046@opindex no-canonical-prefixes
ddf6fe37 18047@item -no-canonical-prefixes
d77de738
ML
18048Do not expand any symbolic links, resolve references to @samp{/../}
18049or @samp{/./}, or make the path absolute when generating a relative
18050prefix.
18051
d77de738 18052@opindex sysroot
ddf6fe37 18053@item --sysroot=@var{dir}
d77de738
ML
18054Use @var{dir} as the logical root directory for headers and libraries.
18055For example, if the compiler normally searches for headers in
18056@file{/usr/include} and libraries in @file{/usr/lib}, it instead
18057searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
18058
18059If you use both this option and the @option{-isysroot} option, then
18060the @option{--sysroot} option applies to libraries, but the
18061@option{-isysroot} option applies to header files.
18062
18063The GNU linker (beginning with version 2.16) has the necessary support
18064for this option. If your linker does not support this option, the
18065header file aspect of @option{--sysroot} still works, but the
18066library aspect does not.
18067
d77de738 18068@opindex no-sysroot-suffix
ddf6fe37 18069@item --no-sysroot-suffix
d77de738
ML
18070For some targets, a suffix is added to the root directory specified
18071with @option{--sysroot}, depending on the other options used, so that
18072headers may for example be found in
18073@file{@var{dir}/@var{suffix}/usr/include} instead of
18074@file{@var{dir}/usr/include}. This option disables the addition of
18075such a suffix.
18076
18077@end table
18078
18079@node Code Gen Options
18080@section Options for Code Generation Conventions
18081@cindex code generation conventions
18082@cindex options, code generation
18083@cindex run-time options
18084
18085These machine-independent options control the interface conventions
18086used in code generation.
18087
18088Most of them have both positive and negative forms; the negative form
18089of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18090one of the forms is listed---the one that is not the default. You
18091can figure out the other form by either removing @samp{no-} or adding
18092it.
18093
18094@table @gcctabopt
d77de738 18095@opindex fstack_reuse
ddf6fe37 18096@item -fstack-reuse=@var{reuse-level}
d77de738
ML
18097This option controls stack space reuse for user declared local/auto variables
18098and compiler generated temporaries. @var{reuse_level} can be @samp{all},
18099@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
18100local variables and temporaries, @samp{named_vars} enables the reuse only for
18101user defined local variables with names, and @samp{none} disables stack reuse
18102completely. The default value is @samp{all}. The option is needed when the
18103program extends the lifetime of a scoped local variable or a compiler generated
18104temporary beyond the end point defined by the language. When a lifetime of
18105a variable ends, and if the variable lives in memory, the optimizing compiler
18106has the freedom to reuse its stack space with other temporaries or scoped
18107local variables whose live range does not overlap with it. Legacy code extending
18108local lifetime is likely to break with the stack reuse optimization.
18109
18110For example,
18111
18112@smallexample
18113 int *p;
18114 @{
18115 int local1;
18116
18117 p = &local1;
18118 local1 = 10;
18119 ....
18120 @}
18121 @{
18122 int local2;
18123 local2 = 20;
18124 ...
18125 @}
18126
18127 if (*p == 10) // out of scope use of local1
18128 @{
18129
18130 @}
18131@end smallexample
18132
18133Another example:
18134@smallexample
18135
18136 struct A
18137 @{
18138 A(int k) : i(k), j(k) @{ @}
18139 int i;
18140 int j;
18141 @};
18142
18143 A *ap;
18144
18145 void foo(const A& ar)
18146 @{
18147 ap = &ar;
18148 @}
18149
18150 void bar()
18151 @{
18152 foo(A(10)); // temp object's lifetime ends when foo returns
18153
18154 @{
18155 A a(20);
18156 ....
18157 @}
18158 ap->i+= 10; // ap references out of scope temp whose space
18159 // is reused with a. What is the value of ap->i?
18160 @}
18161
18162@end smallexample
18163
18164The lifetime of a compiler generated temporary is well defined by the C++
18165standard. When a lifetime of a temporary ends, and if the temporary lives
18166in memory, the optimizing compiler has the freedom to reuse its stack
18167space with other temporaries or scoped local variables whose live range
18168does not overlap with it. However some of the legacy code relies on
18169the behavior of older compilers in which temporaries' stack space is
18170not reused, the aggressive stack reuse can lead to runtime errors. This
18171option is used to control the temporary stack reuse optimization.
18172
d77de738 18173@opindex ftrapv
ddf6fe37 18174@item -ftrapv
d77de738
ML
18175This option generates traps for signed overflow on addition, subtraction,
18176multiplication operations.
18177The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18178@option{-ftrapv} @option{-fwrapv} on the command-line results in
18179@option{-fwrapv} being effective. Note that only active options override, so
18180using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18181results in @option{-ftrapv} being effective.
18182
d77de738 18183@opindex fwrapv
ddf6fe37 18184@item -fwrapv
d77de738
ML
18185This option instructs the compiler to assume that signed arithmetic
18186overflow of addition, subtraction and multiplication wraps around
18187using twos-complement representation. This flag enables some optimizations
18188and disables others.
18189The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18190@option{-ftrapv} @option{-fwrapv} on the command-line results in
18191@option{-fwrapv} being effective. Note that only active options override, so
18192using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18193results in @option{-ftrapv} being effective.
18194
d77de738 18195@opindex fwrapv-pointer
ddf6fe37 18196@item -fwrapv-pointer
d77de738
ML
18197This option instructs the compiler to assume that pointer arithmetic
18198overflow on addition and subtraction wraps around using twos-complement
18199representation. This flag disables some optimizations which assume
18200pointer overflow is invalid.
18201
d77de738 18202@opindex fstrict-overflow
ddf6fe37 18203@item -fstrict-overflow
d77de738
ML
18204This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18205negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18206
d77de738 18207@opindex fexceptions
ddf6fe37 18208@item -fexceptions
d77de738
ML
18209Enable exception handling. Generates extra code needed to propagate
18210exceptions. For some targets, this implies GCC generates frame
18211unwind information for all functions, which can produce significant data
18212size overhead, although it does not affect execution. If you do not
18213specify this option, GCC enables it by default for languages like
18214C++ that normally require exception handling, and disables it for
18215languages like C that do not normally require it. However, you may need
18216to enable this option when compiling C code that needs to interoperate
18217properly with exception handlers written in C++. You may also wish to
18218disable this option if you are compiling older C++ programs that don't
18219use exception handling.
18220
d77de738 18221@opindex fnon-call-exceptions
ddf6fe37 18222@item -fnon-call-exceptions
d77de738
ML
18223Generate code that allows trapping instructions to throw exceptions.
18224Note that this requires platform-specific runtime support that does
18225not exist everywhere. Moreover, it only allows @emph{trapping}
18226instructions to throw exceptions, i.e.@: memory references or floating-point
18227instructions. It does not allow exceptions to be thrown from
18228arbitrary signal handlers such as @code{SIGALRM}. This enables
18229@option{-fexceptions}.
18230
d77de738 18231@opindex fdelete-dead-exceptions
ddf6fe37 18232@item -fdelete-dead-exceptions
d77de738
ML
18233Consider that instructions that may throw exceptions but don't otherwise
18234contribute to the execution of the program can be optimized away.
18235This does not affect calls to functions except those with the
18236@code{pure} or @code{const} attributes.
18237This option is enabled by default for the Ada and C++ compilers, as permitted by
18238the language specifications.
18239Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18240
d77de738 18241@opindex funwind-tables
ddf6fe37 18242@item -funwind-tables
d77de738
ML
18243Similar to @option{-fexceptions}, except that it just generates any needed
18244static data, but does not affect the generated code in any other way.
18245You normally do not need to enable this option; instead, a language processor
18246that needs this handling enables it on your behalf.
18247
d77de738 18248@opindex fasynchronous-unwind-tables
ddf6fe37 18249@item -fasynchronous-unwind-tables
d77de738
ML
18250Generate unwind table in DWARF format, if supported by target machine. The
18251table is exact at each instruction boundary, so it can be used for stack
18252unwinding from asynchronous events (such as debugger or garbage collector).
18253
d77de738
ML
18254@opindex fno-gnu-unique
18255@opindex fgnu-unique
ddf6fe37 18256@item -fno-gnu-unique
d77de738
ML
18257On systems with recent GNU assembler and C library, the C++ compiler
18258uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18259of template static data members and static local variables in inline
18260functions are unique even in the presence of @code{RTLD_LOCAL}; this
18261is necessary to avoid problems with a library used by two different
18262@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18263therefore disagreeing with the other one about the binding of the
18264symbol. But this causes @code{dlclose} to be ignored for affected
18265DSOs; if your program relies on reinitialization of a DSO via
18266@code{dlclose} and @code{dlopen}, you can use
18267@option{-fno-gnu-unique}.
18268
d77de738 18269@opindex fpcc-struct-return
ddf6fe37 18270@item -fpcc-struct-return
d77de738
ML
18271Return ``short'' @code{struct} and @code{union} values in memory like
18272longer ones, rather than in registers. This convention is less
18273efficient, but it has the advantage of allowing intercallability between
18274GCC-compiled files and files compiled with other compilers, particularly
18275the Portable C Compiler (pcc).
18276
18277The precise convention for returning structures in memory depends
18278on the target configuration macros.
18279
18280Short structures and unions are those whose size and alignment match
18281that of some integer type.
18282
18283@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18284switch is not binary compatible with code compiled with the
18285@option{-freg-struct-return} switch.
18286Use it to conform to a non-default application binary interface.
18287
d77de738 18288@opindex freg-struct-return
ddf6fe37 18289@item -freg-struct-return
d77de738
ML
18290Return @code{struct} and @code{union} values in registers when possible.
18291This is more efficient for small structures than
18292@option{-fpcc-struct-return}.
18293
18294If you specify neither @option{-fpcc-struct-return} nor
18295@option{-freg-struct-return}, GCC defaults to whichever convention is
18296standard for the target. If there is no standard convention, GCC
18297defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18298the principal compiler. In those cases, we can choose the standard, and
18299we chose the more efficient register return alternative.
18300
18301@strong{Warning:} code compiled with the @option{-freg-struct-return}
18302switch is not binary compatible with code compiled with the
18303@option{-fpcc-struct-return} switch.
18304Use it to conform to a non-default application binary interface.
18305
d77de738 18306@opindex fshort-enums
ddf6fe37 18307@item -fshort-enums
d77de738
ML
18308Allocate to an @code{enum} type only as many bytes as it needs for the
18309declared range of possible values. Specifically, the @code{enum} type
18310is equivalent to the smallest integer type that has enough room.
d8a656d5
JW
18311This option has no effect for an enumeration type with a fixed underlying
18312type.
d77de738
ML
18313
18314@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18315code that is not binary compatible with code generated without that switch.
18316Use it to conform to a non-default application binary interface.
18317
d77de738 18318@opindex fshort-wchar
ddf6fe37 18319@item -fshort-wchar
d77de738
ML
18320Override the underlying type for @code{wchar_t} to be @code{short
18321unsigned int} instead of the default for the target. This option is
18322useful for building programs to run under WINE@.
18323
18324@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18325code that is not binary compatible with code generated without that switch.
18326Use it to conform to a non-default application binary interface.
18327
d77de738
ML
18328@opindex fcommon
18329@opindex fno-common
18330@cindex tentative definitions
f33d7a88 18331@item -fcommon
d77de738
ML
18332In C code, this option controls the placement of global variables
18333defined without an initializer, known as @dfn{tentative definitions}
18334in the C standard. Tentative definitions are distinct from declarations
18335of a variable with the @code{extern} keyword, which do not allocate storage.
18336
18337The default is @option{-fno-common}, which specifies that the compiler places
18338uninitialized global variables in the BSS section of the object file.
18339This inhibits the merging of tentative definitions by the linker so you get a
18340multiple-definition error if the same variable is accidentally defined in more
18341than one compilation unit.
18342
18343The @option{-fcommon} places uninitialized global variables in a common block.
18344This allows the linker to resolve all tentative definitions of the same variable
18345in different compilation units to the same object, or to a non-tentative
18346definition. This behavior is inconsistent with C++, and on many targets implies
18347a speed and code size penalty on global variable references. It is mainly
18348useful to enable legacy code to link without errors.
18349
d77de738
ML
18350@opindex fno-ident
18351@opindex fident
ddf6fe37 18352@item -fno-ident
d77de738
ML
18353Ignore the @code{#ident} directive.
18354
d77de738 18355@opindex finhibit-size-directive
ddf6fe37 18356@item -finhibit-size-directive
d77de738
ML
18357Don't output a @code{.size} assembler directive, or anything else that
18358would cause trouble if the function is split in the middle, and the
18359two halves are placed at locations far apart in memory. This option is
18360used when compiling @file{crtstuff.c}; you should not need to use it
18361for anything else.
18362
d77de738 18363@opindex fverbose-asm
ddf6fe37 18364@item -fverbose-asm
d77de738
ML
18365Put extra commentary information in the generated assembly code to
18366make it more readable. This option is generally only of use to those
18367who actually need to read the generated assembly code (perhaps while
18368debugging the compiler itself).
18369
18370@option{-fno-verbose-asm}, the default, causes the
18371extra information to be omitted and is useful when comparing two assembler
18372files.
18373
18374The added comments include:
18375
18376@itemize @bullet
18377
18378@item
18379information on the compiler version and command-line options,
18380
18381@item
18382the source code lines associated with the assembly instructions,
18383in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18384
18385@item
18386hints on which high-level expressions correspond to
18387the various assembly instruction operands.
18388
18389@end itemize
18390
18391For example, given this C source file:
18392
18393@smallexample
18394int test (int n)
18395@{
18396 int i;
18397 int total = 0;
18398
18399 for (i = 0; i < n; i++)
18400 total += i * i;
18401
18402 return total;
18403@}
18404@end smallexample
18405
18406compiling to (x86_64) assembly via @option{-S} and emitting the result
18407direct to stdout via @option{-o} @option{-}
18408
18409@smallexample
18410gcc -S test.c -fverbose-asm -Os -o -
18411@end smallexample
18412
18413gives output similar to this:
18414
18415@smallexample
18416 .file "test.c"
18417# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18418 [...snip...]
18419# options passed:
18420 [...snip...]
18421
18422 .text
18423 .globl test
18424 .type test, @@function
18425test:
18426.LFB0:
18427 .cfi_startproc
18428# test.c:4: int total = 0;
18429 xorl %eax, %eax # <retval>
18430# test.c:6: for (i = 0; i < n; i++)
18431 xorl %edx, %edx # i
18432.L2:
18433# test.c:6: for (i = 0; i < n; i++)
18434 cmpl %edi, %edx # n, i
18435 jge .L5 #,
18436# test.c:7: total += i * i;
18437 movl %edx, %ecx # i, tmp92
18438 imull %edx, %ecx # i, tmp92
18439# test.c:6: for (i = 0; i < n; i++)
18440 incl %edx # i
18441# test.c:7: total += i * i;
18442 addl %ecx, %eax # tmp92, <retval>
18443 jmp .L2 #
18444.L5:
18445# test.c:10: @}
18446 ret
18447 .cfi_endproc
18448.LFE0:
18449 .size test, .-test
18450 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18451 .section .note.GNU-stack,"",@@progbits
18452@end smallexample
18453
18454The comments are intended for humans rather than machines and hence the
18455precise format of the comments is subject to change.
18456
d77de738 18457@opindex frecord-gcc-switches
ddf6fe37 18458@item -frecord-gcc-switches
d77de738
ML
18459This switch causes the command line used to invoke the
18460compiler to be recorded into the object file that is being created.
18461This switch is only implemented on some targets and the exact format
18462of the recording is target and binary file format dependent, but it
18463usually takes the form of a section containing ASCII text. This
18464switch is related to the @option{-fverbose-asm} switch, but that
18465switch only records information in the assembler output file as
18466comments, so it never reaches the object file.
18467See also @option{-grecord-gcc-switches} for another
18468way of storing compiler options into the object file.
18469
d77de738
ML
18470@opindex fpic
18471@cindex global offset table
18472@cindex PIC
f33d7a88 18473@item -fpic
d77de738
ML
18474Generate position-independent code (PIC) suitable for use in a shared
18475library, if supported for the target machine. Such code accesses all
18476constant addresses through a global offset table (GOT)@. The dynamic
18477loader resolves the GOT entries when the program starts (the dynamic
18478loader is not part of GCC; it is part of the operating system). If
18479the GOT size for the linked executable exceeds a machine-specific
18480maximum size, you get an error message from the linker indicating that
18481@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18482instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18483on the m68k and RS/6000. The x86 has no such limit.)
18484
18485Position-independent code requires special support, and therefore works
18486only on certain machines. For the x86, GCC supports PIC for System V
18487but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18488position-independent.
18489
18490When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18491are defined to 1.
18492
d77de738 18493@opindex fPIC
ddf6fe37 18494@item -fPIC
d77de738
ML
18495If supported for the target machine, emit position-independent code,
18496suitable for dynamic linking and avoiding any limit on the size of the
18497global offset table. This option makes a difference on AArch64, m68k,
18498PowerPC and SPARC@.
18499
18500Position-independent code requires special support, and therefore works
18501only on certain machines.
18502
18503When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18504are defined to 2.
18505
d77de738
ML
18506@opindex fpie
18507@opindex fPIE
ddf6fe37
AA
18508@item -fpie
18509@itemx -fPIE
d77de738
ML
18510These options are similar to @option{-fpic} and @option{-fPIC}, but the
18511generated position-independent code can be only linked into executables.
18512Usually these options are used to compile code that will be linked using
18513the @option{-pie} GCC option.
18514
18515@option{-fpie} and @option{-fPIE} both define the macros
18516@code{__pie__} and @code{__PIE__}. The macros have the value 1
18517for @option{-fpie} and 2 for @option{-fPIE}.
18518
d77de738
ML
18519@opindex fno-plt
18520@opindex fplt
ddf6fe37 18521@item -fno-plt
d77de738
ML
18522Do not use the PLT for external function calls in position-independent code.
18523Instead, load the callee address at call sites from the GOT and branch to it.
18524This leads to more efficient code by eliminating PLT stubs and exposing
18525GOT loads to optimizations. On architectures such as 32-bit x86 where
18526PLT stubs expect the GOT pointer in a specific register, this gives more
18527register allocation freedom to the compiler.
18528Lazy binding requires use of the PLT;
18529with @option{-fno-plt} all external symbols are resolved at load time.
18530
18531Alternatively, the function attribute @code{noplt} can be used to avoid calls
18532through the PLT for specific external functions.
18533
18534In position-dependent code, a few targets also convert calls to
18535functions that are marked to not use the PLT to use the GOT instead.
18536
d77de738
ML
18537@opindex fno-jump-tables
18538@opindex fjump-tables
ddf6fe37 18539@item -fno-jump-tables
d77de738
ML
18540Do not use jump tables for switch statements even where it would be
18541more efficient than other code generation strategies. This option is
18542of use in conjunction with @option{-fpic} or @option{-fPIC} for
18543building code that forms part of a dynamic linker and cannot
18544reference the address of a jump table. On some targets, jump tables
18545do not require a GOT and this option is not needed.
18546
d77de738
ML
18547@opindex fno-bit-tests
18548@opindex fbit-tests
ddf6fe37 18549@item -fno-bit-tests
d77de738
ML
18550Do not use bit tests for switch statements even where it would be
18551more efficient than other code generation strategies.
18552
d77de738 18553@opindex ffixed
ddf6fe37 18554@item -ffixed-@var{reg}
d77de738
ML
18555Treat the register named @var{reg} as a fixed register; generated code
18556should never refer to it (except perhaps as a stack pointer, frame
18557pointer or in some other fixed role).
18558
18559@var{reg} must be the name of a register. The register names accepted
18560are machine-specific and are defined in the @code{REGISTER_NAMES}
18561macro in the machine description macro file.
18562
18563This flag does not have a negative form, because it specifies a
18564three-way choice.
18565
d77de738 18566@opindex fcall-used
ddf6fe37 18567@item -fcall-used-@var{reg}
d77de738
ML
18568Treat the register named @var{reg} as an allocable register that is
18569clobbered by function calls. It may be allocated for temporaries or
18570variables that do not live across a call. Functions compiled this way
18571do not save and restore the register @var{reg}.
18572
18573It is an error to use this flag with the frame pointer or stack pointer.
18574Use of this flag for other registers that have fixed pervasive roles in
18575the machine's execution model produces disastrous results.
18576
18577This flag does not have a negative form, because it specifies a
18578three-way choice.
18579
d77de738 18580@opindex fcall-saved
ddf6fe37 18581@item -fcall-saved-@var{reg}
d77de738
ML
18582Treat the register named @var{reg} as an allocable register saved by
18583functions. It may be allocated even for temporaries or variables that
18584live across a call. Functions compiled this way save and restore
18585the register @var{reg} if they use it.
18586
18587It is an error to use this flag with the frame pointer or stack pointer.
18588Use of this flag for other registers that have fixed pervasive roles in
18589the machine's execution model produces disastrous results.
18590
18591A different sort of disaster results from the use of this flag for
18592a register in which function values may be returned.
18593
18594This flag does not have a negative form, because it specifies a
18595three-way choice.
18596
d77de738 18597@opindex fpack-struct
ddf6fe37 18598@item -fpack-struct[=@var{n}]
d77de738
ML
18599Without a value specified, pack all structure members together without
18600holes. When a value is specified (which must be a small power of two), pack
18601structure members according to this value, representing the maximum
18602alignment (that is, objects with default alignment requirements larger than
18603this are output potentially unaligned at the next fitting location.
18604
18605@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18606code that is not binary compatible with code generated without that switch.
18607Additionally, it makes the code suboptimal.
18608Use it to conform to a non-default application binary interface.
18609
d77de738 18610@opindex fleading-underscore
ddf6fe37 18611@item -fleading-underscore
d77de738
ML
18612This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18613change the way C symbols are represented in the object file. One use
18614is to help link with legacy assembly code.
18615
18616@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18617generate code that is not binary compatible with code generated without that
18618switch. Use it to conform to a non-default application binary interface.
18619Not all targets provide complete support for this switch.
18620
d77de738 18621@opindex ftls-model
ddf6fe37 18622@item -ftls-model=@var{model}
d77de738
ML
18623Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18624The @var{model} argument should be one of @samp{global-dynamic},
18625@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18626Note that the choice is subject to optimization: the compiler may use
18627a more efficient model for symbols not visible outside of the translation
18628unit, or if @option{-fpic} is not given on the command line.
18629
18630The default without @option{-fpic} is @samp{initial-exec}; with
18631@option{-fpic} the default is @samp{global-dynamic}.
18632
d77de738 18633@opindex ftrampolines
ddf6fe37 18634@item -ftrampolines
d77de738
ML
18635For targets that normally need trampolines for nested functions, always
18636generate them instead of using descriptors. Otherwise, for targets that
18637do not need them, like for example HP-PA or IA-64, do nothing.
18638
18639A trampoline is a small piece of code that is created at run time on the
18640stack when the address of a nested function is taken, and is used to call
18641the nested function indirectly. Therefore, it requires the stack to be
18642made executable in order for the program to work properly.
18643
18644@option{-fno-trampolines} is enabled by default on a language by language
18645basis to let the compiler avoid generating them, if it computes that this
18646is safe, and replace them with descriptors. Descriptors are made up of data
18647only, but the generated code must be prepared to deal with them. As of this
18648writing, @option{-fno-trampolines} is enabled by default only for Ada.
18649
18650Moreover, code compiled with @option{-ftrampolines} and code compiled with
18651@option{-fno-trampolines} are not binary compatible if nested functions are
18652present. This option must therefore be used on a program-wide basis and be
18653manipulated with extreme care.
18654
18655For languages other than Ada, the @code{-ftrampolines} and
18656@code{-fno-trampolines} options currently have no effect, and
18657trampolines are always generated on platforms that need them
18658for nested functions.
18659
d77de738 18660@opindex fvisibility
ddf6fe37 18661@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
18662Set the default ELF image symbol visibility to the specified option---all
18663symbols are marked with this unless overridden within the code.
18664Using this feature can very substantially improve linking and
18665load times of shared object libraries, produce more optimized
18666code, provide near-perfect API export and prevent symbol clashes.
18667It is @strong{strongly} recommended that you use this in any shared objects
18668you distribute.
18669
18670Despite the nomenclature, @samp{default} always means public; i.e.,
18671available to be linked against from outside the shared object.
18672@samp{protected} and @samp{internal} are pretty useless in real-world
18673usage so the only other commonly used option is @samp{hidden}.
18674The default if @option{-fvisibility} isn't specified is
18675@samp{default}, i.e., make every symbol public.
18676
18677A good explanation of the benefits offered by ensuring ELF
18678symbols have the correct visibility is given by ``How To Write
18679Shared Libraries'' by Ulrich Drepper (which can be found at
18680@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18681solution made possible by this option to marking things hidden when
18682the default is public is to make the default hidden and mark things
18683public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18684and @code{__attribute__ ((visibility("default")))} instead of
18685@code{__declspec(dllexport)} you get almost identical semantics with
18686identical syntax. This is a great boon to those working with
18687cross-platform projects.
18688
18689For those adding visibility support to existing code, you may find
18690@code{#pragma GCC visibility} of use. This works by you enclosing
18691the declarations you wish to set visibility for with (for example)
18692@code{#pragma GCC visibility push(hidden)} and
18693@code{#pragma GCC visibility pop}.
18694Bear in mind that symbol visibility should be viewed @strong{as
18695part of the API interface contract} and thus all new code should
18696always specify visibility when it is not the default; i.e., declarations
18697only for use within the local DSO should @strong{always} be marked explicitly
18698as hidden as so to avoid PLT indirection overheads---making this
18699abundantly clear also aids readability and self-documentation of the code.
18700Note that due to ISO C++ specification requirements, @code{operator new} and
18701@code{operator delete} must always be of default visibility.
18702
18703Be aware that headers from outside your project, in particular system
18704headers and headers from any other library you use, may not be
18705expecting to be compiled with visibility other than the default. You
18706may need to explicitly say @code{#pragma GCC visibility push(default)}
18707before including any such headers.
18708
18709@code{extern} declarations are not affected by @option{-fvisibility}, so
18710a lot of code can be recompiled with @option{-fvisibility=hidden} with
18711no modifications. However, this means that calls to @code{extern}
18712functions with no explicit visibility use the PLT, so it is more
18713effective to use @code{__attribute ((visibility))} and/or
18714@code{#pragma GCC visibility} to tell the compiler which @code{extern}
18715declarations should be treated as hidden.
18716
18717Note that @option{-fvisibility} does affect C++ vague linkage
18718entities. This means that, for instance, an exception class that is
18719be thrown between DSOs must be explicitly marked with default
18720visibility so that the @samp{type_info} nodes are unified between
18721the DSOs.
18722
18723An overview of these techniques, their benefits and how to use them
18724is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
18725
d77de738 18726@opindex fstrict-volatile-bitfields
ddf6fe37 18727@item -fstrict-volatile-bitfields
d77de738
ML
18728This option should be used if accesses to volatile bit-fields (or other
18729structure fields, although the compiler usually honors those types
18730anyway) should use a single access of the width of the
18731field's type, aligned to a natural alignment if possible. For
18732example, targets with memory-mapped peripheral registers might require
18733all such accesses to be 16 bits wide; with this flag you can
18734declare all peripheral bit-fields as @code{unsigned short} (assuming short
18735is 16 bits on these targets) to force GCC to use 16-bit accesses
18736instead of, perhaps, a more efficient 32-bit access.
18737
18738If this option is disabled, the compiler uses the most efficient
18739instruction. In the previous example, that might be a 32-bit load
18740instruction, even though that accesses bytes that do not contain
18741any portion of the bit-field, or memory-mapped registers unrelated to
18742the one being updated.
18743
18744In some cases, such as when the @code{packed} attribute is applied to a
18745structure field, it may not be possible to access the field with a single
18746read or write that is correctly aligned for the target machine. In this
18747case GCC falls back to generating multiple accesses rather than code that
18748will fault or truncate the result at run time.
18749
18750Note: Due to restrictions of the C/C++11 memory model, write accesses are
18751not allowed to touch non bit-field members. It is therefore recommended
18752to define all bits of the field's type as bit-field members.
18753
18754The default value of this option is determined by the application binary
18755interface for the target processor.
18756
d77de738 18757@opindex fsync-libcalls
ddf6fe37 18758@item -fsync-libcalls
d77de738
ML
18759This option controls whether any out-of-line instance of the @code{__sync}
18760family of functions may be used to implement the C++11 @code{__atomic}
18761family of functions.
18762
18763The default value of this option is enabled, thus the only useful form
18764of the option is @option{-fno-sync-libcalls}. This option is used in
18765the implementation of the @file{libatomic} runtime library.
18766
18767@end table
18768
18769@node Developer Options
18770@section GCC Developer Options
18771@cindex developer options
18772@cindex debugging GCC
18773@cindex debug dump options
18774@cindex dump options
18775@cindex compilation statistics
18776
18777This section describes command-line options that are primarily of
18778interest to GCC developers, including options to support compiler
18779testing and investigation of compiler bugs and compile-time
18780performance problems. This includes options that produce debug dumps
18781at various points in the compilation; that print statistics such as
18782memory use and execution time; and that print information about GCC's
18783configuration, such as where it searches for libraries. You should
18784rarely need to use any of these options for ordinary compilation and
18785linking tasks.
18786
18787Many developer options that cause GCC to dump output to a file take an
18788optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
18789or @samp{-} to dump to standard output, and @samp{stderr} for standard
18790error.
18791
18792If @samp{=@var{filename}} is omitted, a default dump file name is
18793constructed by concatenating the base dump file name, a pass number,
18794phase letter, and pass name. The base dump file name is the name of
18795output file produced by the compiler if explicitly specified and not
18796an executable; otherwise it is the source file name.
18797The pass number is determined by the order passes are registered with
18798the compiler's pass manager.
18799This is generally the same as the order of execution, but passes
18800registered by plugins, target-specific passes, or passes that are
18801otherwise registered late are numbered higher than the pass named
18802@samp{final}, even if they are executed earlier. The phase letter is
18803one of @samp{i} (inter-procedural analysis), @samp{l}
18804(language-specific), @samp{r} (RTL), or @samp{t} (tree).
18805The files are created in the directory of the output file.
18806
18807@table @gcctabopt
18808
ddf6fe37 18809@opindex fcallgraph-info
d77de738
ML
18810@item -fcallgraph-info
18811@itemx -fcallgraph-info=@var{MARKERS}
d77de738
ML
18812Makes the compiler output callgraph information for the program, on a
18813per-object-file basis. The information is generated in the common VCG
18814format. It can be decorated with additional, per-node and/or per-edge
18815information, if a list of comma-separated markers is additionally
18816specified. When the @code{su} marker is specified, the callgraph is
18817decorated with stack usage information; it is equivalent to
18818@option{-fstack-usage}. When the @code{da} marker is specified, the
18819callgraph is decorated with information about dynamically allocated
18820objects.
18821
18822When compiling with @option{-flto}, no callgraph information is output
18823along with the object file. At LTO link time, @option{-fcallgraph-info}
18824may generate multiple callgraph information files next to intermediate
18825LTO output files.
18826
ddf6fe37
AA
18827@opindex d
18828@opindex fdump-rtl-@var{pass}
d77de738
ML
18829@item -d@var{letters}
18830@itemx -fdump-rtl-@var{pass}
18831@itemx -fdump-rtl-@var{pass}=@var{filename}
d77de738
ML
18832Says to make debugging dumps during compilation at times specified by
18833@var{letters}. This is used for debugging the RTL-based passes of the
18834compiler.
18835
18836Some @option{-d@var{letters}} switches have different meaning when
18837@option{-E} is used for preprocessing. @xref{Preprocessor Options},
18838for information about preprocessor-specific dump options.
18839
18840Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
18841@option{-d} option @var{letters}. Here are the possible
18842letters for use in @var{pass} and @var{letters}, and their meanings:
18843
18844@table @gcctabopt
18845
d77de738 18846@opindex fdump-rtl-alignments
ddf6fe37 18847@item -fdump-rtl-alignments
d77de738
ML
18848Dump after branch alignments have been computed.
18849
d77de738 18850@opindex fdump-rtl-asmcons
ddf6fe37 18851@item -fdump-rtl-asmcons
d77de738
ML
18852Dump after fixing rtl statements that have unsatisfied in/out constraints.
18853
d77de738 18854@opindex fdump-rtl-auto_inc_dec
ddf6fe37 18855@item -fdump-rtl-auto_inc_dec
d77de738
ML
18856Dump after auto-inc-dec discovery. This pass is only run on
18857architectures that have auto inc or auto dec instructions.
18858
d77de738 18859@opindex fdump-rtl-barriers
ddf6fe37 18860@item -fdump-rtl-barriers
d77de738
ML
18861Dump after cleaning up the barrier instructions.
18862
d77de738 18863@opindex fdump-rtl-bbpart
ddf6fe37 18864@item -fdump-rtl-bbpart
d77de738
ML
18865Dump after partitioning hot and cold basic blocks.
18866
d77de738 18867@opindex fdump-rtl-bbro
ddf6fe37 18868@item -fdump-rtl-bbro
d77de738
ML
18869Dump after block reordering.
18870
d77de738
ML
18871@opindex fdump-rtl-btl2
18872@opindex fdump-rtl-btl2
ddf6fe37
AA
18873@item -fdump-rtl-btl1
18874@itemx -fdump-rtl-btl2
d77de738
ML
18875@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
18876after the two branch
18877target load optimization passes.
18878
d77de738 18879@opindex fdump-rtl-bypass
ddf6fe37 18880@item -fdump-rtl-bypass
d77de738
ML
18881Dump after jump bypassing and control flow optimizations.
18882
d77de738 18883@opindex fdump-rtl-combine
ddf6fe37 18884@item -fdump-rtl-combine
d77de738
ML
18885Dump after the RTL instruction combination pass.
18886
d77de738 18887@opindex fdump-rtl-compgotos
ddf6fe37 18888@item -fdump-rtl-compgotos
d77de738
ML
18889Dump after duplicating the computed gotos.
18890
d77de738
ML
18891@opindex fdump-rtl-ce1
18892@opindex fdump-rtl-ce2
18893@opindex fdump-rtl-ce3
ddf6fe37
AA
18894@item -fdump-rtl-ce1
18895@itemx -fdump-rtl-ce2
18896@itemx -fdump-rtl-ce3
d77de738
ML
18897@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
18898@option{-fdump-rtl-ce3} enable dumping after the three
18899if conversion passes.
18900
d77de738 18901@opindex fdump-rtl-cprop_hardreg
ddf6fe37 18902@item -fdump-rtl-cprop_hardreg
d77de738
ML
18903Dump after hard register copy propagation.
18904
d77de738 18905@opindex fdump-rtl-csa
ddf6fe37 18906@item -fdump-rtl-csa
d77de738
ML
18907Dump after combining stack adjustments.
18908
d77de738
ML
18909@opindex fdump-rtl-cse1
18910@opindex fdump-rtl-cse2
ddf6fe37
AA
18911@item -fdump-rtl-cse1
18912@itemx -fdump-rtl-cse2
d77de738
ML
18913@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
18914the two common subexpression elimination passes.
18915
d77de738 18916@opindex fdump-rtl-dce
ddf6fe37 18917@item -fdump-rtl-dce
d77de738
ML
18918Dump after the standalone dead code elimination passes.
18919
d77de738 18920@opindex fdump-rtl-dbr
ddf6fe37 18921@item -fdump-rtl-dbr
d77de738
ML
18922Dump after delayed branch scheduling.
18923
d77de738
ML
18924@opindex fdump-rtl-dce1
18925@opindex fdump-rtl-dce2
ddf6fe37
AA
18926@item -fdump-rtl-dce1
18927@itemx -fdump-rtl-dce2
d77de738
ML
18928@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
18929the two dead store elimination passes.
18930
d77de738 18931@opindex fdump-rtl-eh
ddf6fe37 18932@item -fdump-rtl-eh
d77de738
ML
18933Dump after finalization of EH handling code.
18934
d77de738 18935@opindex fdump-rtl-eh_ranges
ddf6fe37 18936@item -fdump-rtl-eh_ranges
d77de738
ML
18937Dump after conversion of EH handling range regions.
18938
d77de738 18939@opindex fdump-rtl-expand
ddf6fe37 18940@item -fdump-rtl-expand
d77de738
ML
18941Dump after RTL generation.
18942
d77de738
ML
18943@opindex fdump-rtl-fwprop1
18944@opindex fdump-rtl-fwprop2
ddf6fe37
AA
18945@item -fdump-rtl-fwprop1
18946@itemx -fdump-rtl-fwprop2
d77de738
ML
18947@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
18948dumping after the two forward propagation passes.
18949
d77de738
ML
18950@opindex fdump-rtl-gcse1
18951@opindex fdump-rtl-gcse2
ddf6fe37
AA
18952@item -fdump-rtl-gcse1
18953@itemx -fdump-rtl-gcse2
d77de738
ML
18954@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
18955after global common subexpression elimination.
18956
d77de738 18957@opindex fdump-rtl-init-regs
ddf6fe37 18958@item -fdump-rtl-init-regs
d77de738
ML
18959Dump after the initialization of the registers.
18960
d77de738 18961@opindex fdump-rtl-initvals
ddf6fe37 18962@item -fdump-rtl-initvals
d77de738
ML
18963Dump after the computation of the initial value sets.
18964
d77de738 18965@opindex fdump-rtl-into_cfglayout
ddf6fe37 18966@item -fdump-rtl-into_cfglayout
d77de738
ML
18967Dump after converting to cfglayout mode.
18968
d77de738 18969@opindex fdump-rtl-ira
ddf6fe37 18970@item -fdump-rtl-ira
d77de738
ML
18971Dump after iterated register allocation.
18972
d77de738 18973@opindex fdump-rtl-jump
ddf6fe37 18974@item -fdump-rtl-jump
d77de738
ML
18975Dump after the second jump optimization.
18976
d77de738 18977@opindex fdump-rtl-loop2
ddf6fe37 18978@item -fdump-rtl-loop2
d77de738
ML
18979@option{-fdump-rtl-loop2} enables dumping after the rtl
18980loop optimization passes.
18981
d77de738 18982@opindex fdump-rtl-mach
ddf6fe37 18983@item -fdump-rtl-mach
d77de738
ML
18984Dump after performing the machine dependent reorganization pass, if that
18985pass exists.
18986
d77de738 18987@opindex fdump-rtl-mode_sw
ddf6fe37 18988@item -fdump-rtl-mode_sw
d77de738
ML
18989Dump after removing redundant mode switches.
18990
d77de738 18991@opindex fdump-rtl-rnreg
ddf6fe37 18992@item -fdump-rtl-rnreg
d77de738
ML
18993Dump after register renumbering.
18994
d77de738 18995@opindex fdump-rtl-outof_cfglayout
ddf6fe37 18996@item -fdump-rtl-outof_cfglayout
d77de738
ML
18997Dump after converting from cfglayout mode.
18998
d77de738 18999@opindex fdump-rtl-peephole2
ddf6fe37 19000@item -fdump-rtl-peephole2
d77de738
ML
19001Dump after the peephole pass.
19002
d77de738 19003@opindex fdump-rtl-postreload
ddf6fe37 19004@item -fdump-rtl-postreload
d77de738
ML
19005Dump after post-reload optimizations.
19006
d77de738 19007@opindex fdump-rtl-pro_and_epilogue
ddf6fe37 19008@item -fdump-rtl-pro_and_epilogue
d77de738
ML
19009Dump after generating the function prologues and epilogues.
19010
d77de738
ML
19011@opindex fdump-rtl-sched1
19012@opindex fdump-rtl-sched2
ddf6fe37
AA
19013@item -fdump-rtl-sched1
19014@itemx -fdump-rtl-sched2
d77de738
ML
19015@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
19016after the basic block scheduling passes.
19017
d77de738 19018@opindex fdump-rtl-ree
ddf6fe37 19019@item -fdump-rtl-ree
d77de738
ML
19020Dump after sign/zero extension elimination.
19021
d77de738 19022@opindex fdump-rtl-seqabstr
ddf6fe37 19023@item -fdump-rtl-seqabstr
d77de738
ML
19024Dump after common sequence discovery.
19025
d77de738 19026@opindex fdump-rtl-shorten
ddf6fe37 19027@item -fdump-rtl-shorten
d77de738
ML
19028Dump after shortening branches.
19029
d77de738 19030@opindex fdump-rtl-sibling
ddf6fe37 19031@item -fdump-rtl-sibling
d77de738
ML
19032Dump after sibling call optimizations.
19033
d77de738
ML
19034@opindex fdump-rtl-split1
19035@opindex fdump-rtl-split2
19036@opindex fdump-rtl-split3
19037@opindex fdump-rtl-split4
19038@opindex fdump-rtl-split5
ddf6fe37
AA
19039@item -fdump-rtl-split1
19040@itemx -fdump-rtl-split2
19041@itemx -fdump-rtl-split3
19042@itemx -fdump-rtl-split4
19043@itemx -fdump-rtl-split5
d77de738
ML
19044These options enable dumping after five rounds of
19045instruction splitting.
19046
d77de738 19047@opindex fdump-rtl-sms
ddf6fe37 19048@item -fdump-rtl-sms
d77de738
ML
19049Dump after modulo scheduling. This pass is only run on some
19050architectures.
19051
d77de738 19052@opindex fdump-rtl-stack
ddf6fe37 19053@item -fdump-rtl-stack
d77de738
ML
19054Dump after conversion from GCC's ``flat register file'' registers to the
19055x87's stack-like registers. This pass is only run on x86 variants.
19056
d77de738
ML
19057@opindex fdump-rtl-subreg1
19058@opindex fdump-rtl-subreg2
ddf6fe37
AA
19059@item -fdump-rtl-subreg1
19060@itemx -fdump-rtl-subreg2
d77de738
ML
19061@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
19062the two subreg expansion passes.
19063
d77de738 19064@opindex fdump-rtl-unshare
ddf6fe37 19065@item -fdump-rtl-unshare
d77de738
ML
19066Dump after all rtl has been unshared.
19067
d77de738 19068@opindex fdump-rtl-vartrack
ddf6fe37 19069@item -fdump-rtl-vartrack
d77de738
ML
19070Dump after variable tracking.
19071
d77de738 19072@opindex fdump-rtl-vregs
ddf6fe37 19073@item -fdump-rtl-vregs
d77de738
ML
19074Dump after converting virtual registers to hard registers.
19075
d77de738 19076@opindex fdump-rtl-web
ddf6fe37 19077@item -fdump-rtl-web
d77de738
ML
19078Dump after live range splitting.
19079
d77de738
ML
19080@opindex fdump-rtl-regclass
19081@opindex fdump-rtl-subregs_of_mode_init
19082@opindex fdump-rtl-subregs_of_mode_finish
19083@opindex fdump-rtl-dfinit
19084@opindex fdump-rtl-dfinish
ddf6fe37
AA
19085@item -fdump-rtl-regclass
19086@itemx -fdump-rtl-subregs_of_mode_init
19087@itemx -fdump-rtl-subregs_of_mode_finish
19088@itemx -fdump-rtl-dfinit
19089@itemx -fdump-rtl-dfinish
d77de738
ML
19090These dumps are defined but always produce empty files.
19091
d77de738
ML
19092@opindex da
19093@opindex fdump-rtl-all
ddf6fe37
AA
19094@item -da
19095@itemx -fdump-rtl-all
d77de738
ML
19096Produce all the dumps listed above.
19097
d77de738 19098@opindex dA
ddf6fe37 19099@item -dA
d77de738
ML
19100Annotate the assembler output with miscellaneous debugging information.
19101
d77de738 19102@opindex dD
ddf6fe37 19103@item -dD
d77de738
ML
19104Dump all macro definitions, at the end of preprocessing, in addition to
19105normal output.
19106
d77de738 19107@opindex dH
ddf6fe37 19108@item -dH
d77de738
ML
19109Produce a core dump whenever an error occurs.
19110
d77de738 19111@opindex dp
ddf6fe37 19112@item -dp
d77de738
ML
19113Annotate the assembler output with a comment indicating which
19114pattern and alternative is used. The length and cost of each instruction are
19115also printed.
19116
d77de738 19117@opindex dP
ddf6fe37 19118@item -dP
d77de738
ML
19119Dump the RTL in the assembler output as a comment before each instruction.
19120Also turns on @option{-dp} annotation.
19121
d77de738 19122@opindex dx
ddf6fe37 19123@item -dx
d77de738
ML
19124Just generate RTL for a function instead of compiling it. Usually used
19125with @option{-fdump-rtl-expand}.
19126@end table
19127
d77de738 19128@opindex fdump-debug
ddf6fe37 19129@item -fdump-debug
d77de738
ML
19130Dump debugging information generated during the debug
19131generation phase.
19132
d77de738 19133@opindex fdump-earlydebug
ddf6fe37 19134@item -fdump-earlydebug
d77de738
ML
19135Dump debugging information generated during the early debug
19136generation phase.
19137
d77de738 19138@opindex fdump-noaddr
ddf6fe37 19139@item -fdump-noaddr
d77de738
ML
19140When doing debugging dumps, suppress address output. This makes it more
19141feasible to use diff on debugging dumps for compiler invocations with
19142different compiler binaries and/or different
19143text / bss / data / heap / stack / dso start locations.
19144
d77de738 19145@opindex freport-bug
ddf6fe37 19146@item -freport-bug
d77de738
ML
19147Collect and dump debug information into a temporary file if an
19148internal compiler error (ICE) occurs.
19149
d77de738 19150@opindex fdump-unnumbered
ddf6fe37 19151@item -fdump-unnumbered
d77de738
ML
19152When doing debugging dumps, suppress instruction numbers and address output.
19153This makes it more feasible to use diff on debugging dumps for compiler
19154invocations with different options, in particular with and without
19155@option{-g}.
19156
d77de738 19157@opindex fdump-unnumbered-links
ddf6fe37 19158@item -fdump-unnumbered-links
d77de738
ML
19159When doing debugging dumps (see @option{-d} option above), suppress
19160instruction numbers for the links to the previous and next instructions
19161in a sequence.
19162
ddf6fe37 19163@opindex fdump-ipa
d77de738
ML
19164@item -fdump-ipa-@var{switch}
19165@itemx -fdump-ipa-@var{switch}-@var{options}
d77de738
ML
19166Control the dumping at various stages of inter-procedural analysis
19167language tree to a file. The file name is generated by appending a
19168switch specific suffix to the source file name, and the file is created
19169in the same directory as the output file. The following dumps are
19170possible:
19171
19172@table @samp
19173@item all
19174Enables all inter-procedural analysis dumps.
19175
19176@item cgraph
19177Dumps information about call-graph optimization, unused function removal,
19178and inlining decisions.
19179
19180@item inline
19181Dump after function inlining.
19182
19183@end table
19184
19185Additionally, the options @option{-optimized}, @option{-missed},
19186@option{-note}, and @option{-all} can be provided, with the same meaning
19187as for @option{-fopt-info}, defaulting to @option{-optimized}.
19188
19189For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19190information on callsites that were inlined, along with callsites
19191that were not inlined.
19192
19193By default, the dump will contain messages about successful
19194optimizations (equivalent to @option{-optimized}) together with
19195low-level details about the analysis.
19196
d77de738 19197@opindex fdump-lang
ddf6fe37 19198@item -fdump-lang
d77de738
ML
19199Dump language-specific information. The file name is made by appending
19200@file{.lang} to the source file name.
19201
ddf6fe37
AA
19202@opindex fdump-lang-all
19203@opindex fdump-lang
d77de738
ML
19204@item -fdump-lang-all
19205@itemx -fdump-lang-@var{switch}
19206@itemx -fdump-lang-@var{switch}-@var{options}
19207@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19208Control the dumping of language-specific information. The @var{options}
19209and @var{filename} portions behave as described in the
19210@option{-fdump-tree} option. The following @var{switch} values are
19211accepted:
19212
19213@table @samp
19214@item all
19215
19216Enable all language-specific dumps.
19217
19218@item class
19219Dump class hierarchy information. Virtual table information is emitted
19220unless '@option{slim}' is specified. This option is applicable to C++ only.
19221
19222@item module
19223Dump module information. Options @option{lineno} (locations),
19224@option{graph} (reachability), @option{blocks} (clusters),
19225@option{uid} (serialization), @option{alias} (mergeable),
19226@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19227(macros) may provide additional information. This option is
19228applicable to C++ only.
19229
19230@item raw
19231Dump the raw internal tree data. This option is applicable to C++ only.
19232
19233@end table
19234
d77de738 19235@opindex fdump-passes
ddf6fe37 19236@item -fdump-passes
d77de738
ML
19237Print on @file{stderr} the list of optimization passes that are turned
19238on and off by the current command-line options.
19239
d77de738 19240@opindex fdump-statistics
ddf6fe37 19241@item -fdump-statistics-@var{option}
d77de738
ML
19242Enable and control dumping of pass statistics in a separate file. The
19243file name is generated by appending a suffix ending in
19244@samp{.statistics} to the source file name, and the file is created in
19245the same directory as the output file. If the @samp{-@var{option}}
19246form is used, @samp{-stats} causes counters to be summed over the
19247whole compilation unit while @samp{-details} dumps every event as
19248the passes generate them. The default with no option is to sum
19249counters for each function compiled.
19250
ddf6fe37
AA
19251@opindex fdump-tree-all
19252@opindex fdump-tree
d77de738
ML
19253@item -fdump-tree-all
19254@itemx -fdump-tree-@var{switch}
19255@itemx -fdump-tree-@var{switch}-@var{options}
19256@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19257Control the dumping at various stages of processing the intermediate
19258language tree to a file. If the @samp{-@var{options}}
19259form is used, @var{options} is a list of @samp{-} separated options
19260which control the details of the dump. Not all options are applicable
19261to all dumps; those that are not meaningful are ignored. The
19262following options are available
19263
19264@table @samp
19265@item address
19266Print the address of each node. Usually this is not meaningful as it
19267changes according to the environment and source file. Its primary use
19268is for tying up a dump file with a debug environment.
19269@item asmname
19270If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19271in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19272use working backward from mangled names in the assembly file.
19273@item slim
19274When dumping front-end intermediate representations, inhibit dumping
19275of members of a scope or body of a function merely because that scope
19276has been reached. Only dump such items when they are directly reachable
19277by some other path.
19278
19279When dumping pretty-printed trees, this option inhibits dumping the
19280bodies of control structures.
19281
19282When dumping RTL, print the RTL in slim (condensed) form instead of
19283the default LISP-like representation.
19284@item raw
19285Print a raw representation of the tree. By default, trees are
19286pretty-printed into a C-like representation.
19287@item details
19288Enable more detailed dumps (not honored by every dump option). Also
19289include information from the optimization passes.
19290@item stats
19291Enable dumping various statistics about the pass (not honored by every dump
19292option).
19293@item blocks
19294Enable showing basic block boundaries (disabled in raw dumps).
19295@item graph
19296For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19297dump a representation of the control flow graph suitable for viewing with
19298GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19299the file is pretty-printed as a subgraph, so that GraphViz can render them
19300all in a single plot.
19301
19302This option currently only works for RTL dumps, and the RTL is always
19303dumped in slim form.
19304@item vops
19305Enable showing virtual operands for every statement.
19306@item lineno
19307Enable showing line numbers for statements.
19308@item uid
19309Enable showing the unique ID (@code{DECL_UID}) for each variable.
19310@item verbose
19311Enable showing the tree dump for each statement.
19312@item eh
19313Enable showing the EH region number holding each statement.
19314@item scev
19315Enable showing scalar evolution analysis details.
19316@item optimized
19317Enable showing optimization information (only available in certain
19318passes).
19319@item missed
19320Enable showing missed optimization information (only available in certain
19321passes).
19322@item note
19323Enable other detailed optimization information (only available in
19324certain passes).
19325@item all
19326Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19327and @option{lineno}.
19328@item optall
19329Turn on all optimization options, i.e., @option{optimized},
19330@option{missed}, and @option{note}.
19331@end table
19332
19333To determine what tree dumps are available or find the dump for a pass
19334of interest follow the steps below.
19335
19336@enumerate
19337@item
19338Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19339look for a code that corresponds to the pass you are interested in.
19340For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19341@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19342The number at the end distinguishes distinct invocations of the same pass.
19343@item
19344To enable the creation of the dump file, append the pass code to
19345the @option{-fdump-} option prefix and invoke GCC with it. For example,
19346to enable the dump from the Early Value Range Propagation pass, invoke
19347GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19348specify the name of the dump file. If you don't specify one, GCC
19349creates as described below.
19350@item
19351Find the pass dump in a file whose name is composed of three components
19352separated by a period: the name of the source file GCC was invoked to
19353compile, a numeric suffix indicating the pass number followed by the
19354letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19355and finally the pass code. For example, the Early VRP pass dump might
19356be in a file named @file{myfile.c.038t.evrp} in the current working
19357directory. Note that the numeric codes are not stable and may change
19358from one version of GCC to another.
19359@end enumerate
19360
ddf6fe37 19361@opindex fopt-info
d77de738
ML
19362@item -fopt-info
19363@itemx -fopt-info-@var{options}
19364@itemx -fopt-info-@var{options}=@var{filename}
d77de738
ML
19365Controls optimization dumps from various optimization passes. If the
19366@samp{-@var{options}} form is used, @var{options} is a list of
19367@samp{-} separated option keywords to select the dump details and
19368optimizations.
19369
19370The @var{options} can be divided into three groups:
19371@enumerate
19372@item
19373options describing what kinds of messages should be emitted,
19374@item
19375options describing the verbosity of the dump, and
19376@item
19377options describing which optimizations should be included.
19378@end enumerate
19379The options from each group can be freely mixed as they are
19380non-overlapping. However, in case of any conflicts,
19381the later options override the earlier options on the command
19382line.
19383
19384The following options control which kinds of messages should be emitted:
19385
19386@table @samp
19387@item optimized
19388Print information when an optimization is successfully applied. It is
19389up to a pass to decide which information is relevant. For example, the
19390vectorizer passes print the source location of loops which are
19391successfully vectorized.
19392@item missed
19393Print information about missed optimizations. Individual passes
19394control which information to include in the output.
19395@item note
19396Print verbose information about optimizations, such as certain
19397transformations, more detailed messages about decisions etc.
19398@item all
19399Print detailed optimization information. This includes
19400@samp{optimized}, @samp{missed}, and @samp{note}.
19401@end table
19402
19403The following option controls the dump verbosity:
19404
19405@table @samp
19406@item internals
19407By default, only ``high-level'' messages are emitted. This option enables
19408additional, more detailed, messages, which are likely to only be of interest
19409to GCC developers.
19410@end table
19411
19412One or more of the following option keywords can be used to describe a
19413group of optimizations:
19414
19415@table @samp
19416@item ipa
19417Enable dumps from all interprocedural optimizations.
19418@item loop
19419Enable dumps from all loop optimizations.
19420@item inline
19421Enable dumps from all inlining optimizations.
19422@item omp
19423Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19424@item vec
19425Enable dumps from all vectorization optimizations.
19426@item optall
19427Enable dumps from all optimizations. This is a superset of
19428the optimization groups listed above.
19429@end table
19430
19431If @var{options} is
19432omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19433about successful optimizations from all the passes, omitting messages
19434that are treated as ``internals''.
19435
19436If the @var{filename} is provided, then the dumps from all the
19437applicable optimizations are concatenated into the @var{filename}.
19438Otherwise the dump is output onto @file{stderr}. Though multiple
19439@option{-fopt-info} options are accepted, only one of them can include
19440a @var{filename}. If other filenames are provided then all but the
19441first such option are ignored.
19442
19443Note that the output @var{filename} is overwritten
19444in case of multiple translation units. If a combined output from
19445multiple translation units is desired, @file{stderr} should be used
19446instead.
19447
19448In the following example, the optimization info is output to
19449@file{stderr}:
19450
19451@smallexample
19452gcc -O3 -fopt-info
19453@end smallexample
19454
19455This example:
19456@smallexample
19457gcc -O3 -fopt-info-missed=missed.all
19458@end smallexample
19459
19460@noindent
19461outputs missed optimization report from all the passes into
19462@file{missed.all}, and this one:
19463
19464@smallexample
19465gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19466@end smallexample
19467
19468@noindent
19469prints information about missed optimization opportunities from
19470vectorization passes on @file{stderr}.
19471Note that @option{-fopt-info-vec-missed} is equivalent to
19472@option{-fopt-info-missed-vec}. The order of the optimization group
19473names and message types listed after @option{-fopt-info} does not matter.
19474
19475As another example,
19476@smallexample
19477gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19478@end smallexample
19479
19480@noindent
19481outputs information about missed optimizations as well as
19482optimized locations from all the inlining passes into
19483@file{inline.txt}.
19484
19485Finally, consider:
19486
19487@smallexample
19488gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19489@end smallexample
19490
19491@noindent
19492Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19493in conflict since only one output file is allowed. In this case, only
19494the first option takes effect and the subsequent options are
19495ignored. Thus only @file{vec.miss} is produced which contains
19496dumps from the vectorizer about missed opportunities.
19497
d77de738 19498@opindex fsave-optimization-record
ddf6fe37 19499@item -fsave-optimization-record
d77de738
ML
19500Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19501were performed, for those optimizations that support @option{-fopt-info}.
19502
19503This option is experimental and the format of the data within the
19504compressed JSON file is subject to change.
19505
19506It is roughly equivalent to a machine-readable version of
19507@option{-fopt-info-all}, as a collection of messages with source file,
19508line number and column number, with the following additional data for
19509each message:
19510
19511@itemize @bullet
19512
19513@item
19514the execution count of the code being optimized, along with metadata about
19515whether this was from actual profile data, or just an estimate, allowing
19516consumers to prioritize messages by code hotness,
19517
19518@item
19519the function name of the code being optimized, where applicable,
19520
19521@item
19522the ``inlining chain'' for the code being optimized, so that when
19523a function is inlined into several different places (which might
19524themselves be inlined), the reader can distinguish between the copies,
19525
19526@item
19527objects identifying those parts of the message that refer to expressions,
19528statements or symbol-table nodes, which of these categories they are, and,
19529when available, their source code location,
19530
19531@item
19532the GCC pass that emitted the message, and
19533
19534@item
19535the location in GCC's own code from which the message was emitted
19536
19537@end itemize
19538
19539Additionally, some messages are logically nested within other
19540messages, reflecting implementation details of the optimization
19541passes.
19542
d77de738 19543@opindex fsched-verbose
ddf6fe37 19544@item -fsched-verbose=@var{n}
d77de738
ML
19545On targets that use instruction scheduling, this option controls the
19546amount of debugging output the scheduler prints to the dump files.
19547
19548For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19549same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19550For @var{n} greater than one, it also output basic block probabilities,
19551detailed ready list information and unit/insn info. For @var{n} greater
19552than two, it includes RTL at abort point, control-flow and regions info.
19553And for @var{n} over four, @option{-fsched-verbose} also includes
19554dependence info.
19555
19556
19557
d77de738
ML
19558@opindex fdisable-
19559@opindex fenable-
ddf6fe37
AA
19560@item -fenable-@var{kind}-@var{pass}
19561@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
d77de738
ML
19562
19563This is a set of options that are used to explicitly disable/enable
19564optimization passes. These options are intended for use for debugging GCC.
19565Compiler users should use regular options for enabling/disabling
19566passes instead.
19567
19568@table @gcctabopt
19569
19570@item -fdisable-ipa-@var{pass}
19571Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19572statically invoked in the compiler multiple times, the pass name should be
19573appended with a sequential number starting from 1.
19574
19575@item -fdisable-rtl-@var{pass}
19576@itemx -fdisable-rtl-@var{pass}=@var{range-list}
19577Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19578statically invoked in the compiler multiple times, the pass name should be
19579appended with a sequential number starting from 1. @var{range-list} is a
19580comma-separated list of function ranges or assembler names. Each range is a number
19581pair separated by a colon. The range is inclusive in both ends. If the range
19582is trivial, the number pair can be simplified as a single number. If the
19583function's call graph node's @var{uid} falls within one of the specified ranges,
19584the @var{pass} is disabled for that function. The @var{uid} is shown in the
19585function header of a dump file, and the pass names can be dumped by using
19586option @option{-fdump-passes}.
19587
19588@item -fdisable-tree-@var{pass}
19589@itemx -fdisable-tree-@var{pass}=@var{range-list}
19590Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19591option arguments.
19592
19593@item -fenable-ipa-@var{pass}
19594Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19595statically invoked in the compiler multiple times, the pass name should be
19596appended with a sequential number starting from 1.
19597
19598@item -fenable-rtl-@var{pass}
19599@itemx -fenable-rtl-@var{pass}=@var{range-list}
19600Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19601description and examples.
19602
19603@item -fenable-tree-@var{pass}
19604@itemx -fenable-tree-@var{pass}=@var{range-list}
19605Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19606of option arguments.
19607
19608@end table
19609
19610Here are some examples showing uses of these options.
19611
19612@smallexample
19613
19614# disable ccp1 for all functions
19615 -fdisable-tree-ccp1
19616# disable complete unroll for function whose cgraph node uid is 1
19617 -fenable-tree-cunroll=1
19618# disable gcse2 for functions at the following ranges [1,1],
19619# [300,400], and [400,1000]
19620# disable gcse2 for functions foo and foo2
19621 -fdisable-rtl-gcse2=foo,foo2
19622# disable early inlining
19623 -fdisable-tree-einline
19624# disable ipa inlining
19625 -fdisable-ipa-inline
19626# enable tree full unroll
19627 -fenable-tree-unroll
19628
19629@end smallexample
19630
d77de738
ML
19631@opindex fchecking
19632@opindex fno-checking
ddf6fe37
AA
19633@item -fchecking
19634@itemx -fchecking=@var{n}
d77de738
ML
19635Enable internal consistency checking. The default depends on
19636the compiler configuration. @option{-fchecking=2} enables further
19637internal consistency checking that might affect code generation.
19638
d77de738 19639@opindex frandom-seed
ddf6fe37 19640@item -frandom-seed=@var{string}
d77de738
ML
19641This option provides a seed that GCC uses in place of
19642random numbers in generating certain symbol names
19643that have to be different in every compiled file. It is also used to
19644place unique stamps in coverage data files and the object files that
19645produce them. You can use the @option{-frandom-seed} option to produce
19646reproducibly identical object files.
19647
19648The @var{string} can either be a number (decimal, octal or hex) or an
19649arbitrary string (in which case it's converted to a number by
19650computing CRC32).
19651
19652The @var{string} should be different for every file you compile.
19653
d77de738 19654@opindex save-temps
ddf6fe37 19655@item -save-temps
d77de738
ML
19656Store the usual ``temporary'' intermediate files permanently; name them
19657as auxiliary output files, as specified described under
19658@option{-dumpbase} and @option{-dumpdir}.
19659
19660When used in combination with the @option{-x} command-line option,
19661@option{-save-temps} is sensible enough to avoid overwriting an
19662input source file with the same extension as an intermediate file.
19663The corresponding intermediate file may be obtained by renaming the
19664source file before using @option{-save-temps}.
19665
d77de738 19666@opindex save-temps=cwd
ddf6fe37 19667@item -save-temps=cwd
d77de738
ML
19668Equivalent to @option{-save-temps -dumpdir ./}.
19669
d77de738 19670@opindex save-temps=obj
ddf6fe37 19671@item -save-temps=obj
d77de738
ML
19672Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19673@file{outdir/} is the directory of the output file specified after the
19674@option{-o} option, including any directory separators. If the
19675@option{-o} option is not used, the @option{-save-temps=obj} switch
19676behaves like @option{-save-temps=cwd}.
19677
d77de738 19678@opindex time
ddf6fe37 19679@item -time@r{[}=@var{file}@r{]}
d77de738
ML
19680Report the CPU time taken by each subprocess in the compilation
19681sequence. For C source files, this is the compiler proper and assembler
19682(plus the linker if linking is done).
19683
19684Without the specification of an output file, the output looks like this:
19685
19686@smallexample
19687# cc1 0.12 0.01
19688# as 0.00 0.01
19689@end smallexample
19690
19691The first number on each line is the ``user time'', that is time spent
19692executing the program itself. The second number is ``system time'',
19693time spent executing operating system routines on behalf of the program.
19694Both numbers are in seconds.
19695
19696With the specification of an output file, the output is appended to the
19697named file, and it looks like this:
19698
19699@smallexample
197000.12 0.01 cc1 @var{options}
197010.00 0.01 as @var{options}
19702@end smallexample
19703
19704The ``user time'' and the ``system time'' are moved before the program
19705name, and the options passed to the program are displayed, so that one
19706can later tell what file was being compiled, and with which options.
19707
d77de738 19708@opindex fdump-final-insns
ddf6fe37 19709@item -fdump-final-insns@r{[}=@var{file}@r{]}
d77de738
ML
19710Dump the final internal representation (RTL) to @var{file}. If the
19711optional argument is omitted (or if @var{file} is @code{.}), the name
19712of the dump file is determined by appending @code{.gkd} to the
19713dump base name, see @option{-dumpbase}.
19714
d77de738
ML
19715@opindex fcompare-debug
19716@opindex fno-compare-debug
ddf6fe37 19717@item -fcompare-debug@r{[}=@var{opts}@r{]}
d77de738
ML
19718If no error occurs during compilation, run the compiler a second time,
19719adding @var{opts} and @option{-fcompare-debug-second} to the arguments
19720passed to the second compilation. Dump the final internal
19721representation in both compilations, and print an error if they differ.
19722
19723If the equal sign is omitted, the default @option{-gtoggle} is used.
19724
19725The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
19726and nonzero, implicitly enables @option{-fcompare-debug}. If
19727@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
19728then it is used for @var{opts}, otherwise the default @option{-gtoggle}
19729is used.
19730
19731@option{-fcompare-debug=}, with the equal sign but without @var{opts},
19732is equivalent to @option{-fno-compare-debug}, which disables the dumping
19733of the final representation and the second compilation, preventing even
19734@env{GCC_COMPARE_DEBUG} from taking effect.
19735
19736To verify full coverage during @option{-fcompare-debug} testing, set
19737@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
19738which GCC rejects as an invalid option in any actual compilation
19739(rather than preprocessing, assembly or linking). To get just a
19740warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
19741not overridden} will do.
19742
d77de738 19743@opindex fcompare-debug-second
ddf6fe37 19744@item -fcompare-debug-second
d77de738
ML
19745This option is implicitly passed to the compiler for the second
19746compilation requested by @option{-fcompare-debug}, along with options to
19747silence warnings, and omitting other options that would cause the compiler
19748to produce output to files or to standard output as a side effect. Dump
19749files and preserved temporary files are renamed so as to contain the
19750@code{.gk} additional extension during the second compilation, to avoid
19751overwriting those generated by the first.
19752
19753When this option is passed to the compiler driver, it causes the
19754@emph{first} compilation to be skipped, which makes it useful for little
19755other than debugging the compiler proper.
19756
d77de738 19757@opindex gtoggle
ddf6fe37 19758@item -gtoggle
d77de738
ML
19759Turn off generation of debug info, if leaving out this option
19760generates it, or turn it on at level 2 otherwise. The position of this
19761argument in the command line does not matter; it takes effect after all
19762other options are processed, and it does so only once, no matter how
19763many times it is given. This is mainly intended to be used with
19764@option{-fcompare-debug}.
19765
d77de738
ML
19766@opindex fvar-tracking-assignments-toggle
19767@opindex fno-var-tracking-assignments-toggle
ddf6fe37 19768@item -fvar-tracking-assignments-toggle
d77de738
ML
19769Toggle @option{-fvar-tracking-assignments}, in the same way that
19770@option{-gtoggle} toggles @option{-g}.
19771
d77de738 19772@opindex Q
ddf6fe37 19773@item -Q
d77de738
ML
19774Makes the compiler print out each function name as it is compiled, and
19775print some statistics about each pass when it finishes.
19776
d77de738 19777@opindex ftime-report
ddf6fe37 19778@item -ftime-report
d77de738
ML
19779Makes the compiler print some statistics about the time consumed by each
19780pass when it finishes.
19781
d77de738 19782@opindex ftime-report-details
ddf6fe37 19783@item -ftime-report-details
d77de738
ML
19784Record the time consumed by infrastructure parts separately for each pass.
19785
d77de738 19786@opindex fira-verbose
ddf6fe37 19787@item -fira-verbose=@var{n}
d77de738
ML
19788Control the verbosity of the dump file for the integrated register allocator.
19789The default value is 5. If the value @var{n} is greater or equal to 10,
19790the dump output is sent to stderr using the same format as @var{n} minus 10.
19791
d77de738 19792@opindex flto-report
ddf6fe37 19793@item -flto-report
d77de738
ML
19794Prints a report with internal details on the workings of the link-time
19795optimizer. The contents of this report vary from version to version.
19796It is meant to be useful to GCC developers when processing object
19797files in LTO mode (via @option{-flto}).
19798
19799Disabled by default.
19800
d77de738 19801@opindex flto-report-wpa
ddf6fe37 19802@item -flto-report-wpa
d77de738
ML
19803Like @option{-flto-report}, but only print for the WPA phase of link-time
19804optimization.
19805
d77de738 19806@opindex fmem-report
ddf6fe37 19807@item -fmem-report
d77de738
ML
19808Makes the compiler print some statistics about permanent memory
19809allocation when it finishes.
19810
d77de738 19811@opindex fmem-report-wpa
ddf6fe37 19812@item -fmem-report-wpa
d77de738
ML
19813Makes the compiler print some statistics about permanent memory
19814allocation for the WPA phase only.
19815
d77de738 19816@opindex fpre-ipa-mem-report
d77de738 19817@opindex fpost-ipa-mem-report
ddf6fe37
AA
19818@item -fpre-ipa-mem-report
19819@item -fpost-ipa-mem-report
d77de738
ML
19820Makes the compiler print some statistics about permanent memory
19821allocation before or after interprocedural optimization.
19822
d77de738 19823@opindex fmultiflags
ddf6fe37 19824@item -fmultiflags
d77de738
ML
19825This option enables multilib-aware @code{TFLAGS} to be used to build
19826target libraries with options different from those the compiler is
19827configured to use by default, through the use of specs (@xref{Spec
19828Files}) set up by compiler internals, by the target, or by builders at
19829configure time.
19830
19831Like @code{TFLAGS}, this allows the target libraries to be built for
19832portable baseline environments, while the compiler defaults to more
19833demanding ones. That's useful because users can easily override the
19834defaults the compiler is configured to use to build their own programs,
19835if the defaults are not ideal for their target environment, whereas
19836rebuilding the runtime libraries is usually not as easy or desirable.
19837
19838Unlike @code{TFLAGS}, the use of specs enables different flags to be
19839selected for different multilibs. The way to accomplish that is to
19840build with @samp{make TFLAGS=-fmultiflags}, after configuring
19841@samp{--with-specs=%@{fmultiflags:...@}}.
19842
19843This option is discarded by the driver once it's done processing driver
19844self spec.
19845
19846It is also useful to check that @code{TFLAGS} are being used to build
19847all target libraries, by configuring a non-bootstrap compiler
19848@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
19849the compiler and target libraries.
19850
d77de738 19851@opindex fprofile-report
ddf6fe37 19852@item -fprofile-report
d77de738
ML
19853Makes the compiler print some statistics about consistency of the
19854(estimated) profile and effect of individual passes.
19855
d77de738 19856@opindex fstack-usage
ddf6fe37 19857@item -fstack-usage
d77de738
ML
19858Makes the compiler output stack usage information for the program, on a
19859per-function basis. The filename for the dump is made by appending
19860@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
19861the output file, if explicitly specified and it is not an executable,
19862otherwise it is the basename of the source file. An entry is made up
19863of three fields:
19864
19865@itemize
19866@item
19867The name of the function.
19868@item
19869A number of bytes.
19870@item
19871One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
19872@end itemize
19873
19874The qualifier @code{static} means that the function manipulates the stack
19875statically: a fixed number of bytes are allocated for the frame on function
19876entry and released on function exit; no stack adjustments are otherwise made
19877in the function. The second field is this fixed number of bytes.
19878
19879The qualifier @code{dynamic} means that the function manipulates the stack
19880dynamically: in addition to the static allocation described above, stack
19881adjustments are made in the body of the function, for example to push/pop
19882arguments around function calls. If the qualifier @code{bounded} is also
19883present, the amount of these adjustments is bounded at compile time and
19884the second field is an upper bound of the total amount of stack used by
19885the function. If it is not present, the amount of these adjustments is
19886not bounded at compile time and the second field only represents the
19887bounded part.
19888
d77de738 19889@opindex fstats
ddf6fe37 19890@item -fstats
d77de738
ML
19891Emit statistics about front-end processing at the end of the compilation.
19892This option is supported only by the C++ front end, and
19893the information is generally only useful to the G++ development team.
19894
d77de738 19895@opindex fdbg-cnt-list
ddf6fe37 19896@item -fdbg-cnt-list
d77de738
ML
19897Print the name and the counter upper bound for all debug counters.
19898
19899
d77de738 19900@opindex fdbg-cnt
ddf6fe37 19901@item -fdbg-cnt=@var{counter-value-list}
d77de738
ML
19902Set the internal debug counter lower and upper bound. @var{counter-value-list}
19903is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
19904[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
19905the name of the counter and list of closed intervals.
19906The @var{lower_bound} is optional and is zero
19907initialized if not set.
19908For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
19909@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
19910eleventh invocation.
19911For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
19912
d77de738 19913@opindex print-file-name
ddf6fe37 19914@item -print-file-name=@var{library}
d77de738
ML
19915Print the full absolute name of the library file @var{library} that
19916would be used when linking---and don't do anything else. With this
19917option, GCC does not compile or link anything; it just prints the
19918file name.
19919
d77de738 19920@opindex print-multi-directory
ddf6fe37 19921@item -print-multi-directory
d77de738
ML
19922Print the directory name corresponding to the multilib selected by any
19923other switches present in the command line. This directory is supposed
19924to exist in @env{GCC_EXEC_PREFIX}.
19925
d77de738 19926@opindex print-multi-lib
ddf6fe37 19927@item -print-multi-lib
d77de738
ML
19928Print the mapping from multilib directory names to compiler switches
19929that enable them. The directory name is separated from the switches by
19930@samp{;}, and each switch starts with an @samp{@@} instead of the
19931@samp{-}, without spaces between multiple switches. This is supposed to
19932ease shell processing.
19933
d77de738 19934@opindex print-multi-os-directory
ddf6fe37 19935@item -print-multi-os-directory
d77de738
ML
19936Print the path to OS libraries for the selected
19937multilib, relative to some @file{lib} subdirectory. If OS libraries are
19938present in the @file{lib} subdirectory and no multilibs are used, this is
19939usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
19940sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
19941@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
19942subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
19943
d77de738 19944@opindex print-multiarch
ddf6fe37 19945@item -print-multiarch
d77de738
ML
19946Print the path to OS libraries for the selected multiarch,
19947relative to some @file{lib} subdirectory.
19948
d77de738 19949@opindex print-prog-name
ddf6fe37 19950@item -print-prog-name=@var{program}
d77de738
ML
19951Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
19952
d77de738 19953@opindex print-libgcc-file-name
ddf6fe37 19954@item -print-libgcc-file-name
d77de738
ML
19955Same as @option{-print-file-name=libgcc.a}.
19956
19957This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
19958but you do want to link with @file{libgcc.a}. You can do:
19959
19960@smallexample
19961gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
19962@end smallexample
19963
d77de738 19964@opindex print-search-dirs
ddf6fe37 19965@item -print-search-dirs
d77de738
ML
19966Print the name of the configured installation directory and a list of
19967program and library directories @command{gcc} searches---and don't do anything else.
19968
19969This is useful when @command{gcc} prints the error message
19970@samp{installation problem, cannot exec cpp0: No such file or directory}.
19971To resolve this you either need to put @file{cpp0} and the other compiler
19972components where @command{gcc} expects to find them, or you can set the environment
19973variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
19974Don't forget the trailing @samp{/}.
19975@xref{Environment Variables}.
19976
d77de738 19977@opindex print-sysroot
ddf6fe37 19978@item -print-sysroot
d77de738
ML
19979Print the target sysroot directory that is used during
19980compilation. This is the target sysroot specified either at configure
19981time or using the @option{--sysroot} option, possibly with an extra
19982suffix that depends on compilation options. If no target sysroot is
19983specified, the option prints nothing.
19984
d77de738 19985@opindex print-sysroot-headers-suffix
ddf6fe37 19986@item -print-sysroot-headers-suffix
d77de738
ML
19987Print the suffix added to the target sysroot when searching for
19988headers, or give an error if the compiler is not configured with such
19989a suffix---and don't do anything else.
19990
d77de738 19991@opindex dumpmachine
ddf6fe37 19992@item -dumpmachine
d77de738
ML
19993Print the compiler's target machine (for example,
19994@samp{i686-pc-linux-gnu})---and don't do anything else.
19995
d77de738 19996@opindex dumpversion
ddf6fe37 19997@item -dumpversion
d77de738
ML
19998Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
19999anything else. This is the compiler version used in filesystem paths and
20000specs. Depending on how the compiler has been configured it can be just
20001a single number (major version), two numbers separated by a dot (major and
20002minor version) or three numbers separated by dots (major, minor and patchlevel
20003version).
20004
d77de738 20005@opindex dumpfullversion
ddf6fe37 20006@item -dumpfullversion
d77de738
ML
20007Print the full compiler version---and don't do anything else. The output is
20008always three numbers separated by dots, major, minor and patchlevel version.
20009
d77de738 20010@opindex dumpspecs
ddf6fe37 20011@item -dumpspecs
d77de738
ML
20012Print the compiler's built-in specs---and don't do anything else. (This
20013is used when GCC itself is being built.) @xref{Spec Files}.
20014@end table
20015
20016@node Submodel Options
20017@section Machine-Dependent Options
20018@cindex submodel options
20019@cindex specifying hardware config
20020@cindex hardware models and configurations, specifying
20021@cindex target-dependent options
20022@cindex machine-dependent options
20023
20024Each target machine supported by GCC can have its own options---for
20025example, to allow you to compile for a particular processor variant or
20026ABI, or to control optimizations specific to that machine. By
20027convention, the names of machine-specific options start with
20028@samp{-m}.
20029
20030Some configurations of the compiler also support additional target-specific
20031options, usually for compatibility with other compilers on the same
20032platform.
20033
20034@c This list is ordered alphanumerically by subsection name.
20035@c It should be the same order and spelling as these options are listed
20036@c in Machine Dependent Options
20037
20038@menu
20039* AArch64 Options::
20040* Adapteva Epiphany Options::
20041* AMD GCN Options::
20042* ARC Options::
20043* ARM Options::
20044* AVR Options::
20045* Blackfin Options::
20046* C6X Options::
20047* CRIS Options::
20048* C-SKY Options::
20049* Darwin Options::
20050* DEC Alpha Options::
20051* eBPF Options::
20052* FR30 Options::
20053* FT32 Options::
20054* FRV Options::
20055* GNU/Linux Options::
20056* H8/300 Options::
20057* HPPA Options::
20058* IA-64 Options::
20059* LM32 Options::
20060* LoongArch Options::
20061* M32C Options::
20062* M32R/D Options::
20063* M680x0 Options::
20064* MCore Options::
d77de738
ML
20065* MicroBlaze Options::
20066* MIPS Options::
20067* MMIX Options::
20068* MN10300 Options::
20069* Moxie Options::
20070* MSP430 Options::
20071* NDS32 Options::
20072* Nios II Options::
20073* Nvidia PTX Options::
20074* OpenRISC Options::
20075* PDP-11 Options::
d77de738
ML
20076* PowerPC Options::
20077* PRU Options::
20078* RISC-V Options::
20079* RL78 Options::
20080* RS/6000 and PowerPC Options::
20081* RX Options::
20082* S/390 and zSeries Options::
d77de738
ML
20083* SH Options::
20084* Solaris 2 Options::
20085* SPARC Options::
20086* System V Options::
20087* V850 Options::
20088* VAX Options::
20089* Visium Options::
20090* VMS Options::
20091* VxWorks Options::
20092* x86 Options::
20093* x86 Windows Options::
20094* Xstormy16 Options::
20095* Xtensa Options::
20096* zSeries Options::
20097@end menu
20098
20099@node AArch64 Options
20100@subsection AArch64 Options
20101@cindex AArch64 Options
20102
20103These options are defined for AArch64 implementations:
20104
20105@table @gcctabopt
20106
d77de738 20107@opindex mabi
ddf6fe37 20108@item -mabi=@var{name}
d77de738
ML
20109Generate code for the specified data model. Permissible values
20110are @samp{ilp32} for SysV-like data model where int, long int and pointers
20111are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
20112but long int and pointers are 64 bits.
20113
20114The default depends on the specific target configuration. Note that
20115the LP64 and ILP32 ABIs are not link-compatible; you must compile your
20116entire program with the same ABI, and link with a compatible set of libraries.
20117
d77de738 20118@opindex mbig-endian
ddf6fe37 20119@item -mbig-endian
d77de738
ML
20120Generate big-endian code. This is the default when GCC is configured for an
20121@samp{aarch64_be-*-*} target.
20122
d77de738 20123@opindex mgeneral-regs-only
ddf6fe37 20124@item -mgeneral-regs-only
d77de738
ML
20125Generate code which uses only the general-purpose registers. This will prevent
20126the compiler from using floating-point and Advanced SIMD registers but will not
20127impose any restrictions on the assembler.
20128
d77de738 20129@opindex mlittle-endian
ddf6fe37 20130@item -mlittle-endian
d77de738
ML
20131Generate little-endian code. This is the default when GCC is configured for an
20132@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
20133
d77de738 20134@opindex mcmodel=tiny
ddf6fe37 20135@item -mcmodel=tiny
d77de738
ML
20136Generate code for the tiny code model. The program and its statically defined
20137symbols must be within 1MB of each other. Programs can be statically or
20138dynamically linked.
20139
d77de738 20140@opindex mcmodel=small
ddf6fe37 20141@item -mcmodel=small
d77de738
ML
20142Generate code for the small code model. The program and its statically defined
20143symbols must be within 4GB of each other. Programs can be statically or
20144dynamically linked. This is the default code model.
20145
d77de738 20146@opindex mcmodel=large
ddf6fe37 20147@item -mcmodel=large
d77de738
ML
20148Generate code for the large code model. This makes no assumptions about
20149addresses and sizes of sections. Programs can be statically linked only. The
20150@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20151@option{-fpic} and @option{-fPIC}.
20152
573624ec
KT
20153@item -mtp=@var{name}
20154@opindex mtp
20155Specify the system register to use as a thread pointer. The valid values
20156are @samp{el0}, @samp{el1}, @samp{el2}, @samp{el3}. These correspond to
20157using the @samp{tpidr_el0}, @samp{tpidr_el1}, @samp{tpidr_el2},
20158@samp{tpidr_el3} registers accordingly. The default setting is @samp{el0}.
20159It is recommended to compile all code intended to interoperate with the same
20160value of this option to avoid accessing a different thread pointer from the
20161wrong exception level.
20162
d77de738
ML
20163@opindex mstrict-align
20164@opindex mno-strict-align
ddf6fe37
AA
20165@item -mstrict-align
20166@itemx -mno-strict-align
d77de738
ML
20167Avoid or allow generating memory accesses that may not be aligned on a natural
20168object boundary as described in the architecture specification.
20169
d77de738
ML
20170@opindex momit-leaf-frame-pointer
20171@opindex mno-omit-leaf-frame-pointer
ddf6fe37
AA
20172@item -momit-leaf-frame-pointer
20173@itemx -mno-omit-leaf-frame-pointer
d77de738
ML
20174Omit or keep the frame pointer in leaf functions. The former behavior is the
20175default.
20176
d77de738
ML
20177@opindex mstack-protector-guard
20178@opindex mstack-protector-guard-reg
20179@opindex mstack-protector-guard-offset
ddf6fe37
AA
20180@item -mstack-protector-guard=@var{guard}
20181@itemx -mstack-protector-guard-reg=@var{reg}
20182@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
20183Generate stack protection code using canary at @var{guard}. Supported
20184locations are @samp{global} for a global canary or @samp{sysreg} for a
20185canary in an appropriate system register.
20186
20187With the latter choice the options
20188@option{-mstack-protector-guard-reg=@var{reg}} and
20189@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20190which system register to use as base register for reading the canary,
20191and from what offset from that base register. There is no default
20192register or offset as this is entirely for use within the Linux
20193kernel.
20194
d77de738 20195@opindex mtls-dialect=desc
ddf6fe37 20196@item -mtls-dialect=desc
d77de738
ML
20197Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20198of TLS variables. This is the default.
20199
d77de738 20200@opindex mtls-dialect=traditional
ddf6fe37 20201@item -mtls-dialect=traditional
d77de738
ML
20202Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20203of TLS variables.
20204
d77de738 20205@opindex mtls-size
ddf6fe37 20206@item -mtls-size=@var{size}
d77de738
ML
20207Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20208This option requires binutils 2.26 or newer.
20209
d77de738
ML
20210@opindex mfix-cortex-a53-835769
20211@opindex mno-fix-cortex-a53-835769
ddf6fe37
AA
20212@item -mfix-cortex-a53-835769
20213@itemx -mno-fix-cortex-a53-835769
d77de738
ML
20214Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20215This involves inserting a NOP instruction between memory instructions and
2021664-bit integer multiply-accumulate instructions.
20217
d77de738
ML
20218@opindex mfix-cortex-a53-843419
20219@opindex mno-fix-cortex-a53-843419
ddf6fe37
AA
20220@item -mfix-cortex-a53-843419
20221@itemx -mno-fix-cortex-a53-843419
d77de738
ML
20222Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20223This erratum workaround is made at link time and this will only pass the
20224corresponding flag to the linker.
20225
d77de738
ML
20226@opindex mlow-precision-recip-sqrt
20227@opindex mno-low-precision-recip-sqrt
ddf6fe37
AA
20228@item -mlow-precision-recip-sqrt
20229@itemx -mno-low-precision-recip-sqrt
d77de738
ML
20230Enable or disable the reciprocal square root approximation.
20231This option only has an effect if @option{-ffast-math} or
20232@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20233precision of reciprocal square root results to about 16 bits for
20234single precision and to 32 bits for double precision.
20235
d77de738
ML
20236@opindex mlow-precision-sqrt
20237@opindex mno-low-precision-sqrt
ddf6fe37
AA
20238@item -mlow-precision-sqrt
20239@itemx -mno-low-precision-sqrt
d77de738
ML
20240Enable or disable the square root approximation.
20241This option only has an effect if @option{-ffast-math} or
20242@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20243precision of square root results to about 16 bits for
20244single precision and to 32 bits for double precision.
20245If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20246
d77de738
ML
20247@opindex mlow-precision-div
20248@opindex mno-low-precision-div
ddf6fe37
AA
20249@item -mlow-precision-div
20250@itemx -mno-low-precision-div
d77de738
ML
20251Enable or disable the division approximation.
20252This option only has an effect if @option{-ffast-math} or
20253@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20254precision of division results to about 16 bits for
20255single precision and to 32 bits for double precision.
20256
20257@item -mtrack-speculation
20258@itemx -mno-track-speculation
20259Enable or disable generation of additional code to track speculative
20260execution through conditional branches. The tracking state can then
20261be used by the compiler when expanding calls to
20262@code{__builtin_speculation_safe_copy} to permit a more efficient code
20263sequence to be generated.
20264
20265@item -moutline-atomics
20266@itemx -mno-outline-atomics
20267Enable or disable calls to out-of-line helpers to implement atomic operations.
20268These helpers will, at runtime, determine if the LSE instructions from
20269ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20270instructions that are present in the base ARMv8.0 ISA.
20271
20272This option is only applicable when compiling for the base ARMv8.0
20273instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20274or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20275used directly. The same applies when using @option{-mcpu=} when the
20276selected cpu supports the @samp{lse} feature.
20277This option is on by default.
20278
d77de738 20279@opindex march
ddf6fe37 20280@item -march=@var{name}
d77de738
ML
20281Specify the name of the target architecture and, optionally, one or
20282more feature modifiers. This option has the form
20283@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20284
20285The table below summarizes the permissible values for @var{arch}
20286and the features that they enable by default:
20287
20288@multitable @columnfractions 0.20 0.20 0.60
20289@headitem @var{arch} value @tab Architecture @tab Includes by default
20290@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20291@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20292@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20293@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20294@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20295@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20296@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20297@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20298@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20299@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20300@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20301@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20302@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20303@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20304@end multitable
20305
20306The value @samp{native} is available on native AArch64 GNU/Linux and
20307causes the compiler to pick the architecture of the host system. This
20308option has no effect if the compiler is unable to recognize the
20309architecture of the host system,
20310
20311The permissible values for @var{feature} are listed in the sub-section
20312on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20313Feature Modifiers}. Where conflicting feature modifiers are
20314specified, the right-most feature is used.
20315
20316GCC uses @var{name} to determine what kind of instructions it can emit
20317when generating assembly code. If @option{-march} is specified
20318without either of @option{-mtune} or @option{-mcpu} also being
20319specified, the code is tuned to perform well across a range of target
20320processors implementing the target architecture.
20321
d77de738 20322@opindex mtune
ddf6fe37 20323@item -mtune=@var{name}
d77de738
ML
20324Specify the name of the target processor for which GCC should tune the
20325performance of the code. Permissible values for this option are:
20326@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20327@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20328@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20329@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20330@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20331@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20332@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20333@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20334@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20335@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20336@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20337@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20338@samp{octeontx2f95mm},
20339@samp{a64fx},
20340@samp{thunderx}, @samp{thunderxt88},
20341@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20342@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20343@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20344@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20345@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20346@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
e07556a8
SP
20347@samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715},
20348@samp{ampere1}, @samp{ampere1a}, and @samp{native}.
d77de738
ML
20349
20350The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20351@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20352@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20353should tune for a big.LITTLE system.
20354
20355The value @samp{neoverse-512tvb} specifies that GCC should tune
20356for Neoverse cores that (a) implement SVE and (b) have a total vector
20357bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20358tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20359instructions a cycle and that can execute an equivalent number of SVE
20360arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20361This is more general than tuning for a specific core like Neoverse V1
20362but is more specific than the default tuning described below.
20363
20364Additionally on native AArch64 GNU/Linux systems the value
20365@samp{native} tunes performance to the host system. This option has no effect
20366if the compiler is unable to recognize the processor of the host system.
20367
20368Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20369are specified, the code is tuned to perform well across a range
20370of target processors.
20371
20372This option cannot be suffixed by feature modifiers.
20373
d77de738 20374@opindex mcpu
ddf6fe37 20375@item -mcpu=@var{name}
d77de738
ML
20376Specify the name of the target processor, optionally suffixed by one
20377or more feature modifiers. This option has the form
20378@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20379the permissible values for @var{cpu} are the same as those available
20380for @option{-mtune}. The permissible values for @var{feature} are
20381documented in the sub-section on
20382@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20383Feature Modifiers}. Where conflicting feature modifiers are
20384specified, the right-most feature is used.
20385
20386GCC uses @var{name} to determine what kind of instructions it can emit when
20387generating assembly code (as if by @option{-march}) and to determine
20388the target processor for which to tune for performance (as if
20389by @option{-mtune}). Where this option is used in conjunction
20390with @option{-march} or @option{-mtune}, those options take precedence
20391over the appropriate part of this option.
20392
20393@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20394to a specific core, but instead refers to all Neoverse cores that
20395(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20396a cycle. Unless overridden by @option{-march},
20397@option{-mcpu=neoverse-512tvb} generates code that can run on a
20398Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20399these properties. Unless overridden by @option{-mtune},
20400@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20401@option{-mtune=neoverse-512tvb}.
20402
d77de738 20403@opindex moverride
ddf6fe37 20404@item -moverride=@var{string}
d77de738
ML
20405Override tuning decisions made by the back-end in response to a
20406@option{-mtune=} switch. The syntax, semantics, and accepted values
20407for @var{string} in this option are not guaranteed to be consistent
20408across releases.
20409
20410This option is only intended to be useful when developing GCC.
20411
d77de738 20412@opindex mverbose-cost-dump
ddf6fe37 20413@item -mverbose-cost-dump
d77de738
ML
20414Enable verbose cost model dumping in the debug dump files. This option is
20415provided for use in debugging the compiler.
20416
d77de738
ML
20417@opindex mpc-relative-literal-loads
20418@opindex mno-pc-relative-literal-loads
ddf6fe37
AA
20419@item -mpc-relative-literal-loads
20420@itemx -mno-pc-relative-literal-loads
d77de738
ML
20421Enable or disable PC-relative literal loads. With this option literal pools are
20422accessed using a single instruction and emitted after each function. This
20423limits the maximum size of functions to 1MB. This is enabled by default for
20424@option{-mcmodel=tiny}.
20425
d77de738 20426@opindex msign-return-address
ddf6fe37 20427@item -msign-return-address=@var{scope}
d77de738
ML
20428Select the function scope on which return address signing will be applied.
20429Permissible values are @samp{none}, which disables return address signing,
20430@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20431functions, and @samp{all}, which enables pointer signing for all functions. The
20432default value is @samp{none}. This option has been deprecated by
20433-mbranch-protection.
20434
d77de738 20435@opindex mbranch-protection
ddf6fe37 20436@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
d77de738
ML
20437Select the branch protection features to use.
20438@samp{none} is the default and turns off all types of branch protection.
20439@samp{standard} turns on all types of branch protection features. If a feature
20440has additional tuning options, then @samp{standard} sets it to its standard
20441level.
20442@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20443level: signing functions that save the return address to memory (non-leaf
20444functions will practically always do this) using the a-key. The optional
20445argument @samp{leaf} can be used to extend the signing to include leaf
20446functions. The optional argument @samp{b-key} can be used to sign the functions
20447with the B-key instead of the A-key.
20448@samp{bti} turns on branch target identification mechanism.
20449
d77de738 20450@opindex mharden-sls
ddf6fe37 20451@item -mharden-sls=@var{opts}
d77de738
ML
20452Enable compiler hardening against straight line speculation (SLS).
20453@var{opts} is a comma-separated list of the following options:
20454@table @samp
20455@item retbr
20456@item blr
20457@end table
20458In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20459@samp{-mharden-sls=none} disables all SLS hardening.
20460
d77de738 20461@opindex msve-vector-bits
ddf6fe37 20462@item -msve-vector-bits=@var{bits}
d77de738
ML
20463Specify the number of bits in an SVE vector register. This option only has
20464an effect when SVE is enabled.
20465
20466GCC supports two forms of SVE code generation: ``vector-length
20467agnostic'' output that works with any size of vector register and
20468``vector-length specific'' output that allows GCC to make assumptions
20469about the vector length when it is useful for optimization reasons.
20470The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20471@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20472Specifying @samp{scalable} selects vector-length agnostic
20473output. At present @samp{-msve-vector-bits=128} also generates vector-length
20474agnostic output for big-endian targets. All other values generate
20475vector-length specific code. The behavior of these values may change
20476in future releases and no value except @samp{scalable} should be
20477relied on for producing code that is portable across different
20478hardware SVE vector lengths.
20479
20480The default is @samp{-msve-vector-bits=scalable}, which produces
20481vector-length agnostic code.
20482@end table
20483
20484@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20485@anchor{aarch64-feature-modifiers}
20486@cindex @option{-march} feature modifiers
20487@cindex @option{-mcpu} feature modifiers
20488Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20489the following and their inverses @option{no@var{feature}}:
20490
20491@table @samp
20492@item crc
20493Enable CRC extension. This is on by default for
20494@option{-march=armv8.1-a}.
20495@item crypto
20496Enable Crypto extension. This also enables Advanced SIMD and floating-point
20497instructions.
20498@item fp
20499Enable floating-point instructions. This is on by default for all possible
20500values for options @option{-march} and @option{-mcpu}.
20501@item simd
20502Enable Advanced SIMD instructions. This also enables floating-point
20503instructions. This is on by default for all possible values for options
20504@option{-march} and @option{-mcpu}.
20505@item sve
20506Enable Scalable Vector Extension instructions. This also enables Advanced
20507SIMD and floating-point instructions.
20508@item lse
20509Enable Large System Extension instructions. This is on by default for
20510@option{-march=armv8.1-a}.
20511@item rdma
20512Enable Round Double Multiply Accumulate instructions. This is on by default
20513for @option{-march=armv8.1-a}.
20514@item fp16
20515Enable FP16 extension. This also enables floating-point instructions.
20516@item fp16fml
20517Enable FP16 fmla extension. This also enables FP16 extensions and
20518floating-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.
20519
20520@item rcpc
0431e8ae
AV
20521Enable the RCpc extension. This enables the use of the LDAPR instructions for
20522load-acquire atomic semantics, and passes it on to the assembler, enabling
20523inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20524@item dotprod
20525Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20526@item aes
20527Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20528SIMD instructions.
20529@item sha2
20530Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20531@item sha3
20532Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20533instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20534@item sm4
20535Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20536Use of this option with architectures prior to Armv8.2-A is not supported.
20537@item profile
20538Enable the Statistical Profiling extension. This option is only to enable the
20539extension at the assembler level and does not affect code generation.
20540@item rng
20541Enable the Armv8.5-a Random Number instructions. This option is only to
20542enable the extension at the assembler level and does not affect code
20543generation.
20544@item memtag
20545Enable the Armv8.5-a Memory Tagging Extensions.
20546Use of this option with architectures prior to Armv8.5-A is not supported.
20547@item sb
20548Enable the Armv8-a Speculation Barrier instruction. This option is only to
20549enable the extension at the assembler level and does not affect code
20550generation. This option is enabled by default for @option{-march=armv8.5-a}.
20551@item ssbs
20552Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20553is only to enable the extension at the assembler level and does not affect code
20554generation. This option is enabled by default for @option{-march=armv8.5-a}.
20555@item predres
20556Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20557This option is only to enable the extension at the assembler level and does
20558not affect code generation. This option is enabled by default for
20559@option{-march=armv8.5-a}.
20560@item sve2
20561Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20562instructions.
20563@item sve2-bitperm
20564Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20565@item sve2-sm4
20566Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20567@item sve2-aes
20568Enable SVE2 aes instructions. This also enables SVE2 instructions.
20569@item sve2-sha3
20570Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20571@item tme
20572Enable the Transactional Memory Extension.
20573@item i8mm
20574Enable 8-bit Integer Matrix Multiply instructions. This also enables
20575Advanced SIMD and floating-point instructions. This option is enabled by
20576default for @option{-march=armv8.6-a}. Use of this option with architectures
20577prior to Armv8.2-A is not supported.
20578@item f32mm
20579Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20580SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20581not supported.
20582@item f64mm
20583Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20584SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20585not supported.
20586@item bf16
20587Enable brain half-precision floating-point instructions. This also enables
20588Advanced SIMD and floating-point instructions. This option is enabled by
20589default for @option{-march=armv8.6-a}. Use of this option with architectures
20590prior to Armv8.2-A is not supported.
20591@item ls64
20592Enable the 64-byte atomic load and store instructions for accelerators.
20593This option is enabled by default for @option{-march=armv8.7-a}.
20594@item mops
20595Enable the instructions to accelerate memory operations like @code{memcpy},
20596@code{memmove}, @code{memset}. This option is enabled by default for
20597@option{-march=armv8.8-a}
20598@item flagm
20599Enable the Flag Manipulation instructions Extension.
20600@item pauth
20601Enable the Pointer Authentication Extension.
d758d190
KT
20602@item cssc
20603Enable the Common Short Sequence Compression instructions.
d77de738
ML
20604
20605@end table
20606
20607Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20608which implies @option{fp}.
20609Conversely, @option{nofp} implies @option{nosimd}, which implies
20610@option{nocrypto}, @option{noaes} and @option{nosha2}.
20611
20612@node Adapteva Epiphany Options
20613@subsection Adapteva Epiphany Options
20614
20615These @samp{-m} options are defined for Adapteva Epiphany:
20616
20617@table @gcctabopt
d77de738 20618@opindex mhalf-reg-file
ddf6fe37 20619@item -mhalf-reg-file
d77de738
ML
20620Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20621That allows code to run on hardware variants that lack these registers.
20622
d77de738 20623@opindex mprefer-short-insn-regs
ddf6fe37 20624@item -mprefer-short-insn-regs
d77de738
ML
20625Preferentially allocate registers that allow short instruction generation.
20626This can result in increased instruction count, so this may either reduce or
20627increase overall code size.
20628
d77de738 20629@opindex mbranch-cost
ddf6fe37 20630@item -mbranch-cost=@var{num}
d77de738
ML
20631Set the cost of branches to roughly @var{num} ``simple'' instructions.
20632This cost is only a heuristic and is not guaranteed to produce
20633consistent results across releases.
20634
d77de738 20635@opindex mcmove
ddf6fe37 20636@item -mcmove
d77de738
ML
20637Enable the generation of conditional moves.
20638
d77de738 20639@opindex mnops
ddf6fe37 20640@item -mnops=@var{num}
d77de738
ML
20641Emit @var{num} NOPs before every other generated instruction.
20642
d77de738
ML
20643@opindex mno-soft-cmpsf
20644@opindex msoft-cmpsf
ddf6fe37 20645@item -mno-soft-cmpsf
d77de738
ML
20646For single-precision floating-point comparisons, emit an @code{fsub} instruction
20647and test the flags. This is faster than a software comparison, but can
20648get incorrect results in the presence of NaNs, or when two different small
20649numbers are compared such that their difference is calculated as zero.
20650The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20651software comparisons.
20652
d77de738 20653@opindex mstack-offset
ddf6fe37 20654@item -mstack-offset=@var{num}
d77de738
ML
20655Set the offset between the top of the stack and the stack pointer.
20656E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20657can be used by leaf functions without stack allocation.
20658Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20659Note also that this option changes the ABI; compiling a program with a
20660different stack offset than the libraries have been compiled with
20661generally does not work.
20662This option can be useful if you want to evaluate if a different stack
20663offset would give you better code, but to actually use a different stack
20664offset to build working programs, it is recommended to configure the
20665toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20666
d77de738
ML
20667@opindex mno-round-nearest
20668@opindex mround-nearest
ddf6fe37 20669@item -mno-round-nearest
d77de738
ML
20670Make the scheduler assume that the rounding mode has been set to
20671truncating. The default is @option{-mround-nearest}.
20672
d77de738 20673@opindex mlong-calls
ddf6fe37 20674@item -mlong-calls
d77de738
ML
20675If not otherwise specified by an attribute, assume all calls might be beyond
20676the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20677function address into a register before performing a (otherwise direct) call.
20678This is the default.
20679
d77de738 20680@opindex short-calls
ddf6fe37 20681@item -mshort-calls
d77de738
ML
20682If not otherwise specified by an attribute, assume all direct calls are
20683in the range of the @code{b} / @code{bl} instructions, so use these instructions
20684for direct calls. The default is @option{-mlong-calls}.
20685
d77de738 20686@opindex msmall16
ddf6fe37 20687@item -msmall16
d77de738
ML
20688Assume addresses can be loaded as 16-bit unsigned values. This does not
20689apply to function addresses for which @option{-mlong-calls} semantics
20690are in effect.
20691
d77de738 20692@opindex mfp-mode
ddf6fe37 20693@item -mfp-mode=@var{mode}
d77de738
ML
20694Set the prevailing mode of the floating-point unit.
20695This determines the floating-point mode that is provided and expected
20696at function call and return time. Making this mode match the mode you
20697predominantly need at function start can make your programs smaller and
20698faster by avoiding unnecessary mode switches.
20699
20700@var{mode} can be set to one the following values:
20701
20702@table @samp
20703@item caller
20704Any mode at function entry is valid, and retained or restored when
20705the function returns, and when it calls other functions.
20706This mode is useful for compiling libraries or other compilation units
20707you might want to incorporate into different programs with different
20708prevailing FPU modes, and the convenience of being able to use a single
20709object file outweighs the size and speed overhead for any extra
20710mode switching that might be needed, compared with what would be needed
20711with a more specific choice of prevailing FPU mode.
20712
20713@item truncate
20714This is the mode used for floating-point calculations with
20715truncating (i.e.@: round towards zero) rounding mode. That includes
20716conversion from floating point to integer.
20717
20718@item round-nearest
20719This is the mode used for floating-point calculations with
20720round-to-nearest-or-even rounding mode.
20721
20722@item int
20723This is the mode used to perform integer calculations in the FPU, e.g.@:
20724integer multiply, or integer multiply-and-accumulate.
20725@end table
20726
20727The default is @option{-mfp-mode=caller}
20728
d77de738
ML
20729@opindex mno-split-lohi
20730@opindex msplit-lohi
20731@opindex mno-postinc
20732@opindex mpostinc
20733@opindex mno-postmodify
20734@opindex mpostmodify
ddf6fe37
AA
20735@item -mno-split-lohi
20736@itemx -mno-postinc
20737@itemx -mno-postmodify
d77de738
ML
20738Code generation tweaks that disable, respectively, splitting of 32-bit
20739loads, generation of post-increment addresses, and generation of
20740post-modify addresses. The defaults are @option{msplit-lohi},
20741@option{-mpost-inc}, and @option{-mpost-modify}.
20742
d77de738
ML
20743@opindex mno-vect-double
20744@opindex mvect-double
ddf6fe37 20745@item -mnovect-double
d77de738
ML
20746Change the preferred SIMD mode to SImode. The default is
20747@option{-mvect-double}, which uses DImode as preferred SIMD mode.
20748
d77de738 20749@opindex max-vect-align
ddf6fe37 20750@item -max-vect-align=@var{num}
d77de738
ML
20751The maximum alignment for SIMD vector mode types.
20752@var{num} may be 4 or 8. The default is 8.
20753Note that this is an ABI change, even though many library function
20754interfaces are unaffected if they don't use SIMD vector modes
20755in places that affect size and/or alignment of relevant types.
20756
d77de738 20757@opindex msplit-vecmove-early
ddf6fe37 20758@item -msplit-vecmove-early
d77de738
ML
20759Split vector moves into single word moves before reload. In theory this
20760can give better register allocation, but so far the reverse seems to be
20761generally the case.
20762
d77de738 20763@opindex m1reg-
ddf6fe37 20764@item -m1reg-@var{reg}
d77de738
ML
20765Specify a register to hold the constant @minus{}1, which makes loading small negative
20766constants and certain bitmasks faster.
20767Allowable values for @var{reg} are @samp{r43} and @samp{r63},
20768which specify use of that register as a fixed register,
20769and @samp{none}, which means that no register is used for this
20770purpose. The default is @option{-m1reg-none}.
20771
20772@end table
20773
20774@node AMD GCN Options
20775@subsection AMD GCN Options
20776@cindex AMD GCN Options
20777
20778These options are defined specifically for the AMD GCN port.
20779
20780@table @gcctabopt
20781
d77de738 20782@opindex march
d77de738 20783@opindex mtune
ddf6fe37
AA
20784@item -march=@var{gpu}
20785@itemx -mtune=@var{gpu}
d77de738
ML
20786Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
20787are
20788
20789@table @samp
20790@item fiji
20791Compile for GCN3 Fiji devices (gfx803).
20792
20793@item gfx900
20794Compile for GCN5 Vega 10 devices (gfx900).
20795
20796@item gfx906
20797Compile for GCN5 Vega 20 devices (gfx906).
20798
20799@item gfx908
20800Compile for CDNA1 Instinct MI100 series devices (gfx908).
20801
20802@item gfx90a
20803Compile for CDNA2 Instinct MI200 series devices (gfx90a).
20804
20805@end table
20806
ddf6fe37 20807@opindex msram-ecc
d77de738
ML
20808@item -msram-ecc=on
20809@itemx -msram-ecc=off
20810@itemx -msram-ecc=any
d77de738
ML
20811Compile binaries suitable for devices with the SRAM-ECC feature enabled,
20812disabled, or either mode. This feature can be enabled per-process on some
20813devices. The compiled code must match the device mode. The default is
20814@samp{any}, for devices that support it.
20815
d77de738 20816@opindex mstack-size
ddf6fe37 20817@item -mstack-size=@var{bytes}
d77de738
ML
20818Specify how many @var{bytes} of stack space will be requested for each GPU
20819thread (wave-front). Beware that there may be many threads and limited memory
20820available. The size of the stack allocation may also have an impact on
20821run-time performance. The default is 32KB when using OpenACC or OpenMP, and
208221MB otherwise.
20823
d77de738 20824@opindex mxnack
366e3d30
TB
20825@item -mxnack=on
20826@itemx -mxnack=off
20827@itemx -mxnack=any
20828Compile binaries suitable for devices with the XNACK feature enabled, disabled,
20829or either mode. Some devices always require XNACK and some allow the user to
20830configure XNACK. The compiled code must match the device mode.
20831@c The default is @samp{-mxnack=any}.
20832At present this option is a placeholder for support that is not yet implemented.
d77de738
ML
20833
20834@end table
20835
20836@node ARC Options
20837@subsection ARC Options
20838@cindex ARC options
20839
20840The following options control the architecture variant for which code
20841is being compiled:
20842
20843@c architecture variants
20844@table @gcctabopt
20845
d77de738 20846@opindex mbarrel-shifter
ddf6fe37 20847@item -mbarrel-shifter
d77de738
ML
20848Generate instructions supported by barrel shifter. This is the default
20849unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
20850
d77de738 20851@opindex mjli-always
ddf6fe37 20852@item -mjli-always
d77de738
ML
20853Force to call a function using jli_s instruction. This option is
20854valid only for ARCv2 architecture.
20855
d77de738 20856@opindex mcpu
ddf6fe37 20857@item -mcpu=@var{cpu}
d77de738
ML
20858Set architecture type, register usage, and instruction scheduling
20859parameters for @var{cpu}. There are also shortcut alias options
20860available for backward compatibility and convenience. Supported
20861values for @var{cpu} are
20862
20863@table @samp
20864@opindex mA6
20865@opindex mARC600
20866@item arc600
20867Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
20868
d77de738 20869@opindex mARC601
ddf6fe37 20870@item arc601
d77de738
ML
20871Compile for ARC601. Alias: @option{-mARC601}.
20872
d77de738
ML
20873@opindex mA7
20874@opindex mARC700
ddf6fe37 20875@item arc700
d77de738
ML
20876Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
20877This is the default when configured with @option{--with-cpu=arc700}@.
20878
20879@item arcem
20880Compile for ARC EM.
20881
20882@item archs
20883Compile for ARC HS.
20884
20885@item em
20886Compile for ARC EM CPU with no hardware extensions.
20887
20888@item em4
20889Compile for ARC EM4 CPU.
20890
20891@item em4_dmips
20892Compile for ARC EM4 DMIPS CPU.
20893
20894@item em4_fpus
20895Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
20896extension.
20897
20898@item em4_fpuda
20899Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
20900double assist instructions.
20901
20902@item hs
20903Compile for ARC HS CPU with no hardware extensions except the atomic
20904instructions.
20905
20906@item hs34
20907Compile for ARC HS34 CPU.
20908
20909@item hs38
20910Compile for ARC HS38 CPU.
20911
20912@item hs38_linux
20913Compile for ARC HS38 CPU with all hardware extensions on.
20914
20915@item hs4x
20916Compile for ARC HS4x CPU.
20917
20918@item hs4xd
20919Compile for ARC HS4xD CPU.
20920
20921@item hs4x_rel31
20922Compile for ARC HS4x CPU release 3.10a.
20923
20924@item arc600_norm
20925Compile for ARC 600 CPU with @code{norm} instructions enabled.
20926
20927@item arc600_mul32x16
20928Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
20929instructions enabled.
20930
20931@item arc600_mul64
20932Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
20933instructions enabled.
20934
20935@item arc601_norm
20936Compile for ARC 601 CPU with @code{norm} instructions enabled.
20937
20938@item arc601_mul32x16
20939Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
20940instructions enabled.
20941
20942@item arc601_mul64
20943Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
20944instructions enabled.
20945
20946@item nps400
20947Compile for ARC 700 on NPS400 chip.
20948
20949@item em_mini
20950Compile for ARC EM minimalist configuration featuring reduced register
20951set.
20952
20953@end table
20954
d77de738 20955@opindex mdpfp
d77de738 20956@opindex mdpfp-compact
ddf6fe37
AA
20957@item -mdpfp
20958@itemx -mdpfp-compact
d77de738
ML
20959Generate double-precision FPX instructions, tuned for the compact
20960implementation.
20961
d77de738 20962@opindex mdpfp-fast
ddf6fe37 20963@item -mdpfp-fast
d77de738
ML
20964Generate double-precision FPX instructions, tuned for the fast
20965implementation.
20966
d77de738 20967@opindex mno-dpfp-lrsr
ddf6fe37 20968@item -mno-dpfp-lrsr
d77de738
ML
20969Disable @code{lr} and @code{sr} instructions from using FPX extension
20970aux registers.
20971
d77de738 20972@opindex mea
ddf6fe37 20973@item -mea
d77de738
ML
20974Generate extended arithmetic instructions. Currently only
20975@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
20976supported. Only valid for @option{-mcpu=ARC700}.
20977
d77de738
ML
20978@opindex mno-mpy
20979@opindex mmpy
ddf6fe37 20980@item -mno-mpy
d77de738
ML
20981Do not generate @code{mpy}-family instructions for ARC700. This option is
20982deprecated.
20983
d77de738 20984@opindex mmul32x16
ddf6fe37 20985@item -mmul32x16
d77de738
ML
20986Generate 32x16-bit multiply and multiply-accumulate instructions.
20987
d77de738 20988@opindex mmul64
ddf6fe37 20989@item -mmul64
d77de738
ML
20990Generate @code{mul64} and @code{mulu64} instructions.
20991Only valid for @option{-mcpu=ARC600}.
20992
d77de738 20993@opindex mnorm
ddf6fe37 20994@item -mnorm
d77de738
ML
20995Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
20996is in effect.
20997
d77de738 20998@opindex mspfp
d77de738 20999@opindex mspfp-compact
ddf6fe37
AA
21000@item -mspfp
21001@itemx -mspfp-compact
d77de738
ML
21002Generate single-precision FPX instructions, tuned for the compact
21003implementation.
21004
d77de738 21005@opindex mspfp-fast
ddf6fe37 21006@item -mspfp-fast
d77de738
ML
21007Generate single-precision FPX instructions, tuned for the fast
21008implementation.
21009
d77de738 21010@opindex msimd
ddf6fe37 21011@item -msimd
d77de738
ML
21012Enable generation of ARC SIMD instructions via target-specific
21013builtins. Only valid for @option{-mcpu=ARC700}.
21014
d77de738 21015@opindex msoft-float
ddf6fe37 21016@item -msoft-float
d77de738
ML
21017This option ignored; it is provided for compatibility purposes only.
21018Software floating-point code is emitted by default, and this default
21019can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
21020@option{-mspfp-fast} for single precision, and @option{-mdpfp},
21021@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
21022
d77de738 21023@opindex mswap
ddf6fe37 21024@item -mswap
d77de738
ML
21025Generate @code{swap} instructions.
21026
d77de738 21027@opindex matomic
ddf6fe37 21028@item -matomic
d77de738
ML
21029This enables use of the locked load/store conditional extension to implement
21030atomic memory built-in functions. Not available for ARC 6xx or ARC
21031EM cores.
21032
d77de738 21033@opindex mdiv-rem
ddf6fe37 21034@item -mdiv-rem
d77de738
ML
21035Enable @code{div} and @code{rem} instructions for ARCv2 cores.
21036
d77de738 21037@opindex mcode-density
ddf6fe37 21038@item -mcode-density
d77de738
ML
21039Enable code density instructions for ARC EM.
21040This option is on by default for ARC HS.
21041
d77de738 21042@opindex mll64
ddf6fe37 21043@item -mll64
d77de738
ML
21044Enable double load/store operations for ARC HS cores.
21045
d77de738 21046@opindex mtp-regno
ddf6fe37 21047@item -mtp-regno=@var{regno}
d77de738
ML
21048Specify thread pointer register number.
21049
d77de738 21050@opindex mmpy-option
ddf6fe37 21051@item -mmpy-option=@var{multo}
d77de738
ML
21052Compile ARCv2 code with a multiplier design option. You can specify
21053the option using either a string or numeric value for @var{multo}.
21054@samp{wlh1} is the default value. The recognized values are:
21055
21056@table @samp
21057@item 0
21058@itemx none
21059No multiplier available.
21060
21061@item 1
21062@itemx w
2106316x16 multiplier, fully pipelined.
21064The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
21065
21066@item 2
21067@itemx wlh1
2106832x32 multiplier, fully
21069pipelined (1 stage). The following instructions are additionally
21070enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21071
21072@item 3
21073@itemx wlh2
2107432x32 multiplier, fully pipelined
21075(2 stages). The following instructions are additionally enabled: @code{mpy},
21076@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21077
21078@item 4
21079@itemx wlh3
21080Two 16x16 multipliers, blocking,
21081sequential. The following instructions are additionally enabled: @code{mpy},
21082@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21083
21084@item 5
21085@itemx wlh4
21086One 16x16 multiplier, blocking,
21087sequential. The following instructions are additionally enabled: @code{mpy},
21088@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21089
21090@item 6
21091@itemx wlh5
21092One 32x4 multiplier, blocking,
21093sequential. The following instructions are additionally enabled: @code{mpy},
21094@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21095
21096@item 7
21097@itemx plus_dmpy
21098ARC HS SIMD support.
21099
21100@item 8
21101@itemx plus_macd
21102ARC HS SIMD support.
21103
21104@item 9
21105@itemx plus_qmacw
21106ARC HS SIMD support.
21107
21108@end table
21109
21110This option is only available for ARCv2 cores@.
21111
d77de738 21112@opindex mfpu
ddf6fe37 21113@item -mfpu=@var{fpu}
d77de738
ML
21114Enables support for specific floating-point hardware extensions for ARCv2
21115cores. Supported values for @var{fpu} are:
21116
21117@table @samp
21118
21119@item fpus
21120Enables support for single-precision floating-point hardware
21121extensions@.
21122
21123@item fpud
21124Enables support for double-precision floating-point hardware
21125extensions. The single-precision floating-point extension is also
21126enabled. Not available for ARC EM@.
21127
21128@item fpuda
21129Enables support for double-precision floating-point hardware
21130extensions using double-precision assist instructions. The single-precision
21131floating-point extension is also enabled. This option is
21132only available for ARC EM@.
21133
21134@item fpuda_div
21135Enables support for double-precision floating-point hardware
21136extensions using double-precision assist instructions.
21137The single-precision floating-point, square-root, and divide
21138extensions are also enabled. This option is
21139only available for ARC EM@.
21140
21141@item fpuda_fma
21142Enables support for double-precision floating-point hardware
21143extensions using double-precision assist instructions.
21144The single-precision floating-point and fused multiply and add
21145hardware extensions are also enabled. This option is
21146only available for ARC EM@.
21147
21148@item fpuda_all
21149Enables support for double-precision floating-point hardware
21150extensions using double-precision assist instructions.
21151All single-precision floating-point hardware extensions are also
21152enabled. This option is only available for ARC EM@.
21153
21154@item fpus_div
21155Enables support for single-precision floating-point, square-root and divide
21156hardware extensions@.
21157
21158@item fpud_div
21159Enables support for double-precision floating-point, square-root and divide
21160hardware extensions. This option
21161includes option @samp{fpus_div}. Not available for ARC EM@.
21162
21163@item fpus_fma
21164Enables support for single-precision floating-point and
21165fused multiply and add hardware extensions@.
21166
21167@item fpud_fma
21168Enables support for double-precision floating-point and
21169fused multiply and add hardware extensions. This option
21170includes option @samp{fpus_fma}. Not available for ARC EM@.
21171
21172@item fpus_all
21173Enables support for all single-precision floating-point hardware
21174extensions@.
21175
21176@item fpud_all
21177Enables support for all single- and double-precision floating-point
21178hardware extensions. Not available for ARC EM@.
21179
21180@end table
21181
d77de738 21182@opindex mirq-ctrl-saved
ddf6fe37 21183@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
d77de738
ML
21184Specifies general-purposes registers that the processor automatically
21185saves/restores on interrupt entry and exit. @var{register-range} is
21186specified as two registers separated by a dash. The register range
21187always starts with @code{r0}, the upper limit is @code{fp} register.
21188@var{blink} and @var{lp_count} are optional. This option is only
21189valid for ARC EM and ARC HS cores.
21190
d77de738 21191@opindex mrgf-banked-regs
ddf6fe37 21192@item -mrgf-banked-regs=@var{number}
d77de738
ML
21193Specifies the number of registers replicated in second register bank
21194on entry to fast interrupt. Fast interrupts are interrupts with the
21195highest priority level P0. These interrupts save only PC and STATUS32
21196registers to avoid memory transactions during interrupt entry and exit
21197sequences. Use this option when you are using fast interrupts in an
21198ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21199
d77de738 21200@opindex mlpc-width
ddf6fe37 21201@item -mlpc-width=@var{width}
d77de738
ML
21202Specify the width of the @code{lp_count} register. Valid values for
21203@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21204fixed to 32 bits. If the width is less than 32, the compiler does not
21205attempt to transform loops in your program to use the zero-delay loop
21206mechanism unless it is known that the @code{lp_count} register can
21207hold the required loop-counter value. Depending on the width
21208specified, the compiler and run-time library might continue to use the
21209loop mechanism for various needs. This option defines macro
21210@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21211
d77de738 21212@opindex mrf16
ddf6fe37 21213@item -mrf16
d77de738
ML
21214This option instructs the compiler to generate code for a 16-entry
21215register file. This option defines the @code{__ARC_RF16__}
21216preprocessor macro.
21217
d77de738 21218@opindex mbranch-index
ddf6fe37 21219@item -mbranch-index
d77de738
ML
21220Enable use of @code{bi} or @code{bih} instructions to implement jump
21221tables.
21222
21223@end table
21224
21225The following options are passed through to the assembler, and also
21226define preprocessor macro symbols.
21227
21228@c Flags used by the assembler, but for which we define preprocessor
21229@c macro symbols as well.
21230@table @gcctabopt
d77de738 21231@opindex mdsp-packa
ddf6fe37 21232@item -mdsp-packa
d77de738
ML
21233Passed down to the assembler to enable the DSP Pack A extensions.
21234Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21235deprecated.
21236
d77de738 21237@opindex mdvbf
ddf6fe37 21238@item -mdvbf
d77de738
ML
21239Passed down to the assembler to enable the dual Viterbi butterfly
21240extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21241option is deprecated.
21242
21243@c ARC700 4.10 extension instruction
d77de738 21244@opindex mlock
ddf6fe37 21245@item -mlock
d77de738
ML
21246Passed down to the assembler to enable the locked load/store
21247conditional extension. Also sets the preprocessor symbol
21248@code{__Xlock}.
21249
d77de738 21250@opindex mmac-d16
ddf6fe37 21251@item -mmac-d16
d77de738
ML
21252Passed down to the assembler. Also sets the preprocessor symbol
21253@code{__Xxmac_d16}. This option is deprecated.
21254
d77de738 21255@opindex mmac-24
ddf6fe37 21256@item -mmac-24
d77de738
ML
21257Passed down to the assembler. Also sets the preprocessor symbol
21258@code{__Xxmac_24}. This option is deprecated.
21259
21260@c ARC700 4.10 extension instruction
d77de738 21261@opindex mrtsc
ddf6fe37 21262@item -mrtsc
d77de738
ML
21263Passed down to the assembler to enable the 64-bit time-stamp counter
21264extension instruction. Also sets the preprocessor symbol
21265@code{__Xrtsc}. This option is deprecated.
21266
21267@c ARC700 4.10 extension instruction
d77de738 21268@opindex mswape
ddf6fe37 21269@item -mswape
d77de738
ML
21270Passed down to the assembler to enable the swap byte ordering
21271extension instruction. Also sets the preprocessor symbol
21272@code{__Xswape}.
21273
d77de738 21274@opindex mtelephony
ddf6fe37 21275@item -mtelephony
d77de738
ML
21276Passed down to the assembler to enable dual- and single-operand
21277instructions for telephony. Also sets the preprocessor symbol
21278@code{__Xtelephony}. This option is deprecated.
21279
d77de738 21280@opindex mxy
ddf6fe37 21281@item -mxy
d77de738
ML
21282Passed down to the assembler to enable the XY memory extension. Also
21283sets the preprocessor symbol @code{__Xxy}.
21284
21285@end table
21286
21287The following options control how the assembly code is annotated:
21288
21289@c Assembly annotation options
21290@table @gcctabopt
d77de738 21291@opindex misize
ddf6fe37 21292@item -misize
d77de738
ML
21293Annotate assembler instructions with estimated addresses.
21294
d77de738 21295@opindex mannotate-align
ddf6fe37 21296@item -mannotate-align
d77de738
ML
21297Explain what alignment considerations lead to the decision to make an
21298instruction short or long.
21299
21300@end table
21301
21302The following options are passed through to the linker:
21303
21304@c options passed through to the linker
21305@table @gcctabopt
d77de738 21306@opindex marclinux
ddf6fe37 21307@item -marclinux
d77de738
ML
21308Passed through to the linker, to specify use of the @code{arclinux} emulation.
21309This option is enabled by default in tool chains built for
21310@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21311when profiling is not requested.
21312
d77de738 21313@opindex marclinux_prof
ddf6fe37 21314@item -marclinux_prof
d77de738
ML
21315Passed through to the linker, to specify use of the
21316@code{arclinux_prof} emulation. This option is enabled by default in
21317tool chains built for @w{@code{arc-linux-uclibc}} and
21318@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21319
21320@end table
21321
21322The following options control the semantics of generated code:
21323
21324@c semantically relevant code generation options
21325@table @gcctabopt
d77de738 21326@opindex mlong-calls
ddf6fe37 21327@item -mlong-calls
d77de738
ML
21328Generate calls as register indirect calls, thus providing access
21329to the full 32-bit address range.
21330
d77de738 21331@opindex mmedium-calls
ddf6fe37 21332@item -mmedium-calls
d77de738
ML
21333Don't use less than 25-bit addressing range for calls, which is the
21334offset available for an unconditional branch-and-link
21335instruction. Conditional execution of function calls is suppressed, to
21336allow use of the 25-bit range, rather than the 21-bit range with
21337conditional branch-and-link. This is the default for tool chains built
21338for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21339
d77de738 21340@opindex G
ddf6fe37 21341@item -G @var{num}
d77de738
ML
21342Put definitions of externally-visible data in a small data section if
21343that data is no bigger than @var{num} bytes. The default value of
21344@var{num} is 4 for any ARC configuration, or 8 when we have double
21345load/store operations.
21346
d77de738
ML
21347@opindex mno-sdata
21348@opindex msdata
ddf6fe37 21349@item -mno-sdata
d77de738
ML
21350Do not generate sdata references. This is the default for tool chains
21351built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21352targets.
21353
d77de738 21354@opindex mvolatile-cache
ddf6fe37 21355@item -mvolatile-cache
d77de738
ML
21356Use ordinarily cached memory accesses for volatile references. This is the
21357default.
21358
d77de738
ML
21359@opindex mno-volatile-cache
21360@opindex mvolatile-cache
ddf6fe37 21361@item -mno-volatile-cache
d77de738
ML
21362Enable cache bypass for volatile references.
21363
21364@end table
21365
21366The following options fine tune code generation:
21367@c code generation tuning options
21368@table @gcctabopt
d77de738 21369@opindex malign-call
ddf6fe37 21370@item -malign-call
d77de738
ML
21371Does nothing. Preserved for backward compatibility.
21372
d77de738 21373@opindex mauto-modify-reg
ddf6fe37 21374@item -mauto-modify-reg
d77de738
ML
21375Enable the use of pre/post modify with register displacement.
21376
d77de738 21377@opindex mbbit-peephole
ddf6fe37 21378@item -mbbit-peephole
d77de738
ML
21379Enable bbit peephole2.
21380
d77de738 21381@opindex mno-brcc
ddf6fe37 21382@item -mno-brcc
d77de738
ML
21383This option disables a target-specific pass in @file{arc_reorg} to
21384generate compare-and-branch (@code{br@var{cc}}) instructions.
21385It has no effect on
21386generation of these instructions driven by the combiner pass.
21387
d77de738 21388@opindex mcase-vector-pcrel
ddf6fe37 21389@item -mcase-vector-pcrel
d77de738
ML
21390Use PC-relative switch case tables to enable case table shortening.
21391This is the default for @option{-Os}.
21392
d77de738 21393@opindex mcompact-casesi
ddf6fe37 21394@item -mcompact-casesi
d77de738
ML
21395Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21396and only available for ARCv1 cores. This option is deprecated.
21397
d77de738 21398@opindex mno-cond-exec
ddf6fe37 21399@item -mno-cond-exec
d77de738
ML
21400Disable the ARCompact-specific pass to generate conditional
21401execution instructions.
21402
21403Due to delay slot scheduling and interactions between operand numbers,
21404literal sizes, instruction lengths, and the support for conditional execution,
21405the target-independent pass to generate conditional execution is often lacking,
21406so the ARC port has kept a special pass around that tries to find more
21407conditional execution generation opportunities after register allocation,
21408branch shortening, and delay slot scheduling have been done. This pass
21409generally, but not always, improves performance and code size, at the cost of
21410extra compilation time, which is why there is an option to switch it off.
21411If you have a problem with call instructions exceeding their allowable
21412offset range because they are conditionalized, you should consider using
21413@option{-mmedium-calls} instead.
21414
d77de738 21415@opindex mearly-cbranchsi
ddf6fe37 21416@item -mearly-cbranchsi
d77de738
ML
21417Enable pre-reload use of the @code{cbranchsi} pattern.
21418
d77de738 21419@opindex mexpand-adddi
ddf6fe37 21420@item -mexpand-adddi
d77de738
ML
21421Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21422@code{add.f}, @code{adc} etc. This option is deprecated.
21423
d77de738 21424@opindex mindexed-loads
ddf6fe37 21425@item -mindexed-loads
d77de738
ML
21426Enable the use of indexed loads. This can be problematic because some
21427optimizers then assume that indexed stores exist, which is not
21428the case.
21429
d77de738 21430@opindex mlra
ddf6fe37 21431@item -mlra
d77de738
ML
21432Enable Local Register Allocation. This is still experimental for ARC,
21433so by default the compiler uses standard reload
21434(i.e.@: @option{-mno-lra}).
21435
d77de738 21436@opindex mlra-priority-none
ddf6fe37 21437@item -mlra-priority-none
d77de738
ML
21438Don't indicate any priority for target registers.
21439
d77de738 21440@opindex mlra-priority-compact
ddf6fe37 21441@item -mlra-priority-compact
d77de738
ML
21442Indicate target register priority for r0..r3 / r12..r15.
21443
d77de738 21444@opindex mlra-priority-noncompact
ddf6fe37 21445@item -mlra-priority-noncompact
d77de738
ML
21446Reduce target register priority for r0..r3 / r12..r15.
21447
d77de738 21448@opindex mmillicode
ddf6fe37 21449@item -mmillicode
d77de738
ML
21450When optimizing for size (using @option{-Os}), prologues and epilogues
21451that have to save or restore a large number of registers are often
21452shortened by using call to a special function in libgcc; this is
21453referred to as a @emph{millicode} call. As these calls can pose
21454performance issues, and/or cause linking issues when linking in a
21455nonstandard way, this option is provided to turn on or off millicode
21456call generation.
21457
d77de738 21458@opindex mcode-density-frame
ddf6fe37 21459@item -mcode-density-frame
d77de738
ML
21460This option enable the compiler to emit @code{enter} and @code{leave}
21461instructions. These instructions are only valid for CPUs with
21462code-density feature.
21463
d77de738 21464@opindex mmixed-code
ddf6fe37 21465@item -mmixed-code
d77de738
ML
21466Does nothing. Preserved for backward compatibility.
21467
d77de738 21468@opindex mq-class
ddf6fe37 21469@item -mq-class
d77de738
ML
21470Ths option is deprecated. Enable @samp{q} instruction alternatives.
21471This is the default for @option{-Os}.
21472
d77de738 21473@opindex mRcq
ddf6fe37 21474@item -mRcq
d77de738
ML
21475Does nothing. Preserved for backward compatibility.
21476
d77de738 21477@opindex mRcw
ddf6fe37 21478@item -mRcw
d77de738
ML
21479Does nothing. Preserved for backward compatibility.
21480
d77de738 21481@opindex msize-level
ddf6fe37 21482@item -msize-level=@var{level}
d77de738
ML
21483Fine-tune size optimization with regards to instruction lengths and alignment.
21484The recognized values for @var{level} are:
21485@table @samp
21486@item 0
21487No size optimization. This level is deprecated and treated like @samp{1}.
21488
21489@item 1
21490Short instructions are used opportunistically.
21491
21492@item 2
21493In addition, alignment of loops and of code after barriers are dropped.
21494
21495@item 3
21496In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21497
21498@end table
21499
21500This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21501the behavior when this is not set is equivalent to level @samp{1}.
21502
d77de738 21503@opindex mtune
ddf6fe37 21504@item -mtune=@var{cpu}
d77de738
ML
21505Set instruction scheduling parameters for @var{cpu}, overriding any implied
21506by @option{-mcpu=}.
21507
21508Supported values for @var{cpu} are
21509
21510@table @samp
21511@item ARC600
21512Tune for ARC600 CPU.
21513
21514@item ARC601
21515Tune for ARC601 CPU.
21516
21517@item ARC700
21518Tune for ARC700 CPU with standard multiplier block.
21519
21520@item ARC700-xmac
21521Tune for ARC700 CPU with XMAC block.
21522
21523@item ARC725D
21524Tune for ARC725D CPU.
21525
21526@item ARC750D
21527Tune for ARC750D CPU.
21528
21529@item core3
21530Tune for ARCv2 core3 type CPU. This option enable usage of
21531@code{dbnz} instruction.
21532
21533@item release31a
21534Tune for ARC4x release 3.10a.
21535
21536@end table
21537
d77de738 21538@opindex mmultcost
ddf6fe37 21539@item -mmultcost=@var{num}
d77de738
ML
21540Cost to assume for a multiply instruction, with @samp{4} being equal to a
21541normal instruction.
21542
d77de738 21543@opindex munalign-prob-threshold
ddf6fe37 21544@item -munalign-prob-threshold=@var{probability}
d77de738
ML
21545Does nothing. Preserved for backward compatibility.
21546
21547@end table
21548
21549The following options are maintained for backward compatibility, but
21550are now deprecated and will be removed in a future release:
21551
21552@c Deprecated options
21553@table @gcctabopt
21554
d77de738 21555@opindex margonaut
ddf6fe37 21556@item -margonaut
d77de738
ML
21557Obsolete FPX.
21558
d77de738 21559@opindex mbig-endian
d77de738 21560@opindex EB
ddf6fe37
AA
21561@item -mbig-endian
21562@itemx -EB
d77de738
ML
21563Compile code for big-endian targets. Use of these options is now
21564deprecated. Big-endian code is supported by configuring GCC to build
21565@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21566for which big endian is the default.
21567
d77de738 21568@opindex mlittle-endian
d77de738 21569@opindex EL
ddf6fe37
AA
21570@item -mlittle-endian
21571@itemx -EL
d77de738
ML
21572Compile code for little-endian targets. Use of these options is now
21573deprecated. Little-endian code is supported by configuring GCC to build
21574@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21575for which little endian is the default.
21576
d77de738 21577@opindex mbarrel_shifter
ddf6fe37 21578@item -mbarrel_shifter
d77de738
ML
21579Replaced by @option{-mbarrel-shifter}.
21580
d77de738 21581@opindex mdpfp_compact
ddf6fe37 21582@item -mdpfp_compact
d77de738
ML
21583Replaced by @option{-mdpfp-compact}.
21584
d77de738 21585@opindex mdpfp_fast
ddf6fe37 21586@item -mdpfp_fast
d77de738
ML
21587Replaced by @option{-mdpfp-fast}.
21588
d77de738 21589@opindex mdsp_packa
ddf6fe37 21590@item -mdsp_packa
d77de738
ML
21591Replaced by @option{-mdsp-packa}.
21592
d77de738 21593@opindex mEA
ddf6fe37 21594@item -mEA
d77de738
ML
21595Replaced by @option{-mea}.
21596
d77de738 21597@opindex mmac_24
ddf6fe37 21598@item -mmac_24
d77de738
ML
21599Replaced by @option{-mmac-24}.
21600
d77de738 21601@opindex mmac_d16
ddf6fe37 21602@item -mmac_d16
d77de738
ML
21603Replaced by @option{-mmac-d16}.
21604
d77de738 21605@opindex mspfp_compact
ddf6fe37 21606@item -mspfp_compact
d77de738
ML
21607Replaced by @option{-mspfp-compact}.
21608
d77de738 21609@opindex mspfp_fast
ddf6fe37 21610@item -mspfp_fast
d77de738
ML
21611Replaced by @option{-mspfp-fast}.
21612
d77de738 21613@opindex mtune
ddf6fe37 21614@item -mtune=@var{cpu}
d77de738
ML
21615Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21616@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21617@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21618
d77de738 21619@opindex multcost
ddf6fe37 21620@item -multcost=@var{num}
d77de738
ML
21621Replaced by @option{-mmultcost}.
21622
21623@end table
21624
21625@node ARM Options
21626@subsection ARM Options
21627@cindex ARM options
21628
21629These @samp{-m} options are defined for the ARM port:
21630
21631@table @gcctabopt
d77de738 21632@opindex mabi
ddf6fe37 21633@item -mabi=@var{name}
d77de738
ML
21634Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21635@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21636
d77de738 21637@opindex mapcs-frame
ddf6fe37 21638@item -mapcs-frame
d77de738
ML
21639Generate a stack frame that is compliant with the ARM Procedure Call
21640Standard for all functions, even if this is not strictly necessary for
21641correct execution of the code. Specifying @option{-fomit-frame-pointer}
21642with this option causes the stack frames not to be generated for
21643leaf functions. The default is @option{-mno-apcs-frame}.
21644This option is deprecated.
21645
d77de738 21646@opindex mapcs
ddf6fe37 21647@item -mapcs
d77de738
ML
21648This is a synonym for @option{-mapcs-frame} and is deprecated.
21649
21650@ignore
21651@c not currently implemented
d77de738 21652@opindex mapcs-stack-check
ddf6fe37 21653@item -mapcs-stack-check
d77de738
ML
21654Generate code to check the amount of stack space available upon entry to
21655every function (that actually uses some stack space). If there is
21656insufficient space available then either the function
21657@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21658called, depending upon the amount of stack space required. The runtime
21659system is required to provide these functions. The default is
21660@option{-mno-apcs-stack-check}, since this produces smaller code.
21661
21662@c not currently implemented
d77de738 21663@opindex mapcs-reentrant
ddf6fe37 21664@item -mapcs-reentrant
d77de738
ML
21665Generate reentrant, position-independent code. The default is
21666@option{-mno-apcs-reentrant}.
21667@end ignore
21668
d77de738 21669@opindex mthumb-interwork
ddf6fe37 21670@item -mthumb-interwork
d77de738
ML
21671Generate code that supports calling between the ARM and Thumb
21672instruction sets. Without this option, on pre-v5 architectures, the
21673two instruction sets cannot be reliably used inside one program. The
21674default is @option{-mno-thumb-interwork}, since slightly larger code
21675is generated when @option{-mthumb-interwork} is specified. In AAPCS
21676configurations this option is meaningless.
21677
d77de738
ML
21678@opindex mno-sched-prolog
21679@opindex msched-prolog
ddf6fe37 21680@item -mno-sched-prolog
d77de738
ML
21681Prevent the reordering of instructions in the function prologue, or the
21682merging of those instruction with the instructions in the function's
21683body. This means that all functions start with a recognizable set
21684of instructions (or in fact one of a choice from a small set of
21685different function prologues), and this information can be used to
21686locate the start of functions inside an executable piece of code. The
21687default is @option{-msched-prolog}.
21688
d77de738 21689@opindex mfloat-abi
ddf6fe37 21690@item -mfloat-abi=@var{name}
d77de738
ML
21691Specifies which floating-point ABI to use. Permissible values
21692are: @samp{soft}, @samp{softfp} and @samp{hard}.
21693
21694Specifying @samp{soft} causes GCC to generate output containing
21695library calls for floating-point operations.
21696@samp{softfp} allows the generation of code using hardware floating-point
21697instructions, but still uses the soft-float calling conventions.
21698@samp{hard} allows generation of floating-point instructions
21699and uses FPU-specific calling conventions.
21700
21701The default depends on the specific target configuration. Note that
21702the hard-float and soft-float ABIs are not link-compatible; you must
21703compile your entire program with the same ABI, and link with a
21704compatible set of libraries.
21705
d77de738 21706@opindex mgeneral-regs-only
ddf6fe37 21707@item -mgeneral-regs-only
d77de738
ML
21708Generate code which uses only the general-purpose registers. This will prevent
21709the compiler from using floating-point and Advanced SIMD registers but will not
21710impose any restrictions on the assembler.
21711
d77de738 21712@opindex mlittle-endian
ddf6fe37 21713@item -mlittle-endian
d77de738
ML
21714Generate code for a processor running in little-endian mode. This is
21715the default for all standard configurations.
21716
d77de738 21717@opindex mbig-endian
ddf6fe37 21718@item -mbig-endian
d77de738
ML
21719Generate code for a processor running in big-endian mode; the default is
21720to compile code for a little-endian processor.
21721
ddf6fe37 21722@opindex mbe8
d77de738
ML
21723@item -mbe8
21724@itemx -mbe32
d77de738
ML
21725When linking a big-endian image select between BE8 and BE32 formats.
21726The option has no effect for little-endian images and is ignored. The
21727default is dependent on the selected target architecture. For ARMv6
21728and later architectures the default is BE8, for older architectures
21729the default is BE32. BE32 format has been deprecated by ARM.
21730
d77de738 21731@opindex march
ddf6fe37 21732@item -march=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
21733This specifies the name of the target ARM architecture. GCC uses this
21734name to determine what kind of instructions it can emit when generating
21735assembly code. This option can be used in conjunction with or instead
21736of the @option{-mcpu=} option.
21737
21738Permissible names are:
21739@samp{armv4t},
21740@samp{armv5t}, @samp{armv5te},
21741@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
21742@samp{armv6z}, @samp{armv6zk},
21743@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
21744@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
21745@samp{armv8.4-a},
21746@samp{armv8.5-a},
21747@samp{armv8.6-a},
21748@samp{armv9-a},
21749@samp{armv7-r},
21750@samp{armv8-r},
21751@samp{armv6-m}, @samp{armv6s-m},
21752@samp{armv7-m}, @samp{armv7e-m},
21753@samp{armv8-m.base}, @samp{armv8-m.main},
21754@samp{armv8.1-m.main},
21755@samp{armv9-a},
21756@samp{iwmmxt} and @samp{iwmmxt2}.
21757
21758Additionally, the following architectures, which lack support for the
21759Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
21760
21761Many of the architectures support extensions. These can be added by
21762appending @samp{+@var{extension}} to the architecture name. Extension
21763options are processed in order and capabilities accumulate. An extension
21764will also enable any necessary base extensions
21765upon which it depends. For example, the @samp{+crypto} extension
21766will always enable the @samp{+simd} extension. The exception to the
21767additive construction is for extensions that are prefixed with
21768@samp{+no@dots{}}: these extensions disable the specified option and
21769any other extensions that may depend on the presence of that
21770extension.
21771
21772For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
21773writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
21774entirely disabled by the @samp{+nofp} option that follows it.
21775
21776Most extension names are generically named, but have an effect that is
21777dependent upon the architecture to which it is applied. For example,
21778the @samp{+simd} option can be applied to both @samp{armv7-a} and
21779@samp{armv8-a} architectures, but will enable the original ARMv7-A
21780Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
21781variant for @samp{armv8-a}.
21782
21783The table below lists the supported extensions for each architecture.
21784Architectures not mentioned do not support any extensions.
21785
21786@table @samp
21787@item armv5te
21788@itemx armv6
21789@itemx armv6j
21790@itemx armv6k
21791@itemx armv6kz
21792@itemx armv6t2
21793@itemx armv6z
21794@itemx armv6zk
21795@table @samp
21796@item +fp
21797The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
21798used as an alias for this extension.
21799
21800@item +nofp
21801Disable the floating-point instructions.
21802@end table
21803
21804@item armv7
21805The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
21806@table @samp
21807@item +fp
21808The VFPv3 floating-point instructions, with 16 double-precision
21809registers. The extension @samp{+vfpv3-d16} can be used as an alias
21810for this extension. Note that floating-point is not supported by the
21811base ARMv7-M architecture, but is compatible with both the ARMv7-A and
21812ARMv7-R architectures.
21813
21814@item +nofp
21815Disable the floating-point instructions.
21816@end table
21817
21818@item armv7-a
21819@table @samp
21820@item +mp
21821The multiprocessing extension.
21822
21823@item +sec
21824The security extension.
21825
21826@item +fp
21827The VFPv3 floating-point instructions, with 16 double-precision
21828registers. The extension @samp{+vfpv3-d16} can be used as an alias
21829for this extension.
21830
21831@item +simd
21832The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21833The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
21834for this extension.
21835
21836@item +vfpv3
21837The VFPv3 floating-point instructions, with 32 double-precision
21838registers.
21839
21840@item +vfpv3-d16-fp16
21841The VFPv3 floating-point instructions, with 16 double-precision
21842registers and the half-precision floating-point conversion operations.
21843
21844@item +vfpv3-fp16
21845The VFPv3 floating-point instructions, with 32 double-precision
21846registers and the half-precision floating-point conversion operations.
21847
21848@item +vfpv4-d16
21849The VFPv4 floating-point instructions, with 16 double-precision
21850registers.
21851
21852@item +vfpv4
21853The VFPv4 floating-point instructions, with 32 double-precision
21854registers.
21855
21856@item +neon-fp16
21857The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21858the half-precision floating-point conversion operations.
21859
21860@item +neon-vfpv4
21861The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
21862
21863@item +nosimd
21864Disable the Advanced SIMD instructions (does not disable floating point).
21865
21866@item +nofp
21867Disable the floating-point and Advanced SIMD instructions.
21868@end table
21869
21870@item armv7ve
21871The extended version of the ARMv7-A architecture with support for
21872virtualization.
21873@table @samp
21874@item +fp
21875The VFPv4 floating-point instructions, with 16 double-precision registers.
21876The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
21877
21878@item +simd
21879The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
21880extension @samp{+neon-vfpv4} can be used as an alias for this extension.
21881
21882@item +vfpv3-d16
21883The VFPv3 floating-point instructions, with 16 double-precision
21884registers.
21885
21886@item +vfpv3
21887The VFPv3 floating-point instructions, with 32 double-precision
21888registers.
21889
21890@item +vfpv3-d16-fp16
21891The VFPv3 floating-point instructions, with 16 double-precision
21892registers and the half-precision floating-point conversion operations.
21893
21894@item +vfpv3-fp16
21895The VFPv3 floating-point instructions, with 32 double-precision
21896registers and the half-precision floating-point conversion operations.
21897
21898@item +vfpv4-d16
21899The VFPv4 floating-point instructions, with 16 double-precision
21900registers.
21901
21902@item +vfpv4
21903The VFPv4 floating-point instructions, with 32 double-precision
21904registers.
21905
21906@item +neon
21907The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21908The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
21909
21910@item +neon-fp16
21911The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21912the half-precision floating-point conversion operations.
21913
21914@item +nosimd
21915Disable the Advanced SIMD instructions (does not disable floating point).
21916
21917@item +nofp
21918Disable the floating-point and Advanced SIMD instructions.
21919@end table
21920
21921@item armv8-a
21922@table @samp
21923@item +crc
21924The Cyclic Redundancy Check (CRC) instructions.
21925@item +simd
21926The ARMv8-A Advanced SIMD and floating-point instructions.
21927@item +crypto
21928The cryptographic instructions.
21929@item +nocrypto
21930Disable the cryptographic instructions.
21931@item +nofp
21932Disable the floating-point, Advanced SIMD and cryptographic instructions.
21933@item +sb
21934Speculation Barrier Instruction.
21935@item +predres
21936Execution and Data Prediction Restriction Instructions.
21937@end table
21938
21939@item armv8.1-a
21940@table @samp
21941@item +simd
21942The ARMv8.1-A Advanced SIMD and floating-point instructions.
21943
21944@item +crypto
21945The cryptographic instructions. This also enables the Advanced SIMD and
21946floating-point instructions.
21947
21948@item +nocrypto
21949Disable the cryptographic instructions.
21950
21951@item +nofp
21952Disable the floating-point, Advanced SIMD and cryptographic instructions.
21953
21954@item +sb
21955Speculation Barrier Instruction.
21956
21957@item +predres
21958Execution and Data Prediction Restriction Instructions.
21959@end table
21960
21961@item armv8.2-a
21962@itemx armv8.3-a
21963@table @samp
21964@item +fp16
21965The half-precision floating-point data processing instructions.
21966This also enables the Advanced SIMD and floating-point instructions.
21967
21968@item +fp16fml
21969The half-precision floating-point fmla extension. This also enables
21970the half-precision floating-point extension and Advanced SIMD and
21971floating-point instructions.
21972
21973@item +simd
21974The ARMv8.1-A Advanced SIMD and floating-point instructions.
21975
21976@item +crypto
21977The cryptographic instructions. This also enables the Advanced SIMD and
21978floating-point instructions.
21979
21980@item +dotprod
21981Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21982
21983@item +nocrypto
21984Disable the cryptographic extension.
21985
21986@item +nofp
21987Disable the floating-point, Advanced SIMD and cryptographic instructions.
21988
21989@item +sb
21990Speculation Barrier Instruction.
21991
21992@item +predres
21993Execution and Data Prediction Restriction Instructions.
21994
21995@item +i8mm
219968-bit Integer Matrix Multiply instructions.
21997This also enables Advanced SIMD and floating-point instructions.
21998
21999@item +bf16
22000Brain half-precision floating-point instructions.
22001This also enables Advanced SIMD and floating-point instructions.
22002@end table
22003
22004@item armv8.4-a
22005@table @samp
22006@item +fp16
22007The half-precision floating-point data processing instructions.
22008This also enables the Advanced SIMD and floating-point instructions as well
22009as the Dot Product extension and the half-precision floating-point fmla
22010extension.
22011
22012@item +simd
22013The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22014Dot Product extension.
22015
22016@item +crypto
22017The cryptographic instructions. This also enables the Advanced SIMD and
22018floating-point instructions as well as the Dot Product extension.
22019
22020@item +nocrypto
22021Disable the cryptographic extension.
22022
22023@item +nofp
22024Disable the floating-point, Advanced SIMD and cryptographic instructions.
22025
22026@item +sb
22027Speculation Barrier Instruction.
22028
22029@item +predres
22030Execution and Data Prediction Restriction Instructions.
22031
22032@item +i8mm
220338-bit Integer Matrix Multiply instructions.
22034This also enables Advanced SIMD and floating-point instructions.
22035
22036@item +bf16
22037Brain half-precision floating-point instructions.
22038This also enables Advanced SIMD and floating-point instructions.
22039@end table
22040
22041@item armv8.5-a
22042@table @samp
22043@item +fp16
22044The half-precision floating-point data processing instructions.
22045This also enables the Advanced SIMD and floating-point instructions as well
22046as the Dot Product extension and the half-precision floating-point fmla
22047extension.
22048
22049@item +simd
22050The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22051Dot Product extension.
22052
22053@item +crypto
22054The cryptographic instructions. This also enables the Advanced SIMD and
22055floating-point instructions as well as the Dot Product extension.
22056
22057@item +nocrypto
22058Disable the cryptographic extension.
22059
22060@item +nofp
22061Disable the floating-point, Advanced SIMD and cryptographic instructions.
22062
22063@item +i8mm
220648-bit Integer Matrix Multiply instructions.
22065This also enables Advanced SIMD and floating-point instructions.
22066
22067@item +bf16
22068Brain half-precision floating-point instructions.
22069This also enables Advanced SIMD and floating-point instructions.
22070@end table
22071
22072@item armv8.6-a
22073@table @samp
22074@item +fp16
22075The half-precision floating-point data processing instructions.
22076This also enables the Advanced SIMD and floating-point instructions as well
22077as the Dot Product extension and the half-precision floating-point fmla
22078extension.
22079
22080@item +simd
22081The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22082Dot Product extension.
22083
22084@item +crypto
22085The cryptographic instructions. This also enables the Advanced SIMD and
22086floating-point instructions as well as the Dot Product extension.
22087
22088@item +nocrypto
22089Disable the cryptographic extension.
22090
22091@item +nofp
22092Disable the floating-point, Advanced SIMD and cryptographic instructions.
22093
22094@item +i8mm
220958-bit Integer Matrix Multiply instructions.
22096This also enables Advanced SIMD and floating-point instructions.
22097
22098@item +bf16
22099Brain half-precision floating-point instructions.
22100This also enables Advanced SIMD and floating-point instructions.
22101@end table
22102
22103@item armv7-r
22104@table @samp
22105@item +fp.sp
22106The single-precision VFPv3 floating-point instructions. The extension
22107@samp{+vfpv3xd} can be used as an alias for this extension.
22108
22109@item +fp
22110The VFPv3 floating-point instructions with 16 double-precision registers.
22111The extension +vfpv3-d16 can be used as an alias for this extension.
22112
22113@item +vfpv3xd-d16-fp16
22114The single-precision VFPv3 floating-point instructions with 16 double-precision
22115registers and the half-precision floating-point conversion operations.
22116
22117@item +vfpv3-d16-fp16
22118The VFPv3 floating-point instructions with 16 double-precision
22119registers and the half-precision floating-point conversion operations.
22120
22121@item +nofp
22122Disable the floating-point extension.
22123
22124@item +idiv
22125The ARM-state integer division instructions.
22126
22127@item +noidiv
22128Disable the ARM-state integer division extension.
22129@end table
22130
22131@item armv7e-m
22132@table @samp
22133@item +fp
22134The single-precision VFPv4 floating-point instructions.
22135
22136@item +fpv5
22137The single-precision FPv5 floating-point instructions.
22138
22139@item +fp.dp
22140The single- and double-precision FPv5 floating-point instructions.
22141
22142@item +nofp
22143Disable the floating-point extensions.
22144@end table
22145
22146@item armv8.1-m.main
22147@table @samp
22148
22149@item +dsp
22150The DSP instructions.
22151
22152@item +mve
22153The M-Profile Vector Extension (MVE) integer instructions.
22154
22155@item +mve.fp
22156The M-Profile Vector Extension (MVE) integer and single precision
22157floating-point instructions.
22158
22159@item +fp
22160The single-precision floating-point instructions.
22161
22162@item +fp.dp
22163The single- and double-precision floating-point instructions.
22164
22165@item +nofp
22166Disable the floating-point extension.
22167
22168@item +cdecp0, +cdecp1, ... , +cdecp7
22169Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22170to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
22171
22172@item +pacbti
22173Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
22174@end table
22175
22176@item armv8-m.main
22177@table @samp
22178@item +dsp
22179The DSP instructions.
22180
22181@item +nodsp
22182Disable the DSP extension.
22183
22184@item +fp
22185The single-precision floating-point instructions.
22186
22187@item +fp.dp
22188The single- and double-precision floating-point instructions.
22189
22190@item +nofp
22191Disable the floating-point extension.
22192
22193@item +cdecp0, +cdecp1, ... , +cdecp7
22194Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22195to the numbers given in the options in the range 0 to 7.
22196@end table
22197
22198@item armv8-r
22199@table @samp
22200@item +crc
22201The Cyclic Redundancy Check (CRC) instructions.
22202@item +fp.sp
22203The single-precision FPv5 floating-point instructions.
22204@item +simd
22205The ARMv8-A Advanced SIMD and floating-point instructions.
22206@item +crypto
22207The cryptographic instructions.
22208@item +nocrypto
22209Disable the cryptographic instructions.
22210@item +nofp
22211Disable the floating-point, Advanced SIMD and cryptographic instructions.
22212@end table
22213
22214@end table
22215
22216@option{-march=native} causes the compiler to auto-detect the architecture
22217of the build computer. At present, this feature is only supported on
22218GNU/Linux, and not all architectures are recognized. If the auto-detect
22219is unsuccessful the option has no effect.
22220
d77de738 22221@opindex mtune
ddf6fe37 22222@item -mtune=@var{name}
d77de738
ML
22223This option specifies the name of the target ARM processor for
22224which GCC should tune the performance of the code.
22225For some ARM implementations better performance can be obtained by using
22226this option.
22227Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22228@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22229@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22230@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22231@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22232@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22233@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22234@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22235@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22236@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22237@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22238@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22239@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22240@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22241@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22242@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22243@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22244@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22245@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
ccfd1e7f
SP
22246@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
22247@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
22248@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22249@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22250@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22251@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22252@samp{xgene1}.
22253
22254Additionally, this option can specify that GCC should tune the performance
22255of the code for a big.LITTLE system. Permissible names are:
22256@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22257@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22258@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22259@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22260
22261@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22262performance for a blend of processors within architecture @var{arch}.
22263The aim is to generate code that run well on the current most popular
22264processors, balancing between optimizations that benefit some CPUs in the
22265range, and avoiding performance pitfalls of other CPUs. The effects of
22266this option may change in future GCC versions as CPU models come and go.
22267
22268@option{-mtune} permits the same extension options as @option{-mcpu}, but
22269the extension options do not affect the tuning of the generated code.
22270
22271@option{-mtune=native} causes the compiler to auto-detect the CPU
22272of the build computer. At present, this feature is only supported on
22273GNU/Linux, and not all architectures are recognized. If the auto-detect is
22274unsuccessful the option has no effect.
22275
d77de738 22276@opindex mcpu
ddf6fe37 22277@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22278This specifies the name of the target ARM processor. GCC uses this name
22279to derive the name of the target ARM architecture (as if specified
22280by @option{-march}) and the ARM processor type for which to tune for
22281performance (as if specified by @option{-mtune}). Where this option
22282is used in conjunction with @option{-march} or @option{-mtune},
22283those options take precedence over the appropriate part of this option.
22284
22285Many of the supported CPUs implement optional architectural
22286extensions. Where this is so the architectural extensions are
22287normally enabled by default. If implementations that lack the
22288extension exist, then the extension syntax can be used to disable
22289those extensions that have been omitted. For floating-point and
22290Advanced SIMD (Neon) instructions, the settings of the options
22291@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22292floating-point and Advanced SIMD instructions will only be used if
22293@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22294@option{-mfpu} other than @samp{auto} will override the available
22295floating-point and SIMD extension instructions.
22296
22297For example, @samp{cortex-a9} can be found in three major
22298configurations: integer only, with just a floating-point unit or with
22299floating-point and Advanced SIMD. The default is to enable all the
22300instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22301be used to disable just the SIMD or both the SIMD and floating-point
22302instructions respectively.
22303
22304Permissible names for this option are the same as those for
22305@option{-mtune}.
22306
22307The following extension options are common to the listed CPUs:
22308
22309@table @samp
22310@item +nodsp
ccfd1e7f
SP
22311Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
22312@samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector
22313Extension (MVE) integer and single precision floating-point instructions on
22314@samp{cortex-m55} and @samp{cortex-m85}.
22315
22316@item +nopacbti
22317Disable the Pointer Authentication and Branch Target Identification Extension
22318on @samp{cortex-m85}.
d77de738
ML
22319
22320@item +nomve
22321Disable the M-Profile Vector Extension (MVE) integer and single precision
ccfd1e7f 22322floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22323
22324@item +nomve.fp
22325Disable the M-Profile Vector Extension (MVE) single precision floating-point
ccfd1e7f 22326instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 22327
798a0d05
SP
22328@item +cdecp0, +cdecp1, ... , +cdecp7
22329Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22330to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22331
d77de738
ML
22332@item +nofp
22333Disables the floating-point instructions on @samp{arm9e},
22334@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22335@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22336@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22337@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
ccfd1e7f
SP
22338@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
22339@samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22340Disables the floating-point and SIMD instructions on
22341@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22342@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22343@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22344@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22345@samp{cortex-a53} and @samp{cortex-a55}.
22346
22347@item +nofp.dp
22348Disables the double-precision component of the floating-point instructions
22349on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22350@samp{cortex-r52plus} and @samp{cortex-m7}.
22351
22352@item +nosimd
22353Disables the SIMD (but not floating-point) instructions on
22354@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22355and @samp{cortex-a9}.
22356
22357@item +crypto
22358Enables the cryptographic instructions on @samp{cortex-a32},
22359@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22360@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22361@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22362@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22363@samp{cortex-a75.cortex-a55}.
22364@end table
22365
22366Additionally the @samp{generic-armv7-a} pseudo target defaults to
22367VFPv3 with 16 double-precision registers. It supports the following
22368extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22369@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22370@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22371@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22372the extensions to @option{-march=armv7-a}.
22373
22374@option{-mcpu=generic-@var{arch}} is also permissible, and is
22375equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22376See @option{-mtune} for more information.
22377
22378@option{-mcpu=native} causes the compiler to auto-detect the CPU
22379of the build computer. At present, this feature is only supported on
22380GNU/Linux, and not all architectures are recognized. If the auto-detect
22381is unsuccessful the option has no effect.
22382
d77de738 22383@opindex mfpu
ddf6fe37 22384@item -mfpu=@var{name}
d77de738
ML
22385This specifies what floating-point hardware (or hardware emulation) is
22386available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22387@samp{vfpv3},
22388@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22389@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22390@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22391@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22392@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22393Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22394is an alias for @samp{vfpv2}.
22395
22396The setting @samp{auto} is the default and is special. It causes the
22397compiler to select the floating-point and Advanced SIMD instructions
22398based on the settings of @option{-mcpu} and @option{-march}.
22399
22400If the selected floating-point hardware includes the NEON extension
22401(e.g.@: @option{-mfpu=neon}), note that floating-point
22402operations are not generated by GCC's auto-vectorization pass unless
22403@option{-funsafe-math-optimizations} is also specified. This is
22404because NEON hardware does not fully implement the IEEE 754 standard for
22405floating-point arithmetic (in particular denormal values are treated as
22406zero), so the use of NEON instructions may lead to a loss of precision.
22407
22408You 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}).
22409
d77de738 22410@opindex mfp16-format
ddf6fe37 22411@item -mfp16-format=@var{name}
d77de738
ML
22412Specify the format of the @code{__fp16} half-precision floating-point type.
22413Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22414the default is @samp{none}, in which case the @code{__fp16} type is not
22415defined. @xref{Half-Precision}, for more information.
22416
d77de738 22417@opindex mstructure-size-boundary
ddf6fe37 22418@item -mstructure-size-boundary=@var{n}
d77de738
ML
22419The sizes of all structures and unions are rounded up to a multiple
22420of the number of bits set by this option. Permissible values are 8, 32
22421and 64. The default value varies for different toolchains. For the COFF
22422targeted toolchain the default value is 8. A value of 64 is only allowed
22423if the underlying ABI supports it.
22424
22425Specifying a larger number can produce faster, more efficient code, but
22426can also increase the size of the program. Different values are potentially
22427incompatible. Code compiled with one value cannot necessarily expect to
22428work with code or libraries compiled with another value, if they exchange
22429information using structures or unions.
22430
22431This option is deprecated.
22432
d77de738 22433@opindex mabort-on-noreturn
ddf6fe37 22434@item -mabort-on-noreturn
d77de738
ML
22435Generate a call to the function @code{abort} at the end of a
22436@code{noreturn} function. It is executed if the function tries to
22437return.
22438
d77de738
ML
22439@opindex mlong-calls
22440@opindex mno-long-calls
ddf6fe37
AA
22441@item -mlong-calls
22442@itemx -mno-long-calls
d77de738
ML
22443Tells the compiler to perform function calls by first loading the
22444address of the function into a register and then performing a subroutine
22445call on this register. This switch is needed if the target function
22446lies outside of the 64-megabyte addressing range of the offset-based
22447version of subroutine call instruction.
22448
22449Even if this switch is enabled, not all function calls are turned
22450into long calls. The heuristic is that static functions, functions
22451that have the @code{short_call} attribute, functions that are inside
22452the scope of a @code{#pragma no_long_calls} directive, and functions whose
22453definitions have already been compiled within the current compilation
22454unit are not turned into long calls. The exceptions to this rule are
22455that weak function definitions, functions with the @code{long_call}
22456attribute or the @code{section} attribute, and functions that are within
22457the scope of a @code{#pragma long_calls} directive are always
22458turned into long calls.
22459
22460This feature is not enabled by default. Specifying
22461@option{-mno-long-calls} restores the default behavior, as does
22462placing the function calls within the scope of a @code{#pragma
22463long_calls_off} directive. Note these switches have no effect on how
22464the compiler generates code to handle function calls via function
22465pointers.
22466
d77de738 22467@opindex msingle-pic-base
ddf6fe37 22468@item -msingle-pic-base
d77de738
ML
22469Treat the register used for PIC addressing as read-only, rather than
22470loading it in the prologue for each function. The runtime system is
22471responsible for initializing this register with an appropriate value
22472before execution begins.
22473
d77de738 22474@opindex mpic-register
ddf6fe37 22475@item -mpic-register=@var{reg}
d77de738
ML
22476Specify the register to be used for PIC addressing.
22477For standard PIC base case, the default is any suitable register
22478determined by compiler. For single PIC base case, the default is
22479@samp{R9} if target is EABI based or stack-checking is enabled,
22480otherwise the default is @samp{R10}.
22481
d77de738 22482@opindex mpic-data-is-text-relative
ddf6fe37 22483@item -mpic-data-is-text-relative
d77de738
ML
22484Assume that the displacement between the text and data segments is fixed
22485at static link time. This permits using PC-relative addressing
22486operations to access data known to be in the data segment. For
22487non-VxWorks RTP targets, this option is enabled by default. When
22488disabled on such targets, it will enable @option{-msingle-pic-base} by
22489default.
22490
d77de738 22491@opindex mpoke-function-name
ddf6fe37 22492@item -mpoke-function-name
d77de738
ML
22493Write the name of each function into the text section, directly
22494preceding the function prologue. The generated code is similar to this:
22495
22496@smallexample
22497 t0
22498 .ascii "arm_poke_function_name", 0
22499 .align
22500 t1
22501 .word 0xff000000 + (t1 - t0)
22502 arm_poke_function_name
22503 mov ip, sp
22504 stmfd sp!, @{fp, ip, lr, pc@}
22505 sub fp, ip, #4
22506@end smallexample
22507
22508When performing a stack backtrace, code can inspect the value of
22509@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22510location @code{pc - 12} and the top 8 bits are set, then we know that
22511there is a function name embedded immediately preceding this location
22512and has length @code{((pc[-3]) & 0xff000000)}.
22513
d77de738
ML
22514@opindex marm
22515@opindex mthumb
ddf6fe37
AA
22516@item -mthumb
22517@itemx -marm
d77de738
ML
22518
22519Select between generating code that executes in ARM and Thumb
22520states. The default for most configurations is to generate code
22521that executes in ARM state, but the default can be changed by
22522configuring GCC with the @option{--with-mode=}@var{state}
22523configure option.
22524
22525You can also override the ARM and Thumb mode for each function
22526by using the @code{target("thumb")} and @code{target("arm")} function attributes
22527(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22528
d77de738 22529@opindex mflip-thumb
ddf6fe37 22530@item -mflip-thumb
d77de738
ML
22531Switch ARM/Thumb modes on alternating functions.
22532This option is provided for regression testing of mixed Thumb/ARM code
22533generation, and is not intended for ordinary use in compiling code.
22534
d77de738 22535@opindex mtpcs-frame
ddf6fe37 22536@item -mtpcs-frame
d77de738
ML
22537Generate a stack frame that is compliant with the Thumb Procedure Call
22538Standard for all non-leaf functions. (A leaf function is one that does
22539not call any other functions.) The default is @option{-mno-tpcs-frame}.
22540
d77de738 22541@opindex mtpcs-leaf-frame
ddf6fe37 22542@item -mtpcs-leaf-frame
d77de738
ML
22543Generate a stack frame that is compliant with the Thumb Procedure Call
22544Standard for all leaf functions. (A leaf function is one that does
22545not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22546
d77de738 22547@opindex mcallee-super-interworking
ddf6fe37 22548@item -mcallee-super-interworking
d77de738
ML
22549Gives all externally visible functions in the file being compiled an ARM
22550instruction set header which switches to Thumb mode before executing the
22551rest of the function. This allows these functions to be called from
22552non-interworking code. This option is not valid in AAPCS configurations
22553because interworking is enabled by default.
22554
d77de738 22555@opindex mcaller-super-interworking
ddf6fe37 22556@item -mcaller-super-interworking
d77de738
ML
22557Allows calls via function pointers (including virtual functions) to
22558execute correctly regardless of whether the target code has been
22559compiled for interworking or not. There is a small overhead in the cost
22560of executing a function pointer if this option is enabled. This option
22561is not valid in AAPCS configurations because interworking is enabled
22562by default.
22563
d77de738 22564@opindex mtp
ddf6fe37 22565@item -mtp=@var{name}
d77de738
ML
22566Specify the access model for the thread local storage pointer. The valid
22567models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
22568@samp{cp15}, which fetches the thread pointer from @code{cp15} directly
22569(supported in the arm6k architecture), and @samp{auto}, which uses the
22570best available method for the selected processor. The default setting is
22571@samp{auto}.
22572
d77de738 22573@opindex mtls-dialect
ddf6fe37 22574@item -mtls-dialect=@var{dialect}
d77de738
ML
22575Specify the dialect to use for accessing thread local storage. Two
22576@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22577@samp{gnu} dialect selects the original GNU scheme for supporting
22578local and global dynamic TLS models. The @samp{gnu2} dialect
22579selects the GNU descriptor scheme, which provides better performance
22580for shared libraries. The GNU descriptor scheme is compatible with
22581the original scheme, but does require new assembler, linker and
22582library support. Initial and local exec TLS models are unaffected by
22583this option and always use the original scheme.
22584
d77de738 22585@opindex mword-relocations
ddf6fe37 22586@item -mword-relocations
d77de738
ML
22587Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22588This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22589loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22590is specified. This option conflicts with @option{-mslow-flash-data}.
22591
d77de738 22592@opindex mfix-cortex-m3-ldrd
ddf6fe37 22593@item -mfix-cortex-m3-ldrd
d77de738
ML
22594Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22595with overlapping destination and base registers are used. This option avoids
22596generating these instructions. This option is enabled by default when
22597@option{-mcpu=cortex-m3} is specified.
22598
22599@item -mfix-cortex-a57-aes-1742098
22600@itemx -mno-fix-cortex-a57-aes-1742098
22601@itemx -mfix-cortex-a72-aes-1655431
22602@itemx -mno-fix-cortex-a72-aes-1655431
22603Enable (disable) mitigation for an erratum on Cortex-A57 and
22604Cortex-A72 that affects the AES cryptographic instructions. This
22605option is enabled by default when either @option{-mcpu=cortex-a57} or
22606@option{-mcpu=cortex-a72} is specified.
22607
d77de738
ML
22608@opindex munaligned-access
22609@opindex mno-unaligned-access
ddf6fe37
AA
22610@item -munaligned-access
22611@itemx -mno-unaligned-access
d77de738
ML
22612Enables (or disables) reading and writing of 16- and 32- bit values
22613from addresses that are not 16- or 32- bit aligned. By default
22614unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22615ARMv8-M Baseline architectures, and enabled for all other
22616architectures. If unaligned access is not enabled then words in packed
22617data structures are accessed a byte at a time.
22618
22619The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22620generated object file to either true or false, depending upon the
22621setting of this option. If unaligned access is enabled then the
22622preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22623defined.
22624
d77de738 22625@opindex mneon-for-64bits
ddf6fe37 22626@item -mneon-for-64bits
d77de738
ML
22627This option is deprecated and has no effect.
22628
d77de738 22629@opindex mslow-flash-data
ddf6fe37 22630@item -mslow-flash-data
d77de738
ML
22631Assume loading data from flash is slower than fetching instruction.
22632Therefore literal load is minimized for better performance.
22633This option is only supported when compiling for ARMv7 M-profile and
22634off by default. It conflicts with @option{-mword-relocations}.
22635
d77de738 22636@opindex masm-syntax-unified
ddf6fe37 22637@item -masm-syntax-unified
d77de738
ML
22638Assume inline assembler is using unified asm syntax. The default is
22639currently off which implies divided syntax. This option has no impact
22640on Thumb2. However, this may change in future releases of GCC.
22641Divided syntax should be considered deprecated.
22642
d77de738 22643@opindex mrestrict-it
ddf6fe37 22644@item -mrestrict-it
d77de738
ML
22645Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22646IT blocks can only contain a single 16-bit instruction from a select
22647set of instructions. This option is on by default for ARMv8-A Thumb mode.
22648
d77de738 22649@opindex mprint-tune-info
ddf6fe37 22650@item -mprint-tune-info
d77de738
ML
22651Print CPU tuning information as comment in assembler file. This is
22652an option used only for regression testing of the compiler and not
22653intended for ordinary use in compiling code. This option is disabled
22654by default.
22655
d77de738 22656@opindex mverbose-cost-dump
ddf6fe37 22657@item -mverbose-cost-dump
d77de738
ML
22658Enable verbose cost model dumping in the debug dump files. This option is
22659provided for use in debugging the compiler.
22660
d77de738 22661@opindex mpure-code
ddf6fe37 22662@item -mpure-code
d77de738
ML
22663Do not allow constant data to be placed in code sections.
22664Additionally, when compiling for ELF object format give all text sections the
22665ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22666is only available when generating non-pic code for M-profile targets.
22667
d77de738 22668@opindex mcmse
ddf6fe37 22669@item -mcmse
d77de738
ML
22670Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22671Development Tools Engineering Specification", which can be found on
22672@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22673
d77de738 22674@opindex mfix-cmse-cve-2021-35465
ddf6fe37 22675@item -mfix-cmse-cve-2021-35465
d77de738
ML
22676Mitigate against a potential security issue with the @code{VLLDM} instruction
22677in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22678enabled by default when the option @option{-mcpu=} is used with
ccfd1e7f
SP
22679@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85}
22680or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used
22681to disable the mitigation.
d77de738 22682
d77de738
ML
22683@opindex mstack-protector-guard
22684@opindex mstack-protector-guard-offset
ddf6fe37
AA
22685@item -mstack-protector-guard=@var{guard}
22686@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
22687Generate stack protection code using canary at @var{guard}. Supported
22688locations are @samp{global} for a global canary or @samp{tls} for a
22689canary accessible via the TLS register. The option
22690@option{-mstack-protector-guard-offset=} is for use with
22691@option{-fstack-protector-guard=tls} and not for use in user-land code.
22692
d77de738
ML
22693@opindex mfdpic
22694@opindex mno-fdpic
ddf6fe37
AA
22695@item -mfdpic
22696@itemx -mno-fdpic
d77de738
ML
22697Select the FDPIC ABI, which uses 64-bit function descriptors to
22698represent pointers to functions. When the compiler is configured for
22699@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
22700and implies @option{-fPIE} if none of the PIC/PIE-related options is
22701provided. On other targets, it only enables the FDPIC-specific code
22702generation features, and the user should explicitly provide the
22703PIC/PIE-related options as needed.
22704
22705Note that static linking is not supported because it would still
22706involve the dynamic linker when the program self-relocates. If such
22707behavior is acceptable, use -static and -Wl,-dynamic-linker options.
22708
22709The opposite @option{-mno-fdpic} option is useful (and required) to
22710build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
22711toolchain as the one used to build the userland programs.
22712
14fab5fb 22713@opindex mbranch-protection
ddf6fe37 22714@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
22715Enable branch protection features (armv8.1-m.main only).
22716@samp{none} generate code without branch protection or return address
22717signing.
22718@samp{standard[+@var{leaf}]} generate code with all branch protection
22719features enabled at their standard level.
22720@samp{pac-ret[+@var{leaf}]} generate code with return address signing
22721set to its standard level, which is to sign all functions that save
22722the return address to memory.
22723@samp{leaf} When return address signing is enabled, also sign leaf
22724functions even if they do not write the return address to memory.
22725+@samp{bti} Add landing-pad instructions at the permitted targets of
22726indirect branch instructions.
22727
22728If the @samp{+pacbti} architecture extension is not enabled, then all
22729branch protection and return address signing operations are
22730constrained to use only the instructions defined in the
22731architectural-NOP space. The generated code will remain
22732backwards-compatible with earlier versions of the architecture, but
22733the additional security can be enabled at run time on processors that
22734support the @samp{PACBTI} extension.
22735
22736Branch target enforcement using BTI can only be enabled at runtime if
22737all code in the application has been compiled with at least
22738@samp{-mbranch-protection=bti}.
22739
22740Any setting other than @samp{none} is supported only on armv8-m.main
22741or later.
22742
22743The default is to generate code without branch protection or return
22744address signing.
22745
d77de738
ML
22746@end table
22747
22748@node AVR Options
22749@subsection AVR Options
22750@cindex AVR Options
22751
22752These options are defined for AVR implementations:
22753
22754@table @gcctabopt
d77de738 22755@opindex mmcu
ddf6fe37 22756@item -mmcu=@var{mcu}
d77de738
ML
22757Specify Atmel AVR instruction set architectures (ISA) or MCU type.
22758
22759The default for this option is@tie{}@samp{avr2}.
22760
22761GCC supports the following AVR devices and ISAs:
22762
22763@include avr-mmcu.texi
22764
d77de738 22765@opindex mabsdata
ddf6fe37 22766@item -mabsdata
d77de738
ML
22767
22768Assume that all data in static storage can be accessed by LDS / STS
22769instructions. This option has only an effect on reduced Tiny devices like
22770ATtiny40. See also the @code{absdata}
22771@ref{AVR Variable Attributes,variable attribute}.
22772
d77de738 22773@opindex maccumulate-args
ddf6fe37 22774@item -maccumulate-args
d77de738
ML
22775Accumulate outgoing function arguments and acquire/release the needed
22776stack space for outgoing function arguments once in function
22777prologue/epilogue. Without this option, outgoing arguments are pushed
22778before calling a function and popped afterwards.
22779
22780Popping the arguments after the function call can be expensive on
22781AVR so that accumulating the stack space might lead to smaller
22782executables because arguments need not be removed from the
22783stack after such a function call.
22784
22785This option can lead to reduced code size for functions that perform
22786several calls to functions that get their arguments on the stack like
22787calls to printf-like functions.
22788
d77de738 22789@opindex mbranch-cost
ddf6fe37 22790@item -mbranch-cost=@var{cost}
d77de738
ML
22791Set the branch costs for conditional branch instructions to
22792@var{cost}. Reasonable values for @var{cost} are small, non-negative
22793integers. The default branch cost is 0.
22794
d77de738 22795@opindex mcall-prologues
ddf6fe37 22796@item -mcall-prologues
d77de738
ML
22797Functions prologues/epilogues are expanded as calls to appropriate
22798subroutines. Code size is smaller.
22799
d77de738
ML
22800@opindex mdouble
22801@opindex mlong-double
ddf6fe37
AA
22802@item -mdouble=@var{bits}
22803@itemx -mlong-double=@var{bits}
d77de738
ML
22804Set the size (in bits) of the @code{double} or @code{long double} type,
22805respectively. Possible values for @var{bits} are 32 and 64.
22806Whether or not a specific value for @var{bits} is allowed depends on
22807the @code{--with-double=} and @code{--with-long-double=}
22808@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
22809and the same applies for the default values of the options.
22810
d77de738 22811@opindex mgas-isr-prologues
ddf6fe37 22812@item -mgas-isr-prologues
d77de738
ML
22813Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
22814instruction supported by GNU Binutils.
22815If this option is on, the feature can still be disabled for individual
22816ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
22817function attribute. This feature is activated per default
22818if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
22819and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
22820
d77de738 22821@opindex mint8
ddf6fe37 22822@item -mint8
d77de738
ML
22823Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
22824@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
22825and @code{long long} is 4 bytes. Please note that this option does not
22826conform to the C standards, but it results in smaller code
22827size.
22828
d77de738 22829@opindex mmain-is-OS_task
ddf6fe37 22830@item -mmain-is-OS_task
d77de738
ML
22831Do not save registers in @code{main}. The effect is the same like
22832attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
22833to @code{main}. It is activated per default if optimization is on.
22834
d77de738 22835@opindex mn-flash
ddf6fe37 22836@item -mn-flash=@var{num}
d77de738
ML
22837Assume that the flash memory has a size of
22838@var{num} times 64@tie{}KiB.
22839
d77de738 22840@opindex mno-interrupts
ddf6fe37 22841@item -mno-interrupts
d77de738
ML
22842Generated code is not compatible with hardware interrupts.
22843Code size is smaller.
22844
d77de738 22845@opindex mrelax
ddf6fe37 22846@item -mrelax
d77de738
ML
22847Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
22848@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
22849Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
22850the assembler's command line and the @option{--relax} option to the
22851linker's command line.
22852
22853Jump relaxing is performed by the linker because jump offsets are not
22854known before code is located. Therefore, the assembler code generated by the
22855compiler is the same, but the instructions in the executable may
22856differ from instructions in the assembler code.
22857
22858Relaxing must be turned on if linker stubs are needed, see the
22859section on @code{EIND} and linker stubs below.
22860
d77de738 22861@opindex mrmw
ddf6fe37 22862@item -mrmw
d77de738
ML
22863Assume that the device supports the Read-Modify-Write
22864instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
22865
d77de738 22866@opindex mshort-calls
ddf6fe37 22867@item -mshort-calls
d77de738
ML
22868
22869Assume that @code{RJMP} and @code{RCALL} can target the whole
22870program memory.
22871
22872This option is used internally for multilib selection. It is
22873not an optimization option, and you don't need to set it by hand.
22874
d77de738 22875@opindex msp8
ddf6fe37 22876@item -msp8
d77de738
ML
22877Treat the stack pointer register as an 8-bit register,
22878i.e.@: assume the high byte of the stack pointer is zero.
22879In general, you don't need to set this option by hand.
22880
22881This option is used internally by the compiler to select and
22882build multilibs for architectures @code{avr2} and @code{avr25}.
22883These architectures mix devices with and without @code{SPH}.
22884For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
22885the compiler driver adds or removes this option from the compiler
22886proper's command line, because the compiler then knows if the device
22887or architecture has an 8-bit stack pointer and thus no @code{SPH}
22888register or not.
22889
d77de738 22890@opindex mstrict-X
ddf6fe37 22891@item -mstrict-X
d77de738
ML
22892Use address register @code{X} in a way proposed by the hardware. This means
22893that @code{X} is only used in indirect, post-increment or
22894pre-decrement addressing.
22895
22896Without this option, the @code{X} register may be used in the same way
22897as @code{Y} or @code{Z} which then is emulated by additional
22898instructions.
22899For example, loading a value with @code{X+const} addressing with a
22900small non-negative @code{const < 64} to a register @var{Rn} is
22901performed as
22902
22903@example
22904adiw r26, const ; X += const
22905ld @var{Rn}, X ; @var{Rn} = *X
22906sbiw r26, const ; X -= const
22907@end example
22908
d77de738 22909@opindex mtiny-stack
ddf6fe37 22910@item -mtiny-stack
d77de738
ML
22911Only change the lower 8@tie{}bits of the stack pointer.
22912
d77de738 22913@opindex mfract-convert-truncate
ddf6fe37 22914@item -mfract-convert-truncate
d77de738
ML
22915Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
22916
d77de738 22917@opindex nodevicelib
ddf6fe37 22918@item -nodevicelib
d77de738
ML
22919Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
22920
d77de738 22921@opindex nodevicespecs
ddf6fe37 22922@item -nodevicespecs
d77de738
ML
22923Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
22924command line. The user takes responsibility for supplying the sub-processes
22925like compiler proper, assembler and linker with appropriate command line
22926options. This means that the user has to supply her private device specs
22927file by means of @option{-specs=@var{path-to-specs-file}}. There is no
22928more need for option @option{-mmcu=@var{mcu}}.
22929
22930This option can also serve as a replacement for the older way of
22931specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
22932which contains a folder named @code{device-specs} which contains a specs file named
22933@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
22934
d77de738
ML
22935@opindex Waddr-space-convert
22936@opindex Wno-addr-space-convert
ddf6fe37 22937@item -Waddr-space-convert
d77de738
ML
22938Warn about conversions between address spaces in the case where the
22939resulting address space is not contained in the incoming address space.
22940
d77de738
ML
22941@opindex Wmisspelled-isr
22942@opindex Wno-misspelled-isr
ddf6fe37 22943@item -Wmisspelled-isr
d77de738
ML
22944Warn if the ISR is misspelled, i.e.@: without __vector prefix.
22945Enabled by default.
22946@end table
22947
22948@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
22949@cindex @code{EIND}
22950Pointers in the implementation are 16@tie{}bits wide.
22951The address of a function or label is represented as word address so
22952that indirect jumps and calls can target any code address in the
22953range of 64@tie{}Ki words.
22954
22955In order to facilitate indirect jump on devices with more than 128@tie{}Ki
22956bytes of program memory space, there is a special function register called
22957@code{EIND} that serves as most significant part of the target address
22958when @code{EICALL} or @code{EIJMP} instructions are used.
22959
22960Indirect jumps and calls on these devices are handled as follows by
22961the compiler and are subject to some limitations:
22962
22963@itemize @bullet
22964
22965@item
22966The compiler never sets @code{EIND}.
22967
22968@item
22969The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
22970instructions or might read @code{EIND} directly in order to emulate an
22971indirect call/jump by means of a @code{RET} instruction.
22972
22973@item
22974The compiler assumes that @code{EIND} never changes during the startup
22975code or during the application. In particular, @code{EIND} is not
22976saved/restored in function or interrupt service routine
22977prologue/epilogue.
22978
22979@item
22980For indirect calls to functions and computed goto, the linker
22981generates @emph{stubs}. Stubs are jump pads sometimes also called
22982@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
22983The stub contains a direct jump to the desired address.
22984
22985@item
22986Linker relaxation must be turned on so that the linker generates
22987the stubs correctly in all situations. See the compiler option
22988@option{-mrelax} and the linker option @option{--relax}.
22989There are corner cases where the linker is supposed to generate stubs
22990but aborts without relaxation and without a helpful error message.
22991
22992@item
22993The default linker script is arranged for code with @code{EIND = 0}.
22994If code is supposed to work for a setup with @code{EIND != 0}, a custom
22995linker script has to be used in order to place the sections whose
22996name start with @code{.trampolines} into the segment where @code{EIND}
22997points to.
22998
22999@item
23000The startup code from libgcc never sets @code{EIND}.
23001Notice that startup code is a blend of code from libgcc and AVR-LibC.
23002For the impact of AVR-LibC on @code{EIND}, see the
a65da9be 23003@w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
d77de738
ML
23004
23005@item
23006It is legitimate for user-specific startup code to set up @code{EIND}
23007early, for example by means of initialization code located in
23008section @code{.init3}. Such code runs prior to general startup code
23009that initializes RAM and calls constructors, but after the bit
23010of startup code from AVR-LibC that sets @code{EIND} to the segment
23011where the vector table is located.
23012@example
23013#include <avr/io.h>
23014
23015static void
23016__attribute__((section(".init3"),naked,used,no_instrument_function))
23017init3_set_eind (void)
23018@{
23019 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
23020 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
23021@}
23022@end example
23023
23024@noindent
23025The @code{__trampolines_start} symbol is defined in the linker script.
23026
23027@item
23028Stubs are generated automatically by the linker if
23029the following two conditions are met:
23030@itemize @minus
23031
23032@item The address of a label is taken by means of the @code{gs} modifier
23033(short for @emph{generate stubs}) like so:
23034@example
23035LDI r24, lo8(gs(@var{func}))
23036LDI r25, hi8(gs(@var{func}))
23037@end example
23038@item The final location of that label is in a code segment
23039@emph{outside} the segment where the stubs are located.
23040@end itemize
23041
23042@item
23043The compiler emits such @code{gs} modifiers for code labels in the
23044following situations:
23045@itemize @minus
23046@item Taking address of a function or code label.
23047@item Computed goto.
23048@item If prologue-save function is used, see @option{-mcall-prologues}
23049command-line option.
23050@item Switch/case dispatch tables. If you do not want such dispatch
23051tables you can specify the @option{-fno-jump-tables} command-line option.
23052@item C and C++ constructors/destructors called during startup/shutdown.
23053@item If the tools hit a @code{gs()} modifier explained above.
23054@end itemize
23055
23056@item
23057Jumping to non-symbolic addresses like so is @emph{not} supported:
23058
23059@example
23060int main (void)
23061@{
23062 /* Call function at word address 0x2 */
23063 return ((int(*)(void)) 0x2)();
23064@}
23065@end example
23066
23067Instead, a stub has to be set up, i.e.@: the function has to be called
23068through a symbol (@code{func_4} in the example):
23069
23070@example
23071int main (void)
23072@{
23073 extern int func_4 (void);
23074
23075 /* Call function at byte address 0x4 */
23076 return func_4();
23077@}
23078@end example
23079
23080and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
23081Alternatively, @code{func_4} can be defined in the linker script.
23082@end itemize
23083
23084@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
23085@cindex @code{RAMPD}
23086@cindex @code{RAMPX}
23087@cindex @code{RAMPY}
23088@cindex @code{RAMPZ}
23089Some AVR devices support memories larger than the 64@tie{}KiB range
23090that can be accessed with 16-bit pointers. To access memory locations
23091outside this 64@tie{}KiB range, the content of a @code{RAMP}
23092register is used as high part of the address:
23093The @code{X}, @code{Y}, @code{Z} address register is concatenated
23094with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
23095register, respectively, to get a wide address. Similarly,
23096@code{RAMPD} is used together with direct addressing.
23097
23098@itemize
23099@item
23100The startup code initializes the @code{RAMP} special function
23101registers with zero.
23102
23103@item
23104If a @ref{AVR Named Address Spaces,named address space} other than
23105generic or @code{__flash} is used, then @code{RAMPZ} is set
23106as needed before the operation.
23107
23108@item
23109If the device supports RAM larger than 64@tie{}KiB and the compiler
23110needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
23111is reset to zero after the operation.
23112
23113@item
23114If the device comes with a specific @code{RAMP} register, the ISR
23115prologue/epilogue saves/restores that SFR and initializes it with
23116zero in case the ISR code might (implicitly) use it.
23117
23118@item
23119RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
23120If you use inline assembler to read from locations outside the
2312116-bit address range and change one of the @code{RAMP} registers,
23122you must reset it to zero after the access.
23123
23124@end itemize
23125
23126@subsubsection AVR Built-in Macros
23127
23128GCC defines several built-in macros so that the user code can test
23129for the presence or absence of features. Almost any of the following
23130built-in macros are deduced from device capabilities and thus
23131triggered by the @option{-mmcu=} command-line option.
23132
23133For even more AVR-specific built-in macros see
23134@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
23135
23136@table @code
23137
23138@item __AVR_ARCH__
23139Build-in macro that resolves to a decimal number that identifies the
23140architecture and depends on the @option{-mmcu=@var{mcu}} option.
23141Possible values are:
23142
23143@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
23144@code{4}, @code{5}, @code{51}, @code{6}
23145
23146for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
23147@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
23148
23149respectively and
23150
23151@code{100},
23152@code{102}, @code{103}, @code{104},
23153@code{105}, @code{106}, @code{107}
23154
23155for @var{mcu}=@code{avrtiny},
23156@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
23157@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
23158If @var{mcu} specifies a device, this built-in macro is set
23159accordingly. For example, with @option{-mmcu=atmega8} the macro is
23160defined to @code{4}.
23161
23162@item __AVR_@var{Device}__
23163Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
23164the device's name. For example, @option{-mmcu=atmega8} defines the
23165built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
23166@code{__AVR_ATtiny261A__}, etc.
23167
23168The built-in macros' names follow
23169the scheme @code{__AVR_@var{Device}__} where @var{Device} is
23170the device name as from the AVR user manual. The difference between
23171@var{Device} in the built-in macro and @var{device} in
23172@option{-mmcu=@var{device}} is that the latter is always lowercase.
23173
23174If @var{device} is not a device but only a core architecture like
23175@samp{avr51}, this macro is not defined.
23176
23177@item __AVR_DEVICE_NAME__
23178Setting @option{-mmcu=@var{device}} defines this built-in macro to
23179the device's name. For example, with @option{-mmcu=atmega8} the macro
23180is defined to @code{atmega8}.
23181
23182If @var{device} is not a device but only a core architecture like
23183@samp{avr51}, this macro is not defined.
23184
23185@item __AVR_XMEGA__
23186The device / architecture belongs to the XMEGA family of devices.
23187
23188@item __AVR_HAVE_ELPM__
23189The device has the @code{ELPM} instruction.
23190
23191@item __AVR_HAVE_ELPMX__
23192The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23193R@var{n},Z+} instructions.
23194
23195@item __AVR_HAVE_MOVW__
23196The device has the @code{MOVW} instruction to perform 16-bit
23197register-register moves.
23198
23199@item __AVR_HAVE_LPMX__
23200The device has the @code{LPM R@var{n},Z} and
23201@code{LPM R@var{n},Z+} instructions.
23202
23203@item __AVR_HAVE_MUL__
23204The device has a hardware multiplier.
23205
23206@item __AVR_HAVE_JMP_CALL__
23207The device has the @code{JMP} and @code{CALL} instructions.
23208This is the case for devices with more than 8@tie{}KiB of program
23209memory.
23210
23211@item __AVR_HAVE_EIJMP_EICALL__
23212@itemx __AVR_3_BYTE_PC__
23213The device has the @code{EIJMP} and @code{EICALL} instructions.
23214This is the case for devices with more than 128@tie{}KiB of program memory.
23215This also means that the program counter
23216(PC) is 3@tie{}bytes wide.
23217
23218@item __AVR_2_BYTE_PC__
23219The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23220with up to 128@tie{}KiB of program memory.
23221
23222@item __AVR_HAVE_8BIT_SP__
23223@itemx __AVR_HAVE_16BIT_SP__
23224The stack pointer (SP) register is treated as 8-bit respectively
2322516-bit register by the compiler.
23226The definition of these macros is affected by @option{-mtiny-stack}.
23227
23228@item __AVR_HAVE_SPH__
23229@itemx __AVR_SP8__
23230The device has the SPH (high part of stack pointer) special function
23231register or has an 8-bit stack pointer, respectively.
23232The definition of these macros is affected by @option{-mmcu=} and
23233in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23234by @option{-msp8}.
23235
23236@item __AVR_HAVE_RAMPD__
23237@itemx __AVR_HAVE_RAMPX__
23238@itemx __AVR_HAVE_RAMPY__
23239@itemx __AVR_HAVE_RAMPZ__
23240The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23241@code{RAMPZ} special function register, respectively.
23242
23243@item __NO_INTERRUPTS__
23244This macro reflects the @option{-mno-interrupts} command-line option.
23245
23246@item __AVR_ERRATA_SKIP__
23247@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23248Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23249instructions because of a hardware erratum. Skip instructions are
23250@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23251The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23252set.
23253
23254@item __AVR_ISA_RMW__
23255The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23256
23257@item __AVR_SFR_OFFSET__=@var{offset}
23258Instructions that can address I/O special function registers directly
23259like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23260address as if addressed by an instruction to access RAM like @code{LD}
23261or @code{STS}. This offset depends on the device architecture and has
23262to be subtracted from the RAM address in order to get the
23263respective I/O@tie{}address.
23264
23265@item __AVR_SHORT_CALLS__
23266The @option{-mshort-calls} command line option is set.
23267
23268@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23269Some devices support reading from flash memory by means of @code{LD*}
23270instructions. The flash memory is seen in the data address space
23271at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23272is not defined, this feature is not available. If defined,
23273the address space is linear and there is no need to put
23274@code{.rodata} into RAM. This is handled by the default linker
23275description file, and is currently available for
23276@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23277there is no need to use address spaces like @code{__flash} or
23278features like attribute @code{progmem} and @code{pgm_read_*}.
23279
23280@item __WITH_AVRLIBC__
23281The compiler is configured to be used together with AVR-Libc.
23282See the @option{--with-avrlibc} configure option.
23283
23284@item __HAVE_DOUBLE_MULTILIB__
23285Defined if @option{-mdouble=} acts as a multilib option.
23286
23287@item __HAVE_DOUBLE32__
23288@itemx __HAVE_DOUBLE64__
23289Defined if the compiler supports 32-bit double resp. 64-bit double.
23290The actual layout is specified by option @option{-mdouble=}.
23291
23292@item __DEFAULT_DOUBLE__
23293The size in bits of @code{double} if @option{-mdouble=} is not set.
23294To test the layout of @code{double} in a program, use the built-in
23295macro @code{__SIZEOF_DOUBLE__}.
23296
23297@item __HAVE_LONG_DOUBLE32__
23298@itemx __HAVE_LONG_DOUBLE64__
23299@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23300@itemx __DEFAULT_LONG_DOUBLE__
23301Same as above, but for @code{long double} instead of @code{double}.
23302
23303@item __WITH_DOUBLE_COMPARISON__
23304Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23305@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23306and is defined to @code{2} or @code{3}.
23307
23308@item __WITH_LIBF7_LIBGCC__
23309@itemx __WITH_LIBF7_MATH__
23310@itemx __WITH_LIBF7_MATH_SYMBOLS__
23311Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23312@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23313
23314@end table
23315
23316@node Blackfin Options
23317@subsection Blackfin Options
23318@cindex Blackfin Options
23319
23320@table @gcctabopt
d77de738 23321@opindex mcpu=
ddf6fe37 23322@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
d77de738
ML
23323Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23324can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23325@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23326@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23327@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23328@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23329@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23330@samp{bf561}, @samp{bf592}.
23331
23332The optional @var{sirevision} specifies the silicon revision of the target
23333Blackfin processor. Any workarounds available for the targeted silicon revision
23334are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23335If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23336are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23337hexadecimal digits representing the major and minor numbers in the silicon
23338revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23339is not defined. If @var{sirevision} is @samp{any}, the
23340@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23341If this optional @var{sirevision} is not used, GCC assumes the latest known
23342silicon revision of the targeted Blackfin processor.
23343
23344GCC defines a preprocessor macro for the specified @var{cpu}.
23345For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23346provided by libgloss to be linked in if @option{-msim} is not given.
23347
23348Without this option, @samp{bf532} is used as the processor by default.
23349
23350Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23351only the preprocessor macro is defined.
23352
d77de738 23353@opindex msim
ddf6fe37 23354@item -msim
d77de738
ML
23355Specifies that the program will be run on the simulator. This causes
23356the simulator BSP provided by libgloss to be linked in. This option
23357has effect only for @samp{bfin-elf} toolchain.
23358Certain other options, such as @option{-mid-shared-library} and
23359@option{-mfdpic}, imply @option{-msim}.
23360
d77de738 23361@opindex momit-leaf-frame-pointer
ddf6fe37 23362@item -momit-leaf-frame-pointer
d77de738
ML
23363Don't keep the frame pointer in a register for leaf functions. This
23364avoids the instructions to save, set up and restore frame pointers and
23365makes an extra register available in leaf functions.
23366
d77de738 23367@opindex mspecld-anomaly
ddf6fe37 23368@item -mspecld-anomaly
d77de738
ML
23369When enabled, the compiler ensures that the generated code does not
23370contain speculative loads after jump instructions. If this option is used,
23371@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23372
d77de738
ML
23373@opindex mno-specld-anomaly
23374@opindex mspecld-anomaly
ddf6fe37 23375@item -mno-specld-anomaly
d77de738
ML
23376Don't generate extra code to prevent speculative loads from occurring.
23377
d77de738 23378@opindex mcsync-anomaly
ddf6fe37 23379@item -mcsync-anomaly
d77de738
ML
23380When enabled, the compiler ensures that the generated code does not
23381contain CSYNC or SSYNC instructions too soon after conditional branches.
23382If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23383
d77de738
ML
23384@opindex mno-csync-anomaly
23385@opindex mcsync-anomaly
ddf6fe37 23386@item -mno-csync-anomaly
d77de738
ML
23387Don't generate extra code to prevent CSYNC or SSYNC instructions from
23388occurring too soon after a conditional branch.
23389
d77de738 23390@opindex mlow64k
ddf6fe37 23391@item -mlow64k
d77de738
ML
23392When enabled, the compiler is free to take advantage of the knowledge that
23393the entire program fits into the low 64k of memory.
23394
d77de738 23395@opindex mno-low64k
ddf6fe37 23396@item -mno-low64k
d77de738
ML
23397Assume that the program is arbitrarily large. This is the default.
23398
d77de738 23399@opindex mstack-check-l1
ddf6fe37 23400@item -mstack-check-l1
d77de738
ML
23401Do stack checking using information placed into L1 scratchpad memory by the
23402uClinux kernel.
23403
d77de738 23404@opindex mid-shared-library
ddf6fe37 23405@item -mid-shared-library
d77de738
ML
23406Generate code that supports shared libraries via the library ID method.
23407This allows for execute in place and shared libraries in an environment
23408without virtual memory management. This option implies @option{-fPIC}.
23409With a @samp{bfin-elf} target, this option implies @option{-msim}.
23410
d77de738
ML
23411@opindex mno-id-shared-library
23412@opindex mid-shared-library
ddf6fe37 23413@item -mno-id-shared-library
d77de738
ML
23414Generate code that doesn't assume ID-based shared libraries are being used.
23415This is the default.
23416
d77de738 23417@opindex mleaf-id-shared-library
ddf6fe37 23418@item -mleaf-id-shared-library
d77de738
ML
23419Generate code that supports shared libraries via the library ID method,
23420but assumes that this library or executable won't link against any other
23421ID shared libraries. That allows the compiler to use faster code for jumps
23422and calls.
23423
d77de738
ML
23424@opindex mno-leaf-id-shared-library
23425@opindex mleaf-id-shared-library
ddf6fe37 23426@item -mno-leaf-id-shared-library
d77de738
ML
23427Do not assume that the code being compiled won't link against any ID shared
23428libraries. Slower code is generated for jump and call insns.
23429
d77de738 23430@opindex mshared-library-id
ddf6fe37 23431@item -mshared-library-id=n
d77de738
ML
23432Specifies the identification number of the ID-based shared library being
23433compiled. Specifying a value of 0 generates more compact code; specifying
23434other values forces the allocation of that number to the current
23435library but is no more space- or time-efficient than omitting this option.
23436
d77de738 23437@opindex msep-data
ddf6fe37 23438@item -msep-data
d77de738
ML
23439Generate code that allows the data segment to be located in a different
23440area of memory from the text segment. This allows for execute in place in
23441an environment without virtual memory management by eliminating relocations
23442against the text section.
23443
d77de738
ML
23444@opindex mno-sep-data
23445@opindex msep-data
ddf6fe37 23446@item -mno-sep-data
d77de738
ML
23447Generate code that assumes that the data segment follows the text segment.
23448This is the default.
23449
d77de738
ML
23450@opindex mlong-calls
23451@opindex mno-long-calls
ddf6fe37
AA
23452@item -mlong-calls
23453@itemx -mno-long-calls
d77de738
ML
23454Tells the compiler to perform function calls by first loading the
23455address of the function into a register and then performing a subroutine
23456call on this register. This switch is needed if the target function
23457lies outside of the 24-bit addressing range of the offset-based
23458version of subroutine call instruction.
23459
23460This feature is not enabled by default. Specifying
23461@option{-mno-long-calls} restores the default behavior. Note these
23462switches have no effect on how the compiler generates code to handle
23463function calls via function pointers.
23464
d77de738 23465@opindex mfast-fp
ddf6fe37 23466@item -mfast-fp
d77de738
ML
23467Link with the fast floating-point library. This library relaxes some of
23468the IEEE floating-point standard's rules for checking inputs against
23469Not-a-Number (NAN), in the interest of performance.
23470
d77de738 23471@opindex minline-plt
ddf6fe37 23472@item -minline-plt
d77de738
ML
23473Enable inlining of PLT entries in function calls to functions that are
23474not known to bind locally. It has no effect without @option{-mfdpic}.
23475
d77de738 23476@opindex mmulticore
ddf6fe37 23477@item -mmulticore
d77de738
ML
23478Build a standalone application for multicore Blackfin processors.
23479This option causes proper start files and link scripts supporting
23480multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23481It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23482
23483This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23484selects the one-application-per-core programming model. Without
23485@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23486programming model is used. In this model, the main function of Core B
23487should be named as @code{coreb_main}.
23488
23489If this option is not used, the single-core application programming
23490model is used.
23491
d77de738 23492@opindex mcorea
ddf6fe37 23493@item -mcorea
d77de738
ML
23494Build a standalone application for Core A of BF561 when using
23495the one-application-per-core programming model. Proper start files
23496and link scripts are used to support Core A, and the macro
23497@code{__BFIN_COREA} is defined.
23498This option can only be used in conjunction with @option{-mmulticore}.
23499
d77de738 23500@opindex mcoreb
ddf6fe37 23501@item -mcoreb
d77de738
ML
23502Build a standalone application for Core B of BF561 when using
23503the one-application-per-core programming model. Proper start files
23504and link scripts are used to support Core B, and the macro
23505@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23506should be used instead of @code{main}.
23507This option can only be used in conjunction with @option{-mmulticore}.
23508
d77de738 23509@opindex msdram
ddf6fe37 23510@item -msdram
d77de738
ML
23511Build a standalone application for SDRAM. Proper start files and
23512link scripts are used to put the application into SDRAM, and the macro
23513@code{__BFIN_SDRAM} is defined.
23514The loader should initialize SDRAM before loading the application.
23515
d77de738 23516@opindex micplb
ddf6fe37 23517@item -micplb
d77de738
ML
23518Assume that ICPLBs are enabled at run time. This has an effect on certain
23519anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23520are enabled; for standalone applications the default is off.
23521@end table
23522
23523@node C6X Options
23524@subsection C6X Options
23525@cindex C6X Options
23526
23527@table @gcctabopt
d77de738 23528@opindex march
ddf6fe37 23529@item -march=@var{name}
d77de738
ML
23530This specifies the name of the target architecture. GCC uses this
23531name to determine what kind of instructions it can emit when generating
23532assembly code. Permissible names are: @samp{c62x},
23533@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23534
d77de738 23535@opindex mbig-endian
ddf6fe37 23536@item -mbig-endian
d77de738
ML
23537Generate code for a big-endian target.
23538
d77de738 23539@opindex mlittle-endian
ddf6fe37 23540@item -mlittle-endian
d77de738
ML
23541Generate code for a little-endian target. This is the default.
23542
d77de738 23543@opindex msim
ddf6fe37 23544@item -msim
d77de738
ML
23545Choose startup files and linker script suitable for the simulator.
23546
d77de738 23547@opindex msdata=default
ddf6fe37 23548@item -msdata=default
d77de738
ML
23549Put small global and static data in the @code{.neardata} section,
23550which is pointed to by register @code{B14}. Put small uninitialized
23551global and static data in the @code{.bss} section, which is adjacent
23552to the @code{.neardata} section. Put small read-only data into the
23553@code{.rodata} section. The corresponding sections used for large
23554pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23555
d77de738 23556@opindex msdata=all
ddf6fe37 23557@item -msdata=all
d77de738
ML
23558Put all data, not just small objects, into the sections reserved for
23559small data, and use addressing relative to the @code{B14} register to
23560access them.
23561
d77de738 23562@opindex msdata=none
ddf6fe37 23563@item -msdata=none
d77de738
ML
23564Make no use of the sections reserved for small data, and use absolute
23565addresses to access all data. Put all initialized global and static
23566data in the @code{.fardata} section, and all uninitialized data in the
23567@code{.far} section. Put all constant data into the @code{.const}
23568section.
23569@end table
23570
23571@node CRIS Options
23572@subsection CRIS Options
23573@cindex CRIS Options
23574
23575These options are defined specifically for the CRIS ports.
23576
23577@table @gcctabopt
d77de738
ML
23578@opindex march
23579@opindex mcpu
ddf6fe37
AA
23580@item -march=@var{architecture-type}
23581@itemx -mcpu=@var{architecture-type}
d77de738
ML
23582Generate code for the specified architecture. The choices for
23583@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23584respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23585Default is @samp{v0}.
23586
d77de738 23587@opindex mtune
ddf6fe37 23588@item -mtune=@var{architecture-type}
d77de738
ML
23589Tune to @var{architecture-type} everything applicable about the generated
23590code, except for the ABI and the set of available instructions. The
23591choices for @var{architecture-type} are the same as for
23592@option{-march=@var{architecture-type}}.
23593
d77de738 23594@opindex mmax-stack-frame
ddf6fe37 23595@item -mmax-stack-frame=@var{n}
d77de738
ML
23596Warn when the stack frame of a function exceeds @var{n} bytes.
23597
d77de738
ML
23598@opindex metrax4
23599@opindex metrax100
ddf6fe37
AA
23600@item -metrax4
23601@itemx -metrax100
d77de738
ML
23602The options @option{-metrax4} and @option{-metrax100} are synonyms for
23603@option{-march=v3} and @option{-march=v8} respectively.
23604
d77de738
ML
23605@opindex mmul-bug-workaround
23606@opindex mno-mul-bug-workaround
ddf6fe37
AA
23607@item -mmul-bug-workaround
23608@itemx -mno-mul-bug-workaround
d77de738
ML
23609Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23610models where it applies. This option is disabled by default.
23611
d77de738 23612@opindex mpdebug
ddf6fe37 23613@item -mpdebug
d77de738
ML
23614Enable CRIS-specific verbose debug-related information in the assembly
23615code. This option also has the effect of turning off the @samp{#NO_APP}
23616formatted-code indicator to the assembler at the beginning of the
23617assembly file.
23618
d77de738 23619@opindex mcc-init
ddf6fe37 23620@item -mcc-init
d77de738
ML
23621Do not use condition-code results from previous instruction; always emit
23622compare and test instructions before use of condition codes.
23623
d77de738
ML
23624@opindex mno-side-effects
23625@opindex mside-effects
ddf6fe37 23626@item -mno-side-effects
d77de738
ML
23627Do not emit instructions with side effects in addressing modes other than
23628post-increment.
23629
d77de738
ML
23630@opindex mstack-align
23631@opindex mno-stack-align
23632@opindex mdata-align
23633@opindex mno-data-align
23634@opindex mconst-align
23635@opindex mno-const-align
ddf6fe37
AA
23636@item -mstack-align
23637@itemx -mno-stack-align
23638@itemx -mdata-align
23639@itemx -mno-data-align
23640@itemx -mconst-align
23641@itemx -mno-const-align
d77de738
ML
23642These options (@samp{no-} options) arrange (eliminate arrangements) for the
23643stack frame, individual data and constants to be aligned for the maximum
23644single data access size for the chosen CPU model. The default is to
23645arrange for 32-bit alignment. ABI details such as structure layout are
23646not affected by these options.
23647
d77de738
ML
23648@opindex m32-bit
23649@opindex m16-bit
23650@opindex m8-bit
ddf6fe37
AA
23651@item -m32-bit
23652@itemx -m16-bit
23653@itemx -m8-bit
d77de738
ML
23654Similar to the stack- data- and const-align options above, these options
23655arrange for stack frame, writable data and constants to all be 32-bit,
2365616-bit or 8-bit aligned. The default is 32-bit alignment.
23657
d77de738
ML
23658@opindex mno-prologue-epilogue
23659@opindex mprologue-epilogue
ddf6fe37
AA
23660@item -mno-prologue-epilogue
23661@itemx -mprologue-epilogue
d77de738
ML
23662With @option{-mno-prologue-epilogue}, the normal function prologue and
23663epilogue which set up the stack frame are omitted and no return
23664instructions or return sequences are generated in the code. Use this
23665option only together with visual inspection of the compiled code: no
23666warnings or errors are generated when call-saved registers must be saved,
23667or storage for local variables needs to be allocated.
23668
d77de738 23669@opindex melf
ddf6fe37 23670@item -melf
d77de738
ML
23671Legacy no-op option.
23672
d77de738 23673@opindex sim
ddf6fe37 23674@item -sim
d77de738
ML
23675This option arranges
23676to link with input-output functions from a simulator library. Code,
23677initialized data and zero-initialized data are allocated consecutively.
23678
d77de738 23679@opindex sim2
ddf6fe37 23680@item -sim2
d77de738
ML
23681Like @option{-sim}, but pass linker options to locate initialized data at
236820x40000000 and zero-initialized data at 0x80000000.
23683@end table
23684
23685@node C-SKY Options
23686@subsection C-SKY Options
23687@cindex C-SKY Options
23688
23689GCC supports these options when compiling for C-SKY V2 processors.
23690
23691@table @gcctabopt
23692
d77de738 23693@opindex march=
ddf6fe37 23694@item -march=@var{arch}
d77de738
ML
23695Specify the C-SKY target architecture. Valid values for @var{arch} are:
23696@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
23697The default is @samp{ck810}.
23698
d77de738 23699@opindex mcpu=
ddf6fe37 23700@item -mcpu=@var{cpu}
d77de738
ML
23701Specify the C-SKY target processor. Valid values for @var{cpu} are:
23702@samp{ck801}, @samp{ck801t},
23703@samp{ck802}, @samp{ck802t}, @samp{ck802j},
23704@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
23705@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
23706@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
23707@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
23708@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
23709@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
23710@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
23711@samp{ck803eftr1}, @samp{ck803efhtr1},
23712@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
23713@samp{ck803sef}, @samp{ck803seft},
23714@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
23715@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
23716@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
23717@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
23718
d77de738 23719@opindex mbig-endian
d77de738 23720@opindex EB
d77de738 23721@opindex mlittle-endian
d77de738 23722@opindex EL
ddf6fe37
AA
23723@item -mbig-endian
23724@itemx -EB
23725@itemx -mlittle-endian
23726@itemx -EL
d77de738
ML
23727
23728Select big- or little-endian code. The default is little-endian.
23729
d77de738 23730@opindex mfloat-abi
ddf6fe37 23731@item -mfloat-abi=@var{name}
d77de738
ML
23732Specifies which floating-point ABI to use. Permissible values
23733are: @samp{soft}, @samp{softfp} and @samp{hard}.
23734
23735Specifying @samp{soft} causes GCC to generate output containing
23736library calls for floating-point operations.
23737@samp{softfp} allows the generation of code using hardware floating-point
23738instructions, but still uses the soft-float calling conventions.
23739@samp{hard} allows generation of floating-point instructions
23740and uses FPU-specific calling conventions.
23741
23742The default depends on the specific target configuration. Note that
23743the hard-float and soft-float ABIs are not link-compatible; you must
23744compile your entire program with the same ABI, and link with a
23745compatible set of libraries.
23746
d77de738 23747@opindex mhard-float
d77de738 23748@opindex msoft-float
ddf6fe37
AA
23749@item -mhard-float
23750@itemx -msoft-float
d77de738
ML
23751
23752Select hardware or software floating-point implementations.
23753The default is soft float.
23754
ddf6fe37 23755@opindex mdouble-float
d77de738
ML
23756@item -mdouble-float
23757@itemx -mno-double-float
d77de738
ML
23758When @option{-mhard-float} is in effect, enable generation of
23759double-precision float instructions. This is the default except
23760when compiling for CK803.
23761
ddf6fe37 23762@opindex mfdivdu
d77de738
ML
23763@item -mfdivdu
23764@itemx -mno-fdivdu
d77de738
ML
23765When @option{-mhard-float} is in effect, enable generation of
23766@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
23767This is the default except when compiling for CK803.
23768
d77de738 23769@opindex mfpu=
ddf6fe37 23770@item -mfpu=@var{fpu}
d77de738
ML
23771Select the floating-point processor. This option can only be used with
23772@option{-mhard-float}.
23773Values for @var{fpu} are
23774@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
23775@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
23776@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
23777
ddf6fe37 23778@opindex melrw
d77de738
ML
23779@item -melrw
23780@itemx -mno-elrw
d77de738
ML
23781Enable the extended @code{lrw} instruction. This option defaults to on
23782for CK801 and off otherwise.
23783
ddf6fe37 23784@opindex mistack
d77de738
ML
23785@item -mistack
23786@itemx -mno-istack
d77de738
ML
23787Enable interrupt stack instructions; the default is off.
23788
23789The @option{-mistack} option is required to handle the
23790@code{interrupt} and @code{isr} function attributes
23791(@pxref{C-SKY Function Attributes}).
23792
d77de738 23793@opindex mmp
ddf6fe37 23794@item -mmp
d77de738
ML
23795Enable multiprocessor instructions; the default is off.
23796
d77de738 23797@opindex mcp
ddf6fe37 23798@item -mcp
d77de738
ML
23799Enable coprocessor instructions; the default is off.
23800
d77de738 23801@opindex mcache
ddf6fe37 23802@item -mcache
d77de738
ML
23803Enable coprocessor instructions; the default is off.
23804
d77de738 23805@opindex msecurity
ddf6fe37 23806@item -msecurity
d77de738
ML
23807Enable C-SKY security instructions; the default is off.
23808
d77de738 23809@opindex mtrust
ddf6fe37 23810@item -mtrust
d77de738
ML
23811Enable C-SKY trust instructions; the default is off.
23812
d77de738 23813@opindex mdsp
d77de738 23814@opindex medsp
d77de738 23815@opindex mvdsp
ddf6fe37
AA
23816@item -mdsp
23817@itemx -medsp
23818@itemx -mvdsp
d77de738
ML
23819Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
23820All of these options default to off.
23821
ddf6fe37 23822@opindex mdiv
d77de738
ML
23823@item -mdiv
23824@itemx -mno-div
d77de738
ML
23825Generate divide instructions. Default is off.
23826
ddf6fe37 23827@opindex msmart
d77de738
ML
23828@item -msmart
23829@itemx -mno-smart
d77de738
ML
23830Generate code for Smart Mode, using only registers numbered 0-7 to allow
23831use of 16-bit instructions. This option is ignored for CK801 where this
23832is the required behavior, and it defaults to on for CK802.
23833For other targets, the default is off.
23834
ddf6fe37 23835@opindex mhigh-registers
d77de738
ML
23836@item -mhigh-registers
23837@itemx -mno-high-registers
d77de738
ML
23838Generate code using the high registers numbered 16-31. This option
23839is not supported on CK801, CK802, or CK803, and is enabled by default
23840for other processors.
23841
ddf6fe37 23842@opindex manchor
d77de738
ML
23843@item -manchor
23844@itemx -mno-anchor
d77de738
ML
23845Generate code using global anchor symbol addresses.
23846
ddf6fe37 23847@opindex mpushpop
d77de738
ML
23848@item -mpushpop
23849@itemx -mno-pushpop
d77de738
ML
23850Generate code using @code{push} and @code{pop} instructions. This option
23851defaults to on.
23852
ddf6fe37 23853@opindex mmultiple-stld
d77de738
ML
23854@item -mmultiple-stld
23855@itemx -mstm
23856@itemx -mno-multiple-stld
23857@itemx -mno-stm
d77de738
ML
23858Generate code using @code{stm} and @code{ldm} instructions. This option
23859isn't supported on CK801 but is enabled by default on other processors.
23860
ddf6fe37 23861@opindex mconstpool
d77de738
ML
23862@item -mconstpool
23863@itemx -mno-constpool
d77de738
ML
23864Create constant pools in the compiler instead of deferring it to the
23865assembler. This option is the default and required for correct code
23866generation on CK801 and CK802, and is optional on other processors.
23867
ddf6fe37 23868@opindex mstack-size
d77de738
ML
23869@item -mstack-size
23870@item -mno-stack-size
d77de738
ML
23871Emit @code{.stack_size} directives for each function in the assembly
23872output. This option defaults to off.
23873
ddf6fe37 23874@opindex mccrt
d77de738
ML
23875@item -mccrt
23876@itemx -mno-ccrt
d77de738
ML
23877Generate code for the C-SKY compiler runtime instead of libgcc. This
23878option defaults to off.
23879
d77de738 23880@opindex mbranch-cost=
ddf6fe37 23881@item -mbranch-cost=@var{n}
d77de738
ML
23882Set the branch costs to roughly @code{n} instructions. The default is 1.
23883
ddf6fe37 23884@opindex msched-prolog
d77de738
ML
23885@item -msched-prolog
23886@itemx -mno-sched-prolog
d77de738
ML
23887Permit scheduling of function prologue and epilogue sequences. Using
23888this option can result in code that is not compliant with the C-SKY V2 ABI
23889prologue requirements and that cannot be debugged or backtraced.
23890It is disabled by default.
23891
d77de738 23892@opindex msim
ddf6fe37 23893@item -msim
d77de738
ML
23894Links the library libsemi.a which is in compatible with simulator. Applicable
23895to ELF compiler only.
23896
23897@end table
23898
23899@node Darwin Options
23900@subsection Darwin Options
23901@cindex Darwin options
23902
23903These options are defined for all architectures running the Darwin operating
23904system.
23905
23906FSF GCC on Darwin does not create ``fat'' object files; it creates
23907an object file for the single architecture that GCC was built to
23908target. Apple's GCC on Darwin does create ``fat'' files if multiple
23909@option{-arch} options are used; it does so by running the compiler or
23910linker multiple times and joining the results together with
23911@file{lipo}.
23912
23913The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
23914@samp{i686}) is determined by the flags that specify the ISA
23915that GCC is targeting, like @option{-mcpu} or @option{-march}. The
23916@option{-force_cpusubtype_ALL} option can be used to override this.
23917
23918The Darwin tools vary in their behavior when presented with an ISA
23919mismatch. The assembler, @file{as}, only permits instructions to
23920be used that are valid for the subtype of the file it is generating,
23921so you cannot put 64-bit instructions in a @samp{ppc750} object file.
23922The linker for shared libraries, @file{/usr/bin/libtool}, fails
23923and prints an error if asked to create a shared library with a less
23924restrictive subtype than its input files (for instance, trying to put
23925a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
23926for executables, @command{ld}, quietly gives the executable the most
23927restrictive subtype of any of its input files.
23928
23929@table @gcctabopt
d77de738 23930@opindex F
ddf6fe37 23931@item -F@var{dir}
d77de738
ML
23932Add the framework directory @var{dir} to the head of the list of
23933directories to be searched for header files. These directories are
23934interleaved with those specified by @option{-I} options and are
23935scanned in a left-to-right order.
23936
23937A framework directory is a directory with frameworks in it. A
23938framework is a directory with a @file{Headers} and/or
23939@file{PrivateHeaders} directory contained directly in it that ends
23940in @file{.framework}. The name of a framework is the name of this
23941directory excluding the @file{.framework}. Headers associated with
23942the framework are found in one of those two directories, with
23943@file{Headers} being searched first. A subframework is a framework
23944directory that is in a framework's @file{Frameworks} directory.
23945Includes of subframework headers can only appear in a header of a
23946framework that contains the subframework, or in a sibling subframework
23947header. Two subframeworks are siblings if they occur in the same
23948framework. A subframework should not have the same name as a
23949framework; a warning is issued if this is violated. Currently a
23950subframework cannot have subframeworks; in the future, the mechanism
23951may be extended to support this. The standard frameworks can be found
23952in @file{/System/Library/Frameworks} and
23953@file{/Library/Frameworks}. An example include looks like
23954@code{#include <Framework/header.h>}, where @file{Framework} denotes
23955the name of the framework and @file{header.h} is found in the
23956@file{PrivateHeaders} or @file{Headers} directory.
23957
d77de738 23958@opindex iframework
ddf6fe37 23959@item -iframework@var{dir}
d77de738
ML
23960Like @option{-F} except the directory is a treated as a system
23961directory. The main difference between this @option{-iframework} and
23962@option{-F} is that with @option{-iframework} the compiler does not
23963warn about constructs contained within header files found via
23964@var{dir}. This option is valid only for the C family of languages.
23965
d77de738 23966@opindex gused
ddf6fe37 23967@item -gused
d77de738
ML
23968Emit debugging information for symbols that are used. For stabs
23969debugging format, this enables @option{-feliminate-unused-debug-symbols}.
23970This is by default ON@.
23971
d77de738 23972@opindex gfull
ddf6fe37 23973@item -gfull
d77de738
ML
23974Emit debugging information for all symbols and types.
23975
23976@item -mmacosx-version-min=@var{version}
23977The earliest version of MacOS X that this executable will run on
23978is @var{version}. Typical values of @var{version} include @code{10.1},
23979@code{10.2}, and @code{10.3.9}.
23980
23981If the compiler was built to use the system's headers by default,
23982then the default for this option is the system version on which the
23983compiler is running, otherwise the default is to make choices that
23984are compatible with as many systems and code bases as possible.
23985
d77de738 23986@opindex mkernel
ddf6fe37 23987@item -mkernel
d77de738
ML
23988Enable kernel development mode. The @option{-mkernel} option sets
23989@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
23990@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
23991@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
23992applicable. This mode also sets @option{-mno-altivec},
23993@option{-msoft-float}, @option{-fno-builtin} and
23994@option{-mlong-branch} for PowerPC targets.
23995
d77de738 23996@opindex mone-byte-bool
ddf6fe37 23997@item -mone-byte-bool
d77de738
ML
23998Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
23999By default @code{sizeof(bool)} is @code{4} when compiling for
24000Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
24001option has no effect on x86.
24002
24003@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
24004to generate code that is not binary compatible with code generated
24005without that switch. Using this switch may require recompiling all
24006other modules in a program, including system libraries. Use this
24007switch to conform to a non-default data model.
24008
d77de738
ML
24009@opindex mfix-and-continue
24010@opindex ffix-and-continue
24011@opindex findirect-data
ddf6fe37
AA
24012@item -mfix-and-continue
24013@itemx -ffix-and-continue
24014@itemx -findirect-data
d77de738
ML
24015Generate code suitable for fast turnaround development, such as to
24016allow GDB to dynamically load @file{.o} files into already-running
24017programs. @option{-findirect-data} and @option{-ffix-and-continue}
24018are provided for backwards compatibility.
24019
d77de738 24020@opindex all_load
ddf6fe37 24021@item -all_load
d77de738
ML
24022Loads all members of static archive libraries.
24023See man ld(1) for more information.
24024
d77de738 24025@opindex arch_errors_fatal
ddf6fe37 24026@item -arch_errors_fatal
d77de738
ML
24027Cause the errors having to do with files that have the wrong architecture
24028to be fatal.
24029
d77de738 24030@opindex bind_at_load
ddf6fe37 24031@item -bind_at_load
d77de738
ML
24032Causes the output file to be marked such that the dynamic linker will
24033bind all undefined references when the file is loaded or launched.
24034
d77de738 24035@opindex bundle
ddf6fe37 24036@item -bundle
d77de738
ML
24037Produce a Mach-o bundle format file.
24038See man ld(1) for more information.
24039
d77de738 24040@opindex bundle_loader
ddf6fe37 24041@item -bundle_loader @var{executable}
d77de738
ML
24042This option specifies the @var{executable} that will load the build
24043output file being linked. See man ld(1) for more information.
24044
d77de738 24045@opindex dynamiclib
ddf6fe37 24046@item -dynamiclib
d77de738
ML
24047When passed this option, GCC produces a dynamic library instead of
24048an executable when linking, using the Darwin @file{libtool} command.
24049
d77de738 24050@opindex force_cpusubtype_ALL
ddf6fe37 24051@item -force_cpusubtype_ALL
d77de738
ML
24052This causes GCC's output file to have the @samp{ALL} subtype, instead of
24053one controlled by the @option{-mcpu} or @option{-march} option.
24054
24055@item -allowable_client @var{client_name}
24056@itemx -client_name
24057@itemx -compatibility_version
24058@itemx -current_version
24059@itemx -dead_strip
24060@itemx -dependency-file
24061@itemx -dylib_file
24062@itemx -dylinker_install_name
24063@itemx -dynamic
24064@itemx -exported_symbols_list
24065@itemx -filelist
24066@need 800
24067@itemx -flat_namespace
24068@itemx -force_flat_namespace
24069@itemx -headerpad_max_install_names
24070@itemx -image_base
24071@itemx -init
24072@itemx -install_name
24073@itemx -keep_private_externs
24074@itemx -multi_module
24075@itemx -multiply_defined
24076@itemx -multiply_defined_unused
24077@need 800
24078@itemx -noall_load
24079@itemx -no_dead_strip_inits_and_terms
24080@itemx -nofixprebinding
24081@itemx -nomultidefs
24082@itemx -noprebind
24083@itemx -noseglinkedit
24084@itemx -pagezero_size
24085@itemx -prebind
24086@itemx -prebind_all_twolevel_modules
24087@itemx -private_bundle
24088@need 800
24089@itemx -read_only_relocs
24090@itemx -sectalign
24091@itemx -sectobjectsymbols
24092@itemx -whyload
24093@itemx -seg1addr
24094@itemx -sectcreate
24095@itemx -sectobjectsymbols
24096@itemx -sectorder
24097@itemx -segaddr
24098@itemx -segs_read_only_addr
24099@need 800
24100@itemx -segs_read_write_addr
24101@itemx -seg_addr_table
24102@itemx -seg_addr_table_filename
24103@itemx -seglinkedit
24104@itemx -segprot
24105@itemx -segs_read_only_addr
24106@itemx -segs_read_write_addr
24107@itemx -single_module
24108@itemx -static
24109@itemx -sub_library
24110@need 800
d77de738
ML
24111@opindex allowable_client
24112@opindex client_name
24113@opindex compatibility_version
24114@opindex current_version
24115@opindex dead_strip
24116@opindex dependency-file
24117@opindex dylib_file
24118@opindex dylinker_install_name
24119@opindex dynamic
24120@opindex exported_symbols_list
24121@opindex filelist
24122@opindex flat_namespace
24123@opindex force_flat_namespace
24124@opindex headerpad_max_install_names
24125@opindex image_base
24126@opindex init
24127@opindex install_name
24128@opindex keep_private_externs
24129@opindex multi_module
24130@opindex multiply_defined
24131@opindex multiply_defined_unused
24132@opindex noall_load
24133@opindex no_dead_strip_inits_and_terms
24134@opindex nofixprebinding
24135@opindex nomultidefs
24136@opindex noprebind
24137@opindex noseglinkedit
24138@opindex pagezero_size
24139@opindex prebind
24140@opindex prebind_all_twolevel_modules
24141@opindex private_bundle
24142@opindex read_only_relocs
24143@opindex sectalign
24144@opindex sectobjectsymbols
24145@opindex whyload
24146@opindex seg1addr
24147@opindex sectcreate
24148@opindex sectobjectsymbols
24149@opindex sectorder
24150@opindex segaddr
24151@opindex segs_read_only_addr
24152@opindex segs_read_write_addr
24153@opindex seg_addr_table
24154@opindex seg_addr_table_filename
24155@opindex seglinkedit
24156@opindex segprot
24157@opindex segs_read_only_addr
24158@opindex segs_read_write_addr
24159@opindex single_module
24160@opindex static
24161@opindex sub_library
24162@opindex sub_umbrella
24163@opindex twolevel_namespace
24164@opindex umbrella
24165@opindex undefined
24166@opindex unexported_symbols_list
24167@opindex weak_reference_mismatches
24168@opindex whatsloaded
ddf6fe37
AA
24169@itemx -sub_umbrella
24170@itemx -twolevel_namespace
24171@itemx -umbrella
24172@itemx -undefined
24173@itemx -unexported_symbols_list
24174@itemx -weak_reference_mismatches
24175@itemx -whatsloaded
d77de738
ML
24176These options are passed to the Darwin linker. The Darwin linker man page
24177describes them in detail.
24178@end table
24179
24180@node DEC Alpha Options
24181@subsection DEC Alpha Options
24182
24183These @samp{-m} options are defined for the DEC Alpha implementations:
24184
24185@table @gcctabopt
d77de738
ML
24186@opindex mno-soft-float
24187@opindex msoft-float
ddf6fe37
AA
24188@item -mno-soft-float
24189@itemx -msoft-float
d77de738
ML
24190Use (do not use) the hardware floating-point instructions for
24191floating-point operations. When @option{-msoft-float} is specified,
24192functions in @file{libgcc.a} are used to perform floating-point
24193operations. Unless they are replaced by routines that emulate the
24194floating-point operations, or compiled in such a way as to call such
24195emulations routines, these routines issue floating-point
24196operations. If you are compiling for an Alpha without floating-point
24197operations, you must ensure that the library is built so as not to call
24198them.
24199
24200Note that Alpha implementations without floating-point operations are
24201required to have floating-point registers.
24202
d77de738
ML
24203@opindex mfp-reg
24204@opindex mno-fp-regs
ddf6fe37
AA
24205@item -mfp-reg
24206@itemx -mno-fp-regs
d77de738
ML
24207Generate code that uses (does not use) the floating-point register set.
24208@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24209register set is not used, floating-point operands are passed in integer
24210registers as if they were integers and floating-point results are passed
24211in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24212so any function with a floating-point argument or return value called by code
24213compiled with @option{-mno-fp-regs} must also be compiled with that
24214option.
24215
24216A typical use of this option is building a kernel that does not use,
24217and hence need not save and restore, any floating-point registers.
24218
d77de738 24219@opindex mieee
ddf6fe37 24220@item -mieee
d77de738
ML
24221The Alpha architecture implements floating-point hardware optimized for
24222maximum performance. It is mostly compliant with the IEEE floating-point
24223standard. However, for full compliance, software assistance is
24224required. This option generates code fully IEEE-compliant code
24225@emph{except} that the @var{inexact-flag} is not maintained (see below).
24226If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24227defined during compilation. The resulting code is less efficient but is
24228able to correctly support denormalized numbers and exceptional IEEE
24229values such as not-a-number and plus/minus infinity. Other Alpha
24230compilers call this option @option{-ieee_with_no_inexact}.
24231
d77de738 24232@opindex mieee-with-inexact
ddf6fe37 24233@item -mieee-with-inexact
d77de738
ML
24234This is like @option{-mieee} except the generated code also maintains
24235the IEEE @var{inexact-flag}. Turning on this option causes the
24236generated code to implement fully-compliant IEEE math. In addition to
24237@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24238macro. On some Alpha implementations the resulting code may execute
24239significantly slower than the code generated by default. Since there is
24240very little code that depends on the @var{inexact-flag}, you should
24241normally not specify this option. Other Alpha compilers call this
24242option @option{-ieee_with_inexact}.
24243
d77de738 24244@opindex mfp-trap-mode
ddf6fe37 24245@item -mfp-trap-mode=@var{trap-mode}
d77de738
ML
24246This option controls what floating-point related traps are enabled.
24247Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24248The trap mode can be set to one of four values:
24249
24250@table @samp
24251@item n
24252This is the default (normal) setting. The only traps that are enabled
24253are the ones that cannot be disabled in software (e.g., division by zero
24254trap).
24255
24256@item u
24257In addition to the traps enabled by @samp{n}, underflow traps are enabled
24258as well.
24259
24260@item su
24261Like @samp{u}, but the instructions are marked to be safe for software
24262completion (see Alpha architecture manual for details).
24263
24264@item sui
24265Like @samp{su}, but inexact traps are enabled as well.
24266@end table
24267
d77de738 24268@opindex mfp-rounding-mode
ddf6fe37 24269@item -mfp-rounding-mode=@var{rounding-mode}
d77de738
ML
24270Selects the IEEE rounding mode. Other Alpha compilers call this option
24271@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24272of:
24273
24274@table @samp
24275@item n
24276Normal IEEE rounding mode. Floating-point numbers are rounded towards
24277the nearest machine number or towards the even machine number in case
24278of a tie.
24279
24280@item m
24281Round towards minus infinity.
24282
24283@item c
24284Chopped rounding mode. Floating-point numbers are rounded towards zero.
24285
24286@item d
24287Dynamic rounding mode. A field in the floating-point control register
24288(@var{fpcr}, see Alpha architecture reference manual) controls the
24289rounding mode in effect. The C library initializes this register for
24290rounding towards plus infinity. Thus, unless your program modifies the
24291@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24292@end table
24293
d77de738 24294@opindex mtrap-precision
ddf6fe37 24295@item -mtrap-precision=@var{trap-precision}
d77de738
ML
24296In the Alpha architecture, floating-point traps are imprecise. This
24297means without software assistance it is impossible to recover from a
24298floating trap and program execution normally needs to be terminated.
24299GCC can generate code that can assist operating system trap handlers
24300in determining the exact location that caused a floating-point trap.
24301Depending on the requirements of an application, different levels of
24302precisions can be selected:
24303
24304@table @samp
24305@item p
24306Program precision. This option is the default and means a trap handler
24307can only identify which program caused a floating-point exception.
24308
24309@item f
24310Function precision. The trap handler can determine the function that
24311caused a floating-point exception.
24312
24313@item i
24314Instruction precision. The trap handler can determine the exact
24315instruction that caused a floating-point exception.
24316@end table
24317
24318Other Alpha compilers provide the equivalent options called
24319@option{-scope_safe} and @option{-resumption_safe}.
24320
d77de738 24321@opindex mieee-conformant
ddf6fe37 24322@item -mieee-conformant
d77de738
ML
24323This option marks the generated code as IEEE conformant. You must not
24324use this option unless you also specify @option{-mtrap-precision=i} and either
24325@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24326is to emit the line @samp{.eflag 48} in the function prologue of the
24327generated assembly file.
24328
d77de738 24329@opindex mbuild-constants
ddf6fe37 24330@item -mbuild-constants
d77de738
ML
24331Normally GCC examines a 32- or 64-bit integer constant to
24332see if it can construct it from smaller constants in two or three
24333instructions. If it cannot, it outputs the constant as a literal and
24334generates code to load it from the data segment at run time.
24335
24336Use this option to require GCC to construct @emph{all} integer constants
24337using code, even if it takes more instructions (the maximum is six).
24338
24339You typically use this option to build a shared library dynamic
24340loader. Itself a shared library, it must relocate itself in memory
24341before it can find the variables and constants in its own data segment.
24342
d77de738
ML
24343@opindex mbwx
24344@opindex mno-bwx
24345@opindex mcix
24346@opindex mno-cix
24347@opindex mfix
24348@opindex mno-fix
24349@opindex mmax
24350@opindex mno-max
ddf6fe37
AA
24351@item -mbwx
24352@itemx -mno-bwx
24353@itemx -mcix
24354@itemx -mno-cix
24355@itemx -mfix
24356@itemx -mno-fix
24357@itemx -mmax
24358@itemx -mno-max
d77de738
ML
24359Indicate whether GCC should generate code to use the optional BWX,
24360CIX, FIX and MAX instruction sets. The default is to use the instruction
24361sets supported by the CPU type specified via @option{-mcpu=} option or that
24362of the CPU on which GCC was built if none is specified.
24363
d77de738
ML
24364@opindex mfloat-vax
24365@opindex mfloat-ieee
ddf6fe37
AA
24366@item -mfloat-vax
24367@itemx -mfloat-ieee
d77de738
ML
24368Generate code that uses (does not use) VAX F and G floating-point
24369arithmetic instead of IEEE single and double precision.
24370
d77de738
ML
24371@opindex mexplicit-relocs
24372@opindex mno-explicit-relocs
ddf6fe37
AA
24373@item -mexplicit-relocs
24374@itemx -mno-explicit-relocs
d77de738
ML
24375Older Alpha assemblers provided no way to generate symbol relocations
24376except via assembler macros. Use of these macros does not allow
24377optimal instruction scheduling. GNU binutils as of version 2.12
24378supports a new syntax that allows the compiler to explicitly mark
24379which relocations should apply to which instructions. This option
24380is mostly useful for debugging, as GCC detects the capabilities of
24381the assembler when it is built and sets the default accordingly.
24382
d77de738
ML
24383@opindex msmall-data
24384@opindex mlarge-data
ddf6fe37
AA
24385@item -msmall-data
24386@itemx -mlarge-data
d77de738
ML
24387When @option{-mexplicit-relocs} is in effect, static data is
24388accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24389is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24390(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2439116-bit relocations off of the @code{$gp} register. This limits the
24392size of the small data area to 64KB, but allows the variables to be
24393directly accessed via a single instruction.
24394
24395The default is @option{-mlarge-data}. With this option the data area
24396is limited to just below 2GB@. Programs that require more than 2GB of
24397data must use @code{malloc} or @code{mmap} to allocate the data in the
24398heap instead of in the program's data segment.
24399
24400When generating code for shared libraries, @option{-fpic} implies
24401@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24402
d77de738
ML
24403@opindex msmall-text
24404@opindex mlarge-text
ddf6fe37
AA
24405@item -msmall-text
24406@itemx -mlarge-text
d77de738
ML
24407When @option{-msmall-text} is used, the compiler assumes that the
24408code of the entire program (or shared library) fits in 4MB, and is
24409thus reachable with a branch instruction. When @option{-msmall-data}
24410is used, the compiler can assume that all local symbols share the
24411same @code{$gp} value, and thus reduce the number of instructions
24412required for a function call from 4 to 1.
24413
24414The default is @option{-mlarge-text}.
24415
d77de738 24416@opindex mcpu
ddf6fe37 24417@item -mcpu=@var{cpu_type}
d77de738
ML
24418Set the instruction set and instruction scheduling parameters for
24419machine type @var{cpu_type}. You can specify either the @samp{EV}
24420style name or the corresponding chip number. GCC supports scheduling
24421parameters for the EV4, EV5 and EV6 family of processors and
24422chooses the default values for the instruction set from the processor
24423you specify. If you do not specify a processor type, GCC defaults
24424to the processor on which the compiler was built.
24425
24426Supported values for @var{cpu_type} are
24427
24428@table @samp
24429@item ev4
24430@itemx ev45
24431@itemx 21064
24432Schedules as an EV4 and has no instruction set extensions.
24433
24434@item ev5
24435@itemx 21164
24436Schedules as an EV5 and has no instruction set extensions.
24437
24438@item ev56
24439@itemx 21164a
24440Schedules as an EV5 and supports the BWX extension.
24441
24442@item pca56
24443@itemx 21164pc
24444@itemx 21164PC
24445Schedules as an EV5 and supports the BWX and MAX extensions.
24446
24447@item ev6
24448@itemx 21264
24449Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24450
24451@item ev67
24452@itemx 21264a
24453Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24454@end table
24455
24456Native toolchains also support the value @samp{native},
24457which selects the best architecture option for the host processor.
24458@option{-mcpu=native} has no effect if GCC does not recognize
24459the processor.
24460
d77de738 24461@opindex mtune
ddf6fe37 24462@item -mtune=@var{cpu_type}
d77de738
ML
24463Set only the instruction scheduling parameters for machine type
24464@var{cpu_type}. The instruction set is not changed.
24465
24466Native toolchains also support the value @samp{native},
24467which selects the best architecture option for the host processor.
24468@option{-mtune=native} has no effect if GCC does not recognize
24469the processor.
24470
d77de738 24471@opindex mmemory-latency
ddf6fe37 24472@item -mmemory-latency=@var{time}
d77de738
ML
24473Sets the latency the scheduler should assume for typical memory
24474references as seen by the application. This number is highly
24475dependent on the memory access patterns used by the application
24476and the size of the external cache on the machine.
24477
24478Valid options for @var{time} are
24479
24480@table @samp
24481@item @var{number}
24482A decimal number representing clock cycles.
24483
24484@item L1
24485@itemx L2
24486@itemx L3
24487@itemx main
24488The compiler contains estimates of the number of clock cycles for
24489``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24490(also called Dcache, Scache, and Bcache), as well as to main memory.
24491Note that L3 is only valid for EV5.
24492
24493@end table
24494@end table
24495
24496@node eBPF Options
24497@subsection eBPF Options
24498@cindex eBPF Options
24499
24500@table @gcctabopt
24501@item -mframe-limit=@var{bytes}
24502This specifies the hard limit for frame sizes, in bytes. Currently,
24503the value that can be specified should be less than or equal to
24504@samp{32767}. Defaults to whatever limit is imposed by the version of
24505the Linux kernel targeted.
24506
d77de738 24507@opindex mkernel
ddf6fe37 24508@item -mkernel=@var{version}
d77de738
ML
24509This specifies the minimum version of the kernel that will run the
24510compiled program. GCC uses this version to determine which
24511instructions to use, what kernel helpers to allow, etc. Currently,
24512@var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
24513@samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
24514@samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
24515@samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
24516@samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
24517@samp{5.2}, @samp{latest} and @samp{native}.
24518
d77de738 24519@opindex mbig-endian
ddf6fe37 24520@item -mbig-endian
d77de738
ML
24521Generate code for a big-endian target.
24522
d77de738 24523@opindex mlittle-endian
ddf6fe37 24524@item -mlittle-endian
d77de738
ML
24525Generate code for a little-endian target. This is the default.
24526
d77de738 24527@opindex mjmpext
ddf6fe37 24528@item -mjmpext
d77de738
ML
24529Enable generation of extra conditional-branch instructions.
24530Enabled for CPU v2 and above.
24531
d77de738 24532@opindex mjmp32
ddf6fe37 24533@item -mjmp32
d77de738
ML
24534Enable 32-bit jump instructions. Enabled for CPU v3 and above.
24535
d77de738 24536@opindex malu32
ddf6fe37 24537@item -malu32
d77de738
ML
24538Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
24539
d77de738 24540@opindex mcpu
ddf6fe37 24541@item -mcpu=@var{version}
d77de738
ML
24542This specifies which version of the eBPF ISA to target. Newer versions
24543may not be supported by all kernels. The default is @samp{v3}.
24544
24545Supported values for @var{version} are:
24546
24547@table @samp
24548@item v1
24549The first stable eBPF ISA with no special features or extensions.
24550
24551@item v2
24552Supports the jump extensions, as in @option{-mjmpext}.
24553
24554@item v3
24555All features of v2, plus:
24556@itemize @minus
24557@item 32-bit jump operations, as in @option{-mjmp32}
24558@item 32-bit ALU operations, as in @option{-malu32}
24559@end itemize
24560
24561@end table
24562
d77de738 24563@opindex mco-re
ddf6fe37 24564@item -mco-re
d77de738
ML
24565Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24566is implied by @option{-gbtf}.
24567
d77de738 24568@opindex mno-co-re
ddf6fe37 24569@item -mno-co-re
d77de738
ML
24570Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24571support is enabled by default when generating BTF debug information for
24572the BPF target.
24573
24574@item -mxbpf
24575Generate code for an expanded version of BPF, which relaxes some of
24576the restrictions imposed by the BPF architecture:
24577@itemize @minus
24578@item Save and restore callee-saved registers at function entry and
24579exit, respectively.
24580@end itemize
24581@end table
24582
24583@node FR30 Options
24584@subsection FR30 Options
24585@cindex FR30 Options
24586
24587These options are defined specifically for the FR30 port.
24588
24589@table @gcctabopt
24590
d77de738 24591@opindex msmall-model
ddf6fe37 24592@item -msmall-model
d77de738
ML
24593Use the small address space model. This can produce smaller code, but
24594it does assume that all symbolic values and addresses fit into a
2459520-bit range.
24596
d77de738 24597@opindex mno-lsim
ddf6fe37 24598@item -mno-lsim
d77de738
ML
24599Assume that runtime support has been provided and so there is no need
24600to include the simulator library (@file{libsim.a}) on the linker
24601command line.
24602
24603@end table
24604
24605@node FT32 Options
24606@subsection FT32 Options
24607@cindex FT32 Options
24608
24609These options are defined specifically for the FT32 port.
24610
24611@table @gcctabopt
24612
d77de738 24613@opindex msim
ddf6fe37 24614@item -msim
d77de738
ML
24615Specifies that the program will be run on the simulator. This causes
24616an alternate runtime startup and library to be linked.
24617You must not use this option when generating programs that will run on
24618real hardware; you must provide your own runtime library for whatever
24619I/O functions are needed.
24620
d77de738 24621@opindex mlra
ddf6fe37 24622@item -mlra
d77de738
ML
24623Enable Local Register Allocation. This is still experimental for FT32,
24624so by default the compiler uses standard reload.
24625
d77de738 24626@opindex mnodiv
ddf6fe37 24627@item -mnodiv
d77de738
ML
24628Do not use div and mod instructions.
24629
d77de738 24630@opindex mft32b
ddf6fe37 24631@item -mft32b
d77de738
ML
24632Enable use of the extended instructions of the FT32B processor.
24633
d77de738 24634@opindex mcompress
ddf6fe37 24635@item -mcompress
d77de738
ML
24636Compress all code using the Ft32B code compression scheme.
24637
d77de738 24638@opindex mnopm
ddf6fe37 24639@item -mnopm
d77de738
ML
24640Do not generate code that reads program memory.
24641
24642@end table
24643
24644@node FRV Options
24645@subsection FRV Options
24646@cindex FRV Options
24647
24648@table @gcctabopt
d77de738 24649@opindex mgpr-32
ddf6fe37 24650@item -mgpr-32
d77de738
ML
24651
24652Only use the first 32 general-purpose registers.
24653
d77de738 24654@opindex mgpr-64
ddf6fe37 24655@item -mgpr-64
d77de738
ML
24656
24657Use all 64 general-purpose registers.
24658
d77de738 24659@opindex mfpr-32
ddf6fe37 24660@item -mfpr-32
d77de738
ML
24661
24662Use only the first 32 floating-point registers.
24663
d77de738 24664@opindex mfpr-64
ddf6fe37 24665@item -mfpr-64
d77de738
ML
24666
24667Use all 64 floating-point registers.
24668
d77de738 24669@opindex mhard-float
ddf6fe37 24670@item -mhard-float
d77de738
ML
24671
24672Use hardware instructions for floating-point operations.
24673
d77de738 24674@opindex msoft-float
ddf6fe37 24675@item -msoft-float
d77de738
ML
24676
24677Use library routines for floating-point operations.
24678
d77de738 24679@opindex malloc-cc
ddf6fe37 24680@item -malloc-cc
d77de738
ML
24681
24682Dynamically allocate condition code registers.
24683
d77de738 24684@opindex mfixed-cc
ddf6fe37 24685@item -mfixed-cc
d77de738
ML
24686
24687Do not try to dynamically allocate condition code registers, only
24688use @code{icc0} and @code{fcc0}.
24689
d77de738 24690@opindex mdword
ddf6fe37 24691@item -mdword
d77de738
ML
24692
24693Change ABI to use double word insns.
24694
d77de738
ML
24695@opindex mno-dword
24696@opindex mdword
ddf6fe37 24697@item -mno-dword
d77de738
ML
24698
24699Do not use double word instructions.
24700
d77de738 24701@opindex mdouble
ddf6fe37 24702@item -mdouble
d77de738
ML
24703
24704Use floating-point double instructions.
24705
d77de738 24706@opindex mno-double
ddf6fe37 24707@item -mno-double
d77de738
ML
24708
24709Do not use floating-point double instructions.
24710
d77de738 24711@opindex mmedia
ddf6fe37 24712@item -mmedia
d77de738
ML
24713
24714Use media instructions.
24715
d77de738 24716@opindex mno-media
ddf6fe37 24717@item -mno-media
d77de738
ML
24718
24719Do not use media instructions.
24720
d77de738 24721@opindex mmuladd
ddf6fe37 24722@item -mmuladd
d77de738
ML
24723
24724Use multiply and add/subtract instructions.
24725
d77de738 24726@opindex mno-muladd
ddf6fe37 24727@item -mno-muladd
d77de738
ML
24728
24729Do not use multiply and add/subtract instructions.
24730
d77de738 24731@opindex mfdpic
ddf6fe37 24732@item -mfdpic
d77de738
ML
24733
24734Select the FDPIC ABI, which uses function descriptors to represent
24735pointers to functions. Without any PIC/PIE-related options, it
24736implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
24737assumes GOT entries and small data are within a 12-bit range from the
24738GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
24739are computed with 32 bits.
24740With a @samp{bfin-elf} target, this option implies @option{-msim}.
24741
d77de738 24742@opindex minline-plt
ddf6fe37 24743@item -minline-plt
d77de738
ML
24744
24745Enable inlining of PLT entries in function calls to functions that are
24746not known to bind locally. It has no effect without @option{-mfdpic}.
24747It's enabled by default if optimizing for speed and compiling for
24748shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
24749optimization option such as @option{-O3} or above is present in the
24750command line.
24751
d77de738 24752@opindex mTLS
ddf6fe37 24753@item -mTLS
d77de738
ML
24754
24755Assume a large TLS segment when generating thread-local code.
24756
d77de738 24757@opindex mtls
ddf6fe37 24758@item -mtls
d77de738
ML
24759
24760Do not assume a large TLS segment when generating thread-local code.
24761
d77de738 24762@opindex mgprel-ro
ddf6fe37 24763@item -mgprel-ro
d77de738
ML
24764
24765Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
24766that is known to be in read-only sections. It's enabled by default,
24767except for @option{-fpic} or @option{-fpie}: even though it may help
24768make the global offset table smaller, it trades 1 instruction for 4.
24769With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
24770one of which may be shared by multiple symbols, and it avoids the need
24771for a GOT entry for the referenced symbol, so it's more likely to be a
24772win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
24773
d77de738 24774@opindex multilib-library-pic
ddf6fe37 24775@item -multilib-library-pic
d77de738
ML
24776
24777Link with the (library, not FD) pic libraries. It's implied by
24778@option{-mlibrary-pic}, as well as by @option{-fPIC} and
24779@option{-fpic} without @option{-mfdpic}. You should never have to use
24780it explicitly.
24781
d77de738 24782@opindex mlinked-fp
ddf6fe37 24783@item -mlinked-fp
d77de738
ML
24784
24785Follow the EABI requirement of always creating a frame pointer whenever
24786a stack frame is allocated. This option is enabled by default and can
24787be disabled with @option{-mno-linked-fp}.
24788
d77de738 24789@opindex mlong-calls
ddf6fe37 24790@item -mlong-calls
d77de738
ML
24791
24792Use indirect addressing to call functions outside the current
24793compilation unit. This allows the functions to be placed anywhere
24794within the 32-bit address space.
24795
d77de738 24796@opindex malign-labels
ddf6fe37 24797@item -malign-labels
d77de738
ML
24798
24799Try to align labels to an 8-byte boundary by inserting NOPs into the
24800previous packet. This option only has an effect when VLIW packing
24801is enabled. It doesn't create new packets; it merely adds NOPs to
24802existing ones.
24803
d77de738 24804@opindex mlibrary-pic
ddf6fe37 24805@item -mlibrary-pic
d77de738
ML
24806
24807Generate position-independent EABI code.
24808
d77de738 24809@opindex macc-4
ddf6fe37 24810@item -macc-4
d77de738
ML
24811
24812Use only the first four media accumulator registers.
24813
d77de738 24814@opindex macc-8
ddf6fe37 24815@item -macc-8
d77de738
ML
24816
24817Use all eight media accumulator registers.
24818
d77de738 24819@opindex mpack
ddf6fe37 24820@item -mpack
d77de738
ML
24821
24822Pack VLIW instructions.
24823
d77de738 24824@opindex mno-pack
ddf6fe37 24825@item -mno-pack
d77de738
ML
24826
24827Do not pack VLIW instructions.
24828
d77de738 24829@opindex mno-eflags
ddf6fe37 24830@item -mno-eflags
d77de738
ML
24831
24832Do not mark ABI switches in e_flags.
24833
d77de738 24834@opindex mcond-move
ddf6fe37 24835@item -mcond-move
d77de738
ML
24836
24837Enable the use of conditional-move instructions (default).
24838
24839This switch is mainly for debugging the compiler and will likely be removed
24840in a future version.
24841
d77de738 24842@opindex mno-cond-move
ddf6fe37 24843@item -mno-cond-move
d77de738
ML
24844
24845Disable the use of conditional-move instructions.
24846
24847This switch is mainly for debugging the compiler and will likely be removed
24848in a future version.
24849
d77de738 24850@opindex mscc
ddf6fe37 24851@item -mscc
d77de738
ML
24852
24853Enable the use of conditional set instructions (default).
24854
24855This switch is mainly for debugging the compiler and will likely be removed
24856in a future version.
24857
d77de738 24858@opindex mno-scc
ddf6fe37 24859@item -mno-scc
d77de738
ML
24860
24861Disable the use of conditional set instructions.
24862
24863This switch is mainly for debugging the compiler and will likely be removed
24864in a future version.
24865
d77de738 24866@opindex mcond-exec
ddf6fe37 24867@item -mcond-exec
d77de738
ML
24868
24869Enable the use of conditional execution (default).
24870
24871This switch is mainly for debugging the compiler and will likely be removed
24872in a future version.
24873
d77de738 24874@opindex mno-cond-exec
ddf6fe37 24875@item -mno-cond-exec
d77de738
ML
24876
24877Disable the use of conditional execution.
24878
24879This switch is mainly for debugging the compiler and will likely be removed
24880in a future version.
24881
d77de738 24882@opindex mvliw-branch
ddf6fe37 24883@item -mvliw-branch
d77de738
ML
24884
24885Run a pass to pack branches into VLIW instructions (default).
24886
24887This switch is mainly for debugging the compiler and will likely be removed
24888in a future version.
24889
d77de738 24890@opindex mno-vliw-branch
ddf6fe37 24891@item -mno-vliw-branch
d77de738
ML
24892
24893Do not run a pass to pack branches into VLIW instructions.
24894
24895This switch is mainly for debugging the compiler and will likely be removed
24896in a future version.
24897
d77de738 24898@opindex mmulti-cond-exec
ddf6fe37 24899@item -mmulti-cond-exec
d77de738
ML
24900
24901Enable optimization of @code{&&} and @code{||} in conditional execution
24902(default).
24903
24904This switch is mainly for debugging the compiler and will likely be removed
24905in a future version.
24906
d77de738 24907@opindex mno-multi-cond-exec
ddf6fe37 24908@item -mno-multi-cond-exec
d77de738
ML
24909
24910Disable optimization of @code{&&} and @code{||} in conditional execution.
24911
24912This switch is mainly for debugging the compiler and will likely be removed
24913in a future version.
24914
d77de738 24915@opindex mnested-cond-exec
ddf6fe37 24916@item -mnested-cond-exec
d77de738
ML
24917
24918Enable nested conditional execution optimizations (default).
24919
24920This switch is mainly for debugging the compiler and will likely be removed
24921in a future version.
24922
d77de738 24923@opindex mno-nested-cond-exec
ddf6fe37 24924@item -mno-nested-cond-exec
d77de738
ML
24925
24926Disable nested conditional execution optimizations.
24927
24928This switch is mainly for debugging the compiler and will likely be removed
24929in a future version.
24930
d77de738 24931@opindex moptimize-membar
ddf6fe37 24932@item -moptimize-membar
d77de738
ML
24933
24934This switch removes redundant @code{membar} instructions from the
24935compiler-generated code. It is enabled by default.
24936
d77de738
ML
24937@opindex mno-optimize-membar
24938@opindex moptimize-membar
ddf6fe37 24939@item -mno-optimize-membar
d77de738
ML
24940
24941This switch disables the automatic removal of redundant @code{membar}
24942instructions from the generated code.
24943
d77de738 24944@opindex mtomcat-stats
ddf6fe37 24945@item -mtomcat-stats
d77de738
ML
24946
24947Cause gas to print out tomcat statistics.
24948
d77de738 24949@opindex mcpu
ddf6fe37 24950@item -mcpu=@var{cpu}
d77de738
ML
24951
24952Select the processor type for which to generate code. Possible values are
24953@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
24954@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
24955
24956@end table
24957
24958@node GNU/Linux Options
24959@subsection GNU/Linux Options
24960
24961These @samp{-m} options are defined for GNU/Linux targets:
24962
24963@table @gcctabopt
d77de738 24964@opindex mglibc
ddf6fe37 24965@item -mglibc
d77de738
ML
24966Use the GNU C library. This is the default except
24967on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
24968@samp{*-*-linux-*android*} targets.
24969
d77de738 24970@opindex muclibc
ddf6fe37 24971@item -muclibc
d77de738
ML
24972Use uClibc C library. This is the default on
24973@samp{*-*-linux-*uclibc*} targets.
24974
d77de738 24975@opindex mmusl
ddf6fe37 24976@item -mmusl
d77de738
ML
24977Use the musl C library. This is the default on
24978@samp{*-*-linux-*musl*} targets.
24979
d77de738 24980@opindex mbionic
ddf6fe37 24981@item -mbionic
d77de738
ML
24982Use Bionic C library. This is the default on
24983@samp{*-*-linux-*android*} targets.
24984
d77de738 24985@opindex mandroid
ddf6fe37 24986@item -mandroid
d77de738
ML
24987Compile code compatible with Android platform. This is the default on
24988@samp{*-*-linux-*android*} targets.
24989
24990When compiling, this option enables @option{-mbionic}, @option{-fPIC},
24991@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
24992this option makes the GCC driver pass Android-specific options to the linker.
24993Finally, this option causes the preprocessor macro @code{__ANDROID__}
24994to be defined.
24995
d77de738 24996@opindex tno-android-cc
ddf6fe37 24997@item -tno-android-cc
d77de738
ML
24998Disable compilation effects of @option{-mandroid}, i.e., do not enable
24999@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
25000@option{-fno-rtti} by default.
25001
d77de738 25002@opindex tno-android-ld
ddf6fe37 25003@item -tno-android-ld
d77de738
ML
25004Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
25005linking options to the linker.
25006
25007@end table
25008
25009@node H8/300 Options
25010@subsection H8/300 Options
25011
25012These @samp{-m} options are defined for the H8/300 implementations:
25013
25014@table @gcctabopt
d77de738 25015@opindex mrelax
ddf6fe37 25016@item -mrelax
d77de738
ML
25017Shorten some address references at link time, when possible; uses the
25018linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
25019ld, Using ld}, for a fuller description.
25020
d77de738 25021@opindex mh
ddf6fe37 25022@item -mh
d77de738
ML
25023Generate code for the H8/300H@.
25024
d77de738 25025@opindex ms
ddf6fe37 25026@item -ms
d77de738
ML
25027Generate code for the H8S@.
25028
d77de738 25029@opindex mn
ddf6fe37 25030@item -mn
d77de738
ML
25031Generate code for the H8S and H8/300H in the normal mode. This switch
25032must be used either with @option{-mh} or @option{-ms}.
25033
d77de738 25034@opindex ms2600
ddf6fe37 25035@item -ms2600
d77de738
ML
25036Generate code for the H8S/2600. This switch must be used with @option{-ms}.
25037
d77de738 25038@opindex mexr
ddf6fe37 25039@item -mexr
d77de738
ML
25040Extended registers are stored on stack before execution of function
25041with monitor attribute. Default option is @option{-mexr}.
25042This option is valid only for H8S targets.
25043
d77de738
ML
25044@opindex mno-exr
25045@opindex mexr
ddf6fe37 25046@item -mno-exr
d77de738
ML
25047Extended registers are not stored on stack before execution of function
25048with monitor attribute. Default option is @option{-mno-exr}.
25049This option is valid only for H8S targets.
25050
d77de738 25051@opindex mint32
ddf6fe37 25052@item -mint32
d77de738
ML
25053Make @code{int} data 32 bits by default.
25054
d77de738 25055@opindex malign-300
ddf6fe37 25056@item -malign-300
d77de738
ML
25057On the H8/300H and H8S, use the same alignment rules as for the H8/300.
25058The default for the H8/300H and H8S is to align longs and floats on
250594-byte boundaries.
25060@option{-malign-300} causes them to be aligned on 2-byte boundaries.
25061This option has no effect on the H8/300.
25062@end table
25063
25064@node HPPA Options
25065@subsection HPPA Options
25066@cindex HPPA Options
25067
25068These @samp{-m} options are defined for the HPPA family of computers:
25069
25070@table @gcctabopt
d77de738 25071@opindex march
ddf6fe37 25072@item -march=@var{architecture-type}
d77de738
ML
25073Generate code for the specified architecture. The choices for
25074@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
250751.1, and @samp{2.0} for PA 2.0 processors. Refer to
25076@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
25077architecture option for your machine. Code compiled for lower numbered
25078architectures runs on higher numbered architectures, but not the
25079other way around.
25080
d77de738
ML
25081@opindex mpa-risc-1-0
25082@opindex mpa-risc-1-1
25083@opindex mpa-risc-2-0
ddf6fe37
AA
25084@item -mpa-risc-1-0
25085@itemx -mpa-risc-1-1
25086@itemx -mpa-risc-2-0
d77de738
ML
25087Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
25088
cf467fb9
JDA
25089@opindex matomic-libcalls
25090@opindex mno-atomic-libcalls
ddf6fe37 25091@item -matomic-libcalls
cf467fb9
JDA
25092Generate libcalls for atomic loads and stores when sync libcalls are disabled.
25093This option is enabled by default. It only affects the generation of
25094atomic libcalls by the HPPA backend.
25095
25096Both the sync and @file{libatomic} libcall implementations use locking.
25097As a result, processor stores are not atomic with respect to other
25098atomic operations. Processor loads up to DImode are atomic with
25099respect to other atomic operations provided they are implemented as
25100a single access.
25101
25102The PA-RISC architecture does not support any atomic operations in
25103hardware except for the @code{ldcw} instruction. Thus, all atomic
25104support is implemented using sync and atomic libcalls. Sync libcall
25105support is in @file{libgcc.a}. Atomic libcall support is in
25106@file{libatomic}.
25107
25108This option generates @code{__atomic_exchange} calls for atomic stores.
25109It also provides special handling for atomic DImode accesses on 32-bit
25110targets.
25111
cf467fb9 25112@opindex mbig-switch
ddf6fe37 25113@item -mbig-switch
cf467fb9
JDA
25114Does nothing. Preserved for backward compatibility.
25115
d77de738 25116@opindex mcaller-copies
ddf6fe37 25117@item -mcaller-copies
d77de738
ML
25118The caller copies function arguments passed by hidden reference. This
25119option should be used with care as it is not compatible with the default
2512032-bit runtime. However, only aggregates larger than eight bytes are
25121passed by hidden reference and the option provides better compatibility
25122with OpenMP.
25123
cf467fb9 25124@opindex mcoherent-ldcw
ddf6fe37 25125@item -mcoherent-ldcw
cf467fb9 25126Use ldcw/ldcd coherent cache-control hint.
d77de738 25127
d77de738 25128@opindex mdisable-fpregs
ddf6fe37 25129@item -mdisable-fpregs
cf467fb9 25130Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738 25131
d77de738 25132@opindex mdisable-indexing
ddf6fe37 25133@item -mdisable-indexing
d77de738
ML
25134Prevent the compiler from using indexing address modes. This avoids some
25135rather obscure problems when compiling MIG generated code under MACH@.
25136
d77de738 25137@opindex mfast-indirect-calls
ddf6fe37 25138@item -mfast-indirect-calls
d77de738
ML
25139Generate code that assumes calls never cross space boundaries. This
25140allows GCC to emit code that performs faster indirect calls.
25141
25142This option does not work in the presence of shared libraries or nested
25143functions.
25144
d77de738 25145@opindex mfixed-range
ddf6fe37 25146@item -mfixed-range=@var{register-range}
d77de738
ML
25147Generate code treating the given register range as fixed registers.
25148A fixed register is one that the register allocator cannot use. This is
25149useful when compiling kernel code. A register range is specified as
25150two registers separated by a dash. Multiple register ranges can be
25151specified separated by a comma.
25152
d77de738 25153@opindex mgas
ddf6fe37 25154@item -mgas
d77de738
ML
25155Enable the use of assembler directives only GAS understands.
25156
d77de738 25157@opindex mgnu-ld
ddf6fe37 25158@item -mgnu-ld
d77de738
ML
25159Use options specific to GNU @command{ld}.
25160This passes @option{-shared} to @command{ld} when
25161building a shared library. It is the default when GCC is configured,
25162explicitly or implicitly, with the GNU linker. This option does not
25163affect which @command{ld} is called; it only changes what parameters
25164are passed to that @command{ld}.
25165The @command{ld} that is called is determined by the
25166@option{--with-ld} configure option, GCC's program search path, and
25167finally by the user's @env{PATH}. The linker used by GCC can be printed
25168using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25169on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25170
d77de738 25171@opindex mhp-ld
ddf6fe37 25172@item -mhp-ld
d77de738
ML
25173Use options specific to HP @command{ld}.
25174This passes @option{-b} to @command{ld} when building
25175a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25176links. It is the default when GCC is configured, explicitly or
25177implicitly, with the HP linker. This option does not affect
25178which @command{ld} is called; it only changes what parameters are passed to that
25179@command{ld}.
25180The @command{ld} that is called is determined by the @option{--with-ld}
25181configure option, GCC's program search path, and finally by the user's
25182@env{PATH}. The linker used by GCC can be printed using @samp{which
25183`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25184HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25185
cf467fb9 25186@opindex mlinker-opt
ddf6fe37 25187@item -mlinker-opt
cf467fb9
JDA
25188Enable the optimization pass in the HP-UX linker. Note this makes symbolic
25189debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25190linkers in which they give bogus error messages when linking some programs.
25191
d77de738
ML
25192@opindex mno-long-calls
25193@opindex mlong-calls
ddf6fe37 25194@item -mlong-calls
d77de738
ML
25195Generate code that uses long call sequences. This ensures that a call
25196is always able to reach linker generated stubs. The default is to generate
25197long calls only when the distance from the call site to the beginning
25198of the function or translation unit, as the case may be, exceeds a
25199predefined limit set by the branch type being used. The limits for
25200normal calls are 7,600,000 and 240,000 bytes, respectively for the
25201PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25202240,000 bytes.
25203
25204Distances are measured from the beginning of functions when using the
25205@option{-ffunction-sections} option, or when using the @option{-mgas}
25206and @option{-mno-portable-runtime} options together under HP-UX with
25207the SOM linker.
25208
25209It is normally not desirable to use this option as it degrades
25210performance. However, it may be useful in large applications,
25211particularly when partial linking is used to build the application.
25212
25213The types of long calls used depends on the capabilities of the
25214assembler and linker, and the type of code being generated. The
25215impact on systems that support long absolute calls, and long pic
25216symbol-difference or pc-relative calls should be relatively small.
25217However, an indirect call is used on 32-bit ELF systems in pic code
25218and it is quite long.
25219
cf467fb9 25220@opindex mlong-load-store
ddf6fe37 25221@item -mlong-load-store
cf467fb9
JDA
25222Generate 3-instruction load and store sequences as sometimes required by
25223the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25224the HP compilers.
25225
cf467fb9 25226@opindex mjump-in-delay
ddf6fe37 25227@item -mjump-in-delay
cf467fb9
JDA
25228This option is ignored and provided for compatibility purposes only.
25229
cf467fb9
JDA
25230@opindex mno-space-regs
25231@opindex mspace-regs
ddf6fe37 25232@item -mno-space-regs
cf467fb9
JDA
25233Generate code that assumes the target has no space registers. This allows
25234GCC to generate faster indirect calls and use unscaled index address modes.
25235
25236Such code is suitable for level 0 PA systems and kernels.
25237
cf467fb9 25238@opindex mordered
ddf6fe37 25239@item -mordered
cf467fb9
JDA
25240Assume memory references are ordered and barriers are not needed.
25241
cf467fb9 25242@opindex mportable-runtime
ddf6fe37 25243@item -mportable-runtime
cf467fb9
JDA
25244Use the portable calling conventions proposed by HP for ELF systems.
25245
cf467fb9 25246@opindex mschedule
ddf6fe37 25247@item -mschedule=@var{cpu-type}
cf467fb9
JDA
25248Schedule code according to the constraints for the machine type
25249@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25250@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25251to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25252proper scheduling option for your machine. The default scheduling is
25253@samp{8000}.
25254
cf467fb9 25255@opindex msio
ddf6fe37 25256@item -msio
cf467fb9
JDA
25257Generate the predefine, @code{_SIO}, for server IO@. The default is
25258@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25259@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25260options are available under HP-UX and HI-UX@.
25261
cf467fb9 25262@opindex msoft-float
ddf6fe37 25263@item -msoft-float
cf467fb9
JDA
25264Generate output containing library calls for floating point.
25265@strong{Warning:} the requisite libraries are not available for all HPPA
25266targets. Normally the facilities of the machine's usual C compiler are
25267used, but this cannot be done directly in cross-compilation. You must make
25268your own arrangements to provide suitable library functions for
25269cross-compilation.
25270
25271@option{-msoft-float} changes the calling convention in the output file;
25272therefore, it is only useful if you compile @emph{all} of a program with
25273this option. In particular, you need to compile @file{libgcc.a}, the
25274library that comes with GCC, with @option{-msoft-float} in order for
25275this to work.
25276
cf467fb9 25277@opindex msoft-mult
ddf6fe37 25278@item -msoft-mult
cf467fb9
JDA
25279Use software integer multiplication.
25280
25281This disables the use of the @code{xmpyu} instruction.
25282
d77de738 25283@opindex march
ddf6fe37 25284@item -munix=@var{unix-std}
d77de738
ML
25285Generate compiler predefines and select a startfile for the specified
25286UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25287and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25288is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2528911.11 and later. The default values are @samp{93} for HP-UX 10.00,
25290@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25291and later.
25292
25293@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25294@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25295and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25296@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25297@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25298@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25299
25300It is @emph{important} to note that this option changes the interfaces
25301for various library routines. It also affects the operational behavior
25302of the C library. Thus, @emph{extreme} care is needed in using this
25303option.
25304
25305Library code that is intended to operate with more than one UNIX
25306standard must test, set and restore the variable @code{__xpg4_extended_mask}
25307as appropriate. Most GNU software doesn't provide this capability.
25308
d77de738 25309@opindex nolibdld
ddf6fe37 25310@item -nolibdld
d77de738
ML
25311Suppress the generation of link options to search libdld.sl when the
25312@option{-static} option is specified on HP-UX 10 and later.
25313
d77de738 25314@opindex static
ddf6fe37 25315@item -static
d77de738
ML
25316The HP-UX implementation of setlocale in libc has a dependency on
25317libdld.sl. There isn't an archive version of libdld.sl. Thus,
25318when the @option{-static} option is specified, special link options
25319are needed to resolve this dependency.
25320
25321On HP-UX 10 and later, the GCC driver adds the necessary options to
25322link with libdld.sl when the @option{-static} option is specified.
25323This causes the resulting binary to be dynamic. On the 64-bit port,
25324the linkers generate dynamic binaries by default in any case. The
25325@option{-nolibdld} option can be used to prevent the GCC driver from
25326adding these link options.
25327
d77de738 25328@opindex threads
ddf6fe37 25329@item -threads
d77de738
ML
25330Add support for multithreading with the @dfn{dce thread} library
25331under HP-UX@. This option sets flags for both the preprocessor and
25332linker.
25333@end table
25334
25335@node IA-64 Options
25336@subsection IA-64 Options
25337@cindex IA-64 Options
25338
25339These are the @samp{-m} options defined for the Intel IA-64 architecture.
25340
25341@table @gcctabopt
d77de738 25342@opindex mbig-endian
ddf6fe37 25343@item -mbig-endian
d77de738
ML
25344Generate code for a big-endian target. This is the default for HP-UX@.
25345
d77de738 25346@opindex mlittle-endian
ddf6fe37 25347@item -mlittle-endian
d77de738
ML
25348Generate code for a little-endian target. This is the default for AIX5
25349and GNU/Linux.
25350
d77de738
ML
25351@opindex mgnu-as
25352@opindex mno-gnu-as
ddf6fe37
AA
25353@item -mgnu-as
25354@itemx -mno-gnu-as
d77de738
ML
25355Generate (or don't) code for the GNU assembler. This is the default.
25356@c Also, this is the default if the configure option @option{--with-gnu-as}
25357@c is used.
25358
d77de738
ML
25359@opindex mgnu-ld
25360@opindex mno-gnu-ld
ddf6fe37
AA
25361@item -mgnu-ld
25362@itemx -mno-gnu-ld
d77de738
ML
25363Generate (or don't) code for the GNU linker. This is the default.
25364@c Also, this is the default if the configure option @option{--with-gnu-ld}
25365@c is used.
25366
d77de738 25367@opindex mno-pic
ddf6fe37 25368@item -mno-pic
d77de738
ML
25369Generate code that does not use a global pointer register. The result
25370is not position independent code, and violates the IA-64 ABI@.
25371
d77de738
ML
25372@opindex mvolatile-asm-stop
25373@opindex mno-volatile-asm-stop
ddf6fe37
AA
25374@item -mvolatile-asm-stop
25375@itemx -mno-volatile-asm-stop
d77de738
ML
25376Generate (or don't) a stop bit immediately before and after volatile asm
25377statements.
25378
d77de738
ML
25379@opindex mregister-names
25380@opindex mno-register-names
ddf6fe37
AA
25381@item -mregister-names
25382@itemx -mno-register-names
d77de738
ML
25383Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25384the stacked registers. This may make assembler output more readable.
25385
d77de738
ML
25386@opindex mno-sdata
25387@opindex msdata
ddf6fe37
AA
25388@item -mno-sdata
25389@itemx -msdata
d77de738
ML
25390Disable (or enable) optimizations that use the small data section. This may
25391be useful for working around optimizer bugs.
25392
d77de738 25393@opindex mconstant-gp
ddf6fe37 25394@item -mconstant-gp
d77de738
ML
25395Generate code that uses a single constant global pointer value. This is
25396useful when compiling kernel code.
25397
d77de738 25398@opindex mauto-pic
ddf6fe37 25399@item -mauto-pic
d77de738
ML
25400Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25401This is useful when compiling firmware code.
25402
d77de738 25403@opindex minline-float-divide-min-latency
ddf6fe37 25404@item -minline-float-divide-min-latency
d77de738
ML
25405Generate code for inline divides of floating-point values
25406using the minimum latency algorithm.
25407
d77de738 25408@opindex minline-float-divide-max-throughput
ddf6fe37 25409@item -minline-float-divide-max-throughput
d77de738
ML
25410Generate code for inline divides of floating-point values
25411using the maximum throughput algorithm.
25412
d77de738 25413@opindex mno-inline-float-divide
ddf6fe37 25414@item -mno-inline-float-divide
d77de738
ML
25415Do not generate inline code for divides of floating-point values.
25416
d77de738 25417@opindex minline-int-divide-min-latency
ddf6fe37 25418@item -minline-int-divide-min-latency
d77de738
ML
25419Generate code for inline divides of integer values
25420using the minimum latency algorithm.
25421
d77de738 25422@opindex minline-int-divide-max-throughput
ddf6fe37 25423@item -minline-int-divide-max-throughput
d77de738
ML
25424Generate code for inline divides of integer values
25425using the maximum throughput algorithm.
25426
d77de738
ML
25427@opindex mno-inline-int-divide
25428@opindex minline-int-divide
ddf6fe37 25429@item -mno-inline-int-divide
d77de738
ML
25430Do not generate inline code for divides of integer values.
25431
d77de738 25432@opindex minline-sqrt-min-latency
ddf6fe37 25433@item -minline-sqrt-min-latency
d77de738
ML
25434Generate code for inline square roots
25435using the minimum latency algorithm.
25436
d77de738 25437@opindex minline-sqrt-max-throughput
ddf6fe37 25438@item -minline-sqrt-max-throughput
d77de738
ML
25439Generate code for inline square roots
25440using the maximum throughput algorithm.
25441
d77de738 25442@opindex mno-inline-sqrt
ddf6fe37 25443@item -mno-inline-sqrt
d77de738
ML
25444Do not generate inline code for @code{sqrt}.
25445
d77de738
ML
25446@opindex mfused-madd
25447@opindex mno-fused-madd
ddf6fe37
AA
25448@item -mfused-madd
25449@itemx -mno-fused-madd
d77de738
ML
25450Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25451instructions. The default is to use these instructions.
25452
d77de738
ML
25453@opindex mno-dwarf2-asm
25454@opindex mdwarf2-asm
ddf6fe37
AA
25455@item -mno-dwarf2-asm
25456@itemx -mdwarf2-asm
d77de738
ML
25457Don't (or do) generate assembler code for the DWARF line number debugging
25458info. This may be useful when not using the GNU assembler.
25459
d77de738
ML
25460@opindex mearly-stop-bits
25461@opindex mno-early-stop-bits
ddf6fe37
AA
25462@item -mearly-stop-bits
25463@itemx -mno-early-stop-bits
d77de738
ML
25464Allow stop bits to be placed earlier than immediately preceding the
25465instruction that triggered the stop bit. This can improve instruction
25466scheduling, but does not always do so.
25467
d77de738 25468@opindex mfixed-range
ddf6fe37 25469@item -mfixed-range=@var{register-range}
d77de738
ML
25470Generate code treating the given register range as fixed registers.
25471A fixed register is one that the register allocator cannot use. This is
25472useful when compiling kernel code. A register range is specified as
25473two registers separated by a dash. Multiple register ranges can be
25474specified separated by a comma.
25475
d77de738 25476@opindex mtls-size
ddf6fe37 25477@item -mtls-size=@var{tls-size}
d77de738
ML
25478Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2547964.
25480
d77de738 25481@opindex mtune
ddf6fe37 25482@item -mtune=@var{cpu-type}
d77de738
ML
25483Tune the instruction scheduling for a particular CPU, Valid values are
25484@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25485and @samp{mckinley}.
25486
d77de738
ML
25487@opindex milp32
25488@opindex mlp64
ddf6fe37
AA
25489@item -milp32
25490@itemx -mlp64
d77de738
ML
25491Generate code for a 32-bit or 64-bit environment.
25492The 32-bit environment sets int, long and pointer to 32 bits.
25493The 64-bit environment sets int to 32 bits and long and pointer
25494to 64 bits. These are HP-UX specific flags.
25495
d77de738
ML
25496@opindex mno-sched-br-data-spec
25497@opindex msched-br-data-spec
ddf6fe37
AA
25498@item -mno-sched-br-data-spec
25499@itemx -msched-br-data-spec
d77de738
ML
25500(Dis/En)able data speculative scheduling before reload.
25501This results in generation of @code{ld.a} instructions and
25502the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25503The default setting is disabled.
25504
d77de738
ML
25505@opindex msched-ar-data-spec
25506@opindex mno-sched-ar-data-spec
ddf6fe37
AA
25507@item -msched-ar-data-spec
25508@itemx -mno-sched-ar-data-spec
d77de738
ML
25509(En/Dis)able data speculative scheduling after reload.
25510This results in generation of @code{ld.a} instructions and
25511the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25512The default setting is enabled.
25513
d77de738
ML
25514@opindex mno-sched-control-spec
25515@opindex msched-control-spec
ddf6fe37
AA
25516@item -mno-sched-control-spec
25517@itemx -msched-control-spec
d77de738
ML
25518(Dis/En)able control speculative scheduling. This feature is
25519available only during region scheduling (i.e.@: before reload).
25520This results in generation of the @code{ld.s} instructions and
25521the corresponding check instructions @code{chk.s}.
25522The default setting is disabled.
25523
d77de738
ML
25524@opindex msched-br-in-data-spec
25525@opindex mno-sched-br-in-data-spec
ddf6fe37
AA
25526@item -msched-br-in-data-spec
25527@itemx -mno-sched-br-in-data-spec
d77de738
ML
25528(En/Dis)able speculative scheduling of the instructions that
25529are dependent on the data speculative loads before reload.
25530This is effective only with @option{-msched-br-data-spec} enabled.
25531The default setting is enabled.
25532
d77de738
ML
25533@opindex msched-ar-in-data-spec
25534@opindex mno-sched-ar-in-data-spec
ddf6fe37
AA
25535@item -msched-ar-in-data-spec
25536@itemx -mno-sched-ar-in-data-spec
d77de738
ML
25537(En/Dis)able speculative scheduling of the instructions that
25538are dependent on the data speculative loads after reload.
25539This is effective only with @option{-msched-ar-data-spec} enabled.
25540The default setting is enabled.
25541
d77de738
ML
25542@opindex msched-in-control-spec
25543@opindex mno-sched-in-control-spec
ddf6fe37
AA
25544@item -msched-in-control-spec
25545@itemx -mno-sched-in-control-spec
d77de738
ML
25546(En/Dis)able speculative scheduling of the instructions that
25547are dependent on the control speculative loads.
25548This is effective only with @option{-msched-control-spec} enabled.
25549The default setting is enabled.
25550
d77de738
ML
25551@opindex mno-sched-prefer-non-data-spec-insns
25552@opindex msched-prefer-non-data-spec-insns
ddf6fe37
AA
25553@item -mno-sched-prefer-non-data-spec-insns
25554@itemx -msched-prefer-non-data-spec-insns
d77de738
ML
25555If enabled, data-speculative instructions are chosen for schedule
25556only if there are no other choices at the moment. This makes
25557the use of the data speculation much more conservative.
25558The default setting is disabled.
25559
d77de738
ML
25560@opindex mno-sched-prefer-non-control-spec-insns
25561@opindex msched-prefer-non-control-spec-insns
ddf6fe37
AA
25562@item -mno-sched-prefer-non-control-spec-insns
25563@itemx -msched-prefer-non-control-spec-insns
d77de738
ML
25564If enabled, control-speculative instructions are chosen for schedule
25565only if there are no other choices at the moment. This makes
25566the use of the control speculation much more conservative.
25567The default setting is disabled.
25568
d77de738
ML
25569@opindex mno-sched-count-spec-in-critical-path
25570@opindex msched-count-spec-in-critical-path
ddf6fe37
AA
25571@item -mno-sched-count-spec-in-critical-path
25572@itemx -msched-count-spec-in-critical-path
d77de738
ML
25573If enabled, speculative dependencies are considered during
25574computation of the instructions priorities. This makes the use of the
25575speculation a bit more conservative.
25576The default setting is disabled.
25577
d77de738 25578@opindex msched-spec-ldc
ddf6fe37 25579@item -msched-spec-ldc
d77de738
ML
25580Use a simple data speculation check. This option is on by default.
25581
d77de738 25582@opindex msched-spec-ldc
ddf6fe37 25583@item -msched-control-spec-ldc
d77de738
ML
25584Use a simple check for control speculation. This option is on by default.
25585
d77de738 25586@opindex msched-stop-bits-after-every-cycle
ddf6fe37 25587@item -msched-stop-bits-after-every-cycle
d77de738
ML
25588Place a stop bit after every cycle when scheduling. This option is on
25589by default.
25590
d77de738 25591@opindex msched-fp-mem-deps-zero-cost
ddf6fe37 25592@item -msched-fp-mem-deps-zero-cost
d77de738
ML
25593Assume that floating-point stores and loads are not likely to cause a conflict
25594when placed into the same instruction group. This option is disabled by
25595default.
25596
d77de738 25597@opindex msel-sched-dont-check-control-spec
ddf6fe37 25598@item -msel-sched-dont-check-control-spec
d77de738
ML
25599Generate checks for control speculation in selective scheduling.
25600This flag is disabled by default.
25601
d77de738 25602@opindex msched-max-memory-insns
ddf6fe37 25603@item -msched-max-memory-insns=@var{max-insns}
d77de738
ML
25604Limit on the number of memory insns per instruction group, giving lower
25605priority to subsequent memory insns attempting to schedule in the same
25606instruction group. Frequently useful to prevent cache bank conflicts.
25607The default value is 1.
25608
d77de738 25609@opindex msched-max-memory-insns-hard-limit
ddf6fe37 25610@item -msched-max-memory-insns-hard-limit
d77de738
ML
25611Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25612disallowing more than that number in an instruction group.
25613Otherwise, the limit is ``soft'', meaning that non-memory operations
25614are preferred when the limit is reached, but memory operations may still
25615be scheduled.
25616
25617@end table
25618
25619@node LM32 Options
25620@subsection LM32 Options
25621@cindex LM32 options
25622
25623These @option{-m} options are defined for the LatticeMico32 architecture:
25624
25625@table @gcctabopt
d77de738 25626@opindex mbarrel-shift-enabled
ddf6fe37 25627@item -mbarrel-shift-enabled
d77de738
ML
25628Enable barrel-shift instructions.
25629
d77de738 25630@opindex mdivide-enabled
ddf6fe37 25631@item -mdivide-enabled
d77de738
ML
25632Enable divide and modulus instructions.
25633
d77de738 25634@opindex multiply-enabled
ddf6fe37 25635@item -mmultiply-enabled
d77de738
ML
25636Enable multiply instructions.
25637
d77de738 25638@opindex msign-extend-enabled
ddf6fe37 25639@item -msign-extend-enabled
d77de738
ML
25640Enable sign extend instructions.
25641
d77de738 25642@opindex muser-enabled
ddf6fe37 25643@item -muser-enabled
d77de738
ML
25644Enable user-defined instructions.
25645
25646@end table
25647
25648@node LoongArch Options
25649@subsection LoongArch Options
25650@cindex LoongArch Options
25651
25652These command-line options are defined for LoongArch targets:
25653
25654@table @gcctabopt
9c19597c 25655@opindex march
ddf6fe37 25656@item -march=@var{cpu-type}
d77de738
ML
25657Generate instructions for the machine type @var{cpu-type}. In contrast to
25658@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
25659for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
25660to generate code that may not run at all on processors other than the one
25661indicated. Specifying @option{-march=@var{cpu-type}} implies
25662@option{-mtune=@var{cpu-type}}, except where noted otherwise.
25663
25664The choices for @var{cpu-type} are:
25665
25666@table @samp
25667@item native
25668This selects the CPU to generate code for at compilation time by determining
25669the processor type of the compiling machine. Using @option{-march=native}
25670enables all instruction subsets supported by the local machine (hence
25671the result might not run on different machines). Using @option{-mtune=native}
25672produces code optimized for the local machine under the constraints
25673of the selected instruction set.
25674@item loongarch64
25675A generic CPU with 64-bit extensions.
25676@item la464
25677LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
25678@end table
25679
d77de738 25680@opindex mtune
ddf6fe37 25681@item -mtune=@var{cpu-type}
d77de738
ML
25682Optimize the output for the given processor, specified by microarchitecture
25683name.
25684
d77de738 25685@opindex mabi
ddf6fe37 25686@item -mabi=@var{base-abi-type}
d77de738
ML
25687Generate code for the specified calling convention.
25688@var{base-abi-type} can be one of:
25689@table @samp
25690@item lp64d
25691Uses 64-bit general purpose registers and 32/64-bit floating-point
25692registers for parameter passing. Data model is LP64, where @samp{int}
25693is 32 bits, while @samp{long int} and pointers are 64 bits.
25694@item lp64f
25695Uses 64-bit general purpose registers and 32-bit floating-point
25696registers for parameter passing. Data model is LP64, where @samp{int}
25697is 32 bits, while @samp{long int} and pointers are 64 bits.
25698@item lp64s
25699Uses 64-bit general purpose registers and no floating-point
25700registers for parameter passing. Data model is LP64, where @samp{int}
25701is 32 bits, while @samp{long int} and pointers are 64 bits.
25702@end table
25703
d77de738 25704@opindex mfpu
ddf6fe37 25705@item -mfpu=@var{fpu-type}
d77de738
ML
25706Generate code for the specified FPU type, which can be one of:
25707@table @samp
25708@item 64
25709Allow the use of hardware floating-point instructions for 32-bit
25710and 64-bit operations.
25711@item 32
25712Allow the use of hardware floating-point instructions for 32-bit
25713operations.
25714@item none
25715@item 0
25716Prevent the use of hardware floating-point instructions.
25717@end table
25718
d77de738 25719@opindex msoft-float
ddf6fe37 25720@item -msoft-float
d77de738
ML
25721Force @option{-mfpu=none} and prevents the use of floating-point
25722registers for parameter passing. This option may change the target
25723ABI.
25724
9c19597c 25725@opindex msingle-float
ddf6fe37 25726@item -msingle-float
d77de738
ML
25727Force @option{-mfpu=32} and allow the use of 32-bit floating-point
25728registers for parameter passing. This option may change the target
25729ABI.
25730
9c19597c 25731@opindex mdouble-float
ddf6fe37 25732@item -mdouble-float
d77de738
ML
25733Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
25734registers for parameter passing. This option may change the target
25735ABI.
25736
9c19597c 25737@opindex mbranch-cost
ddf6fe37 25738@item -mbranch-cost=@var{n}
d77de738
ML
25739Set the cost of branches to roughly @var{n} instructions.
25740
ddf6fe37 25741@opindex mcheck-zero-division
d77de738
ML
25742@item -mcheck-zero-division
25743@itemx -mno-check-zero-divison
d77de738
ML
25744Trap (do not trap) on integer division by zero. The default is
25745@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
25746@option{-mno-check-zero-division} for other optimization levels.
25747
ddf6fe37 25748@opindex mcond-move-int
d77de738
ML
25749@item -mcond-move-int
25750@itemx -mno-cond-move-int
d77de738
ML
25751Conditional moves for integral data in general-purpose registers
25752are enabled (disabled). The default is @option{-mcond-move-int}.
25753
ddf6fe37 25754@opindex mcond-move-float
d77de738
ML
25755@item -mcond-move-float
25756@itemx -mno-cond-move-float
d77de738
ML
25757Conditional moves for floating-point registers are enabled (disabled).
25758The default is @option{-mcond-move-float}.
25759
ddf6fe37 25760@opindex mmemcpy
d77de738
ML
25761@item -mmemcpy
25762@itemx -mno-memcpy
d77de738
ML
25763Force (do not force) the use of @code{memcpy} for non-trivial block moves.
25764The default is @option{-mno-memcpy}, which allows GCC to inline most
25765constant-sized copies. Setting optimization level to @option{-Os} also
25766forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
25767behavior if explicitly specified, regardless of the order these options on
25768the command line.
25769
ddf6fe37 25770@opindex mstrict-align
d77de738
ML
25771@item -mstrict-align
25772@itemx -mno-strict-align
d77de738
ML
25773Avoid or allow generating memory accesses that may not be aligned on a natural
25774object boundary as described in the architecture specification. The default is
25775@option{-mno-strict-align}.
25776
9c19597c 25777@opindex msmall-data-limit
ddf6fe37 25778@item -msmall-data-limit=@var{number}
d77de738
ML
25779Put global and static data smaller than @var{number} bytes into a special
25780section (on some targets). The default value is 0.
25781
9c19597c 25782@opindex mmax-inline-memcpy-size
ddf6fe37 25783@item -mmax-inline-memcpy-size=@var{n}
d77de738
ML
25784Inline all block moves (such as calls to @code{memcpy} or structure copies)
25785less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
25786
25787@item -mcmodel=@var{code-model}
25788Set the code model to one of:
25789@table @samp
25790@item tiny-static (Not implemented yet)
25791@item tiny (Not implemented yet)
25792
25793@item normal
25794The text segment must be within 128MB addressing space. The data segment must
25795be within 2GB addressing space.
25796
25797@item medium
25798The text segment and data segment must be within 2GB addressing space.
25799
25800@item large (Not implemented yet)
25801
25802@item extreme
25803This mode does not limit the size of the code segment and data segment.
25804The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
25805@option{-mno-explicit-relocs}.
25806@end table
25807The default code model is @code{normal}.
25808
d77de738
ML
25809@opindex mexplicit-relocs
25810@opindex mno-explicit-relocs
ddf6fe37
AA
25811@item -mexplicit-relocs
25812@itemx -mno-explicit-relocs
d77de738
ML
25813Use or do not use assembler relocation operators when dealing with symbolic
25814addresses. The alternative is to use assembler macros instead, which may
25815limit optimization. The default value for the option is determined during
25816GCC build-time by detecting corresponding assembler support:
25817@code{-mexplicit-relocs} if said support is present,
25818@code{-mno-explicit-relocs} otherwise. This option is mostly useful for
25819debugging, or interoperation with assemblers different from the build-time
25820one.
25821
ddf6fe37 25822@opindex mdirect-extern-access
d77de738
ML
25823@item -mdirect-extern-access
25824@itemx -mno-direct-extern-access
d77de738
ML
25825Do not use or use GOT to access external symbols. The default is
25826@option{-mno-direct-extern-access}: GOT is used for external symbols with
25827default visibility, but not used for other external symbols.
25828
25829With @option{-mdirect-extern-access}, GOT is not used and all external
25830symbols are PC-relatively addressed. It is @strong{only} suitable for
25831environments where no dynamic link is performed, like firmwares, OS
25832kernels, executables linked with @option{-static} or @option{-static-pie}.
25833@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
25834@option{-fpic}.
25835@end table
25836
25837@node M32C Options
25838@subsection M32C Options
25839@cindex M32C options
25840
25841@table @gcctabopt
d77de738 25842@opindex mcpu=
ddf6fe37 25843@item -mcpu=@var{name}
d77de738
ML
25844Select the CPU for which code is generated. @var{name} may be one of
25845@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
25846/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
25847the M32C/80 series.
25848
d77de738 25849@opindex msim
ddf6fe37 25850@item -msim
d77de738
ML
25851Specifies that the program will be run on the simulator. This causes
25852an alternate runtime library to be linked in which supports, for
25853example, file I/O@. You must not use this option when generating
25854programs that will run on real hardware; you must provide your own
25855runtime library for whatever I/O functions are needed.
25856
d77de738 25857@opindex memregs=
ddf6fe37 25858@item -memregs=@var{number}
d77de738
ML
25859Specifies the number of memory-based pseudo-registers GCC uses
25860during code generation. These pseudo-registers are used like real
25861registers, so there is a tradeoff between GCC's ability to fit the
25862code into available registers, and the performance penalty of using
25863memory instead of registers. Note that all modules in a program must
25864be compiled with the same value for this option. Because of that, you
25865must not use this option with GCC's default runtime libraries.
25866
25867@end table
25868
25869@node M32R/D Options
25870@subsection M32R/D Options
25871@cindex M32R/D options
25872
25873These @option{-m} options are defined for Renesas M32R/D architectures:
25874
25875@table @gcctabopt
d77de738 25876@opindex m32r2
ddf6fe37 25877@item -m32r2
d77de738
ML
25878Generate code for the M32R/2@.
25879
d77de738 25880@opindex m32rx
ddf6fe37 25881@item -m32rx
d77de738
ML
25882Generate code for the M32R/X@.
25883
d77de738 25884@opindex m32r
ddf6fe37 25885@item -m32r
d77de738
ML
25886Generate code for the M32R@. This is the default.
25887
d77de738 25888@opindex mmodel=small
ddf6fe37 25889@item -mmodel=small
d77de738
ML
25890Assume all objects live in the lower 16MB of memory (so that their addresses
25891can be loaded with the @code{ld24} instruction), and assume all subroutines
25892are reachable with the @code{bl} instruction.
25893This is the default.
25894
25895The addressability of a particular object can be set with the
25896@code{model} attribute.
25897
d77de738 25898@opindex mmodel=medium
ddf6fe37 25899@item -mmodel=medium
d77de738
ML
25900Assume objects may be anywhere in the 32-bit address space (the compiler
25901generates @code{seth/add3} instructions to load their addresses), and
25902assume all subroutines are reachable with the @code{bl} instruction.
25903
d77de738 25904@opindex mmodel=large
ddf6fe37 25905@item -mmodel=large
d77de738
ML
25906Assume objects may be anywhere in the 32-bit address space (the compiler
25907generates @code{seth/add3} instructions to load their addresses), and
25908assume subroutines may not be reachable with the @code{bl} instruction
25909(the compiler generates the much slower @code{seth/add3/jl}
25910instruction sequence).
25911
d77de738 25912@opindex msdata=none
ddf6fe37 25913@item -msdata=none
d77de738
ML
25914Disable use of the small data area. Variables are put into
25915one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
25916@code{section} attribute has been specified).
25917This is the default.
25918
25919The small data area consists of sections @code{.sdata} and @code{.sbss}.
25920Objects may be explicitly put in the small data area with the
25921@code{section} attribute using one of these sections.
25922
d77de738 25923@opindex msdata=sdata
ddf6fe37 25924@item -msdata=sdata
d77de738
ML
25925Put small global and static data in the small data area, but do not
25926generate special code to reference them.
25927
d77de738 25928@opindex msdata=use
ddf6fe37 25929@item -msdata=use
d77de738
ML
25930Put small global and static data in the small data area, and generate
25931special instructions to reference them.
25932
d77de738
ML
25933@opindex G
25934@cindex smaller data references
f33d7a88 25935@item -G @var{num}
d77de738
ML
25936Put global and static objects less than or equal to @var{num} bytes
25937into the small data or BSS sections instead of the normal data or BSS
25938sections. The default value of @var{num} is 8.
25939The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
25940for this option to have any effect.
25941
25942All modules should be compiled with the same @option{-G @var{num}} value.
25943Compiling with different values of @var{num} may or may not work; if it
25944doesn't the linker gives an error message---incorrect code is not
25945generated.
25946
d77de738 25947@opindex mdebug
ddf6fe37 25948@item -mdebug
d77de738
ML
25949Makes the M32R-specific code in the compiler display some statistics
25950that might help in debugging programs.
25951
d77de738 25952@opindex malign-loops
ddf6fe37 25953@item -malign-loops
d77de738
ML
25954Align all loops to a 32-byte boundary.
25955
d77de738 25956@opindex mno-align-loops
ddf6fe37 25957@item -mno-align-loops
d77de738
ML
25958Do not enforce a 32-byte alignment for loops. This is the default.
25959
d77de738 25960@opindex missue-rate=@var{number}
ddf6fe37 25961@item -missue-rate=@var{number}
d77de738
ML
25962Issue @var{number} instructions per cycle. @var{number} can only be 1
25963or 2.
25964
d77de738 25965@opindex mbranch-cost=@var{number}
ddf6fe37 25966@item -mbranch-cost=@var{number}
d77de738
ML
25967@var{number} can only be 1 or 2. If it is 1 then branches are
25968preferred over conditional code, if it is 2, then the opposite applies.
25969
d77de738 25970@opindex mflush-trap=@var{number}
ddf6fe37 25971@item -mflush-trap=@var{number}
d77de738
ML
25972Specifies the trap number to use to flush the cache. The default is
2597312. Valid numbers are between 0 and 15 inclusive.
25974
d77de738 25975@opindex mno-flush-trap
ddf6fe37 25976@item -mno-flush-trap
d77de738
ML
25977Specifies that the cache cannot be flushed by using a trap.
25978
d77de738 25979@opindex mflush-func=@var{name}
ddf6fe37 25980@item -mflush-func=@var{name}
d77de738
ML
25981Specifies the name of the operating system function to call to flush
25982the cache. The default is @samp{_flush_cache}, but a function call
25983is only used if a trap is not available.
25984
d77de738 25985@opindex mno-flush-func
ddf6fe37 25986@item -mno-flush-func
d77de738
ML
25987Indicates that there is no OS function for flushing the cache.
25988
25989@end table
25990
25991@node M680x0 Options
25992@subsection M680x0 Options
25993@cindex M680x0 options
25994
25995These are the @samp{-m} options defined for M680x0 and ColdFire processors.
25996The default settings depend on which architecture was selected when
25997the compiler was configured; the defaults for the most common choices
25998are given below.
25999
26000@table @gcctabopt
d77de738 26001@opindex march
ddf6fe37 26002@item -march=@var{arch}
d77de738
ML
26003Generate code for a specific M680x0 or ColdFire instruction set
26004architecture. Permissible values of @var{arch} for M680x0
26005architectures are: @samp{68000}, @samp{68010}, @samp{68020},
26006@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
26007architectures are selected according to Freescale's ISA classification
26008and the permissible values are: @samp{isaa}, @samp{isaaplus},
26009@samp{isab} and @samp{isac}.
26010
26011GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
26012code for a ColdFire target. The @var{arch} in this macro is one of the
26013@option{-march} arguments given above.
26014
26015When used together, @option{-march} and @option{-mtune} select code
26016that runs on a family of similar processors but that is optimized
26017for a particular microarchitecture.
26018
d77de738 26019@opindex mcpu
ddf6fe37 26020@item -mcpu=@var{cpu}
d77de738
ML
26021Generate code for a specific M680x0 or ColdFire processor.
26022The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
26023@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
26024and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
26025below, which also classifies the CPUs into families:
26026
26027@multitable @columnfractions 0.20 0.80
26028@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
26029@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}
26030@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
26031@item @samp{5206e} @tab @samp{5206e}
26032@item @samp{5208} @tab @samp{5207} @samp{5208}
26033@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
26034@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
26035@item @samp{5216} @tab @samp{5214} @samp{5216}
26036@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
26037@item @samp{5225} @tab @samp{5224} @samp{5225}
26038@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
26039@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
26040@item @samp{5249} @tab @samp{5249}
26041@item @samp{5250} @tab @samp{5250}
26042@item @samp{5271} @tab @samp{5270} @samp{5271}
26043@item @samp{5272} @tab @samp{5272}
26044@item @samp{5275} @tab @samp{5274} @samp{5275}
26045@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
26046@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
26047@item @samp{5307} @tab @samp{5307}
26048@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
26049@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
26050@item @samp{5407} @tab @samp{5407}
26051@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}
26052@end multitable
26053
26054@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
26055@var{arch} is compatible with @var{cpu}. Other combinations of
26056@option{-mcpu} and @option{-march} are rejected.
26057
26058GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
26059@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
26060where the value of @var{family} is given by the table above.
26061
d77de738 26062@opindex mtune
ddf6fe37 26063@item -mtune=@var{tune}
d77de738
ML
26064Tune the code for a particular microarchitecture within the
26065constraints set by @option{-march} and @option{-mcpu}.
26066The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
26067@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
26068and @samp{cpu32}. The ColdFire microarchitectures
26069are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
26070
26071You can also use @option{-mtune=68020-40} for code that needs
26072to run relatively well on 68020, 68030 and 68040 targets.
26073@option{-mtune=68020-60} is similar but includes 68060 targets
26074as well. These two options select the same tuning decisions as
26075@option{-m68020-40} and @option{-m68020-60} respectively.
26076
26077GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
26078when tuning for 680x0 architecture @var{arch}. It also defines
26079@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
26080option is used. If GCC is tuning for a range of architectures,
26081as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
26082it defines the macros for every architecture in the range.
26083
26084GCC also defines the macro @code{__m@var{uarch}__} when tuning for
26085ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
26086of the arguments given above.
26087
d77de738
ML
26088@opindex m68000
26089@opindex mc68000
ddf6fe37
AA
26090@item -m68000
26091@itemx -mc68000
d77de738
ML
26092Generate output for a 68000. This is the default
26093when the compiler is configured for 68000-based systems.
26094It is equivalent to @option{-march=68000}.
26095
26096Use this option for microcontrollers with a 68000 or EC000 core,
26097including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
26098
d77de738 26099@opindex m68010
ddf6fe37 26100@item -m68010
d77de738
ML
26101Generate output for a 68010. This is the default
26102when the compiler is configured for 68010-based systems.
26103It is equivalent to @option{-march=68010}.
26104
d77de738
ML
26105@opindex m68020
26106@opindex mc68020
ddf6fe37
AA
26107@item -m68020
26108@itemx -mc68020
d77de738
ML
26109Generate output for a 68020. This is the default
26110when the compiler is configured for 68020-based systems.
26111It is equivalent to @option{-march=68020}.
26112
d77de738 26113@opindex m68030
ddf6fe37 26114@item -m68030
d77de738
ML
26115Generate output for a 68030. This is the default when the compiler is
26116configured for 68030-based systems. It is equivalent to
26117@option{-march=68030}.
26118
d77de738 26119@opindex m68040
ddf6fe37 26120@item -m68040
d77de738
ML
26121Generate output for a 68040. This is the default when the compiler is
26122configured for 68040-based systems. It is equivalent to
26123@option{-march=68040}.
26124
26125This option inhibits the use of 68881/68882 instructions that have to be
26126emulated by software on the 68040. Use this option if your 68040 does not
26127have code to emulate those instructions.
26128
d77de738 26129@opindex m68060
ddf6fe37 26130@item -m68060
d77de738
ML
26131Generate output for a 68060. This is the default when the compiler is
26132configured for 68060-based systems. It is equivalent to
26133@option{-march=68060}.
26134
26135This option inhibits the use of 68020 and 68881/68882 instructions that
26136have to be emulated by software on the 68060. Use this option if your 68060
26137does not have code to emulate those instructions.
26138
d77de738 26139@opindex mcpu32
ddf6fe37 26140@item -mcpu32
d77de738
ML
26141Generate output for a CPU32. This is the default
26142when the compiler is configured for CPU32-based systems.
26143It is equivalent to @option{-march=cpu32}.
26144
26145Use this option for microcontrollers with a
26146CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2614768336, 68340, 68341, 68349 and 68360.
26148
d77de738 26149@opindex m5200
ddf6fe37 26150@item -m5200
d77de738
ML
26151Generate output for a 520X ColdFire CPU@. This is the default
26152when the compiler is configured for 520X-based systems.
26153It is equivalent to @option{-mcpu=5206}, and is now deprecated
26154in favor of that option.
26155
26156Use this option for microcontroller with a 5200 core, including
26157the MCF5202, MCF5203, MCF5204 and MCF5206.
26158
d77de738 26159@opindex m5206e
ddf6fe37 26160@item -m5206e
d77de738
ML
26161Generate output for a 5206e ColdFire CPU@. The option is now
26162deprecated in favor of the equivalent @option{-mcpu=5206e}.
26163
d77de738 26164@opindex m528x
ddf6fe37 26165@item -m528x
d77de738
ML
26166Generate output for a member of the ColdFire 528X family.
26167The option is now deprecated in favor of the equivalent
26168@option{-mcpu=528x}.
26169
d77de738 26170@opindex m5307
ddf6fe37 26171@item -m5307
d77de738
ML
26172Generate output for a ColdFire 5307 CPU@. The option is now deprecated
26173in favor of the equivalent @option{-mcpu=5307}.
26174
d77de738 26175@opindex m5407
ddf6fe37 26176@item -m5407
d77de738
ML
26177Generate output for a ColdFire 5407 CPU@. The option is now deprecated
26178in favor of the equivalent @option{-mcpu=5407}.
26179
d77de738 26180@opindex mcfv4e
ddf6fe37 26181@item -mcfv4e
d77de738
ML
26182Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
26183This includes use of hardware floating-point instructions.
26184The option is equivalent to @option{-mcpu=547x}, and is now
26185deprecated in favor of that option.
26186
d77de738 26187@opindex m68020-40
ddf6fe37 26188@item -m68020-40
d77de738
ML
26189Generate output for a 68040, without using any of the new instructions.
26190This results in code that can run relatively efficiently on either a
2619168020/68881 or a 68030 or a 68040. The generated code does use the
2619268881 instructions that are emulated on the 68040.
26193
26194The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26195
d77de738 26196@opindex m68020-60
ddf6fe37 26197@item -m68020-60
d77de738
ML
26198Generate output for a 68060, without using any of the new instructions.
26199This results in code that can run relatively efficiently on either a
2620068020/68881 or a 68030 or a 68040. The generated code does use the
2620168881 instructions that are emulated on the 68060.
26202
26203The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26204
d77de738
ML
26205@opindex mhard-float
26206@opindex m68881
ddf6fe37
AA
26207@item -mhard-float
26208@itemx -m68881
d77de738
ML
26209Generate floating-point instructions. This is the default for 68020
26210and above, and for ColdFire devices that have an FPU@. It defines the
26211macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26212on ColdFire targets.
26213
d77de738 26214@opindex msoft-float
ddf6fe37 26215@item -msoft-float
d77de738
ML
26216Do not generate floating-point instructions; use library calls instead.
26217This is the default for 68000, 68010, and 68832 targets. It is also
26218the default for ColdFire devices that have no FPU.
26219
d77de738
ML
26220@opindex mdiv
26221@opindex mno-div
ddf6fe37
AA
26222@item -mdiv
26223@itemx -mno-div
d77de738
ML
26224Generate (do not generate) ColdFire hardware divide and remainder
26225instructions. If @option{-march} is used without @option{-mcpu},
26226the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26227architectures. Otherwise, the default is taken from the target CPU
26228(either the default CPU, or the one specified by @option{-mcpu}). For
26229example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26230@option{-mcpu=5206e}.
26231
26232GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26233
d77de738 26234@opindex mshort
ddf6fe37 26235@item -mshort
d77de738
ML
26236Consider type @code{int} to be 16 bits wide, like @code{short int}.
26237Additionally, parameters passed on the stack are also aligned to a
2623816-bit boundary even on targets whose API mandates promotion to 32-bit.
26239
d77de738 26240@opindex mno-short
ddf6fe37 26241@item -mno-short
d77de738
ML
26242Do not consider type @code{int} to be 16 bits wide. This is the default.
26243
d77de738
ML
26244@opindex mnobitfield
26245@opindex mno-bitfield
ddf6fe37
AA
26246@item -mnobitfield
26247@itemx -mno-bitfield
d77de738
ML
26248Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26249and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26250
d77de738 26251@opindex mbitfield
ddf6fe37 26252@item -mbitfield
d77de738
ML
26253Do use the bit-field instructions. The @option{-m68020} option implies
26254@option{-mbitfield}. This is the default if you use a configuration
26255designed for a 68020.
26256
d77de738 26257@opindex mrtd
ddf6fe37 26258@item -mrtd
d77de738
ML
26259Use a different function-calling convention, in which functions
26260that take a fixed number of arguments return with the @code{rtd}
26261instruction, which pops their arguments while returning. This
26262saves one instruction in the caller since there is no need to pop
26263the arguments there.
26264
26265This calling convention is incompatible with the one normally
26266used on Unix, so you cannot use it if you need to call libraries
26267compiled with the Unix compiler.
26268
26269Also, you must provide function prototypes for all functions that
26270take variable numbers of arguments (including @code{printf});
26271otherwise incorrect code is generated for calls to those
26272functions.
26273
26274In addition, seriously incorrect code results if you call a
26275function with too many arguments. (Normally, extra arguments are
26276harmlessly ignored.)
26277
26278The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2627968040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26280
26281The default is @option{-mno-rtd}.
26282
d77de738
ML
26283@opindex malign-int
26284@opindex mno-align-int
ddf6fe37
AA
26285@item -malign-int
26286@itemx -mno-align-int
d77de738
ML
26287Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26288@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26289boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26290Aligning variables on 32-bit boundaries produces code that runs somewhat
26291faster on processors with 32-bit busses at the expense of more memory.
26292
26293@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26294aligns structures containing the above types differently than
26295most published application binary interface specifications for the m68k.
26296
26297@opindex mpcrel
26298Use the pc-relative addressing mode of the 68000 directly, instead of
26299using a global offset table. At present, this option implies @option{-fpic},
26300allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26301not presently supported with @option{-mpcrel}, though this could be supported for
2630268020 and higher processors.
26303
d77de738
ML
26304@opindex mno-strict-align
26305@opindex mstrict-align
ddf6fe37
AA
26306@item -mno-strict-align
26307@itemx -mstrict-align
d77de738
ML
26308Do not (do) assume that unaligned memory references are handled by
26309the system.
26310
26311@item -msep-data
26312Generate code that allows the data segment to be located in a different
26313area of memory from the text segment. This allows for execute-in-place in
26314an environment without virtual memory management. This option implies
26315@option{-fPIC}.
26316
26317@item -mno-sep-data
26318Generate code that assumes that the data segment follows the text segment.
26319This is the default.
26320
26321@item -mid-shared-library
26322Generate code that supports shared libraries via the library ID method.
26323This allows for execute-in-place and shared libraries in an environment
26324without virtual memory management. This option implies @option{-fPIC}.
26325
26326@item -mno-id-shared-library
26327Generate code that doesn't assume ID-based shared libraries are being used.
26328This is the default.
26329
26330@item -mshared-library-id=n
26331Specifies the identification number of the ID-based shared library being
26332compiled. Specifying a value of 0 generates more compact code; specifying
26333other values forces the allocation of that number to the current
26334library, but is no more space- or time-efficient than omitting this option.
26335
d77de738
ML
26336@opindex mxgot
26337@opindex mno-xgot
ddf6fe37
AA
26338@item -mxgot
26339@itemx -mno-xgot
d77de738
ML
26340When generating position-independent code for ColdFire, generate code
26341that works if the GOT has more than 8192 entries. This code is
26342larger and slower than code generated without this option. On M680x0
26343processors, this option is not needed; @option{-fPIC} suffices.
26344
26345GCC normally uses a single instruction to load values from the GOT@.
26346While this is relatively efficient, it only works if the GOT
26347is smaller than about 64k. Anything larger causes the linker
26348to report an error such as:
26349
26350@cindex relocation truncated to fit (ColdFire)
26351@smallexample
26352relocation truncated to fit: R_68K_GOT16O foobar
26353@end smallexample
26354
26355If this happens, you should recompile your code with @option{-mxgot}.
26356It should then work with very large GOTs. However, code generated with
26357@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26358the value of a global symbol.
26359
26360Note that some linkers, including newer versions of the GNU linker,
26361can create multiple GOTs and sort GOT entries. If you have such a linker,
26362you should only need to use @option{-mxgot} when compiling a single
26363object file that accesses more than 8192 GOT entries. Very few do.
26364
26365These options have no effect unless GCC is generating
26366position-independent code.
26367
d77de738 26368@opindex mlong-jump-table-offsets
ddf6fe37 26369@item -mlong-jump-table-offsets
d77de738
ML
26370Use 32-bit offsets in @code{switch} tables. The default is to use
2637116-bit offsets.
26372
26373@end table
26374
26375@node MCore Options
26376@subsection MCore Options
26377@cindex MCore options
26378
26379These are the @samp{-m} options defined for the Motorola M*Core
26380processors.
26381
26382@table @gcctabopt
26383
d77de738
ML
26384@opindex mhardlit
26385@opindex mno-hardlit
ddf6fe37
AA
26386@item -mhardlit
26387@itemx -mno-hardlit
d77de738
ML
26388Inline constants into the code stream if it can be done in two
26389instructions or less.
26390
d77de738
ML
26391@opindex mdiv
26392@opindex mno-div
ddf6fe37
AA
26393@item -mdiv
26394@itemx -mno-div
d77de738
ML
26395Use the divide instruction. (Enabled by default).
26396
d77de738
ML
26397@opindex mrelax-immediate
26398@opindex mno-relax-immediate
ddf6fe37
AA
26399@item -mrelax-immediate
26400@itemx -mno-relax-immediate
d77de738
ML
26401Allow arbitrary-sized immediates in bit operations.
26402
d77de738
ML
26403@opindex mwide-bitfields
26404@opindex mno-wide-bitfields
ddf6fe37
AA
26405@item -mwide-bitfields
26406@itemx -mno-wide-bitfields
d77de738
ML
26407Always treat bit-fields as @code{int}-sized.
26408
d77de738
ML
26409@opindex m4byte-functions
26410@opindex mno-4byte-functions
ddf6fe37
AA
26411@item -m4byte-functions
26412@itemx -mno-4byte-functions
d77de738
ML
26413Force all functions to be aligned to a 4-byte boundary.
26414
d77de738
ML
26415@opindex mcallgraph-data
26416@opindex mno-callgraph-data
ddf6fe37
AA
26417@item -mcallgraph-data
26418@itemx -mno-callgraph-data
d77de738
ML
26419Emit callgraph information.
26420
d77de738
ML
26421@opindex mslow-bytes
26422@opindex mno-slow-bytes
ddf6fe37
AA
26423@item -mslow-bytes
26424@itemx -mno-slow-bytes
d77de738
ML
26425Prefer word access when reading byte quantities.
26426
d77de738
ML
26427@opindex mlittle-endian
26428@opindex mbig-endian
ddf6fe37
AA
26429@item -mlittle-endian
26430@itemx -mbig-endian
d77de738
ML
26431Generate code for a little-endian target.
26432
d77de738
ML
26433@opindex m210
26434@opindex m340
ddf6fe37
AA
26435@item -m210
26436@itemx -m340
d77de738
ML
26437Generate code for the 210 processor.
26438
d77de738 26439@opindex mno-lsim
ddf6fe37 26440@item -mno-lsim
d77de738
ML
26441Assume that runtime support has been provided and so omit the
26442simulator library (@file{libsim.a)} from the linker command line.
26443
d77de738 26444@opindex mstack-increment
ddf6fe37 26445@item -mstack-increment=@var{size}
d77de738
ML
26446Set the maximum amount for a single stack increment operation. Large
26447values can increase the speed of programs that contain functions
26448that need a large amount of stack space, but they can also trigger a
26449segmentation fault if the stack is extended too much. The default
26450value is 0x1000.
26451
26452@end table
26453
d77de738
ML
26454@node MicroBlaze Options
26455@subsection MicroBlaze Options
26456@cindex MicroBlaze Options
26457
26458@table @gcctabopt
26459
d77de738 26460@opindex msoft-float
ddf6fe37 26461@item -msoft-float
d77de738
ML
26462Use software emulation for floating point (default).
26463
d77de738 26464@opindex mhard-float
ddf6fe37 26465@item -mhard-float
d77de738
ML
26466Use hardware floating-point instructions.
26467
d77de738 26468@opindex mmemcpy
ddf6fe37 26469@item -mmemcpy
d77de738
ML
26470Do not optimize block moves, use @code{memcpy}.
26471
d77de738 26472@opindex mno-clearbss
ddf6fe37 26473@item -mno-clearbss
d77de738
ML
26474This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26475
d77de738 26476@opindex mcpu=
ddf6fe37 26477@item -mcpu=@var{cpu-type}
d77de738
ML
26478Use features of, and schedule code for, the given CPU.
26479Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26480where @var{X} is a major version, @var{YY} is the minor version, and
26481@var{Z} is compatibility code. Example values are @samp{v3.00.a},
26482@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26483
d77de738 26484@opindex mxl-soft-mul
ddf6fe37 26485@item -mxl-soft-mul
d77de738
ML
26486Use software multiply emulation (default).
26487
d77de738 26488@opindex mxl-soft-div
ddf6fe37 26489@item -mxl-soft-div
d77de738
ML
26490Use software emulation for divides (default).
26491
d77de738 26492@opindex mxl-barrel-shift
ddf6fe37 26493@item -mxl-barrel-shift
d77de738
ML
26494Use the hardware barrel shifter.
26495
d77de738 26496@opindex mxl-pattern-compare
ddf6fe37 26497@item -mxl-pattern-compare
d77de738
ML
26498Use pattern compare instructions.
26499
d77de738 26500@opindex msmall-divides
ddf6fe37 26501@item -msmall-divides
d77de738
ML
26502Use table lookup optimization for small signed integer divisions.
26503
d77de738 26504@opindex mxl-stack-check
ddf6fe37 26505@item -mxl-stack-check
d77de738
ML
26506This option is deprecated. Use @option{-fstack-check} instead.
26507
d77de738 26508@opindex mxl-gp-opt
ddf6fe37 26509@item -mxl-gp-opt
d77de738
ML
26510Use GP-relative @code{.sdata}/@code{.sbss} sections.
26511
d77de738 26512@opindex mxl-multiply-high
ddf6fe37 26513@item -mxl-multiply-high
d77de738
ML
26514Use multiply high instructions for high part of 32x32 multiply.
26515
d77de738 26516@opindex mxl-float-convert
ddf6fe37 26517@item -mxl-float-convert
d77de738
ML
26518Use hardware floating-point conversion instructions.
26519
d77de738 26520@opindex mxl-float-sqrt
ddf6fe37 26521@item -mxl-float-sqrt
d77de738
ML
26522Use hardware floating-point square root instruction.
26523
d77de738 26524@opindex mbig-endian
ddf6fe37 26525@item -mbig-endian
d77de738
ML
26526Generate code for a big-endian target.
26527
d77de738 26528@opindex mlittle-endian
ddf6fe37 26529@item -mlittle-endian
d77de738
ML
26530Generate code for a little-endian target.
26531
d77de738 26532@opindex mxl-reorder
ddf6fe37 26533@item -mxl-reorder
d77de738
ML
26534Use reorder instructions (swap and byte reversed load/store).
26535
26536@item -mxl-mode-@var{app-model}
26537Select application model @var{app-model}. Valid models are
26538@table @samp
26539@item executable
26540normal executable (default), uses startup code @file{crt0.o}.
26541
26542@item xmdstub
26543for use with Xilinx Microprocessor Debugger (XMD) based
26544software intrusive debug agent called xmdstub. This uses startup file
26545@file{crt1.o} and sets the start address of the program to 0x800.
26546
26547@item bootstrap
26548for applications that are loaded using a bootloader.
26549This model uses startup file @file{crt2.o} which does not contain a processor
26550reset vector handler. This is suitable for transferring control on a
26551processor reset to the bootloader rather than the application.
26552
26553@item novectors
26554for applications that do not require any of the
26555MicroBlaze vectors. This option may be useful for applications running
26556within a monitoring application. This model uses @file{crt3.o} as a startup file.
26557@end table
26558
26559Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26560@option{-mxl-mode-@var{app-model}}.
26561
d77de738 26562@opindex mpic-data-is-text-relative
ddf6fe37 26563@item -mpic-data-is-text-relative
d77de738
ML
26564Assume that the displacement between the text and data segments is fixed
26565at static link time. This allows data to be referenced by offset from start of
26566text address instead of GOT since PC-relative addressing is not supported.
26567
26568@end table
26569
26570@node MIPS Options
26571@subsection MIPS Options
26572@cindex MIPS options
26573
26574@table @gcctabopt
26575
d77de738 26576@opindex EB
ddf6fe37 26577@item -EB
d77de738
ML
26578Generate big-endian code.
26579
d77de738 26580@opindex EL
ddf6fe37 26581@item -EL
d77de738
ML
26582Generate little-endian code. This is the default for @samp{mips*el-*-*}
26583configurations.
26584
d77de738 26585@opindex march
ddf6fe37 26586@item -march=@var{arch}
d77de738
ML
26587Generate code that runs on @var{arch}, which can be the name of a
26588generic MIPS ISA, or the name of a particular processor.
26589The ISA names are:
26590@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26591@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26592@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26593@samp{mips64r5} and @samp{mips64r6}.
26594The processor names are:
26595@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26596@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26597@samp{5kc}, @samp{5kf},
26598@samp{20kc},
26599@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26600@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26601@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26602@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26603@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26604@samp{i6400}, @samp{i6500},
26605@samp{interaptiv},
26606@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
26607@samp{gs464e}, @samp{gs264e},
26608@samp{m4k},
26609@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
26610@samp{m5100}, @samp{m5101},
26611@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
26612@samp{orion},
26613@samp{p5600}, @samp{p6600},
26614@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
26615@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
26616@samp{r6000}, @samp{r8000},
26617@samp{rm7000}, @samp{rm9000},
26618@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
26619@samp{sb1},
26620@samp{sr71000},
26621@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
26622@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
26623@samp{xlr} and @samp{xlp}.
26624The special value @samp{from-abi} selects the
26625most compatible architecture for the selected ABI (that is,
26626@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
26627
26628The native Linux/GNU toolchain also supports the value @samp{native},
26629which selects the best architecture option for the host processor.
26630@option{-march=native} has no effect if GCC does not recognize
26631the processor.
26632
26633In processor names, a final @samp{000} can be abbreviated as @samp{k}
26634(for example, @option{-march=r2k}). Prefixes are optional, and
26635@samp{vr} may be written @samp{r}.
26636
26637Names of the form @samp{@var{n}f2_1} refer to processors with
26638FPUs clocked at half the rate of the core, names of the form
26639@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
26640rate as the core, and names of the form @samp{@var{n}f3_2} refer to
26641processors with FPUs clocked a ratio of 3:2 with respect to the core.
26642For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
26643for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
26644accepted as synonyms for @samp{@var{n}f1_1}.
26645
26646GCC defines two macros based on the value of this option. The first
26647is @code{_MIPS_ARCH}, which gives the name of target architecture, as
26648a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
26649where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
26650For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
26651to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
26652
26653Note that the @code{_MIPS_ARCH} macro uses the processor names given
26654above. In other words, it has the full prefix and does not
26655abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
26656the macro names the resolved architecture (either @code{"mips1"} or
26657@code{"mips3"}). It names the default architecture when no
26658@option{-march} option is given.
26659
d77de738 26660@opindex mtune
ddf6fe37 26661@item -mtune=@var{arch}
d77de738
ML
26662Optimize for @var{arch}. Among other things, this option controls
26663the way instructions are scheduled, and the perceived cost of arithmetic
26664operations. The list of @var{arch} values is the same as for
26665@option{-march}.
26666
26667When this option is not used, GCC optimizes for the processor
26668specified by @option{-march}. By using @option{-march} and
26669@option{-mtune} together, it is possible to generate code that
26670runs on a family of processors, but optimize the code for one
26671particular member of that family.
26672
26673@option{-mtune} defines the macros @code{_MIPS_TUNE} and
26674@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
26675@option{-march} ones described above.
26676
d77de738 26677@opindex mips1
ddf6fe37 26678@item -mips1
d77de738
ML
26679Equivalent to @option{-march=mips1}.
26680
d77de738 26681@opindex mips2
ddf6fe37 26682@item -mips2
d77de738
ML
26683Equivalent to @option{-march=mips2}.
26684
d77de738 26685@opindex mips3
ddf6fe37 26686@item -mips3
d77de738
ML
26687Equivalent to @option{-march=mips3}.
26688
d77de738 26689@opindex mips4
ddf6fe37 26690@item -mips4
d77de738
ML
26691Equivalent to @option{-march=mips4}.
26692
d77de738 26693@opindex mips32
ddf6fe37 26694@item -mips32
d77de738
ML
26695Equivalent to @option{-march=mips32}.
26696
d77de738 26697@opindex mips32r3
ddf6fe37 26698@item -mips32r3
d77de738
ML
26699Equivalent to @option{-march=mips32r3}.
26700
d77de738 26701@opindex mips32r5
ddf6fe37 26702@item -mips32r5
d77de738
ML
26703Equivalent to @option{-march=mips32r5}.
26704
d77de738 26705@opindex mips32r6
ddf6fe37 26706@item -mips32r6
d77de738
ML
26707Equivalent to @option{-march=mips32r6}.
26708
d77de738 26709@opindex mips64
ddf6fe37 26710@item -mips64
d77de738
ML
26711Equivalent to @option{-march=mips64}.
26712
d77de738 26713@opindex mips64r2
ddf6fe37 26714@item -mips64r2
d77de738
ML
26715Equivalent to @option{-march=mips64r2}.
26716
d77de738 26717@opindex mips64r3
ddf6fe37 26718@item -mips64r3
d77de738
ML
26719Equivalent to @option{-march=mips64r3}.
26720
d77de738 26721@opindex mips64r5
ddf6fe37 26722@item -mips64r5
d77de738
ML
26723Equivalent to @option{-march=mips64r5}.
26724
d77de738 26725@opindex mips64r6
ddf6fe37 26726@item -mips64r6
d77de738
ML
26727Equivalent to @option{-march=mips64r6}.
26728
d77de738
ML
26729@opindex mips16
26730@opindex mno-mips16
ddf6fe37
AA
26731@item -mips16
26732@itemx -mno-mips16
d77de738
ML
26733Generate (do not generate) MIPS16 code. If GCC is targeting a
26734MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
26735
26736MIPS16 code generation can also be controlled on a per-function basis
26737by means of @code{mips16} and @code{nomips16} attributes.
26738@xref{Function Attributes}, for more information.
26739
d77de738 26740@opindex mflip-mips16
ddf6fe37 26741@item -mflip-mips16
d77de738
ML
26742Generate MIPS16 code on alternating functions. This option is provided
26743for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
26744not intended for ordinary use in compiling user code.
26745
d77de738
ML
26746@opindex minterlink-compressed
26747@opindex mno-interlink-compressed
ddf6fe37
AA
26748@item -minterlink-compressed
26749@itemx -mno-interlink-compressed
d77de738
ML
26750Require (do not require) that code using the standard (uncompressed) MIPS ISA
26751be link-compatible with MIPS16 and microMIPS code, and vice versa.
26752
26753For example, code using the standard ISA encoding cannot jump directly
26754to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
26755@option{-minterlink-compressed} therefore disables direct jumps unless GCC
26756knows that the target of the jump is not compressed.
26757
d77de738
ML
26758@opindex minterlink-mips16
26759@opindex mno-interlink-mips16
ddf6fe37
AA
26760@item -minterlink-mips16
26761@itemx -mno-interlink-mips16
d77de738
ML
26762Aliases of @option{-minterlink-compressed} and
26763@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
26764and are retained for backwards compatibility.
26765
d77de738
ML
26766@opindex mabi=32
26767@opindex mabi=o64
26768@opindex mabi=n32
26769@opindex mabi=64
26770@opindex mabi=eabi
ddf6fe37
AA
26771@item -mabi=32
26772@itemx -mabi=o64
26773@itemx -mabi=n32
26774@itemx -mabi=64
26775@itemx -mabi=eabi
d77de738
ML
26776Generate code for the given ABI@.
26777
26778Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
26779generates 64-bit code when you select a 64-bit architecture, but you
26780can use @option{-mgp32} to get 32-bit code instead.
26781
26782For information about the O64 ABI, see
26783@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
26784
26785GCC supports a variant of the o32 ABI in which floating-point registers
26786are 64 rather than 32 bits wide. You can select this combination with
26787@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
26788and @code{mfhc1} instructions and is therefore only supported for
26789MIPS32R2, MIPS32R3 and MIPS32R5 processors.
26790
26791The register assignments for arguments and return values remain the
26792same, but each scalar value is passed in a single 64-bit register
26793rather than a pair of 32-bit registers. For example, scalar
26794floating-point values are returned in @samp{$f0} only, not a
26795@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
26796remains the same in that the even-numbered double-precision registers
26797are saved.
26798
26799Two additional variants of the o32 ABI are supported to enable
26800a transition from 32-bit to 64-bit registers. These are FPXX
26801(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
26802The FPXX extension mandates that all code must execute correctly
26803when run using 32-bit or 64-bit registers. The code can be interlinked
26804with either FP32 or FP64, but not both.
26805The FP64A extension is similar to the FP64 extension but forbids the
26806use of odd-numbered single-precision registers. This can be used
26807in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
26808processors and allows both FP32 and FP64A code to interlink and
26809run in the same process without changing FPU modes.
26810
d77de738
ML
26811@opindex mabicalls
26812@opindex mno-abicalls
ddf6fe37
AA
26813@item -mabicalls
26814@itemx -mno-abicalls
d77de738
ML
26815Generate (do not generate) code that is suitable for SVR4-style
26816dynamic objects. @option{-mabicalls} is the default for SVR4-based
26817systems.
26818
26819@item -mshared
26820@itemx -mno-shared
26821Generate (do not generate) code that is fully position-independent,
26822and that can therefore be linked into shared libraries. This option
26823only affects @option{-mabicalls}.
26824
26825All @option{-mabicalls} code has traditionally been position-independent,
26826regardless of options like @option{-fPIC} and @option{-fpic}. However,
26827as an extension, the GNU toolchain allows executables to use absolute
26828accesses for locally-binding symbols. It can also use shorter GP
26829initialization sequences and generate direct calls to locally-defined
26830functions. This mode is selected by @option{-mno-shared}.
26831
26832@option{-mno-shared} depends on binutils 2.16 or higher and generates
26833objects that can only be linked by the GNU linker. However, the option
26834does not affect the ABI of the final executable; it only affects the ABI
26835of relocatable objects. Using @option{-mno-shared} generally makes
26836executables both smaller and quicker.
26837
26838@option{-mshared} is the default.
26839
d77de738
ML
26840@opindex mplt
26841@opindex mno-plt
ddf6fe37
AA
26842@item -mplt
26843@itemx -mno-plt
d77de738
ML
26844Assume (do not assume) that the static and dynamic linkers
26845support PLTs and copy relocations. This option only affects
26846@option{-mno-shared -mabicalls}. For the n64 ABI, this option
26847has no effect without @option{-msym32}.
26848
26849You can make @option{-mplt} the default by configuring
26850GCC with @option{--with-mips-plt}. The default is
26851@option{-mno-plt} otherwise.
26852
d77de738
ML
26853@opindex mxgot
26854@opindex mno-xgot
ddf6fe37
AA
26855@item -mxgot
26856@itemx -mno-xgot
d77de738
ML
26857Lift (do not lift) the usual restrictions on the size of the global
26858offset table.
26859
26860GCC normally uses a single instruction to load values from the GOT@.
26861While this is relatively efficient, it only works if the GOT
26862is smaller than about 64k. Anything larger causes the linker
26863to report an error such as:
26864
26865@cindex relocation truncated to fit (MIPS)
26866@smallexample
26867relocation truncated to fit: R_MIPS_GOT16 foobar
26868@end smallexample
26869
26870If this happens, you should recompile your code with @option{-mxgot}.
26871This works with very large GOTs, although the code is also
26872less efficient, since it takes three instructions to fetch the
26873value of a global symbol.
26874
26875Note that some linkers can create multiple GOTs. If you have such a
26876linker, you should only need to use @option{-mxgot} when a single object
26877file accesses more than 64k's worth of GOT entries. Very few do.
26878
26879These options have no effect unless GCC is generating position
26880independent code.
26881
d77de738 26882@opindex mgp32
ddf6fe37 26883@item -mgp32
d77de738
ML
26884Assume that general-purpose registers are 32 bits wide.
26885
d77de738 26886@opindex mgp64
ddf6fe37 26887@item -mgp64
d77de738
ML
26888Assume that general-purpose registers are 64 bits wide.
26889
d77de738 26890@opindex mfp32
ddf6fe37 26891@item -mfp32
d77de738
ML
26892Assume that floating-point registers are 32 bits wide.
26893
d77de738 26894@opindex mfp64
ddf6fe37 26895@item -mfp64
d77de738
ML
26896Assume that floating-point registers are 64 bits wide.
26897
d77de738 26898@opindex mfpxx
ddf6fe37 26899@item -mfpxx
d77de738
ML
26900Do not assume the width of floating-point registers.
26901
d77de738 26902@opindex mhard-float
ddf6fe37 26903@item -mhard-float
d77de738
ML
26904Use floating-point coprocessor instructions.
26905
d77de738 26906@opindex msoft-float
ddf6fe37 26907@item -msoft-float
d77de738
ML
26908Do not use floating-point coprocessor instructions. Implement
26909floating-point calculations using library calls instead.
26910
d77de738 26911@opindex mno-float
ddf6fe37 26912@item -mno-float
d77de738
ML
26913Equivalent to @option{-msoft-float}, but additionally asserts that the
26914program being compiled does not perform any floating-point operations.
26915This option is presently supported only by some bare-metal MIPS
26916configurations, where it may select a special set of libraries
26917that lack all floating-point support (including, for example, the
26918floating-point @code{printf} formats).
26919If code compiled with @option{-mno-float} accidentally contains
26920floating-point operations, it is likely to suffer a link-time
26921or run-time failure.
26922
d77de738 26923@opindex msingle-float
ddf6fe37 26924@item -msingle-float
d77de738
ML
26925Assume that the floating-point coprocessor only supports single-precision
26926operations.
26927
d77de738 26928@opindex mdouble-float
ddf6fe37 26929@item -mdouble-float
d77de738
ML
26930Assume that the floating-point coprocessor supports double-precision
26931operations. This is the default.
26932
d77de738
ML
26933@opindex modd-spreg
26934@opindex mno-odd-spreg
ddf6fe37
AA
26935@item -modd-spreg
26936@itemx -mno-odd-spreg
d77de738
ML
26937Enable the use of odd-numbered single-precision floating-point registers
26938for the o32 ABI. This is the default for processors that are known to
26939support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
26940is set by default.
26941
d77de738
ML
26942@opindex mabs=2008
26943@opindex mabs=legacy
ddf6fe37
AA
26944@item -mabs=2008
26945@itemx -mabs=legacy
d77de738
ML
26946These options control the treatment of the special not-a-number (NaN)
26947IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
26948@code{neg.@i{fmt}} machine instructions.
26949
26950By default or when @option{-mabs=legacy} is used the legacy
26951treatment is selected. In this case these instructions are considered
26952arithmetic and avoided where correct operation is required and the
26953input operand might be a NaN. A longer sequence of instructions that
26954manipulate the sign bit of floating-point datum manually is used
26955instead unless the @option{-ffinite-math-only} option has also been
26956specified.
26957
26958The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
26959this case these instructions are considered non-arithmetic and therefore
26960operating correctly in all cases, including in particular where the
26961input operand is a NaN. These instructions are therefore always used
26962for the respective operations.
26963
d77de738
ML
26964@opindex mnan=2008
26965@opindex mnan=legacy
ddf6fe37
AA
26966@item -mnan=2008
26967@itemx -mnan=legacy
d77de738
ML
26968These options control the encoding of the special not-a-number (NaN)
26969IEEE 754 floating-point data.
26970
26971The @option{-mnan=legacy} option selects the legacy encoding. In this
26972case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
26973significand field being 0, whereas signaling NaNs (sNaNs) are denoted
26974by the first bit of their trailing significand field being 1.
26975
26976The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
26977this case qNaNs are denoted by the first bit of their trailing
26978significand field being 1, whereas sNaNs are denoted by the first bit of
26979their trailing significand field being 0.
26980
26981The default is @option{-mnan=legacy} unless GCC has been configured with
26982@option{--with-nan=2008}.
26983
d77de738
ML
26984@opindex mllsc
26985@opindex mno-llsc
ddf6fe37
AA
26986@item -mllsc
26987@itemx -mno-llsc
d77de738
ML
26988Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
26989implement atomic memory built-in functions. When neither option is
26990specified, GCC uses the instructions if the target architecture
26991supports them.
26992
26993@option{-mllsc} is useful if the runtime environment can emulate the
26994instructions and @option{-mno-llsc} can be useful when compiling for
26995nonstandard ISAs. You can make either option the default by
26996configuring GCC with @option{--with-llsc} and @option{--without-llsc}
26997respectively. @option{--with-llsc} is the default for some
26998configurations; see the installation documentation for details.
26999
d77de738
ML
27000@opindex mdsp
27001@opindex mno-dsp
ddf6fe37
AA
27002@item -mdsp
27003@itemx -mno-dsp
d77de738
ML
27004Use (do not use) revision 1 of the MIPS DSP ASE@.
27005@xref{MIPS DSP Built-in Functions}. This option defines the
27006preprocessor macro @code{__mips_dsp}. It also defines
27007@code{__mips_dsp_rev} to 1.
27008
d77de738
ML
27009@opindex mdspr2
27010@opindex mno-dspr2
ddf6fe37
AA
27011@item -mdspr2
27012@itemx -mno-dspr2
d77de738
ML
27013Use (do not use) revision 2 of the MIPS DSP ASE@.
27014@xref{MIPS DSP Built-in Functions}. This option defines the
27015preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
27016It also defines @code{__mips_dsp_rev} to 2.
27017
d77de738
ML
27018@opindex msmartmips
27019@opindex mno-smartmips
ddf6fe37
AA
27020@item -msmartmips
27021@itemx -mno-smartmips
d77de738
ML
27022Use (do not use) the MIPS SmartMIPS ASE.
27023
d77de738
ML
27024@opindex mpaired-single
27025@opindex mno-paired-single
ddf6fe37
AA
27026@item -mpaired-single
27027@itemx -mno-paired-single
d77de738
ML
27028Use (do not use) paired-single floating-point instructions.
27029@xref{MIPS Paired-Single Support}. This option requires
27030hardware floating-point support to be enabled.
27031
d77de738
ML
27032@opindex mdmx
27033@opindex mno-mdmx
ddf6fe37
AA
27034@item -mdmx
27035@itemx -mno-mdmx
d77de738
ML
27036Use (do not use) MIPS Digital Media Extension instructions.
27037This option can only be used when generating 64-bit code and requires
27038hardware floating-point support to be enabled.
27039
d77de738
ML
27040@opindex mips3d
27041@opindex mno-mips3d
ddf6fe37
AA
27042@item -mips3d
27043@itemx -mno-mips3d
d77de738
ML
27044Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
27045The option @option{-mips3d} implies @option{-mpaired-single}.
27046
d77de738
ML
27047@opindex mmicromips
27048@opindex mno-mmicromips
ddf6fe37
AA
27049@item -mmicromips
27050@itemx -mno-micromips
d77de738
ML
27051Generate (do not generate) microMIPS code.
27052
27053MicroMIPS code generation can also be controlled on a per-function basis
27054by means of @code{micromips} and @code{nomicromips} attributes.
27055@xref{Function Attributes}, for more information.
27056
d77de738
ML
27057@opindex mmt
27058@opindex mno-mt
ddf6fe37
AA
27059@item -mmt
27060@itemx -mno-mt
d77de738
ML
27061Use (do not use) MT Multithreading instructions.
27062
d77de738
ML
27063@opindex mmcu
27064@opindex mno-mcu
ddf6fe37
AA
27065@item -mmcu
27066@itemx -mno-mcu
d77de738
ML
27067Use (do not use) the MIPS MCU ASE instructions.
27068
d77de738
ML
27069@opindex meva
27070@opindex mno-eva
ddf6fe37
AA
27071@item -meva
27072@itemx -mno-eva
d77de738
ML
27073Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
27074
d77de738
ML
27075@opindex mvirt
27076@opindex mno-virt
ddf6fe37
AA
27077@item -mvirt
27078@itemx -mno-virt
d77de738
ML
27079Use (do not use) the MIPS Virtualization (VZ) instructions.
27080
d77de738
ML
27081@opindex mxpa
27082@opindex mno-xpa
ddf6fe37
AA
27083@item -mxpa
27084@itemx -mno-xpa
d77de738
ML
27085Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
27086
d77de738
ML
27087@opindex mcrc
27088@opindex mno-crc
ddf6fe37
AA
27089@item -mcrc
27090@itemx -mno-crc
d77de738
ML
27091Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
27092
d77de738
ML
27093@opindex mginv
27094@opindex mno-ginv
ddf6fe37
AA
27095@item -mginv
27096@itemx -mno-ginv
d77de738
ML
27097Use (do not use) the MIPS Global INValidate (GINV) instructions.
27098
d77de738
ML
27099@opindex mloongson-mmi
27100@opindex mno-loongson-mmi
ddf6fe37
AA
27101@item -mloongson-mmi
27102@itemx -mno-loongson-mmi
d77de738
ML
27103Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
27104
d77de738
ML
27105@opindex mloongson-ext
27106@opindex mno-loongson-ext
ddf6fe37
AA
27107@item -mloongson-ext
27108@itemx -mno-loongson-ext
d77de738
ML
27109Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
27110
d77de738
ML
27111@opindex mloongson-ext2
27112@opindex mno-loongson-ext2
ddf6fe37
AA
27113@item -mloongson-ext2
27114@itemx -mno-loongson-ext2
d77de738
ML
27115Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
27116
d77de738 27117@opindex mlong64
ddf6fe37 27118@item -mlong64
d77de738
ML
27119Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
27120an explanation of the default and the way that the pointer size is
27121determined.
27122
d77de738 27123@opindex mlong32
ddf6fe37 27124@item -mlong32
d77de738
ML
27125Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
27126
27127The default size of @code{int}s, @code{long}s and pointers depends on
27128the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
27129uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2713032-bit @code{long}s. Pointers are the same size as @code{long}s,
27131or the same size as integer registers, whichever is smaller.
27132
d77de738
ML
27133@opindex msym32
27134@opindex mno-sym32
ddf6fe37
AA
27135@item -msym32
27136@itemx -mno-sym32
d77de738
ML
27137Assume (do not assume) that all symbols have 32-bit values, regardless
27138of the selected ABI@. This option is useful in combination with
27139@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
27140to generate shorter and faster references to symbolic addresses.
27141
d77de738 27142@opindex G
ddf6fe37 27143@item -G @var{num}
d77de738
ML
27144Put definitions of externally-visible data in a small data section
27145if that data is no bigger than @var{num} bytes. GCC can then generate
27146more efficient accesses to the data; see @option{-mgpopt} for details.
27147
27148The default @option{-G} option depends on the configuration.
27149
d77de738
ML
27150@opindex mlocal-sdata
27151@opindex mno-local-sdata
ddf6fe37
AA
27152@item -mlocal-sdata
27153@itemx -mno-local-sdata
d77de738
ML
27154Extend (do not extend) the @option{-G} behavior to local data too,
27155such as to static variables in C@. @option{-mlocal-sdata} is the
27156default for all configurations.
27157
27158If the linker complains that an application is using too much small data,
27159you might want to try rebuilding the less performance-critical parts with
27160@option{-mno-local-sdata}. You might also want to build large
27161libraries with @option{-mno-local-sdata}, so that the libraries leave
27162more room for the main program.
27163
d77de738
ML
27164@opindex mextern-sdata
27165@opindex mno-extern-sdata
ddf6fe37
AA
27166@item -mextern-sdata
27167@itemx -mno-extern-sdata
d77de738
ML
27168Assume (do not assume) that externally-defined data is in
27169a small data section if the size of that data is within the @option{-G} limit.
27170@option{-mextern-sdata} is the default for all configurations.
27171
27172If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
27173@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
27174that is no bigger than @var{num} bytes, you must make sure that @var{Var}
27175is placed in a small data section. If @var{Var} is defined by another
27176module, you must either compile that module with a high-enough
27177@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
27178definition. If @var{Var} is common, you must link the application
27179with a high-enough @option{-G} setting.
27180
27181The easiest way of satisfying these restrictions is to compile
27182and link every module with the same @option{-G} option. However,
27183you may wish to build a library that supports several different
27184small data limits. You can do this by compiling the library with
27185the highest supported @option{-G} setting and additionally using
27186@option{-mno-extern-sdata} to stop the library from making assumptions
27187about externally-defined data.
27188
d77de738
ML
27189@opindex mgpopt
27190@opindex mno-gpopt
ddf6fe37
AA
27191@item -mgpopt
27192@itemx -mno-gpopt
d77de738
ML
27193Use (do not use) GP-relative accesses for symbols that are known to be
27194in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27195@option{-mextern-sdata}. @option{-mgpopt} is the default for all
27196configurations.
27197
27198@option{-mno-gpopt} is useful for cases where the @code{$gp} register
27199might not hold the value of @code{_gp}. For example, if the code is
27200part of a library that might be used in a boot monitor, programs that
27201call boot monitor routines pass an unknown value in @code{$gp}.
27202(In such situations, the boot monitor itself is usually compiled
27203with @option{-G0}.)
27204
27205@option{-mno-gpopt} implies @option{-mno-local-sdata} and
27206@option{-mno-extern-sdata}.
27207
d77de738
ML
27208@opindex membedded-data
27209@opindex mno-embedded-data
ddf6fe37
AA
27210@item -membedded-data
27211@itemx -mno-embedded-data
d77de738
ML
27212Allocate variables to the read-only data section first if possible, then
27213next in the small data section if possible, otherwise in data. This gives
27214slightly slower code than the default, but reduces the amount of RAM required
27215when executing, and thus may be preferred for some embedded systems.
27216
d77de738
ML
27217@opindex muninit-const-in-rodata
27218@opindex mno-uninit-const-in-rodata
ddf6fe37
AA
27219@item -muninit-const-in-rodata
27220@itemx -mno-uninit-const-in-rodata
d77de738
ML
27221Put uninitialized @code{const} variables in the read-only data section.
27222This option is only meaningful in conjunction with @option{-membedded-data}.
27223
d77de738 27224@opindex mcode-readable
ddf6fe37 27225@item -mcode-readable=@var{setting}
d77de738
ML
27226Specify whether GCC may generate code that reads from executable sections.
27227There are three possible settings:
27228
27229@table @gcctabopt
27230@item -mcode-readable=yes
27231Instructions may freely access executable sections. This is the
27232default setting.
27233
27234@item -mcode-readable=pcrel
27235MIPS16 PC-relative load instructions can access executable sections,
27236but other instructions must not do so. This option is useful on 4KSc
27237and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27238It is also useful on processors that can be configured to have a dual
27239instruction/data SRAM interface and that, like the M4K, automatically
27240redirect PC-relative loads to the instruction RAM.
27241
27242@item -mcode-readable=no
27243Instructions must not access executable sections. This option can be
27244useful on targets that are configured to have a dual instruction/data
27245SRAM interface but that (unlike the M4K) do not automatically redirect
27246PC-relative loads to the instruction RAM.
27247@end table
27248
d77de738
ML
27249@opindex msplit-addresses
27250@opindex mno-split-addresses
ddf6fe37
AA
27251@item -msplit-addresses
27252@itemx -mno-split-addresses
d77de738
ML
27253Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27254relocation operators. This option has been superseded by
27255@option{-mexplicit-relocs} but is retained for backwards compatibility.
27256
d77de738
ML
27257@opindex mexplicit-relocs
27258@opindex mno-explicit-relocs
ddf6fe37
AA
27259@item -mexplicit-relocs
27260@itemx -mno-explicit-relocs
d77de738
ML
27261Use (do not use) assembler relocation operators when dealing with symbolic
27262addresses. The alternative, selected by @option{-mno-explicit-relocs},
27263is to use assembler macros instead.
27264
27265@option{-mexplicit-relocs} is the default if GCC was configured
27266to use an assembler that supports relocation operators.
27267
d77de738
ML
27268@opindex mcheck-zero-division
27269@opindex mno-check-zero-division
ddf6fe37
AA
27270@item -mcheck-zero-division
27271@itemx -mno-check-zero-division
d77de738
ML
27272Trap (do not trap) on integer division by zero.
27273
27274The default is @option{-mcheck-zero-division}.
27275
d77de738
ML
27276@opindex mdivide-traps
27277@opindex mdivide-breaks
ddf6fe37
AA
27278@item -mdivide-traps
27279@itemx -mdivide-breaks
d77de738
ML
27280MIPS systems check for division by zero by generating either a
27281conditional trap or a break instruction. Using traps results in
27282smaller code, but is only supported on MIPS II and later. Also, some
27283versions of the Linux kernel have a bug that prevents trap from
27284generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27285allow conditional traps on architectures that support them and
27286@option{-mdivide-breaks} to force the use of breaks.
27287
27288The default is usually @option{-mdivide-traps}, but this can be
27289overridden at configure time using @option{--with-divide=breaks}.
27290Divide-by-zero checks can be completely disabled using
27291@option{-mno-check-zero-division}.
27292
d77de738
ML
27293@opindex mload-store-pairs
27294@opindex mno-load-store-pairs
ddf6fe37
AA
27295@item -mload-store-pairs
27296@itemx -mno-load-store-pairs
d77de738
ML
27297Enable (disable) an optimization that pairs consecutive load or store
27298instructions to enable load/store bonding. This option is enabled by
27299default but only takes effect when the selected architecture is known
27300to support bonding.
27301
d77de738
ML
27302@opindex munaligned-access
27303@opindex mno-unaligned-access
ddf6fe37
AA
27304@item -munaligned-access
27305@itemx -mno-unaligned-access
d77de738
ML
27306Enable (disable) direct unaligned access for MIPS Release 6.
27307MIPSr6 requires load/store unaligned-access support,
27308by hardware or trap&emulate.
27309So @option{-mno-unaligned-access} may be needed by kernel.
27310
d77de738
ML
27311@opindex mmemcpy
27312@opindex mno-memcpy
ddf6fe37
AA
27313@item -mmemcpy
27314@itemx -mno-memcpy
d77de738
ML
27315Force (do not force) the use of @code{memcpy} for non-trivial block
27316moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27317most constant-sized copies.
27318
d77de738
ML
27319@opindex mlong-calls
27320@opindex mno-long-calls
ddf6fe37
AA
27321@item -mlong-calls
27322@itemx -mno-long-calls
d77de738
ML
27323Disable (do not disable) use of the @code{jal} instruction. Calling
27324functions using @code{jal} is more efficient but requires the caller
27325and callee to be in the same 256 megabyte segment.
27326
27327This option has no effect on abicalls code. The default is
27328@option{-mno-long-calls}.
27329
d77de738
ML
27330@opindex mmad
27331@opindex mno-mad
ddf6fe37
AA
27332@item -mmad
27333@itemx -mno-mad
d77de738
ML
27334Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27335instructions, as provided by the R4650 ISA@.
27336
d77de738
ML
27337@opindex mimadd
27338@opindex mno-imadd
ddf6fe37
AA
27339@item -mimadd
27340@itemx -mno-imadd
d77de738
ML
27341Enable (disable) use of the @code{madd} and @code{msub} integer
27342instructions. The default is @option{-mimadd} on architectures
27343that support @code{madd} and @code{msub} except for the 74k
27344architecture where it was found to generate slower code.
27345
d77de738
ML
27346@opindex mfused-madd
27347@opindex mno-fused-madd
ddf6fe37
AA
27348@item -mfused-madd
27349@itemx -mno-fused-madd
d77de738
ML
27350Enable (disable) use of the floating-point multiply-accumulate
27351instructions, when they are available. The default is
27352@option{-mfused-madd}.
27353
27354On the R8000 CPU when multiply-accumulate instructions are used,
27355the intermediate product is calculated to infinite precision
27356and is not subject to the FCSR Flush to Zero bit. This may be
27357undesirable in some circumstances. On other processors the result
27358is numerically identical to the equivalent computation using
27359separate multiply, add, subtract and negate instructions.
27360
d77de738 27361@opindex nocpp
ddf6fe37 27362@item -nocpp
d77de738
ML
27363Tell the MIPS assembler to not run its preprocessor over user
27364assembler files (with a @samp{.s} suffix) when assembling them.
27365
d77de738
ML
27366@opindex mfix-24k
27367@opindex mno-fix-24k
ddf6fe37
AA
27368@item -mfix-24k
27369@itemx -mno-fix-24k
d77de738
ML
27370Work around the 24K E48 (lost data on stores during refill) errata.
27371The workarounds are implemented by the assembler rather than by GCC@.
27372
d77de738
ML
27373@opindex mfix-r4000
27374@opindex mno-fix-r4000
ddf6fe37
AA
27375@item -mfix-r4000
27376@itemx -mno-fix-r4000
d77de738
ML
27377Work around certain R4000 CPU errata:
27378@itemize @minus
27379@item
27380A double-word or a variable shift may give an incorrect result if executed
27381immediately after starting an integer division.
27382@item
27383A double-word or a variable shift may give an incorrect result if executed
27384while an integer multiplication is in progress.
27385@item
27386An integer division may give an incorrect result if started in a delay slot
27387of a taken branch or a jump.
27388@end itemize
27389
d77de738
ML
27390@opindex mfix-r4400
27391@opindex mno-fix-r4400
ddf6fe37
AA
27392@item -mfix-r4400
27393@itemx -mno-fix-r4400
d77de738
ML
27394Work around certain R4400 CPU errata:
27395@itemize @minus
27396@item
27397A double-word or a variable shift may give an incorrect result if executed
27398immediately after starting an integer division.
27399@end itemize
27400
d77de738
ML
27401@opindex mfix-r10000
27402@opindex mno-fix-r10000
ddf6fe37
AA
27403@item -mfix-r10000
27404@itemx -mno-fix-r10000
d77de738
ML
27405Work around certain R10000 errata:
27406@itemize @minus
27407@item
27408@code{ll}/@code{sc} sequences may not behave atomically on revisions
27409prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27410@end itemize
27411
27412This option can only be used if the target architecture supports
27413branch-likely instructions. @option{-mfix-r10000} is the default when
27414@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27415otherwise.
27416
ddf6fe37 27417@opindex mfix-r5900
d77de738
ML
27418@item -mfix-r5900
27419@itemx -mno-fix-r5900
d77de738
ML
27420Do not attempt to schedule the preceding instruction into the delay slot
27421of a branch instruction placed at the end of a short loop of six
27422instructions or fewer and always schedule a @code{nop} instruction there
27423instead. The short loop bug under certain conditions causes loops to
27424execute only once or twice, due to a hardware bug in the R5900 chip. The
27425workaround is implemented by the assembler rather than by GCC@.
27426
ddf6fe37 27427@opindex mfix-rm7000
d77de738
ML
27428@item -mfix-rm7000
27429@itemx -mno-fix-rm7000
d77de738
ML
27430Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27431workarounds are implemented by the assembler rather than by GCC@.
27432
ddf6fe37 27433@opindex mfix-vr4120
d77de738
ML
27434@item -mfix-vr4120
27435@itemx -mno-fix-vr4120
d77de738
ML
27436Work around certain VR4120 errata:
27437@itemize @minus
27438@item
27439@code{dmultu} does not always produce the correct result.
27440@item
27441@code{div} and @code{ddiv} do not always produce the correct result if one
27442of the operands is negative.
27443@end itemize
27444The workarounds for the division errata rely on special functions in
27445@file{libgcc.a}. At present, these functions are only provided by
27446the @code{mips64vr*-elf} configurations.
27447
27448Other VR4120 errata require a NOP to be inserted between certain pairs of
27449instructions. These errata are handled by the assembler, not by GCC itself.
27450
d77de738 27451@opindex mfix-vr4130
ddf6fe37 27452@item -mfix-vr4130
d77de738
ML
27453Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27454workarounds are implemented by the assembler rather than by GCC,
27455although GCC avoids using @code{mflo} and @code{mfhi} if the
27456VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27457instructions are available instead.
27458
ddf6fe37 27459@opindex mfix-sb1
d77de738
ML
27460@item -mfix-sb1
27461@itemx -mno-fix-sb1
d77de738
ML
27462Work around certain SB-1 CPU core errata.
27463(This flag currently works around the SB-1 revision 2
27464``F1'' and ``F2'' floating-point errata.)
27465
d77de738 27466@opindex mr10k-cache-barrier
ddf6fe37 27467@item -mr10k-cache-barrier=@var{setting}
d77de738
ML
27468Specify whether GCC should insert cache barriers to avoid the
27469side effects of speculation on R10K processors.
27470
27471In common with many processors, the R10K tries to predict the outcome
27472of a conditional branch and speculatively executes instructions from
27473the ``taken'' branch. It later aborts these instructions if the
27474predicted outcome is wrong. However, on the R10K, even aborted
27475instructions can have side effects.
27476
27477This problem only affects kernel stores and, depending on the system,
27478kernel loads. As an example, a speculatively-executed store may load
27479the target memory into cache and mark the cache line as dirty, even if
27480the store itself is later aborted. If a DMA operation writes to the
27481same area of memory before the ``dirty'' line is flushed, the cached
27482data overwrites the DMA-ed data. See the R10K processor manual
27483for a full description, including other potential problems.
27484
27485One workaround is to insert cache barrier instructions before every memory
27486access that might be speculatively executed and that might have side
27487effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27488controls GCC's implementation of this workaround. It assumes that
27489aborted accesses to any byte in the following regions does not have
27490side effects:
27491
27492@enumerate
27493@item
27494the memory occupied by the current function's stack frame;
27495
27496@item
27497the memory occupied by an incoming stack argument;
27498
27499@item
27500the memory occupied by an object with a link-time-constant address.
27501@end enumerate
27502
27503It is the kernel's responsibility to ensure that speculative
27504accesses to these regions are indeed safe.
27505
27506If the input program contains a function declaration such as:
27507
27508@smallexample
27509void foo (void);
27510@end smallexample
27511
27512then the implementation of @code{foo} must allow @code{j foo} and
27513@code{jal foo} to be executed speculatively. GCC honors this
27514restriction for functions it compiles itself. It expects non-GCC
27515functions (such as hand-written assembly code) to do the same.
27516
27517The option has three forms:
27518
27519@table @gcctabopt
27520@item -mr10k-cache-barrier=load-store
27521Insert a cache barrier before a load or store that might be
27522speculatively executed and that might have side effects even
27523if aborted.
27524
27525@item -mr10k-cache-barrier=store
27526Insert a cache barrier before a store that might be speculatively
27527executed and that might have side effects even if aborted.
27528
27529@item -mr10k-cache-barrier=none
27530Disable the insertion of cache barriers. This is the default setting.
27531@end table
27532
ddf6fe37 27533@opindex mflush-func
d77de738
ML
27534@item -mflush-func=@var{func}
27535@itemx -mno-flush-func
d77de738
ML
27536Specifies the function to call to flush the I and D caches, or to not
27537call any such function. If called, the function must take the same
27538arguments as the common @code{_flush_func}, that is, the address of the
27539memory range for which the cache is being flushed, the size of the
27540memory range, and the number 3 (to flush both caches). The default
27541depends on the target GCC was configured for, but commonly is either
27542@code{_flush_func} or @code{__cpu_flush}.
27543
d77de738 27544@opindex mbranch-cost
ddf6fe37 27545@item mbranch-cost=@var{num}
d77de738
ML
27546Set the cost of branches to roughly @var{num} ``simple'' instructions.
27547This cost is only a heuristic and is not guaranteed to produce
27548consistent results across releases. A zero cost redundantly selects
27549the default, which is based on the @option{-mtune} setting.
27550
d77de738
ML
27551@opindex mbranch-likely
27552@opindex mno-branch-likely
ddf6fe37
AA
27553@item -mbranch-likely
27554@itemx -mno-branch-likely
d77de738
ML
27555Enable or disable use of Branch Likely instructions, regardless of the
27556default for the selected architecture. By default, Branch Likely
27557instructions may be generated if they are supported by the selected
27558architecture. An exception is for the MIPS32 and MIPS64 architectures
27559and processors that implement those architectures; for those, Branch
27560Likely instructions are not be generated by default because the MIPS32
27561and MIPS64 architectures specifically deprecate their use.
27562
d77de738
ML
27563@opindex mcompact-branches=never
27564@opindex mcompact-branches=optimal
27565@opindex mcompact-branches=always
ddf6fe37
AA
27566@item -mcompact-branches=never
27567@itemx -mcompact-branches=optimal
27568@itemx -mcompact-branches=always
d77de738
ML
27569These options control which form of branches will be generated. The
27570default is @option{-mcompact-branches=optimal}.
27571
27572The @option{-mcompact-branches=never} option ensures that compact branch
27573instructions will never be generated.
27574
27575The @option{-mcompact-branches=always} option ensures that a compact
27576branch instruction will be generated if available for MIPS Release 6 onwards.
27577If a compact branch instruction is not available (or pre-R6),
27578a delay slot form of the branch will be used instead.
27579
27580If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27581The behaviour for MIPS16/microMIPS may change in future,
27582since they do have some compact branch instructions.
27583
27584The @option{-mcompact-branches=optimal} option will cause a delay slot
27585branch to be used if one is available in the current ISA and the delay
27586slot is successfully filled. If the delay slot is not filled, a compact
27587branch will be chosen if one is available.
27588
ddf6fe37 27589@opindex mfp-exceptions
d77de738
ML
27590@item -mfp-exceptions
27591@itemx -mno-fp-exceptions
d77de738
ML
27592Specifies whether FP exceptions are enabled. This affects how
27593FP instructions are scheduled for some processors.
27594The default is that FP exceptions are
27595enabled.
27596
27597For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2759864-bit code, then we can use both FP pipes. Otherwise, we can only use one
27599FP pipe.
27600
ddf6fe37 27601@opindex mvr4130-align
d77de738
ML
27602@item -mvr4130-align
27603@itemx -mno-vr4130-align
d77de738
ML
27604The VR4130 pipeline is two-way superscalar, but can only issue two
27605instructions together if the first one is 8-byte aligned. When this
27606option is enabled, GCC aligns pairs of instructions that it
27607thinks should execute in parallel.
27608
27609This option only has an effect when optimizing for the VR4130.
27610It normally makes code faster, but at the expense of making it bigger.
27611It is enabled by default at optimization level @option{-O3}.
27612
ddf6fe37 27613@opindex msynci
d77de738
ML
27614@item -msynci
27615@itemx -mno-synci
d77de738
ML
27616Enable (disable) generation of @code{synci} instructions on
27617architectures that support it. The @code{synci} instructions (if
27618enabled) are generated when @code{__builtin___clear_cache} is
27619compiled.
27620
27621This option defaults to @option{-mno-synci}, but the default can be
27622overridden by configuring GCC with @option{--with-synci}.
27623
27624When compiling code for single processor systems, it is generally safe
27625to use @code{synci}. However, on many multi-core (SMP) systems, it
27626does not invalidate the instruction caches on all cores and may lead
27627to undefined behavior.
27628
ddf6fe37 27629@opindex mrelax-pic-calls
d77de738
ML
27630@item -mrelax-pic-calls
27631@itemx -mno-relax-pic-calls
d77de738
ML
27632Try to turn PIC calls that are normally dispatched via register
27633@code{$25} into direct calls. This is only possible if the linker can
27634resolve the destination at link time and if the destination is within
27635range for a direct call.
27636
27637@option{-mrelax-pic-calls} is the default if GCC was configured to use
27638an assembler and a linker that support the @code{.reloc} assembly
27639directive and @option{-mexplicit-relocs} is in effect. With
27640@option{-mno-explicit-relocs}, this optimization can be performed by the
27641assembler and the linker alone without help from the compiler.
27642
d77de738
ML
27643@opindex mmcount-ra-address
27644@opindex mno-mcount-ra-address
ddf6fe37
AA
27645@item -mmcount-ra-address
27646@itemx -mno-mcount-ra-address
d77de738
ML
27647Emit (do not emit) code that allows @code{_mcount} to modify the
27648calling function's return address. When enabled, this option extends
27649the usual @code{_mcount} interface with a new @var{ra-address}
27650parameter, which has type @code{intptr_t *} and is passed in register
27651@code{$12}. @code{_mcount} can then modify the return address by
27652doing both of the following:
27653@itemize
27654@item
27655Returning the new address in register @code{$31}.
27656@item
27657Storing the new address in @code{*@var{ra-address}},
27658if @var{ra-address} is nonnull.
27659@end itemize
27660
27661The default is @option{-mno-mcount-ra-address}.
27662
ddf6fe37 27663@opindex mframe-header-opt
d77de738
ML
27664@item -mframe-header-opt
27665@itemx -mno-frame-header-opt
d77de738
ML
27666Enable (disable) frame header optimization in the o32 ABI. When using the
27667o32 ABI, calling functions will allocate 16 bytes on the stack for the called
27668function to write out register arguments. When enabled, this optimization
27669will suppress the allocation of the frame header if it can be determined that
27670it is unused.
27671
27672This optimization is off by default at all optimization levels.
27673
ddf6fe37 27674@opindex mlxc1-sxc1
d77de738
ML
27675@item -mlxc1-sxc1
27676@itemx -mno-lxc1-sxc1
d77de738
ML
27677When applicable, enable (disable) the generation of @code{lwxc1},
27678@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
27679
ddf6fe37 27680@opindex mmadd4
d77de738
ML
27681@item -mmadd4
27682@itemx -mno-madd4
d77de738
ML
27683When applicable, enable (disable) the generation of 4-operand @code{madd.s},
27684@code{madd.d} and related instructions. Enabled by default.
27685
27686@end table
27687
27688@node MMIX Options
27689@subsection MMIX Options
27690@cindex MMIX Options
27691
27692These options are defined for the MMIX:
27693
27694@table @gcctabopt
d77de738
ML
27695@opindex mlibfuncs
27696@opindex mno-libfuncs
ddf6fe37
AA
27697@item -mlibfuncs
27698@itemx -mno-libfuncs
d77de738
ML
27699Specify that intrinsic library functions are being compiled, passing all
27700values in registers, no matter the size.
27701
d77de738
ML
27702@opindex mepsilon
27703@opindex mno-epsilon
ddf6fe37
AA
27704@item -mepsilon
27705@itemx -mno-epsilon
d77de738
ML
27706Generate floating-point comparison instructions that compare with respect
27707to the @code{rE} epsilon register.
27708
d77de738
ML
27709@opindex mabi=mmixware
27710@opindex mabi=gnu
ddf6fe37
AA
27711@item -mabi=mmixware
27712@itemx -mabi=gnu
d77de738
ML
27713Generate code that passes function parameters and return values that (in
27714the called function) are seen as registers @code{$0} and up, as opposed to
27715the GNU ABI which uses global registers @code{$231} and up.
27716
d77de738
ML
27717@opindex mzero-extend
27718@opindex mno-zero-extend
ddf6fe37
AA
27719@item -mzero-extend
27720@itemx -mno-zero-extend
d77de738
ML
27721When reading data from memory in sizes shorter than 64 bits, use (do not
27722use) zero-extending load instructions by default, rather than
27723sign-extending ones.
27724
d77de738
ML
27725@opindex mknuthdiv
27726@opindex mno-knuthdiv
ddf6fe37
AA
27727@item -mknuthdiv
27728@itemx -mno-knuthdiv
d77de738
ML
27729Make the result of a division yielding a remainder have the same sign as
27730the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
27731remainder follows the sign of the dividend. Both methods are
27732arithmetically valid, the latter being almost exclusively used.
27733
d77de738
ML
27734@opindex mtoplevel-symbols
27735@opindex mno-toplevel-symbols
ddf6fe37
AA
27736@item -mtoplevel-symbols
27737@itemx -mno-toplevel-symbols
d77de738
ML
27738Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
27739code can be used with the @code{PREFIX} assembly directive.
27740
d77de738 27741@opindex melf
ddf6fe37 27742@item -melf
d77de738
ML
27743Generate an executable in the ELF format, rather than the default
27744@samp{mmo} format used by the @command{mmix} simulator.
27745
d77de738
ML
27746@opindex mbranch-predict
27747@opindex mno-branch-predict
ddf6fe37
AA
27748@item -mbranch-predict
27749@itemx -mno-branch-predict
d77de738
ML
27750Use (do not use) the probable-branch instructions, when static branch
27751prediction indicates a probable branch.
27752
d77de738
ML
27753@opindex mbase-addresses
27754@opindex mno-base-addresses
ddf6fe37
AA
27755@item -mbase-addresses
27756@itemx -mno-base-addresses
d77de738
ML
27757Generate (do not generate) code that uses @emph{base addresses}. Using a
27758base address automatically generates a request (handled by the assembler
27759and the linker) for a constant to be set up in a global register. The
27760register is used for one or more base address requests within the range 0
27761to 255 from the value held in the register. The generally leads to short
27762and fast code, but the number of different data items that can be
27763addressed is limited. This means that a program that uses lots of static
27764data may require @option{-mno-base-addresses}.
27765
d77de738
ML
27766@opindex msingle-exit
27767@opindex mno-single-exit
ddf6fe37
AA
27768@item -msingle-exit
27769@itemx -mno-single-exit
d77de738
ML
27770Force (do not force) generated code to have a single exit point in each
27771function.
27772@end table
27773
27774@node MN10300 Options
27775@subsection MN10300 Options
27776@cindex MN10300 options
27777
27778These @option{-m} options are defined for Matsushita MN10300 architectures:
27779
27780@table @gcctabopt
d77de738 27781@opindex mmult-bug
ddf6fe37 27782@item -mmult-bug
d77de738
ML
27783Generate code to avoid bugs in the multiply instructions for the MN10300
27784processors. This is the default.
27785
d77de738 27786@opindex mno-mult-bug
ddf6fe37 27787@item -mno-mult-bug
d77de738
ML
27788Do not generate code to avoid bugs in the multiply instructions for the
27789MN10300 processors.
27790
d77de738 27791@opindex mam33
ddf6fe37 27792@item -mam33
d77de738
ML
27793Generate code using features specific to the AM33 processor.
27794
d77de738 27795@opindex mno-am33
ddf6fe37 27796@item -mno-am33
d77de738
ML
27797Do not generate code using features specific to the AM33 processor. This
27798is the default.
27799
d77de738 27800@opindex mam33-2
ddf6fe37 27801@item -mam33-2
d77de738
ML
27802Generate code using features specific to the AM33/2.0 processor.
27803
d77de738 27804@opindex mam34
ddf6fe37 27805@item -mam34
d77de738
ML
27806Generate code using features specific to the AM34 processor.
27807
d77de738 27808@opindex mtune
ddf6fe37 27809@item -mtune=@var{cpu-type}
d77de738
ML
27810Use the timing characteristics of the indicated CPU type when
27811scheduling instructions. This does not change the targeted processor
27812type. The CPU type must be one of @samp{mn10300}, @samp{am33},
27813@samp{am33-2} or @samp{am34}.
27814
d77de738 27815@opindex mreturn-pointer-on-d0
ddf6fe37 27816@item -mreturn-pointer-on-d0
d77de738
ML
27817When generating a function that returns a pointer, return the pointer
27818in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
27819only in @code{a0}, and attempts to call such functions without a prototype
27820result in errors. Note that this option is on by default; use
27821@option{-mno-return-pointer-on-d0} to disable it.
27822
d77de738 27823@opindex mno-crt0
ddf6fe37 27824@item -mno-crt0
d77de738
ML
27825Do not link in the C run-time initialization object file.
27826
d77de738 27827@opindex mrelax
ddf6fe37 27828@item -mrelax
d77de738
ML
27829Indicate to the linker that it should perform a relaxation optimization pass
27830to shorten branches, calls and absolute memory addresses. This option only
27831has an effect when used on the command line for the final link step.
27832
27833This option makes symbolic debugging impossible.
27834
d77de738 27835@opindex mliw
ddf6fe37 27836@item -mliw
d77de738
ML
27837Allow the compiler to generate @emph{Long Instruction Word}
27838instructions if the target is the @samp{AM33} or later. This is the
27839default. This option defines the preprocessor macro @code{__LIW__}.
27840
d77de738 27841@opindex mno-liw
ddf6fe37 27842@item -mno-liw
d77de738
ML
27843Do not allow the compiler to generate @emph{Long Instruction Word}
27844instructions. This option defines the preprocessor macro
27845@code{__NO_LIW__}.
27846
d77de738 27847@opindex msetlb
ddf6fe37 27848@item -msetlb
d77de738
ML
27849Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
27850instructions if the target is the @samp{AM33} or later. This is the
27851default. This option defines the preprocessor macro @code{__SETLB__}.
27852
d77de738 27853@opindex mno-setlb
ddf6fe37 27854@item -mno-setlb
d77de738
ML
27855Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
27856instructions. This option defines the preprocessor macro
27857@code{__NO_SETLB__}.
27858
27859@end table
27860
27861@node Moxie Options
27862@subsection Moxie Options
27863@cindex Moxie Options
27864
27865@table @gcctabopt
27866
d77de738 27867@opindex meb
ddf6fe37 27868@item -meb
d77de738
ML
27869Generate big-endian code. This is the default for @samp{moxie-*-*}
27870configurations.
27871
d77de738 27872@opindex mel
ddf6fe37 27873@item -mel
d77de738
ML
27874Generate little-endian code.
27875
d77de738 27876@opindex mmul.x
ddf6fe37 27877@item -mmul.x
d77de738
ML
27878Generate mul.x and umul.x instructions. This is the default for
27879@samp{moxiebox-*-*} configurations.
27880
d77de738 27881@opindex mno-crt0
ddf6fe37 27882@item -mno-crt0
d77de738
ML
27883Do not link in the C run-time initialization object file.
27884
27885@end table
27886
27887@node MSP430 Options
27888@subsection MSP430 Options
27889@cindex MSP430 Options
27890
27891These options are defined for the MSP430:
27892
27893@table @gcctabopt
27894
d77de738 27895@opindex masm-hex
ddf6fe37 27896@item -masm-hex
d77de738
ML
27897Force assembly output to always use hex constants. Normally such
27898constants are signed decimals, but this option is available for
27899testsuite and/or aesthetic purposes.
27900
d77de738 27901@opindex mmcu=
ddf6fe37 27902@item -mmcu=
d77de738
ML
27903Select the MCU to target. This is used to create a C preprocessor
27904symbol based upon the MCU name, converted to upper case and pre- and
27905post-fixed with @samp{__}. This in turn is used by the
27906@file{msp430.h} header file to select an MCU-specific supplementary
27907header file.
27908
27909The option also sets the ISA to use. If the MCU name is one that is
27910known to only support the 430 ISA then that is selected, otherwise the
27911430X ISA is selected. A generic MCU name of @samp{msp430} can also be
27912used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
27913name selects the 430X ISA.
27914
27915In addition an MCU-specific linker script is added to the linker
27916command line. The script's name is the name of the MCU with
27917@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
27918command line defines the C preprocessor symbol @code{__XXX__} and
27919cause the linker to search for a script called @file{xxx.ld}.
27920
27921The ISA and hardware multiply supported for the different MCUs is hard-coded
27922into GCC. However, an external @samp{devices.csv} file can be used to
27923extend device support beyond those that have been hard-coded.
27924
27925GCC searches for the @samp{devices.csv} file using the following methods in the
27926given precedence order, where the first method takes precendence over the
27927second which takes precedence over the third.
27928
27929@table @asis
27930@item Include path specified with @code{-I} and @code{-L}
27931@samp{devices.csv} will be searched for in each of the directories specified by
27932include paths and linker library search paths.
27933@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
27934Define the value of the global environment variable
27935@samp{MSP430_GCC_INCLUDE_DIR}
27936to the full path to the directory containing devices.csv, and GCC will search
27937this directory for devices.csv. If devices.csv is found, this directory will
27938also be registered as an include path, and linker library path. Header files
27939and linker scripts in this directory can therefore be used without manually
27940specifying @code{-I} and @code{-L} on the command line.
27941@item The @samp{msp430-elf@{,bare@}/include/devices} directory
27942Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
27943toolchain root directory. This directory does not exist in a default
27944installation, but if the user has created it and copied @samp{devices.csv}
27945there, then the MCU data will be read. As above, this directory will
27946also be registered as an include path, and linker library path.
27947
27948@end table
27949If none of the above search methods find @samp{devices.csv}, then the
27950hard-coded MCU data is used.
27951
27952
d77de738
ML
27953@opindex mwarn-mcu
27954@opindex mno-warn-mcu
ddf6fe37
AA
27955@item -mwarn-mcu
27956@itemx -mno-warn-mcu
d77de738
ML
27957This option enables or disables warnings about conflicts between the
27958MCU name specified by the @option{-mmcu} option and the ISA set by the
27959@option{-mcpu} option and/or the hardware multiply support set by the
27960@option{-mhwmult} option. It also toggles warnings about unrecognized
27961MCU names. This option is on by default.
27962
d77de738 27963@opindex mcpu=
ddf6fe37 27964@item -mcpu=
d77de738
ML
27965Specifies the ISA to use. Accepted values are @samp{msp430},
27966@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
27967@option{-mmcu=} option should be used to select the ISA.
27968
d77de738 27969@opindex msim
ddf6fe37 27970@item -msim
d77de738
ML
27971Link to the simulator runtime libraries and linker script. Overrides
27972any scripts that would be selected by the @option{-mmcu=} option.
27973
d77de738 27974@opindex mlarge
ddf6fe37 27975@item -mlarge
d77de738
ML
27976Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
27977
d77de738 27978@opindex msmall
ddf6fe37 27979@item -msmall
d77de738
ML
27980Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
27981
d77de738 27982@opindex mrelax
ddf6fe37 27983@item -mrelax
d77de738
ML
27984This option is passed to the assembler and linker, and allows the
27985linker to perform certain optimizations that cannot be done until
27986the final link.
27987
d77de738 27988@opindex mhwmult=
ddf6fe37 27989@item mhwmult=
d77de738
ML
27990Describes the type of hardware multiply supported by the target.
27991Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
27992for the original 16-bit-only multiply supported by early MCUs.
27993@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
27994@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
27995A value of @samp{auto} can also be given. This tells GCC to deduce
27996the hardware multiply support based upon the MCU name provided by the
27997@option{-mmcu} option. If no @option{-mmcu} option is specified or if
27998the MCU name is not recognized then no hardware multiply support is
27999assumed. @code{auto} is the default setting.
28000
28001Hardware multiplies are normally performed by calling a library
28002routine. This saves space in the generated code. When compiling at
28003@option{-O3} or higher however the hardware multiplier is invoked
28004inline. This makes for bigger, but faster code.
28005
28006The hardware multiply routines disable interrupts whilst running and
28007restore the previous interrupt state when they finish. This makes
28008them safe to use inside interrupt handlers as well as in normal code.
28009
d77de738 28010@opindex minrt
ddf6fe37 28011@item -minrt
d77de738
ML
28012Enable the use of a minimum runtime environment - no static
28013initializers or constructors. This is intended for memory-constrained
28014devices. The compiler includes special symbols in some objects
28015that tell the linker and runtime which code fragments are required.
28016
d77de738 28017@opindex mtiny-printf
ddf6fe37 28018@item -mtiny-printf
d77de738
ML
28019Enable reduced code size @code{printf} and @code{puts} library functions.
28020The @samp{tiny} implementations of these functions are not reentrant, so
28021must be used with caution in multi-threaded applications.
28022
28023Support for streams has been removed and the string to be printed will
28024always be sent to stdout via the @code{write} syscall. The string is not
28025buffered before it is sent to write.
28026
28027This option requires Newlib Nano IO, so GCC must be configured with
28028@samp{--enable-newlib-nano-formatted-io}.
28029
d77de738 28030@opindex mmax-inline-shift=
ddf6fe37 28031@item -mmax-inline-shift=
d77de738
ML
28032This option takes an integer between 0 and 64 inclusive, and sets
28033the maximum number of inline shift instructions which should be emitted to
28034perform a shift operation by a constant amount. When this value needs to be
28035exceeded, an mspabi helper function is used instead. The default value is 4.
28036
28037This only affects cases where a shift by multiple positions cannot be
28038completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
28039
28040Shifts of a 32-bit value are at least twice as costly, so the value passed for
28041this option is divided by 2 and the resulting value used instead.
28042
d77de738
ML
28043@opindex mcode-region
28044@opindex mdata-region
ddf6fe37
AA
28045@item -mcode-region=
28046@itemx -mdata-region=
d77de738
ML
28047These options tell the compiler where to place functions and data that
28048do not have one of the @code{lower}, @code{upper}, @code{either} or
28049@code{section} attributes. Possible values are @code{lower},
28050@code{upper}, @code{either} or @code{any}. The first three behave
28051like the corresponding attribute. The fourth possible value -
28052@code{any} - is the default. It leaves placement entirely up to the
28053linker script and how it assigns the standard sections
28054(@code{.text}, @code{.data}, etc) to the memory regions.
28055
d77de738 28056@opindex msilicon-errata
ddf6fe37 28057@item -msilicon-errata=
d77de738
ML
28058This option passes on a request to assembler to enable the fixes for
28059the named silicon errata.
28060
d77de738 28061@opindex msilicon-errata-warn
ddf6fe37 28062@item -msilicon-errata-warn=
d77de738
ML
28063This option passes on a request to the assembler to enable warning
28064messages when a silicon errata might need to be applied.
28065
d77de738
ML
28066@opindex mwarn-devices-csv
28067@opindex mno-warn-devices-csv
ddf6fe37
AA
28068@item -mwarn-devices-csv
28069@itemx -mno-warn-devices-csv
d77de738
ML
28070Warn if @samp{devices.csv} is not found or there are problem parsing it
28071(default: on).
28072
28073@end table
28074
28075@node NDS32 Options
28076@subsection NDS32 Options
28077@cindex NDS32 Options
28078
28079These options are defined for NDS32 implementations:
28080
28081@table @gcctabopt
28082
d77de738 28083@opindex mbig-endian
ddf6fe37 28084@item -mbig-endian
d77de738
ML
28085Generate code in big-endian mode.
28086
d77de738 28087@opindex mlittle-endian
ddf6fe37 28088@item -mlittle-endian
d77de738
ML
28089Generate code in little-endian mode.
28090
d77de738 28091@opindex mreduced-regs
ddf6fe37 28092@item -mreduced-regs
d77de738
ML
28093Use reduced-set registers for register allocation.
28094
d77de738 28095@opindex mfull-regs
ddf6fe37 28096@item -mfull-regs
d77de738
ML
28097Use full-set registers for register allocation.
28098
d77de738 28099@opindex mcmov
ddf6fe37 28100@item -mcmov
d77de738
ML
28101Generate conditional move instructions.
28102
d77de738 28103@opindex mno-cmov
ddf6fe37 28104@item -mno-cmov
d77de738
ML
28105Do not generate conditional move instructions.
28106
d77de738 28107@opindex mext-perf
ddf6fe37 28108@item -mext-perf
d77de738
ML
28109Generate performance extension instructions.
28110
d77de738 28111@opindex mno-ext-perf
ddf6fe37 28112@item -mno-ext-perf
d77de738
ML
28113Do not generate performance extension instructions.
28114
d77de738 28115@opindex mext-perf2
ddf6fe37 28116@item -mext-perf2
d77de738
ML
28117Generate performance extension 2 instructions.
28118
d77de738 28119@opindex mno-ext-perf2
ddf6fe37 28120@item -mno-ext-perf2
d77de738
ML
28121Do not generate performance extension 2 instructions.
28122
d77de738 28123@opindex mext-string
ddf6fe37 28124@item -mext-string
d77de738
ML
28125Generate string extension instructions.
28126
d77de738 28127@opindex mno-ext-string
ddf6fe37 28128@item -mno-ext-string
d77de738
ML
28129Do not generate string extension instructions.
28130
d77de738 28131@opindex mv3push
ddf6fe37 28132@item -mv3push
d77de738
ML
28133Generate v3 push25/pop25 instructions.
28134
d77de738 28135@opindex mno-v3push
ddf6fe37 28136@item -mno-v3push
d77de738
ML
28137Do not generate v3 push25/pop25 instructions.
28138
d77de738 28139@opindex m16-bit
ddf6fe37 28140@item -m16-bit
d77de738
ML
28141Generate 16-bit instructions.
28142
d77de738 28143@opindex mno-16-bit
ddf6fe37 28144@item -mno-16-bit
d77de738
ML
28145Do not generate 16-bit instructions.
28146
d77de738 28147@opindex misr-vector-size
ddf6fe37 28148@item -misr-vector-size=@var{num}
d77de738
ML
28149Specify the size of each interrupt vector, which must be 4 or 16.
28150
d77de738 28151@opindex mcache-block-size
ddf6fe37 28152@item -mcache-block-size=@var{num}
d77de738
ML
28153Specify the size of each cache block,
28154which must be a power of 2 between 4 and 512.
28155
d77de738 28156@opindex march
ddf6fe37 28157@item -march=@var{arch}
d77de738
ML
28158Specify the name of the target architecture.
28159
d77de738 28160@opindex mcmodel
ddf6fe37 28161@item -mcmodel=@var{code-model}
d77de738
ML
28162Set the code model to one of
28163@table @asis
28164@item @samp{small}
28165All the data and read-only data segments must be within 512KB addressing space.
28166The text segment must be within 16MB addressing space.
28167@item @samp{medium}
28168The data segment must be within 512KB while the read-only data segment can be
28169within 4GB addressing space. The text segment should be still within 16MB
28170addressing space.
28171@item @samp{large}
28172All the text and data segments can be within 4GB addressing space.
28173@end table
28174
d77de738 28175@opindex mctor-dtor
ddf6fe37 28176@item -mctor-dtor
d77de738
ML
28177Enable constructor/destructor feature.
28178
d77de738 28179@opindex mrelax
ddf6fe37 28180@item -mrelax
d77de738
ML
28181Guide linker to relax instructions.
28182
28183@end table
28184
28185@node Nios II Options
28186@subsection Nios II Options
28187@cindex Nios II options
28188@cindex Altera Nios II options
28189
28190These are the options defined for the Altera Nios II processor.
28191
28192@table @gcctabopt
28193
d77de738
ML
28194@opindex G
28195@cindex smaller data references
f33d7a88 28196@item -G @var{num}
d77de738
ML
28197Put global and static objects less than or equal to @var{num} bytes
28198into the small data or BSS sections instead of the normal data or BSS
28199sections. The default value of @var{num} is 8.
28200
ddf6fe37
AA
28201@opindex mgpopt
28202@opindex mno-gpopt
d77de738
ML
28203@item -mgpopt=@var{option}
28204@itemx -mgpopt
28205@itemx -mno-gpopt
d77de738
ML
28206Generate (do not generate) GP-relative accesses. The following
28207@var{option} names are recognized:
28208
28209@table @samp
28210
28211@item none
28212Do not generate GP-relative accesses.
28213
28214@item local
28215Generate GP-relative accesses for small data objects that are not
28216external, weak, or uninitialized common symbols.
28217Also use GP-relative addressing for objects that
28218have been explicitly placed in a small data section via a @code{section}
28219attribute.
28220
28221@item global
28222As for @samp{local}, but also generate GP-relative accesses for
28223small data objects that are external, weak, or common. If you use this option,
28224you must ensure that all parts of your program (including libraries) are
28225compiled with the same @option{-G} setting.
28226
28227@item data
28228Generate GP-relative accesses for all data objects in the program. If you
28229use this option, the entire data and BSS segments
28230of your program must fit in 64K of memory and you must use an appropriate
28231linker script to allocate them within the addressable range of the
28232global pointer.
28233
28234@item all
28235Generate GP-relative addresses for function pointers as well as data
28236pointers. If you use this option, the entire text, data, and BSS segments
28237of your program must fit in 64K of memory and you must use an appropriate
28238linker script to allocate them within the addressable range of the
28239global pointer.
28240
28241@end table
28242
28243@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28244@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28245
28246The default is @option{-mgpopt} except when @option{-fpic} or
28247@option{-fPIC} is specified to generate position-independent code.
28248Note that the Nios II ABI does not permit GP-relative accesses from
28249shared libraries.
28250
28251You may need to specify @option{-mno-gpopt} explicitly when building
28252programs that include large amounts of small data, including large
28253GOT data sections. In this case, the 16-bit offset for GP-relative
28254addressing may not be large enough to allow access to the entire
28255small data section.
28256
d77de738 28257@opindex mgprel-sec
ddf6fe37 28258@item -mgprel-sec=@var{regexp}
d77de738
ML
28259This option specifies additional section names that can be accessed via
28260GP-relative addressing. It is most useful in conjunction with
28261@code{section} attributes on variable declarations
28262(@pxref{Common Variable Attributes}) and a custom linker script.
28263The @var{regexp} is a POSIX Extended Regular Expression.
28264
28265This option does not affect the behavior of the @option{-G} option, and
28266the specified sections are in addition to the standard @code{.sdata}
28267and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28268
d77de738 28269@opindex mr0rel-sec
ddf6fe37 28270@item -mr0rel-sec=@var{regexp}
d77de738
ML
28271This option specifies names of sections that can be accessed via a
2827216-bit offset from @code{r0}; that is, in the low 32K or high 32K
28273of the 32-bit address space. It is most useful in conjunction with
28274@code{section} attributes on variable declarations
28275(@pxref{Common Variable Attributes}) and a custom linker script.
28276The @var{regexp} is a POSIX Extended Regular Expression.
28277
28278In contrast to the use of GP-relative addressing for small data,
28279zero-based addressing is never generated by default and there are no
28280conventional section names used in standard linker scripts for sections
28281in the low or high areas of memory.
28282
d77de738
ML
28283@opindex mel
28284@opindex meb
ddf6fe37
AA
28285@item -mel
28286@itemx -meb
d77de738
ML
28287Generate little-endian (default) or big-endian (experimental) code,
28288respectively.
28289
d77de738 28290@opindex march
ddf6fe37 28291@item -march=@var{arch}
d77de738
ML
28292This specifies the name of the target Nios II architecture. GCC uses this
28293name to determine what kind of instructions it can emit when generating
28294assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28295
28296The preprocessor macro @code{__nios2_arch__} is available to programs,
28297with value 1 or 2, indicating the targeted ISA level.
28298
d77de738
ML
28299@opindex mno-bypass-cache
28300@opindex mbypass-cache
ddf6fe37
AA
28301@item -mbypass-cache
28302@itemx -mno-bypass-cache
d77de738
ML
28303Force all load and store instructions to always bypass cache by
28304using I/O variants of the instructions. The default is not to
28305bypass the cache.
28306
d77de738
ML
28307@opindex mcache-volatile
28308@opindex mno-cache-volatile
ddf6fe37
AA
28309@item -mno-cache-volatile
28310@itemx -mcache-volatile
d77de738
ML
28311Volatile memory access bypass the cache using the I/O variants of
28312the load and store instructions. The default is not to bypass the cache.
28313
d77de738
ML
28314@opindex mno-fast-sw-div
28315@opindex mfast-sw-div
ddf6fe37
AA
28316@item -mno-fast-sw-div
28317@itemx -mfast-sw-div
d77de738
ML
28318Do not use table-based fast divide for small numbers. The default
28319is to use the fast divide at @option{-O3} and above.
28320
d77de738
ML
28321@opindex mno-hw-mul
28322@opindex mhw-mul
28323@opindex mno-hw-mulx
28324@opindex mhw-mulx
28325@opindex mno-hw-div
28326@opindex mhw-div
ddf6fe37
AA
28327@item -mno-hw-mul
28328@itemx -mhw-mul
28329@itemx -mno-hw-mulx
28330@itemx -mhw-mulx
28331@itemx -mno-hw-div
28332@itemx -mhw-div
d77de738
ML
28333Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28334instructions by the compiler. The default is to emit @code{mul}
28335and not emit @code{div} and @code{mulx}.
28336
28337@item -mbmx
28338@itemx -mno-bmx
28339@itemx -mcdx
28340@itemx -mno-cdx
28341Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28342CDX (code density) instructions. Enabling these instructions also
28343requires @option{-march=r2}. Since these instructions are optional
28344extensions to the R2 architecture, the default is not to emit them.
28345
d77de738
ML
28346@opindex mcustom-@var{insn}
28347@opindex mno-custom-@var{insn}
ddf6fe37
AA
28348@item -mcustom-@var{insn}=@var{N}
28349@itemx -mno-custom-@var{insn}
d77de738
ML
28350Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28351custom instruction with encoding @var{N} when generating code that uses
28352@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28353instruction 253 for single-precision floating-point add operations instead
28354of the default behavior of using a library call.
28355
28356The following values of @var{insn} are supported. Except as otherwise
28357noted, floating-point operations are expected to be implemented with
28358normal IEEE 754 semantics and correspond directly to the C operators or the
28359equivalent GCC built-in functions (@pxref{Other Builtins}).
28360
28361Single-precision floating point:
28362@table @asis
28363
28364@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28365Binary arithmetic operations.
28366
28367@item @samp{fnegs}
28368Unary negation.
28369
28370@item @samp{fabss}
28371Unary absolute value.
28372
28373@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28374Comparison operations.
28375
28376@item @samp{fmins}, @samp{fmaxs}
28377Floating-point minimum and maximum. These instructions are only
28378generated if @option{-ffinite-math-only} is specified.
28379
28380@item @samp{fsqrts}
28381Unary square root operation.
28382
28383@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28384Floating-point trigonometric and exponential functions. These instructions
28385are only generated if @option{-funsafe-math-optimizations} is also specified.
28386
28387@end table
28388
28389Double-precision floating point:
28390@table @asis
28391
28392@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28393Binary arithmetic operations.
28394
28395@item @samp{fnegd}
28396Unary negation.
28397
28398@item @samp{fabsd}
28399Unary absolute value.
28400
28401@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28402Comparison operations.
28403
28404@item @samp{fmind}, @samp{fmaxd}
28405Double-precision minimum and maximum. These instructions are only
28406generated if @option{-ffinite-math-only} is specified.
28407
28408@item @samp{fsqrtd}
28409Unary square root operation.
28410
28411@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28412Double-precision trigonometric and exponential functions. These instructions
28413are only generated if @option{-funsafe-math-optimizations} is also specified.
28414
28415@end table
28416
28417Conversions:
28418@table @asis
28419@item @samp{fextsd}
28420Conversion from single precision to double precision.
28421
28422@item @samp{ftruncds}
28423Conversion from double precision to single precision.
28424
28425@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28426Conversion from floating point to signed or unsigned integer types, with
28427truncation towards zero.
28428
28429@item @samp{round}
28430Conversion from single-precision floating point to signed integer,
28431rounding to the nearest integer and ties away from zero.
28432This corresponds to the @code{__builtin_lroundf} function when
28433@option{-fno-math-errno} is used.
28434
28435@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28436Conversion from signed or unsigned integer types to floating-point types.
28437
28438@end table
28439
28440In addition, all of the following transfer instructions for internal
28441registers X and Y must be provided to use any of the double-precision
28442floating-point instructions. Custom instructions taking two
28443double-precision source operands expect the first operand in the
2844464-bit register X. The other operand (or only operand of a unary
28445operation) is given to the custom arithmetic instruction with the
28446least significant half in source register @var{src1} and the most
28447significant half in @var{src2}. A custom instruction that returns a
28448double-precision result returns the most significant 32 bits in the
28449destination register and the other half in 32-bit register Y.
28450GCC automatically generates the necessary code sequences to write
28451register X and/or read register Y when double-precision floating-point
28452instructions are used.
28453
28454@table @asis
28455
28456@item @samp{fwrx}
28457Write @var{src1} into the least significant half of X and @var{src2} into
28458the most significant half of X.
28459
28460@item @samp{fwry}
28461Write @var{src1} into Y.
28462
28463@item @samp{frdxhi}, @samp{frdxlo}
28464Read the most or least (respectively) significant half of X and store it in
28465@var{dest}.
28466
28467@item @samp{frdy}
28468Read the value of Y and store it into @var{dest}.
28469@end table
28470
28471Note that you can gain more local control over generation of Nios II custom
28472instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28473and @code{target("no-custom-@var{insn}")} function attributes
28474(@pxref{Function Attributes})
28475or pragmas (@pxref{Function Specific Option Pragmas}).
28476
d77de738 28477@opindex mcustom-fpu-cfg
ddf6fe37 28478@item -mcustom-fpu-cfg=@var{name}
d77de738
ML
28479
28480This option enables a predefined, named set of custom instruction encodings
28481(see @option{-mcustom-@var{insn}} above).
28482Currently, the following sets are defined:
28483
28484@option{-mcustom-fpu-cfg=60-1} is equivalent to:
43b72ede
AA
28485@gccoptlist{-mcustom-fmuls=252
28486-mcustom-fadds=253
28487-mcustom-fsubs=254
d77de738
ML
28488-fsingle-precision-constant}
28489
28490@option{-mcustom-fpu-cfg=60-2} is equivalent to:
43b72ede
AA
28491@gccoptlist{-mcustom-fmuls=252
28492-mcustom-fadds=253
28493-mcustom-fsubs=254
28494-mcustom-fdivs=255
d77de738
ML
28495-fsingle-precision-constant}
28496
28497@option{-mcustom-fpu-cfg=72-3} is equivalent to:
43b72ede
AA
28498@gccoptlist{-mcustom-floatus=243
28499-mcustom-fixsi=244
28500-mcustom-floatis=245
28501-mcustom-fcmpgts=246
28502-mcustom-fcmples=249
28503-mcustom-fcmpeqs=250
28504-mcustom-fcmpnes=251
28505-mcustom-fmuls=252
28506-mcustom-fadds=253
28507-mcustom-fsubs=254
28508-mcustom-fdivs=255
d77de738
ML
28509-fsingle-precision-constant}
28510
28511@option{-mcustom-fpu-cfg=fph2} is equivalent to:
43b72ede
AA
28512@gccoptlist{-mcustom-fabss=224
28513-mcustom-fnegs=225
28514-mcustom-fcmpnes=226
28515-mcustom-fcmpeqs=227
28516-mcustom-fcmpges=228
28517-mcustom-fcmpgts=229
28518-mcustom-fcmples=230
28519-mcustom-fcmplts=231
28520-mcustom-fmaxs=232
28521-mcustom-fmins=233
28522-mcustom-round=248
28523-mcustom-fixsi=249
28524-mcustom-floatis=250
28525-mcustom-fsqrts=251
28526-mcustom-fmuls=252
28527-mcustom-fadds=253
28528-mcustom-fsubs=254
28529-mcustom-fdivs=255}
d77de738
ML
28530
28531Custom instruction assignments given by individual
28532@option{-mcustom-@var{insn}=} options override those given by
28533@option{-mcustom-fpu-cfg=}, regardless of the
28534order of the options on the command line.
28535
28536Note that you can gain more local control over selection of a FPU
28537configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28538function attribute (@pxref{Function Attributes})
28539or pragma (@pxref{Function Specific Option Pragmas}).
28540
28541The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28542Hardware 2 Component}. Please note that the custom instructions enabled by
28543@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28544if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28545@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28546specified. In contrast to the other configurations,
28547@option{-fsingle-precision-constant} is not set.
28548
28549@end table
28550
28551These additional @samp{-m} options are available for the Altera Nios II
28552ELF (bare-metal) target:
28553
28554@table @gcctabopt
28555
d77de738 28556@opindex mhal
ddf6fe37 28557@item -mhal
d77de738
ML
28558Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28559startup and termination code, and is typically used in conjunction with
28560@option{-msys-crt0=} to specify the location of the alternate startup code
28561provided by the HAL BSP.
28562
d77de738 28563@opindex msmallc
ddf6fe37 28564@item -msmallc
d77de738
ML
28565Link with a limited version of the C library, @option{-lsmallc}, rather than
28566Newlib.
28567
d77de738 28568@opindex msys-crt0
ddf6fe37 28569@item -msys-crt0=@var{startfile}
d77de738
ML
28570@var{startfile} is the file name of the startfile (crt0) to use
28571when linking. This option is only useful in conjunction with @option{-mhal}.
28572
d77de738 28573@opindex msys-lib
ddf6fe37 28574@item -msys-lib=@var{systemlib}
d77de738
ML
28575@var{systemlib} is the library name of the library that provides
28576low-level system calls required by the C library,
28577e.g.@: @code{read} and @code{write}.
28578This option is typically used to link with a library provided by a HAL BSP.
28579
28580@end table
28581
28582@node Nvidia PTX Options
28583@subsection Nvidia PTX Options
28584@cindex Nvidia PTX options
28585@cindex nvptx options
28586
28587These options are defined for Nvidia PTX:
28588
28589@table @gcctabopt
28590
d77de738 28591@opindex m64
ddf6fe37 28592@item -m64
d77de738
ML
28593Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28594supported.
28595
d77de738 28596@opindex march
ddf6fe37 28597@item -march=@var{architecture-string}
d77de738
ML
28598Generate code for the specified PTX ISA target architecture
28599(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
28600@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
28601@samp{sm_80}.
28602The default depends on how the compiler has been configured, see
28603@option{--with-arch}.
28604
28605This option sets the value of the preprocessor macro
28606@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
28607@samp{350}.
28608
d77de738 28609@opindex misa
ddf6fe37 28610@item -misa=@var{architecture-string}
d77de738
ML
28611Alias of @option{-march=}.
28612
d77de738 28613@opindex march
ddf6fe37 28614@item -march-map=@var{architecture-string}
d77de738
ML
28615Select the closest available @option{-march=} value that is not more
28616capable. For instance, for @option{-march-map=sm_50} select
28617@option{-march=sm_35}, and for @option{-march-map=sm_53} select
28618@option{-march=sm_53}.
28619
d77de738 28620@opindex mptx
ddf6fe37 28621@item -mptx=@var{version-string}
d77de738
ML
28622Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
28623Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
28624@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
28625version is required for specified PTX ISA target architecture via
28626option @option{-march=}.
28627
28628This option sets the values of the preprocessor macros
28629@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
28630for instance, for @samp{3.1} the macros have the values @samp{3} and
28631@samp{1}, respectively.
28632
d77de738 28633@opindex mmainkernel
ddf6fe37 28634@item -mmainkernel
d77de738
ML
28635Link in code for a __main kernel. This is for stand-alone instead of
28636offloading execution.
28637
d77de738 28638@opindex moptimize
ddf6fe37 28639@item -moptimize
d77de738
ML
28640Apply partitioned execution optimizations. This is the default when any
28641level of optimization is selected.
28642
d77de738 28643@opindex msoft-stack
ddf6fe37 28644@item -msoft-stack
d77de738
ML
28645Generate code that does not use @code{.local} memory
28646directly for stack storage. Instead, a per-warp stack pointer is
28647maintained explicitly. This enables variable-length stack allocation (with
28648variable-length arrays or @code{alloca}), and when global memory is used for
28649underlying storage, makes it possible to access automatic variables from other
28650threads, or with atomic instructions. This code generation variant is used
28651for OpenMP offloading, but the option is exposed on its own for the purpose
28652of testing the compiler; to generate code suitable for linking into programs
28653using OpenMP offloading, use option @option{-mgomp}.
28654
d77de738 28655@opindex muniform-simt
ddf6fe37 28656@item -muniform-simt
d77de738
ML
28657Switch to code generation variant that allows to execute all threads in each
28658warp, while maintaining memory state and side effects as if only one thread
28659in each warp was active outside of OpenMP SIMD regions. All atomic operations
28660and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
28661current lane index equals the master lane index), and the register being
28662assigned is copied via a shuffle instruction from the master lane. Outside of
28663SIMD regions lane 0 is the master; inside, each thread sees itself as the
28664master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
28665all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
28666regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
28667with current lane index to compute the master lane index.
28668
d77de738 28669@opindex mgomp
ddf6fe37 28670@item -mgomp
d77de738
ML
28671Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
28672@option{-muniform-simt} options, and selects corresponding multilib variant.
28673
28674@end table
28675
28676@node OpenRISC Options
28677@subsection OpenRISC Options
28678@cindex OpenRISC Options
28679
28680These options are defined for OpenRISC:
28681
28682@table @gcctabopt
28683
d77de738 28684@opindex mboard
ddf6fe37 28685@item -mboard=@var{name}
d77de738
ML
28686Configure a board specific runtime. This will be passed to the linker for
28687newlib board library linking. The default is @code{or1ksim}.
28688
d77de738 28689@opindex mnewlib
ddf6fe37 28690@item -mnewlib
d77de738
ML
28691This option is ignored; it is for compatibility purposes only. This used to
28692select linker and preprocessor options for use with newlib.
28693
d77de738
ML
28694@opindex msoft-div
28695@opindex mhard-div
ddf6fe37
AA
28696@item -msoft-div
28697@itemx -mhard-div
d77de738
ML
28698Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
28699This default is hardware divide.
28700
d77de738
ML
28701@opindex msoft-mul
28702@opindex mhard-mul
ddf6fe37
AA
28703@item -msoft-mul
28704@itemx -mhard-mul
d77de738
ML
28705Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
28706This default is hardware multiply.
28707
d77de738
ML
28708@opindex msoft-float
28709@opindex mhard-float
ddf6fe37
AA
28710@item -msoft-float
28711@itemx -mhard-float
d77de738
ML
28712Select software or hardware for floating point operations.
28713The default is software.
28714
d77de738 28715@opindex mdouble-float
ddf6fe37 28716@item -mdouble-float
d77de738
ML
28717When @option{-mhard-float} is selected, enables generation of double-precision
28718floating point instructions. By default functions from @file{libgcc} are used
28719to perform double-precision floating point operations.
28720
d77de738 28721@opindex munordered-float
ddf6fe37 28722@item -munordered-float
d77de738
ML
28723When @option{-mhard-float} is selected, enables generation of unordered
28724floating point compare and set flag (@code{lf.sfun*}) instructions. By default
28725functions from @file{libgcc} are used to perform unordered floating point
28726compare and set flag operations.
28727
d77de738 28728@opindex mcmov
ddf6fe37 28729@item -mcmov
d77de738
ML
28730Enable generation of conditional move (@code{l.cmov}) instructions. By
28731default the equivalent will be generated using set and branch.
28732
d77de738 28733@opindex mror
ddf6fe37 28734@item -mror
d77de738
ML
28735Enable generation of rotate right (@code{l.ror}) instructions. By default
28736functions from @file{libgcc} are used to perform rotate right operations.
28737
d77de738 28738@opindex mrori
ddf6fe37 28739@item -mrori
d77de738
ML
28740Enable generation of rotate right with immediate (@code{l.rori}) instructions.
28741By default functions from @file{libgcc} are used to perform rotate right with
28742immediate operations.
28743
d77de738 28744@opindex msext
ddf6fe37 28745@item -msext
d77de738
ML
28746Enable generation of sign extension (@code{l.ext*}) instructions. By default
28747memory loads are used to perform sign extension.
28748
d77de738 28749@opindex msfimm
ddf6fe37 28750@item -msfimm
d77de738
ML
28751Enable generation of compare and set flag with immediate (@code{l.sf*i})
28752instructions. By default extra instructions will be generated to store the
28753immediate to a register first.
28754
d77de738 28755@opindex mshftimm
ddf6fe37 28756@item -mshftimm
d77de738
ML
28757Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
28758@code{l.slli}) instructions. By default extra instructions will be generated
28759to store the immediate to a register first.
28760
d77de738 28761@opindex mcmodel=small
ddf6fe37 28762@item -mcmodel=small
d77de738
ML
28763Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
28764the default model.
28765
d77de738 28766@opindex mcmodel=large
ddf6fe37 28767@item -mcmodel=large
d77de738
ML
28768Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
28769
28770
28771@end table
28772
28773@node PDP-11 Options
28774@subsection PDP-11 Options
28775@cindex PDP-11 Options
28776
28777These options are defined for the PDP-11:
28778
28779@table @gcctabopt
d77de738 28780@opindex mfpu
ddf6fe37 28781@item -mfpu
d77de738
ML
28782Use hardware FPP floating point. This is the default. (FIS floating
28783point on the PDP-11/40 is not supported.) Implies -m45.
28784
d77de738 28785@opindex msoft-float
ddf6fe37 28786@item -msoft-float
d77de738
ML
28787Do not use hardware floating point.
28788
d77de738 28789@opindex mac0
ddf6fe37 28790@item -mac0
d77de738
ML
28791Return floating-point results in ac0 (fr0 in Unix assembler syntax).
28792
d77de738 28793@opindex mno-ac0
ddf6fe37 28794@item -mno-ac0
d77de738
ML
28795Return floating-point results in memory. This is the default.
28796
d77de738 28797@opindex m40
ddf6fe37 28798@item -m40
d77de738
ML
28799Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
28800
d77de738 28801@opindex m45
ddf6fe37 28802@item -m45
d77de738
ML
28803Generate code for a PDP-11/45. This is the default.
28804
d77de738 28805@opindex m10
ddf6fe37 28806@item -m10
d77de738
ML
28807Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
28808
d77de738
ML
28809@opindex mint16
28810@opindex mno-int32
ddf6fe37
AA
28811@item -mint16
28812@itemx -mno-int32
d77de738
ML
28813Use 16-bit @code{int}. This is the default.
28814
d77de738
ML
28815@opindex mint32
28816@opindex mno-int16
ddf6fe37
AA
28817@item -mint32
28818@itemx -mno-int16
d77de738
ML
28819Use 32-bit @code{int}.
28820
d77de738 28821@opindex msplit
ddf6fe37 28822@item -msplit
d77de738
ML
28823Target has split instruction and data space. Implies -m45.
28824
d77de738 28825@opindex munix-asm
ddf6fe37 28826@item -munix-asm
d77de738
ML
28827Use Unix assembler syntax.
28828
d77de738 28829@opindex mdec-asm
ddf6fe37 28830@item -mdec-asm
d77de738
ML
28831Use DEC assembler syntax.
28832
d77de738 28833@opindex mgnu-asm
ddf6fe37 28834@item -mgnu-asm
d77de738
ML
28835Use GNU assembler syntax. This is the default.
28836
d77de738 28837@opindex mlra
ddf6fe37 28838@item -mlra
d77de738
ML
28839Use the new LRA register allocator. By default, the old ``reload''
28840allocator is used.
28841@end table
28842
d77de738
ML
28843@node PowerPC Options
28844@subsection PowerPC Options
28845@cindex PowerPC options
28846
28847These are listed under @xref{RS/6000 and PowerPC Options}.
28848
28849@node PRU Options
28850@subsection PRU Options
28851@cindex PRU Options
28852
28853These command-line options are defined for PRU target:
28854
28855@table @gcctabopt
d77de738 28856@opindex minrt
ddf6fe37 28857@item -minrt
d77de738
ML
28858Link with a minimum runtime environment, with no support for static
28859initializers and constructors. Using this option can significantly reduce
28860the size of the final ELF binary. Beware that the compiler could still
28861generate code with static initializers and constructors. It is up to the
28862programmer to ensure that the source program will not use those features.
28863
d77de738 28864@opindex mmcu
ddf6fe37 28865@item -mmcu=@var{mcu}
d77de738
ML
28866Specify the PRU MCU variant to use. Check Newlib for the exact list of
28867supported MCUs.
28868
d77de738 28869@opindex mno-relax
ddf6fe37 28870@item -mno-relax
d77de738
ML
28871Make GCC pass the @option{--no-relax} command-line option to the linker
28872instead of the @option{--relax} option.
28873
d77de738 28874@opindex mloop
ddf6fe37 28875@item -mloop
d77de738
ML
28876Allow (or do not allow) GCC to use the LOOP instruction.
28877
d77de738 28878@opindex mabi
ddf6fe37 28879@item -mabi=@var{variant}
d77de738
ML
28880Specify the ABI variant to output code for. @option{-mabi=ti} selects the
28881unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
28882more naturally with certain GCC assumptions. These are the differences:
28883
28884@table @samp
28885@item Function Pointer Size
28886TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
28887supports only 32-bit data and code pointers.
28888
28889@item Optional Return Value Pointer
28890Function return values larger than 64 bits are passed by using a hidden
28891pointer as the first argument of the function. TI ABI, though, mandates that
28892the pointer can be NULL in case the caller is not using the returned value.
28893GNU always passes and expects a valid return value pointer.
28894
28895@end table
28896
28897The current @option{-mabi=ti} implementation simply raises a compile error
28898when any of the above code constructs is detected. As a consequence
28899the standard C library cannot be built and it is omitted when linking with
28900@option{-mabi=ti}.
28901
28902Relaxation is a GNU feature and for safety reasons is disabled when using
28903@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
28904instructions, so the GNU linker cannot adjust them when shortening adjacent
28905LDI32 pseudo instructions.
28906
28907@end table
28908
28909@node RISC-V Options
28910@subsection RISC-V Options
28911@cindex RISC-V Options
28912
28913These command-line options are defined for RISC-V targets:
28914
28915@table @gcctabopt
d77de738 28916@opindex mbranch-cost
ddf6fe37 28917@item -mbranch-cost=@var{n}
d77de738
ML
28918Set the cost of branches to roughly @var{n} instructions.
28919
ddf6fe37 28920@opindex plt
d77de738
ML
28921@item -mplt
28922@itemx -mno-plt
d77de738
ML
28923When generating PIC code, do or don't allow the use of PLTs. Ignored for
28924non-PIC. The default is @option{-mplt}.
28925
d77de738 28926@opindex mabi
ddf6fe37 28927@item -mabi=@var{ABI-string}
d77de738
ML
28928Specify integer and floating-point calling convention. @var{ABI-string}
28929contains two parts: the size of integer types and the registers used for
28930floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
28931@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2893232-bit), and that floating-point values up to 64 bits wide are passed in F
28933registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
28934allows the compiler to generate code that uses the F and D extensions but only
28935allows floating-point values up to 32 bits long to be passed in registers; or
28936@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
28937passed in registers.
28938
28939The default for this argument is system dependent, users who want a specific
28940calling convention should specify one explicitly. The valid calling
28941conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
28942@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
28943implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
28944invalid because the ABI requires 64-bit values be passed in F registers, but F
28945registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
28946only be used with the @samp{rv32e} architecture. This ABI is not well
28947specified at present, and is subject to change.
28948
ddf6fe37 28949@opindex mfdiv
d77de738
ML
28950@item -mfdiv
28951@itemx -mno-fdiv
d77de738
ML
28952Do or don't use hardware floating-point divide and square root instructions.
28953This requires the F or D extensions for floating-point registers. The default
28954is to use them if the specified architecture has these instructions.
28955
ddf6fe37 28956@opindex mdiv
d77de738
ML
28957@item -mdiv
28958@itemx -mno-div
d77de738
ML
28959Do or don't use hardware instructions for integer division. This requires the
28960M extension. The default is to use them if the specified architecture has
28961these instructions.
28962
d77de738 28963@opindex misa-spec
ddf6fe37 28964@item -misa-spec=@var{ISA-spec-string}
d77de738
ML
28965Specify the version of the RISC-V Unprivileged (formerly User-Level)
28966ISA specification to produce code conforming to. The possibilities
28967for @var{ISA-spec-string} are:
28968@table @code
28969@item 2.2
28970Produce code conforming to version 2.2.
28971@item 20190608
28972Produce code conforming to version 20190608.
28973@item 20191213
28974Produce code conforming to version 20191213.
28975@end table
28976The default is @option{-misa-spec=20191213} unless GCC has been configured
28977with @option{--with-isa-spec=} specifying a different default version.
28978
d77de738 28979@opindex march
ddf6fe37 28980@item -march=@var{ISA-string}
d77de738
ML
28981Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
28982lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
28983@samp{rv32imaf}.
28984
28985When @option{-march=} is not specified, use the setting from @option{-mcpu}.
28986
28987If both @option{-march} and @option{-mcpu=} are not specified, the default for
28988this argument is system dependent, users who want a specific architecture
28989extensions should specify one explicitly.
28990
d77de738 28991@opindex mcpu
ddf6fe37 28992@item -mcpu=@var{processor-string}
d77de738
ML
28993Use architecture of and optimize the output for the given processor, specified
28994by particular CPU name.
28995Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
28996@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
28997@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 28998@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738 28999
d77de738 29000@opindex mtune
ddf6fe37 29001@item -mtune=@var{processor-string}
d77de738
ML
29002Optimize the output for the given processor, specified by microarchitecture or
29003particular CPU name. Permissible values for this option are: @samp{rocket},
29004@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 29005@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
29006
29007When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
29008the default is @samp{rocket} if both are not specified.
29009
29010The @samp{size} choice is not intended for use by end-users. This is used
29011when @option{-Os} is specified. It overrides the instruction cost info
29012provided by @option{-mtune=}, but does not override the pipeline info. This
29013helps reduce code size while still giving good performance.
29014
d77de738 29015@opindex mpreferred-stack-boundary
ddf6fe37 29016@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
29017Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
29018byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
29019the default is 4 (16 bytes or 128-bits).
29020
29021@strong{Warning:} If you use this switch, then you must build all modules with
29022the same value, including any libraries. This includes the system libraries
29023and startup modules.
29024
d77de738 29025@opindex msmall-data-limit
ddf6fe37 29026@item -msmall-data-limit=@var{n}
d77de738
ML
29027Put global and static data smaller than @var{n} bytes into a special section
29028(on some targets).
29029
ddf6fe37 29030@opindex msave-restore
d77de738
ML
29031@item -msave-restore
29032@itemx -mno-save-restore
d77de738
ML
29033Do or don't use smaller but slower prologue and epilogue code that uses
29034library function calls. The default is to use fast inline prologues and
29035epilogues.
29036
f797260a
PN
29037@opindex minline-atomics
29038@item -minline-atomics
29039@itemx -mno-inline-atomics
29040Do or don't use smaller but slower subword atomic emulation code that uses
29041libatomic function calls. The default is to use fast inline subword atomics
29042that do not require libatomic.
29043
ddf6fe37 29044@opindex mshorten-memrefs
d77de738
ML
29045@item -mshorten-memrefs
29046@itemx -mno-shorten-memrefs
d77de738
ML
29047Do or do not attempt to make more use of compressed load/store instructions by
29048replacing a load/store of 'base register + large offset' with a new load/store
29049of 'new base + small offset'. If the new base gets stored in a compressed
29050register, then the new load/store can be compressed. Currently targets 32-bit
29051integer load/stores only.
29052
ddf6fe37 29053@opindex mstrict-align
d77de738
ML
29054@item -mstrict-align
29055@itemx -mno-strict-align
d77de738
ML
29056Do not or do generate unaligned memory accesses. The default is set depending
29057on whether the processor we are optimizing for supports fast unaligned access
29058or not.
29059
d77de738 29060@opindex mcmodel=medlow
ddf6fe37 29061@item -mcmodel=medlow
d77de738
ML
29062Generate code for the medium-low code model. The program and its statically
29063defined symbols must lie within a single 2 GiB address range and must lie
29064between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
29065statically or dynamically linked. This is the default code model.
29066
d77de738 29067@opindex mcmodel=medany
ddf6fe37 29068@item -mcmodel=medany
d77de738
ML
29069Generate code for the medium-any code model. The program and its statically
29070defined symbols must be within any single 2 GiB address range. Programs can be
29071statically or dynamically linked.
29072
29073The code generated by the medium-any code model is position-independent, but is
29074not guaranteed to function correctly when linked into position-independent
29075executables or libraries.
29076
29077@item -mexplicit-relocs
29078@itemx -mno-exlicit-relocs
29079Use or do not use assembler relocation operators when dealing with symbolic
29080addresses. The alternative is to use assembler macros instead, which may
29081limit optimization.
29082
ddf6fe37 29083@opindex mrelax
d77de738
ML
29084@item -mrelax
29085@itemx -mno-relax
d77de738
ML
29086Take advantage of linker relaxations to reduce the number of instructions
29087required to materialize symbol addresses. The default is to take advantage of
29088linker relaxations.
29089
ddf6fe37 29090@opindex mriscv-attribute
d77de738
ML
29091@item -mriscv-attribute
29092@itemx -mno-riscv-attribute
d77de738
ML
29093Emit (do not emit) RISC-V attribute to record extra information into ELF
29094objects. This feature requires at least binutils 2.32.
29095
ddf6fe37 29096@opindex mcsr-check
d77de738
ML
29097@item -mcsr-check
29098@itemx -mno-csr-check
d77de738
ML
29099Enables or disables the CSR checking.
29100
d77de738 29101@opindex malign-data
ddf6fe37 29102@item -malign-data=@var{type}
d77de738
ML
29103Control how GCC aligns variables and constants of array, structure, or union
29104types. Supported values for @var{type} are @samp{xlen} which uses x register
29105width as the alignment value, and @samp{natural} which uses natural alignment.
29106@samp{xlen} is the default.
29107
d77de738 29108@opindex mbig-endian
ddf6fe37 29109@item -mbig-endian
d77de738
ML
29110Generate big-endian code. This is the default when GCC is configured for a
29111@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
29112
d77de738 29113@opindex mlittle-endian
ddf6fe37 29114@item -mlittle-endian
d77de738
ML
29115Generate little-endian code. This is the default when GCC is configured for a
29116@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
29117@samp{riscv32be-*-*} target.
29118
d77de738
ML
29119@opindex mstack-protector-guard
29120@opindex mstack-protector-guard-reg
29121@opindex mstack-protector-guard-offset
ddf6fe37
AA
29122@item -mstack-protector-guard=@var{guard}
29123@itemx -mstack-protector-guard-reg=@var{reg}
29124@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
29125Generate stack protection code using canary at @var{guard}. Supported
29126locations are @samp{global} for a global canary or @samp{tls} for per-thread
29127canary in the TLS block.
29128
29129With the latter choice the options
29130@option{-mstack-protector-guard-reg=@var{reg}} and
29131@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
29132which register to use as base register for reading the canary,
29133and from what offset from that base register. There is no default
29134register or offset as this is entirely for use within the Linux
29135kernel.
29136@end table
29137
29138@node RL78 Options
29139@subsection RL78 Options
29140@cindex RL78 Options
29141
29142@table @gcctabopt
29143
d77de738 29144@opindex msim
ddf6fe37 29145@item -msim
d77de738
ML
29146Links in additional target libraries to support operation within a
29147simulator.
29148
ddf6fe37 29149@opindex mmul
d77de738
ML
29150@item -mmul=none
29151@itemx -mmul=g10
29152@itemx -mmul=g13
29153@itemx -mmul=g14
29154@itemx -mmul=rl78
d77de738
ML
29155Specifies the type of hardware multiplication and division support to
29156be used. The simplest is @code{none}, which uses software for both
29157multiplication and division. This is the default. The @code{g13}
29158value is for the hardware multiply/divide peripheral found on the
29159RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
29160the multiplication and division instructions supported by the RL78/G14
29161(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
29162the value @code{mg10} is an alias for @code{none}.
29163
29164In addition a C preprocessor macro is defined, based upon the setting
29165of this option. Possible values are: @code{__RL78_MUL_NONE__},
29166@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
29167
ddf6fe37 29168@opindex mcpu
d77de738
ML
29169@item -mcpu=g10
29170@itemx -mcpu=g13
29171@itemx -mcpu=g14
29172@itemx -mcpu=rl78
d77de738
ML
29173Specifies the RL78 core to target. The default is the G14 core, also
29174known as an S3 core or just RL78. The G13 or S2 core does not have
29175multiply or divide instructions, instead it uses a hardware peripheral
29176for these operations. The G10 or S1 core does not have register
29177banks, so it uses a different calling convention.
29178
29179If this option is set it also selects the type of hardware multiply
29180support to use, unless this is overridden by an explicit
29181@option{-mmul=none} option on the command line. Thus specifying
29182@option{-mcpu=g13} enables the use of the G13 hardware multiply
29183peripheral and specifying @option{-mcpu=g10} disables the use of
29184hardware multiplications altogether.
29185
29186Note, although the RL78/G14 core is the default target, specifying
29187@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
29188change the behavior of the toolchain since it also enables G14
29189hardware multiply support. If these options are not specified on the
29190command line then software multiplication routines will be used even
29191though the code targets the RL78 core. This is for backwards
29192compatibility with older toolchains which did not have hardware
29193multiply and divide support.
29194
29195In addition a C preprocessor macro is defined, based upon the setting
29196of this option. Possible values are: @code{__RL78_G10__},
29197@code{__RL78_G13__} or @code{__RL78_G14__}.
29198
d77de738
ML
29199@opindex mg10
29200@opindex mg13
29201@opindex mg14
29202@opindex mrl78
ddf6fe37
AA
29203@item -mg10
29204@itemx -mg13
29205@itemx -mg14
29206@itemx -mrl78
d77de738
ML
29207These are aliases for the corresponding @option{-mcpu=} option. They
29208are provided for backwards compatibility.
29209
d77de738 29210@opindex mallregs
ddf6fe37 29211@item -mallregs
d77de738
ML
29212Allow the compiler to use all of the available registers. By default
29213registers @code{r24..r31} are reserved for use in interrupt handlers.
29214With this option enabled these registers can be used in ordinary
29215functions as well.
29216
d77de738
ML
29217@opindex m64bit-doubles
29218@opindex m32bit-doubles
ddf6fe37
AA
29219@item -m64bit-doubles
29220@itemx -m32bit-doubles
d77de738
ML
29221Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29222or 32 bits (@option{-m32bit-doubles}) in size. The default is
29223@option{-m32bit-doubles}.
29224
d77de738
ML
29225@opindex msave-mduc-in-interrupts
29226@opindex mno-save-mduc-in-interrupts
ddf6fe37
AA
29227@item -msave-mduc-in-interrupts
29228@itemx -mno-save-mduc-in-interrupts
d77de738
ML
29229Specifies that interrupt handler functions should preserve the
29230MDUC registers. This is only necessary if normal code might use
29231the MDUC registers, for example because it performs multiplication
29232and division operations. The default is to ignore the MDUC registers
29233as this makes the interrupt handlers faster. The target option -mg13
29234needs to be passed for this to work as this feature is only available
29235on the G13 target (S2 core). The MDUC registers will only be saved
29236if the interrupt handler performs a multiplication or division
29237operation or it calls another function.
29238
29239@end table
29240
29241@node RS/6000 and PowerPC Options
29242@subsection IBM RS/6000 and PowerPC Options
29243@cindex RS/6000 and PowerPC Options
29244@cindex IBM RS/6000 and PowerPC Options
29245
29246These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29247@table @gcctabopt
29248@item -mpowerpc-gpopt
29249@itemx -mno-powerpc-gpopt
29250@itemx -mpowerpc-gfxopt
29251@itemx -mno-powerpc-gfxopt
29252@need 800
29253@itemx -mpowerpc64
29254@itemx -mno-powerpc64
29255@itemx -mmfcrf
29256@itemx -mno-mfcrf
29257@itemx -mpopcntb
29258@itemx -mno-popcntb
29259@itemx -mpopcntd
29260@itemx -mno-popcntd
29261@itemx -mfprnd
29262@itemx -mno-fprnd
29263@need 800
d77de738
ML
29264@opindex mpowerpc-gpopt
29265@opindex mno-powerpc-gpopt
29266@opindex mpowerpc-gfxopt
29267@opindex mno-powerpc-gfxopt
29268@opindex mpowerpc64
29269@opindex mno-powerpc64
29270@opindex mmfcrf
29271@opindex mno-mfcrf
29272@opindex mpopcntb
29273@opindex mno-popcntb
29274@opindex mpopcntd
29275@opindex mno-popcntd
29276@opindex mfprnd
29277@opindex mno-fprnd
29278@opindex mcmpb
29279@opindex mno-cmpb
29280@opindex mhard-dfp
29281@opindex mno-hard-dfp
ddf6fe37
AA
29282@itemx -mcmpb
29283@itemx -mno-cmpb
29284@itemx -mhard-dfp
29285@itemx -mno-hard-dfp
d77de738
ML
29286You use these options to specify which instructions are available on the
29287processor you are using. The default value of these options is
29288determined when configuring GCC@. Specifying the
29289@option{-mcpu=@var{cpu_type}} overrides the specification of these
29290options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29291rather than the options listed above.
29292
29293Specifying @option{-mpowerpc-gpopt} allows
29294GCC to use the optional PowerPC architecture instructions in the
29295General Purpose group, including floating-point square root. Specifying
29296@option{-mpowerpc-gfxopt} allows GCC to
29297use the optional PowerPC architecture instructions in the Graphics
29298group, including floating-point select.
29299
29300The @option{-mmfcrf} option allows GCC to generate the move from
29301condition register field instruction implemented on the POWER4
29302processor and other processors that support the PowerPC V2.01
29303architecture.
29304The @option{-mpopcntb} option allows GCC to generate the popcount and
29305double-precision FP reciprocal estimate instruction implemented on the
29306POWER5 processor and other processors that support the PowerPC V2.02
29307architecture.
29308The @option{-mpopcntd} option allows GCC to generate the popcount
29309instruction implemented on the POWER7 processor and other processors
29310that support the PowerPC V2.06 architecture.
29311The @option{-mfprnd} option allows GCC to generate the FP round to
29312integer instructions implemented on the POWER5+ processor and other
29313processors that support the PowerPC V2.03 architecture.
29314The @option{-mcmpb} option allows GCC to generate the compare bytes
29315instruction implemented on the POWER6 processor and other processors
29316that support the PowerPC V2.05 architecture.
29317The @option{-mhard-dfp} option allows GCC to generate the decimal
29318floating-point instructions implemented on some POWER processors.
29319
29320The @option{-mpowerpc64} option allows GCC to generate the additional
2932164-bit instructions that are found in the full PowerPC64 architecture
29322and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29323@option{-mno-powerpc64}.
29324
d77de738 29325@opindex mcpu
ddf6fe37 29326@item -mcpu=@var{cpu_type}
d77de738
ML
29327Set architecture type, register usage, and
29328instruction scheduling parameters for machine type @var{cpu_type}.
29329Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29330@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29331@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29332@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29333@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29334@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29335@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29336@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29337@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29338@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29339@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29340@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29341
29342@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29343@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29344endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29345architecture machine types, with an appropriate, generic processor
29346model assumed for scheduling purposes.
29347
29348Specifying @samp{native} as cpu type detects and selects the
29349architecture option that corresponds to the host processor of the
29350system performing the compilation.
29351@option{-mcpu=native} has no effect if GCC does not recognize the
29352processor.
29353
29354The other options specify a specific processor. Code generated under
29355those options runs best on that processor, and may not run at all on
29356others.
29357
29358The @option{-mcpu} options automatically enable or disable the
29359following options:
29360
43b72ede
AA
29361@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple
29362-mpopcntb -mpopcntd -mpowerpc64
29363-mpowerpc-gpopt -mpowerpc-gfxopt
29364-mmulhw -mdlmzb -mmfpgpr -mvsx
29365-mcrypto -mhtm -mpower8-fusion -mpower8-vector
29366-mquad-memory -mquad-memory-atomic -mfloat128
29367-mfloat128-hardware -mprefixed -mpcrel -mmma
d77de738
ML
29368-mrop-protect}
29369
29370The particular options set for any particular CPU varies between
29371compiler versions, depending on what setting seems to produce optimal
29372code for that CPU; it doesn't necessarily reflect the actual hardware's
29373capabilities. If you wish to set an individual option to a particular
29374value, you may specify it after the @option{-mcpu} option, like
29375@option{-mcpu=970 -mno-altivec}.
29376
29377On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29378not enabled or disabled by the @option{-mcpu} option at present because
29379AIX does not have full support for these options. You may still
29380enable or disable them individually if you're sure it'll work in your
29381environment.
29382
d77de738 29383@opindex mtune
ddf6fe37 29384@item -mtune=@var{cpu_type}
d77de738
ML
29385Set the instruction scheduling parameters for machine type
29386@var{cpu_type}, but do not set the architecture type or register usage,
29387as @option{-mcpu=@var{cpu_type}} does. The same
29388values for @var{cpu_type} are used for @option{-mtune} as for
29389@option{-mcpu}. If both are specified, the code generated uses the
29390architecture and registers set by @option{-mcpu}, but the
29391scheduling parameters set by @option{-mtune}.
29392
d77de738 29393@opindex mcmodel=small
ddf6fe37 29394@item -mcmodel=small
d77de738
ML
29395Generate PowerPC64 code for the small model: The TOC is limited to
2939664k.
29397
d77de738 29398@opindex mcmodel=medium
ddf6fe37 29399@item -mcmodel=medium
d77de738
ML
29400Generate PowerPC64 code for the medium model: The TOC and other static
29401data may be up to a total of 4G in size. This is the default for 64-bit
29402Linux.
29403
d77de738 29404@opindex mcmodel=large
ddf6fe37 29405@item -mcmodel=large
d77de738
ML
29406Generate PowerPC64 code for the large model: The TOC may be up to 4G
29407in size. Other data and code is only limited by the 64-bit address
29408space.
29409
d77de738
ML
29410@opindex maltivec
29411@opindex mno-altivec
ddf6fe37
AA
29412@item -maltivec
29413@itemx -mno-altivec
d77de738
ML
29414Generate code that uses (does not use) AltiVec instructions, and also
29415enable the use of built-in functions that allow more direct access to
29416the AltiVec instruction set. You may also need to set
29417@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29418enhancements.
29419
29420When @option{-maltivec} is used, the element order for AltiVec intrinsics
29421such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29422match array element order corresponding to the endianness of the
29423target. That is, element zero identifies the leftmost element in a
29424vector register when targeting a big-endian platform, and identifies
29425the rightmost element in a vector register when targeting a
29426little-endian platform.
29427
d77de738
ML
29428@opindex mvrsave
29429@opindex mno-vrsave
ddf6fe37
AA
29430@item -mvrsave
29431@itemx -mno-vrsave
d77de738
ML
29432Generate VRSAVE instructions when generating AltiVec code.
29433
d77de738 29434@opindex msecure-plt
ddf6fe37 29435@item -msecure-plt
d77de738
ML
29436Generate code that allows @command{ld} and @command{ld.so}
29437to build executables and shared
29438libraries with non-executable @code{.plt} and @code{.got} sections.
29439This is a PowerPC
2944032-bit SYSV ABI option.
29441
d77de738 29442@opindex mbss-plt
ddf6fe37 29443@item -mbss-plt
d77de738
ML
29444Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29445fills in, and
29446requires @code{.plt} and @code{.got}
29447sections that are both writable and executable.
29448This is a PowerPC 32-bit SYSV ABI option.
29449
d77de738
ML
29450@opindex misel
29451@opindex mno-isel
ddf6fe37
AA
29452@item -misel
29453@itemx -mno-isel
d77de738
ML
29454This switch enables or disables the generation of ISEL instructions.
29455
d77de738
ML
29456@opindex mvsx
29457@opindex mno-vsx
ddf6fe37
AA
29458@item -mvsx
29459@itemx -mno-vsx
d77de738
ML
29460Generate code that uses (does not use) vector/scalar (VSX)
29461instructions, and also enable the use of built-in functions that allow
29462more direct access to the VSX instruction set.
29463
d77de738
ML
29464@opindex mcrypto
29465@opindex mno-crypto
ddf6fe37
AA
29466@item -mcrypto
29467@itemx -mno-crypto
d77de738
ML
29468Enable the use (disable) of the built-in functions that allow direct
29469access to the cryptographic instructions that were added in version
294702.07 of the PowerPC ISA.
29471
d77de738
ML
29472@opindex mhtm
29473@opindex mno-htm
ddf6fe37
AA
29474@item -mhtm
29475@itemx -mno-htm
d77de738
ML
29476Enable (disable) the use of the built-in functions that allow direct
29477access to the Hardware Transactional Memory (HTM) instructions that
29478were added in version 2.07 of the PowerPC ISA.
29479
d77de738
ML
29480@opindex mpower8-fusion
29481@opindex mno-power8-fusion
ddf6fe37
AA
29482@item -mpower8-fusion
29483@itemx -mno-power8-fusion
d77de738
ML
29484Generate code that keeps (does not keeps) some integer operations
29485adjacent so that the instructions can be fused together on power8 and
29486later processors.
29487
d77de738
ML
29488@opindex mpower8-vector
29489@opindex mno-power8-vector
ddf6fe37
AA
29490@item -mpower8-vector
29491@itemx -mno-power8-vector
d77de738
ML
29492Generate code that uses (does not use) the vector and scalar
29493instructions that were added in version 2.07 of the PowerPC ISA. Also
29494enable the use of built-in functions that allow more direct access to
29495the vector instructions.
29496
d77de738
ML
29497@opindex mquad-memory
29498@opindex mno-quad-memory
ddf6fe37
AA
29499@item -mquad-memory
29500@itemx -mno-quad-memory
d77de738
ML
29501Generate code that uses (does not use) the non-atomic quad word memory
29502instructions. The @option{-mquad-memory} option requires use of
2950364-bit mode.
29504
d77de738
ML
29505@opindex mquad-memory-atomic
29506@opindex mno-quad-memory-atomic
ddf6fe37
AA
29507@item -mquad-memory-atomic
29508@itemx -mno-quad-memory-atomic
d77de738
ML
29509Generate code that uses (does not use) the atomic quad word memory
29510instructions. The @option{-mquad-memory-atomic} option requires use of
2951164-bit mode.
29512
d77de738
ML
29513@opindex mfloat128
29514@opindex mno-float128
ddf6fe37
AA
29515@item -mfloat128
29516@itemx -mno-float128
d77de738
ML
29517Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29518and use either software emulation for IEEE 128-bit floating point or
29519hardware instructions.
29520
29521The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29522128-bit floating point support. The IEEE 128-bit floating point is only
29523supported on Linux.
29524
29525The default for @option{-mfloat128} is enabled on PowerPC Linux
29526systems using the VSX instruction set, and disabled on other systems.
29527
29528If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29529@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29530point support will also enable the generation of ISA 3.0 IEEE 128-bit
29531floating point instructions. Otherwise, if you do not specify to
29532generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29533system, IEEE 128-bit floating point will be done with software
29534emulation.
29535
d77de738
ML
29536@opindex mfloat128-hardware
29537@opindex mno-float128-hardware
ddf6fe37
AA
29538@item -mfloat128-hardware
29539@itemx -mno-float128-hardware
d77de738
ML
29540Enable/disable using ISA 3.0 hardware instructions to support the
29541@var{__float128} data type.
29542
29543The default for @option{-mfloat128-hardware} is enabled on PowerPC
29544Linux systems using the ISA 3.0 instruction set, and disabled on other
29545systems.
29546
d77de738
ML
29547@opindex m32
29548@opindex m64
ddf6fe37
AA
29549@item -m32
29550@itemx -m64
d77de738
ML
29551Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29552targets (including GNU/Linux). The 32-bit environment sets int, long
29553and pointer to 32 bits and generates code that runs on any PowerPC
29554variant. The 64-bit environment sets int to 32 bits and long and
29555pointer to 64 bits, and generates code for PowerPC64, as for
29556@option{-mpowerpc64}.
29557
d77de738
ML
29558@opindex mfull-toc
29559@opindex mno-fp-in-toc
29560@opindex mno-sum-in-toc
29561@opindex mminimal-toc
ddf6fe37
AA
29562@item -mfull-toc
29563@itemx -mno-fp-in-toc
29564@itemx -mno-sum-in-toc
29565@itemx -mminimal-toc
d77de738
ML
29566Modify generation of the TOC (Table Of Contents), which is created for
29567every executable file. The @option{-mfull-toc} option is selected by
29568default. In that case, GCC allocates at least one TOC entry for
29569each unique non-automatic variable reference in your program. GCC
29570also places floating-point constants in the TOC@. However, only
2957116,384 entries are available in the TOC@.
29572
29573If you receive a linker error message that saying you have overflowed
29574the available TOC space, you can reduce the amount of TOC space used
29575with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
29576@option{-mno-fp-in-toc} prevents GCC from putting floating-point
29577constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
29578generate code to calculate the sum of an address and a constant at
29579run time instead of putting that sum into the TOC@. You may specify one
29580or both of these options. Each causes GCC to produce very slightly
29581slower and larger code at the expense of conserving TOC space.
29582
29583If you still run out of space in the TOC even when you specify both of
29584these options, specify @option{-mminimal-toc} instead. This option causes
29585GCC to make only one TOC entry for every file. When you specify this
29586option, GCC produces code that is slower and larger but which
29587uses extremely little TOC space. You may wish to use this option
29588only on files that contain less frequently-executed code.
29589
d77de738
ML
29590@opindex maix64
29591@opindex maix32
ddf6fe37
AA
29592@item -maix64
29593@itemx -maix32
d77de738
ML
29594Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
29595@code{long} type, and the infrastructure needed to support them.
29596Specifying @option{-maix64} implies @option{-mpowerpc64},
29597while @option{-maix32} disables the 64-bit ABI and
29598implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
29599
d77de738
ML
29600@opindex mxl-compat
29601@opindex mno-xl-compat
ddf6fe37
AA
29602@item -mxl-compat
29603@itemx -mno-xl-compat
d77de738
ML
29604Produce code that conforms more closely to IBM XL compiler semantics
29605when using AIX-compatible ABI@. Pass floating-point arguments to
29606prototyped functions beyond the register save area (RSA) on the stack
29607in addition to argument FPRs. Do not assume that most significant
29608double in 128-bit long double value is properly rounded when comparing
29609values and converting to double. Use XL symbol names for long double
29610support routines.
29611
29612The AIX calling convention was extended but not initially documented to
29613handle an obscure K&R C case of calling a function that takes the
29614address of its arguments with fewer arguments than declared. IBM XL
29615compilers access floating-point arguments that do not fit in the
29616RSA from the stack when a subroutine is compiled without
29617optimization. Because always storing floating-point arguments on the
29618stack is inefficient and rarely needed, this option is not enabled by
29619default and only is necessary when calling subroutines compiled by IBM
29620XL compilers without optimization.
29621
d77de738 29622@opindex mpe
ddf6fe37 29623@item -mpe
d77de738
ML
29624Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
29625application written to use message passing with special startup code to
29626enable the application to run. The system must have PE installed in the
29627standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
29628must be overridden with the @option{-specs=} option to specify the
29629appropriate directory location. The Parallel Environment does not
29630support threads, so the @option{-mpe} option and the @option{-pthread}
29631option are incompatible.
29632
d77de738
ML
29633@opindex malign-natural
29634@opindex malign-power
ddf6fe37
AA
29635@item -malign-natural
29636@itemx -malign-power
d77de738
ML
29637On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
29638@option{-malign-natural} overrides the ABI-defined alignment of larger
29639types, such as floating-point doubles, on their natural size-based boundary.
29640The option @option{-malign-power} instructs GCC to follow the ABI-specified
29641alignment rules. GCC defaults to the standard alignment defined in the ABI@.
29642
29643On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
29644is not supported.
29645
d77de738
ML
29646@opindex msoft-float
29647@opindex mhard-float
ddf6fe37
AA
29648@item -msoft-float
29649@itemx -mhard-float
d77de738
ML
29650Generate code that does not use (uses) the floating-point register set.
29651Software floating-point emulation is provided if you use the
29652@option{-msoft-float} option, and pass the option to GCC when linking.
29653
d77de738
ML
29654@opindex mmultiple
29655@opindex mno-multiple
ddf6fe37
AA
29656@item -mmultiple
29657@itemx -mno-multiple
d77de738
ML
29658Generate code that uses (does not use) the load multiple word
29659instructions and the store multiple word instructions. These
29660instructions are generated by default on POWER systems, and not
29661generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
29662PowerPC systems, since those instructions do not work when the
29663processor is in little-endian mode. The exceptions are PPC740 and
29664PPC750 which permit these instructions in little-endian mode.
29665
d77de738
ML
29666@opindex mupdate
29667@opindex mno-update
ddf6fe37
AA
29668@item -mupdate
29669@itemx -mno-update
d77de738
ML
29670Generate code that uses (does not use) the load or store instructions
29671that update the base register to the address of the calculated memory
29672location. These instructions are generated by default. If you use
29673@option{-mno-update}, there is a small window between the time that the
29674stack pointer is updated and the address of the previous frame is
29675stored, which means code that walks the stack frame across interrupts or
29676signals may get corrupted data.
29677
d77de738
ML
29678@opindex mavoid-indexed-addresses
29679@opindex mno-avoid-indexed-addresses
ddf6fe37
AA
29680@item -mavoid-indexed-addresses
29681@itemx -mno-avoid-indexed-addresses
d77de738
ML
29682Generate code that tries to avoid (not avoid) the use of indexed load
29683or store instructions. These instructions can incur a performance
29684penalty on Power6 processors in certain situations, such as when
29685stepping through large arrays that cross a 16M boundary. This option
29686is enabled by default when targeting Power6 and disabled otherwise.
29687
d77de738
ML
29688@opindex mfused-madd
29689@opindex mno-fused-madd
ddf6fe37
AA
29690@item -mfused-madd
29691@itemx -mno-fused-madd
d77de738
ML
29692Generate code that uses (does not use) the floating-point multiply and
29693accumulate instructions. These instructions are generated by default
29694if hardware floating point is used. The machine-dependent
29695@option{-mfused-madd} option is now mapped to the machine-independent
29696@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29697mapped to @option{-ffp-contract=off}.
29698
d77de738
ML
29699@opindex mmulhw
29700@opindex mno-mulhw
ddf6fe37
AA
29701@item -mmulhw
29702@itemx -mno-mulhw
d77de738
ML
29703Generate code that uses (does not use) the half-word multiply and
29704multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
29705These instructions are generated by default when targeting those
29706processors.
29707
d77de738
ML
29708@opindex mdlmzb
29709@opindex mno-dlmzb
ddf6fe37
AA
29710@item -mdlmzb
29711@itemx -mno-dlmzb
d77de738
ML
29712Generate code that uses (does not use) the string-search @samp{dlmzb}
29713instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
29714generated by default when targeting those processors.
29715
d77de738
ML
29716@opindex mno-bit-align
29717@opindex mbit-align
ddf6fe37
AA
29718@item -mno-bit-align
29719@itemx -mbit-align
d77de738
ML
29720On System V.4 and embedded PowerPC systems do not (do) force structures
29721and unions that contain bit-fields to be aligned to the base type of the
29722bit-field.
29723
29724For example, by default a structure containing nothing but 8
29725@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
29726boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
29727the structure is aligned to a 1-byte boundary and is 1 byte in
29728size.
29729
d77de738
ML
29730@opindex mno-strict-align
29731@opindex mstrict-align
ddf6fe37
AA
29732@item -mno-strict-align
29733@itemx -mstrict-align
d77de738
ML
29734On System V.4 and embedded PowerPC systems do not (do) assume that
29735unaligned memory references are handled by the system.
29736
d77de738
ML
29737@opindex mrelocatable
29738@opindex mno-relocatable
ddf6fe37
AA
29739@item -mrelocatable
29740@itemx -mno-relocatable
d77de738
ML
29741Generate code that allows (does not allow) a static executable to be
29742relocated to a different address at run time. A simple embedded
29743PowerPC system loader should relocate the entire contents of
29744@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
29745a table of 32-bit addresses generated by this option. For this to
29746work, all objects linked together must be compiled with
29747@option{-mrelocatable} or @option{-mrelocatable-lib}.
29748@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
29749
d77de738
ML
29750@opindex mrelocatable-lib
29751@opindex mno-relocatable-lib
ddf6fe37
AA
29752@item -mrelocatable-lib
29753@itemx -mno-relocatable-lib
d77de738
ML
29754Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
29755@code{.fixup} section to allow static executables to be relocated at
29756run time, but @option{-mrelocatable-lib} does not use the smaller stack
29757alignment of @option{-mrelocatable}. Objects compiled with
29758@option{-mrelocatable-lib} may be linked with objects compiled with
29759any combination of the @option{-mrelocatable} options.
29760
d77de738
ML
29761@opindex mno-toc
29762@opindex mtoc
ddf6fe37
AA
29763@item -mno-toc
29764@itemx -mtoc
d77de738
ML
29765On System V.4 and embedded PowerPC systems do not (do) assume that
29766register 2 contains a pointer to a global area pointing to the addresses
29767used in the program.
29768
d77de738
ML
29769@opindex mlittle
29770@opindex mlittle-endian
ddf6fe37
AA
29771@item -mlittle
29772@itemx -mlittle-endian
d77de738
ML
29773On System V.4 and embedded PowerPC systems compile code for the
29774processor in little-endian mode. The @option{-mlittle-endian} option is
29775the same as @option{-mlittle}.
29776
d77de738
ML
29777@opindex mbig
29778@opindex mbig-endian
ddf6fe37
AA
29779@item -mbig
29780@itemx -mbig-endian
d77de738
ML
29781On System V.4 and embedded PowerPC systems compile code for the
29782processor in big-endian mode. The @option{-mbig-endian} option is
29783the same as @option{-mbig}.
29784
d77de738 29785@opindex mdynamic-no-pic
ddf6fe37 29786@item -mdynamic-no-pic
d77de738
ML
29787On Darwin and Mac OS X systems, compile code so that it is not
29788relocatable, but that its external references are relocatable. The
29789resulting code is suitable for applications, but not shared
29790libraries.
29791
d77de738 29792@opindex msingle-pic-base
ddf6fe37 29793@item -msingle-pic-base
d77de738
ML
29794Treat the register used for PIC addressing as read-only, rather than
29795loading it in the prologue for each function. The runtime system is
29796responsible for initializing this register with an appropriate value
29797before execution begins.
29798
d77de738 29799@opindex mprioritize-restricted-insns
ddf6fe37 29800@item -mprioritize-restricted-insns=@var{priority}
d77de738
ML
29801This option controls the priority that is assigned to
29802dispatch-slot restricted instructions during the second scheduling
29803pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
29804or @samp{2} to assign no, highest, or second-highest (respectively)
29805priority to dispatch-slot restricted
29806instructions.
29807
d77de738 29808@opindex msched-costly-dep
ddf6fe37 29809@item -msched-costly-dep=@var{dependence_type}
d77de738
ML
29810This option controls which dependences are considered costly
29811by the target during instruction scheduling. The argument
29812@var{dependence_type} takes one of the following values:
29813
29814@table @asis
29815@item @samp{no}
29816No dependence is costly.
29817
29818@item @samp{all}
29819All dependences are costly.
29820
29821@item @samp{true_store_to_load}
29822A true dependence from store to load is costly.
29823
29824@item @samp{store_to_load}
29825Any dependence from store to load is costly.
29826
29827@item @var{number}
29828Any dependence for which the latency is greater than or equal to
29829@var{number} is costly.
29830@end table
29831
d77de738 29832@opindex minsert-sched-nops
ddf6fe37 29833@item -minsert-sched-nops=@var{scheme}
d77de738
ML
29834This option controls which NOP insertion scheme is used during
29835the second scheduling pass. The argument @var{scheme} takes one of the
29836following values:
29837
29838@table @asis
29839@item @samp{no}
29840Don't insert NOPs.
29841
29842@item @samp{pad}
29843Pad with NOPs any dispatch group that has vacant issue slots,
29844according to the scheduler's grouping.
29845
29846@item @samp{regroup_exact}
29847Insert NOPs to force costly dependent insns into
29848separate groups. Insert exactly as many NOPs as needed to force an insn
29849to a new group, according to the estimated processor grouping.
29850
29851@item @var{number}
29852Insert NOPs to force costly dependent insns into
29853separate groups. Insert @var{number} NOPs to force an insn to a new group.
29854@end table
29855
d77de738 29856@opindex mcall-sysv
ddf6fe37 29857@item -mcall-sysv
d77de738
ML
29858On System V.4 and embedded PowerPC systems compile code using calling
29859conventions that adhere to the March 1995 draft of the System V
29860Application Binary Interface, PowerPC processor supplement. This is the
29861default unless you configured GCC using @samp{powerpc-*-eabiaix}.
29862
d77de738
ML
29863@opindex mcall-sysv-eabi
29864@opindex mcall-eabi
ddf6fe37
AA
29865@item -mcall-sysv-eabi
29866@itemx -mcall-eabi
d77de738
ML
29867Specify both @option{-mcall-sysv} and @option{-meabi} options.
29868
d77de738 29869@opindex mcall-sysv-noeabi
ddf6fe37 29870@item -mcall-sysv-noeabi
d77de738
ML
29871Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
29872
d7971cf7 29873@opindex mcall-aixdesc
ddf6fe37 29874@item -mcall-aixdesc
d77de738
ML
29875On System V.4 and embedded PowerPC systems compile code for the AIX
29876operating system.
29877
d77de738 29878@opindex mcall-linux
ddf6fe37 29879@item -mcall-linux
d77de738
ML
29880On System V.4 and embedded PowerPC systems compile code for the
29881Linux-based GNU system.
29882
d77de738 29883@opindex mcall-freebsd
ddf6fe37 29884@item -mcall-freebsd
d77de738
ML
29885On System V.4 and embedded PowerPC systems compile code for the
29886FreeBSD operating system.
29887
d77de738 29888@opindex mcall-netbsd
ddf6fe37 29889@item -mcall-netbsd
d77de738
ML
29890On System V.4 and embedded PowerPC systems compile code for the
29891NetBSD operating system.
29892
d7971cf7 29893@opindex mcall-openbsd
ddf6fe37 29894@item -mcall-openbsd
d77de738
ML
29895On System V.4 and embedded PowerPC systems compile code for the
29896OpenBSD operating system.
29897
d77de738 29898@opindex mtraceback
ddf6fe37 29899@item -mtraceback=@var{traceback_type}
d77de738
ML
29900Select the type of traceback table. Valid values for @var{traceback_type}
29901are @samp{full}, @samp{part}, and @samp{no}.
29902
d77de738 29903@opindex maix-struct-return
ddf6fe37 29904@item -maix-struct-return
d77de738
ML
29905Return all structures in memory (as specified by the AIX ABI)@.
29906
d77de738 29907@opindex msvr4-struct-return
ddf6fe37 29908@item -msvr4-struct-return
d77de738
ML
29909Return structures smaller than 8 bytes in registers (as specified by the
29910SVR4 ABI)@.
29911
d77de738 29912@opindex mabi
ddf6fe37 29913@item -mabi=@var{abi-type}
d77de738
ML
29914Extend the current ABI with a particular extension, or remove such extension.
29915Valid values are: @samp{altivec}, @samp{no-altivec},
29916@samp{ibmlongdouble}, @samp{ieeelongdouble},
29917@samp{elfv1}, @samp{elfv2},
29918and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
29919
d77de738 29920@opindex mabi=ibmlongdouble
ddf6fe37 29921@item -mabi=ibmlongdouble
d77de738
ML
29922Change the current ABI to use IBM extended-precision long double.
29923This is not likely to work if your system defaults to using IEEE
29924extended-precision long double. If you change the long double type
29925from IEEE extended-precision, the compiler will issue a warning unless
29926you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29927to be enabled.
29928
d77de738 29929@opindex mabi=ieeelongdouble
ddf6fe37 29930@item -mabi=ieeelongdouble
d77de738
ML
29931Change the current ABI to use IEEE extended-precision long double.
29932This is not likely to work if your system defaults to using IBM
29933extended-precision long double. If you change the long double type
29934from IBM extended-precision, the compiler will issue a warning unless
29935you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29936to be enabled.
29937
d77de738 29938@opindex mabi=elfv1
ddf6fe37 29939@item -mabi=elfv1
d77de738
ML
29940Change the current ABI to use the ELFv1 ABI.
29941This is the default ABI for big-endian PowerPC 64-bit Linux.
29942Overriding the default ABI requires special system support and is
29943likely to fail in spectacular ways.
29944
d77de738 29945@opindex mabi=elfv2
ddf6fe37 29946@item -mabi=elfv2
d77de738
ML
29947Change the current ABI to use the ELFv2 ABI.
29948This is the default ABI for little-endian PowerPC 64-bit Linux.
29949Overriding the default ABI requires special system support and is
29950likely to fail in spectacular ways.
29951
d77de738
ML
29952@opindex mgnu-attribute
29953@opindex mno-gnu-attribute
ddf6fe37
AA
29954@item -mgnu-attribute
29955@itemx -mno-gnu-attribute
d77de738
ML
29956Emit .gnu_attribute assembly directives to set tag/value pairs in a
29957.gnu.attributes section that specify ABI variations in function
29958parameters or return values.
29959
d77de738
ML
29960@opindex mprototype
29961@opindex mno-prototype
ddf6fe37
AA
29962@item -mprototype
29963@itemx -mno-prototype
d77de738
ML
29964On System V.4 and embedded PowerPC systems assume that all calls to
29965variable argument functions are properly prototyped. Otherwise, the
29966compiler must insert an instruction before every non-prototyped call to
29967set or clear bit 6 of the condition code register (@code{CR}) to
29968indicate whether floating-point values are passed in the floating-point
29969registers in case the function takes variable arguments. With
29970@option{-mprototype}, only calls to prototyped variable argument functions
29971set or clear the bit.
29972
d77de738 29973@opindex msim
ddf6fe37 29974@item -msim
d77de738
ML
29975On embedded PowerPC systems, assume that the startup module is called
29976@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
29977@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
29978configurations.
29979
d77de738 29980@opindex mmvme
ddf6fe37 29981@item -mmvme
d77de738
ML
29982On embedded PowerPC systems, assume that the startup module is called
29983@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
29984@file{libc.a}.
29985
d77de738 29986@opindex mads
ddf6fe37 29987@item -mads
d77de738
ML
29988On embedded PowerPC systems, assume that the startup module is called
29989@file{crt0.o} and the standard C libraries are @file{libads.a} and
29990@file{libc.a}.
29991
d77de738 29992@opindex myellowknife
ddf6fe37 29993@item -myellowknife
d77de738
ML
29994On embedded PowerPC systems, assume that the startup module is called
29995@file{crt0.o} and the standard C libraries are @file{libyk.a} and
29996@file{libc.a}.
29997
d77de738 29998@opindex mvxworks
ddf6fe37 29999@item -mvxworks
d77de738
ML
30000On System V.4 and embedded PowerPC systems, specify that you are
30001compiling for a VxWorks system.
30002
d77de738 30003@opindex memb
ddf6fe37 30004@item -memb
d77de738
ML
30005On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
30006header to indicate that @samp{eabi} extended relocations are used.
30007
d77de738
ML
30008@opindex meabi
30009@opindex mno-eabi
ddf6fe37
AA
30010@item -meabi
30011@itemx -mno-eabi
d77de738
ML
30012On System V.4 and embedded PowerPC systems do (do not) adhere to the
30013Embedded Applications Binary Interface (EABI), which is a set of
30014modifications to the System V.4 specifications. Selecting @option{-meabi}
30015means that the stack is aligned to an 8-byte boundary, a function
30016@code{__eabi} is called from @code{main} to set up the EABI
30017environment, and the @option{-msdata} option can use both @code{r2} and
30018@code{r13} to point to two separate small data areas. Selecting
30019@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
30020no EABI initialization function is called from @code{main}, and the
30021@option{-msdata} option only uses @code{r13} to point to a single
30022small data area. The @option{-meabi} option is on by default if you
30023configured GCC using one of the @samp{powerpc*-*-eabi*} options.
30024
d77de738 30025@opindex msdata=eabi
ddf6fe37 30026@item -msdata=eabi
d77de738
ML
30027On System V.4 and embedded PowerPC systems, put small initialized
30028@code{const} global and static data in the @code{.sdata2} section, which
30029is pointed to by register @code{r2}. Put small initialized
30030non-@code{const} global and static data in the @code{.sdata} section,
30031which is pointed to by register @code{r13}. Put small uninitialized
30032global and static data in the @code{.sbss} section, which is adjacent to
30033the @code{.sdata} section. The @option{-msdata=eabi} option is
30034incompatible with the @option{-mrelocatable} option. The
30035@option{-msdata=eabi} option also sets the @option{-memb} option.
30036
d77de738 30037@opindex msdata=sysv
ddf6fe37 30038@item -msdata=sysv
d77de738
ML
30039On System V.4 and embedded PowerPC systems, put small global and static
30040data in the @code{.sdata} section, which is pointed to by register
30041@code{r13}. Put small uninitialized global and static data in the
30042@code{.sbss} section, which is adjacent to the @code{.sdata} section.
30043The @option{-msdata=sysv} option is incompatible with the
30044@option{-mrelocatable} option.
30045
d77de738
ML
30046@opindex msdata=default
30047@opindex msdata
ddf6fe37
AA
30048@item -msdata=default
30049@itemx -msdata
d77de738
ML
30050On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
30051compile code the same as @option{-msdata=eabi}, otherwise compile code the
30052same as @option{-msdata=sysv}.
30053
d77de738 30054@opindex msdata=data
ddf6fe37 30055@item -msdata=data
d77de738
ML
30056On System V.4 and embedded PowerPC systems, put small global
30057data in the @code{.sdata} section. Put small uninitialized global
30058data in the @code{.sbss} section. Do not use register @code{r13}
30059to address small data however. This is the default behavior unless
30060other @option{-msdata} options are used.
30061
d77de738
ML
30062@opindex msdata=none
30063@opindex mno-sdata
ddf6fe37
AA
30064@item -msdata=none
30065@itemx -mno-sdata
d77de738
ML
30066On embedded PowerPC systems, put all initialized global and static data
30067in the @code{.data} section, and all uninitialized data in the
30068@code{.bss} section.
30069
d77de738
ML
30070@opindex mreadonly-in-sdata
30071@opindex mno-readonly-in-sdata
ddf6fe37 30072@item -mreadonly-in-sdata
d77de738
ML
30073Put read-only objects in the @code{.sdata} section as well. This is the
30074default.
30075
d77de738 30076@opindex mblock-move-inline-limit
ddf6fe37 30077@item -mblock-move-inline-limit=@var{num}
d77de738
ML
30078Inline all block moves (such as calls to @code{memcpy} or structure
30079copies) less than or equal to @var{num} bytes. The minimum value for
30080@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
30081targets. The default value is target-specific.
30082
d77de738 30083@opindex mblock-compare-inline-limit
ddf6fe37 30084@item -mblock-compare-inline-limit=@var{num}
d77de738
ML
30085Generate non-looping inline code for all block compares (such as calls
30086to @code{memcmp} or structure compares) less than or equal to @var{num}
30087bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
30088block compare is disabled. The default value is target-specific.
30089
d77de738 30090@opindex mblock-compare-inline-loop-limit
ddf6fe37 30091@item -mblock-compare-inline-loop-limit=@var{num}
d77de738
ML
30092Generate an inline expansion using loop code for all block compares that
30093are less than or equal to @var{num} bytes, but greater than the limit
30094for non-loop inline block compare expansion. If the block length is not
30095constant, at most @var{num} bytes will be compared before @code{memcmp}
30096is called to compare the remainder of the block. The default value is
30097target-specific.
30098
d77de738 30099@opindex mstring-compare-inline-limit
ddf6fe37 30100@item -mstring-compare-inline-limit=@var{num}
d77de738
ML
30101Compare at most @var{num} string bytes with inline code.
30102If the difference or end of string is not found at the
30103end of the inline compare a call to @code{strcmp} or @code{strncmp} will
30104take care of the rest of the comparison. The default is 64 bytes.
30105
d77de738
ML
30106@opindex G
30107@cindex smaller data references (PowerPC)
30108@cindex .sdata/.sdata2 references (PowerPC)
f33d7a88 30109@item -G @var{num}
d77de738
ML
30110On embedded PowerPC systems, put global and static items less than or
30111equal to @var{num} bytes into the small data or BSS sections instead of
30112the normal data or BSS section. By default, @var{num} is 8. The
30113@option{-G @var{num}} switch is also passed to the linker.
30114All modules should be compiled with the same @option{-G @var{num}} value.
30115
d77de738
ML
30116@opindex mregnames
30117@opindex mno-regnames
ddf6fe37
AA
30118@item -mregnames
30119@itemx -mno-regnames
d77de738
ML
30120On System V.4 and embedded PowerPC systems do (do not) emit register
30121names in the assembly language output using symbolic forms.
30122
d77de738
ML
30123@opindex mlongcall
30124@opindex mno-longcall
ddf6fe37
AA
30125@item -mlongcall
30126@itemx -mno-longcall
d77de738
ML
30127By default assume that all calls are far away so that a longer and more
30128expensive calling sequence is required. This is required for calls
30129farther than 32 megabytes (33,554,432 bytes) from the current location.
30130A short call is generated if the compiler knows
30131the call cannot be that far away. This setting can be overridden by
30132the @code{shortcall} function attribute, or by @code{#pragma
30133longcall(0)}.
30134
30135Some linkers are capable of detecting out-of-range calls and generating
30136glue code on the fly. On these systems, long calls are unnecessary and
30137generate slower code. As of this writing, the AIX linker can do this,
30138as can the GNU linker for PowerPC/64. It is planned to add this feature
30139to the GNU linker for 32-bit PowerPC systems as well.
30140
30141On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
30142GCC can generate long calls using an inline PLT call sequence (see
30143@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
30144ELFv1 (big-endian) do not support inline PLT calls.
30145
30146On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
30147callee, L42}, plus a @dfn{branch island} (glue code). The two target
30148addresses represent the callee and the branch island. The
30149Darwin/PPC linker prefers the first address and generates a @code{bl
30150callee} if the PPC @code{bl} instruction reaches the callee directly;
30151otherwise, the linker generates @code{bl L42} to call the branch
30152island. The branch island is appended to the body of the
30153calling function; it computes the full 32-bit address of the callee
30154and jumps to it.
30155
30156On Mach-O (Darwin) systems, this option directs the compiler emit to
30157the glue for every direct call, and the Darwin linker decides whether
30158to use or discard it.
30159
30160In the future, GCC may ignore all longcall specifications
30161when the linker is known to generate glue.
30162
d77de738
ML
30163@opindex mpltseq
30164@opindex mno-pltseq
ddf6fe37
AA
30165@item -mpltseq
30166@itemx -mno-pltseq
d77de738
ML
30167Implement (do not implement) -fno-plt and long calls using an inline
30168PLT call sequence that supports lazy linking and long calls to
30169functions in dlopen'd shared libraries. Inline PLT calls are only
30170supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
30171linkers, and are enabled by default if the support is detected when
30172configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
30173configured with @option{--enable-secureplt}. @option{-mpltseq} code
30174and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
30175linked together.
30176
d77de738
ML
30177@opindex mtls-markers
30178@opindex mno-tls-markers
ddf6fe37
AA
30179@item -mtls-markers
30180@itemx -mno-tls-markers
d77de738
ML
30181Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
30182specifying the function argument. The relocation allows the linker to
30183reliably associate function call with argument setup instructions for
30184TLS optimization, which in turn allows GCC to better schedule the
30185sequence.
30186
ddf6fe37 30187@opindex mrecip
d77de738
ML
30188@item -mrecip
30189@itemx -mno-recip
d77de738
ML
30190This option enables use of the reciprocal estimate and
30191reciprocal square root estimate instructions with additional
30192Newton-Raphson steps to increase precision instead of doing a divide or
30193square root and divide for floating-point arguments. You should use
30194the @option{-ffast-math} option when using @option{-mrecip} (or at
30195least @option{-funsafe-math-optimizations},
30196@option{-ffinite-math-only}, @option{-freciprocal-math} and
30197@option{-fno-trapping-math}). Note that while the throughput of the
30198sequence is generally higher than the throughput of the non-reciprocal
30199instruction, the precision of the sequence can be decreased by up to 2
30200ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30201roots.
30202
d77de738 30203@opindex mrecip=opt
ddf6fe37 30204@item -mrecip=@var{opt}
d77de738
ML
30205This option controls which reciprocal estimate instructions
30206may be used. @var{opt} is a comma-separated list of options, which may
30207be preceded by a @code{!} to invert the option:
30208
30209@table @samp
30210
30211@item all
30212Enable all estimate instructions.
30213
30214@item default
30215Enable the default instructions, equivalent to @option{-mrecip}.
30216
30217@item none
30218Disable all estimate instructions, equivalent to @option{-mno-recip}.
30219
30220@item div
30221Enable the reciprocal approximation instructions for both
30222single and double precision.
30223
30224@item divf
30225Enable the single-precision reciprocal approximation instructions.
30226
30227@item divd
30228Enable the double-precision reciprocal approximation instructions.
30229
30230@item rsqrt
30231Enable the reciprocal square root approximation instructions for both
30232single and double precision.
30233
30234@item rsqrtf
30235Enable the single-precision reciprocal square root approximation instructions.
30236
30237@item rsqrtd
30238Enable the double-precision reciprocal square root approximation instructions.
30239
30240@end table
30241
30242So, for example, @option{-mrecip=all,!rsqrtd} enables
30243all of the reciprocal estimate instructions, except for the
30244@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30245which handle the double-precision reciprocal square root calculations.
30246
ddf6fe37 30247@opindex mrecip-precision
d77de738
ML
30248@item -mrecip-precision
30249@itemx -mno-recip-precision
d77de738
ML
30250Assume (do not assume) that the reciprocal estimate instructions
30251provide higher-precision estimates than is mandated by the PowerPC
30252ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30253@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30254The double-precision square root estimate instructions are not generated by
30255default on low-precision machines, since they do not provide an
30256estimate that converges after three steps.
30257
d77de738 30258@opindex mveclibabi
ddf6fe37 30259@item -mveclibabi=@var{type}
d77de738
ML
30260Specifies the ABI type to use for vectorizing intrinsics using an
30261external library. The only type supported at present is @samp{mass},
30262which specifies to use IBM's Mathematical Acceleration Subsystem
30263(MASS) libraries for vectorizing intrinsics using external libraries.
30264GCC currently emits calls to @code{acosd2}, @code{acosf4},
30265@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30266@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30267@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30268@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30269@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30270@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30271@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30272@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30273@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30274@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30275@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30276@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30277@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30278for power7. Both @option{-ftree-vectorize} and
30279@option{-funsafe-math-optimizations} must also be enabled. The MASS
30280libraries must be specified at link time.
30281
ddf6fe37 30282@opindex mfriz
d77de738
ML
30283@item -mfriz
30284@itemx -mno-friz
d77de738
ML
30285Generate (do not generate) the @code{friz} instruction when the
30286@option{-funsafe-math-optimizations} option is used to optimize
30287rounding of floating-point values to 64-bit integer and back to floating
30288point. The @code{friz} instruction does not return the same value if
30289the floating-point number is too large to fit in an integer.
30290
ddf6fe37 30291@opindex mpointers-to-nested-functions
d77de738
ML
30292@item -mpointers-to-nested-functions
30293@itemx -mno-pointers-to-nested-functions
d77de738
ML
30294Generate (do not generate) code to load up the static chain register
30295(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30296systems where a function pointer points to a 3-word descriptor giving
30297the function address, TOC value to be loaded in register @code{r2}, and
30298static chain value to be loaded in register @code{r11}. The
30299@option{-mpointers-to-nested-functions} is on by default. You cannot
30300call through pointers to nested functions or pointers
30301to functions compiled in other languages that use the static chain if
30302you use @option{-mno-pointers-to-nested-functions}.
30303
ddf6fe37 30304@opindex msave-toc-indirect
d77de738
ML
30305@item -msave-toc-indirect
30306@itemx -mno-save-toc-indirect
d77de738
ML
30307Generate (do not generate) code to save the TOC value in the reserved
30308stack location in the function prologue if the function calls through
30309a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30310saved in the prologue, it is saved just before the call through the
30311pointer. The @option{-mno-save-toc-indirect} option is the default.
30312
ddf6fe37 30313@opindex mcompat-align-parm
d77de738
ML
30314@item -mcompat-align-parm
30315@itemx -mno-compat-align-parm
d77de738
ML
30316Generate (do not generate) code to pass structure parameters with a
30317maximum alignment of 64 bits, for compatibility with older versions
30318of GCC.
30319
30320Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30321structure parameter on a 128-bit boundary when that structure contained
30322a member requiring 128-bit alignment. This is corrected in more
30323recent versions of GCC. This option may be used to generate code
30324that is compatible with functions compiled with older versions of
30325GCC.
30326
30327The @option{-mno-compat-align-parm} option is the default.
30328
d77de738
ML
30329@opindex mstack-protector-guard
30330@opindex mstack-protector-guard-reg
30331@opindex mstack-protector-guard-offset
30332@opindex mstack-protector-guard-symbol
ddf6fe37
AA
30333@item -mstack-protector-guard=@var{guard}
30334@itemx -mstack-protector-guard-reg=@var{reg}
30335@itemx -mstack-protector-guard-offset=@var{offset}
30336@itemx -mstack-protector-guard-symbol=@var{symbol}
d77de738
ML
30337Generate stack protection code using canary at @var{guard}. Supported
30338locations are @samp{global} for global canary or @samp{tls} for per-thread
30339canary in the TLS block (the default with GNU libc version 2.4 or later).
30340
30341With the latter choice the options
30342@option{-mstack-protector-guard-reg=@var{reg}} and
30343@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30344which register to use as base register for reading the canary, and from what
30345offset from that base register. The default for those is as specified in the
30346relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30347the offset with a symbol reference to a canary in the TLS block.
30348
d77de738
ML
30349@opindex mpcrel
30350@opindex mno-pcrel
ddf6fe37
AA
30351@item -mpcrel
30352@itemx -mno-pcrel
d77de738
ML
30353Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30354option requires that the medium code model (@option{-mcmodel=medium})
30355and prefixed addressing (@option{-mprefixed}) options are enabled.
30356
d77de738
ML
30357@opindex mprefixed
30358@opindex mno-prefixed
ddf6fe37
AA
30359@item -mprefixed
30360@itemx -mno-prefixed
d77de738
ML
30361Generate (do not generate) addressing modes using prefixed load and
30362store instructions. The @option{-mprefixed} option requires that
30363the option @option{-mcpu=power10} (or later) is enabled.
30364
d77de738
ML
30365@opindex mmma
30366@opindex mno-mma
ddf6fe37
AA
30367@item -mmma
30368@itemx -mno-mma
d77de738
ML
30369Generate (do not generate) the MMA instructions. The @option{-mma}
30370option requires that the option @option{-mcpu=power10} (or later)
30371is enabled.
30372
d77de738
ML
30373@opindex mrop-protect
30374@opindex mno-rop-protect
ddf6fe37
AA
30375@item -mrop-protect
30376@itemx -mno-rop-protect
d77de738
ML
30377Generate (do not generate) ROP protection instructions when the target
30378processor supports them. Currently this option disables the shrink-wrap
30379optimization (@option{-fshrink-wrap}).
30380
d77de738
ML
30381@opindex mprivileged
30382@opindex mno-privileged
ddf6fe37
AA
30383@item -mprivileged
30384@itemx -mno-privileged
d77de738
ML
30385Generate (do not generate) code that will run in privileged state.
30386
d77de738
ML
30387@opindex block-ops-unaligned-vsx
30388@opindex no-block-ops-unaligned-vsx
ddf6fe37
AA
30389@item -mblock-ops-unaligned-vsx
30390@itemx -mno-block-ops-unaligned-vsx
d77de738
ML
30391Generate (do not generate) unaligned vsx loads and stores for
30392inline expansion of @code{memcpy} and @code{memmove}.
30393
30394@item --param rs6000-vect-unroll-limit=
30395The vectorizer will check with target information to determine whether it
30396would be beneficial to unroll the main vectorized loop and by how much. This
30397parameter sets the upper bound of how much the vectorizer will unroll the main
30398loop. The default value is four.
30399
30400@end table
30401
30402@node RX Options
30403@subsection RX Options
30404@cindex RX Options
30405
30406These command-line options are defined for RX targets:
30407
30408@table @gcctabopt
d77de738
ML
30409@opindex m64bit-doubles
30410@opindex m32bit-doubles
ddf6fe37
AA
30411@item -m64bit-doubles
30412@itemx -m32bit-doubles
d77de738
ML
30413Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30414or 32 bits (@option{-m32bit-doubles}) in size. The default is
30415@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30416works on 32-bit values, which is why the default is
30417@option{-m32bit-doubles}.
30418
d77de738
ML
30419@opindex fpu
30420@opindex nofpu
ddf6fe37
AA
30421@item -fpu
30422@itemx -nofpu
d77de738
ML
30423Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30424floating-point hardware. The default is enabled for the RX600
30425series and disabled for the RX200 series.
30426
30427Floating-point instructions are only generated for 32-bit floating-point
30428values, however, so the FPU hardware is not used for doubles if the
30429@option{-m64bit-doubles} option is used.
30430
30431@emph{Note} If the @option{-fpu} option is enabled then
30432@option{-funsafe-math-optimizations} is also enabled automatically.
30433This is because the RX FPU instructions are themselves unsafe.
30434
d77de738 30435@opindex mcpu
ddf6fe37 30436@item -mcpu=@var{name}
d77de738
ML
30437Selects the type of RX CPU to be targeted. Currently three types are
30438supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30439the specific @samp{RX610} CPU. The default is @samp{RX600}.
30440
30441The only difference between @samp{RX600} and @samp{RX610} is that the
30442@samp{RX610} does not support the @code{MVTIPL} instruction.
30443
30444The @samp{RX200} series does not have a hardware floating-point unit
30445and so @option{-nofpu} is enabled by default when this type is
30446selected.
30447
d77de738
ML
30448@opindex mbig-endian-data
30449@opindex mlittle-endian-data
ddf6fe37
AA
30450@item -mbig-endian-data
30451@itemx -mlittle-endian-data
d77de738
ML
30452Store data (but not code) in the big-endian format. The default is
30453@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30454format.
30455
d77de738 30456@opindex msmall-data-limit
ddf6fe37 30457@item -msmall-data-limit=@var{N}
d77de738
ML
30458Specifies the maximum size in bytes of global and static variables
30459which can be placed into the small data area. Using the small data
30460area can lead to smaller and faster code, but the size of area is
30461limited and it is up to the programmer to ensure that the area does
30462not overflow. Also when the small data area is used one of the RX's
30463registers (usually @code{r13}) is reserved for use pointing to this
30464area, so it is no longer available for use by the compiler. This
30465could result in slower and/or larger code if variables are pushed onto
30466the stack instead of being held in this register.
30467
30468Note, common variables (variables that have not been initialized) and
30469constants are not placed into the small data area as they are assigned
30470to other sections in the output executable.
30471
30472The default value is zero, which disables this feature. Note, this
30473feature is not enabled by default with higher optimization levels
30474(@option{-O2} etc) because of the potentially detrimental effects of
30475reserving a register. It is up to the programmer to experiment and
30476discover whether this feature is of benefit to their program. See the
30477description of the @option{-mpid} option for a description of how the
30478actual register to hold the small data area pointer is chosen.
30479
d77de738
ML
30480@opindex msim
30481@opindex mno-sim
ddf6fe37
AA
30482@item -msim
30483@itemx -mno-sim
d77de738
ML
30484Use the simulator runtime. The default is to use the libgloss
30485board-specific runtime.
30486
d77de738
ML
30487@opindex mas100-syntax
30488@opindex mno-as100-syntax
ddf6fe37
AA
30489@item -mas100-syntax
30490@itemx -mno-as100-syntax
d77de738
ML
30491When generating assembler output use a syntax that is compatible with
30492Renesas's AS100 assembler. This syntax can also be handled by the GAS
30493assembler, but it has some restrictions so it is not generated by default.
30494
d77de738 30495@opindex mmax-constant-size
ddf6fe37 30496@item -mmax-constant-size=@var{N}
d77de738
ML
30497Specifies the maximum size, in bytes, of a constant that can be used as
30498an operand in a RX instruction. Although the RX instruction set does
30499allow constants of up to 4 bytes in length to be used in instructions,
30500a longer value equates to a longer instruction. Thus in some
30501circumstances it can be beneficial to restrict the size of constants
30502that are used in instructions. Constants that are too big are instead
30503placed into a constant pool and referenced via register indirection.
30504
30505The value @var{N} can be between 0 and 4. A value of 0 (the default)
30506or 4 means that constants of any size are allowed.
30507
d77de738 30508@opindex mrelax
ddf6fe37 30509@item -mrelax
d77de738
ML
30510Enable linker relaxation. Linker relaxation is a process whereby the
30511linker attempts to reduce the size of a program by finding shorter
30512versions of various instructions. Disabled by default.
30513
d77de738 30514@opindex mint-register
ddf6fe37 30515@item -mint-register=@var{N}
d77de738
ML
30516Specify the number of registers to reserve for fast interrupt handler
30517functions. The value @var{N} can be between 0 and 4. A value of 1
30518means that register @code{r13} is reserved for the exclusive use
30519of fast interrupt handlers. A value of 2 reserves @code{r13} and
30520@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30521@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30522A value of 0, the default, does not reserve any registers.
30523
d77de738 30524@opindex msave-acc-in-interrupts
ddf6fe37 30525@item -msave-acc-in-interrupts
d77de738
ML
30526Specifies that interrupt handler functions should preserve the
30527accumulator register. This is only necessary if normal code might use
30528the accumulator register, for example because it performs 64-bit
30529multiplications. The default is to ignore the accumulator as this
30530makes the interrupt handlers faster.
30531
d77de738
ML
30532@opindex mpid
30533@opindex mno-pid
ddf6fe37
AA
30534@item -mpid
30535@itemx -mno-pid
d77de738
ML
30536Enables the generation of position independent data. When enabled any
30537access to constant data is done via an offset from a base address
30538held in a register. This allows the location of constant data to be
30539determined at run time without requiring the executable to be
30540relocated, which is a benefit to embedded applications with tight
30541memory constraints. Data that can be modified is not affected by this
30542option.
30543
30544Note, using this feature reserves a register, usually @code{r13}, for
30545the constant data base address. This can result in slower and/or
30546larger code, especially in complicated functions.
30547
30548The actual register chosen to hold the constant data base address
30549depends upon whether the @option{-msmall-data-limit} and/or the
30550@option{-mint-register} command-line options are enabled. Starting
30551with register @code{r13} and proceeding downwards, registers are
30552allocated first to satisfy the requirements of @option{-mint-register},
30553then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30554is possible for the small data area register to be @code{r8} if both
30555@option{-mint-register=4} and @option{-mpid} are specified on the
30556command line.
30557
30558By default this feature is not enabled. The default can be restored
30559via the @option{-mno-pid} command-line option.
30560
d77de738
ML
30561@opindex mno-warn-multiple-fast-interrupts
30562@opindex mwarn-multiple-fast-interrupts
ddf6fe37
AA
30563@item -mno-warn-multiple-fast-interrupts
30564@itemx -mwarn-multiple-fast-interrupts
d77de738
ML
30565Prevents GCC from issuing a warning message if it finds more than one
30566fast interrupt handler when it is compiling a file. The default is to
30567issue a warning for each extra fast interrupt handler found, as the RX
30568only supports one such interrupt.
30569
d77de738
ML
30570@opindex mallow-string-insns
30571@opindex mno-allow-string-insns
ddf6fe37
AA
30572@item -mallow-string-insns
30573@itemx -mno-allow-string-insns
d77de738
ML
30574Enables or disables the use of the string manipulation instructions
30575@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
30576@code{SWHILE} and also the @code{RMPA} instruction. These
30577instructions may prefetch data, which is not safe to do if accessing
30578an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
30579for more information).
30580
30581The default is to allow these instructions, but it is not possible for
30582GCC to reliably detect all circumstances where a string instruction
30583might be used to access an I/O register, so their use cannot be
30584disabled automatically. Instead it is reliant upon the programmer to
30585use the @option{-mno-allow-string-insns} option if their program
30586accesses I/O space.
30587
30588When the instructions are enabled GCC defines the C preprocessor
30589symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
30590symbol @code{__RX_DISALLOW_STRING_INSNS__}.
30591
d77de738
ML
30592@opindex mjsr
30593@opindex mno-jsr
ddf6fe37
AA
30594@item -mjsr
30595@itemx -mno-jsr
d77de738
ML
30596Use only (or not only) @code{JSR} instructions to access functions.
30597This option can be used when code size exceeds the range of @code{BSR}
30598instructions. Note that @option{-mno-jsr} does not mean to not use
30599@code{JSR} but instead means that any type of branch may be used.
30600@end table
30601
30602@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
30603has special significance to the RX port when used with the
30604@code{interrupt} function attribute. This attribute indicates a
30605function intended to process fast interrupts. GCC ensures
30606that it only uses the registers @code{r10}, @code{r11}, @code{r12}
30607and/or @code{r13} and only provided that the normal use of the
30608corresponding registers have been restricted via the
30609@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
30610options.
30611
30612@node S/390 and zSeries Options
30613@subsection S/390 and zSeries Options
30614@cindex S/390 and zSeries Options
30615
30616These are the @samp{-m} options defined for the S/390 and zSeries architecture.
30617
30618@table @gcctabopt
d77de738
ML
30619@opindex mhard-float
30620@opindex msoft-float
ddf6fe37
AA
30621@item -mhard-float
30622@itemx -msoft-float
d77de738
ML
30623Use (do not use) the hardware floating-point instructions and registers
30624for floating-point operations. When @option{-msoft-float} is specified,
30625functions in @file{libgcc.a} are used to perform floating-point
30626operations. When @option{-mhard-float} is specified, the compiler
30627generates IEEE floating-point instructions. This is the default.
30628
d77de738
ML
30629@opindex mhard-dfp
30630@opindex mno-hard-dfp
ddf6fe37
AA
30631@item -mhard-dfp
30632@itemx -mno-hard-dfp
d77de738
ML
30633Use (do not use) the hardware decimal-floating-point instructions for
30634decimal-floating-point operations. When @option{-mno-hard-dfp} is
30635specified, functions in @file{libgcc.a} are used to perform
30636decimal-floating-point operations. When @option{-mhard-dfp} is
30637specified, the compiler generates decimal-floating-point hardware
30638instructions. This is the default for @option{-march=z9-ec} or higher.
30639
d77de738
ML
30640@opindex mlong-double-64
30641@opindex mlong-double-128
ddf6fe37
AA
30642@item -mlong-double-64
30643@itemx -mlong-double-128
d77de738
ML
30644These switches control the size of @code{long double} type. A size
30645of 64 bits makes the @code{long double} type equivalent to the @code{double}
30646type. This is the default.
30647
d77de738
ML
30648@opindex mbackchain
30649@opindex mno-backchain
ddf6fe37
AA
30650@item -mbackchain
30651@itemx -mno-backchain
d77de738
ML
30652Store (do not store) the address of the caller's frame as backchain pointer
30653into the callee's stack frame.
30654A backchain may be needed to allow debugging using tools that do not understand
30655DWARF call frame information.
30656When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
30657at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
30658the backchain is placed into the topmost word of the 96/160 byte register
30659save area.
30660
30661In general, code compiled with @option{-mbackchain} is call-compatible with
30662code compiled with @option{-mno-backchain}; however, use of the backchain
30663for debugging purposes usually requires that the whole binary is built with
30664@option{-mbackchain}. Note that the combination of @option{-mbackchain},
30665@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30666to build a linux kernel use @option{-msoft-float}.
30667
30668The default is to not maintain the backchain.
30669
d77de738
ML
30670@opindex mpacked-stack
30671@opindex mno-packed-stack
ddf6fe37
AA
30672@item -mpacked-stack
30673@itemx -mno-packed-stack
d77de738
ML
30674Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
30675specified, the compiler uses the all fields of the 96/160 byte register save
30676area only for their default purpose; unused fields still take up stack space.
30677When @option{-mpacked-stack} is specified, register save slots are densely
30678packed at the top of the register save area; unused space is reused for other
30679purposes, allowing for more efficient use of the available stack space.
30680However, when @option{-mbackchain} is also in effect, the topmost word of
30681the save area is always used to store the backchain, and the return address
30682register is always saved two words below the backchain.
30683
30684As long as the stack frame backchain is not used, code generated with
30685@option{-mpacked-stack} is call-compatible with code generated with
30686@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
30687S/390 or zSeries generated code that uses the stack frame backchain at run
30688time, not just for debugging purposes. Such code is not call-compatible
30689with code compiled with @option{-mpacked-stack}. Also, note that the
30690combination of @option{-mbackchain},
30691@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30692to build a linux kernel use @option{-msoft-float}.
30693
30694The default is to not use the packed stack layout.
30695
d77de738
ML
30696@opindex msmall-exec
30697@opindex mno-small-exec
ddf6fe37
AA
30698@item -msmall-exec
30699@itemx -mno-small-exec
d77de738
ML
30700Generate (or do not generate) code using the @code{bras} instruction
30701to do subroutine calls.
30702This only works reliably if the total executable size does not
30703exceed 64k. The default is to use the @code{basr} instruction instead,
30704which does not have this limitation.
30705
d77de738
ML
30706@opindex m64
30707@opindex m31
ddf6fe37
AA
30708@item -m64
30709@itemx -m31
d77de738
ML
30710When @option{-m31} is specified, generate code compliant to the
30711GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
30712code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
30713particular to generate 64-bit instructions. For the @samp{s390}
30714targets, the default is @option{-m31}, while the @samp{s390x}
30715targets default to @option{-m64}.
30716
d77de738
ML
30717@opindex mzarch
30718@opindex mesa
ddf6fe37
AA
30719@item -mzarch
30720@itemx -mesa
d77de738
ML
30721When @option{-mzarch} is specified, generate code using the
30722instructions available on z/Architecture.
30723When @option{-mesa} is specified, generate code using the
30724instructions available on ESA/390. Note that @option{-mesa} is
30725not possible with @option{-m64}.
30726When generating code compliant to the GNU/Linux for S/390 ABI,
30727the default is @option{-mesa}. When generating code compliant
30728to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
30729
d77de738
ML
30730@opindex mhtm
30731@opindex mno-htm
ddf6fe37
AA
30732@item -mhtm
30733@itemx -mno-htm
d77de738
ML
30734The @option{-mhtm} option enables a set of builtins making use of
30735instructions available with the transactional execution facility
30736introduced with the IBM zEnterprise EC12 machine generation
30737@ref{S/390 System z Built-in Functions}.
30738@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
30739
d77de738
ML
30740@opindex mvx
30741@opindex mno-vx
ddf6fe37
AA
30742@item -mvx
30743@itemx -mno-vx
d77de738
ML
30744When @option{-mvx} is specified, generate code using the instructions
30745available with the vector extension facility introduced with the IBM
30746z13 machine generation.
30747This option changes the ABI for some vector type values with regard to
30748alignment and calling conventions. In case vector type values are
30749being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
30750command will be added to mark the resulting binary with the ABI used.
30751@option{-mvx} is enabled by default when using @option{-march=z13}.
30752
d77de738
ML
30753@opindex mzvector
30754@opindex mno-zvector
ddf6fe37
AA
30755@item -mzvector
30756@itemx -mno-zvector
d77de738
ML
30757The @option{-mzvector} option enables vector language extensions and
30758builtins using instructions available with the vector extension
30759facility introduced with the IBM z13 machine generation.
30760This option adds support for @samp{vector} to be used as a keyword to
30761define vector type variables and arguments. @samp{vector} is only
30762available when GNU extensions are enabled. It will not be expanded
30763when requesting strict standard compliance e.g.@: with @option{-std=c99}.
30764In addition to the GCC low-level builtins @option{-mzvector} enables
30765a set of builtins added for compatibility with AltiVec-style
30766implementations like Power and Cell. In order to make use of these
30767builtins the header file @file{vecintrin.h} needs to be included.
30768@option{-mzvector} is disabled by default.
30769
d77de738
ML
30770@opindex mmvcle
30771@opindex mno-mvcle
ddf6fe37
AA
30772@item -mmvcle
30773@itemx -mno-mvcle
d77de738
ML
30774Generate (or do not generate) code using the @code{mvcle} instruction
30775to perform block moves. When @option{-mno-mvcle} is specified,
30776use a @code{mvc} loop instead. This is the default unless optimizing for
30777size.
30778
d77de738
ML
30779@opindex mdebug
30780@opindex mno-debug
ddf6fe37
AA
30781@item -mdebug
30782@itemx -mno-debug
d77de738
ML
30783Print (or do not print) additional debug information when compiling.
30784The default is to not print debug information.
30785
d77de738 30786@opindex march
ddf6fe37 30787@item -march=@var{cpu-type}
d77de738
ML
30788Generate code that runs on @var{cpu-type}, which is the name of a
30789system representing a certain processor type. Possible values for
30790@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
30791@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
30792@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
30793@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
30794@samp{z16}/@samp{arch14}, and @samp{native}.
30795
30796The default is @option{-march=z900}.
30797
30798Specifying @samp{native} as cpu type can be used to select the best
30799architecture option for the host processor.
30800@option{-march=native} has no effect if GCC does not recognize the
30801processor.
30802
d77de738 30803@opindex mtune
ddf6fe37 30804@item -mtune=@var{cpu-type}
d77de738
ML
30805Tune to @var{cpu-type} everything applicable about the generated code,
30806except for the ABI and the set of available instructions.
30807The list of @var{cpu-type} values is the same as for @option{-march}.
30808The default is the value used for @option{-march}.
30809
d77de738
ML
30810@opindex mtpf-trace
30811@opindex mno-tpf-trace
ddf6fe37
AA
30812@item -mtpf-trace
30813@itemx -mno-tpf-trace
d77de738
ML
30814Generate code that adds (does not add) in TPF OS specific branches to trace
30815routines in the operating system. This option is off by default, even
30816when compiling for the TPF OS@.
30817
d77de738
ML
30818@opindex mtpf-trace-skip
30819@opindex mno-tpf-trace-skip
ddf6fe37
AA
30820@item -mtpf-trace-skip
30821@itemx -mno-tpf-trace-skip
d77de738
ML
30822Generate code that changes (does not change) the default branch
30823targets enabled by @option{-mtpf-trace} to point to specialized trace
30824routines providing the ability of selectively skipping function trace
30825entries for the TPF OS. This option is off by default, even when
30826compiling for the TPF OS and specifying @option{-mtpf-trace}.
30827
d77de738
ML
30828@opindex mfused-madd
30829@opindex mno-fused-madd
ddf6fe37
AA
30830@item -mfused-madd
30831@itemx -mno-fused-madd
d77de738
ML
30832Generate code that uses (does not use) the floating-point multiply and
30833accumulate instructions. These instructions are generated by default if
30834hardware floating point is used.
30835
d77de738 30836@opindex mwarn-framesize
ddf6fe37 30837@item -mwarn-framesize=@var{framesize}
d77de738
ML
30838Emit a warning if the current function exceeds the given frame size. Because
30839this is a compile-time check it doesn't need to be a real problem when the program
30840runs. It is intended to identify functions that most probably cause
30841a stack overflow. It is useful to be used in an environment with limited stack
30842size e.g.@: the linux kernel.
30843
d77de738 30844@opindex mwarn-dynamicstack
ddf6fe37 30845@item -mwarn-dynamicstack
d77de738
ML
30846Emit a warning if the function calls @code{alloca} or uses dynamically-sized
30847arrays. This is generally a bad idea with a limited stack size.
30848
d77de738
ML
30849@opindex mstack-guard
30850@opindex mstack-size
ddf6fe37
AA
30851@item -mstack-guard=@var{stack-guard}
30852@itemx -mstack-size=@var{stack-size}
d77de738
ML
30853If these options are provided the S/390 back end emits additional instructions in
30854the function prologue that trigger a trap if the stack size is @var{stack-guard}
30855bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
30856If the @var{stack-guard} option is omitted the smallest power of 2 larger than
30857the frame size of the compiled function is chosen.
30858These options are intended to be used to help debugging stack overflow problems.
30859The additionally emitted code causes only little overhead and hence can also be
30860used in production-like systems without greater performance degradation. The given
30861values have to be exact powers of 2 and @var{stack-size} has to be greater than
30862@var{stack-guard} without exceeding 64k.
30863In order to be efficient the extra code makes the assumption that the stack starts
30864at an address aligned to the value given by @var{stack-size}.
30865The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
30866
d77de738 30867@opindex mhotpatch
ddf6fe37 30868@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
d77de738
ML
30869If the hotpatch option is enabled, a ``hot-patching'' function
30870prologue is generated for all functions in the compilation unit.
30871The funtion label is prepended with the given number of two-byte
30872NOP instructions (@var{pre-halfwords}, maximum 1000000). After
30873the label, 2 * @var{post-halfwords} bytes are appended, using the
30874largest NOP like instructions the architecture allows (maximum
308751000000).
30876
30877If both arguments are zero, hotpatching is disabled.
30878
30879This option can be overridden for individual functions with the
30880@code{hotpatch} attribute.
30881@end table
30882
d77de738
ML
30883@node SH Options
30884@subsection SH Options
30885
30886These @samp{-m} options are defined for the SH implementations:
30887
30888@table @gcctabopt
d77de738 30889@opindex m1
ddf6fe37 30890@item -m1
d77de738
ML
30891Generate code for the SH1.
30892
d77de738 30893@opindex m2
ddf6fe37 30894@item -m2
d77de738
ML
30895Generate code for the SH2.
30896
30897@item -m2e
30898Generate code for the SH2e.
30899
d77de738 30900@opindex m2a-nofpu
ddf6fe37 30901@item -m2a-nofpu
d77de738
ML
30902Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
30903that the floating-point unit is not used.
30904
d77de738 30905@opindex m2a-single-only
ddf6fe37 30906@item -m2a-single-only
d77de738
ML
30907Generate code for the SH2a-FPU, in such a way that no double-precision
30908floating-point operations are used.
30909
d77de738 30910@opindex m2a-single
ddf6fe37 30911@item -m2a-single
d77de738
ML
30912Generate code for the SH2a-FPU assuming the floating-point unit is in
30913single-precision mode by default.
30914
d77de738 30915@opindex m2a
ddf6fe37 30916@item -m2a
d77de738
ML
30917Generate code for the SH2a-FPU assuming the floating-point unit is in
30918double-precision mode by default.
30919
d77de738 30920@opindex m3
ddf6fe37 30921@item -m3
d77de738
ML
30922Generate code for the SH3.
30923
d77de738 30924@opindex m3e
ddf6fe37 30925@item -m3e
d77de738
ML
30926Generate code for the SH3e.
30927
d77de738 30928@opindex m4-nofpu
ddf6fe37 30929@item -m4-nofpu
d77de738
ML
30930Generate code for the SH4 without a floating-point unit.
30931
d77de738 30932@opindex m4-single-only
ddf6fe37 30933@item -m4-single-only
d77de738
ML
30934Generate code for the SH4 with a floating-point unit that only
30935supports single-precision arithmetic.
30936
d77de738 30937@opindex m4-single
ddf6fe37 30938@item -m4-single
d77de738
ML
30939Generate code for the SH4 assuming the floating-point unit is in
30940single-precision mode by default.
30941
d77de738 30942@opindex m4
ddf6fe37 30943@item -m4
d77de738
ML
30944Generate code for the SH4.
30945
d77de738 30946@opindex m4-100
ddf6fe37 30947@item -m4-100
d77de738
ML
30948Generate code for SH4-100.
30949
d77de738 30950@opindex m4-100-nofpu
ddf6fe37 30951@item -m4-100-nofpu
d77de738
ML
30952Generate code for SH4-100 in such a way that the
30953floating-point unit is not used.
30954
d77de738 30955@opindex m4-100-single
ddf6fe37 30956@item -m4-100-single
d77de738
ML
30957Generate code for SH4-100 assuming the floating-point unit is in
30958single-precision mode by default.
30959
d77de738 30960@opindex m4-100-single-only
ddf6fe37 30961@item -m4-100-single-only
d77de738
ML
30962Generate code for SH4-100 in such a way that no double-precision
30963floating-point operations are used.
30964
d77de738 30965@opindex m4-200
ddf6fe37 30966@item -m4-200
d77de738
ML
30967Generate code for SH4-200.
30968
d77de738 30969@opindex m4-200-nofpu
ddf6fe37 30970@item -m4-200-nofpu
d77de738
ML
30971Generate code for SH4-200 without in such a way that the
30972floating-point unit is not used.
30973
d77de738 30974@opindex m4-200-single
ddf6fe37 30975@item -m4-200-single
d77de738
ML
30976Generate code for SH4-200 assuming the floating-point unit is in
30977single-precision mode by default.
30978
d77de738 30979@opindex m4-200-single-only
ddf6fe37 30980@item -m4-200-single-only
d77de738
ML
30981Generate code for SH4-200 in such a way that no double-precision
30982floating-point operations are used.
30983
d77de738 30984@opindex m4-300
ddf6fe37 30985@item -m4-300
d77de738
ML
30986Generate code for SH4-300.
30987
d77de738 30988@opindex m4-300-nofpu
ddf6fe37 30989@item -m4-300-nofpu
d77de738
ML
30990Generate code for SH4-300 without in such a way that the
30991floating-point unit is not used.
30992
d77de738 30993@opindex m4-300-single
ddf6fe37 30994@item -m4-300-single
d77de738
ML
30995Generate code for SH4-300 in such a way that no double-precision
30996floating-point operations are used.
30997
d77de738 30998@opindex m4-300-single-only
ddf6fe37 30999@item -m4-300-single-only
d77de738
ML
31000Generate code for SH4-300 in such a way that no double-precision
31001floating-point operations are used.
31002
d77de738 31003@opindex m4-340
ddf6fe37 31004@item -m4-340
d77de738
ML
31005Generate code for SH4-340 (no MMU, no FPU).
31006
d77de738 31007@opindex m4-500
ddf6fe37 31008@item -m4-500
d77de738
ML
31009Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
31010assembler.
31011
d77de738 31012@opindex m4a-nofpu
ddf6fe37 31013@item -m4a-nofpu
d77de738
ML
31014Generate code for the SH4al-dsp, or for a SH4a in such a way that the
31015floating-point unit is not used.
31016
d77de738 31017@opindex m4a-single-only
ddf6fe37 31018@item -m4a-single-only
d77de738
ML
31019Generate code for the SH4a, in such a way that no double-precision
31020floating-point operations are used.
31021
d77de738 31022@opindex m4a-single
ddf6fe37 31023@item -m4a-single
d77de738
ML
31024Generate code for the SH4a assuming the floating-point unit is in
31025single-precision mode by default.
31026
d77de738 31027@opindex m4a
ddf6fe37 31028@item -m4a
d77de738
ML
31029Generate code for the SH4a.
31030
d77de738 31031@opindex m4al
ddf6fe37 31032@item -m4al
d77de738
ML
31033Same as @option{-m4a-nofpu}, except that it implicitly passes
31034@option{-dsp} to the assembler. GCC doesn't generate any DSP
31035instructions at the moment.
31036
d77de738 31037@opindex mb
ddf6fe37 31038@item -mb
d77de738
ML
31039Compile code for the processor in big-endian mode.
31040
d77de738 31041@opindex ml
ddf6fe37 31042@item -ml
d77de738
ML
31043Compile code for the processor in little-endian mode.
31044
d77de738 31045@opindex mdalign
ddf6fe37 31046@item -mdalign
d77de738
ML
31047Align doubles at 64-bit boundaries. Note that this changes the calling
31048conventions, and thus some functions from the standard C library do
31049not work unless you recompile it first with @option{-mdalign}.
31050
d77de738 31051@opindex mrelax
ddf6fe37 31052@item -mrelax
d77de738
ML
31053Shorten some address references at link time, when possible; uses the
31054linker option @option{-relax}.
31055
d77de738 31056@opindex mbigtable
ddf6fe37 31057@item -mbigtable
d77de738
ML
31058Use 32-bit offsets in @code{switch} tables. The default is to use
3105916-bit offsets.
31060
d77de738 31061@opindex mbitops
ddf6fe37 31062@item -mbitops
d77de738
ML
31063Enable the use of bit manipulation instructions on SH2A.
31064
d77de738 31065@opindex mfmovd
ddf6fe37 31066@item -mfmovd
d77de738
ML
31067Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
31068alignment constraints.
31069
d77de738 31070@opindex mrenesas
ddf6fe37 31071@item -mrenesas
d77de738
ML
31072Comply with the calling conventions defined by Renesas.
31073
d77de738 31074@opindex mno-renesas
ddf6fe37 31075@item -mno-renesas
d77de738
ML
31076Comply with the calling conventions defined for GCC before the Renesas
31077conventions were available. This option is the default for all
31078targets of the SH toolchain.
31079
d77de738 31080@opindex mnomacsave
ddf6fe37 31081@item -mnomacsave
d77de738
ML
31082Mark the @code{MAC} register as call-clobbered, even if
31083@option{-mrenesas} is given.
31084
d77de738
ML
31085@opindex mieee
31086@opindex mno-ieee
ddf6fe37
AA
31087@item -mieee
31088@itemx -mno-ieee
d77de738
ML
31089Control the IEEE compliance of floating-point comparisons, which affects the
31090handling of cases where the result of a comparison is unordered. By default
31091@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
31092enabled @option{-mno-ieee} is implicitly set, which results in faster
31093floating-point greater-equal and less-equal comparisons. The implicit settings
31094can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
31095
d77de738 31096@opindex minline-ic_invalidate
ddf6fe37 31097@item -minline-ic_invalidate
d77de738
ML
31098Inline code to invalidate instruction cache entries after setting up
31099nested function trampolines.
31100This option has no effect if @option{-musermode} is in effect and the selected
31101code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
31102instruction.
31103If the selected code generation option does not allow the use of the @code{icbi}
31104instruction, and @option{-musermode} is not in effect, the inlined code
31105manipulates the instruction cache address array directly with an associative
31106write. This not only requires privileged mode at run time, but it also
31107fails if the cache line had been mapped via the TLB and has become unmapped.
31108
d77de738 31109@opindex misize
ddf6fe37 31110@item -misize
d77de738
ML
31111Dump instruction size and location in the assembly code.
31112
d77de738 31113@opindex mpadstruct
ddf6fe37 31114@item -mpadstruct
d77de738
ML
31115This option is deprecated. It pads structures to multiple of 4 bytes,
31116which is incompatible with the SH ABI@.
31117
d77de738 31118@opindex matomic-model=@var{model}
ddf6fe37 31119@item -matomic-model=@var{model}
d77de738
ML
31120Sets the model of atomic operations and additional parameters as a comma
31121separated list. For details on the atomic built-in functions see
31122@ref{__atomic Builtins}. The following models and parameters are supported:
31123
31124@table @samp
31125
31126@item none
31127Disable compiler generated atomic sequences and emit library calls for atomic
31128operations. This is the default if the target is not @code{sh*-*-linux*}.
31129
31130@item soft-gusa
31131Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
31132built-in functions. The generated atomic sequences require additional support
31133from the interrupt/exception handling code of the system and are only suitable
31134for SH3* and SH4* single-core systems. This option is enabled by default when
31135the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
31136this option also partially utilizes the hardware atomic instructions
31137@code{movli.l} and @code{movco.l} to create more efficient code, unless
31138@samp{strict} is specified.
31139
31140@item soft-tcb
31141Generate software atomic sequences that use a variable in the thread control
31142block. This is a variation of the gUSA sequences which can also be used on
31143SH1* and SH2* targets. The generated atomic sequences require additional
31144support from the interrupt/exception handling code of the system and are only
31145suitable for single-core systems. When using this model, the @samp{gbr-offset=}
31146parameter has to be specified as well.
31147
31148@item soft-imask
31149Generate software atomic sequences that temporarily disable interrupts by
31150setting @code{SR.IMASK = 1111}. This model works only when the program runs
31151in privileged mode and is only suitable for single-core systems. Additional
31152support from the interrupt/exception handling code of the system is not
31153required. This model is enabled by default when the target is
31154@code{sh*-*-linux*} and SH1* or SH2*.
31155
31156@item hard-llcs
31157Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
31158instructions only. This is only available on SH4A and is suitable for
31159multi-core systems. Since the hardware instructions support only 32 bit atomic
31160variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
31161Code compiled with this option is also compatible with other software
31162atomic model interrupt/exception handling systems if executed on an SH4A
31163system. Additional support from the interrupt/exception handling code of the
31164system is not required for this model.
31165
31166@item gbr-offset=
31167This parameter specifies the offset in bytes of the variable in the thread
31168control block structure that should be used by the generated atomic sequences
31169when the @samp{soft-tcb} model has been selected. For other models this
31170parameter is ignored. The specified value must be an integer multiple of four
31171and in the range 0-1020.
31172
31173@item strict
31174This parameter prevents mixed usage of multiple atomic models, even if they
31175are compatible, and makes the compiler generate atomic sequences of the
31176specified model only.
31177
31178@end table
31179
d77de738 31180@opindex mtas
ddf6fe37 31181@item -mtas
d77de738
ML
31182Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
31183Notice that depending on the particular hardware and software configuration
31184this can degrade overall performance due to the operand cache line flushes
31185that are implied by the @code{tas.b} instruction. On multi-core SH4A
31186processors the @code{tas.b} instruction must be used with caution since it
31187can result in data corruption for certain cache configurations.
31188
d77de738 31189@opindex mprefergot
ddf6fe37 31190@item -mprefergot
d77de738
ML
31191When generating position-independent code, emit function calls using
31192the Global Offset Table instead of the Procedure Linkage Table.
31193
d77de738
ML
31194@opindex musermode
31195@opindex mno-usermode
ddf6fe37
AA
31196@item -musermode
31197@itemx -mno-usermode
d77de738
ML
31198Don't allow (allow) the compiler generating privileged mode code. Specifying
31199@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31200inlined code would not work in user mode. @option{-musermode} is the default
31201when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31202@option{-musermode} has no effect, since there is no user mode.
31203
d77de738 31204@opindex multcost=@var{number}
ddf6fe37 31205@item -multcost=@var{number}
d77de738
ML
31206Set the cost to assume for a multiply insn.
31207
d77de738 31208@opindex mdiv=@var{strategy}
ddf6fe37 31209@item -mdiv=@var{strategy}
d77de738
ML
31210Set the division strategy to be used for integer division operations.
31211@var{strategy} can be one of:
31212
31213@table @samp
31214
31215@item call-div1
31216Calls a library function that uses the single-step division instruction
31217@code{div1} to perform the operation. Division by zero calculates an
31218unspecified result and does not trap. This is the default except for SH4,
31219SH2A and SHcompact.
31220
31221@item call-fp
31222Calls a library function that performs the operation in double precision
31223floating point. Division by zero causes a floating-point exception. This is
31224the default for SHcompact with FPU. Specifying this for targets that do not
31225have a double precision FPU defaults to @code{call-div1}.
31226
31227@item call-table
31228Calls a library function that uses a lookup table for small divisors and
31229the @code{div1} instruction with case distinction for larger divisors. Division
31230by zero calculates an unspecified result and does not trap. This is the default
31231for SH4. Specifying this for targets that do not have dynamic shift
31232instructions defaults to @code{call-div1}.
31233
31234@end table
31235
31236When a division strategy has not been specified the default strategy is
31237selected based on the current target. For SH2A the default strategy is to
31238use the @code{divs} and @code{divu} instructions instead of library function
31239calls.
31240
d77de738 31241@opindex maccumulate-outgoing-args
ddf6fe37 31242@item -maccumulate-outgoing-args
d77de738
ML
31243Reserve space once for outgoing arguments in the function prologue rather
31244than around each call. Generally beneficial for performance and size. Also
31245needed for unwinding to avoid changing the stack frame around conditional code.
31246
d77de738 31247@opindex mdivsi3_libfunc=@var{name}
ddf6fe37 31248@item -mdivsi3_libfunc=@var{name}
d77de738
ML
31249Set the name of the library function used for 32-bit signed division to
31250@var{name}.
31251This only affects the name used in the @samp{call} division strategies, and
31252the compiler still expects the same sets of input/output/clobbered registers as
31253if this option were not present.
31254
d77de738 31255@opindex mfixed-range
ddf6fe37 31256@item -mfixed-range=@var{register-range}
d77de738
ML
31257Generate code treating the given register range as fixed registers.
31258A fixed register is one that the register allocator cannot use. This is
31259useful when compiling kernel code. A register range is specified as
31260two registers separated by a dash. Multiple register ranges can be
31261specified separated by a comma.
31262
d77de738 31263@opindex mbranch-cost=@var{num}
ddf6fe37 31264@item -mbranch-cost=@var{num}
d77de738
ML
31265Assume @var{num} to be the cost for a branch instruction. Higher numbers
31266make the compiler try to generate more branch-free code if possible.
31267If not specified the value is selected depending on the processor type that
31268is being compiled for.
31269
d77de738
ML
31270@opindex mzdcbranch
31271@opindex mno-zdcbranch
ddf6fe37
AA
31272@item -mzdcbranch
31273@itemx -mno-zdcbranch
d77de738
ML
31274Assume (do not assume) that zero displacement conditional branch instructions
31275@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31276compiler prefers zero displacement branch code sequences. This is
31277enabled by default when generating code for SH4 and SH4A. It can be explicitly
31278disabled by specifying @option{-mno-zdcbranch}.
31279
d77de738 31280@opindex mcbranch-force-delay-slot
ddf6fe37 31281@item -mcbranch-force-delay-slot
d77de738
ML
31282Force the usage of delay slots for conditional branches, which stuffs the delay
31283slot with a @code{nop} if a suitable instruction cannot be found. By default
31284this option is disabled. It can be enabled to work around hardware bugs as
31285found in the original SH7055.
31286
d77de738
ML
31287@opindex mfused-madd
31288@opindex mno-fused-madd
ddf6fe37
AA
31289@item -mfused-madd
31290@itemx -mno-fused-madd
d77de738
ML
31291Generate code that uses (does not use) the floating-point multiply and
31292accumulate instructions. These instructions are generated by default
31293if hardware floating point is used. The machine-dependent
31294@option{-mfused-madd} option is now mapped to the machine-independent
31295@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31296mapped to @option{-ffp-contract=off}.
31297
d77de738
ML
31298@opindex mfsca
31299@opindex mno-fsca
ddf6fe37
AA
31300@item -mfsca
31301@itemx -mno-fsca
d77de738
ML
31302Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31303and cosine approximations. The option @option{-mfsca} must be used in
31304combination with @option{-funsafe-math-optimizations}. It is enabled by default
31305when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31306approximations even if @option{-funsafe-math-optimizations} is in effect.
31307
d77de738
ML
31308@opindex mfsrra
31309@opindex mno-fsrra
ddf6fe37
AA
31310@item -mfsrra
31311@itemx -mno-fsrra
d77de738
ML
31312Allow or disallow the compiler to emit the @code{fsrra} instruction for
31313reciprocal square root approximations. The option @option{-mfsrra} must be used
31314in combination with @option{-funsafe-math-optimizations} and
31315@option{-ffinite-math-only}. It is enabled by default when generating code for
31316SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31317even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31318in effect.
31319
d77de738 31320@opindex mpretend-cmove
ddf6fe37 31321@item -mpretend-cmove
d77de738
ML
31322Prefer zero-displacement conditional branches for conditional move instruction
31323patterns. This can result in faster code on the SH4 processor.
31324
d77de738 31325@opindex fdpic
ddf6fe37 31326@item -mfdpic
d77de738
ML
31327Generate code using the FDPIC ABI.
31328
31329@end table
31330
31331@node Solaris 2 Options
31332@subsection Solaris 2 Options
31333@cindex Solaris 2 options
31334
31335These @samp{-m} options are supported on Solaris 2:
31336
31337@table @gcctabopt
d77de738 31338@opindex mclear-hwcap
ddf6fe37 31339@item -mclear-hwcap
d77de738
ML
31340@option{-mclear-hwcap} tells the compiler to remove the hardware
31341capabilities generated by the Solaris assembler. This is only necessary
31342when object files use ISA extensions not supported by the current
31343machine, but check at runtime whether or not to use them.
31344
d77de738 31345@opindex mimpure-text
ddf6fe37 31346@item -mimpure-text
d77de738
ML
31347@option{-mimpure-text}, used in addition to @option{-shared}, tells
31348the compiler to not pass @option{-z text} to the linker when linking a
31349shared object. Using this option, you can link position-dependent
31350code into a shared object.
31351
31352@option{-mimpure-text} suppresses the ``relocations remain against
31353allocatable but non-writable sections'' linker error message.
31354However, the necessary relocations trigger copy-on-write, and the
31355shared object is not actually shared across processes. Instead of
31356using @option{-mimpure-text}, you should compile all source code with
31357@option{-fpic} or @option{-fPIC}.
31358
31359@end table
31360
31361These switches are supported in addition to the above on Solaris 2:
31362
31363@table @gcctabopt
d77de738 31364@opindex pthreads
ddf6fe37 31365@item -pthreads
d77de738
ML
31366This is a synonym for @option{-pthread}.
31367@end table
31368
31369@node SPARC Options
31370@subsection SPARC Options
31371@cindex SPARC options
31372
31373These @samp{-m} options are supported on the SPARC:
31374
31375@table @gcctabopt
d77de738
ML
31376@opindex mno-app-regs
31377@opindex mapp-regs
ddf6fe37
AA
31378@item -mno-app-regs
31379@itemx -mapp-regs
d77de738
ML
31380Specify @option{-mapp-regs} to generate output using the global registers
313812 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31382global register 1, each global register 2 through 4 is then treated as an
31383allocable register that is clobbered by function calls. This is the default.
31384
31385To be fully SVR4 ABI-compliant at the cost of some performance loss,
31386specify @option{-mno-app-regs}. You should compile libraries and system
31387software with this option.
31388
d77de738
ML
31389@opindex mflat
31390@opindex mno-flat
ddf6fe37
AA
31391@item -mflat
31392@itemx -mno-flat
d77de738
ML
31393With @option{-mflat}, the compiler does not generate save/restore instructions
31394and uses a ``flat'' or single register window model. This model is compatible
31395with the regular register window model. The local registers and the input
31396registers (0--5) are still treated as ``call-saved'' registers and are
31397saved on the stack as needed.
31398
31399With @option{-mno-flat} (the default), the compiler generates save/restore
31400instructions (except for leaf functions). This is the normal operating mode.
31401
d77de738
ML
31402@opindex mfpu
31403@opindex mhard-float
ddf6fe37
AA
31404@item -mfpu
31405@itemx -mhard-float
d77de738
ML
31406Generate output containing floating-point instructions. This is the
31407default.
31408
d77de738
ML
31409@opindex mno-fpu
31410@opindex msoft-float
ddf6fe37
AA
31411@item -mno-fpu
31412@itemx -msoft-float
d77de738
ML
31413Generate output containing library calls for floating point.
31414@strong{Warning:} the requisite libraries are not available for all SPARC
31415targets. Normally the facilities of the machine's usual C compiler are
31416used, but this cannot be done directly in cross-compilation. You must make
31417your own arrangements to provide suitable library functions for
31418cross-compilation. The embedded targets @samp{sparc-*-aout} and
31419@samp{sparclite-*-*} do provide software floating-point support.
31420
31421@option{-msoft-float} changes the calling convention in the output file;
31422therefore, it is only useful if you compile @emph{all} of a program with
31423this option. In particular, you need to compile @file{libgcc.a}, the
31424library that comes with GCC, with @option{-msoft-float} in order for
31425this to work.
31426
d77de738 31427@opindex mhard-quad-float
ddf6fe37 31428@item -mhard-quad-float
d77de738
ML
31429Generate output containing quad-word (long double) floating-point
31430instructions.
31431
d77de738 31432@opindex msoft-quad-float
ddf6fe37 31433@item -msoft-quad-float
d77de738
ML
31434Generate output containing library calls for quad-word (long double)
31435floating-point instructions. The functions called are those specified
31436in the SPARC ABI@. This is the default.
31437
31438As of this writing, there are no SPARC implementations that have hardware
31439support for the quad-word floating-point instructions. They all invoke
31440a trap handler for one of these instructions, and then the trap handler
31441emulates the effect of the instruction. Because of the trap handler overhead,
31442this is much slower than calling the ABI library routines. Thus the
31443@option{-msoft-quad-float} option is the default.
31444
d77de738
ML
31445@opindex mno-unaligned-doubles
31446@opindex munaligned-doubles
ddf6fe37
AA
31447@item -mno-unaligned-doubles
31448@itemx -munaligned-doubles
d77de738
ML
31449Assume that doubles have 8-byte alignment. This is the default.
31450
31451With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31452alignment only if they are contained in another type, or if they have an
31453absolute address. Otherwise, it assumes they have 4-byte alignment.
31454Specifying this option avoids some rare compatibility problems with code
31455generated by other compilers. It is not the default because it results
31456in a performance loss, especially for floating-point code.
31457
d77de738
ML
31458@opindex muser-mode
31459@opindex mno-user-mode
ddf6fe37
AA
31460@item -muser-mode
31461@itemx -mno-user-mode
d77de738
ML
31462Do not generate code that can only run in supervisor mode. This is relevant
31463only for the @code{casa} instruction emitted for the LEON3 processor. This
31464is the default.
31465
d77de738
ML
31466@opindex mfaster-structs
31467@opindex mno-faster-structs
ddf6fe37
AA
31468@item -mfaster-structs
31469@itemx -mno-faster-structs
d77de738
ML
31470With @option{-mfaster-structs}, the compiler assumes that structures
31471should have 8-byte alignment. This enables the use of pairs of
31472@code{ldd} and @code{std} instructions for copies in structure
31473assignment, in place of twice as many @code{ld} and @code{st} pairs.
31474However, the use of this changed alignment directly violates the SPARC
31475ABI@. Thus, it's intended only for use on targets where the developer
31476acknowledges that their resulting code is not directly in line with
31477the rules of the ABI@.
31478
d77de738
ML
31479@opindex mstd-struct-return
31480@opindex mno-std-struct-return
ddf6fe37
AA
31481@item -mstd-struct-return
31482@itemx -mno-std-struct-return
d77de738
ML
31483With @option{-mstd-struct-return}, the compiler generates checking code
31484in functions returning structures or unions to detect size mismatches
31485between the two sides of function calls, as per the 32-bit ABI@.
31486
31487The default is @option{-mno-std-struct-return}. This option has no effect
31488in 64-bit mode.
31489
d77de738
ML
31490@opindex mlra
31491@opindex mno-lra
ddf6fe37
AA
31492@item -mlra
31493@itemx -mno-lra
d77de738
ML
31494Enable Local Register Allocation. This is the default for SPARC since GCC 7
31495so @option{-mno-lra} needs to be passed to get old Reload.
31496
d77de738 31497@opindex mcpu
ddf6fe37 31498@item -mcpu=@var{cpu_type}
d77de738
ML
31499Set the instruction set, register set, and instruction scheduling parameters
31500for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31501@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31502@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31503@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31504@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31505@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31506@samp{m8}.
31507
31508Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31509which selects the best architecture option for the host processor.
31510@option{-mcpu=native} has no effect if GCC does not recognize
31511the processor.
31512
31513Default instruction scheduling parameters are used for values that select
31514an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31515@samp{sparclite}, @samp{sparclet}, @samp{v9}.
31516
31517Here is a list of each supported architecture and their supported
31518implementations.
31519
31520@table @asis
31521@item v7
31522cypress, leon3v7
31523
31524@item v8
31525supersparc, hypersparc, leon, leon3, leon5
31526
31527@item sparclite
31528f930, f934, sparclite86x
31529
31530@item sparclet
31531tsc701
31532
31533@item v9
31534ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31535niagara7, m8
31536@end table
31537
31538By default (unless configured otherwise), GCC generates code for the V7
31539variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31540additionally optimizes it for the Cypress CY7C602 chip, as used in the
31541SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31542SPARCStation 1, 2, IPX etc.
31543
31544With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31545architecture. The only difference from V7 code is that the compiler emits
31546the integer multiply and integer divide instructions which exist in SPARC-V8
31547but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31548optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
315492000 series.
31550
31551With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31552the SPARC architecture. This adds the integer multiply, integer divide step
31553and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31554With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31555Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31556@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31557MB86934 chip, which is the more recent SPARClite with FPU@.
31558
31559With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31560the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31561integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31562but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31563optimizes it for the TEMIC SPARClet chip.
31564
31565With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31566architecture. This adds 64-bit integer and floating-point move instructions,
315673 additional floating-point condition code registers and conditional move
31568instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31569optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31570@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31571Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31572@option{-mcpu=niagara}, the compiler additionally optimizes it for
31573Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31574additionally optimizes it for Sun UltraSPARC T2 chips. With
31575@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
31576UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
31577additionally optimizes it for Sun UltraSPARC T4 chips. With
31578@option{-mcpu=niagara7}, the compiler additionally optimizes it for
31579Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
31580additionally optimizes it for Oracle M8 chips.
31581
d77de738 31582@opindex mtune
ddf6fe37 31583@item -mtune=@var{cpu_type}
d77de738
ML
31584Set the instruction scheduling parameters for machine type
31585@var{cpu_type}, but do not set the instruction set or register set that the
31586option @option{-mcpu=@var{cpu_type}} does.
31587
31588The same values for @option{-mcpu=@var{cpu_type}} can be used for
31589@option{-mtune=@var{cpu_type}}, but the only useful values are those
31590that select a particular CPU implementation. Those are
31591@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
31592@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
31593@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
31594@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
31595@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
31596and GNU/Linux toolchains, @samp{native} can also be used.
31597
d77de738
ML
31598@opindex mv8plus
31599@opindex mno-v8plus
ddf6fe37
AA
31600@item -mv8plus
31601@itemx -mno-v8plus
d77de738
ML
31602With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
31603difference from the V8 ABI is that the global and out registers are
31604considered 64 bits wide. This is enabled by default on Solaris in 32-bit
31605mode for all SPARC-V9 processors.
31606
d77de738
ML
31607@opindex mvis
31608@opindex mno-vis
ddf6fe37
AA
31609@item -mvis
31610@itemx -mno-vis
d77de738
ML
31611With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
31612Visual Instruction Set extensions. The default is @option{-mno-vis}.
31613
d77de738
ML
31614@opindex mvis2
31615@opindex mno-vis2
ddf6fe37
AA
31616@item -mvis2
31617@itemx -mno-vis2
d77de738
ML
31618With @option{-mvis2}, GCC generates code that takes advantage of
31619version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
31620default is @option{-mvis2} when targeting a cpu that supports such
31621instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
31622also sets @option{-mvis}.
31623
d77de738
ML
31624@opindex mvis3
31625@opindex mno-vis3
ddf6fe37
AA
31626@item -mvis3
31627@itemx -mno-vis3
d77de738
ML
31628With @option{-mvis3}, GCC generates code that takes advantage of
31629version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
31630default is @option{-mvis3} when targeting a cpu that supports such
31631instructions, such as niagara-3 and later. Setting @option{-mvis3}
31632also sets @option{-mvis2} and @option{-mvis}.
31633
d77de738
ML
31634@opindex mvis4
31635@opindex mno-vis4
ddf6fe37
AA
31636@item -mvis4
31637@itemx -mno-vis4
d77de738
ML
31638With @option{-mvis4}, GCC generates code that takes advantage of
31639version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
31640default is @option{-mvis4} when targeting a cpu that supports such
31641instructions, such as niagara-7 and later. Setting @option{-mvis4}
31642also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
31643
d77de738
ML
31644@opindex mvis4b
31645@opindex mno-vis4b
ddf6fe37
AA
31646@item -mvis4b
31647@itemx -mno-vis4b
d77de738
ML
31648With @option{-mvis4b}, GCC generates code that takes advantage of
31649version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
31650the additional VIS instructions introduced in the Oracle SPARC
31651Architecture 2017. The default is @option{-mvis4b} when targeting a
31652cpu that supports such instructions, such as m8 and later. Setting
31653@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
31654@option{-mvis2} and @option{-mvis}.
31655
d77de738
ML
31656@opindex mcbcond
31657@opindex mno-cbcond
ddf6fe37
AA
31658@item -mcbcond
31659@itemx -mno-cbcond
d77de738
ML
31660With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
31661Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
31662when targeting a CPU that supports such instructions, such as Niagara-4 and
31663later.
31664
d77de738
ML
31665@opindex mfmaf
31666@opindex mno-fmaf
ddf6fe37
AA
31667@item -mfmaf
31668@itemx -mno-fmaf
d77de738
ML
31669With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
31670Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
31671when targeting a CPU that supports such instructions, such as Niagara-3 and
31672later.
31673
d77de738
ML
31674@opindex mfsmuld
31675@opindex mno-fsmuld
ddf6fe37
AA
31676@item -mfsmuld
31677@itemx -mno-fsmuld
d77de738
ML
31678With @option{-mfsmuld}, GCC generates code that takes advantage of the
31679Floating-point Multiply Single to Double (FsMULd) instruction. The default is
31680@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
31681or V9 with FPU except @option{-mcpu=leon}.
31682
d77de738
ML
31683@opindex mpopc
31684@opindex mno-popc
ddf6fe37
AA
31685@item -mpopc
31686@itemx -mno-popc
d77de738
ML
31687With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
31688Population Count instruction. The default is @option{-mpopc}
31689when targeting a CPU that supports such an instruction, such as Niagara-2 and
31690later.
31691
d77de738
ML
31692@opindex msubxc
31693@opindex mno-subxc
ddf6fe37
AA
31694@item -msubxc
31695@itemx -mno-subxc
d77de738
ML
31696With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
31697Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
31698when targeting a CPU that supports such an instruction, such as Niagara-7 and
31699later.
31700
d77de738 31701@opindex mfix-at697f
ddf6fe37 31702@item -mfix-at697f
d77de738
ML
31703Enable the documented workaround for the single erratum of the Atmel AT697F
31704processor (which corresponds to erratum #13 of the AT697E processor).
31705
d77de738 31706@opindex mfix-ut699
ddf6fe37 31707@item -mfix-ut699
d77de738
ML
31708Enable the documented workarounds for the floating-point errata and the data
31709cache nullify errata of the UT699 processor.
31710
d77de738 31711@opindex mfix-ut700
ddf6fe37 31712@item -mfix-ut700
d77de738
ML
31713Enable the documented workaround for the back-to-back store errata of
31714the UT699E/UT700 processor.
31715
d77de738 31716@opindex mfix-gr712rc
ddf6fe37 31717@item -mfix-gr712rc
d77de738
ML
31718Enable the documented workaround for the back-to-back store errata of
31719the GR712RC processor.
31720@end table
31721
31722These @samp{-m} options are supported in addition to the above
31723on SPARC-V9 processors in 64-bit environments:
31724
31725@table @gcctabopt
d77de738
ML
31726@opindex m32
31727@opindex m64
ddf6fe37
AA
31728@item -m32
31729@itemx -m64
d77de738
ML
31730Generate code for a 32-bit or 64-bit environment.
31731The 32-bit environment sets int, long and pointer to 32 bits.
31732The 64-bit environment sets int to 32 bits and long and pointer
31733to 64 bits.
31734
d77de738 31735@opindex mcmodel
ddf6fe37 31736@item -mcmodel=@var{which}
d77de738
ML
31737Set the code model to one of
31738
31739@table @samp
31740@item medlow
31741The Medium/Low code model: 64-bit addresses, programs
31742must be linked in the low 32 bits of memory. Programs can be statically
31743or dynamically linked.
31744
31745@item medmid
31746The Medium/Middle code model: 64-bit addresses, programs
31747must be linked in the low 44 bits of memory, the text and data segments must
31748be less than 2GB in size and the data segment must be located within 2GB of
31749the text segment.
31750
31751@item medany
31752The Medium/Anywhere code model: 64-bit addresses, programs
31753may be linked anywhere in memory, the text and data segments must be less
31754than 2GB in size and the data segment must be located within 2GB of the
31755text segment.
31756
31757@item embmedany
31758The Medium/Anywhere code model for embedded systems:
3175964-bit addresses, the text and data segments must be less than 2GB in
31760size, both starting anywhere in memory (determined at link time). The
31761global register %g4 points to the base of the data segment. Programs
31762are statically linked and PIC is not supported.
31763@end table
31764
d77de738 31765@opindex mmemory-model
ddf6fe37 31766@item -mmemory-model=@var{mem-model}
d77de738
ML
31767Set the memory model in force on the processor to one of
31768
31769@table @samp
31770@item default
31771The default memory model for the processor and operating system.
31772
31773@item rmo
31774Relaxed Memory Order
31775
31776@item pso
31777Partial Store Order
31778
31779@item tso
31780Total Store Order
31781
31782@item sc
31783Sequential Consistency
31784@end table
31785
31786These memory models are formally defined in Appendix D of the SPARC-V9
31787architecture manual, as set in the processor's @code{PSTATE.MM} field.
31788
d77de738
ML
31789@opindex mstack-bias
31790@opindex mno-stack-bias
ddf6fe37
AA
31791@item -mstack-bias
31792@itemx -mno-stack-bias
d77de738
ML
31793With @option{-mstack-bias}, GCC assumes that the stack pointer, and
31794frame pointer if present, are offset by @minus{}2047 which must be added back
31795when making stack frame references. This is the default in 64-bit mode.
31796Otherwise, assume no such offset is present.
31797@end table
31798
31799@node System V Options
31800@subsection Options for System V
31801
31802These additional options are available on System V Release 4 for
31803compatibility with other compilers on those systems:
31804
31805@table @gcctabopt
d77de738 31806@opindex G
ddf6fe37 31807@item -G
d77de738
ML
31808Create a shared object.
31809It is recommended that @option{-symbolic} or @option{-shared} be used instead.
31810
d77de738 31811@opindex Qy
ddf6fe37 31812@item -Qy
d77de738
ML
31813Identify the versions of each tool used by the compiler, in a
31814@code{.ident} assembler directive in the output.
31815
d77de738 31816@opindex Qn
ddf6fe37 31817@item -Qn
d77de738
ML
31818Refrain from adding @code{.ident} directives to the output file (this is
31819the default).
31820
d77de738 31821@opindex YP
ddf6fe37 31822@item -YP,@var{dirs}
d77de738
ML
31823Search the directories @var{dirs}, and no others, for libraries
31824specified with @option{-l}.
31825
d77de738 31826@opindex Ym
ddf6fe37 31827@item -Ym,@var{dir}
d77de738
ML
31828Look in the directory @var{dir} to find the M4 preprocessor.
31829The assembler uses this option.
31830@c This is supposed to go with a -Yd for predefined M4 macro files, but
31831@c the generic assembler that comes with Solaris takes just -Ym.
31832@end table
31833
31834@node V850 Options
31835@subsection V850 Options
31836@cindex V850 Options
31837
31838These @samp{-m} options are defined for V850 implementations:
31839
31840@table @gcctabopt
d77de738
ML
31841@opindex mlong-calls
31842@opindex mno-long-calls
ddf6fe37
AA
31843@item -mlong-calls
31844@itemx -mno-long-calls
d77de738
ML
31845Treat all calls as being far away (near). If calls are assumed to be
31846far away, the compiler always loads the function's address into a
31847register, and calls indirect through the pointer.
31848
d77de738
ML
31849@opindex mno-ep
31850@opindex mep
ddf6fe37
AA
31851@item -mno-ep
31852@itemx -mep
d77de738
ML
31853Do not optimize (do optimize) basic blocks that use the same index
31854pointer 4 or more times to copy pointer into the @code{ep} register, and
31855use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
31856option is on by default if you optimize.
31857
d77de738
ML
31858@opindex mno-prolog-function
31859@opindex mprolog-function
ddf6fe37
AA
31860@item -mno-prolog-function
31861@itemx -mprolog-function
d77de738
ML
31862Do not use (do use) external functions to save and restore registers
31863at the prologue and epilogue of a function. The external functions
31864are slower, but use less code space if more than one function saves
31865the same number of registers. The @option{-mprolog-function} option
31866is on by default if you optimize.
31867
d77de738 31868@opindex mspace
ddf6fe37 31869@item -mspace
d77de738
ML
31870Try to make the code as small as possible. At present, this just turns
31871on the @option{-mep} and @option{-mprolog-function} options.
31872
d77de738 31873@opindex mtda
ddf6fe37 31874@item -mtda=@var{n}
d77de738
ML
31875Put static or global variables whose size is @var{n} bytes or less into
31876the tiny data area that register @code{ep} points to. The tiny data
31877area can hold up to 256 bytes in total (128 bytes for byte references).
31878
d77de738 31879@opindex msda
ddf6fe37 31880@item -msda=@var{n}
d77de738
ML
31881Put static or global variables whose size is @var{n} bytes or less into
31882the small data area that register @code{gp} points to. The small data
31883area can hold up to 64 kilobytes.
31884
d77de738 31885@opindex mzda
ddf6fe37 31886@item -mzda=@var{n}
d77de738
ML
31887Put static or global variables whose size is @var{n} bytes or less into
31888the first 32 kilobytes of memory.
31889
d77de738 31890@opindex mv850
ddf6fe37 31891@item -mv850
d77de738
ML
31892Specify that the target processor is the V850.
31893
d77de738 31894@opindex mv850e3v5
ddf6fe37 31895@item -mv850e3v5
d77de738
ML
31896Specify that the target processor is the V850E3V5. The preprocessor
31897constant @code{__v850e3v5__} is defined if this option is used.
31898
d77de738 31899@opindex mv850e2v4
ddf6fe37 31900@item -mv850e2v4
d77de738
ML
31901Specify that the target processor is the V850E3V5. This is an alias for
31902the @option{-mv850e3v5} option.
31903
d77de738 31904@opindex mv850e2v3
ddf6fe37 31905@item -mv850e2v3
d77de738
ML
31906Specify that the target processor is the V850E2V3. The preprocessor
31907constant @code{__v850e2v3__} is defined if this option is used.
31908
d77de738 31909@opindex mv850e2
ddf6fe37 31910@item -mv850e2
d77de738
ML
31911Specify that the target processor is the V850E2. The preprocessor
31912constant @code{__v850e2__} is defined if this option is used.
31913
d77de738 31914@opindex mv850e1
ddf6fe37 31915@item -mv850e1
d77de738
ML
31916Specify that the target processor is the V850E1. The preprocessor
31917constants @code{__v850e1__} and @code{__v850e__} are defined if
31918this option is used.
31919
d77de738 31920@opindex mv850es
ddf6fe37 31921@item -mv850es
d77de738
ML
31922Specify that the target processor is the V850ES. This is an alias for
31923the @option{-mv850e1} option.
31924
d77de738 31925@opindex mv850e
ddf6fe37 31926@item -mv850e
d77de738
ML
31927Specify that the target processor is the V850E@. The preprocessor
31928constant @code{__v850e__} is defined if this option is used.
31929
31930If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
31931nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
31932are defined then a default target processor is chosen and the
31933relevant @samp{__v850*__} preprocessor constant is defined.
31934
31935The preprocessor constants @code{__v850} and @code{__v851__} are always
31936defined, regardless of which processor variant is the target.
31937
d77de738
ML
31938@opindex mdisable-callt
31939@opindex mno-disable-callt
ddf6fe37
AA
31940@item -mdisable-callt
31941@itemx -mno-disable-callt
d77de738
ML
31942This option suppresses generation of the @code{CALLT} instruction for the
31943v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
31944architecture.
31945
31946This option is enabled by default when the RH850 ABI is
31947in use (see @option{-mrh850-abi}), and disabled by default when the
31948GCC ABI is in use. If @code{CALLT} instructions are being generated
31949then the C preprocessor symbol @code{__V850_CALLT__} is defined.
31950
d77de738
ML
31951@opindex mrelax
31952@opindex mno-relax
ddf6fe37
AA
31953@item -mrelax
31954@itemx -mno-relax
d77de738
ML
31955Pass on (or do not pass on) the @option{-mrelax} command-line option
31956to the assembler.
31957
d77de738
ML
31958@opindex mlong-jumps
31959@opindex mno-long-jumps
ddf6fe37
AA
31960@item -mlong-jumps
31961@itemx -mno-long-jumps
d77de738
ML
31962Disable (or re-enable) the generation of PC-relative jump instructions.
31963
d77de738
ML
31964@opindex msoft-float
31965@opindex mhard-float
ddf6fe37
AA
31966@item -msoft-float
31967@itemx -mhard-float
d77de738
ML
31968Disable (or re-enable) the generation of hardware floating point
31969instructions. This option is only significant when the target
31970architecture is @samp{V850E2V3} or higher. If hardware floating point
31971instructions are being generated then the C preprocessor symbol
31972@code{__FPU_OK__} is defined, otherwise the symbol
31973@code{__NO_FPU__} is defined.
31974
d77de738 31975@opindex mloop
ddf6fe37 31976@item -mloop
d77de738
ML
31977Enables the use of the e3v5 LOOP instruction. The use of this
31978instruction is not enabled by default when the e3v5 architecture is
31979selected because its use is still experimental.
31980
d77de738
ML
31981@opindex mrh850-abi
31982@opindex mghs
ddf6fe37
AA
31983@item -mrh850-abi
31984@itemx -mghs
d77de738
ML
31985Enables support for the RH850 version of the V850 ABI. This is the
31986default. With this version of the ABI the following rules apply:
31987
31988@itemize
31989@item
31990Integer sized structures and unions are returned via a memory pointer
31991rather than a register.
31992
31993@item
31994Large structures and unions (more than 8 bytes in size) are passed by
31995value.
31996
31997@item
31998Functions are aligned to 16-bit boundaries.
31999
32000@item
32001The @option{-m8byte-align} command-line option is supported.
32002
32003@item
32004The @option{-mdisable-callt} command-line option is enabled by
32005default. The @option{-mno-disable-callt} command-line option is not
32006supported.
32007@end itemize
32008
32009When this version of the ABI is enabled the C preprocessor symbol
32010@code{__V850_RH850_ABI__} is defined.
32011
d77de738 32012@opindex mgcc-abi
ddf6fe37 32013@item -mgcc-abi
d77de738
ML
32014Enables support for the old GCC version of the V850 ABI. With this
32015version of the ABI the following rules apply:
32016
32017@itemize
32018@item
32019Integer sized structures and unions are returned in register @code{r10}.
32020
32021@item
32022Large structures and unions (more than 8 bytes in size) are passed by
32023reference.
32024
32025@item
32026Functions are aligned to 32-bit boundaries, unless optimizing for
32027size.
32028
32029@item
32030The @option{-m8byte-align} command-line option is not supported.
32031
32032@item
32033The @option{-mdisable-callt} command-line option is supported but not
32034enabled by default.
32035@end itemize
32036
32037When this version of the ABI is enabled the C preprocessor symbol
32038@code{__V850_GCC_ABI__} is defined.
32039
d77de738
ML
32040@opindex m8byte-align
32041@opindex mno-8byte-align
ddf6fe37
AA
32042@item -m8byte-align
32043@itemx -mno-8byte-align
d77de738
ML
32044Enables support for @code{double} and @code{long long} types to be
32045aligned on 8-byte boundaries. The default is to restrict the
32046alignment of all objects to at most 4-bytes. When
32047@option{-m8byte-align} is in effect the C preprocessor symbol
32048@code{__V850_8BYTE_ALIGN__} is defined.
32049
d77de738 32050@opindex mbig-switch
ddf6fe37 32051@item -mbig-switch
d77de738
ML
32052Generate code suitable for big switch tables. Use this option only if
32053the assembler/linker complain about out of range branches within a switch
32054table.
32055
d77de738 32056@opindex mapp-regs
ddf6fe37 32057@item -mapp-regs
d77de738
ML
32058This option causes r2 and r5 to be used in the code generated by
32059the compiler. This setting is the default.
32060
d77de738 32061@opindex mno-app-regs
ddf6fe37 32062@item -mno-app-regs
d77de738
ML
32063This option causes r2 and r5 to be treated as fixed registers.
32064
32065@end table
32066
32067@node VAX Options
32068@subsection VAX Options
32069@cindex VAX options
32070
32071These @samp{-m} options are defined for the VAX:
32072
32073@table @gcctabopt
d77de738 32074@opindex munix
ddf6fe37 32075@item -munix
d77de738
ML
32076Do not output certain jump instructions (@code{aobleq} and so on)
32077that the Unix assembler for the VAX cannot handle across long
32078ranges.
32079
d77de738 32080@opindex mgnu
ddf6fe37 32081@item -mgnu
d77de738
ML
32082Do output those jump instructions, on the assumption that the
32083GNU assembler is being used.
32084
d77de738 32085@opindex mg
ddf6fe37 32086@item -mg
d77de738
ML
32087Output code for G-format floating-point numbers instead of D-format.
32088
d77de738
ML
32089@opindex mlra
32090@opindex mno-lra
ddf6fe37
AA
32091@item -mlra
32092@itemx -mno-lra
d77de738
ML
32093Enable Local Register Allocation. This is still experimental for the VAX,
32094so by default the compiler uses standard reload.
32095@end table
32096
32097@node Visium Options
32098@subsection Visium Options
32099@cindex Visium options
32100
32101@table @gcctabopt
32102
d77de738 32103@opindex mdebug
ddf6fe37 32104@item -mdebug
d77de738
ML
32105A program which performs file I/O and is destined to run on an MCM target
32106should be linked with this option. It causes the libraries libc.a and
32107libdebug.a to be linked. The program should be run on the target under
32108the control of the GDB remote debugging stub.
32109
d77de738 32110@opindex msim
ddf6fe37 32111@item -msim
d77de738
ML
32112A program which performs file I/O and is destined to run on the simulator
32113should be linked with option. This causes libraries libc.a and libsim.a to
32114be linked.
32115
d77de738
ML
32116@opindex mfpu
32117@opindex mhard-float
ddf6fe37
AA
32118@item -mfpu
32119@itemx -mhard-float
d77de738
ML
32120Generate code containing floating-point instructions. This is the
32121default.
32122
d77de738
ML
32123@opindex mno-fpu
32124@opindex msoft-float
ddf6fe37
AA
32125@item -mno-fpu
32126@itemx -msoft-float
d77de738
ML
32127Generate code containing library calls for floating-point.
32128
32129@option{-msoft-float} changes the calling convention in the output file;
32130therefore, it is only useful if you compile @emph{all} of a program with
32131this option. In particular, you need to compile @file{libgcc.a}, the
32132library that comes with GCC, with @option{-msoft-float} in order for
32133this to work.
32134
d77de738 32135@opindex mcpu
ddf6fe37 32136@item -mcpu=@var{cpu_type}
d77de738
ML
32137Set the instruction set, register set, and instruction scheduling parameters
32138for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32139@samp{mcm}, @samp{gr5} and @samp{gr6}.
32140
32141@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
32142
32143By default (unless configured otherwise), GCC generates code for the GR5
32144variant of the Visium architecture.
32145
32146With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
32147architecture. The only difference from GR5 code is that the compiler will
32148generate block move instructions.
32149
d77de738 32150@opindex mtune
ddf6fe37 32151@item -mtune=@var{cpu_type}
d77de738
ML
32152Set the instruction scheduling parameters for machine type @var{cpu_type},
32153but do not set the instruction set or register set that the option
32154@option{-mcpu=@var{cpu_type}} would.
32155
d77de738 32156@opindex msv-mode
ddf6fe37 32157@item -msv-mode
d77de738
ML
32158Generate code for the supervisor mode, where there are no restrictions on
32159the access to general registers. This is the default.
32160
d77de738 32161@opindex muser-mode
ddf6fe37 32162@item -muser-mode
d77de738
ML
32163Generate code for the user mode, where the access to some general registers
32164is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
32165mode; on the GR6, only registers r29 to r31 are affected.
32166@end table
32167
32168@node VMS Options
32169@subsection VMS Options
32170
32171These @samp{-m} options are defined for the VMS implementations:
32172
32173@table @gcctabopt
d77de738 32174@opindex mvms-return-codes
ddf6fe37 32175@item -mvms-return-codes
d77de738
ML
32176Return VMS condition codes from @code{main}. The default is to return POSIX-style
32177condition (e.g.@: error) codes.
32178
d77de738 32179@opindex mdebug-main=@var{prefix}
ddf6fe37 32180@item -mdebug-main=@var{prefix}
d77de738
ML
32181Flag the first routine whose name starts with @var{prefix} as the main
32182routine for the debugger.
32183
d77de738 32184@opindex mmalloc64
ddf6fe37 32185@item -mmalloc64
d77de738
ML
32186Default to 64-bit memory allocation routines.
32187
d77de738 32188@opindex mpointer-size=@var{size}
ddf6fe37 32189@item -mpointer-size=@var{size}
d77de738
ML
32190Set the default size of pointers. Possible options for @var{size} are
32191@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
32192for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
32193The later option disables @code{pragma pointer_size}.
32194@end table
32195
32196@node VxWorks Options
32197@subsection VxWorks Options
32198@cindex VxWorks Options
32199
32200The options in this section are defined for all VxWorks targets.
32201Options specific to the target hardware are listed with the other
32202options for that target.
32203
32204@table @gcctabopt
d77de738 32205@opindex mrtp
ddf6fe37 32206@item -mrtp
d77de738
ML
32207GCC can generate code for both VxWorks kernels and real time processes
32208(RTPs). This option switches from the former to the latter. It also
32209defines the preprocessor macro @code{__RTP__}.
32210
d77de738 32211@opindex non-static
ddf6fe37 32212@item -non-static
d77de738
ML
32213Link an RTP executable against shared libraries rather than static
32214libraries. The options @option{-static} and @option{-shared} can
32215also be used for RTPs (@pxref{Link Options}); @option{-static}
32216is the default.
32217
d77de738
ML
32218@opindex Bstatic
32219@opindex Bdynamic
ddf6fe37
AA
32220@item -Bstatic
32221@itemx -Bdynamic
d77de738
ML
32222These options are passed down to the linker. They are defined for
32223compatibility with Diab.
32224
d77de738 32225@opindex Xbind-lazy
ddf6fe37 32226@item -Xbind-lazy
d77de738
ML
32227Enable lazy binding of function calls. This option is equivalent to
32228@option{-Wl,-z,now} and is defined for compatibility with Diab.
32229
d77de738 32230@opindex Xbind-now
ddf6fe37 32231@item -Xbind-now
d77de738
ML
32232Disable lazy binding of function calls. This option is the default and
32233is defined for compatibility with Diab.
32234@end table
32235
32236@node x86 Options
32237@subsection x86 Options
32238@cindex x86 Options
32239
32240These @samp{-m} options are defined for the x86 family of computers.
32241
32242@table @gcctabopt
32243
d77de738 32244@opindex march
ddf6fe37 32245@item -march=@var{cpu-type}
d77de738
ML
32246Generate instructions for the machine type @var{cpu-type}. In contrast to
32247@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32248for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32249to generate code that may not run at all on processors other than the one
32250indicated. Specifying @option{-march=@var{cpu-type}} implies
32251@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32252
32253The choices for @var{cpu-type} are:
32254
32255@table @samp
32256@item native
32257This selects the CPU to generate code for at compilation time by determining
32258the processor type of the compiling machine. Using @option{-march=native}
32259enables all instruction subsets supported by the local machine (hence
32260the result might not run on different machines). Using @option{-mtune=native}
32261produces code optimized for the local machine under the constraints
32262of the selected instruction set.
32263
32264@item x86-64
32265A generic CPU with 64-bit extensions.
32266
32267@item x86-64-v2
32268@itemx x86-64-v3
32269@itemx x86-64-v4
32270These choices for @var{cpu-type} select the corresponding
32271micro-architecture level from the x86-64 psABI. On ABIs other than
32272the x86-64 psABI they select the same CPU features as the x86-64 psABI
32273documents for the particular micro-architecture level.
32274
32275Since these @var{cpu-type} values do not have a corresponding
32276@option{-mtune} setting, using @option{-march} with these values enables
32277generic tuning. Specific tuning can be enabled using the
32278@option{-mtune=@var{other-cpu-type}} option with an appropriate
32279@var{other-cpu-type} value.
32280
32281@item i386
32282Original Intel i386 CPU@.
32283
32284@item i486
32285Intel i486 CPU@. (No scheduling is implemented for this chip.)
32286
32287@item i586
32288@itemx pentium
32289Intel Pentium CPU with no MMX support.
32290
32291@item lakemont
32292Intel Lakemont MCU, based on Intel Pentium CPU.
32293
32294@item pentium-mmx
32295Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32296
32297@item pentiumpro
32298Intel Pentium Pro CPU@.
32299
32300@item i686
32301When used with @option{-march}, the Pentium Pro
32302instruction set is used, so the code runs on all i686 family chips.
32303When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32304
32305@item pentium2
32306Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32307set support.
32308
32309@item pentium3
32310@itemx pentium3m
32311Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32312instruction set support.
32313
32314@item pentium-m
32315Intel Pentium M; low-power version of Intel Pentium III CPU
32316with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32317notebooks.
32318
32319@item pentium4
32320@itemx pentium4m
32321Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32322
32323@item prescott
32324Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32325instruction set support.
32326
32327@item nocona
32328Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32329SSE2, SSE3 and FXSR instruction set support.
32330
32331@item core2
32332Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32333SAHF and FXSR instruction set support.
32334
32335@item nehalem
32336Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32337SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32338
32339@item westmere
32340Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32341SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32342
32343@item sandybridge
32344Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32345SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32346support.
32347
32348@item ivybridge
32349Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32350SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32351and F16C instruction set support.
32352
32353@item haswell
32354Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32355SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32356F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32357
32358@item broadwell
32359Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32360SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32361F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32362instruction set support.
32363
32364@item skylake
32365Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32366SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32367F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32368CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32369
32370@item bonnell
32371Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32372instruction set support.
32373
32374@item silvermont
32375Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32376SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32377instruction set support.
32378
32379@item goldmont
32380Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32381SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32382RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32383set support.
32384
32385@item goldmont-plus
32386Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32387SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32388SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32389RDPID and SGX instruction set support.
32390
32391@item tremont
32392Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32393SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32394RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32395SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32396support.
32397
32398@item sierraforest
32399Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32400SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32401XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32402MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32403PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32404AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32405
32406@item grandridge
32407Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32408SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32409XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32410MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32411PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32412AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set
32413support.
32414
32415@item knl
32416Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32417SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32418RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32419AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32420
32421@item knm
32422Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32423SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32424RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32425AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32426AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32427
32428@item skylake-avx512
32429Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32430SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32431RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32432AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32433AVX512DQ and AVX512CD instruction set support.
32434
32435@item cannonlake
32436Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32437SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32438FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32439PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32440AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32441support.
32442
32443@item icelake-client
32444Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32445SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32446RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32447AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32448AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32449, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32450
32451@item icelake-server
32452Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32453SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32454RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32455AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32456AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32457, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32458instruction set support.
32459
32460@item cascadelake
32461Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32462SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32463F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32464CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32465AVX512CD and AVX512VNNI instruction set support.
32466
32467@item cooperlake
32468Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32469SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32470F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32471CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32472AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32473
32474@item tigerlake
32475Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32476SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32477F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32478CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32479PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32480VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32481AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32482
32483@item sapphirerapids
32484Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32485SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32486RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32487AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32488AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32489VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32490MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
29ecb952 32491UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
d77de738
ML
32492instruction set support.
32493
32494@item alderlake
32495Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32496SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32497XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32498CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32499VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32500support.
32501
32502@item rocketlake
32503Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32504, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32505F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32506CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32507PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32508VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32509
32510@item graniterapids
32511Intel graniterapids 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, AVX512VL, AVX512BW, AVX512DQ,
32515AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32516VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32517MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
29ecb952 32518SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16,
d77de738
ML
32519AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
32520
32521@item k6
32522AMD K6 CPU with MMX instruction set support.
32523
32524@item k6-2
32525@itemx k6-3
32526Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
32527
32528@item athlon
32529@itemx athlon-tbird
32530AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
32531support.
32532
32533@item athlon-4
32534@itemx athlon-xp
32535@itemx athlon-mp
32536Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
32537instruction set support.
32538
32539@item k8
32540@itemx opteron
32541@itemx athlon64
32542@itemx athlon-fx
32543Processors based on the AMD K8 core with x86-64 instruction set support,
32544including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
32545(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
32546instruction set extensions.)
32547
32548@item k8-sse3
32549@itemx opteron-sse3
32550@itemx athlon64-sse3
32551Improved versions of AMD K8 cores with SSE3 instruction set support.
32552
32553@item amdfam10
32554@itemx barcelona
32555CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
32556supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
32557instruction set extensions.)
32558
32559@item bdver1
32560CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
32561supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
32562SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
32563
32564@item bdver2
32565AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32566supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
32567SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
32568extensions.)
32569
32570@item bdver3
32571AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32572supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
32573PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3257464-bit instruction set extensions.)
32575
32576@item bdver4
32577AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32578supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
32579AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
32580SSE4.2, ABM and 64-bit instruction set extensions.)
32581
32582@item znver1
32583AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32584supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
32585SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
32586SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
32587instruction set extensions.)
32588
32589@item znver2
32590AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32591supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32592MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32593SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32594WBNOINVD, and 64-bit instruction set extensions.)
32595
32596@item znver3
32597AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32598supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32599MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32600SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32601WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
32602
32603@item znver4
32604AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32605supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32606MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32607SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32608WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
32609AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
32610AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
32611
32612@item btver1
32613CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
32614supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
32615instruction set extensions.)
32616
32617@item btver2
32618CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
32619includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
32620SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
32621
32622@item winchip-c6
32623IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
32624set support.
32625
32626@item winchip2
32627IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
32628instruction set support.
32629
32630@item c3
32631VIA C3 CPU with MMX and 3DNow!@: instruction set support.
32632(No scheduling is implemented for this chip.)
32633
32634@item c3-2
32635VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
32636(No scheduling is implemented for this chip.)
32637
32638@item c7
32639VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32640(No scheduling is implemented for this chip.)
32641
32642@item samuel-2
32643VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
32644(No scheduling is implemented for this chip.)
32645
32646@item nehemiah
32647VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
32648(No scheduling is implemented for this chip.)
32649
32650@item esther
32651VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32652(No scheduling is implemented for this chip.)
32653
32654@item eden-x2
32655VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
32656(No scheduling is implemented for this chip.)
32657
32658@item eden-x4
32659VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
32660AVX and AVX2 instruction set support.
32661(No scheduling is implemented for this chip.)
32662
32663@item nano
32664Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32665instruction set support.
32666(No scheduling is implemented for this chip.)
32667
32668@item nano-1000
32669VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32670instruction set support.
32671(No scheduling is implemented for this chip.)
32672
32673@item nano-2000
32674VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32675instruction set support.
32676(No scheduling is implemented for this chip.)
32677
32678@item nano-3000
32679VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32680instruction set support.
32681(No scheduling is implemented for this chip.)
32682
32683@item nano-x2
32684VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32685instruction set support.
32686(No scheduling is implemented for this chip.)
32687
32688@item nano-x4
32689VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32690instruction set support.
32691(No scheduling is implemented for this chip.)
32692
32693@item lujiazui
32694ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
32695SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
32696ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
32697
32698@item geode
32699AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
32700@end table
32701
d77de738 32702@opindex mtune
ddf6fe37 32703@item -mtune=@var{cpu-type}
d77de738
ML
32704Tune to @var{cpu-type} everything applicable about the generated code, except
32705for the ABI and the set of available instructions.
32706While picking a specific @var{cpu-type} schedules things appropriately
32707for that particular chip, the compiler does not generate any code that
32708cannot run on the default machine type unless you use a
32709@option{-march=@var{cpu-type}} option.
32710For example, if GCC is configured for i686-pc-linux-gnu
32711then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
32712but still runs on i686 machines.
32713
32714The choices for @var{cpu-type} are the same as for @option{-march}.
32715In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
32716
32717@table @samp
32718@item generic
32719Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
32720If you know the CPU on which your code will run, then you should use
32721the corresponding @option{-mtune} or @option{-march} option instead of
32722@option{-mtune=generic}. But, if you do not know exactly what CPU users
32723of your application will have, then you should use this option.
32724
32725As new processors are deployed in the marketplace, the behavior of this
32726option will change. Therefore, if you upgrade to a newer version of
32727GCC, code generation controlled by this option will change to reflect
32728the processors
32729that are most common at the time that version of GCC is released.
32730
32731There is no @option{-march=generic} option because @option{-march}
32732indicates the instruction set the compiler can use, and there is no
32733generic instruction set applicable to all processors. In contrast,
32734@option{-mtune} indicates the processor (or, in this case, collection of
32735processors) for which the code is optimized.
32736
32737@item intel
32738Produce code optimized for the most current Intel processors, which are
32739Haswell and Silvermont for this version of GCC. If you know the CPU
32740on which your code will run, then you should use the corresponding
32741@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
32742But, if you want your application performs better on both Haswell and
32743Silvermont, then you should use this option.
32744
32745As new Intel processors are deployed in the marketplace, the behavior of
32746this option will change. Therefore, if you upgrade to a newer version of
32747GCC, code generation controlled by this option will change to reflect
32748the most current Intel processors at the time that version of GCC is
32749released.
32750
32751There is no @option{-march=intel} option because @option{-march} indicates
32752the instruction set the compiler can use, and there is no common
32753instruction set applicable to all processors. In contrast,
32754@option{-mtune} indicates the processor (or, in this case, collection of
32755processors) for which the code is optimized.
32756@end table
32757
d77de738 32758@opindex mcpu
ddf6fe37 32759@item -mcpu=@var{cpu-type}
d77de738
ML
32760A deprecated synonym for @option{-mtune}.
32761
d77de738 32762@opindex mfpmath
ddf6fe37 32763@item -mfpmath=@var{unit}
d77de738
ML
32764Generate floating-point arithmetic for selected unit @var{unit}. The choices
32765for @var{unit} are:
32766
32767@table @samp
32768@item 387
32769Use the standard 387 floating-point coprocessor present on the majority of chips and
32770emulated otherwise. Code compiled with this option runs almost everywhere.
32771The temporary results are computed in 80-bit precision instead of the precision
32772specified by the type, resulting in slightly different results compared to most
32773of other chips. See @option{-ffloat-store} for more detailed description.
32774
32775This is the default choice for non-Darwin x86-32 targets.
32776
32777@item sse
32778Use scalar floating-point instructions present in the SSE instruction set.
32779This instruction set is supported by Pentium III and newer chips,
32780and in the AMD line
32781by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
32782instruction set supports only single-precision arithmetic, thus the double and
32783extended-precision arithmetic are still done using 387. A later version, present
32784only in Pentium 4 and AMD x86-64 chips, supports double-precision
32785arithmetic too.
32786
32787For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
32788or @option{-msse2} switches to enable SSE extensions and make this option
32789effective. For the x86-64 compiler, these extensions are enabled by default.
32790
32791The resulting code should be considerably faster in the majority of cases and avoid
32792the numerical instability problems of 387 code, but may break some existing
32793code that expects temporaries to be 80 bits.
32794
32795This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
32796and the default choice for x86-32 targets with the SSE2 instruction set
32797when @option{-ffast-math} is enabled.
32798
32799@item sse,387
32800@itemx sse+387
32801@itemx both
32802Attempt to utilize both instruction sets at once. This effectively doubles the
32803amount of available registers, and on chips with separate execution units for
32804387 and SSE the execution resources too. Use this option with care, as it is
32805still experimental, because the GCC register allocator does not model separate
32806functional units well, resulting in unstable performance.
32807@end table
32808
d77de738 32809@opindex masm=@var{dialect}
ddf6fe37 32810@item -masm=@var{dialect}
d77de738
ML
32811Output assembly instructions using selected @var{dialect}. Also affects
32812which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
32813extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
32814order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
32815not support @samp{intel}.
32816
d77de738
ML
32817@opindex mieee-fp
32818@opindex mno-ieee-fp
ddf6fe37
AA
32819@item -mieee-fp
32820@itemx -mno-ieee-fp
d77de738
ML
32821Control whether or not the compiler uses IEEE floating-point
32822comparisons. These correctly handle the case where the result of a
32823comparison is unordered.
32824
30348d30 32825@opindex m80387
d77de738 32826@opindex mhard-float
ddf6fe37
AA
32827@item -m80387
32828@itemx -mhard-float
d77de738
ML
32829Generate output containing 80387 instructions for floating point.
32830
d77de738
ML
32831@opindex no-80387
32832@opindex msoft-float
ddf6fe37
AA
32833@item -mno-80387
32834@itemx -msoft-float
d77de738
ML
32835Generate output containing library calls for floating point.
32836
32837@strong{Warning:} the requisite libraries are not part of GCC@.
32838Normally the facilities of the machine's usual C compiler are used, but
32839this cannot be done directly in cross-compilation. You must make your
32840own arrangements to provide suitable library functions for
32841cross-compilation.
32842
32843On machines where a function returns floating-point results in the 80387
32844register stack, some floating-point opcodes may be emitted even if
32845@option{-msoft-float} is used.
32846
d77de738
ML
32847@opindex mno-fp-ret-in-387
32848@opindex mfp-ret-in-387
ddf6fe37 32849@item -mno-fp-ret-in-387
d77de738
ML
32850Do not use the FPU registers for return values of functions.
32851
32852The usual calling convention has functions return values of types
32853@code{float} and @code{double} in an FPU register, even if there
32854is no FPU@. The idea is that the operating system should emulate
32855an FPU@.
32856
32857The option @option{-mno-fp-ret-in-387} causes such values to be returned
32858in ordinary CPU registers instead.
32859
d77de738
ML
32860@opindex mno-fancy-math-387
32861@opindex mfancy-math-387
ddf6fe37 32862@item -mno-fancy-math-387
d77de738
ML
32863Some 387 emulators do not support the @code{sin}, @code{cos} and
32864@code{sqrt} instructions for the 387. Specify this option to avoid
32865generating those instructions.
32866This option is overridden when @option{-march}
32867indicates that the target CPU always has an FPU and so the
32868instruction does not need emulation. These
32869instructions are not generated unless you also use the
32870@option{-funsafe-math-optimizations} switch.
32871
d77de738
ML
32872@opindex malign-double
32873@opindex mno-align-double
ddf6fe37
AA
32874@item -malign-double
32875@itemx -mno-align-double
d77de738
ML
32876Control whether GCC aligns @code{double}, @code{long double}, and
32877@code{long long} variables on a two-word boundary or a one-word
32878boundary. Aligning @code{double} variables on a two-word boundary
32879produces code that runs somewhat faster on a Pentium at the
32880expense of more memory.
32881
32882On x86-64, @option{-malign-double} is enabled by default.
32883
32884@strong{Warning:} if you use the @option{-malign-double} switch,
32885structures containing the above types are aligned differently than
32886the published application binary interface specifications for the x86-32
32887and are not binary compatible with structures in code compiled
32888without that switch.
32889
d77de738
ML
32890@opindex m96bit-long-double
32891@opindex m128bit-long-double
ddf6fe37
AA
32892@item -m96bit-long-double
32893@itemx -m128bit-long-double
d77de738
ML
32894These switches control the size of @code{long double} type. The x86-32
32895application binary interface specifies the size to be 96 bits,
32896so @option{-m96bit-long-double} is the default in 32-bit mode.
32897
32898Modern architectures (Pentium and newer) prefer @code{long double}
32899to be aligned to an 8- or 16-byte boundary. In arrays or structures
32900conforming to the ABI, this is not possible. So specifying
32901@option{-m128bit-long-double} aligns @code{long double}
32902to a 16-byte boundary by padding the @code{long double} with an additional
3290332-bit zero.
32904
32905In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
32906its ABI specifies that @code{long double} is aligned on 16-byte boundary.
32907
32908Notice that neither of these options enable any extra precision over the x87
32909standard of 80 bits for a @code{long double}.
32910
32911@strong{Warning:} if you override the default value for your target ABI, this
32912changes the size of
32913structures and arrays containing @code{long double} variables,
32914as well as modifying the function calling convention for functions taking
32915@code{long double}. Hence they are not binary-compatible
32916with code compiled without that switch.
32917
d77de738
ML
32918@opindex mlong-double-64
32919@opindex mlong-double-80
32920@opindex mlong-double-128
ddf6fe37
AA
32921@item -mlong-double-64
32922@itemx -mlong-double-80
32923@itemx -mlong-double-128
d77de738
ML
32924These switches control the size of @code{long double} type. A size
32925of 64 bits makes the @code{long double} type equivalent to the @code{double}
32926type. This is the default for 32-bit Bionic C library. A size
32927of 128 bits makes the @code{long double} type equivalent to the
32928@code{__float128} type. This is the default for 64-bit Bionic C library.
32929
32930@strong{Warning:} if you override the default value for your target ABI, this
32931changes the size of
32932structures and arrays containing @code{long double} variables,
32933as well as modifying the function calling convention for functions taking
32934@code{long double}. Hence they are not binary-compatible
32935with code compiled without that switch.
32936
d77de738 32937@opindex malign-data
ddf6fe37 32938@item -malign-data=@var{type}
d77de738
ML
32939Control how GCC aligns variables. Supported values for @var{type} are
32940@samp{compat} uses increased alignment value compatible uses GCC 4.8
32941and earlier, @samp{abi} uses alignment value as specified by the
32942psABI, and @samp{cacheline} uses increased alignment value to match
32943the cache line size. @samp{compat} is the default.
32944
d77de738 32945@opindex mlarge-data-threshold
ddf6fe37 32946@item -mlarge-data-threshold=@var{threshold}
d77de738
ML
32947When @option{-mcmodel=medium} is specified, data objects larger than
32948@var{threshold} are placed in the large data section. This value must be the
32949same across all objects linked into the binary, and defaults to 65535.
32950
d77de738 32951@opindex mrtd
ddf6fe37 32952@item -mrtd
d77de738
ML
32953Use a different function-calling convention, in which functions that
32954take a fixed number of arguments return with the @code{ret @var{num}}
32955instruction, which pops their arguments while returning. This saves one
32956instruction in the caller since there is no need to pop the arguments
32957there.
32958
32959You can specify that an individual function is called with this calling
32960sequence with the function attribute @code{stdcall}. You can also
32961override the @option{-mrtd} option by using the function attribute
32962@code{cdecl}. @xref{Function Attributes}.
32963
32964@strong{Warning:} this calling convention is incompatible with the one
32965normally used on Unix, so you cannot use it if you need to call
32966libraries compiled with the Unix compiler.
32967
32968Also, you must provide function prototypes for all functions that
32969take variable numbers of arguments (including @code{printf});
32970otherwise incorrect code is generated for calls to those
32971functions.
32972
32973In addition, seriously incorrect code results if you call a
32974function with too many arguments. (Normally, extra arguments are
32975harmlessly ignored.)
32976
d77de738 32977@opindex mregparm
ddf6fe37 32978@item -mregparm=@var{num}
d77de738
ML
32979Control how many registers are used to pass integer arguments. By
32980default, no registers are used to pass arguments, and at most 3
32981registers can be used. You can control this behavior for a specific
32982function by using the function attribute @code{regparm}.
32983@xref{Function Attributes}.
32984
32985@strong{Warning:} if you use this switch, and
32986@var{num} is nonzero, then you must build all modules with the same
32987value, including any libraries. This includes the system libraries and
32988startup modules.
32989
d77de738 32990@opindex msseregparm
ddf6fe37 32991@item -msseregparm
d77de738
ML
32992Use SSE register passing conventions for float and double arguments
32993and return values. You can control this behavior for a specific
32994function by using the function attribute @code{sseregparm}.
32995@xref{Function Attributes}.
32996
32997@strong{Warning:} if you use this switch then you must build all
32998modules with the same value, including any libraries. This includes
32999the system libraries and startup modules.
33000
d77de738 33001@opindex mvect8-ret-in-mem
ddf6fe37 33002@item -mvect8-ret-in-mem
d77de738
ML
33003Return 8-byte vectors in memory instead of MMX registers. This is the
33004default on VxWorks to match the ABI of the Sun Studio compilers until
33005version 12. @emph{Only} use this option if you need to remain
33006compatible with existing code produced by those previous compiler
33007versions or older versions of GCC@.
33008
d77de738
ML
33009@opindex mpc32
33010@opindex mpc64
33011@opindex mpc80
ddf6fe37
AA
33012@item -mpc32
33013@itemx -mpc64
33014@itemx -mpc80
d77de738
ML
33015
33016Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
33017is specified, the significands of results of floating-point operations are
33018rounded to 24 bits (single precision); @option{-mpc64} rounds the
33019significands of results of floating-point operations to 53 bits (double
33020precision) and @option{-mpc80} rounds the significands of results of
33021floating-point operations to 64 bits (extended double precision), which is
33022the default. When this option is used, floating-point operations in higher
33023precisions are not available to the programmer without setting the FPU
33024control word explicitly.
33025
33026Setting the rounding of floating-point operations to less than the default
3302780 bits can speed some programs by 2% or more. Note that some mathematical
33028libraries assume that extended-precision (80-bit) floating-point operations
33029are enabled by default; routines in such libraries could suffer significant
33030loss of accuracy, typically through so-called ``catastrophic cancellation'',
33031when this option is used to set the precision to less than extended precision.
33032
e54375d8 33033@opindex mdaz-ftz
ddf6fe37 33034@item -mdaz-ftz
e54375d8 33035
33036The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
33037are used to control floating-point calculations.SSE and AVX instructions
33038including scalar and vector instructions could benefit from enabling the FTZ
33039and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
33040when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
33041will set FTZ/DAZ flags even with @option{-shared}.
33042
d77de738 33043@opindex mstackrealign
ddf6fe37 33044@item -mstackrealign
d77de738
ML
33045Realign the stack at entry. On the x86, the @option{-mstackrealign}
33046option generates an alternate prologue and epilogue that realigns the
33047run-time stack if necessary. This supports mixing legacy codes that keep
330484-byte stack alignment with modern codes that keep 16-byte stack alignment for
33049SSE compatibility. See also the attribute @code{force_align_arg_pointer},
33050applicable to individual functions.
33051
d77de738 33052@opindex mpreferred-stack-boundary
ddf6fe37 33053@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
33054Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
33055byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
33056the default is 4 (16 bytes or 128 bits).
33057
33058@strong{Warning:} When generating code for the x86-64 architecture with
33059SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
33060used to keep the stack boundary aligned to 8 byte boundary. Since
33061x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
33062intended to be used in controlled environment where stack space is
33063important limitation. This option leads to wrong code when functions
33064compiled with 16 byte stack alignment (such as functions from a standard
33065library) are called with misaligned stack. In this case, SSE
33066instructions may lead to misaligned memory access traps. In addition,
33067variable arguments are handled incorrectly for 16 byte aligned
33068objects (including x87 long double and __int128), leading to wrong
33069results. You must build all modules with
33070@option{-mpreferred-stack-boundary=3}, including any libraries. This
33071includes the system libraries and startup modules.
33072
d77de738 33073@opindex mincoming-stack-boundary
ddf6fe37 33074@item -mincoming-stack-boundary=@var{num}
d77de738
ML
33075Assume the incoming stack is aligned to a 2 raised to @var{num} byte
33076boundary. If @option{-mincoming-stack-boundary} is not specified,
33077the one specified by @option{-mpreferred-stack-boundary} is used.
33078
33079On Pentium and Pentium Pro, @code{double} and @code{long double} values
33080should be aligned to an 8-byte boundary (see @option{-malign-double}) or
33081suffer significant run time performance penalties. On Pentium III, the
33082Streaming SIMD Extension (SSE) data type @code{__m128} may not work
33083properly if it is not 16-byte aligned.
33084
33085To ensure proper alignment of this values on the stack, the stack boundary
33086must be as aligned as that required by any value stored on the stack.
33087Further, every function must be generated such that it keeps the stack
33088aligned. Thus calling a function compiled with a higher preferred
33089stack boundary from a function compiled with a lower preferred stack
33090boundary most likely misaligns the stack. It is recommended that
33091libraries that use callbacks always use the default setting.
33092
33093This extra alignment does consume extra stack space, and generally
33094increases code size. Code that is sensitive to stack space usage, such
33095as embedded systems and operating system kernels, may want to reduce the
33096preferred alignment to @option{-mpreferred-stack-boundary=2}.
33097
33098@need 200
d77de738 33099@opindex mmmx
ddf6fe37 33100@item -mmmx
d77de738 33101@need 200
d77de738 33102@opindex msse
ddf6fe37 33103@itemx -msse
d77de738 33104@need 200
d77de738 33105@opindex msse2
ddf6fe37 33106@itemx -msse2
d77de738 33107@need 200
d77de738 33108@opindex msse3
ddf6fe37 33109@itemx -msse3
d77de738 33110@need 200
d77de738 33111@opindex mssse3
ddf6fe37 33112@itemx -mssse3
d77de738 33113@need 200
d77de738 33114@opindex msse4
ddf6fe37 33115@itemx -msse4
d77de738 33116@need 200
d77de738 33117@opindex msse4a
ddf6fe37 33118@itemx -msse4a
d77de738 33119@need 200
d77de738 33120@opindex msse4.1
ddf6fe37 33121@itemx -msse4.1
d77de738 33122@need 200
d77de738 33123@opindex msse4.2
ddf6fe37 33124@itemx -msse4.2
d77de738 33125@need 200
d77de738 33126@opindex mavx
ddf6fe37 33127@itemx -mavx
d77de738 33128@need 200
d77de738 33129@opindex mavx2
ddf6fe37 33130@itemx -mavx2
d77de738 33131@need 200
d77de738 33132@opindex mavx512f
ddf6fe37 33133@itemx -mavx512f
d77de738 33134@need 200
d77de738 33135@opindex mavx512pf
ddf6fe37 33136@itemx -mavx512pf
d77de738 33137@need 200
d77de738 33138@opindex mavx512er
ddf6fe37 33139@itemx -mavx512er
d77de738 33140@need 200
d77de738 33141@opindex mavx512cd
ddf6fe37 33142@itemx -mavx512cd
d77de738 33143@need 200
d77de738 33144@opindex mavx512vl
ddf6fe37 33145@itemx -mavx512vl
d77de738 33146@need 200
d77de738 33147@opindex mavx512bw
ddf6fe37 33148@itemx -mavx512bw
d77de738 33149@need 200
d77de738 33150@opindex mavx512dq
ddf6fe37 33151@itemx -mavx512dq
d77de738 33152@need 200
d77de738 33153@opindex mavx512ifma
ddf6fe37 33154@itemx -mavx512ifma
d77de738 33155@need 200
d77de738 33156@opindex mavx512vbmi
ddf6fe37 33157@itemx -mavx512vbmi
d77de738 33158@need 200
d77de738 33159@opindex msha
ddf6fe37 33160@itemx -msha
d77de738 33161@need 200
d77de738 33162@opindex maes
ddf6fe37 33163@itemx -maes
d77de738 33164@need 200
d77de738 33165@opindex mpclmul
ddf6fe37 33166@itemx -mpclmul
d77de738 33167@need 200
d77de738 33168@opindex mclflushopt
ddf6fe37 33169@itemx -mclflushopt
d77de738 33170@need 200
d77de738 33171@opindex mclwb
ddf6fe37 33172@itemx -mclwb
d77de738 33173@need 200
d77de738 33174@opindex mfsgsbase
ddf6fe37 33175@itemx -mfsgsbase
d77de738 33176@need 200
d77de738 33177@opindex mptwrite
ddf6fe37 33178@itemx -mptwrite
d77de738 33179@need 200
d77de738 33180@opindex mrdrnd
ddf6fe37 33181@itemx -mrdrnd
d77de738 33182@need 200
d77de738 33183@opindex mf16c
ddf6fe37 33184@itemx -mf16c
d77de738 33185@need 200
d77de738 33186@opindex mfma
ddf6fe37 33187@itemx -mfma
d77de738 33188@need 200
d77de738 33189@opindex mpconfig
ddf6fe37 33190@itemx -mpconfig
d77de738 33191@need 200
d77de738 33192@opindex mwbnoinvd
ddf6fe37 33193@itemx -mwbnoinvd
d77de738 33194@need 200
d77de738 33195@opindex mfma4
ddf6fe37 33196@itemx -mfma4
d77de738 33197@need 200
d77de738 33198@opindex mprfchw
ddf6fe37 33199@itemx -mprfchw
d77de738 33200@need 200
d77de738 33201@opindex mrdpid
ddf6fe37 33202@itemx -mrdpid
d77de738 33203@need 200
d77de738 33204@opindex mprefetchwt1
ddf6fe37 33205@itemx -mprefetchwt1
d77de738 33206@need 200
d77de738 33207@opindex mrdseed
ddf6fe37 33208@itemx -mrdseed
d77de738 33209@need 200
d77de738 33210@opindex msgx
ddf6fe37 33211@itemx -msgx
d77de738 33212@need 200
d77de738 33213@opindex mxop
ddf6fe37 33214@itemx -mxop
d77de738 33215@need 200
d77de738 33216@opindex mlwp
ddf6fe37 33217@itemx -mlwp
d77de738 33218@need 200
d77de738 33219@opindex m3dnow
ddf6fe37 33220@itemx -m3dnow
d77de738 33221@need 200
d77de738 33222@opindex m3dnowa
ddf6fe37 33223@itemx -m3dnowa
d77de738 33224@need 200
d77de738 33225@opindex mpopcnt
ddf6fe37 33226@itemx -mpopcnt
d77de738 33227@need 200
d77de738 33228@opindex mabm
ddf6fe37 33229@itemx -mabm
d77de738 33230@need 200
d77de738 33231@opindex madx
ddf6fe37 33232@itemx -madx
d77de738 33233@need 200
d77de738 33234@opindex mbmi
ddf6fe37 33235@itemx -mbmi
d77de738 33236@need 200
d77de738 33237@opindex mbmi2
ddf6fe37 33238@itemx -mbmi2
d77de738 33239@need 200
d77de738 33240@opindex mlzcnt
ddf6fe37 33241@itemx -mlzcnt
d77de738 33242@need 200
d77de738 33243@opindex mfxsr
ddf6fe37 33244@itemx -mfxsr
d77de738 33245@need 200
d77de738 33246@opindex mxsave
ddf6fe37 33247@itemx -mxsave
d77de738 33248@need 200
d77de738 33249@opindex mxsaveopt
ddf6fe37 33250@itemx -mxsaveopt
d77de738 33251@need 200
d77de738 33252@opindex mxsavec
ddf6fe37 33253@itemx -mxsavec
d77de738 33254@need 200
d77de738 33255@opindex mxsaves
ddf6fe37 33256@itemx -mxsaves
d77de738 33257@need 200
d77de738 33258@opindex mrtm
ddf6fe37 33259@itemx -mrtm
d77de738 33260@need 200
d77de738 33261@opindex mhle
ddf6fe37 33262@itemx -mhle
d77de738 33263@need 200
d77de738 33264@opindex mtbm
ddf6fe37 33265@itemx -mtbm
d77de738 33266@need 200
d77de738 33267@opindex mmwaitx
ddf6fe37 33268@itemx -mmwaitx
d77de738 33269@need 200
d77de738 33270@opindex mclzero
ddf6fe37 33271@itemx -mclzero
d77de738 33272@need 200
d77de738 33273@opindex mpku
ddf6fe37 33274@itemx -mpku
d77de738 33275@need 200
d77de738 33276@opindex mavx512vbmi2
ddf6fe37 33277@itemx -mavx512vbmi2
d77de738 33278@need 200
d77de738 33279@opindex mavx512bf16
ddf6fe37 33280@itemx -mavx512bf16
d77de738 33281@need 200
d77de738 33282@opindex mavx512fp16
ddf6fe37 33283@itemx -mavx512fp16
d77de738 33284@need 200
d77de738 33285@opindex mgfni
ddf6fe37 33286@itemx -mgfni
d77de738 33287@need 200
d77de738 33288@opindex mvaes
ddf6fe37 33289@itemx -mvaes
d77de738 33290@need 200
d77de738 33291@opindex mwaitpkg
ddf6fe37 33292@itemx -mwaitpkg
d77de738 33293@need 200
d77de738 33294@opindex mvpclmulqdq
ddf6fe37 33295@itemx -mvpclmulqdq
d77de738 33296@need 200
d77de738 33297@opindex mavx512bitalg
ddf6fe37 33298@itemx -mavx512bitalg
d77de738 33299@need 200
d77de738 33300@opindex mmovdiri
ddf6fe37 33301@itemx -mmovdiri
d77de738 33302@need 200
d77de738 33303@opindex mmovdir64b
ddf6fe37 33304@itemx -mmovdir64b
d77de738 33305@need 200
d77de738 33306@opindex menqcmd
d77de738 33307@opindex muintr
ddf6fe37
AA
33308@itemx -menqcmd
33309@itemx -muintr
d77de738 33310@need 200
d77de738 33311@opindex mtsxldtrk
ddf6fe37 33312@itemx -mtsxldtrk
d77de738 33313@need 200
d77de738 33314@opindex mavx512vpopcntdq
ddf6fe37 33315@itemx -mavx512vpopcntdq
d77de738 33316@need 200
d77de738 33317@opindex mavx512vp2intersect
ddf6fe37 33318@itemx -mavx512vp2intersect
d77de738 33319@need 200
d77de738 33320@opindex mavx5124fmaps
ddf6fe37 33321@itemx -mavx5124fmaps
d77de738 33322@need 200
d77de738 33323@opindex mavx512vnni
ddf6fe37 33324@itemx -mavx512vnni
d77de738 33325@need 200
d77de738 33326@opindex mavxvnni
ddf6fe37 33327@itemx -mavxvnni
d77de738 33328@need 200
d77de738 33329@opindex mavx5124vnniw
ddf6fe37 33330@itemx -mavx5124vnniw
d77de738 33331@need 200
d77de738 33332@opindex mcldemote
ddf6fe37 33333@itemx -mcldemote
d77de738 33334@need 200
d77de738 33335@opindex mserialize
ddf6fe37 33336@itemx -mserialize
d77de738 33337@need 200
d77de738 33338@opindex mamx-tile
ddf6fe37 33339@itemx -mamx-tile
d77de738 33340@need 200
d77de738 33341@opindex mamx-int8
ddf6fe37 33342@itemx -mamx-int8
d77de738 33343@need 200
d77de738 33344@opindex mamx-bf16
ddf6fe37 33345@itemx -mamx-bf16
d77de738 33346@need 200
d77de738 33347@opindex mhreset
d77de738 33348@opindex mkl
ddf6fe37
AA
33349@itemx -mhreset
33350@itemx -mkl
d77de738 33351@need 200
d77de738 33352@opindex mwidekl
ddf6fe37 33353@itemx -mwidekl
d77de738 33354@need 200
d77de738 33355@opindex mavxifma
ddf6fe37 33356@itemx -mavxifma
d77de738 33357@need 200
d77de738 33358@opindex mavxvnniint8
ddf6fe37 33359@itemx -mavxvnniint8
d77de738 33360@need 200
d77de738 33361@opindex mavxneconvert
ddf6fe37 33362@itemx -mavxneconvert
d77de738 33363@need 200
d77de738 33364@opindex mcmpccxadd
ddf6fe37 33365@itemx -mcmpccxadd
d77de738 33366@need 200
d77de738 33367@opindex mamx-fp16
ddf6fe37 33368@itemx -mamx-fp16
d77de738 33369@need 200
d77de738 33370@opindex mprefetchi
ddf6fe37 33371@itemx -mprefetchi
d77de738 33372@need 200
d77de738 33373@opindex mraoint
ddf6fe37 33374@itemx -mraoint
efa6a82b
HJ
33375@need 200
33376@opindex mamx-complex
33377@itemx -mamx-complex
d77de738
ML
33378These switches enable the use of instructions in the MMX, SSE,
33379SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
33380AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33381AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33382WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
333833DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33384XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33385GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33386ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
29ecb952 33387UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
efa6a82b
HJ
33388AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT,
33389AMX-COMPLEX or CLDEMOTE extended instruction sets. Each has a corresponding
33390@option{-mno-} option to disable use of these instructions.
d77de738
ML
33391
33392These extensions are also available as built-in functions: see
33393@ref{x86 Built-in Functions}, for details of the functions enabled and
33394disabled by these switches.
33395
33396To generate SSE/SSE2 instructions automatically from floating-point
33397code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33398
33399GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33400generates new AVX instructions or AVX equivalence for all SSEx instructions
33401when needed.
33402
33403These options enable GCC to use these extended instructions in
33404generated code, even without @option{-mfpmath=sse}. Applications that
33405perform run-time CPU detection must compile separate files for each
33406supported architecture, using the appropriate flags. In particular,
33407the file containing the CPU detection code should be compiled without
33408these options.
33409
d77de738 33410@opindex mdump-tune-features
ddf6fe37 33411@item -mdump-tune-features
d77de738
ML
33412This option instructs GCC to dump the names of the x86 performance
33413tuning features and default settings. The names can be used in
33414@option{-mtune-ctrl=@var{feature-list}}.
33415
d77de738 33416@opindex mtune-ctrl=@var{feature-list}
ddf6fe37 33417@item -mtune-ctrl=@var{feature-list}
d77de738
ML
33418This option is used to do fine grain control of x86 code generation features.
33419@var{feature-list} is a comma separated list of @var{feature} names. See also
33420@option{-mdump-tune-features}. When specified, the @var{feature} is turned
33421on if it is not preceded with @samp{^}, otherwise, it is turned off.
33422@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33423developers. Using it may lead to code paths not covered by testing and can
33424potentially result in compiler ICEs or runtime errors.
33425
d77de738 33426@opindex mno-default
ddf6fe37 33427@item -mno-default
d77de738
ML
33428This option instructs GCC to turn off all tunable features. See also
33429@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33430
d77de738 33431@opindex mcld
ddf6fe37 33432@item -mcld
d77de738
ML
33433This option instructs GCC to emit a @code{cld} instruction in the prologue
33434of functions that use string instructions. String instructions depend on
33435the DF flag to select between autoincrement or autodecrement mode. While the
33436ABI specifies the DF flag to be cleared on function entry, some operating
33437systems violate this specification by not clearing the DF flag in their
33438exception dispatchers. The exception handler can be invoked with the DF flag
33439set, which leads to wrong direction mode when string instructions are used.
33440This option can be enabled by default on 32-bit x86 targets by configuring
33441GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33442instructions can be suppressed with the @option{-mno-cld} compiler option
33443in this case.
33444
d77de738 33445@opindex mvzeroupper
ddf6fe37 33446@item -mvzeroupper
d77de738
ML
33447This option instructs GCC to emit a @code{vzeroupper} instruction
33448before a transfer of control flow out of the function to minimize
33449the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33450intrinsics.
33451
d77de738 33452@opindex mprefer-avx128
ddf6fe37 33453@item -mprefer-avx128
d77de738
ML
33454This option instructs GCC to use 128-bit AVX instructions instead of
33455256-bit AVX instructions in the auto-vectorizer.
33456
d77de738 33457@opindex mprefer-vector-width
ddf6fe37 33458@item -mprefer-vector-width=@var{opt}
d77de738
ML
33459This option instructs GCC to use @var{opt}-bit vector width in instructions
33460instead of default on the selected platform.
33461
d77de738 33462@opindex mmove-max
ddf6fe37 33463@item -mmove-max=@var{bits}
d77de738
ML
33464This option instructs GCC to set the maximum number of bits can be
33465moved from memory to memory efficiently to @var{bits}. The valid
33466@var{bits} are 128, 256 and 512.
33467
d77de738 33468@opindex mstore-max
ddf6fe37 33469@item -mstore-max=@var{bits}
d77de738
ML
33470This option instructs GCC to set the maximum number of bits can be
33471stored to memory efficiently to @var{bits}. The valid @var{bits} are
33472128, 256 and 512.
33473
33474@table @samp
33475@item none
33476No extra limitations applied to GCC other than defined by the selected platform.
33477
33478@item 128
33479Prefer 128-bit vector width for instructions.
33480
33481@item 256
33482Prefer 256-bit vector width for instructions.
33483
33484@item 512
33485Prefer 512-bit vector width for instructions.
33486@end table
33487
d77de738 33488@opindex mcx16
ddf6fe37 33489@item -mcx16
d77de738
ML
33490This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
33491code to implement compare-and-exchange operations on 16-byte aligned 128-bit
33492objects. This is useful for atomic updates of data structures exceeding one
33493machine word in size. The compiler uses this instruction to implement
33494@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
33495128-bit integers, a library call is always used.
33496
d77de738 33497@opindex msahf
ddf6fe37 33498@item -msahf
d77de738
ML
33499This option enables generation of @code{SAHF} instructions in 64-bit code.
33500Early Intel Pentium 4 CPUs with Intel 64 support,
33501prior to the introduction of Pentium 4 G1 step in December 2005,
33502lacked the @code{LAHF} and @code{SAHF} instructions
33503which are supported by AMD64.
33504These are load and store instructions, respectively, for certain status flags.
33505In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
33506@code{drem}, and @code{remainder} built-in functions;
33507see @ref{Other Builtins} for details.
33508
d77de738 33509@opindex mmovbe
ddf6fe37 33510@item -mmovbe
d77de738
ML
33511This option enables use of the @code{movbe} instruction to implement
33512@code{__builtin_bswap32} and @code{__builtin_bswap64}.
33513
d77de738 33514@opindex mshstk
ddf6fe37 33515@item -mshstk
d77de738
ML
33516The @option{-mshstk} option enables shadow stack built-in functions
33517from x86 Control-flow Enforcement Technology (CET).
33518
d77de738 33519@opindex mcrc32
ddf6fe37 33520@item -mcrc32
d77de738
ML
33521This option enables built-in functions @code{__builtin_ia32_crc32qi},
33522@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
33523@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
33524
d77de738 33525@opindex mmwait
ddf6fe37 33526@item -mmwait
d77de738
ML
33527This option enables built-in functions @code{__builtin_ia32_monitor},
33528and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
33529@code{mwait} machine instructions.
33530
d77de738 33531@opindex mrecip
ddf6fe37 33532@item -mrecip
d77de738
ML
33533This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
33534(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
33535with an additional Newton-Raphson step
33536to increase precision instead of @code{DIVSS} and @code{SQRTSS}
33537(and their vectorized
33538variants) for single-precision floating-point arguments. These instructions
33539are generated only when @option{-funsafe-math-optimizations} is enabled
33540together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
33541Note that while the throughput of the sequence is higher than the throughput
33542of the non-reciprocal instruction, the precision of the sequence can be
33543decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
33544
33545Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
33546(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
33547combination), and doesn't need @option{-mrecip}.
33548
33549Also note that GCC emits the above sequence with additional Newton-Raphson step
33550for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
33551already with @option{-ffast-math} (or the above option combination), and
33552doesn't need @option{-mrecip}.
33553
d77de738 33554@opindex mrecip=opt
ddf6fe37 33555@item -mrecip=@var{opt}
d77de738
ML
33556This option controls which reciprocal estimate instructions
33557may be used. @var{opt} is a comma-separated list of options, which may
33558be preceded by a @samp{!} to invert the option:
33559
33560@table @samp
33561@item all
33562Enable all estimate instructions.
33563
33564@item default
33565Enable the default instructions, equivalent to @option{-mrecip}.
33566
33567@item none
33568Disable all estimate instructions, equivalent to @option{-mno-recip}.
33569
33570@item div
33571Enable the approximation for scalar division.
33572
33573@item vec-div
33574Enable the approximation for vectorized division.
33575
33576@item sqrt
33577Enable the approximation for scalar square root.
33578
33579@item vec-sqrt
33580Enable the approximation for vectorized square root.
33581@end table
33582
33583So, for example, @option{-mrecip=all,!sqrt} enables
33584all of the reciprocal approximations, except for square root.
33585
d77de738 33586@opindex mveclibabi
ddf6fe37 33587@item -mveclibabi=@var{type}
d77de738
ML
33588Specifies the ABI type to use for vectorizing intrinsics using an
33589external library. Supported values for @var{type} are @samp{svml}
33590for the Intel short
33591vector math library and @samp{acml} for the AMD math core library.
33592To use this option, both @option{-ftree-vectorize} and
33593@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
33594ABI-compatible library must be specified at link time.
33595
33596GCC currently emits calls to @code{vmldExp2},
33597@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
33598@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
33599@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
33600@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
33601@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
33602@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
33603@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
33604@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
33605@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
33606function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
33607@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
33608@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
33609@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
33610@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
33611when @option{-mveclibabi=acml} is used.
33612
d77de738 33613@opindex mabi
ddf6fe37 33614@item -mabi=@var{name}
d77de738
ML
33615Generate code for the specified calling convention. Permissible values
33616are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
33617@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
33618ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
33619You can control this behavior for specific functions by
33620using the function attributes @code{ms_abi} and @code{sysv_abi}.
33621@xref{Function Attributes}.
33622
d77de738 33623@opindex mforce-indirect-call
ddf6fe37 33624@item -mforce-indirect-call
d77de738
ML
33625Force all calls to functions to be indirect. This is useful
33626when using Intel Processor Trace where it generates more precise timing
33627information for function calls.
33628
d77de738 33629@opindex mmanual-endbr
ddf6fe37 33630@item -mmanual-endbr
d77de738
ML
33631Insert ENDBR instruction at function entry only via the @code{cf_check}
33632function attribute. This is useful when used with the option
33633@option{-fcf-protection=branch} to control ENDBR insertion at the
33634function entry.
33635
d77de738 33636@opindex mcet-switch
ddf6fe37 33637@item -mcet-switch
d77de738
ML
33638By default, CET instrumentation is turned off on switch statements that
33639use a jump table and indirect branch track is disabled. Since jump
33640tables are stored in read-only memory, this does not result in a direct
33641loss of hardening. But if the jump table index is attacker-controlled,
33642the indirect jump may not be constrained by CET. This option turns on
33643CET instrumentation to enable indirect branch track for switch statements
33644with jump tables which leads to the jump targets reachable via any indirect
33645jumps.
33646
d77de738
ML
33647@opindex mcall-ms2sysv-xlogues
33648@opindex mno-call-ms2sysv-xlogues
ddf6fe37 33649@item -mcall-ms2sysv-xlogues
d77de738
ML
33650Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
33651System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
33652default, the code for saving and restoring these registers is emitted inline,
33653resulting in fairly lengthy prologues and epilogues. Using
33654@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
33655use stubs in the static portion of libgcc to perform these saves and restores,
33656thus reducing function size at the cost of a few extra instructions.
33657
d77de738 33658@opindex mtls-dialect
ddf6fe37 33659@item -mtls-dialect=@var{type}
d77de738
ML
33660Generate code to access thread-local storage using the @samp{gnu} or
33661@samp{gnu2} conventions. @samp{gnu} is the conservative default;
33662@samp{gnu2} is more efficient, but it may add compile- and run-time
33663requirements that cannot be satisfied on all systems.
33664
d77de738
ML
33665@opindex mpush-args
33666@opindex mno-push-args
ddf6fe37
AA
33667@item -mpush-args
33668@itemx -mno-push-args
d77de738
ML
33669Use PUSH operations to store outgoing parameters. This method is shorter
33670and usually equally fast as method using SUB/MOV operations and is enabled
33671by default. In some cases disabling it may improve performance because of
33672improved scheduling and reduced dependencies.
33673
d77de738 33674@opindex maccumulate-outgoing-args
ddf6fe37 33675@item -maccumulate-outgoing-args
d77de738
ML
33676If enabled, the maximum amount of space required for outgoing arguments is
33677computed in the function prologue. This is faster on most modern CPUs
33678because of reduced dependencies, improved scheduling and reduced stack usage
33679when the preferred stack boundary is not equal to 2. The drawback is a notable
33680increase in code size. This switch implies @option{-mno-push-args}.
33681
d77de738 33682@opindex mthreads
ddf6fe37 33683@item -mthreads
d77de738
ML
33684Support thread-safe exception handling on MinGW. Programs that rely
33685on thread-safe exception handling must compile and link all code with the
33686@option{-mthreads} option. When compiling, @option{-mthreads} defines
33687@option{-D_MT}; when linking, it links in a special thread helper library
33688@option{-lmingwthrd} which cleans up per-thread exception-handling data.
33689
d77de738
ML
33690@opindex mms-bitfields
33691@opindex mno-ms-bitfields
ddf6fe37
AA
33692@item -mms-bitfields
33693@itemx -mno-ms-bitfields
d77de738
ML
33694
33695Enable/disable bit-field layout compatible with the native Microsoft
33696Windows compiler.
33697
33698If @code{packed} is used on a structure, or if bit-fields are used,
33699it may be that the Microsoft ABI lays out the structure differently
33700than the way GCC normally does. Particularly when moving packed
33701data between functions compiled with GCC and the native Microsoft compiler
33702(either via function call or as data in a file), it may be necessary to access
33703either format.
33704
33705This option is enabled by default for Microsoft Windows
33706targets. This behavior can also be controlled locally by use of variable
33707or type attributes. For more information, see @ref{x86 Variable Attributes}
33708and @ref{x86 Type Attributes}.
33709
33710The Microsoft structure layout algorithm is fairly simple with the exception
33711of the bit-field packing.
33712The padding and alignment of members of structures and whether a bit-field
33713can straddle a storage-unit boundary are determine by these rules:
33714
33715@enumerate
33716@item Structure members are stored sequentially in the order in which they are
33717declared: the first member has the lowest memory address and the last member
33718the highest.
33719
33720@item Every data object has an alignment requirement. The alignment requirement
33721for all data except structures, unions, and arrays is either the size of the
33722object or the current packing size (specified with either the
33723@code{aligned} attribute or the @code{pack} pragma),
33724whichever is less. For structures, unions, and arrays,
33725the alignment requirement is the largest alignment requirement of its members.
33726Every object is allocated an offset so that:
33727
33728@smallexample
33729offset % alignment_requirement == 0
33730@end smallexample
33731
33732@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
33733unit if the integral types are the same size and if the next bit-field fits
33734into the current allocation unit without crossing the boundary imposed by the
33735common alignment requirements of the bit-fields.
33736@end enumerate
33737
33738MSVC interprets zero-length bit-fields in the following ways:
33739
33740@enumerate
33741@item If a zero-length bit-field is inserted between two bit-fields that
33742are normally coalesced, the bit-fields are not coalesced.
33743
33744For example:
33745
33746@smallexample
33747struct
33748 @{
33749 unsigned long bf_1 : 12;
33750 unsigned long : 0;
33751 unsigned long bf_2 : 12;
33752 @} t1;
33753@end smallexample
33754
33755@noindent
33756The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
33757zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
33758
33759@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
33760alignment of the zero-length bit-field is greater than the member that follows it,
33761@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
33762
33763For example:
33764
33765@smallexample
33766struct
33767 @{
33768 char foo : 4;
33769 short : 0;
33770 char bar;
33771 @} t2;
33772
33773struct
33774 @{
33775 char foo : 4;
33776 short : 0;
33777 double bar;
33778 @} t3;
33779@end smallexample
33780
33781@noindent
33782For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
33783Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
33784bit-field does not affect the alignment of @code{bar} or, as a result, the size
33785of the structure.
33786
33787Taking this into account, it is important to note the following:
33788
33789@enumerate
33790@item If a zero-length bit-field follows a normal bit-field, the type of the
33791zero-length bit-field may affect the alignment of the structure as whole. For
33792example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
33793normal bit-field, and is of type short.
33794
33795@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
33796still affect the alignment of the structure:
33797
33798@smallexample
33799struct
33800 @{
33801 char foo : 6;
33802 long : 0;
33803 @} t4;
33804@end smallexample
33805
33806@noindent
33807Here, @code{t4} takes up 4 bytes.
33808@end enumerate
33809
33810@item Zero-length bit-fields following non-bit-field members are ignored:
33811
33812@smallexample
33813struct
33814 @{
33815 char foo;
33816 long : 0;
33817 char bar;
33818 @} t5;
33819@end smallexample
33820
33821@noindent
33822Here, @code{t5} takes up 2 bytes.
33823@end enumerate
33824
33825
d77de738
ML
33826@opindex mno-align-stringops
33827@opindex malign-stringops
ddf6fe37 33828@item -mno-align-stringops
d77de738
ML
33829Do not align the destination of inlined string operations. This switch reduces
33830code size and improves performance in case the destination is already aligned,
33831but GCC doesn't know about it.
33832
d77de738 33833@opindex minline-all-stringops
ddf6fe37 33834@item -minline-all-stringops
d77de738
ML
33835By default GCC inlines string operations only when the destination is
33836known to be aligned to least a 4-byte boundary.
33837This enables more inlining and increases code
33838size, but may improve performance of code that depends on fast
33839@code{memcpy} and @code{memset} for short lengths.
33840The option enables inline expansion of @code{strlen} for all
33841pointer alignments.
33842
d77de738 33843@opindex minline-stringops-dynamically
ddf6fe37 33844@item -minline-stringops-dynamically
d77de738
ML
33845For string operations of unknown size, use run-time checks with
33846inline code for small blocks and a library call for large blocks.
33847
d77de738 33848@opindex mstringop-strategy=@var{alg}
ddf6fe37 33849@item -mstringop-strategy=@var{alg}
d77de738
ML
33850Override the internal decision heuristic for the particular algorithm to use
33851for inlining string operations. The allowed values for @var{alg} are:
33852
33853@table @samp
33854@item rep_byte
33855@itemx rep_4byte
33856@itemx rep_8byte
33857Expand using i386 @code{rep} prefix of the specified size.
33858
33859@item byte_loop
33860@itemx loop
33861@itemx unrolled_loop
33862Expand into an inline loop.
33863
33864@item libcall
33865Always use a library call.
33866@end table
33867
d77de738 33868@opindex mmemcpy-strategy=@var{strategy}
ddf6fe37 33869@item -mmemcpy-strategy=@var{strategy}
d77de738
ML
33870Override the internal decision heuristic to decide if @code{__builtin_memcpy}
33871should be inlined and what inline algorithm to use when the expected size
33872of the copy operation is known. @var{strategy}
33873is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
33874@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
33875the max byte size with which inline algorithm @var{alg} is allowed. For the last
33876triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
33877in the list must be specified in increasing order. The minimal byte size for
33878@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
33879preceding range.
33880
d77de738 33881@opindex mmemset-strategy=@var{strategy}
ddf6fe37 33882@item -mmemset-strategy=@var{strategy}
d77de738
ML
33883The option is similar to @option{-mmemcpy-strategy=} except that it is to control
33884@code{__builtin_memset} expansion.
33885
d77de738 33886@opindex momit-leaf-frame-pointer
ddf6fe37 33887@item -momit-leaf-frame-pointer
d77de738
ML
33888Don't keep the frame pointer in a register for leaf functions. This
33889avoids the instructions to save, set up, and restore frame pointers and
33890makes an extra register available in leaf functions. The option
33891@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
33892which might make debugging harder.
33893
ddf6fe37 33894@opindex mtls-direct-seg-refs
d77de738
ML
33895@item -mtls-direct-seg-refs
33896@itemx -mno-tls-direct-seg-refs
d77de738
ML
33897Controls whether TLS variables may be accessed with offsets from the
33898TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
33899or whether the thread base pointer must be added. Whether or not this
33900is valid depends on the operating system, and whether it maps the
33901segment to cover the entire TLS area.
33902
33903For systems that use the GNU C Library, the default is on.
33904
ddf6fe37 33905@opindex msse2avx
d77de738
ML
33906@item -msse2avx
33907@itemx -mno-sse2avx
d77de738
ML
33908Specify that the assembler should encode SSE instructions with VEX
33909prefix. The option @option{-mavx} turns this on by default.
33910
ddf6fe37 33911@opindex mfentry
d77de738
ML
33912@item -mfentry
33913@itemx -mno-fentry
d77de738
ML
33914If profiling is active (@option{-pg}), put the profiling
33915counter call before the prologue.
33916Note: On x86 architectures the attribute @code{ms_hook_prologue}
33917isn't possible at the moment for @option{-mfentry} and @option{-pg}.
33918
ddf6fe37 33919@opindex mrecord-mcount
d77de738
ML
33920@item -mrecord-mcount
33921@itemx -mno-record-mcount
d77de738
ML
33922If profiling is active (@option{-pg}), generate a __mcount_loc section
33923that contains pointers to each profiling call. This is useful for
33924automatically patching and out calls.
33925
ddf6fe37 33926@opindex mnop-mcount
d77de738
ML
33927@item -mnop-mcount
33928@itemx -mno-nop-mcount
d77de738
ML
33929If profiling is active (@option{-pg}), generate the calls to
33930the profiling functions as NOPs. This is useful when they
33931should be patched in later dynamically. This is likely only
33932useful together with @option{-mrecord-mcount}.
33933
d77de738 33934@opindex minstrument-return
ddf6fe37 33935@item -minstrument-return=@var{type}
d77de738
ML
33936Instrument function exit in -pg -mfentry instrumented functions with
33937call to specified function. This only instruments true returns ending
33938with ret, but not sibling calls ending with jump. Valid types
33939are @var{none} to not instrument, @var{call} to generate a call to __return__,
33940or @var{nop5} to generate a 5 byte nop.
33941
ddf6fe37 33942@opindex mrecord-return
d77de738
ML
33943@item -mrecord-return
33944@itemx -mno-record-return
d77de738
ML
33945Generate a __return_loc section pointing to all return instrumentation code.
33946
d77de738 33947@opindex mfentry-name
ddf6fe37 33948@item -mfentry-name=@var{name}
d77de738
ML
33949Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
33950
d77de738 33951@opindex mfentry-section
ddf6fe37 33952@item -mfentry-section=@var{name}
d77de738
ML
33953Set name of section to record -mrecord-mcount calls (default __mcount_loc).
33954
ddf6fe37 33955@opindex mskip-rax-setup
d77de738
ML
33956@item -mskip-rax-setup
33957@itemx -mno-skip-rax-setup
d77de738
ML
33958When generating code for the x86-64 architecture with SSE extensions
33959disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
33960register when there are no variable arguments passed in vector registers.
33961
33962@strong{Warning:} Since RAX register is used to avoid unnecessarily
33963saving vector registers on stack when passing variable arguments, the
33964impacts of this option are callees may waste some stack space,
33965misbehave or jump to a random location. GCC 4.4 or newer don't have
33966those issues, regardless the RAX register value.
33967
ddf6fe37 33968@opindex m8bit-idiv
d77de738
ML
33969@item -m8bit-idiv
33970@itemx -mno-8bit-idiv
d77de738
ML
33971On some processors, like Intel Atom, 8-bit unsigned integer divide is
33972much faster than 32-bit/64-bit integer divide. This option generates a
33973run-time check. If both dividend and divisor are within range of 0
33974to 255, 8-bit unsigned integer divide is used instead of
3397532-bit/64-bit integer divide.
33976
d77de738
ML
33977@opindex mavx256-split-unaligned-load
33978@opindex mavx256-split-unaligned-store
ddf6fe37
AA
33979@item -mavx256-split-unaligned-load
33980@itemx -mavx256-split-unaligned-store
d77de738
ML
33981Split 32-byte AVX unaligned load and store.
33982
d77de738
ML
33983@opindex mstack-protector-guard
33984@opindex mstack-protector-guard-reg
33985@opindex mstack-protector-guard-offset
ddf6fe37
AA
33986@item -mstack-protector-guard=@var{guard}
33987@itemx -mstack-protector-guard-reg=@var{reg}
33988@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
33989Generate stack protection code using canary at @var{guard}. Supported
33990locations are @samp{global} for global canary or @samp{tls} for per-thread
33991canary in the TLS block (the default). This option has effect only when
33992@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
33993
33994With the latter choice the options
33995@option{-mstack-protector-guard-reg=@var{reg}} and
33996@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
33997which segment register (@code{%fs} or @code{%gs}) to use as base register
33998for reading the canary, and from what offset from that base register.
33999The default for those is as specified in the relevant ABI.
34000
d77de738 34001@opindex mgeneral-regs-only
ddf6fe37 34002@item -mgeneral-regs-only
d77de738
ML
34003Generate code that uses only the general-purpose registers. This
34004prevents the compiler from using floating-point, vector, mask and bound
34005registers.
34006
d77de738 34007@opindex mrelax-cmpxchg-loop
ddf6fe37 34008@item -mrelax-cmpxchg-loop
85966f0d
AM
34009When emitting a compare-and-swap loop for @ref{__sync Builtins}
34010and @ref{__atomic Builtins} lacking a native instruction, optimize
34011for the highly contended case by issuing an atomic load before the
34012@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
34013to save CPU power when restarting the loop.
d77de738 34014
d77de738 34015@opindex mindirect-branch
ddf6fe37 34016@item -mindirect-branch=@var{choice}
d77de738
ML
34017Convert indirect call and jump with @var{choice}. The default is
34018@samp{keep}, which keeps indirect call and jump unmodified.
34019@samp{thunk} converts indirect call and jump to call and return thunk.
34020@samp{thunk-inline} converts indirect call and jump to inlined call
34021and return thunk. @samp{thunk-extern} converts indirect call and jump
34022to external call and return thunk provided in a separate object file.
34023You can control this behavior for a specific function by using the
34024function attribute @code{indirect_branch}. @xref{Function Attributes}.
34025
34026Note that @option{-mcmodel=large} is incompatible with
34027@option{-mindirect-branch=thunk} and
34028@option{-mindirect-branch=thunk-extern} since the thunk function may
34029not be reachable in the large code model.
34030
34031Note that @option{-mindirect-branch=thunk-extern} is compatible with
34032@option{-fcf-protection=branch} since the external thunk can be made
34033to enable control-flow check.
34034
d77de738 34035@opindex mfunction-return
ddf6fe37 34036@item -mfunction-return=@var{choice}
d77de738
ML
34037Convert function return with @var{choice}. The default is @samp{keep},
34038which keeps function return unmodified. @samp{thunk} converts function
34039return to call and return thunk. @samp{thunk-inline} converts function
34040return to inlined call and return thunk. @samp{thunk-extern} converts
34041function return to external call and return thunk provided in a separate
34042object file. You can control this behavior for a specific function by
34043using the function attribute @code{function_return}.
34044@xref{Function Attributes}.
34045
34046Note that @option{-mindirect-return=thunk-extern} is compatible with
34047@option{-fcf-protection=branch} since the external thunk can be made
34048to enable control-flow check.
34049
34050Note that @option{-mcmodel=large} is incompatible with
34051@option{-mfunction-return=thunk} and
34052@option{-mfunction-return=thunk-extern} since the thunk function may
34053not be reachable in the large code model.
34054
34055
d77de738 34056@opindex mindirect-branch-register
ddf6fe37 34057@item -mindirect-branch-register
d77de738
ML
34058Force indirect call and jump via register.
34059
d77de738 34060@opindex mharden-sls
ddf6fe37 34061@item -mharden-sls=@var{choice}
d77de738
ML
34062Generate code to mitigate against straight line speculation (SLS) with
34063@var{choice}. The default is @samp{none} which disables all SLS
34064hardening. @samp{return} enables SLS hardening for function returns.
34065@samp{indirect-jmp} enables SLS hardening for indirect jumps.
34066@samp{all} enables all SLS hardening.
34067
d77de738 34068@opindex mindirect-branch-cs-prefix
ddf6fe37 34069@item -mindirect-branch-cs-prefix
d77de738
ML
34070Add CS prefix to call and jmp to indirect thunk with branch target in
34071r8-r15 registers so that the call and jmp instruction length is 6 bytes
34072to allow them to be replaced with @samp{lfence; call *%r8-r15} or
34073@samp{lfence; jmp *%r8-r15} at run-time.
34074
34075@end table
34076
34077These @samp{-m} switches are supported in addition to the above
34078on x86-64 processors in 64-bit environments.
34079
34080@table @gcctabopt
d77de738
ML
34081@opindex m32
34082@opindex m64
34083@opindex mx32
34084@opindex m16
34085@opindex miamcu
ddf6fe37
AA
34086@item -m32
34087@itemx -m64
34088@itemx -mx32
34089@itemx -m16
34090@itemx -miamcu
d77de738
ML
34091Generate code for a 16-bit, 32-bit or 64-bit environment.
34092The @option{-m32} option sets @code{int}, @code{long}, and pointer types
34093to 32 bits, and
eeb92704 34094generates code that runs in 32-bit mode.
d77de738
ML
34095
34096The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
34097types to 64 bits, and generates code for the x86-64 architecture.
34098For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
34099and @option{-mdynamic-no-pic} options.
34100
34101The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
34102to 32 bits, and
34103generates code for the x86-64 architecture.
34104
34105The @option{-m16} option is the same as @option{-m32}, except for that
34106it outputs the @code{.code16gcc} assembly directive at the beginning of
34107the assembly output so that the binary can run in 16-bit mode.
34108
34109The @option{-miamcu} option generates code which conforms to Intel MCU
34110psABI. It requires the @option{-m32} option to be turned on.
34111
d77de738
ML
34112@opindex mno-red-zone
34113@opindex mred-zone
ddf6fe37 34114@item -mno-red-zone
d77de738
ML
34115Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
34116by the x86-64 ABI; it is a 128-byte area beyond the location of the
34117stack pointer that is not modified by signal or interrupt handlers
34118and therefore can be used for temporary data without adjusting the stack
34119pointer. The flag @option{-mno-red-zone} disables this red zone.
34120
d77de738 34121@opindex mcmodel=small
ddf6fe37 34122@item -mcmodel=small
d77de738
ML
34123Generate code for the small code model: the program and its symbols must
34124be linked in the lower 2 GB of the address space. Pointers are 64 bits.
34125Programs can be statically or dynamically linked. This is the default
34126code model.
34127
d77de738 34128@opindex mcmodel=kernel
ddf6fe37 34129@item -mcmodel=kernel
d77de738
ML
34130Generate code for the kernel code model. The kernel runs in the
34131negative 2 GB of the address space.
34132This model has to be used for Linux kernel code.
34133
d77de738 34134@opindex mcmodel=medium
ddf6fe37 34135@item -mcmodel=medium
d77de738
ML
34136Generate code for the medium model: the program is linked in the lower 2
34137GB of the address space. Small symbols are also placed there. Symbols
34138with sizes larger than @option{-mlarge-data-threshold} are put into
34139large data or BSS sections and can be located above 2GB. Programs can
34140be statically or dynamically linked.
34141
d77de738 34142@opindex mcmodel=large
ddf6fe37 34143@item -mcmodel=large
d77de738
ML
34144Generate code for the large model. This model makes no assumptions
34145about addresses and sizes of sections.
34146
d77de738 34147@opindex maddress-mode=long
ddf6fe37 34148@item -maddress-mode=long
d77de738
ML
34149Generate code for long address mode. This is only supported for 64-bit
34150and x32 environments. It is the default address mode for 64-bit
34151environments.
34152
d77de738 34153@opindex maddress-mode=short
ddf6fe37 34154@item -maddress-mode=short
d77de738
ML
34155Generate code for short address mode. This is only supported for 32-bit
34156and x32 environments. It is the default address mode for 32-bit and
34157x32 environments.
34158
ddf6fe37 34159@opindex mneeded
d77de738
ML
34160@item -mneeded
34161@itemx -mno-needed
d77de738
ML
34162Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
34163indicate the micro-architecture ISA level required to execute the binary.
34164
d77de738
ML
34165@opindex mno-direct-extern-access
34166@opindex mdirect-extern-access
ddf6fe37 34167@item -mno-direct-extern-access
d77de738
ML
34168Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
34169to access external symbols. With @option{-fpic} or @option{-fPIC},
34170treat access to protected symbols as local symbols. The default is
34171@option{-mdirect-extern-access}.
34172
34173@strong{Warning:} shared libraries compiled with
34174@option{-mno-direct-extern-access} and executable compiled with
34175@option{-mdirect-extern-access} may not be binary compatible if
34176protected symbols are used in shared libraries and executable.
ce51e843 34177
ce51e843
ML
34178@opindex munroll-only-small-loops
34179@opindex mno-unroll-only-small-loops
ddf6fe37 34180@item -munroll-only-small-loops
ce51e843
ML
34181Controls conservative small loop unrolling. It is default enabled by
34182O2, and unrolls loop with less than 4 insns by 1 time. Explicit
34183-f[no-]unroll-[all-]loops would disable this flag to avoid any
34184unintended unrolling behavior that user does not want.
bb576017 34185
bb576017 34186@opindex mlam
ddf6fe37 34187@item -mlam=@var{choice}
bb576017 34188LAM(linear-address masking) allows special bits in the pointer to be used
34189for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
34190positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
34191positions 62:57 can be used for metadata.
d77de738
ML
34192@end table
34193
34194@node x86 Windows Options
34195@subsection x86 Windows Options
34196@cindex x86 Windows Options
34197@cindex Windows Options for x86
34198
34199These additional options are available for Microsoft Windows targets:
34200
34201@table @gcctabopt
d77de738 34202@opindex mconsole
ddf6fe37 34203@item -mconsole
d77de738
ML
34204This option
34205specifies that a console application is to be generated, by
34206instructing the linker to set the PE header subsystem type
34207required for console applications.
34208This option is available for Cygwin and MinGW targets and is
34209enabled by default on those targets.
34210
d77de738 34211@opindex mdll
ddf6fe37 34212@item -mdll
d77de738
ML
34213This option is available for Cygwin and MinGW targets. It
34214specifies that a DLL---a dynamic link library---is to be
34215generated, enabling the selection of the required runtime
34216startup object and entry point.
34217
d77de738 34218@opindex mnop-fun-dllimport
ddf6fe37 34219@item -mnop-fun-dllimport
d77de738
ML
34220This option is available for Cygwin and MinGW targets. It
34221specifies that the @code{dllimport} attribute should be ignored.
34222
d77de738 34223@opindex mthreads
ddf6fe37 34224@item -mthreads
d77de738
ML
34225This option is available for MinGW targets. It specifies
34226that MinGW-specific thread support is to be used.
34227
d77de738 34228@opindex municode
ddf6fe37 34229@item -municode
d77de738
ML
34230This option is available for MinGW-w64 targets. It causes
34231the @code{UNICODE} preprocessor macro to be predefined, and
34232chooses Unicode-capable runtime startup code.
34233
d77de738 34234@opindex mwin32
ddf6fe37 34235@item -mwin32
d77de738
ML
34236This option is available for Cygwin and MinGW targets. It
34237specifies that the typical Microsoft Windows predefined macros are to
34238be set in the pre-processor, but does not influence the choice
34239of runtime library/startup code.
34240
d77de738 34241@opindex mwindows
ddf6fe37 34242@item -mwindows
d77de738
ML
34243This option is available for Cygwin and MinGW targets. It
34244specifies that a GUI application is to be generated by
34245instructing the linker to set the PE header subsystem type
34246appropriately.
34247
d77de738
ML
34248@opindex fno-set-stack-executable
34249@opindex fset-stack-executable
ddf6fe37 34250@item -fno-set-stack-executable
d77de738
ML
34251This option is available for MinGW targets. It specifies that
34252the executable flag for the stack used by nested functions isn't
34253set. This is necessary for binaries running in kernel mode of
34254Microsoft Windows, as there the User32 API, which is used to set executable
34255privileges, isn't available.
34256
d77de738
ML
34257@opindex fno-writable-relocated-rdata
34258@opindex fwritable-relocated-rdata
ddf6fe37 34259@item -fwritable-relocated-rdata
d77de738
ML
34260This option is available for MinGW and Cygwin targets. It specifies
34261that relocated-data in read-only section is put into the @code{.data}
34262section. This is a necessary for older runtimes not supporting
34263modification of @code{.rdata} sections for pseudo-relocation.
34264
d77de738 34265@opindex mpe-aligned-commons
ddf6fe37 34266@item -mpe-aligned-commons
d77de738
ML
34267This option is available for Cygwin and MinGW targets. It
34268specifies that the GNU extension to the PE file format that
34269permits the correct alignment of COMMON variables should be
34270used when generating code. It is enabled by default if
34271GCC detects that the target assembler found during configuration
34272supports the feature.
34273@end table
34274
34275See also under @ref{x86 Options} for standard options.
34276
34277@node Xstormy16 Options
34278@subsection Xstormy16 Options
34279@cindex Xstormy16 Options
34280
34281These options are defined for Xstormy16:
34282
34283@table @gcctabopt
d77de738 34284@opindex msim
ddf6fe37 34285@item -msim
d77de738
ML
34286Choose startup files and linker script suitable for the simulator.
34287@end table
34288
34289@node Xtensa Options
34290@subsection Xtensa Options
34291@cindex Xtensa Options
34292
34293These options are supported for Xtensa targets:
34294
34295@table @gcctabopt
d77de738
ML
34296@opindex mconst16
34297@opindex mno-const16
ddf6fe37
AA
34298@item -mconst16
34299@itemx -mno-const16
d77de738
ML
34300Enable or disable use of @code{CONST16} instructions for loading
34301constant values. The @code{CONST16} instruction is currently not a
34302standard option from Tensilica. When enabled, @code{CONST16}
34303instructions are always used in place of the standard @code{L32R}
34304instructions. The use of @code{CONST16} is enabled by default only if
34305the @code{L32R} instruction is not available.
34306
d77de738
ML
34307@opindex mfused-madd
34308@opindex mno-fused-madd
ddf6fe37
AA
34309@item -mfused-madd
34310@itemx -mno-fused-madd
d77de738
ML
34311Enable or disable use of fused multiply/add and multiply/subtract
34312instructions in the floating-point option. This has no effect if the
34313floating-point option is not also enabled. Disabling fused multiply/add
34314and multiply/subtract instructions forces the compiler to use separate
34315instructions for the multiply and add/subtract operations. This may be
34316desirable in some cases where strict IEEE 754-compliant results are
34317required: the fused multiply add/subtract instructions do not round the
34318intermediate result, thereby producing results with @emph{more} bits of
34319precision than specified by the IEEE standard. Disabling fused multiply
34320add/subtract instructions also ensures that the program output is not
34321sensitive to the compiler's ability to combine multiply and add/subtract
34322operations.
34323
d77de738
ML
34324@opindex mserialize-volatile
34325@opindex mno-serialize-volatile
ddf6fe37
AA
34326@item -mserialize-volatile
34327@itemx -mno-serialize-volatile
d77de738
ML
34328When this option is enabled, GCC inserts @code{MEMW} instructions before
34329@code{volatile} memory references to guarantee sequential consistency.
34330The default is @option{-mserialize-volatile}. Use
34331@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
34332
d77de738 34333@opindex mforce-no-pic
ddf6fe37 34334@item -mforce-no-pic
d77de738
ML
34335For targets, like GNU/Linux, where all user-mode Xtensa code must be
34336position-independent code (PIC), this option disables PIC for compiling
34337kernel code.
34338
d77de738
ML
34339@opindex mtext-section-literals
34340@opindex mno-text-section-literals
ddf6fe37
AA
34341@item -mtext-section-literals
34342@itemx -mno-text-section-literals
d77de738
ML
34343These options control the treatment of literal pools. The default is
34344@option{-mno-text-section-literals}, which places literals in a separate
34345section in the output file. This allows the literal pool to be placed
34346in a data RAM/ROM, and it also allows the linker to combine literal
34347pools from separate object files to remove redundant literals and
34348improve code size. With @option{-mtext-section-literals}, the literals
34349are interspersed in the text section in order to keep them as close as
34350possible to their references. This may be necessary for large assembly
34351files. Literals for each function are placed right before that function.
34352
d77de738
ML
34353@opindex mauto-litpools
34354@opindex mno-auto-litpools
ddf6fe37
AA
34355@item -mauto-litpools
34356@itemx -mno-auto-litpools
d77de738
ML
34357These options control the treatment of literal pools. The default is
34358@option{-mno-auto-litpools}, which places literals in a separate
34359section in the output file unless @option{-mtext-section-literals} is
34360used. With @option{-mauto-litpools} the literals are interspersed in
34361the text section by the assembler. Compiler does not produce explicit
34362@code{.literal} directives and loads literals into registers with
34363@code{MOVI} instructions instead of @code{L32R} to let the assembler
34364do relaxation and place literals as necessary. This option allows
34365assembler to create several literal pools per function and assemble
34366very big functions, which may not be possible with
34367@option{-mtext-section-literals}.
34368
d77de738
ML
34369@opindex mtarget-align
34370@opindex mno-target-align
ddf6fe37
AA
34371@item -mtarget-align
34372@itemx -mno-target-align
d77de738
ML
34373When this option is enabled, GCC instructs the assembler to
34374automatically align instructions to reduce branch penalties at the
34375expense of some code density. The assembler attempts to widen density
34376instructions to align branch targets and the instructions following call
34377instructions. If there are not enough preceding safe density
34378instructions to align a target, no widening is performed. The
34379default is @option{-mtarget-align}. These options do not affect the
34380treatment of auto-aligned instructions like @code{LOOP}, which the
34381assembler always aligns, either by widening density instructions or
34382by inserting NOP instructions.
34383
d77de738
ML
34384@opindex mlongcalls
34385@opindex mno-longcalls
ddf6fe37
AA
34386@item -mlongcalls
34387@itemx -mno-longcalls
d77de738
ML
34388When this option is enabled, GCC instructs the assembler to translate
34389direct calls to indirect calls unless it can determine that the target
34390of a direct call is in the range allowed by the call instruction. This
34391translation typically occurs for calls to functions in other source
34392files. Specifically, the assembler translates a direct @code{CALL}
34393instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34394The default is @option{-mno-longcalls}. This option should be used in
34395programs where the call target can potentially be out of range. This
34396option is implemented in the assembler, not the compiler, so the
34397assembly code generated by GCC still shows direct call
34398instructions---look at the disassembled object code to see the actual
34399instructions. Note that the assembler uses an indirect call for
34400every cross-file call, not just those that really are out of range.
34401
d77de738 34402@opindex mabi
ddf6fe37 34403@item -mabi=@var{name}
d77de738
ML
34404Generate code for the specified ABI@. Permissible values are: @samp{call0},
34405@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34406
d77de738 34407@opindex mabi=call0
ddf6fe37 34408@item -mabi=call0
d77de738
ML
34409When this option is enabled function parameters are passed in registers
34410@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34411caller-saved, and register @code{a15} may be used as a frame pointer.
34412When this version of the ABI is enabled the C preprocessor symbol
34413@code{__XTENSA_CALL0_ABI__} is defined.
34414
d77de738 34415@opindex mabi=windowed
ddf6fe37 34416@item -mabi=windowed
d77de738
ML
34417When this option is enabled function parameters are passed in registers
34418@code{a10} through @code{a15}, and called function rotates register window
34419by 8 registers on entry so that its arguments are found in registers
34420@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34421pointer. Register window is rotated 8 registers back upon return.
34422When this version of the ABI is enabled the C preprocessor symbol
34423@code{__XTENSA_WINDOWED_ABI__} is defined.
34424
d77de738 34425@opindex mextra-l32r-costs
ddf6fe37 34426@item -mextra-l32r-costs=@var{n}
d77de738
ML
34427Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34428instructions, in clock cycles. This affects, when optimizing for speed,
34429whether loading a constant from literal pool using @code{L32R} or
34430synthesizing the constant from a small one with a couple of arithmetic
34431instructions. The default value is 0.
675b390e
MF
34432
34433@opindex mstrict-align
34434@opindex mno-strict-align
34435@item -mstrict-align
34436@itemx -mno-strict-align
34437Avoid or allow generating memory accesses that may not be aligned on a natural
34438object boundary as described in the architecture specification.
34439The default is @option{-mno-strict-align} for cores that support both
34440unaligned loads and stores in hardware and @option{-mstrict-align} for all
34441other cores.
34442
d77de738
ML
34443@end table
34444
34445@node zSeries Options
34446@subsection zSeries Options
34447@cindex zSeries options
34448
34449These are listed under @xref{S/390 and zSeries Options}.
34450
34451
34452@c man end
34453
34454@node Spec Files
34455@section Specifying Subprocesses and the Switches to Pass to Them
34456@cindex Spec Files
34457
34458@command{gcc} is a driver program. It performs its job by invoking a
34459sequence of other programs to do the work of compiling, assembling and
34460linking. GCC interprets its command-line parameters and uses these to
34461deduce which programs it should invoke, and which command-line options
34462it ought to place on their command lines. This behavior is controlled
34463by @dfn{spec strings}. In most cases there is one spec string for each
34464program that GCC can invoke, but a few programs have multiple spec
34465strings to control their behavior. The spec strings built into GCC can
34466be overridden by using the @option{-specs=} command-line switch to specify
34467a spec file.
34468
34469@dfn{Spec files} are plain-text files that are used to construct spec
34470strings. They consist of a sequence of directives separated by blank
34471lines. The type of directive is determined by the first non-whitespace
34472character on the line, which can be one of the following:
34473
34474@table @code
34475@item %@var{command}
34476Issues a @var{command} to the spec file processor. The commands that can
34477appear here are:
34478
34479@table @code
d77de738 34480@cindex @code{%include}
f33d7a88 34481@item %include <@var{file}>
d77de738
ML
34482Search for @var{file} and insert its text at the current point in the
34483specs file.
34484
d77de738 34485@cindex @code{%include_noerr}
f33d7a88 34486@item %include_noerr <@var{file}>
d77de738
ML
34487Just like @samp{%include}, but do not generate an error message if the include
34488file cannot be found.
34489
d77de738 34490@cindex @code{%rename}
f33d7a88 34491@item %rename @var{old_name} @var{new_name}
d77de738
ML
34492Rename the spec string @var{old_name} to @var{new_name}.
34493
34494@end table
34495
34496@item *[@var{spec_name}]:
34497This tells the compiler to create, override or delete the named spec
34498string. All lines after this directive up to the next directive or
34499blank line are considered to be the text for the spec string. If this
34500results in an empty string then the spec is deleted. (Or, if the
34501spec did not exist, then nothing happens.) Otherwise, if the spec
34502does not currently exist a new spec is created. If the spec does
34503exist then its contents are overridden by the text of this
34504directive, unless the first character of that text is the @samp{+}
34505character, in which case the text is appended to the spec.
34506
34507@item [@var{suffix}]:
34508Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
34509and up to the next directive or blank line are considered to make up the
34510spec string for the indicated suffix. When the compiler encounters an
34511input file with the named suffix, it processes the spec string in
34512order to work out how to compile that file. For example:
34513
34514@smallexample
34515.ZZ:
34516z-compile -input %i
34517@end smallexample
34518
34519This says that any input file whose name ends in @samp{.ZZ} should be
34520passed to the program @samp{z-compile}, which should be invoked with the
34521command-line switch @option{-input} and with the result of performing the
34522@samp{%i} substitution. (See below.)
34523
34524As an alternative to providing a spec string, the text following a
34525suffix directive can be one of the following:
34526
34527@table @code
34528@item @@@var{language}
34529This says that the suffix is an alias for a known @var{language}. This is
34530similar to using the @option{-x} command-line switch to GCC to specify a
34531language explicitly. For example:
34532
34533@smallexample
34534.ZZ:
34535@@c++
34536@end smallexample
34537
34538Says that .ZZ files are, in fact, C++ source files.
34539
34540@item #@var{name}
34541This causes an error messages saying:
34542
34543@smallexample
34544@var{name} compiler not installed on this system.
34545@end smallexample
34546@end table
34547
34548GCC already has an extensive list of suffixes built into it.
34549This directive adds an entry to the end of the list of suffixes, but
34550since the list is searched from the end backwards, it is effectively
34551possible to override earlier entries using this technique.
34552
34553@end table
34554
34555GCC has the following spec strings built into it. Spec files can
34556override these strings or create their own. Note that individual
34557targets can also add their own spec strings to this list.
34558
34559@smallexample
34560asm Options to pass to the assembler
34561asm_final Options to pass to the assembler post-processor
34562cpp Options to pass to the C preprocessor
34563cc1 Options to pass to the C compiler
34564cc1plus Options to pass to the C++ compiler
34565endfile Object files to include at the end of the link
34566link Options to pass to the linker
34567lib Libraries to include on the command line to the linker
34568libgcc Decides which GCC support library to pass to the linker
34569linker Sets the name of the linker
34570predefines Defines to be passed to the C preprocessor
34571signed_char Defines to pass to CPP to say whether @code{char} is signed
34572 by default
34573startfile Object files to include at the start of the link
34574@end smallexample
34575
34576Here is a small example of a spec file:
34577
34578@smallexample
34579%rename lib old_lib
34580
34581*lib:
34582--start-group -lgcc -lc -leval1 --end-group %(old_lib)
34583@end smallexample
34584
34585This example renames the spec called @samp{lib} to @samp{old_lib} and
34586then overrides the previous definition of @samp{lib} with a new one.
34587The new definition adds in some extra command-line options before
34588including the text of the old definition.
34589
34590@dfn{Spec strings} are a list of command-line options to be passed to their
34591corresponding program. In addition, the spec strings can contain
34592@samp{%}-prefixed sequences to substitute variable text or to
34593conditionally insert text into the command line. Using these constructs
34594it is possible to generate quite complex command lines.
34595
34596Here is a table of all defined @samp{%}-sequences for spec
34597strings. Note that spaces are not generated automatically around the
34598results of expanding these sequences. Therefore you can concatenate them
34599together or combine them with constant text in a single argument.
34600
34601@table @code
34602@item %%
34603Substitute one @samp{%} into the program name or argument.
34604
34605@item %"
34606Substitute an empty argument.
34607
34608@item %i
34609Substitute the name of the input file being processed.
34610
34611@item %b
34612Substitute the basename for outputs related with the input file being
34613processed. This is often the substring up to (and not including) the
34614last period and not including the directory but, unless %w is active, it
34615expands to the basename for auxiliary outputs, which may be influenced
34616by an explicit output name, and by various other options that control
34617how auxiliary outputs are named.
34618
34619@item %B
34620This is the same as @samp{%b}, but include the file suffix (text after
34621the last period). Without %w, it expands to the basename for dump
34622outputs.
34623
34624@item %d
34625Marks the argument containing or following the @samp{%d} as a
34626temporary file name, so that that file is deleted if GCC exits
34627successfully. Unlike @samp{%g}, this contributes no text to the
34628argument.
34629
34630@item %g@var{suffix}
34631Substitute a file name that has suffix @var{suffix} and is chosen
34632once per compilation, and mark the argument in the same way as
34633@samp{%d}. To reduce exposure to denial-of-service attacks, the file
34634name is now chosen in a way that is hard to predict even when previously
34635chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
34636might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
34637the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
34638treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
34639was simply substituted with a file name chosen once per compilation,
34640without regard to any appended suffix (which was therefore treated
34641just like ordinary text), making such attacks more likely to succeed.
34642
34643@item %u@var{suffix}
34644Like @samp{%g}, but generates a new temporary file name
34645each time it appears instead of once per compilation.
34646
34647@item %U@var{suffix}
34648Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
34649new one if there is no such last file name. In the absence of any
34650@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
34651the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
34652involves the generation of two distinct file names, one
34653for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
34654simply substituted with a file name chosen for the previous @samp{%u},
34655without regard to any appended suffix.
34656
34657@item %j@var{suffix}
34658Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
34659writable, and if @option{-save-temps} is not used;
34660otherwise, substitute the name
34661of a temporary file, just like @samp{%u}. This temporary file is not
34662meant for communication between processes, but rather as a junk
34663disposal mechanism.
34664
34665@item %|@var{suffix}
34666@itemx %m@var{suffix}
34667Like @samp{%g}, except if @option{-pipe} is in effect. In that case
34668@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
34669all. These are the two most common ways to instruct a program that it
34670should read from standard input or write to standard output. If you
34671need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
34672construct: see for example @file{gcc/fortran/lang-specs.h}.
34673
34674@item %.@var{SUFFIX}
34675Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
34676when it is subsequently output with @samp{%*}. @var{SUFFIX} is
34677terminated by the next space or %.
34678
34679@item %w
34680Marks the argument containing or following the @samp{%w} as the
34681designated output file of this compilation. This puts the argument
34682into the sequence of arguments that @samp{%o} substitutes.
34683
34684@item %V
34685Indicates that this compilation produces no output file.
34686
34687@item %o
34688Substitutes the names of all the output files, with spaces
34689automatically placed around them. You should write spaces
34690around the @samp{%o} as well or the results are undefined.
34691@samp{%o} is for use in the specs for running the linker.
34692Input files whose names have no recognized suffix are not compiled
34693at all, but they are included among the output files, so they are
34694linked.
34695
34696@item %O
34697Substitutes the suffix for object files. Note that this is
34698handled specially when it immediately follows @samp{%g, %u, or %U},
34699because of the need for those to form complete file names. The
34700handling is such that @samp{%O} is treated exactly as if it had already
34701been substituted, except that @samp{%g, %u, and %U} do not currently
34702support additional @var{suffix} characters following @samp{%O} as they do
34703following, for example, @samp{.o}.
34704
34705@item %I
34706Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
34707@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
34708@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
34709and @option{-imultilib} as necessary.
34710
34711@item %s
34712Current argument is the name of a library or startup file of some sort.
34713Search for that file in a standard list of directories and substitute
34714the full name found. The current working directory is included in the
34715list of directories scanned.
34716
34717@item %T
34718Current argument is the name of a linker script. Search for that file
34719in the current list of directories to scan for libraries. If the file
34720is located insert a @option{--script} option into the command line
34721followed by the full path name found. If the file is not found then
34722generate an error message. Note: the current working directory is not
34723searched.
34724
34725@item %e@var{str}
34726Print @var{str} as an error message. @var{str} is terminated by a newline.
34727Use this when inconsistent options are detected.
34728
34729@item %n@var{str}
34730Print @var{str} as a notice. @var{str} is terminated by a newline.
34731
34732@item %(@var{name})
34733Substitute the contents of spec string @var{name} at this point.
34734
34735@item %x@{@var{option}@}
34736Accumulate an option for @samp{%X}.
34737
34738@item %X
34739Output the accumulated linker options specified by a @samp{%x} spec string.
34740
34741@item %Y
34742Output the accumulated assembler options specified by @option{-Wa}.
34743
34744@item %Z
34745Output the accumulated preprocessor options specified by @option{-Wp}.
34746
34747@item %M
34748Output @code{multilib_os_dir}.
34749
34750@item %R
34751Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
34752
34753@item %a
34754Process the @code{asm} spec. This is used to compute the
34755switches to be passed to the assembler.
34756
34757@item %A
34758Process the @code{asm_final} spec. This is a spec string for
34759passing switches to an assembler post-processor, if such a program is
34760needed.
34761
34762@item %l
34763Process the @code{link} spec. This is the spec for computing the
34764command line passed to the linker. Typically it makes use of the
34765@samp{%L %G %S %D and %E} sequences.
34766
34767@item %D
34768Dump out a @option{-L} option for each directory that GCC believes might
34769contain startup files. If the target supports multilibs then the
34770current multilib directory is prepended to each of these paths.
34771
34772@item %L
34773Process the @code{lib} spec. This is a spec string for deciding which
34774libraries are included on the command line to the linker.
34775
34776@item %G
34777Process the @code{libgcc} spec. This is a spec string for deciding
34778which GCC support library is included on the command line to the linker.
34779
34780@item %S
34781Process the @code{startfile} spec. This is a spec for deciding which
34782object files are the first ones passed to the linker. Typically
34783this might be a file named @file{crt0.o}.
34784
34785@item %E
34786Process the @code{endfile} spec. This is a spec string that specifies
34787the last object files that are passed to the linker.
34788
34789@item %C
34790Process the @code{cpp} spec. This is used to construct the arguments
34791to be passed to the C preprocessor.
34792
34793@item %1
34794Process the @code{cc1} spec. This is used to construct the options to be
34795passed to the actual C compiler (@command{cc1}).
34796
34797@item %2
34798Process the @code{cc1plus} spec. This is used to construct the options to be
34799passed to the actual C++ compiler (@command{cc1plus}).
34800
34801@item %*
34802Substitute the variable part of a matched option. See below.
34803Note that each comma in the substituted string is replaced by
34804a single space.
34805
34806@item %<S
34807Remove all occurrences of @code{-S} from the command line. Note---this
34808command is position dependent. @samp{%} commands in the spec string
34809before this one see @code{-S}, @samp{%} commands in the spec string
34810after this one do not.
34811
34812@item %<S*
34813Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
34814
34815@item %>S
34816Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
34817
34818@item %:@var{function}(@var{args})
34819Call the named function @var{function}, passing it @var{args}.
34820@var{args} is first processed as a nested spec string, then split
34821into an argument vector in the usual fashion. The function returns
34822a string which is processed as if it had appeared literally as part
34823of the current spec.
34824
34825The following built-in spec functions are provided:
34826
34827@table @code
34828@item @code{getenv}
34829The @code{getenv} spec function takes two arguments: an environment
34830variable name and a string. If the environment variable is not
34831defined, a fatal error is issued. Otherwise, the return value is the
34832value of the environment variable concatenated with the string. For
34833example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
34834
34835@smallexample
34836%:getenv(TOPDIR /include)
34837@end smallexample
34838
34839expands to @file{/path/to/top/include}.
34840
34841@item @code{if-exists}
34842The @code{if-exists} spec function takes one argument, an absolute
34843pathname to a file. If the file exists, @code{if-exists} returns the
34844pathname. Here is a small example of its usage:
34845
34846@smallexample
34847*startfile:
34848crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
34849@end smallexample
34850
34851@item @code{if-exists-else}
34852The @code{if-exists-else} spec function is similar to the @code{if-exists}
34853spec function, except that it takes two arguments. The first argument is
34854an absolute pathname to a file. If the file exists, @code{if-exists-else}
34855returns the pathname. If it does not exist, it returns the second argument.
34856This way, @code{if-exists-else} can be used to select one file or another,
34857based on the existence of the first. Here is a small example of its usage:
34858
34859@smallexample
34860*startfile:
34861crt0%O%s %:if-exists(crti%O%s) \
34862%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
34863@end smallexample
34864
34865@item @code{if-exists-then-else}
34866The @code{if-exists-then-else} spec function takes at least two arguments
34867and an optional third one. The first argument is an absolute pathname to a
34868file. If the file exists, the function returns the second argument.
34869If the file does not exist, the function returns the third argument if there
34870is one, or NULL otherwise. This can be used to expand one text, or optionally
34871another, based on the existence of a file. Here is a small example of its
34872usage:
34873
34874@smallexample
34875-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
34876@end smallexample
34877
34878@item @code{sanitize}
34879The @code{sanitize} spec function takes no arguments. It returns non-NULL if
34880any address, thread or undefined behavior sanitizers are active.
34881
34882@smallexample
34883%@{%:sanitize(address):-funwind-tables@}
34884@end smallexample
34885
34886@item @code{replace-outfile}
34887The @code{replace-outfile} spec function takes two arguments. It looks for the
34888first argument in the outfiles array and replaces it with the second argument. Here
34889is a small example of its usage:
34890
34891@smallexample
34892%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
34893@end smallexample
34894
34895@item @code{remove-outfile}
34896The @code{remove-outfile} spec function takes one argument. It looks for the
34897first argument in the outfiles array and removes it. Here is a small example
34898its usage:
34899
34900@smallexample
34901%:remove-outfile(-lm)
34902@end smallexample
34903
34904@item @code{version-compare}
34905The @code{version-compare} spec function takes four or five arguments of the following
34906form:
34907
34908@smallexample
34909<comparison-op> <arg1> [<arg2>] <switch> <result>
34910@end smallexample
34911
34912It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
34913The supported @code{comparison-op} values are:
34914
34915@table @code
34916@item >=
34917True if @code{switch} is a later (or same) version than @code{arg1}
34918
34919@item !>
34920Opposite of @code{>=}
34921
34922@item <
34923True if @code{switch} is an earlier version than @code{arg1}
34924
34925@item !<
34926Opposite of @code{<}
34927
34928@item ><
34929True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
34930
34931@item <>
34932True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
34933@end table
34934
34935If the @code{switch} is not present at all, the condition is false unless the first character
34936of the @code{comparison-op} is @code{!}.
34937
34938@smallexample
34939%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
34940@end smallexample
34941
34942The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
34943passed.
34944
34945@item @code{include}
34946The @code{include} spec function behaves much like @code{%include}, with the advantage
34947that it can be nested inside a spec and thus be conditionalized. It takes one argument,
34948the filename, and looks for it in the startfile path. It always returns NULL.
34949
34950@smallexample
34951%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
34952@end smallexample
34953
34954@item @code{pass-through-libs}
34955The @code{pass-through-libs} spec function takes any number of arguments. It
34956finds any @option{-l} options and any non-options ending in @file{.a} (which it
34957assumes are the names of linker input library archive files) and returns a
34958result containing all the found arguments each prepended by
34959@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
34960intended to be passed to the LTO linker plugin.
34961
34962@smallexample
34963%:pass-through-libs(%G %L %G)
34964@end smallexample
34965
34966@item @code{print-asm-header}
34967The @code{print-asm-header} function takes no arguments and simply
34968prints a banner like:
34969
34970@smallexample
34971Assembler options
34972=================
34973
34974Use "-Wa,OPTION" to pass "OPTION" to the assembler.
34975@end smallexample
34976
34977It is used to separate compiler options from assembler options
34978in the @option{--target-help} output.
34979
34980@item @code{gt}
34981The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
34982empty string) if the second-to-last argument is greater than the last argument, and NULL
34983otherwise. The following example inserts the @code{link_gomp} spec if the last
34984@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
34985
34986@smallexample
34987%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
34988@end smallexample
34989
34990@item @code{debug-level-gt}
34991The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
34992empty string) if @code{debug_info_level} is greater than the specified number, and NULL
34993otherwise.
34994
34995@smallexample
34996%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
34997@end smallexample
34998@end table
34999
35000@item %@{S@}
35001Substitutes the @code{-S} switch, if that switch is given to GCC@.
35002If that switch is not specified, this substitutes nothing. Note that
35003the leading dash is omitted when specifying this option, and it is
35004automatically inserted if the substitution is performed. Thus the spec
35005string @samp{%@{foo@}} matches the command-line option @option{-foo}
35006and outputs the command-line option @option{-foo}.
35007
35008@item %W@{S@}
35009Like %@{@code{S}@} but mark last argument supplied within as a file to be
35010deleted on failure.
35011
35012@item %@@@{S@}
35013Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
35014@code{@@FILE} if an @code{@@file} argument has been supplied.
35015
35016@item %@{S*@}
35017Substitutes all the switches specified to GCC whose names start
35018with @code{-S}, but which also take an argument. This is used for
35019switches like @option{-o}, @option{-D}, @option{-I}, etc.
35020GCC considers @option{-o foo} as being
35021one switch whose name starts with @samp{o}. %@{o*@} substitutes this
35022text, including the space. Thus two arguments are generated.
35023
35024@item %@{S*&T*@}
35025Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
35026(the order of @code{S} and @code{T} in the spec is not significant).
35027There can be any number of ampersand-separated variables; for each the
35028wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
35029
35030@item %@{S:X@}
35031Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
35032
35033@item %@{!S:X@}
35034Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
35035
35036@item %@{S*:X@}
35037Substitutes @code{X} if one or more switches whose names start with
35038@code{-S} are specified to GCC@. Normally @code{X} is substituted only
35039once, no matter how many such switches appeared. However, if @code{%*}
35040appears somewhere in @code{X}, then @code{X} is substituted once
35041for each matching switch, with the @code{%*} replaced by the part of
35042that switch matching the @code{*}.
35043
35044If @code{%*} appears as the last part of a spec sequence then a space
35045is added after the end of the last substitution. If there is more
35046text in the sequence, however, then a space is not generated. This
35047allows the @code{%*} substitution to be used as part of a larger
35048string. For example, a spec string like this:
35049
35050@smallexample
35051%@{mcu=*:--script=%*/memory.ld@}
35052@end smallexample
35053
35054@noindent
35055when matching an option like @option{-mcu=newchip} produces:
35056
35057@smallexample
35058--script=newchip/memory.ld
35059@end smallexample
35060
35061@item %@{.S:X@}
35062Substitutes @code{X}, if processing a file with suffix @code{S}.
35063
35064@item %@{!.S:X@}
35065Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
35066
35067@item %@{,S:X@}
35068Substitutes @code{X}, if processing a file for language @code{S}.
35069
35070@item %@{!,S:X@}
35071Substitutes @code{X}, if not processing a file for language @code{S}.
35072
35073@item %@{S|P:X@}
35074Substitutes @code{X} if either @code{-S} or @code{-P} is given to
35075GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
35076@code{*} sequences as well, although they have a stronger binding than
35077the @samp{|}. If @code{%*} appears in @code{X}, all of the
35078alternatives must be starred, and only the first matching alternative
35079is substituted.
35080
35081For example, a spec string like this:
35082
35083@smallexample
35084%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
35085@end smallexample
35086
35087@noindent
35088outputs the following command-line options from the following input
35089command-line options:
35090
35091@smallexample
35092fred.c -foo -baz
35093jim.d -bar -boggle
35094-d fred.c -foo -baz -boggle
35095-d jim.d -bar -baz -boggle
35096@end smallexample
35097
35098@item %@{%:@var{function}(@var{args}):X@}
35099
35100Call function named @var{function} with args @var{args}. If the
35101function returns non-NULL, then @code{X} is substituted, if it returns
35102NULL, it isn't substituted.
35103
35104@item %@{S:X; T:Y; :D@}
35105
35106If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
35107given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
35108be as many clauses as you need. This may be combined with @code{.},
35109@code{,}, @code{!}, @code{|}, and @code{*} as needed.
35110
35111
35112@end table
35113
35114The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
35115or similar construct can use a backslash to ignore the special meaning
35116of the character following it, thus allowing literal matching of a
35117character that is otherwise specially treated. For example,
35118@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
35119@option{-std=iso9899:1999} option is given.
35120
35121The conditional text @code{X} in a @samp{%@{S:X@}} or similar
35122construct may contain other nested @samp{%} constructs or spaces, or
35123even newlines. They are processed as usual, as described above.
35124Trailing white space in @code{X} is ignored. White space may also
35125appear anywhere on the left side of the colon in these constructs,
35126except between @code{.} or @code{*} and the corresponding word.
35127
35128The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
35129handled specifically in these constructs. If another value of
35130@option{-O} or the negated form of a @option{-f}, @option{-m}, or
35131@option{-W} switch is found later in the command line, the earlier
35132switch value is ignored, except with @{@code{S}*@} where @code{S} is
35133just one letter, which passes all matching options.
35134
35135The character @samp{|} at the beginning of the predicate text is used to
35136indicate that a command should be piped to the following command, but
35137only if @option{-pipe} is specified.
35138
35139It is built into GCC which switches take arguments and which do not.
35140(You might think it would be useful to generalize this to allow each
35141compiler's spec to say which switches take arguments. But this cannot
35142be done in a consistent fashion. GCC cannot even decide which input
35143files have been specified without knowing which switches take arguments,
35144and it must know which input files to compile in order to tell which
35145compilers to run).
35146
35147GCC also knows implicitly that arguments starting in @option{-l} are to be
35148treated as compiler output files, and passed to the linker in their
35149proper position among the other output files.
35150
35151@node Environment Variables
35152@section Environment Variables Affecting GCC
35153@cindex environment variables
35154
35155@c man begin ENVIRONMENT
35156This section describes several environment variables that affect how GCC
35157operates. Some of them work by specifying directories or prefixes to use
35158when searching for various kinds of files. Some are used to specify other
35159aspects of the compilation environment.
35160
35161Note that you can also specify places to search using options such as
35162@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
35163take precedence over places specified using environment variables, which
35164in turn take precedence over those specified by the configuration of GCC@.
35165@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
35166GNU Compiler Collection (GCC) Internals}.
35167
35168@table @env
f33d7a88
AA
35169@vindex LANG
35170@vindex LC_CTYPE
35171@c @vindex LC_COLLATE
35172@vindex LC_MESSAGES
35173@c @vindex LC_MONETARY
35174@c @vindex LC_NUMERIC
35175@c @vindex LC_TIME
35176@vindex LC_ALL
35177@cindex locale
d77de738
ML
35178@item LANG
35179@itemx LC_CTYPE
35180@c @itemx LC_COLLATE
35181@itemx LC_MESSAGES
35182@c @itemx LC_MONETARY
35183@c @itemx LC_NUMERIC
35184@c @itemx LC_TIME
35185@itemx LC_ALL
d77de738
ML
35186These environment variables control the way that GCC uses
35187localization information which allows GCC to work with different
35188national conventions. GCC inspects the locale categories
35189@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
35190so. These locale categories can be set to any value supported by your
35191installation. A typical value is @samp{en_GB.UTF-8} for English in the United
35192Kingdom encoded in UTF-8.
35193
35194The @env{LC_CTYPE} environment variable specifies character
35195classification. GCC uses it to determine the character boundaries in
35196a string; this is needed for some multibyte encodings that contain quote
35197and escape characters that are otherwise interpreted as a string
35198end or escape.
35199
35200The @env{LC_MESSAGES} environment variable specifies the language to
35201use in diagnostic messages.
35202
35203If the @env{LC_ALL} environment variable is set, it overrides the value
35204of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
35205and @env{LC_MESSAGES} default to the value of the @env{LANG}
35206environment variable. If none of these variables are set, GCC
35207defaults to traditional C English behavior.
35208
f33d7a88 35209@vindex TMPDIR
d77de738 35210@item TMPDIR
d77de738
ML
35211If @env{TMPDIR} is set, it specifies the directory to use for temporary
35212files. GCC uses temporary files to hold the output of one stage of
35213compilation which is to be used as input to the next stage: for example,
35214the output of the preprocessor, which is the input to the compiler
35215proper.
35216
f33d7a88 35217@vindex GCC_COMPARE_DEBUG
d77de738 35218@item GCC_COMPARE_DEBUG
d77de738
ML
35219Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
35220@option{-fcompare-debug} to the compiler driver. See the documentation
35221of this option for more details.
35222
f33d7a88 35223@vindex GCC_EXEC_PREFIX
d77de738 35224@item GCC_EXEC_PREFIX
d77de738
ML
35225If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
35226names of the subprograms executed by the compiler. No slash is added
35227when this prefix is combined with the name of a subprogram, but you can
35228specify a prefix that ends with a slash if you wish.
35229
35230If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
35231an appropriate prefix to use based on the pathname it is invoked with.
35232
35233If GCC cannot find the subprogram using the specified prefix, it
35234tries looking in the usual places for the subprogram.
35235
35236The default value of @env{GCC_EXEC_PREFIX} is
35237@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
35238the installed compiler. In many cases @var{prefix} is the value
35239of @code{prefix} when you ran the @file{configure} script.
35240
35241Other prefixes specified with @option{-B} take precedence over this prefix.
35242
35243This prefix is also used for finding files such as @file{crt0.o} that are
35244used for linking.
35245
35246In addition, the prefix is used in an unusual way in finding the
35247directories to search for header files. For each of the standard
35248directories whose name normally begins with @samp{/usr/local/lib/gcc}
35249(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
35250replacing that beginning with the specified prefix to produce an
35251alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
35252@file{foo/bar} just before it searches the standard directory
35253@file{/usr/local/lib/bar}.
35254If a standard directory begins with the configured
35255@var{prefix} then the value of @var{prefix} is replaced by
35256@env{GCC_EXEC_PREFIX} when looking for header files.
35257
f33d7a88 35258@vindex COMPILER_PATH
d77de738 35259@item COMPILER_PATH
d77de738
ML
35260The value of @env{COMPILER_PATH} is a colon-separated list of
35261directories, much like @env{PATH}. GCC tries the directories thus
35262specified when searching for subprograms, if it cannot find the
35263subprograms using @env{GCC_EXEC_PREFIX}.
35264
f33d7a88 35265@vindex LIBRARY_PATH
d77de738 35266@item LIBRARY_PATH
d77de738
ML
35267The value of @env{LIBRARY_PATH} is a colon-separated list of
35268directories, much like @env{PATH}. When configured as a native compiler,
35269GCC tries the directories thus specified when searching for special
35270linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35271using GCC also uses these directories when searching for ordinary
35272libraries for the @option{-l} option (but directories specified with
35273@option{-L} come first).
35274
f33d7a88 35275@vindex LANG
d77de738 35276@cindex locale definition
f33d7a88 35277@item LANG
d77de738
ML
35278This variable is used to pass locale information to the compiler. One way in
35279which this information is used is to determine the character set to be used
35280when character literals, string literals and comments are parsed in C and C++.
35281When the compiler is configured to allow multibyte characters,
35282the following values for @env{LANG} are recognized:
35283
35284@table @samp
35285@item C-JIS
35286Recognize JIS characters.
35287@item C-SJIS
35288Recognize SJIS characters.
35289@item C-EUCJP
35290Recognize EUCJP characters.
35291@end table
35292
35293If @env{LANG} is not defined, or if it has some other value, then the
35294compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35295recognize and translate multibyte characters.
35296
f33d7a88 35297@vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738 35298@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738
ML
35299If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
35300then additional text will be emitted to stderr when fix-it hints are
35301emitted. @option{-fdiagnostics-parseable-fixits} and
35302@option{-fno-diagnostics-parseable-fixits} take precedence over this
35303environment variable.
35304
35305@table @samp
35306@item fixits-v1
35307Emit parseable fix-it hints, equivalent to
35308@option{-fdiagnostics-parseable-fixits}. In particular, columns are
35309expressed as a count of bytes, starting at byte 1 for the initial column.
35310
35311@item fixits-v2
35312As @code{fixits-v1}, but columns are expressed as display columns,
35313as per @option{-fdiagnostics-column-unit=display}.
35314@end table
35315
35316@end table
35317
35318@noindent
35319Some additional environment variables affect the behavior of the
35320preprocessor.
35321
35322@include cppenv.texi
35323
35324@c man end
35325
35326@node Precompiled Headers
35327@section Using Precompiled Headers
35328@cindex precompiled headers
35329@cindex speed of compilation
35330
35331Often large projects have many header files that are included in every
35332source file. The time the compiler takes to process these header files
35333over and over again can account for nearly all of the time required to
35334build the project. To make builds faster, GCC allows you to
35335@dfn{precompile} a header file.
35336
35337To create a precompiled header file, simply compile it as you would any
35338other file, if necessary using the @option{-x} option to make the driver
35339treat it as a C or C++ header file. You may want to use a
35340tool like @command{make} to keep the precompiled header up-to-date when
35341the headers it contains change.
35342
35343A precompiled header file is searched for when @code{#include} is
35344seen in the compilation. As it searches for the included file
35345(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
35346compiler looks for a precompiled header in each directory just before it
35347looks for the include file in that directory. The name searched for is
35348the name specified in the @code{#include} with @samp{.gch} appended. If
35349the precompiled header file cannot be used, it is ignored.
35350
35351For instance, if you have @code{#include "all.h"}, and you have
35352@file{all.h.gch} in the same directory as @file{all.h}, then the
35353precompiled header file is used if possible, and the original
35354header is used otherwise.
35355
35356Alternatively, you might decide to put the precompiled header file in a
35357directory and use @option{-I} to ensure that directory is searched
35358before (or instead of) the directory containing the original header.
35359Then, if you want to check that the precompiled header file is always
35360used, you can put a file of the same name as the original header in this
35361directory containing an @code{#error} command.
35362
35363This also works with @option{-include}. So yet another way to use
35364precompiled headers, good for projects not designed with precompiled
35365header files in mind, is to simply take most of the header files used by
35366a project, include them from another header file, precompile that header
35367file, and @option{-include} the precompiled header. If the header files
35368have guards against multiple inclusion, they are skipped because
35369they've already been included (in the precompiled header).
35370
35371If you need to precompile the same header file for different
35372languages, targets, or compiler options, you can instead make a
35373@emph{directory} named like @file{all.h.gch}, and put each precompiled
35374header in the directory, perhaps using @option{-o}. It doesn't matter
35375what you call the files in the directory; every precompiled header in
35376the directory is considered. The first precompiled header
35377encountered in the directory that is valid for this compilation is
35378used; they're searched in no particular order.
35379
35380There are many other possibilities, limited only by your imagination,
35381good sense, and the constraints of your build system.
35382
35383A precompiled header file can be used only when these conditions apply:
35384
35385@itemize
35386@item
35387Only one precompiled header can be used in a particular compilation.
35388
35389@item
35390A precompiled header cannot be used once the first C token is seen. You
35391can have preprocessor directives before a precompiled header; you cannot
35392include a precompiled header from inside another header.
35393
35394@item
35395The precompiled header file must be produced for the same language as
35396the current compilation. You cannot use a C precompiled header for a C++
35397compilation.
35398
35399@item
35400The precompiled header file must have been produced by the same compiler
35401binary as the current compilation is using.
35402
35403@item
35404Any macros defined before the precompiled header is included must
35405either be defined in the same way as when the precompiled header was
35406generated, or must not affect the precompiled header, which usually
35407means that they don't appear in the precompiled header at all.
35408
35409The @option{-D} option is one way to define a macro before a
35410precompiled header is included; using a @code{#define} can also do it.
35411There are also some options that define macros implicitly, like
35412@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35413defined this way.
35414
35415@item If debugging information is output when using the precompiled
35416header, using @option{-g} or similar, the same kind of debugging information
35417must have been output when building the precompiled header. However,
35418a precompiled header built using @option{-g} can be used in a compilation
35419when no debugging information is being output.
35420
35421@item The same @option{-m} options must generally be used when building
35422and using the precompiled header. @xref{Submodel Options},
35423for any cases where this rule is relaxed.
35424
35425@item Each of the following options must be the same when building and using
35426the precompiled header:
35427
35428@gccoptlist{-fexceptions}
35429
35430@item
35431Some other command-line options starting with @option{-f},
35432@option{-p}, or @option{-O} must be defined in the same way as when
35433the precompiled header was generated. At present, it's not clear
35434which options are safe to change and which are not; the safest choice
35435is to use exactly the same options when generating and using the
35436precompiled header. The following are known to be safe:
35437
43b72ede
AA
35438@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock
35439-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous
35440-fsched-verbose=@var{number} -fschedule-insns -fvisibility=
d77de738
ML
35441-pedantic-errors}
35442
35443@item Address space layout randomization (ASLR) can lead to not binary identical
35444PCH files. If you rely on stable PCH file contents disable ASLR when generating
35445PCH files.
35446
35447@end itemize
35448
35449For all of these except the last, the compiler automatically
35450ignores the precompiled header if the conditions aren't met. If you
35451find an option combination that doesn't work and doesn't cause the
35452precompiled header to be ignored, please consider filing a bug report,
35453see @ref{Bugs}.
35454
35455If you do use differing options when generating and using the
35456precompiled header, the actual behavior is a mixture of the
35457behavior for the options. For instance, if you use @option{-g} to
35458generate the precompiled header but not when using it, you may or may
35459not get debugging information for routines in the precompiled header.
35460
35461@node C++ Modules
35462@section C++ Modules
35463@cindex speed of compilation
35464
35465Modules are a C++20 language feature. As the name suggests, they
35466provides a modular compilation system, intending to provide both
35467faster builds and better library isolation. The ``Merging Modules''
35468paper @uref{https://wg21.link/p1103}, provides the easiest to read set
35469of changes to the standard, although it does not capture later
35470changes.
35471
35472@emph{G++'s modules support is not complete.} Other than bugs, the
35473known missing pieces are:
35474
35475@table @emph
35476
35477@item Private Module Fragment
35478The Private Module Fragment is recognized, but an error is emitted.
35479
35480@item Partition definition visibility rules
35481Entities may be defined in implementation partitions, and those
35482definitions are not available outside of the module. This is not
35483implemented, and the definitions are available to extra-module use.
35484
35485@item Textual merging of reachable GM entities
35486Entities may be multiply defined across different header-units.
35487These must be de-duplicated, and this is implemented across imports,
35488or when an import redefines a textually-defined entity. However the
35489reverse is not implemented---textually redefining an entity that has
35490been defined in an imported header-unit. A redefinition error is
35491emitted.
35492
35493@item Translation-Unit local referencing rules
35494Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
35495(@uref{https://wg21.link/p2003}) add limitations on which entities an
35496exported region may reference (for instance, the entities an exported
35497template definition may reference). These are not fully implemented.
35498
35499@item Standard Library Header Units
35500The Standard Library is not provided as importable header units. If
35501you want to import such units, you must explicitly build them first.
35502If you do not do this with care, you may have multiple declarations,
35503which the module machinery must merge---compiler resource usage can be
35504affected by how you partition header files into header units.
35505
35506@end table
35507
35508Modular compilation is @emph{not} enabled with just the
35509@option{-std=c++20} option. You must explicitly enable it with the
35510@option{-fmodules-ts} option. It is independent of the language
35511version selected, although in pre-C++20 versions, it is of course an
35512extension.
35513
35514No new source file suffixes are required or supported. If you wish to
35515use a non-standard suffix (@pxref{Overall Options}), you also need
35516to provide a @option{-x c++} option too.@footnote{Some users like to
35517distinguish module interface files with a new suffix, such as naming
35518the source @code{module.cppm}, which involves
35519teaching all tools about the new suffix. A different scheme, such as
35520naming @code{module-m.cpp} would be less invasive.}
35521
35522Compiling a module interface unit produces an additional output (to
35523the assembly or object file), called a Compiled Module Interface
35524(CMI). This encodes the exported declarations of the module.
35525Importing a module reads in the CMI. The import graph is a Directed
35526Acyclic Graph (DAG). You must build imports before the importer.
35527
35528Header files may themselves be compiled to header units, which are a
35529transitional ability aiming at faster compilation. The
35530@option{-fmodule-header} option is used to enable this, and implies
35531the @option{-fmodules-ts} option. These CMIs are named by the fully
35532resolved underlying header file, and thus may be a complete pathname
35533containing subdirectories. If the header file is found at an absolute
35534pathname, the CMI location is still relative to a CMI root directory.
35535
35536As header files often have no suffix, you commonly have to specify a
35537@option{-x} option to tell the compiler the source is a header file.
35538You may use @option{-x c++-header}, @option{-x c++-user-header} or
35539@option{-x c++-system-header}. When used in conjunction with
35540@option{-fmodules-ts}, these all imply an appropriate
35541@option{-fmodule-header} option. The latter two variants use the
35542user or system include path to search for the file specified. This
35543allows you to, for instance, compile standard library header files as
35544header units, without needing to know exactly where they are
35545installed. Specifying the language as one of these variants also
35546inhibits output of the object file, as header files have no associated
35547object file.
35548
35549The @option{-fmodule-only} option disables generation of the
35550associated object file for compiling a module interface. Only the CMI
35551is generated. This option is implied when using the
35552@option{-fmodule-header} option.
35553
35554The @option{-flang-info-include-translate} and
35555@option{-flang-info-include-translate-not} options notes whether
35556include translation occurs or not. With no argument, the first will
35557note all include translation. The second will note all
35558non-translations of include files not known to intentionally be
35559textual. With an argument, queries about include translation of a
35560header files with that particular trailing pathname are noted. You
35561may repeat this form to cover several different header files. This
35562option may be helpful in determining whether include translation is
35563happening---if it is working correctly, it behaves as if it isn't
35564there at all.
35565
35566The @option{-flang-info-module-cmi} option can be used to determine
35567where the compiler is reading a CMI from. Without the option, the
35568compiler is silent when such a read is successful. This option has an
35569optional argument, which will restrict the notification to just the
35570set of named modules or header units specified.
35571
35572The @option{-Winvalid-imported-macros} option causes all imported macros
35573to be resolved at the end of compilation. Without this, imported
35574macros are only resolved when expanded or (re)defined. This option
35575detects conflicting import definitions for all macros.
35576
35577For details of the @option{-fmodule-mapper} family of options,
35578@pxref{C++ Module Mapper}.
35579
35580@menu
35581* C++ Module Mapper:: Module Mapper
35582* C++ Module Preprocessing:: Module Preprocessing
35583* C++ Compiled Module Interface:: Compiled Module Interface
35584@end menu
35585
35586@node C++ Module Mapper
35587@subsection Module Mapper
35588@cindex C++ Module Mapper
35589
35590A module mapper provides a server or file that the compiler queries to
35591determine the mapping between module names and CMI files. It is also
35592used to build CMIs on demand. @emph{Mapper functionality is in its
35593infancy and is intended for experimentation with build system
35594interactions.}
35595
35596You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
35597option or @env{CXX_MODULE_MAPPER} environment variable. The value may
35598have one of the following forms:
35599
35600@table @gcctabopt
35601
35602@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
35603An optional hostname and a numeric port number to connect to. If the
35604hostname is omitted, the loopback address is used. If the hostname
35605corresponds to multiple IPV6 addresses, these are tried in turn, until
35606one is successful. If your host lacks IPv6, this form is
35607non-functional. If you must use IPv4 use
35608@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
35609
35610@item =@var{socket}@r{[}?@var{ident}@r{]}
35611A local domain socket. If your host lacks local domain sockets, this
35612form is non-functional.
35613
35614@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
35615A program to spawn, and communicate with on its stdin/stdout streams.
35616Your @var{PATH} environment variable is searched for the program.
35617Arguments are separated by space characters, (it is not possible for
35618one of the arguments delivered to the program to contain a space). An
35619exception is if @var{program} begins with @@. In that case
35620@var{program} (sans @@) is looked for in the compiler's internal
35621binary directory. Thus the sample mapper-server can be specified
35622with @code{@@g++-mapper-server}.
35623
35624@item <>@r{[}?@var{ident}@r{]}
35625@item <>@var{inout}@r{[}?@var{ident}@r{]}
35626@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
35627Named pipes or file descriptors to communicate over. The first form,
35628@option{<>}, communicates over stdin and stdout. The other forms
35629allow you to specify a file descriptor or name a pipe. A numeric value
35630is interpreted as a file descriptor, otherwise named pipe is opened.
35631The second form specifies a bidirectional pipe and the last form
35632allows specifying two independent pipes. Using file descriptors
35633directly in this manner is fragile in general, as it can require the
35634cooperation of intermediate processes. In particular using stdin &
35635stdout is fraught with danger as other compiler options might also
35636cause the compiler to read stdin or write stdout, and it can have
35637unfortunate interactions with signal delivery from the terminal.
35638
35639@item @var{file}@r{[}?@var{ident}@r{]}
35640A mapping file consisting of space-separated module-name, filename
35641pairs, one per line. Only the mappings for the direct imports and any
35642module export name need be provided. If other mappings are provided,
35643they override those stored in any imported CMI files. A repository
35644root may be specified in the mapping file by using @samp{$root} as the
35645module name in the first active line. Use of this option will disable
35646any default module->CMI name mapping.
35647
35648@end table
35649
35650As shown, an optional @var{ident} may suffix the first word of the
35651option, indicated by a @samp{?} prefix. The value is used in the
35652initial handshake with the module server, or to specify a prefix on
35653mapping file lines. In the server case, the main source file name is
35654used if no @var{ident} is specified. In the file case, all non-blank
35655lines are significant, unless a value is specified, in which case only
35656lines beginning with @var{ident} are significant. The @var{ident}
35657must be separated by whitespace from the module name. Be aware that
35658@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
35659significant to the shell, and therefore may need quoting.
35660
35661The mapper is connected to or loaded lazily, when the first module
35662mapping is required. The networking protocols are only supported on
35663hosts that provide networking. If no mapper is specified a default is
35664provided.
35665
35666A project-specific mapper is expected to be provided by the build
35667system that invokes the compiler. It is not expected that a
35668general-purpose server is provided for all compilations. As such, the
35669server will know the build configuration, the compiler it invoked, and
35670the environment (such as working directory) in which that is
35671operating. As it may parallelize builds, several compilations may
35672connect to the same socket.
35673
35674The default mapper generates CMI files in a @samp{gcm.cache}
35675directory. CMI files have a @samp{.gcm} suffix. The module unit name
35676is used directly to provide the basename. Header units construct a
35677relative path using the underlying header file name. If the path is
35678already relative, a @samp{,} directory is prepended. Internal
35679@samp{..} components are translated to @samp{,,}. No attempt is made
35680to canonicalize these filenames beyond that done by the preprocessor's
35681include search algorithm, as in general it is ambiguous when symbolic
35682links are present.
35683
35684The mapper protocol was published as ``A Module Mapper''
35685@uref{https://wg21.link/p1184}. The implementation is provided by
35686@command{libcody}, @uref{https://github.com/urnathan/libcody},
35687which specifies the canonical protocol definition. A proof of concept
35688server implementation embedded in @command{make} was described in
35689''Make Me A Module'', @uref{https://wg21.link/p1602}.
35690
35691@node C++ Module Preprocessing
35692@subsection Module Preprocessing
35693@cindex C++ Module Preprocessing
35694
35695Modules affect preprocessing because of header units and include
35696translation. Some uses of the preprocessor as a separate step either
35697do not produce a correct output, or require CMIs to be available.
35698
35699Header units import macros. These macros can affect later conditional
35700inclusion, which therefore can cascade to differing import sets. When
35701preprocessing, it is necessary to load the CMI. If a header unit is
35702unavailable, the preprocessor issues a warning and continue (when
35703not just preprocessing, an error is emitted). Detecting such imports
35704requires preprocessor tokenization of the input stream to phase 4
35705(macro expansion).
35706
35707Include translation converts @code{#include}, @code{#include_next} and
35708@code{#import} directives to internal @code{import} declarations.
35709Whether a particular directive is translated is controlled by the
35710module mapper. Header unit names are canonicalized during
35711preprocessing.
35712
35713Dependency information can be emitted for macro import, extending the
35714functionality of @option{-MD} and @option{-MMD} options. Detection of
35715import declarations also requires phase 4 preprocessing, and thus
35716requires full preprocessing (or compilation).
35717
35718The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
35719preprocessing before phase 4.
35720
35721The @option{-save-temps} option uses @option{-fdirectives-only} for
35722preprocessing, and preserve the macro definitions in the preprocessed
35723output. Usually you also want to use this option when explicitly
35724preprocessing a header-unit, or consuming such preprocessed output:
35725
35726@smallexample
35727g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
35728g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
35729@end smallexample
35730
35731@node C++ Compiled Module Interface
35732@subsection Compiled Module Interface
35733@cindex C++ Compiled Module Interface
35734
35735CMIs are an additional artifact when compiling named module
35736interfaces, partitions or header units. These are read when
35737importing. CMI contents are implementation-specific, and in GCC's
35738case tied to the compiler version. Consider them a rebuildable cache
35739artifact, not a distributable object.
35740
35741When creating an output CMI, any missing directory components are
35742created in a manner that is safe for concurrent builds creating
35743multiple, different, CMIs within a common subdirectory tree.
35744
35745CMI contents are written to a temporary file, which is then atomically
35746renamed. Observers either see old contents (if there is an
35747existing file), or complete new contents. They do not observe the
35748CMI during its creation. This is unlike object file writing, which
35749may be observed by an external process.
35750
35751CMIs are read in lazily, if the host OS provides @code{mmap}
35752functionality. Generally blocks are read when name lookup or template
35753instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
35754option may be used.
35755
35756The @option{--param lazy-modules=@var{n}} parameter controls the limit
35757on the number of concurrently open module files during lazy loading.
35758Should more modules be imported, an LRU algorithm is used to determine
35759which files to close---until that file is needed again. This limit
35760may be exceeded with deep module dependency hierarchies. With large
35761code bases there may be more imports than the process limit of file
35762descriptors. By default, the limit is a few less than the per-process
35763file descriptor hard limit, if that is determinable.@footnote{Where
35764applicable the soft limit is incremented as needed towards the hard limit.}
35765
35766GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
35767You may use @command{readelf} to inspect them, although section
35768contents are largely undecipherable. There is a section named
35769@code{.gnu.c++.README}, which contains human-readable text. Other
35770than the first line, each line consists of @code{@var{tag}: @code{value}}
35771tuples.
35772
35773@smallexample
35774> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
35775
35776String dump of section '.gnu.c++.README':
35777 [ 0] GNU C++ primary module interface
35778 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
35779 [ 6f] version: 2020/11/16-04:54
35780 [ 89] module: foo
35781 [ 95] source: c_b.ii
35782 [ a4] dialect: C++20/coroutines
35783 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
35784 [ ee] repository: gcm.cache
35785 [ 104] buildtime: 2020/11/16 15:03:21 UTC
35786 [ 127] localtime: 2020/11/16 07:03:21 PST
35787 [ 14a] export: foo:part1 foo-part1.gcm
35788@end smallexample
35789
35790Amongst other things, this lists the source that was built, C++
35791dialect used and imports of the module.@footnote{The precise contents
35792of this output may change.} The timestamp is the same value as that
35793provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
35794explicitly specified with the environment variable
35795@code{SOURCE_DATE_EPOCH}. For further details
35796@pxref{Environment Variables}.
35797
35798A set of related CMIs may be copied, provided the relative pathnames
35799are preserved.
35800
35801The @code{.gnu.c++.README} contents do not affect CMI integrity, and
35802it may be removed or altered. The section numbering of the sections
35803whose names do not begin with @code{.gnu.c++.}, or are not the string
35804section is significant and must not be altered.