]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
doc: Update texinfo.tex
[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}.
189@gccoptlist{-c -S -E -o @var{file} @gol
190-dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf} @gol
191-dumpdir @var{dumppfx} -x @var{language} @gol
192-v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version @gol
193-pass-exit-codes -pipe -specs=@var{file} -wrapper @gol
2eb0191a 194@@@var{file} -ffile-prefix-map=@var{old}=@var{new} -fcanon-prefix-map @gol
d77de738
ML
195-fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg} @gol
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}.
200@gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol
201-fno-asm @gol
202-fno-builtin -fno-builtin-@var{function} -fcond-mismatch @gol
203-ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted @gol
204-flax-vector-conversions -fms-extensions @gol
205-foffload=@var{arg} -foffload-options=@var{arg} @gol
206-fopenacc -fopenacc-dim=@var{geom} @gol
309e2d95 207-fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]} @gol
d77de738
ML
208-fpermitted-flt-eval-methods=@var{standard} @gol
209-fplan9-extensions -fsigned-bitfields -funsigned-bitfields @gol
210-fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}] @gol
211-fsso-struct=@var{endianness}}
212
213@item C++ Language Options
214@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
215@gccoptlist{-fabi-version=@var{n} -fno-access-control @gol
216-faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new @gol
217-fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n} @gol
218-fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n} @gol
219-fno-elide-constructors @gol
220-fno-enforce-eh-specs @gol
221-fno-gnu-keywords @gol
222-fno-implicit-templates @gol
223-fno-implicit-inline-templates @gol
224-fno-implement-inlines @gol
225-fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts @gol
226-fmodule-implicit-inline @gol
227-fno-module-lazy @gol
228-fmodule-mapper=@var{specification} @gol
229-fmodule-version-ignore @gol
230-fms-extensions @gol
231-fnew-inheriting-ctors @gol
232-fnew-ttp-matching @gol
233-fno-nonansi-builtins -fnothrow-opt -fno-operator-names @gol
234-fno-optional-diags -fpermissive @gol
235-fno-pretty-templates @gol
236-fno-rtti -fsized-deallocation @gol
237-ftemplate-backtrace-limit=@var{n} @gol
238-ftemplate-depth=@var{n} @gol
239-fno-threadsafe-statics -fuse-cxa-atexit @gol
240-fno-weak -nostdinc++ @gol
241-fvisibility-inlines-hidden @gol
242-fvisibility-ms-compat @gol
243-fext-numeric-literals @gol
244-flang-info-include-translate@r{[}=@var{header}@r{]} @gol
245-flang-info-include-translate-not @gol
246-flang-info-module-cmi@r{[}=@var{module}@r{]} @gol
247-stdlib=@var{libstdc++,libc++} @gol
248-Wabi-tag -Wcatch-value -Wcatch-value=@var{n} @gol
249-Wno-class-conversion -Wclass-memaccess @gol
250-Wcomma-subscript -Wconditionally-supported @gol
251-Wno-conversion-null -Wctad-maybe-unsupported @gol
252-Wctor-dtor-privacy -Wdangling-reference @gol
253-Wno-delete-incomplete @gol
254-Wdelete-non-virtual-dtor -Wno-deprecated-array-compare @gol
255-Wdeprecated-copy -Wdeprecated-copy-dtor @gol
256-Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion @gol
257-Weffc++ -Wno-exceptions -Wextra-semi -Wno-inaccessible-base @gol
258-Wno-inherited-variadic-ctor -Wno-init-list-lifetime @gol
c85f8dbb 259-Winvalid-constexpr -Winvalid-imported-macros @gol
d77de738
ML
260-Wno-invalid-offsetof -Wno-literal-suffix @gol
261-Wmismatched-new-delete -Wmismatched-tags @gol
262-Wmultiple-inheritance -Wnamespaces -Wnarrowing @gol
263-Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor @gol
264-Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} @gol
265-Wrange-loop-construct -Wredundant-move -Wredundant-tags @gol
266-Wreorder -Wregister @gol
267-Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates @gol
268-Wno-non-template-friend -Wold-style-cast @gol
269-Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo @gol
270-Wsized-deallocation -Wsuggest-final-methods @gol
271-Wsuggest-final-types -Wsuggest-override @gol
272-Wno-terminate -Wuseless-cast -Wno-vexing-parse @gol
273-Wvirtual-inheritance @gol
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}.
279@gccoptlist{-fconstant-string-class=@var{class-name} @gol
280-fgnu-runtime -fnext-runtime @gol
281-fno-nil-receivers @gol
282-fobjc-abi-version=@var{n} @gol
283-fobjc-call-cxx-cdtors @gol
284-fobjc-direct-dispatch @gol
285-fobjc-exceptions @gol
286-fobjc-gc @gol
287-fobjc-nilcheck @gol
288-fobjc-std=objc1 @gol
289-fno-local-ivars @gol
290-fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} @gol
291-freplace-objc-classes @gol
292-fzero-link @gol
293-gen-decls @gol
294-Wassign-intercept -Wno-property-assign-default @gol
295-Wno-protocol -Wobjc-root-class -Wselector @gol
296-Wstrict-selector-match @gol
297-Wundeclared-selector}
298
299@item Diagnostic Message Formatting Options
300@xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}.
301@gccoptlist{-fmessage-length=@var{n} @gol
302-fdiagnostics-plain-output @gol
303-fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} @gol
304-fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]} @gol
305-fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]} @gol
306-fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]} @gol
307-fno-diagnostics-show-option -fno-diagnostics-show-caret @gol
308-fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers @gol
309-fno-diagnostics-show-cwe @gol
310-fno-diagnostics-show-rule @gol
311-fdiagnostics-minimum-margin-width=@var{width} @gol
312-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch @gol
313-fdiagnostics-show-template-tree -fno-elide-type @gol
314-fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]} @gol
315-fdiagnostics-show-path-depths @gol
316-fno-show-column @gol
317-fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} @gol
318-fdiagnostics-column-origin=@var{origin} @gol
319-fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}}
320
321@item Warning Options
322@xref{Warning Options,,Options to Request or Suppress Warnings}.
323@gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic @gol
324-pedantic-errors @gol
325-w -Wextra -Wall -Wabi=@var{n} @gol
326-Waddress -Wno-address-of-packed-member -Waggregate-return @gol
327-Walloc-size-larger-than=@var{byte-size} -Walloc-zero @gol
328-Walloca -Walloca-larger-than=@var{byte-size} @gol
329-Wno-aggressive-loop-optimizations @gol
330-Warith-conversion @gol
331-Warray-bounds -Warray-bounds=@var{n} -Warray-compare @gol
332-Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias @gol
333-Wno-attribute-warning @gol
334-Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} @gol
335-Wbool-compare -Wbool-operation @gol
336-Wno-builtin-declaration-mismatch @gol
337-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat @gol
338-Wc11-c2x-compat @gol
339-Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat @gol
340-Wc++20-compat @gol
341-Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions @gol
342-Wno-c++20-extensions -Wno-c++23-extensions @gol
343-Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual @gol
344-Wchar-subscripts @gol
345-Wclobbered -Wcomment @gol
320dc51c 346-Wno-complain-wrong-lang @gol
d77de738
ML
347-Wconversion -Wno-coverage-mismatch -Wno-cpp @gol
348-Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} @gol
349-Wdate-time @gol
350-Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init @gol
351-Wdisabled-optimization @gol
352-Wno-discarded-array-qualifiers -Wno-discarded-qualifiers @gol
353-Wno-div-by-zero -Wdouble-promotion @gol
354-Wduplicated-branches -Wduplicated-cond @gol
355-Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion @gol
356-Wenum-int-mismatch @gol
357-Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors @gol
358-Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 @gol
359-Wno-format-contains-nul -Wno-format-extra-args @gol
360-Wformat-nonliteral -Wformat-overflow=@var{n} @gol
361-Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} @gol
362-Wformat-y2k -Wframe-address @gol
363-Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object @gol
364-Wno-if-not-aligned -Wno-ignored-attributes @gol
365-Wignored-qualifiers -Wno-incompatible-pointer-types @gol
366-Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} @gol
367-Wno-implicit-function-declaration -Wno-implicit-int @gol
368-Winfinite-recursion @gol
369-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context @gol
370-Wno-int-to-pointer-cast -Wno-invalid-memory-model @gol
371-Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init @gol
372-Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op @gol
373-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized @gol
374-Wmemset-elt-size -Wmemset-transposed-args @gol
375-Wmisleading-indentation -Wmissing-attributes -Wmissing-braces @gol
376-Wmissing-field-initializers -Wmissing-format-attribute @gol
377-Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile @gol
378-Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare @gol
379-Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
380-Wnull-dereference -Wno-odr @gol
381-Wopenacc-parallelism @gol
382-Wopenmp-simd @gol
383-Wno-overflow -Woverlength-strings -Wno-override-init-side-effects @gol
384-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol
385-Wparentheses -Wno-pedantic-ms-format @gol
386-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol
387-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
388-Wrestrict -Wno-return-local-addr -Wreturn-type @gol
389-Wno-scalar-storage-order -Wsequence-point @gol
390-Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local @gol
391-Wno-shadow-ivar @gol
392-Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value @gol
393-Wno-shift-overflow -Wshift-overflow=@var{n} @gol
394-Wsign-compare -Wsign-conversion @gol
395-Wno-sizeof-array-argument @gol
396-Wsizeof-array-div @gol
397-Wsizeof-pointer-div -Wsizeof-pointer-memaccess @gol
398-Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing @gol
399-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
400-Wstring-compare @gol
401-Wno-stringop-overflow -Wno-stringop-overread @gol
2a27ae32 402-Wno-stringop-truncation -Wstrict-flex-arrays @gol
d77de738
ML
403-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} @gol
404-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum @gol
405-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand @gol
406-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol
407-Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef @gol
408-Wuninitialized -Wunknown-pragmas @gol
409-Wunsuffixed-float-constants -Wunused @gol
410-Wunused-but-set-parameter -Wunused-but-set-variable @gol
411-Wunused-const-variable -Wunused-const-variable=@var{n} @gol
412-Wunused-function -Wunused-label -Wunused-local-typedefs @gol
413-Wunused-macros @gol
414-Wunused-parameter -Wno-unused-result @gol
415-Wunused-value -Wunused-variable @gol
416-Wno-varargs -Wvariadic-macros @gol
417-Wvector-operation-performance @gol
418-Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than @gol
419-Wvolatile-register-var -Wwrite-strings @gol
420-Wxor-used-as-pow @gol
421-Wzero-length-bounds}
422
423@item Static Analyzer Options
424@gccoptlist{
425-fanalyzer @gol
426-fanalyzer-call-summaries @gol
427-fanalyzer-checker=@var{name} @gol
428-fno-analyzer-feasibility @gol
429-fanalyzer-fine-grained @gol
430-fno-analyzer-state-merge @gol
431-fno-analyzer-state-purge @gol
8f636915 432-fno-analyzer-suppress-followups @gol
d77de738
ML
433-fanalyzer-transitivity @gol
434-fno-analyzer-undo-inlining @gol
435-fanalyzer-verbose-edges @gol
436-fanalyzer-verbose-state-changes @gol
437-fanalyzer-verbosity=@var{level} @gol
438-fdump-analyzer @gol
439-fdump-analyzer-callgraph @gol
440-fdump-analyzer-exploded-graph @gol
441-fdump-analyzer-exploded-nodes @gol
442-fdump-analyzer-exploded-nodes-2 @gol
443-fdump-analyzer-exploded-nodes-3 @gol
444-fdump-analyzer-exploded-paths @gol
445-fdump-analyzer-feasibility @gol
446-fdump-analyzer-json @gol
447-fdump-analyzer-state-purge @gol
448-fdump-analyzer-stderr @gol
449-fdump-analyzer-supergraph @gol
450-fdump-analyzer-untracked @gol
451-Wno-analyzer-double-fclose @gol
452-Wno-analyzer-double-free @gol
453-Wno-analyzer-exposure-through-output-file @gol
454-Wno-analyzer-exposure-through-uninit-copy @gol
455-Wno-analyzer-fd-access-mode-mismatch @gol
456-Wno-analyzer-fd-double-close @gol
457-Wno-analyzer-fd-leak @gol
86a90006
DM
458-Wno-analyzer-fd-phase-mismatch @gol
459-Wno-analyzer-fd-type-mismatch @gol
d77de738
ML
460-Wno-analyzer-fd-use-after-close @gol
461-Wno-analyzer-fd-use-without-check @gol
462-Wno-analyzer-file-leak @gol
463-Wno-analyzer-free-of-non-heap @gol
464-Wno-analyzer-imprecise-fp-arithmetic @gol
ce51e843 465-Wno-analyzer-infinite-recursion @gol
d77de738
ML
466-Wno-analyzer-jump-through-null @gol
467-Wno-analyzer-malloc-leak @gol
468-Wno-analyzer-mismatching-deallocation @gol
469-Wno-analyzer-null-argument @gol
470-Wno-analyzer-null-dereference @gol
471-Wno-analyzer-out-of-bounds @gol
472-Wno-analyzer-possible-null-argument @gol
473-Wno-analyzer-possible-null-dereference @gol
474-Wno-analyzer-putenv-of-auto-var @gol
475-Wno-analyzer-shift-count-negative @gol
476-Wno-analyzer-shift-count-overflow @gol
477-Wno-analyzer-stale-setjmp-buffer @gol
478-Wno-analyzer-tainted-allocation-size @gol
ce51e843 479-Wno-analyzer-tainted-assertion @gol
d77de738
ML
480-Wno-analyzer-tainted-array-index @gol
481-Wno-analyzer-tainted-divisor @gol
482-Wno-analyzer-tainted-offset @gol
483-Wno-analyzer-tainted-size @gol
484-Wanalyzer-too-complex @gol
485-Wno-analyzer-unsafe-call-within-signal-handler @gol
486-Wno-analyzer-use-after-free @gol
487-Wno-analyzer-use-of-pointer-in-stale-stack-frame @gol
488-Wno-analyzer-use-of-uninitialized-value @gol
489-Wno-analyzer-va-arg-type-mismatch @gol
490-Wno-analyzer-va-list-exhausted @gol
491-Wno-analyzer-va-list-leak @gol
492-Wno-analyzer-va-list-use-after-va-end @gol
493-Wno-analyzer-write-to-const @gol
494-Wno-analyzer-write-to-string-literal @gol
495}
496
497@item C and Objective-C-only Warning Options
498@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
499-Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs @gol
500-Wold-style-declaration -Wold-style-definition @gol
501-Wstrict-prototypes -Wtraditional -Wtraditional-conversion @gol
502-Wdeclaration-after-statement -Wpointer-sign}
503
504@item Debugging Options
505@xref{Debugging Options,,Options for Debugging Your Program}.
506@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} @gol
507-gbtf -gctf -gctf@var{level} @gol
508-ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol
509-gstrict-dwarf -gno-strict-dwarf @gol
510-gas-loc-support -gno-as-loc-support @gol
511-gas-locview-support -gno-as-locview-support @gol
512-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol
513-gstatement-frontiers -gno-statement-frontiers @gol
514-gvariable-location-views -gno-variable-location-views @gol
515-ginternal-reset-location-views -gno-internal-reset-location-views @gol
516-ginline-points -gno-inline-points @gol
517-gvms -gz@r{[}=@var{type}@r{]} @gol
518-gsplit-dwarf -gdescribe-dies -gno-describe-dies @gol
519-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section @gol
520-fno-eliminate-unused-debug-types @gol
521-femit-struct-debug-baseonly -femit-struct-debug-reduced @gol
522-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol
523-fno-eliminate-unused-debug-symbols -femit-class-debug-always @gol
524-fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol
525-fvar-tracking -fvar-tracking-assignments}
526
527@item Optimization Options
528@xref{Optimize Options,,Options that Control Optimization}.
529@gccoptlist{-faggressive-loop-optimizations @gol
530-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
531-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
532-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
533-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
534-fno-allocation-dce -fallow-store-data-races @gol
535-fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol
536-fauto-inc-dec -fbranch-probabilities @gol
537-fcaller-saves @gol
538-fcombine-stack-adjustments -fconserve-stack @gol
539-fcompare-elim -fcprop-registers -fcrossjumping @gol
540-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
541-fcx-limited-range @gol
542-fdata-sections -fdce -fdelayed-branch @gol
543-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively @gol
544-fdevirtualize-at-ltrans -fdse @gol
545-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects @gol
546-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol
547-ffinite-loops @gol
548-fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol
549-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity @gol
550-fgcse-sm -fhoist-adjacent-loads -fif-conversion @gol
551-fif-conversion2 -findirect-inlining @gol
552-finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
553-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone @gol
554-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const @gol
555-fipa-reference -fipa-reference-addressable @gol
556-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} @gol
557-flive-patching=@var{level} @gol
558-fira-region=@var{region} -fira-hoist-pressure @gol
559-fira-loop-pressure -fno-ira-share-save-slots @gol
560-fno-ira-share-spill-slots @gol
561-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute @gol
562-fivopts -fkeep-inline-functions -fkeep-static-functions @gol
563-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage @gol
564-floop-block -floop-interchange -floop-strip-mine @gol
565-floop-unroll-and-jam -floop-nest-optimize @gol
566-floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
567-flto-partition=@var{alg} -fmerge-all-constants @gol
568-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol
569-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg @gol
570-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol
571-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol
572-fno-peephole2 -fno-printf-return-value -fno-sched-interblock @gol
573-fno-sched-spec -fno-signed-zeros @gol
574-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
575-fomit-frame-pointer -foptimize-sibling-calls @gol
576-fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
577-fprefetch-loop-arrays @gol
578-fprofile-correction @gol
579-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training @gol
580-fprofile-values -fprofile-reorder-functions @gol
581-freciprocal-math -free -frename-registers -freorder-blocks @gol
582-freorder-blocks-algorithm=@var{algorithm} @gol
583-freorder-blocks-and-partition -freorder-functions @gol
584-frerun-cse-after-loop -freschedule-modulo-scheduled-loops @gol
585-frounding-math -fsave-optimization-record @gol
586-fsched2-use-superblocks -fsched-pressure @gol
587-fsched-spec-load -fsched-spec-load-dangerous @gol
588-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] @gol
589-fsched-group-heuristic -fsched-critical-path-heuristic @gol
590-fsched-spec-insn-heuristic -fsched-rank-heuristic @gol
591-fsched-last-insn-heuristic -fsched-dep-count-heuristic @gol
592-fschedule-fusion @gol
593-fschedule-insns -fschedule-insns2 -fsection-anchors @gol
594-fselective-scheduling -fselective-scheduling2 @gol
595-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
596-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate @gol
597-fsignaling-nans @gol
598-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops@gol
599-fsplit-paths @gol
600-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt @gol
601-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing @gol
602-fthread-jumps -ftracer -ftree-bit-ccp @gol
603-ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
604-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts @gol
605-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting @gol
606-ftree-loop-if-convert -ftree-loop-im @gol
607-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns @gol
608-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol
609-ftree-loop-vectorize @gol
610-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta @gol
611-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra @gol
612-ftree-switch-conversion -ftree-tail-merge @gol
613-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init @gol
614-funconstrained-commons -funit-at-a-time -funroll-all-loops @gol
615-funroll-loops -funsafe-math-optimizations -funswitch-loops @gol
616-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol
617-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs @gol
618--param @var{name}=@var{value}
619-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
620
621@item Program Instrumentation Options
622@xref{Instrumentation Options,,Program Instrumentation Options}.
623@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage @gol
624-fprofile-abs-path @gol
625-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} @gol
626-fprofile-info-section -fprofile-info-section=@var{name} @gol
627-fprofile-note=@var{path} -fprofile-prefix-path=@var{path} @gol
628-fprofile-update=@var{method} -fprofile-filter-files=@var{regex} @gol
629-fprofile-exclude-files=@var{regex} @gol
630-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} @gol
631-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
632-fsanitize-trap -fsanitize-trap=@var{style} @gol
633-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
634-fsanitize-undefined-trap-on-error -fbounds-check @gol
635-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} @gol
636-fharden-compares -fharden-conditional-branches @gol
637-fstack-protector -fstack-protector-all -fstack-protector-strong @gol
638-fstack-protector-explicit -fstack-check @gol
639-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
640-fno-stack-limit -fsplit-stack @gol
641-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
642-fvtv-counts -fvtv-debug @gol
643-finstrument-functions -finstrument-functions-once @gol
644-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
645-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}} @gol
646-fprofile-prefix-map=@var{old}=@var{new}
647
648@item Preprocessor Options
649@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
650@gccoptlist{-A@var{question}=@var{answer} @gol
651-A-@var{question}@r{[}=@var{answer}@r{]} @gol
652-C -CC -D@var{macro}@r{[}=@var{defn}@r{]} @gol
653-dD -dI -dM -dN -dU @gol
654-fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
655-fexec-charset=@var{charset} -fextended-identifiers @gol
656-finput-charset=@var{charset} -flarge-source-files @gol
657-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} @gol
658-fno-canonical-system-headers -fpch-deps -fpch-preprocess @gol
659-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
660-fwide-exec-charset=@var{charset} -fworking-directory @gol
661-H -imacros @var{file} -include @var{file} @gol
662-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules @gol
663-no-integrated-cpp -P -pthread -remap @gol
664-traditional -traditional-cpp -trigraphs @gol
665-U@var{macro} -undef @gol
666-Wp,@var{option} -Xpreprocessor @var{option}}
667
668@item Assembler Options
669@xref{Assembler Options,,Passing Options to the Assembler}.
670@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
671
672@item Linker Options
673@xref{Link Options,,Options for Linking}.
674@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol
675-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ @gol
676-e @var{entry} --entry=@var{entry} @gol
677-pie -pthread -r -rdynamic @gol
678-s -static -static-pie -static-libgcc -static-libstdc++ @gol
679-static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
680-shared -shared-libgcc -symbolic @gol
681-T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
682-u @var{symbol} -z @var{keyword}}
683
684@item Directory Options
685@xref{Directory Options,,Options for Directory Search}.
686@gccoptlist{-B@var{prefix} -I@var{dir} -I- @gol
687-idirafter @var{dir} @gol
688-imacros @var{file} -imultilib @var{dir} @gol
689-iplugindir=@var{dir} -iprefix @var{file} @gol
690-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} @gol
691-iwithprefix @var{dir} -iwithprefixbefore @var{dir} @gol
692-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix @gol
693-nostdinc -nostdinc++ --sysroot=@var{dir}}
694
695@item Code Generation Options
696@xref{Code Gen Options,,Options for Code Generation Conventions}.
697@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
698-ffixed-@var{reg} -fexceptions @gol
699-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables @gol
700-fasynchronous-unwind-tables @gol
701-fno-gnu-unique @gol
702-finhibit-size-directive -fcommon -fno-ident @gol
703-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol
704-fno-jump-tables -fno-bit-tests @gol
705-frecord-gcc-switches @gol
706-freg-struct-return -fshort-enums -fshort-wchar @gol
707-fverbose-asm -fpack-struct[=@var{n}] @gol
708-fleading-underscore -ftls-model=@var{model} @gol
709-fstack-reuse=@var{reuse_level} @gol
710-ftrampolines -ftrapv -fwrapv @gol
711-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} @gol
712-fstrict-volatile-bitfields -fsync-libcalls}
713
714@item Developer Options
715@xref{Developer Options,,GCC Developer Options}.
716@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
717-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
4ace81b6
SL
718-fchecking -fchecking=@var{n} @gol
719-fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} @gol
d77de738
ML
720-fdisable-ipa-@var{pass_name} @gol
721-fdisable-rtl-@var{pass_name} @gol
722-fdisable-rtl-@var{pass-name}=@var{range-list} @gol
723-fdisable-tree-@var{pass_name} @gol
724-fdisable-tree-@var{pass-name}=@var{range-list} @gol
725-fdump-debug -fdump-earlydebug @gol
726-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links @gol
727-fdump-final-insns@r{[}=@var{file}@r{]} @gol
728-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
729-fdump-lang-all @gol
730-fdump-lang-@var{switch} @gol
731-fdump-lang-@var{switch}-@var{options} @gol
732-fdump-lang-@var{switch}-@var{options}=@var{filename} @gol
733-fdump-passes @gol
734-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol
735-fdump-statistics @gol
736-fdump-tree-all @gol
737-fdump-tree-@var{switch} @gol
738-fdump-tree-@var{switch}-@var{options} @gol
739-fdump-tree-@var{switch}-@var{options}=@var{filename} @gol
740-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second @gol
741-fenable-@var{kind}-@var{pass} @gol
742-fenable-@var{kind}-@var{pass}=@var{range-list} @gol
743-fira-verbose=@var{n} @gol
744-flto-report -flto-report-wpa -fmem-report-wpa @gol
745-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report @gol
746-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} @gol
747-fmultiflags -fprofile-report @gol
748-frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
749-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
750-fstats -fstack-usage -ftime-report -ftime-report-details @gol
751-fvar-tracking-assignments-toggle -gtoggle @gol
752-print-file-name=@var{library} -print-libgcc-file-name @gol
753-print-multi-directory -print-multi-lib -print-multi-os-directory @gol
754-print-prog-name=@var{program} -print-search-dirs -Q @gol
755-print-sysroot -print-sysroot-headers-suffix @gol
756-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
757
758@item Machine-Dependent Options
759@xref{Submodel Options,,Machine-Dependent Options}.
760@c This list is ordered alphanumerically by subsection name.
761@c Try and put the significant identifier (CPU or system) first,
762@c so users have a clue at guessing where the ones they want will be.
763
764@emph{AArch64 Options}
765@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian @gol
766-mgeneral-regs-only @gol
767-mcmodel=tiny -mcmodel=small -mcmodel=large @gol
768-mstrict-align -mno-strict-align @gol
769-momit-leaf-frame-pointer @gol
770-mtls-dialect=desc -mtls-dialect=traditional @gol
771-mtls-size=@var{size} @gol
772-mfix-cortex-a53-835769 -mfix-cortex-a53-843419 @gol
773-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div @gol
774-mpc-relative-literal-loads @gol
775-msign-return-address=@var{scope} @gol
776-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
777+@var{b-key}]|@var{bti} @gol
778-mharden-sls=@var{opts} @gol
779-march=@var{name} -mcpu=@var{name} -mtune=@var{name} @gol
780-moverride=@var{string} -mverbose-cost-dump @gol
781-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} @gol
782-mstack-protector-guard-offset=@var{offset} -mtrack-speculation @gol
783-moutline-atomics }
784
785@emph{Adapteva Epiphany Options}
786@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs @gol
787-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf @gol
788-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} @gol
789-mround-nearest -mlong-calls -mshort-calls -msmall16 @gol
790-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} @gol
791-msplit-vecmove-early -m1reg-@var{reg}}
792
793@emph{AMD GCN Options}
794@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
795
796@emph{ARC Options}
797@gccoptlist{-mbarrel-shifter -mjli-always @gol
798-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 @gol
799-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr @gol
800-mea -mno-mpy -mmul32x16 -mmul64 -matomic @gol
801-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap @gol
802-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape @gol
803-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof @gol
804-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved @gol
805-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} @gol
806-mvolatile-cache -mtp-regno=@var{regno} @gol
807-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc @gol
808-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi @gol
809-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none @gol
810-mlra-priority-compact -mlra-priority-noncompact -mmillicode @gol
811-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} @gol
812-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame @gol
813-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} @gol
814-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
815
816@emph{ARM Options}
817@gccoptlist{-mapcs-frame -mno-apcs-frame @gol
818-mabi=@var{name} @gol
819-mapcs-stack-check -mno-apcs-stack-check @gol
820-mapcs-reentrant -mno-apcs-reentrant @gol
821-mgeneral-regs-only @gol
822-msched-prolog -mno-sched-prolog @gol
823-mlittle-endian -mbig-endian @gol
824-mbe8 -mbe32 @gol
825-mfloat-abi=@var{name} @gol
826-mfp16-format=@var{name}
827-mthumb-interwork -mno-thumb-interwork @gol
828-mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
829-mtune=@var{name} -mprint-tune-info @gol
830-mstructure-size-boundary=@var{n} @gol
831-mabort-on-noreturn @gol
832-mlong-calls -mno-long-calls @gol
833-msingle-pic-base -mno-single-pic-base @gol
834-mpic-register=@var{reg} @gol
835-mnop-fun-dllimport @gol
836-mpoke-function-name @gol
837-mthumb -marm -mflip-thumb @gol
838-mtpcs-frame -mtpcs-leaf-frame @gol
839-mcaller-super-interworking -mcallee-super-interworking @gol
840-mtp=@var{name} -mtls-dialect=@var{dialect} @gol
841-mword-relocations @gol
842-mfix-cortex-m3-ldrd @gol
843-mfix-cortex-a57-aes-1742098 @gol
844-mfix-cortex-a72-aes-1655431 @gol
845-munaligned-access @gol
846-mneon-for-64bits @gol
847-mslow-flash-data @gol
848-masm-syntax-unified @gol
849-mrestrict-it @gol
850-mverbose-cost-dump @gol
851-mpure-code @gol
852-mcmse @gol
853-mfix-cmse-cve-2021-35465 @gol
854-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} @gol
14fab5fb
AC
855-mfdpic @gol
856-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}]
857[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]}
d77de738
ML
858
859@emph{AVR Options}
860@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol
861-mbranch-cost=@var{cost} @gol
862-mcall-prologues -mgas-isr-prologues -mint8 @gol
863-mdouble=@var{bits} -mlong-double=@var{bits} @gol
864-mn_flash=@var{size} -mno-interrupts @gol
865-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack @gol
866-mfract-convert-truncate @gol
867-mshort-calls -nodevicelib -nodevicespecs @gol
868-Waddr-space-convert -Wmisspelled-isr}
869
870@emph{Blackfin Options}
871@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol
872-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer @gol
873-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly @gol
874-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library @gol
875-mno-id-shared-library -mshared-library-id=@var{n} @gol
876-mleaf-id-shared-library -mno-leaf-id-shared-library @gol
877-msep-data -mno-sep-data -mlong-calls -mno-long-calls @gol
878-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram @gol
879-micplb}
880
881@emph{C6X Options}
882@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} @gol
883-msim -msdata=@var{sdata-type}}
884
885@emph{CRIS Options}
886@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
887-mtune=@var{cpu} -mmax-stack-frame=@var{n} @gol
888-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
889-mstack-align -mdata-align -mconst-align @gol
890-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue @gol
891-melf -maout -sim -sim2 @gol
892-mmul-bug-workaround -mno-mul-bug-workaround}
893
894@emph{C-SKY Options}
895@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} @gol
896-mbig-endian -EB -mlittle-endian -EL @gol
897-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu @gol
898-mfloat-abi=@var{name} @gol
899-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust @gol
900-mdsp -medsp -mvdsp @gol
901-mdiv -msmart -mhigh-registers -manchor @gol
902-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt @gol
903-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
904
905@emph{Darwin Options}
906@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
907-arch_only -bind_at_load -bundle -bundle_loader @gol
908-client_name -compatibility_version -current_version @gol
909-dead_strip @gol
910-dependency-file -dylib_file -dylinker_install_name @gol
911-dynamic -dynamiclib -exported_symbols_list @gol
912-filelist -flat_namespace -force_cpusubtype_ALL @gol
913-force_flat_namespace -headerpad_max_install_names @gol
914-iframework @gol
915-image_base -init -install_name -keep_private_externs @gol
916-multi_module -multiply_defined -multiply_defined_unused @gol
917-noall_load -no_dead_strip_inits_and_terms @gol
918-nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
919-pagezero_size -prebind -prebind_all_twolevel_modules @gol
920-private_bundle -read_only_relocs -sectalign @gol
921-sectobjectsymbols -whyload -seg1addr @gol
922-sectcreate -sectobjectsymbols -sectorder @gol
923-segaddr -segs_read_only_addr -segs_read_write_addr @gol
924-seg_addr_table -seg_addr_table_filename -seglinkedit @gol
925-segprot -segs_read_only_addr -segs_read_write_addr @gol
926-single_module -static -sub_library -sub_umbrella @gol
927-twolevel_namespace -umbrella -undefined @gol
928-unexported_symbols_list -weak_reference_mismatches @gol
929-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} @gol
930-mkernel -mone-byte-bool}
931
932@emph{DEC Alpha Options}
933@gccoptlist{-mno-fp-regs -msoft-float @gol
934-mieee -mieee-with-inexact -mieee-conformant @gol
935-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
936-mtrap-precision=@var{mode} -mbuild-constants @gol
937-mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
938-mbwx -mmax -mfix -mcix @gol
939-mfloat-vax -mfloat-ieee @gol
940-mexplicit-relocs -msmall-data -mlarge-data @gol
941-msmall-text -mlarge-text @gol
942-mmemory-latency=@var{time}}
943
944@emph{eBPF Options}
945@gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version}
946-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re
947-mjmpext -mjmp32 -malu32 -mcpu=@var{version}}
948
949@emph{FR30 Options}
950@gccoptlist{-msmall-model -mno-lsim}
951
952@emph{FT32 Options}
953@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
954
955@emph{FRV Options}
956@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
957-mhard-float -msoft-float @gol
958-malloc-cc -mfixed-cc -mdword -mno-dword @gol
959-mdouble -mno-double @gol
960-mmedia -mno-media -mmuladd -mno-muladd @gol
961-mfdpic -minline-plt -mgprel-ro -multilib-library-pic @gol
962-mlinked-fp -mlong-calls -malign-labels @gol
963-mlibrary-pic -macc-4 -macc-8 @gol
964-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
965-moptimize-membar -mno-optimize-membar @gol
966-mscc -mno-scc -mcond-exec -mno-cond-exec @gol
967-mvliw-branch -mno-vliw-branch @gol
968-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
969-mno-nested-cond-exec -mtomcat-stats @gol
970-mTLS -mtls @gol
971-mcpu=@var{cpu}}
972
973@emph{GNU/Linux Options}
974@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
975-tno-android-cc -tno-android-ld}
976
977@emph{H8/300 Options}
978@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
979
980@emph{HPPA Options}
981@gccoptlist{-march=@var{architecture-type} @gol
cf467fb9 982-matomic-libcalls -mbig-switch @gol
d77de738 983-mcaller-copies -mdisable-fpregs -mdisable-indexing @gol
cf467fb9 984-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
d77de738 985-mfixed-range=@var{register-range} @gol
cf467fb9
JDA
986-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls @gol
987-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs @gol
d77de738
ML
988-mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
989-mno-jump-in-delay -mno-long-load-store @gol
990-mno-portable-runtime -mno-soft-float @gol
991-mno-space-regs -msoft-float -mpa-risc-1-0 @gol
992-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
cf467fb9 993-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio @gol
d77de738
ML
994-munix=@var{unix-std} -nolibdld -static -threads}
995
996@emph{IA-64 Options}
997@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
998-mvolatile-asm-stop -mregister-names -msdata -mno-sdata @gol
999-mconstant-gp -mauto-pic -mfused-madd @gol
1000-minline-float-divide-min-latency @gol
1001-minline-float-divide-max-throughput @gol
1002-mno-inline-float-divide @gol
1003-minline-int-divide-min-latency @gol
1004-minline-int-divide-max-throughput @gol
1005-mno-inline-int-divide @gol
1006-minline-sqrt-min-latency -minline-sqrt-max-throughput @gol
1007-mno-inline-sqrt @gol
1008-mdwarf2-asm -mearly-stop-bits @gol
1009-mfixed-range=@var{register-range} -mtls-size=@var{tls-size} @gol
1010-mtune=@var{cpu-type} -milp32 -mlp64 @gol
1011-msched-br-data-spec -msched-ar-data-spec -msched-control-spec @gol
1012-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec @gol
1013-msched-spec-ldc -msched-spec-control-ldc @gol
1014-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns @gol
1015-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path @gol
1016-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost @gol
1017-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1018
1019@emph{LM32 Options}
1020@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled @gol
1021-msign-extend-enabled -muser-enabled}
1022
1023@emph{LoongArch Options}
1024@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} @gol
1025-mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float @gol
1026-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division @gol
1027-mcond-move-int -mno-cond-move-int @gol
1028-mcond-move-float -mno-cond-move-float @gol
1029-memcpy -mno-memcpy -mstrict-align -mno-strict-align @gol
1030-mmax-inline-memcpy-size=@var{n} @gol
1031-mexplicit-relocs -mno-explicit-relocs @gol
1032-mdirect-extern-access -mno-direct-extern-access @gol
1033-mcmodel=@var{code-model}}
1034
1035@emph{M32R/D Options}
1036@gccoptlist{-m32r2 -m32rx -m32r @gol
1037-mdebug @gol
1038-malign-loops -mno-align-loops @gol
1039-missue-rate=@var{number} @gol
1040-mbranch-cost=@var{number} @gol
1041-mmodel=@var{code-size-model-type} @gol
1042-msdata=@var{sdata-type} @gol
1043-mno-flush-func -mflush-func=@var{name} @gol
1044-mno-flush-trap -mflush-trap=@var{number} @gol
1045-G @var{num}}
1046
1047@emph{M32C Options}
1048@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1049
1050@emph{M680x0 Options}
1051@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} @gol
1052-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
1053-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 @gol
1054-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 @gol
1055-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort @gol
1056-mno-short -mhard-float -m68881 -msoft-float -mpcrel @gol
1057-malign-int -mstrict-align -msep-data -mno-sep-data @gol
1058-mshared-library-id=n -mid-shared-library -mno-id-shared-library @gol
1059-mxgot -mno-xgot -mlong-jump-table-offsets}
1060
1061@emph{MCore Options}
1062@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
1063-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
1064-m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
1065-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
1066-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1067
d77de738
ML
1068@emph{MicroBlaze Options}
1069@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} @gol
1070-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift @gol
1071-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss @gol
1072-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt @gol
1073-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} @gol
1074-mpic-data-is-text-relative}
1075
1076@emph{MIPS Options}
1077@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
1078-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 @gol
1079-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 @gol
1080-mips16 -mno-mips16 -mflip-mips16 @gol
1081-minterlink-compressed -mno-interlink-compressed @gol
1082-minterlink-mips16 -mno-interlink-mips16 @gol
1083-mabi=@var{abi} -mabicalls -mno-abicalls @gol
1084-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol
1085-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float @gol
1086-mno-float -msingle-float -mdouble-float @gol
1087-modd-spreg -mno-odd-spreg @gol
1088-mabs=@var{mode} -mnan=@var{encoding} @gol
1089-mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
1090-mmcu -mmno-mcu @gol
1091-meva -mno-eva @gol
1092-mvirt -mno-virt @gol
1093-mxpa -mno-xpa @gol
1094-mcrc -mno-crc @gol
1095-mginv -mno-ginv @gol
1096-mmicromips -mno-micromips @gol
1097-mmsa -mno-msa @gol
1098-mloongson-mmi -mno-loongson-mmi @gol
1099-mloongson-ext -mno-loongson-ext @gol
1100-mloongson-ext2 -mno-loongson-ext2 @gol
1101-mfpu=@var{fpu-type} @gol
1102-msmartmips -mno-smartmips @gol
1103-mpaired-single -mno-paired-single -mdmx -mno-mdmx @gol
1104-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc @gol
1105-mlong64 -mlong32 -msym32 -mno-sym32 @gol
1106-G@var{num} -mlocal-sdata -mno-local-sdata @gol
1107-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt @gol
1108-membedded-data -mno-embedded-data @gol
1109-muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
1110-mcode-readable=@var{setting} @gol
1111-msplit-addresses -mno-split-addresses @gol
1112-mexplicit-relocs -mno-explicit-relocs @gol
1113-mcheck-zero-division -mno-check-zero-division @gol
1114-mdivide-traps -mdivide-breaks @gol
1115-mload-store-pairs -mno-load-store-pairs @gol
1116-munaligned-access -mno-unaligned-access @gol
1117-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
1118-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp @gol
1119-mfix-24k -mno-fix-24k @gol
1120-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
1121-mfix-r5900 -mno-fix-r5900 @gol
1122-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 @gol
1123-mfix-vr4120 -mno-fix-vr4120 @gol
1124-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 @gol
1125-mflush-func=@var{func} -mno-flush-func @gol
1126-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely @gol
1127-mcompact-branches=@var{policy} @gol
1128-mfp-exceptions -mno-fp-exceptions @gol
1129-mvr4130-align -mno-vr4130-align -msynci -mno-synci @gol
1130-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 @gol
1131-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address @gol
1132-mframe-header-opt -mno-frame-header-opt}
1133
1134@emph{MMIX Options}
1135@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
1136-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
1137-melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
1138-mno-base-addresses -msingle-exit -mno-single-exit}
1139
1140@emph{MN10300 Options}
1141@gccoptlist{-mmult-bug -mno-mult-bug @gol
1142-mno-am33 -mam33 -mam33-2 -mam34 @gol
1143-mtune=@var{cpu-type} @gol
1144-mreturn-pointer-on-d0 @gol
1145-mno-crt0 -mrelax -mliw -msetlb}
1146
1147@emph{Moxie Options}
1148@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1149
1150@emph{MSP430 Options}
1151@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax @gol
1152-mwarn-mcu @gol
1153-mcode-region= -mdata-region= @gol
1154-msilicon-errata= -msilicon-errata-warn= @gol
1155-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1156
1157@emph{NDS32 Options}
1158@gccoptlist{-mbig-endian -mlittle-endian @gol
1159-mreduced-regs -mfull-regs @gol
1160-mcmov -mno-cmov @gol
1161-mext-perf -mno-ext-perf @gol
1162-mext-perf2 -mno-ext-perf2 @gol
1163-mext-string -mno-ext-string @gol
1164-mv3push -mno-v3push @gol
1165-m16bit -mno-16bit @gol
1166-misr-vector-size=@var{num} @gol
1167-mcache-block-size=@var{num} @gol
1168-march=@var{arch} @gol
1169-mcmodel=@var{code-model} @gol
1170-mctor-dtor -mrelax}
1171
1172@emph{Nios II Options}
1173@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt @gol
1174-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} @gol
1175-mel -meb @gol
1176-mno-bypass-cache -mbypass-cache @gol
1177-mno-cache-volatile -mcache-volatile @gol
1178-mno-fast-sw-div -mfast-sw-div @gol
1179-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div @gol
1180-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} @gol
1181-mcustom-fpu-cfg=@var{name} @gol
1182-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} @gol
1183-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1184
1185@emph{Nvidia PTX Options}
1186@gccoptlist{-m64 -mmainkernel -moptimize}
1187
1188@emph{OpenRISC Options}
1189@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div @gol
1190-msoft-mul -msoft-div @gol
1191-msoft-float -mhard-float -mdouble-float -munordered-float @gol
1192-mcmov -mror -mrori -msext -msfimm -mshftimm @gol
1193-mcmodel=@var{code-model}}
1194
1195@emph{PDP-11 Options}
1196@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
1197-mint32 -mno-int16 -mint16 -mno-int32 @gol
1198-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1199
d77de738
ML
1200@emph{PowerPC Options}
1201See RS/6000 and PowerPC Options.
1202
1203@emph{PRU Options}
1204@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop @gol
f58e6d42 1205-mabi=@var{variant}}
d77de738
ML
1206
1207@emph{RISC-V Options}
1208@gccoptlist{-mbranch-cost=@var{N-instruction} @gol
1209-mplt -mno-plt @gol
1210-mabi=@var{ABI-string} @gol
1211-mfdiv -mno-fdiv @gol
1212-mdiv -mno-div @gol
1213-misa-spec=@var{ISA-spec-string} @gol
1214-march=@var{ISA-string} @gol
1215-mtune=@var{processor-string} @gol
1216-mpreferred-stack-boundary=@var{num} @gol
1217-msmall-data-limit=@var{N-bytes} @gol
1218-msave-restore -mno-save-restore @gol
1219-mshorten-memrefs -mno-shorten-memrefs @gol
1220-mstrict-align -mno-strict-align @gol
1221-mcmodel=medlow -mcmodel=medany @gol
1222-mexplicit-relocs -mno-explicit-relocs @gol
1223-mrelax -mno-relax @gol
1224-mriscv-attribute -mno-riscv-attribute @gol
1225-malign-data=@var{type} @gol
1226-mbig-endian -mlittle-endian @gol
1227-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
f58e6d42
CM
1228-mstack-protector-guard-offset=@var{offset} @gol
1229-mcsr-check -mno-csr-check}
d77de738
ML
1230
1231@emph{RL78 Options}
1232@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol
1233-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 @gol
1234-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1235
1236@emph{RS/6000 and PowerPC Options}
1237@gccoptlist{-mcpu=@var{cpu-type} @gol
1238-mtune=@var{cpu-type} @gol
1239-mcmodel=@var{code-model} @gol
1240-mpowerpc64 @gol
1241-maltivec -mno-altivec @gol
1242-mpowerpc-gpopt -mno-powerpc-gpopt @gol
1243-mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
1244-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd @gol
1245-mfprnd -mno-fprnd @gol
1246-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp @gol
1247-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
1248-m64 -m32 -mxl-compat -mno-xl-compat -mpe @gol
1249-malign-power -malign-natural @gol
1250-msoft-float -mhard-float -mmultiple -mno-multiple @gol
1251-mupdate -mno-update @gol
1252-mavoid-indexed-addresses -mno-avoid-indexed-addresses @gol
1253-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
1254-mstrict-align -mno-strict-align -mrelocatable @gol
1255-mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
1256-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
1257-mdynamic-no-pic -mswdiv -msingle-pic-base @gol
1258-mprioritize-restricted-insns=@var{priority} @gol
1259-msched-costly-dep=@var{dependence_type} @gol
1260-minsert-sched-nops=@var{scheme} @gol
1261-mcall-aixdesc -mcall-eabi -mcall-freebsd @gol
1262-mcall-linux -mcall-netbsd -mcall-openbsd @gol
1263-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi @gol
1264-mtraceback=@var{traceback_type} @gol
1265-maix-struct-return -msvr4-struct-return @gol
1266-mabi=@var{abi-type} -msecure-plt -mbss-plt @gol
1267-mlongcall -mno-longcall -mpltseq -mno-pltseq @gol
1268-mblock-move-inline-limit=@var{num} @gol
1269-mblock-compare-inline-limit=@var{num} @gol
1270-mblock-compare-inline-loop-limit=@var{num} @gol
1271-mno-block-ops-unaligned-vsx @gol
1272-mstring-compare-inline-limit=@var{num} @gol
1273-misel -mno-isel @gol
1274-mvrsave -mno-vrsave @gol
1275-mmulhw -mno-mulhw @gol
1276-mdlmzb -mno-dlmzb @gol
1277-mprototype -mno-prototype @gol
1278-msim -mmvme -mads -myellowknife -memb -msdata @gol
1279-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol
1280-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol
1281-mno-recip-precision @gol
1282-mveclibabi=@var{type} -mfriz -mno-friz @gol
1283-mpointers-to-nested-functions -mno-pointers-to-nested-functions @gol
1284-msave-toc-indirect -mno-save-toc-indirect @gol
1285-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
1286-mcrypto -mno-crypto -mhtm -mno-htm @gol
1287-mquad-memory -mno-quad-memory @gol
1288-mquad-memory-atomic -mno-quad-memory-atomic @gol
1289-mcompat-align-parm -mno-compat-align-parm @gol
1290-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware @gol
1291-mgnu-attribute -mno-gnu-attribute @gol
1292-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1293-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed @gol
1294-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect @gol
1295-mprivileged -mno-privileged}
1296
1297@emph{RX Options}
1298@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu@gol
1299-mcpu=@gol
1300-mbig-endian-data -mlittle-endian-data @gol
1301-msmall-data @gol
1302-msim -mno-sim@gol
1303-mas100-syntax -mno-as100-syntax@gol
1304-mrelax@gol
1305-mmax-constant-size=@gol
1306-mint-register=@gol
1307-mpid@gol
1308-mallow-string-insns -mno-allow-string-insns@gol
1309-mjsr@gol
1310-mno-warn-multiple-fast-interrupts@gol
1311-msave-acc-in-interrupts}
1312
1313@emph{S/390 and zSeries Options}
1314@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1315-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp @gol
1316-mlong-double-64 -mlong-double-128 @gol
1317-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack @gol
1318-msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
1319-m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
1320-mhtm -mvx -mzvector @gol
1321-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip @gol
1322-mfused-madd -mno-fused-madd @gol
1323-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard @gol
1324-mhotpatch=@var{halfwords},@var{halfwords}}
1325
d77de738
ML
1326@emph{SH Options}
1327@gccoptlist{-m1 -m2 -m2e @gol
1328-m2a-nofpu -m2a-single-only -m2a-single -m2a @gol
1329-m3 -m3e @gol
1330-m4-nofpu -m4-single-only -m4-single -m4 @gol
1331-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol
1332-mb -ml -mdalign -mrelax @gol
1333-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave @gol
1334-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct @gol
1335-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
1336-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol
1337-maccumulate-outgoing-args @gol
1338-matomic-model=@var{atomic-model} @gol
1339-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch @gol
1340-mcbranch-force-delay-slot @gol
1341-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra @gol
1342-mpretend-cmove -mtas}
1343
1344@emph{Solaris 2 Options}
1345@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text @gol
1346-pthreads}
1347
1348@emph{SPARC Options}
1349@gccoptlist{-mcpu=@var{cpu-type} @gol
1350-mtune=@var{cpu-type} @gol
1351-mcmodel=@var{code-model} @gol
1352-mmemory-model=@var{mem-model} @gol
1353-m32 -m64 -mapp-regs -mno-app-regs @gol
1354-mfaster-structs -mno-faster-structs -mflat -mno-flat @gol
1355-mfpu -mno-fpu -mhard-float -msoft-float @gol
1356-mhard-quad-float -msoft-quad-float @gol
1357-mstack-bias -mno-stack-bias @gol
1358-mstd-struct-return -mno-std-struct-return @gol
1359-munaligned-doubles -mno-unaligned-doubles @gol
1360-muser-mode -mno-user-mode @gol
1361-mv8plus -mno-v8plus -mvis -mno-vis @gol
1362-mvis2 -mno-vis2 -mvis3 -mno-vis3 @gol
1363-mvis4 -mno-vis4 -mvis4b -mno-vis4b @gol
1364-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld @gol
1365-mpopc -mno-popc -msubxc -mno-subxc @gol
1366-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc @gol
1367-mlra -mno-lra}
1368
1369@emph{System V Options}
1370@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1371
1372@emph{V850 Options}
1373@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
1374-mprolog-function -mno-prolog-function -mspace @gol
1375-mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
1376-mapp-regs -mno-app-regs @gol
1377-mdisable-callt -mno-disable-callt @gol
1378-mv850e2v3 -mv850e2 -mv850e1 -mv850es @gol
1379-mv850e -mv850 -mv850e3v5 @gol
1380-mloop @gol
1381-mrelax @gol
1382-mlong-jumps @gol
1383-msoft-float @gol
1384-mhard-float @gol
1385-mgcc-abi @gol
1386-mrh850-abi @gol
1387-mbig-switch}
1388
1389@emph{VAX Options}
1390@gccoptlist{-mg -mgnu -munix -mlra}
1391
1392@emph{Visium Options}
1393@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float @gol
1394-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1395
1396@emph{VMS Options}
1397@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 @gol
1398-mpointer-size=@var{size}}
1399
1400@emph{VxWorks Options}
1401@gccoptlist{-mrtp -non-static -Bstatic -Bdynamic @gol
1402-Xbind-lazy -Xbind-now}
1403
1404@emph{x86 Options}
1405@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1406-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default @gol
1407-mfpmath=@var{unit} @gol
1408-masm=@var{dialect} -mno-fancy-math-387 @gol
1409-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float @gol
1410-mno-wide-multiply -mrtd -malign-double @gol
1411-mpreferred-stack-boundary=@var{num} @gol
1412-mincoming-stack-boundary=@var{num} @gol
1413-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait @gol
1414-mrecip -mrecip=@var{opt} @gol
1415-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} @gol
1416-mmove-max=@var{bits} -mstore-max=@var{bits} @gol
1417-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
1418-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl @gol
1419-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes @gol
1420-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd @gol
1421-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves @gol
1422-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol
1423-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp @gol
1424-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol
1425-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call @gol
1426-mavx512vbmi2 -mavx512bf16 -menqcmd @gol
1427-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol
1428-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid @gol
1429-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk@gol
1430-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni@gol
1431-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 @gol
1432-mprefetchi -mraoint @gol
1433-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops @gol
1434-minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
1435-mkl -mwidekl @gol
1436-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} @gol
1437-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
1438-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 @gol
1439-mregparm=@var{num} -msseregparm @gol
1440-mveclibabi=@var{type} -mvect8-ret-in-mem @gol
e54375d8 1441-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign @gol
d77de738
ML
1442-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
1443-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
1444-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol
1445-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
1446-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} @gol
1447-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
1448-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
1449-mstack-protector-guard-reg=@var{reg} @gol
1450-mstack-protector-guard-offset=@var{offset} @gol
1451-mstack-protector-guard-symbol=@var{symbol} @gol
1452-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop @gol
1453-mindirect-branch=@var{choice} -mfunction-return=@var{choice} @gol
1454-mindirect-branch-register -mharden-sls=@var{choice} @gol
ce51e843 1455-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access @gol
bb576017 1456-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1457
1458@emph{x86 Windows Options}
1459@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
1460-mnop-fun-dllimport -mthread @gol
1461-municode -mwin32 -mwindows -fno-set-stack-executable}
1462
1463@emph{Xstormy16 Options}
1464@gccoptlist{-msim}
1465
1466@emph{Xtensa Options}
1467@gccoptlist{-mconst16 -mno-const16 @gol
1468-mfused-madd -mno-fused-madd @gol
1469-mforce-no-pic @gol
1470-mserialize-volatile -mno-serialize-volatile @gol
1471-mtext-section-literals -mno-text-section-literals @gol
1472-mauto-litpools -mno-auto-litpools @gol
1473-mtarget-align -mno-target-align @gol
1474-mlongcalls -mno-longcalls @gol
1475-mabi=@var{abi-type} @gol
1476-mextra-l32r-costs=@var{cycles}}
1477
1478@emph{zSeries Options}
1479See S/390 and zSeries Options.
1480@end table
1481
1482
1483@node Overall Options
1484@section Options Controlling the Kind of Output
1485
1486Compilation can involve up to four stages: preprocessing, compilation
1487proper, assembly and linking, always in that order. GCC is capable of
1488preprocessing and compiling several files either into several
1489assembler input files, or into one assembler input file; then each
1490assembler input file produces an object file, and linking combines all
1491the object files (those newly compiled, and those specified as input)
1492into an executable file.
1493
1494@cindex file name suffix
1495For any given input file, the file name suffix determines what kind of
1496compilation is done:
1497
1498@table @gcctabopt
1499@item @var{file}.c
1500C source code that must be preprocessed.
1501
1502@item @var{file}.i
1503C source code that should not be preprocessed.
1504
1505@item @var{file}.ii
1506C++ source code that should not be preprocessed.
1507
1508@item @var{file}.m
1509Objective-C source code. Note that you must link with the @file{libobjc}
1510library to make an Objective-C program work.
1511
1512@item @var{file}.mi
1513Objective-C source code that should not be preprocessed.
1514
1515@item @var{file}.mm
1516@itemx @var{file}.M
1517Objective-C++ source code. Note that you must link with the @file{libobjc}
1518library to make an Objective-C++ program work. Note that @samp{.M} refers
1519to a literal capital M@.
1520
1521@item @var{file}.mii
1522Objective-C++ source code that should not be preprocessed.
1523
1524@item @var{file}.h
1525C, C++, Objective-C or Objective-C++ header file to be turned into a
1526precompiled header (default), or C, C++ header file to be turned into an
1527Ada spec (via the @option{-fdump-ada-spec} switch).
1528
1529@item @var{file}.cc
1530@itemx @var{file}.cp
1531@itemx @var{file}.cxx
1532@itemx @var{file}.cpp
1533@itemx @var{file}.CPP
1534@itemx @var{file}.c++
1535@itemx @var{file}.C
1536C++ source code that must be preprocessed. Note that in @samp{.cxx},
1537the last two letters must both be literally @samp{x}. Likewise,
1538@samp{.C} refers to a literal capital C@.
1539
1540@item @var{file}.mm
1541@itemx @var{file}.M
1542Objective-C++ source code that must be preprocessed.
1543
1544@item @var{file}.mii
1545Objective-C++ source code that should not be preprocessed.
1546
1547@item @var{file}.hh
1548@itemx @var{file}.H
1549@itemx @var{file}.hp
1550@itemx @var{file}.hxx
1551@itemx @var{file}.hpp
1552@itemx @var{file}.HPP
1553@itemx @var{file}.h++
1554@itemx @var{file}.tcc
1555C++ header file to be turned into a precompiled header or Ada spec.
1556
1557@item @var{file}.f
1558@itemx @var{file}.for
1559@itemx @var{file}.ftn
1560Fixed form Fortran source code that should not be preprocessed.
1561
1562@item @var{file}.F
1563@itemx @var{file}.FOR
1564@itemx @var{file}.fpp
1565@itemx @var{file}.FPP
1566@itemx @var{file}.FTN
1567Fixed form Fortran source code that must be preprocessed (with the traditional
1568preprocessor).
1569
1570@item @var{file}.f90
1571@itemx @var{file}.f95
1572@itemx @var{file}.f03
1573@itemx @var{file}.f08
1574Free form Fortran source code that should not be preprocessed.
1575
1576@item @var{file}.F90
1577@itemx @var{file}.F95
1578@itemx @var{file}.F03
1579@itemx @var{file}.F08
1580Free form Fortran source code that must be preprocessed (with the
1581traditional preprocessor).
1582
1583@item @var{file}.go
1584Go source code.
1585
1586@item @var{file}.d
1587D source code.
1588
1589@item @var{file}.di
1590D interface file.
1591
1592@item @var{file}.dd
1593D documentation code (Ddoc).
1594
1595@item @var{file}.ads
1596Ada source code file that contains a library unit declaration (a
1597declaration of a package, subprogram, or generic, or a generic
1598instantiation), or a library unit renaming declaration (a package,
1599generic, or subprogram renaming declaration). Such files are also
1600called @dfn{specs}.
1601
1602@item @var{file}.adb
1603Ada source code file containing a library unit body (a subprogram or
1604package body). Such files are also called @dfn{bodies}.
1605
1606@c GCC also knows about some suffixes for languages not yet included:
1607@c Ratfor:
1608@c @var{file}.r
1609
1610@item @var{file}.s
1611Assembler code.
1612
1613@item @var{file}.S
1614@itemx @var{file}.sx
1615Assembler code that must be preprocessed.
1616
1617@item @var{other}
1618An object file to be fed straight into linking.
1619Any file name with no recognized suffix is treated this way.
1620@end table
1621
1622@opindex x
1623You can specify the input language explicitly with the @option{-x} option:
1624
1625@table @gcctabopt
1626@item -x @var{language}
1627Specify explicitly the @var{language} for the following input files
1628(rather than letting the compiler choose a default based on the file
1629name suffix). This option applies to all following input files until
1630the next @option{-x} option. Possible values for @var{language} are:
1631@smallexample
1632c c-header cpp-output
1633c++ c++-header c++-system-header c++-user-header c++-cpp-output
1634objective-c objective-c-header objective-c-cpp-output
1635objective-c++ objective-c++-header objective-c++-cpp-output
1636assembler assembler-with-cpp
1637ada
1638d
1639f77 f77-cpp-input f95 f95-cpp-input
1640go
1641@end smallexample
1642
1643@item -x none
1644Turn off any specification of a language, so that subsequent files are
1645handled according to their file name suffixes (as they are if @option{-x}
1646has not been used at all).
1647@end table
1648
1649If you only want some of the stages of compilation, you can use
1650@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1651one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1652@command{gcc} is to stop. Note that some combinations (for example,
1653@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1654
1655@table @gcctabopt
d77de738 1656@opindex c
ddf6fe37 1657@item -c
d77de738
ML
1658Compile or assemble the source files, but do not link. The linking
1659stage simply is not done. The ultimate output is in the form of an
1660object file for each source file.
1661
1662By default, the object file name for a source file is made by replacing
1663the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1664
1665Unrecognized input files, not requiring compilation or assembly, are
1666ignored.
1667
d77de738 1668@opindex S
ddf6fe37 1669@item -S
d77de738
ML
1670Stop after the stage of compilation proper; do not assemble. The output
1671is in the form of an assembler code file for each non-assembler input
1672file specified.
1673
1674By default, the assembler file name for a source file is made by
1675replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1676
1677Input files that don't require compilation are ignored.
1678
d77de738 1679@opindex E
ddf6fe37 1680@item -E
d77de738
ML
1681Stop after the preprocessing stage; do not run the compiler proper. The
1682output is in the form of preprocessed source code, which is sent to the
1683standard output.
1684
1685Input files that don't require preprocessing are ignored.
1686
1687@cindex output file option
d77de738 1688@opindex o
ddf6fe37 1689@item -o @var{file}
d77de738
ML
1690Place the primary output in file @var{file}. This applies to whatever
1691sort of output is being produced, whether it be an executable file, an
1692object file, an assembler file or preprocessed C code.
1693
1694If @option{-o} is not specified, the default is to put an executable
1695file in @file{a.out}, the object file for
1696@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1697assembler file in @file{@var{source}.s}, a precompiled header file in
1698@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1699standard output.
1700
1701Though @option{-o} names only the primary output, it also affects the
1702naming of auxiliary and dump outputs. See the examples below. Unless
1703overridden, both auxiliary outputs and dump outputs are placed in the
1704same directory as the primary output. In auxiliary outputs, the suffix
1705of the input file is replaced with that of the auxiliary output file
1706type; in dump outputs, the suffix of the dump file is appended to the
1707input file suffix. In compilation commands, the base name of both
1708auxiliary and dump outputs is that of the primary output; in compile and
1709link commands, the primary output name, minus the executable suffix, is
1710combined with the input file name. If both share the same base name,
1711disregarding the suffix, the result of the combination is that base
1712name, otherwise, they are concatenated, separated by a dash.
1713
1714@smallexample
1715gcc -c foo.c ...
1716@end smallexample
1717
1718will use @file{foo.o} as the primary output, and place aux outputs and
1719dumps next to it, e.g., aux file @file{foo.dwo} for
1720@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1721@option{-fdump-rtl-final}.
1722
1723If a non-linker output file is explicitly specified, aux and dump files
1724by default take the same base name:
1725
1726@smallexample
1727gcc -c foo.c -o dir/foobar.o ...
1728@end smallexample
1729
1730will name aux outputs @file{dir/foobar.*} and dump outputs
1731@file{dir/foobar.c.*}.
1732
1733A linker output will instead prefix aux and dump outputs:
1734
1735@smallexample
1736gcc foo.c bar.c -o dir/foobar ...
1737@end smallexample
1738
1739will generally name aux outputs @file{dir/foobar-foo.*} and
1740@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1741@file{dir/foobar-bar.c.*}.
1742
1743The one exception to the above is when the executable shares the base
1744name with the single input:
1745
1746@smallexample
1747gcc foo.c -o dir/foo ...
1748@end smallexample
1749
1750in which case aux outputs are named @file{dir/foo.*} and dump outputs
1751named @file{dir/foo.c.*}.
1752
1753The location and the names of auxiliary and dump outputs can be adjusted
1754by the options @option{-dumpbase}, @option{-dumpbase-ext},
1755@option{-dumpdir}, @option{-save-temps=cwd}, and
1756@option{-save-temps=obj}.
1757
1758
d77de738 1759@opindex dumpbase
ddf6fe37 1760@item -dumpbase @var{dumpbase}
d77de738
ML
1761This option sets the base name for auxiliary and dump output files. It
1762does not affect the name of the primary output file. Intermediate
1763outputs, when preserved, are not regarded as primary outputs, but as
1764auxiliary outputs:
1765
1766@smallexample
1767gcc -save-temps -S foo.c
1768@end smallexample
1769
1770saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1771then compiles to the (implied) output file @file{foo.s}, whereas:
1772
1773@smallexample
1774gcc -save-temps -dumpbase save-foo -c foo.c
1775@end smallexample
1776
1777preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1778an intermediate, thus auxiliary output), and then assembles to the
1779(implied) output file @file{foo.o}.
1780
1781Absent this option, dump and aux files take their names from the input
1782file, or from the (non-linker) output file, if one is explicitly
1783specified: dump output files (e.g. those requested by @option{-fdump-*}
1784options) with the input name suffix, and aux output files (those
1785requested by other non-dump options, e.g. @code{-save-temps},
1786@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1787
1788Similar suffix differentiation of dump and aux outputs can be attained
1789for explicitly-given @option{-dumpbase basename.suf} by also specifying
1790@option{-dumpbase-ext .suf}.
1791
1792If @var{dumpbase} is explicitly specified with any directory component,
1793any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1794@option{-save-temps=*}) is ignored, and instead of appending to it,
1795@var{dumpbase} fully overrides it:
1796
1797@smallexample
1798gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1799 -dumpdir pfx- -save-temps=cwd ...
1800@end smallexample
1801
1802creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1803@file{dir/} in @option{-o}, the @file{./} prefix implied by
1804@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1805
1806When @option{-dumpbase} is specified in a command that compiles multiple
1807inputs, or that compiles and then links, it may be combined with
1808@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1809file is compiled using the combined @var{dumppfx}, and default values
1810for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1811file:
1812
1813@smallexample
1814gcc foo.c bar.c -c -dumpbase main ...
1815@end smallexample
1816
1817creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1818overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1819as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1820and @file{main-bar.*}.
1821
1822An empty string specified as @var{dumpbase} avoids the influence of the
1823output basename in the naming of auxiliary and dump outputs during
1824compilation, computing default values :
1825
1826@smallexample
1827gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1828@end smallexample
1829
1830will name aux outputs @file{dir/foo.*} and dump outputs
1831@file{dir/foo.c.*}. Note how their basenames are taken from the input
1832name, but the directory still defaults to that of the output.
1833
1834The empty-string dumpbase does not prevent the use of the output
1835basename for outputs during linking:
1836
1837@smallexample
1838gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1839@end smallexample
1840
1841The compilation of the source files will name auxiliary outputs
1842@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1843@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1844linking will use @file{dir/foobar.} as the prefix for dumps and
1845auxiliary files.
1846
1847
d77de738 1848@opindex dumpbase-ext
ddf6fe37 1849@item -dumpbase-ext @var{auxdropsuf}
d77de738
ML
1850When forming the name of an auxiliary (but not a dump) output file, drop
1851trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1852suffixes. If not specified, this option defaults to the suffix of a
1853default @var{dumpbase}, i.e., the suffix of the input file when
1854@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1855is combined with @var{dumppfx}.
1856
1857@smallexample
1858gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1859@end smallexample
1860
1861creates @file{dir/foo.o} as the main output, and generates auxiliary
1862outputs in @file{dir/x-foo.*}, taking the location of the primary
1863output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1864outputs retain the suffix: @file{dir/x-foo.c.*}.
1865
1866This option is disregarded if it does not match the suffix of a
1867specified @var{dumpbase}, except as an alternative to the executable
1868suffix when appending the linker output base name to @var{dumppfx}, as
1869specified below:
1870
1871@smallexample
1872gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1873@end smallexample
1874
1875creates @file{main.out} as the primary output, and avoids overwriting
1876the auxiliary and dump outputs by using the executable name minus
1877@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1878@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1879@file{main-foo.c.*} and @file{main-bar.c.*}.
1880
1881
d77de738 1882@opindex dumpdir
ddf6fe37 1883@item -dumpdir @var{dumppfx}
d77de738
ML
1884When forming the name of an auxiliary or dump output file, use
1885@var{dumppfx} as a prefix:
1886
1887@smallexample
1888gcc -dumpdir pfx- -c foo.c ...
1889@end smallexample
1890
1891creates @file{foo.o} as the primary output, and auxiliary outputs named
1892@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1893@var{dumpbase} derived from the default primary output, derived in turn
1894from the input name. Dump outputs also take the input name suffix:
1895@file{pfx-foo.c.*}.
1896
1897If @var{dumppfx} is to be used as a directory name, it must end with a
1898directory separator:
1899
1900@smallexample
1901gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1902@end smallexample
1903
1904creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1905named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1906default @var{dumpbase} derived from the primary output name. Dump
1907outputs also take the input name suffix: @file{dir/bar.c.*}.
1908
1909It defaults to the location of the output file, unless the output
1910file is a special file like @code{/dev/null}. Options
1911@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1912default, just like an explicit @option{-dumpdir} option. In case
1913multiple such options are given, the last one prevails:
1914
1915@smallexample
1916gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1917@end smallexample
1918
1919outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1920@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1921@option{-dumpdir} option. It does not matter that @option{=obj} is the
1922default for @option{-save-temps}, nor that the output directory is
1923implicitly the current directory. Dump outputs are named
1924@file{foo.c.*}.
1925
1926When compiling from multiple input files, if @option{-dumpbase} is
1927specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1928are appended to (or override, if containing any directory components) an
1929explicit or defaulted @var{dumppfx}, so that each of the multiple
1930compilations gets differently-named aux and dump outputs.
1931
1932@smallexample
1933gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1934@end smallexample
1935
1936outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1937@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1938Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1939and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1940single-input compilation:
1941
1942@smallexample
1943gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1944@end smallexample
1945
1946that, applying @option{-dumpbase} to a single source, does not compute
1947and append a separate @var{dumpbase} per input file. Its auxiliary and
1948dump outputs go in @file{dir/pfx-main.*}.
1949
1950When compiling and then linking from multiple input files, a defaulted
1951or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1952transformation above (e.g. the compilation of @file{foo.c} and
1953@file{bar.c} above, but without @option{-c}). If neither
1954@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1955base name, minus @var{auxdropsuf}, if specified, or the executable
1956suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1957instead. Note, however, that unlike earlier cases of linking:
1958
1959@smallexample
1960gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1961@end smallexample
1962
1963does not append the output name @file{main} to @var{dumppfx}, because
1964@option{-dumpdir} is explicitly specified. The goal is that the
1965explicitly-specified @var{dumppfx} may contain the specified output name
1966as part of the prefix, if desired; only an explicitly-specified
1967@option{-dumpbase} would be combined with it, in order to avoid simply
1968discarding a meaningful option.
1969
1970When compiling and then linking from a single input file, the linker
1971output base name will only be appended to the default @var{dumppfx} as
1972above if it does not share the base name with the single input file
1973name. This has been covered in single-input linking cases above, but
1974not with an explicit @option{-dumpdir} that inhibits the combination,
1975even if overridden by @option{-save-temps=*}:
1976
1977@smallexample
1978gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1979@end smallexample
1980
1981Auxiliary outputs are named @file{foo.*}, and dump outputs
1982@file{foo.c.*}, in the current working directory as ultimately requested
1983by @option{-save-temps=cwd}.
1984
1985Summing it all up for an intuitive though slightly imprecise data flow:
1986the primary output name is broken into a directory part and a basename
1987part; @var{dumppfx} is set to the former, unless overridden by
1988@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
1989to the latter, unless overriden by @option{-dumpbase}. If there are
1990multiple inputs or linking, this @var{dumpbase} may be combined with
1991@var{dumppfx} and taken from each input file. Auxiliary output names
1992for each input are formed by combining @var{dumppfx}, @var{dumpbase}
1993minus suffix, and the auxiliary output suffix; dump output names are
1994only different in that the suffix from @var{dumpbase} is retained.
1995
1996When it comes to auxiliary and dump outputs created during LTO
1997recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
1998given or as derived from the linker output name but not from inputs,
1999even in cases in which this combination would not otherwise be used as
2000such, is passed down with a trailing period replacing the compiler-added
2001dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
2002being involved in linking, this program does not normally get any
2003@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2004
2005When running sub-compilers, @command{lto-wrapper} appends LTO stage
2006names to the received @var{dumppfx}, ensures it contains a directory
2007component so that it overrides any @option{-dumpdir}, and passes that as
2008@option{-dumpbase} to sub-compilers.
2009
d77de738 2010@opindex v
ddf6fe37 2011@item -v
d77de738
ML
2012Print (on standard error output) the commands executed to run the stages
2013of compilation. Also print the version number of the compiler driver
2014program and of the preprocessor and the compiler proper.
2015
d77de738 2016@opindex ###
ddf6fe37 2017@item -###
d77de738
ML
2018Like @option{-v} except the commands are not executed and arguments
2019are quoted unless they contain only alphanumeric characters or @code{./-_}.
2020This is useful for shell scripts to capture the driver-generated command lines.
2021
d77de738 2022@opindex help
ddf6fe37 2023@item --help
d77de738
ML
2024Print (on the standard output) a description of the command-line options
2025understood by @command{gcc}. If the @option{-v} option is also specified
2026then @option{--help} is also passed on to the various processes
2027invoked by @command{gcc}, so that they can display the command-line options
2028they accept. If the @option{-Wextra} option has also been specified
2029(prior to the @option{--help} option), then command-line options that
2030have no documentation associated with them are also displayed.
2031
d77de738 2032@opindex target-help
ddf6fe37 2033@item --target-help
d77de738
ML
2034Print (on the standard output) a description of target-specific command-line
2035options for each tool. For some targets extra target-specific
2036information may also be printed.
2037
2038@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2039Print (on the standard output) a description of the command-line
2040options understood by the compiler that fit into all specified classes
2041and qualifiers. These are the supported classes:
2042
2043@table @asis
2044@item @samp{optimizers}
2045Display all of the optimization options supported by the
2046compiler.
2047
2048@item @samp{warnings}
2049Display all of the options controlling warning messages
2050produced by the compiler.
2051
2052@item @samp{target}
2053Display target-specific options. Unlike the
2054@option{--target-help} option however, target-specific options of the
2055linker and assembler are not displayed. This is because those
2056tools do not currently support the extended @option{--help=} syntax.
2057
2058@item @samp{params}
2059Display the values recognized by the @option{--param}
2060option.
2061
2062@item @var{language}
2063Display the options supported for @var{language}, where
2064@var{language} is the name of one of the languages supported in this
2065version of GCC@. If an option is supported by all languages, one needs
2066to select @samp{common} class.
2067
2068@item @samp{common}
2069Display the options that are common to all languages.
2070@end table
2071
2072These are the supported qualifiers:
2073
2074@table @asis
2075@item @samp{undocumented}
2076Display only those options that are undocumented.
2077
2078@item @samp{joined}
2079Display options taking an argument that appears after an equal
2080sign in the same continuous piece of text, such as:
2081@samp{--help=target}.
2082
2083@item @samp{separate}
2084Display options taking an argument that appears as a separate word
2085following the original option, such as: @samp{-o output-file}.
2086@end table
2087
2088Thus for example to display all the undocumented target-specific
2089switches supported by the compiler, use:
2090
2091@smallexample
2092--help=target,undocumented
2093@end smallexample
2094
2095The sense of a qualifier can be inverted by prefixing it with the
2096@samp{^} character, so for example to display all binary warning
2097options (i.e., ones that are either on or off and that do not take an
2098argument) that have a description, use:
2099
2100@smallexample
2101--help=warnings,^joined,^undocumented
2102@end smallexample
2103
2104The argument to @option{--help=} should not consist solely of inverted
2105qualifiers.
2106
2107Combining several classes is possible, although this usually
2108restricts the output so much that there is nothing to display. One
2109case where it does work, however, is when one of the classes is
2110@var{target}. For example, to display all the target-specific
2111optimization options, use:
2112
2113@smallexample
2114--help=target,optimizers
2115@end smallexample
2116
2117The @option{--help=} option can be repeated on the command line. Each
2118successive use displays its requested class of options, skipping
2119those that have already been displayed. If @option{--help} is also
2120specified anywhere on the command line then this takes precedence
2121over any @option{--help=} option.
2122
2123If the @option{-Q} option appears on the command line before the
2124@option{--help=} option, then the descriptive text displayed by
2125@option{--help=} is changed. Instead of describing the displayed
2126options, an indication is given as to whether the option is enabled,
2127disabled or set to a specific value (assuming that the compiler
2128knows this at the point where the @option{--help=} option is used).
2129
2130Here is a truncated example from the ARM port of @command{gcc}:
2131
2132@smallexample
2133 % gcc -Q -mabi=2 --help=target -c
2134 The following options are target specific:
2135 -mabi= 2
2136 -mabort-on-noreturn [disabled]
2137 -mapcs [disabled]
2138@end smallexample
2139
2140The output is sensitive to the effects of previous command-line
2141options, so for example it is possible to find out which optimizations
2142are enabled at @option{-O2} by using:
2143
2144@smallexample
2145-Q -O2 --help=optimizers
2146@end smallexample
2147
2148Alternatively you can discover which binary optimizations are enabled
2149by @option{-O3} by using:
2150
2151@smallexample
2152gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2153gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2154diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2155@end smallexample
2156
d77de738 2157@opindex version
ddf6fe37 2158@item --version
d77de738
ML
2159Display the version number and copyrights of the invoked GCC@.
2160
d77de738 2161@opindex pass-exit-codes
ddf6fe37 2162@item -pass-exit-codes
d77de738
ML
2163Normally the @command{gcc} program exits with the code of 1 if any
2164phase of the compiler returns a non-success return code. If you specify
2165@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2166the numerically highest error produced by any phase returning an error
2167indication. The C, C++, and Fortran front ends return 4 if an internal
2168compiler error is encountered.
2169
d77de738 2170@opindex pipe
ddf6fe37 2171@item -pipe
d77de738
ML
2172Use pipes rather than temporary files for communication between the
2173various stages of compilation. This fails to work on some systems where
2174the assembler is unable to read from a pipe; but the GNU assembler has
2175no trouble.
2176
d77de738 2177@opindex specs
ddf6fe37 2178@item -specs=@var{file}
d77de738
ML
2179Process @var{file} after the compiler reads in the standard @file{specs}
2180file, in order to override the defaults which the @command{gcc} driver
2181program uses when determining what switches to pass to @command{cc1},
2182@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2183@option{-specs=@var{file}} can be specified on the command line, and they
2184are processed in order, from left to right. @xref{Spec Files}, for
2185information about the format of the @var{file}.
2186
d77de738 2187@opindex wrapper
ddf6fe37 2188@item -wrapper
d77de738
ML
2189Invoke all subcommands under a wrapper program. The name of the
2190wrapper program and its parameters are passed as a comma separated
2191list.
2192
2193@smallexample
2194gcc -c t.c -wrapper gdb,--args
2195@end smallexample
2196
2197@noindent
2198This invokes all subprograms of @command{gcc} under
2199@samp{gdb --args}, thus the invocation of @command{cc1} is
2200@samp{gdb --args cc1 @dots{}}.
2201
d77de738 2202@opindex ffile-prefix-map
ddf6fe37 2203@item -ffile-prefix-map=@var{old}=@var{new}
d77de738
ML
2204When compiling files residing in directory @file{@var{old}}, record
2205any references to them in the result of the compilation as if the
2206files resided in directory @file{@var{new}} instead. Specifying this
2207option is equivalent to specifying all the individual
2208@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27 2209builds that are location independent. Directories referenced by
2eb0191a
JJ
2210directives are not affected by these options. See also
2211@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map},
2212@option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}.
2213
2214@item -fcanon-prefix-map
2215@opindex fcanon-prefix-map
2216For the @option{-f*-prefix-map} options normally comparison
2217of @file{@var{old}} prefix against the filename that would be normally
2218referenced in the result of the compilation is done using textual
2219comparison of the prefixes, or ignoring character case for case insensitive
2220filesystems and considering slashes and backslashes as equal on DOS based
2221filesystems. The @option{-fcanon-prefix-map} causes such comparisons
2222to be done on canonicalized paths of @file{@var{old}}
2223and the referenced filename.
d77de738 2224
d77de738 2225@opindex fplugin
ddf6fe37 2226@item -fplugin=@var{name}.so
d77de738
ML
2227Load the plugin code in file @var{name}.so, assumed to be a
2228shared object to be dlopen'd by the compiler. The base name of
2229the shared object file is used to identify the plugin for the
2230purposes of argument parsing (See
2231@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2232Each plugin should define the callback functions specified in the
2233Plugins API.
2234
d77de738 2235@opindex fplugin-arg
ddf6fe37 2236@item -fplugin-arg-@var{name}-@var{key}=@var{value}
d77de738
ML
2237Define an argument called @var{key} with a value of @var{value}
2238for the plugin called @var{name}.
2239
d77de738 2240@opindex fdump-ada-spec
ddf6fe37 2241@item -fdump-ada-spec@r{[}-slim@r{]}
d77de738
ML
2242For C and C++ source and include files, generate corresponding Ada specs.
2243@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2244GNAT User's Guide}, which provides detailed documentation on this feature.
2245
d77de738 2246@opindex fada-spec-parent
ddf6fe37 2247@item -fada-spec-parent=@var{unit}
d77de738
ML
2248In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2249Ada specs as child units of parent @var{unit}.
2250
d77de738 2251@opindex fdump-go-spec
ddf6fe37 2252@item -fdump-go-spec=@var{file}
d77de738
ML
2253For input files in any language, generate corresponding Go
2254declarations in @var{file}. This generates Go @code{const},
2255@code{type}, @code{var}, and @code{func} declarations which may be a
2256useful way to start writing a Go interface to code written in some
2257other language.
2258
2259@include @value{srcdir}/../libiberty/at-file.texi
2260@end table
2261
2262@node Invoking G++
2263@section Compiling C++ Programs
2264
2265@cindex suffixes for C++ source
2266@cindex C++ source file suffixes
2267C++ source files conventionally use one of the suffixes @samp{.C},
2268@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2269@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2270@samp{.H}, or (for shared template code) @samp{.tcc}; and
2271preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2272files with these names and compiles them as C++ programs even if you
2273call the compiler the same way as for compiling C programs (usually
2274with the name @command{gcc}).
2275
2276@findex g++
2277@findex c++
2278However, the use of @command{gcc} does not add the C++ library.
2279@command{g++} is a program that calls GCC and automatically specifies linking
2280against the C++ library. It treats @samp{.c},
2281@samp{.h} and @samp{.i} files as C++ source files instead of C source
2282files unless @option{-x} is used. This program is also useful when
2283precompiling a C header file with a @samp{.h} extension for use in C++
2284compilations. On many systems, @command{g++} is also installed with
2285the name @command{c++}.
2286
2287@cindex invoking @command{g++}
2288When you compile C++ programs, you may specify many of the same
2289command-line options that you use for compiling programs in any
2290language; or command-line options meaningful for C and related
2291languages; or options that are meaningful only for C++ programs.
2292@xref{C Dialect Options,,Options Controlling C Dialect}, for
2293explanations of options for languages related to C@.
2294@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2295explanations of options that are meaningful only for C++ programs.
2296
2297@node C Dialect Options
2298@section Options Controlling C Dialect
2299@cindex dialect options
2300@cindex language dialect options
2301@cindex options, dialect
2302
2303The following options control the dialect of C (or languages derived
2304from C, such as C++, Objective-C and Objective-C++) that the compiler
2305accepts:
2306
2307@table @gcctabopt
2308@cindex ANSI support
2309@cindex ISO support
d77de738 2310@opindex ansi
ddf6fe37 2311@item -ansi
d77de738
ML
2312In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2313equivalent to @option{-std=c++98}.
2314
2315This turns off certain features of GCC that are incompatible with ISO
2316C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2317such as the @code{asm} and @code{typeof} keywords, and
2318predefined macros such as @code{unix} and @code{vax} that identify the
2319type of system you are using. It also enables the undesirable and
2320rarely used ISO trigraph feature. For the C compiler,
2321it disables recognition of C++ style @samp{//} comments as well as
2322the @code{inline} keyword.
2323
2324The alternate keywords @code{__asm__}, @code{__extension__},
2325@code{__inline__} and @code{__typeof__} continue to work despite
2326@option{-ansi}. You would not want to use them in an ISO C program, of
2327course, but it is useful to put them in header files that might be included
2328in compilations done with @option{-ansi}. Alternate predefined macros
2329such as @code{__unix__} and @code{__vax__} are also available, with or
2330without @option{-ansi}.
2331
2332The @option{-ansi} option does not cause non-ISO programs to be
2333rejected gratuitously. For that, @option{-Wpedantic} is required in
2334addition to @option{-ansi}. @xref{Warning Options}.
2335
2336The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2337option is used. Some header files may notice this macro and refrain
2338from declaring certain functions or defining certain macros that the
2339ISO standard doesn't call for; this is to avoid interfering with any
2340programs that might use these names for other things.
2341
2342Functions that are normally built in but do not have semantics
2343defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2344functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2345built-in functions provided by GCC}, for details of the functions
2346affected.
2347
d77de738 2348@opindex std
ddf6fe37 2349@item -std=
d77de738
ML
2350Determine the language standard. @xref{Standards,,Language Standards
2351Supported by GCC}, for details of these standard versions. This option
2352is currently only supported when compiling C or C++.
2353
2354The compiler can accept several base standards, such as @samp{c90} or
2355@samp{c++98}, and GNU dialects of those standards, such as
2356@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2357compiler accepts all programs following that standard plus those
2358using GNU extensions that do not contradict it. For example,
2359@option{-std=c90} turns off certain features of GCC that are
2360incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2361keywords, but not other GNU extensions that do not have a meaning in
2362ISO C90, such as omitting the middle term of a @code{?:}
2363expression. On the other hand, when a GNU dialect of a standard is
2364specified, all features supported by the compiler are enabled, even when
2365those features change the meaning of the base standard. As a result, some
2366strict-conforming programs may be rejected. The particular standard
2367is used by @option{-Wpedantic} to identify which features are GNU
2368extensions given that version of the standard. For example
2369@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2370comments, while @option{-std=gnu99 -Wpedantic} does not.
2371
2372A value for this option must be provided; possible values are
2373
2374@table @samp
2375@item c90
2376@itemx c89
2377@itemx iso9899:1990
2378Support all ISO C90 programs (certain GNU extensions that conflict
2379with ISO C90 are disabled). Same as @option{-ansi} for C code.
2380
2381@item iso9899:199409
2382ISO C90 as modified in amendment 1.
2383
2384@item c99
2385@itemx c9x
2386@itemx iso9899:1999
2387@itemx iso9899:199x
2388ISO C99. This standard is substantially completely supported, modulo
2389bugs and floating-point issues
2390(mainly but not entirely relating to optional C99 features from
2391Annexes F and G). See
2392@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2393names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2394
2395@item c11
2396@itemx c1x
2397@itemx iso9899:2011
2398ISO C11, the 2011 revision of the ISO C standard. This standard is
2399substantially completely supported, modulo bugs, floating-point issues
2400(mainly but not entirely relating to optional C11 features from
2401Annexes F and G) and the optional Annexes K (Bounds-checking
2402interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2403
2404@item c17
2405@itemx c18
2406@itemx iso9899:2017
2407@itemx iso9899:2018
2408ISO C17, the 2017 revision of the ISO C standard
2409(published in 2018). This standard is
2410same as C11 except for corrections of defects (all of which are also
2411applied with @option{-std=c11}) and a new value of
2412@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2413
2414@item c2x
2415The next version of the ISO C standard, still under development. The
2416support for this version is experimental and incomplete.
2417
2418@item gnu90
2419@itemx gnu89
2420GNU dialect of ISO C90 (including some C99 features).
2421
2422@item gnu99
2423@itemx gnu9x
2424GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2425
2426@item gnu11
2427@itemx gnu1x
2428GNU dialect of ISO C11.
2429The name @samp{gnu1x} is deprecated.
2430
2431@item gnu17
2432@itemx gnu18
2433GNU dialect of ISO C17. This is the default for C code.
2434
2435@item gnu2x
2436The next version of the ISO C standard, still under development, plus
2437GNU extensions. The support for this version is experimental and
2438incomplete.
2439
2440@item c++98
2441@itemx c++03
2442The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2443additional defect reports. Same as @option{-ansi} for C++ code.
2444
2445@item gnu++98
2446@itemx gnu++03
2447GNU dialect of @option{-std=c++98}.
2448
2449@item c++11
2450@itemx c++0x
2451The 2011 ISO C++ standard plus amendments.
2452The name @samp{c++0x} is deprecated.
2453
2454@item gnu++11
2455@itemx gnu++0x
2456GNU dialect of @option{-std=c++11}.
2457The name @samp{gnu++0x} is deprecated.
2458
2459@item c++14
2460@itemx c++1y
2461The 2014 ISO C++ standard plus amendments.
2462The name @samp{c++1y} is deprecated.
2463
2464@item gnu++14
2465@itemx gnu++1y
2466GNU dialect of @option{-std=c++14}.
2467The name @samp{gnu++1y} is deprecated.
2468
2469@item c++17
2470@itemx c++1z
2471The 2017 ISO C++ standard plus amendments.
2472The name @samp{c++1z} is deprecated.
2473
2474@item gnu++17
2475@itemx gnu++1z
2476GNU dialect of @option{-std=c++17}.
2477This is the default for C++ code.
2478The name @samp{gnu++1z} is deprecated.
2479
2480@item c++20
2481@itemx c++2a
2482The 2020 ISO C++ standard plus amendments.
2483Support is experimental, and could change in incompatible ways in
2484future releases.
2485The name @samp{c++2a} is deprecated.
2486
2487@item gnu++20
2488@itemx gnu++2a
2489GNU dialect of @option{-std=c++20}.
2490Support is experimental, and could change in incompatible ways in
2491future releases.
2492The name @samp{gnu++2a} is deprecated.
2493
2494@item c++2b
2495@itemx c++23
2496The next revision of the ISO C++ standard, planned for
24972023. Support is highly experimental, and will almost certainly
2498change in incompatible ways in future releases.
2499
2500@item gnu++2b
2501@itemx gnu++23
2502GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2503and will almost certainly change in incompatible ways in future
2504releases.
2505@end table
2506
d77de738 2507@opindex aux-info
ddf6fe37 2508@item -aux-info @var{filename}
d77de738
ML
2509Output to the given filename prototyped declarations for all functions
2510declared and/or defined in a translation unit, including those in header
2511files. This option is silently ignored in any language other than C@.
2512
2513Besides declarations, the file indicates, in comments, the origin of
2514each declaration (source file and line), whether the declaration was
2515implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2516@samp{O} for old, respectively, in the first character after the line
2517number and the colon), and whether it came from a declaration or a
2518definition (@samp{C} or @samp{F}, respectively, in the following
2519character). In the case of function definitions, a K&R-style list of
2520arguments followed by their declarations is also provided, inside
2521comments, after the declaration.
2522
d77de738
ML
2523@opindex fno-asm
2524@opindex fasm
ddf6fe37 2525@item -fno-asm
d77de738
ML
2526Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2527keyword, so that code can use these words as identifiers. You can use
2528the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2529instead. In C, @option{-ansi} implies @option{-fno-asm}.
2530
2531In C++, @code{inline} is a standard keyword and is not affected by
2532this switch. You may want to use the @option{-fno-gnu-keywords} flag
2533instead, which disables @code{typeof} but not @code{asm} and
2534@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2535this switch only affects the @code{asm} and @code{typeof} keywords,
2536since @code{inline} is a standard keyword in ISO C99. In C2X mode
2537(@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects
2538the @code{asm} keyword, since @code{typeof} is a standard keyword in
2539ISO C2X.
2540
d77de738
ML
2541@opindex fno-builtin
2542@opindex fbuiltin
f33d7a88 2543@cindex built-in functions
ddf6fe37
AA
2544@item -fno-builtin
2545@itemx -fno-builtin-@var{function}
d77de738
ML
2546Don't recognize built-in functions that do not begin with
2547@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2548functions provided by GCC}, for details of the functions affected,
2549including those which are not built-in functions when @option{-ansi} or
2550@option{-std} options for strict ISO C conformance are used because they
2551do not have an ISO standard meaning.
2552
2553GCC normally generates special code to handle certain built-in functions
2554more efficiently; for instance, calls to @code{alloca} may become single
2555instructions which adjust the stack directly, and calls to @code{memcpy}
2556may become inline copy loops. The resulting code is often both smaller
2557and faster, but since the function calls no longer appear as such, you
2558cannot set a breakpoint on those calls, nor can you change the behavior
2559of the functions by linking with a different library. In addition,
2560when a function is recognized as a built-in function, GCC may use
2561information about that function to warn about problems with calls to
2562that function, or to generate more efficient code, even if the
2563resulting code still contains calls to that function. For example,
2564warnings are given with @option{-Wformat} for bad calls to
2565@code{printf} when @code{printf} is built in and @code{strlen} is
2566known not to modify global memory.
2567
2568With the @option{-fno-builtin-@var{function}} option
2569only the built-in function @var{function} is
2570disabled. @var{function} must not begin with @samp{__builtin_}. If a
2571function is named that is not built-in in this version of GCC, this
2572option is ignored. There is no corresponding
2573@option{-fbuiltin-@var{function}} option; if you wish to enable
2574built-in functions selectively when using @option{-fno-builtin} or
2575@option{-ffreestanding}, you may define macros such as:
2576
2577@smallexample
2578#define abs(n) __builtin_abs ((n))
2579#define strcpy(d, s) __builtin_strcpy ((d), (s))
2580@end smallexample
2581
d77de738 2582@opindex fcond-mismatch
ddf6fe37 2583@item -fcond-mismatch
d77de738
ML
2584Allow conditional expressions with mismatched types in the second and
2585third arguments. The value of such an expression is void. This option
2586is not supported for C++.
2587
d77de738
ML
2588@opindex ffreestanding
2589@cindex hosted environment
f33d7a88 2590@item -ffreestanding
d77de738
ML
2591
2592Assert that compilation targets a freestanding environment. This
2593implies @option{-fno-builtin}. A freestanding environment
2594is one in which the standard library may not exist, and program startup may
2595not necessarily be at @code{main}. The most obvious example is an OS kernel.
2596This is equivalent to @option{-fno-hosted}.
2597
2598@xref{Standards,,Language Standards Supported by GCC}, for details of
2599freestanding and hosted environments.
2600
d77de738 2601@opindex fgimple
ddf6fe37 2602@item -fgimple
d77de738
ML
2603
2604Enable parsing of function definitions marked with @code{__GIMPLE}.
2605This is an experimental feature that allows unit testing of GIMPLE
2606passes.
2607
d77de738 2608@opindex fgnu-tm
ddf6fe37 2609@item -fgnu-tm
d77de738
ML
2610When the option @option{-fgnu-tm} is specified, the compiler
2611generates code for the Linux variant of Intel's current Transactional
2612Memory ABI specification document (Revision 1.1, May 6 2009). This is
2613an experimental feature whose interface may change in future versions
2614of GCC, as the official specification changes. Please note that not
2615all architectures are supported for this feature.
2616
2617For more information on GCC's support for transactional memory,
2618@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2619Transactional Memory Library}.
2620
2621Note that the transactional memory feature is not supported with
2622non-call exceptions (@option{-fnon-call-exceptions}).
2623
d77de738 2624@opindex fgnu89-inline
ddf6fe37 2625@item -fgnu89-inline
d77de738
ML
2626The option @option{-fgnu89-inline} tells GCC to use the traditional
2627GNU semantics for @code{inline} functions when in C99 mode.
2628@xref{Inline,,An Inline Function is As Fast As a Macro}.
2629Using this option is roughly equivalent to adding the
2630@code{gnu_inline} function attribute to all inline functions
2631(@pxref{Function Attributes}).
2632
2633The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2634C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2635specifies the default behavior).
2636This option is not supported in @option{-std=c90} or
2637@option{-std=gnu90} mode.
2638
2639The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2640@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2641in effect for @code{inline} functions. @xref{Common Predefined
2642Macros,,,cpp,The C Preprocessor}.
2643
d77de738
ML
2644@opindex fhosted
2645@cindex hosted environment
f33d7a88 2646@item -fhosted
d77de738
ML
2647
2648Assert that compilation targets a hosted environment. This implies
2649@option{-fbuiltin}. A hosted environment is one in which the
2650entire standard library is available, and in which @code{main} has a return
2651type of @code{int}. Examples are nearly everything except a kernel.
2652This is equivalent to @option{-fno-freestanding}.
2653
d77de738 2654@opindex flax-vector-conversions
ddf6fe37 2655@item -flax-vector-conversions
d77de738
ML
2656Allow implicit conversions between vectors with differing numbers of
2657elements and/or incompatible element types. This option should not be
2658used for new code.
2659
d77de738 2660@opindex fms-extensions
ddf6fe37 2661@item -fms-extensions
d77de738
ML
2662Accept some non-standard constructs used in Microsoft header files.
2663
2664In C++ code, this allows member names in structures to be similar
2665to previous types declarations.
2666
2667@smallexample
2668typedef int UOW;
2669struct ABC @{
2670 UOW UOW;
2671@};
2672@end smallexample
2673
2674Some cases of unnamed fields in structures and unions are only
2675accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2676fields within structs/unions}, for details.
2677
2678Note that this option is off for all targets except for x86
2679targets using ms-abi.
2680
ddf6fe37 2681@opindex foffload
d77de738
ML
2682@cindex Offloading targets
2683@cindex OpenACC offloading targets
2684@cindex OpenMP offloading targets
f33d7a88
AA
2685@item -foffload=disable
2686@itemx -foffload=default
2687@itemx -foffload=@var{target-list}
d77de738
ML
2688Specify for which OpenMP and OpenACC offload targets code should be generated.
2689The default behavior, equivalent to @option{-foffload=default}, is to generate
2690code for all supported offload targets. The @option{-foffload=disable} form
2691generates code only for the host fallback, while
2692@option{-foffload=@var{target-list}} generates code only for the specified
2693comma-separated list of offload targets.
2694
2695Offload targets are specified in GCC's internal target-triplet format. You can
2696run the compiler with @option{-v} to show the list of configured offload targets
2697under @code{OFFLOAD_TARGET_NAMES}.
2698
ddf6fe37 2699@opindex foffload-options
d77de738
ML
2700@cindex Offloading options
2701@cindex OpenACC offloading options
2702@cindex OpenMP offloading options
f33d7a88
AA
2703@item -foffload-options=@var{options}
2704@itemx -foffload-options=@var{target-triplet-list}=@var{options}
d77de738
ML
2705
2706With @option{-foffload-options=@var{options}}, GCC passes the specified
2707@var{options} to the compilers for all enabled offloading targets. You can
2708specify options that apply only to a specific target or targets by using
2709the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2710@var{target-list} is a comma-separated list in the same format as for the
2711@option{-foffload=} option.
2712
2713Typical command lines are
2714
2715@smallexample
2716-foffload-options=-lgfortran -foffload-options=-lm
2717-foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic
2718-foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm
2719@end smallexample
2720
d77de738
ML
2721@opindex fopenacc
2722@cindex OpenACC accelerator programming
f33d7a88 2723@item -fopenacc
d77de738
ML
2724Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and
2725@code{!$acc} in Fortran. When @option{-fopenacc} is specified, the
2726compiler generates accelerated code according to the OpenACC Application
2727Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2728implies @option{-pthread}, and thus is only supported on targets that
2729have support for @option{-pthread}.
2730
d77de738
ML
2731@opindex fopenacc-dim
2732@cindex OpenACC accelerator programming
f33d7a88 2733@item -fopenacc-dim=@var{geom}
d77de738
ML
2734Specify default compute dimensions for parallel offload regions that do
2735not explicitly specify. The @var{geom} value is a triple of
2736':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2737can be omitted, to use a target-specific default value.
2738
d77de738
ML
2739@opindex fopenmp
2740@cindex OpenMP parallel
f33d7a88 2741@item -fopenmp
d77de738
ML
2742Enable handling of OpenMP directives @code{#pragma omp} in C/C++,
2743@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and
2744@code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
2745compiler generates parallel code according to the OpenMP Application
2746Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2747implies @option{-pthread}, and thus is only supported on targets that
2748have support for @option{-pthread}. @option{-fopenmp} implies
2749@option{-fopenmp-simd}.
2750
d77de738
ML
2751@opindex fopenmp-simd
2752@cindex OpenMP SIMD
2753@cindex SIMD
f33d7a88 2754@item -fopenmp-simd
d77de738
ML
2755Enable handling of OpenMP's @code{simd}, @code{declare simd},
2756@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan},
2757@code{loop} directives and combined or composite directives with
2758@code{simd} as constituent with @code{#pragma omp} in C/C++,
2759@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++
2760and @code{!$omp} in Fortran. Other OpenMP directives are ignored.
2761
ddf6fe37 2762@opindex fopenmp-target-simd-clone
f33d7a88 2763@cindex OpenMP target SIMD clone
309e2d95
SL
2764@item -fopenmp-target-simd-clone
2765@item -fopenmp-target-simd-clone=@var{device-type}
309e2d95
SL
2766In addition to generating SIMD clones for functions marked with the
2767@code{declare simd} directive, GCC also generates clones
2768for functions marked with the OpenMP @code{declare target} directive
2769that are suitable for vectorization when this option is in effect. The
2770@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2771and @code{any}, which correspond to keywords for the @code{device_type}
2772clause of the @code{declare target} directive; clones are generated for
2773the intersection of devices specified.
2774@option{-fopenmp-target-simd-clone} is equivalent to
2775@option{-fopenmp-target-simd-clone=any} and
2776@option{-fno-openmp-target-simd-clone} is equivalent to
2777@option{-fopenmp-target-simd-clone=none}.
2778
2779At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2780optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2781it is disabled by default.
2782
d77de738
ML
2783@opindex fpermitted-flt-eval-methods
2784@opindex fpermitted-flt-eval-methods=c11
2785@opindex fpermitted-flt-eval-methods=ts-18661-3
ddf6fe37 2786@item -fpermitted-flt-eval-methods=@var{style}
d77de738
ML
2787ISO/IEC TS 18661-3 defines new permissible values for
2788@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2789a semantic type that is an interchange or extended format should be
2790evaluated to the precision and range of that type. These new values are
2791a superset of those permitted under C99/C11, which does not specify the
2792meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2793conforming to C11 may not have been written expecting the possibility of
2794the new values.
2795
2796@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2797should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2798or the extended set of values specified in ISO/IEC TS 18661-3.
2799
2800@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2801
2802The default when in a standards compliant mode (@option{-std=c11} or similar)
2803is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2804dialect (@option{-std=gnu11} or similar) is
2805@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2806
d77de738 2807@opindex fplan9-extensions
ddf6fe37 2808@item -fplan9-extensions
d77de738
ML
2809Accept some non-standard constructs used in Plan 9 code.
2810
2811This enables @option{-fms-extensions}, permits passing pointers to
2812structures with anonymous fields to functions that expect pointers to
2813elements of the type of the field, and permits referring to anonymous
2814fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2815struct/union fields within structs/unions}, for details. This is only
2816supported for C, not C++.
2817
d77de738
ML
2818@opindex fsigned-bitfields
2819@opindex funsigned-bitfields
2820@opindex fno-signed-bitfields
2821@opindex fno-unsigned-bitfields
ddf6fe37
AA
2822@item -fsigned-bitfields
2823@itemx -funsigned-bitfields
2824@itemx -fno-signed-bitfields
2825@itemx -fno-unsigned-bitfields
d77de738
ML
2826These options control whether a bit-field is signed or unsigned, when the
2827declaration does not use either @code{signed} or @code{unsigned}. By
2828default, such a bit-field is signed, because this is consistent: the
2829basic integer types such as @code{int} are signed types.
2830
d77de738 2831@opindex fsigned-char
ddf6fe37 2832@item -fsigned-char
d77de738
ML
2833Let the type @code{char} be signed, like @code{signed char}.
2834
2835Note that this is equivalent to @option{-fno-unsigned-char}, which is
2836the negative form of @option{-funsigned-char}. Likewise, the option
2837@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2838
d77de738 2839@opindex funsigned-char
ddf6fe37 2840@item -funsigned-char
d77de738
ML
2841Let the type @code{char} be unsigned, like @code{unsigned char}.
2842
2843Each kind of machine has a default for what @code{char} should
2844be. It is either like @code{unsigned char} by default or like
2845@code{signed char} by default.
2846
2847Ideally, a portable program should always use @code{signed char} or
2848@code{unsigned char} when it depends on the signedness of an object.
2849But many programs have been written to use plain @code{char} and
2850expect it to be signed, or expect it to be unsigned, depending on the
2851machines they were written for. This option, and its inverse, let you
2852make such a program work with the opposite default.
2853
2854The type @code{char} is always a distinct type from each of
2855@code{signed char} or @code{unsigned char}, even though its behavior
2856is always just like one of those two.
2857
d77de738
ML
2858@opindex fstrict-flex-arrays
2859@opindex fno-strict-flex-arrays
ddf6fe37 2860@item -fstrict-flex-arrays
d77de738
ML
2861Control when to treat the trailing array of a structure as a flexible array
2862member for the purpose of accessing the elements of such an array.
2863The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2864strictest. A trailing array is treated as a flexible array member only when it
2865is declared as a flexible array member per C99 standard onwards.
2866The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2867least strict. All trailing arrays of structures are treated as flexible array
2868members.
2869
d77de738 2870@opindex fstrict-flex-arrays=@var{level}
ddf6fe37 2871@item -fstrict-flex-arrays=@var{level}
d77de738
ML
2872Control when to treat the trailing array of a structure as a flexible array
2873member for the purpose of accessing the elements of such an array. The value
2874of @var{level} controls the level of strictness.
2875
2876The possible values of @var{level} are the same as for the
2877@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2878
2879You can control this behavior for a specific trailing array field of a
2880structure by using the variable attribute @code{strict_flex_array} attribute
2881(@pxref{Variable Attributes}).
2882
d77de738 2883@opindex fsso-struct
ddf6fe37 2884@item -fsso-struct=@var{endianness}
d77de738
ML
2885Set the default scalar storage order of structures and unions to the
2886specified endianness. The accepted values are @samp{big-endian},
2887@samp{little-endian} and @samp{native} for the native endianness of
2888the target (the default). This option is not supported for C++.
2889
2890@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2891code that is not binary compatible with code generated without it if the
2892specified endianness is not the native endianness of the target.
2893@end table
2894
2895@node C++ Dialect Options
2896@section Options Controlling C++ Dialect
2897
2898@cindex compiler options, C++
2899@cindex C++ options, command-line
2900@cindex options, C++
2901This section describes the command-line options that are only meaningful
2902for C++ programs. You can also use most of the GNU compiler options
2903regardless of what language your program is in. For example, you
2904might compile a file @file{firstClass.C} like this:
2905
2906@smallexample
2907g++ -g -fstrict-enums -O -c firstClass.C
2908@end smallexample
2909
2910@noindent
2911In this example, only @option{-fstrict-enums} is an option meant
2912only for C++ programs; you can use the other options with any
2913language supported by GCC@.
2914
2915Some options for compiling C programs, such as @option{-std}, are also
2916relevant for C++ programs.
2917@xref{C Dialect Options,,Options Controlling C Dialect}.
2918
2919Here is a list of options that are @emph{only} for compiling C++ programs:
2920
2921@table @gcctabopt
2922
d77de738 2923@opindex fabi-version
ddf6fe37 2924@item -fabi-version=@var{n}
d77de738
ML
2925Use version @var{n} of the C++ ABI@. The default is version 0.
2926
2927Version 0 refers to the version conforming most closely to
2928the C++ ABI specification. Therefore, the ABI obtained using version 0
2929will change in different versions of G++ as ABI bugs are fixed.
2930
2931Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2932
2933Version 2 is the version of the C++ ABI that first appeared in G++
29343.4, and was the default through G++ 4.9.
2935
2936Version 3 corrects an error in mangling a constant address as a
2937template argument.
2938
2939Version 4, which first appeared in G++ 4.5, implements a standard
2940mangling for vector types.
2941
2942Version 5, which first appeared in G++ 4.6, corrects the mangling of
2943attribute const/volatile on function pointer types, decltype of a
2944plain decl, and use of a function parameter in the declaration of
2945another parameter.
2946
2947Version 6, which first appeared in G++ 4.7, corrects the promotion
2948behavior of C++11 scoped enums and the mangling of template argument
2949packs, const/static_cast, prefix ++ and --, and a class scope function
2950used as a template argument.
2951
2952Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2953builtin type and corrects the mangling of lambdas in default argument
2954scope.
2955
2956Version 8, which first appeared in G++ 4.9, corrects the substitution
2957behavior of function types with function-cv-qualifiers.
2958
2959Version 9, which first appeared in G++ 5.2, corrects the alignment of
2960@code{nullptr_t}.
2961
2962Version 10, which first appeared in G++ 6.1, adds mangling of
2963attributes that affect type identity, such as ia32 calling convention
2964attributes (e.g.@: @samp{stdcall}).
2965
2966Version 11, which first appeared in G++ 7, corrects the mangling of
2967sizeof... expressions and operator names. For multiple entities with
2968the same name within a function, that are declared in different scopes,
2969the mangling now changes starting with the twelfth occurrence. It also
2970implies @option{-fnew-inheriting-ctors}.
2971
2972Version 12, which first appeared in G++ 8, corrects the calling
2973conventions for empty classes on the x86_64 target and for classes
2974with only deleted copy/move constructors. It accidentally changes the
2975calling convention for classes with a deleted copy constructor and a
2976trivial move constructor.
2977
2978Version 13, which first appeared in G++ 8.2, fixes the accidental
2979change in version 12.
2980
2981Version 14, which first appeared in G++ 10, corrects the mangling of
2982the nullptr expression.
2983
2984Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2985tag regression.
2986
2987Version 16, which first appeared in G++ 11, changes the mangling of
2988@code{__alignof__} to be distinct from that of @code{alignof}, and
2989dependent operator names.
2990
2991Version 17, which first appeared in G++ 12, fixes layout of classes
2992that inherit from aggregate classes with default member initializers
2993in C++14 and up.
2994
2995Version 18, which first appeard in G++ 13, fixes manglings of lambdas
2996that have additional context.
2997
2998See also @option{-Wabi}.
2999
d77de738 3000@opindex fabi-compat-version
ddf6fe37 3001@item -fabi-compat-version=@var{n}
d77de738
ML
3002On targets that support strong aliases, G++
3003works around mangling changes by creating an alias with the correct
3004mangled name when defining a symbol with an incorrect mangled name.
3005This switch specifies which ABI version to use for the alias.
3006
3007With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
3008compatibility). If another ABI version is explicitly selected, this
3009defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
3010use @option{-fabi-compat-version=2}.
3011
3012If this option is not provided but @option{-Wabi=@var{n}} is, that
3013version is used for compatibility aliases. If this option is provided
3014along with @option{-Wabi} (without the version), the version from this
3015option is used for the warning.
3016
d77de738
ML
3017@opindex fno-access-control
3018@opindex faccess-control
ddf6fe37 3019@item -fno-access-control
d77de738
ML
3020Turn off all access checking. This switch is mainly useful for working
3021around bugs in the access control code.
3022
d77de738 3023@opindex faligned-new
ddf6fe37 3024@item -faligned-new
d77de738
ML
3025Enable support for C++17 @code{new} of types that require more
3026alignment than @code{void* ::operator new(std::size_t)} provides. A
3027numeric argument such as @code{-faligned-new=32} can be used to
3028specify how much alignment (in bytes) is provided by that function,
3029but few users will need to override the default of
3030@code{alignof(std::max_align_t)}.
3031
3032This flag is enabled by default for @option{-std=c++17}.
3033
d77de738
ML
3034@opindex fchar8_t
3035@opindex fno-char8_t
ddf6fe37
AA
3036@item -fchar8_t
3037@itemx -fno-char8_t
d77de738
ML
3038Enable support for @code{char8_t} as adopted for C++20. This includes
3039the addition of a new @code{char8_t} fundamental type, changes to the
3040types of UTF-8 string and character literals, new signatures for
3041user-defined literals, associated standard library updates, and new
3042@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3043
3044This option enables functions to be overloaded for ordinary and UTF-8
3045strings:
3046
3047@smallexample
3048int f(const char *); // #1
3049int f(const char8_t *); // #2
3050int v1 = f("text"); // Calls #1
3051int v2 = f(u8"text"); // Calls #2
3052@end smallexample
3053
3054@noindent
3055and introduces new signatures for user-defined literals:
3056
3057@smallexample
3058int operator""_udl1(char8_t);
3059int v3 = u8'x'_udl1;
3060int operator""_udl2(const char8_t*, std::size_t);
3061int v4 = u8"text"_udl2;
3062template<typename T, T...> int operator""_udl3();
3063int v5 = u8"text"_udl3;
3064@end smallexample
3065
3066@noindent
3067The change to the types of UTF-8 string and character literals introduces
3068incompatibilities with ISO C++11 and later standards. For example, the
3069following code is well-formed under ISO C++11, but is ill-formed when
3070@option{-fchar8_t} is specified.
3071
3072@smallexample
d77de738
ML
3073const char *cp = u8"xx";// error: invalid conversion from
3074 // `const char8_t*' to `const char*'
3075int f(const char*);
3076auto v = f(u8"xx"); // error: invalid conversion from
3077 // `const char8_t*' to `const char*'
3078std::string s@{u8"xx"@}; // error: no matching function for call to
3079 // `std::basic_string<char>::basic_string()'
3080using namespace std::literals;
3081s = u8"xx"s; // error: conversion from
3082 // `basic_string<char8_t>' to non-scalar
3083 // type `basic_string<char>' requested
3084@end smallexample
3085
d77de738 3086@opindex fcheck-new
ddf6fe37 3087@item -fcheck-new
d77de738
ML
3088Check that the pointer returned by @code{operator new} is non-null
3089before attempting to modify the storage allocated. This check is
3090normally unnecessary because the C++ standard specifies that
3091@code{operator new} only returns @code{0} if it is declared
3092@code{throw()}, in which case the compiler always checks the
3093return value even without this option. In all other cases, when
3094@code{operator new} has a non-empty exception specification, memory
3095exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3096@samp{new (nothrow)}.
3097
d77de738
ML
3098@opindex fconcepts
3099@opindex fconcepts-ts
ddf6fe37
AA
3100@item -fconcepts
3101@itemx -fconcepts-ts
d77de738
ML
3102Enable support for the C++ Concepts feature for constraining template
3103arguments. With @option{-std=c++20} and above, Concepts are part of
3104the language standard, so @option{-fconcepts} defaults to on.
3105
3106Some constructs that were allowed by the earlier C++ Extensions for
3107Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3108into the standard, can additionally be enabled by
3109@option{-fconcepts-ts}.
3110
d77de738 3111@opindex fconstexpr-depth
ddf6fe37 3112@item -fconstexpr-depth=@var{n}
d77de738
ML
3113Set the maximum nested evaluation depth for C++11 constexpr functions
3114to @var{n}. A limit is needed to detect endless recursion during
3115constant expression evaluation. The minimum specified by the standard
3116is 512.
3117
d77de738 3118@opindex fconstexpr-cache-depth
ddf6fe37 3119@item -fconstexpr-cache-depth=@var{n}
d77de738
ML
3120Set the maximum level of nested evaluation depth for C++11 constexpr
3121functions that will be cached to @var{n}. This is a heuristic that
3122trades off compilation speed (when the cache avoids repeated
3123calculations) against memory consumption (when the cache grows very
3124large from highly recursive evaluations). The default is 8. Very few
3125users are likely to want to adjust it, but if your code does heavy
3126constexpr calculations you might want to experiment to find which
3127value works best for you.
3128
d77de738 3129@opindex fconstexpr-fp-except
ddf6fe37 3130@item -fconstexpr-fp-except
d77de738
ML
3131Annex F of the C standard specifies that IEC559 floating point
3132exceptions encountered at compile time should not stop compilation.
3133C++ compilers have historically not followed this guidance, instead
3134treating floating point division by zero as non-constant even though
3135it has a well defined value. This flag tells the compiler to give
3136Annex F priority over other rules saying that a particular operation
3137is undefined.
3138
3139@smallexample
3140constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3141@end smallexample
3142
d77de738 3143@opindex fconstexpr-loop-limit
ddf6fe37 3144@item -fconstexpr-loop-limit=@var{n}
d77de738
ML
3145Set the maximum number of iterations for a loop in C++14 constexpr functions
3146to @var{n}. A limit is needed to detect infinite loops during
3147constant expression evaluation. The default is 262144 (1<<18).
3148
d77de738 3149@opindex fconstexpr-ops-limit
ddf6fe37 3150@item -fconstexpr-ops-limit=@var{n}
d77de738
ML
3151Set the maximum number of operations during a single constexpr evaluation.
3152Even when number of iterations of a single loop is limited with the above limit,
3153if there are several nested loops and each of them has many iterations but still
3154smaller than the above limit, or if in a body of some loop or even outside
3155of a loop too many expressions need to be evaluated, the resulting constexpr
3156evaluation might take too long.
3157The default is 33554432 (1<<25).
3158
2efb237f 3159@opindex fcontracts
ddf6fe37 3160@item -fcontracts
2efb237f
JCI
3161Enable experimental support for the C++ Contracts feature, as briefly
3162added to and then removed from the C++20 working paper (N4820). The
3163implementation also includes proposed enhancements from papers P1290,
3164P1332, and P1429. This functionality is intended mostly for those
3165interested in experimentation towards refining the feature to get it
3166into shape for a future C++ standard.
3167
3168On violation of a checked contract, the violation handler is called.
3169Users can replace the violation handler by defining
3170@smallexample
4ace81b6
SL
3171void
3172handle_contract_violation (const std::experimental::contract_violation&);
2efb237f
JCI
3173@end smallexample
3174
3175There are different sets of additional flags that can be used together
3176to specify which contracts will be checked and how, for N4820
3177contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3178used together.
3179
3180@table @gcctabopt
2efb237f 3181@opindex fcontract-mode
ddf6fe37 3182@item -fcontract-mode=[on|off]
2efb237f
JCI
3183Control whether any contracts have any semantics at all. Defaults to on.
3184
2efb237f 3185@opindex fcontract-assumption-mode
ddf6fe37 3186@item -fcontract-assumption-mode=[on|off]
2efb237f
JCI
3187[N4820] Control whether contracts with level @samp{axiom}
3188should have the assume semantic. Defaults to on.
3189
2efb237f 3190@opindex fcontract-build-level
ddf6fe37 3191@item -fcontract-build-level=[off|default|audit]
2efb237f
JCI
3192[N4820] Specify which level of contracts to generate checks
3193for. Defaults to @samp{default}.
3194
2efb237f 3195@opindex fcontract-continuation-mode
ddf6fe37 3196@item -fcontract-continuation-mode=[on|off]
2efb237f
JCI
3197[N4820] Control whether to allow the program to continue executing
3198after a contract violation. That is, do checked contracts have the
3199@samp{maybe} semantic described below rather than the @samp{never}
3200semantic. Defaults to off.
3201
2efb237f 3202@opindex fcontract-role
ddf6fe37 3203@item -fcontract-role=<name>:<default>,<audit>,<axiom>
2efb237f
JCI
3204[P1332] Specify the concrete semantics for each contract level
3205of a particular contract role.
3206
3207@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3208[P1429] Specify the concrete semantic for a particular
3209contract level.
3210
2efb237f 3211@opindex fcontract-strict-declarations
ddf6fe37 3212@item -fcontract-strict-declarations=[on|off]
2efb237f
JCI
3213Control whether to reject adding contracts to a function after its
3214first declaration. Defaults to off.
3215@end table
3216
3217The possible concrete semantics for that can be specified with
3218@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3219
3220@table @code
3221@item ignore
3222This contract has no effect.
3223
3224@item assume
3225This contract is treated like C++23 @code{[[assume]]}.
3226
3227@item check_never_continue
3228@itemx never
3229@itemx abort
3230This contract is checked. If it fails, the violation handler is
3231called. If the handler returns, @code{std::terminate} is called.
3232
3233@item check_maybe_continue
3234@itemx maybe
3235This contract is checked. If it fails, the violation handler is
3236called. If the handler returns, execution continues normally.
3237@end table
3238
d77de738 3239@opindex fcoroutines
ddf6fe37 3240@item -fcoroutines
d77de738
ML
3241Enable support for the C++ coroutines extension (experimental).
3242
d77de738
ML
3243@opindex fno-elide-constructors
3244@opindex felide-constructors
ddf6fe37 3245@item -fno-elide-constructors
d77de738
ML
3246The C++ standard allows an implementation to omit creating a temporary
3247that is only used to initialize another object of the same type.
3248Specifying this option disables that optimization, and forces G++ to
3249call the copy constructor in all cases. This option also causes G++
3250to call trivial member functions which otherwise would be expanded inline.
3251
3252In C++17, the compiler is required to omit these temporaries, but this
3253option still affects trivial member functions.
3254
d77de738
ML
3255@opindex fno-enforce-eh-specs
3256@opindex fenforce-eh-specs
ddf6fe37 3257@item -fno-enforce-eh-specs
d77de738
ML
3258Don't generate code to check for violation of exception specifications
3259at run time. This option violates the C++ standard, but may be useful
3260for reducing code size in production builds, much like defining
3261@code{NDEBUG}. This does not give user code permission to throw
3262exceptions in violation of the exception specifications; the compiler
3263still optimizes based on the specifications, so throwing an
3264unexpected exception results in undefined behavior at run time.
3265
d77de738
ML
3266@opindex fextern-tls-init
3267@opindex fno-extern-tls-init
ddf6fe37
AA
3268@item -fextern-tls-init
3269@itemx -fno-extern-tls-init
d77de738
ML
3270The C++11 and OpenMP standards allow @code{thread_local} and
3271@code{threadprivate} variables to have dynamic (runtime)
3272initialization. To support this, any use of such a variable goes
3273through a wrapper function that performs any necessary initialization.
3274When the use and definition of the variable are in the same
3275translation unit, this overhead can be optimized away, but when the
3276use is in a different translation unit there is significant overhead
3277even if the variable doesn't actually need dynamic initialization. If
3278the programmer can be sure that no use of the variable in a
3279non-defining TU needs to trigger dynamic initialization (either
3280because the variable is statically initialized, or a use of the
3281variable in the defining TU will be executed before any uses in
3282another TU), they can avoid this overhead with the
3283@option{-fno-extern-tls-init} option.
3284
3285On targets that support symbol aliases, the default is
3286@option{-fextern-tls-init}. On targets that do not support symbol
3287aliases, the default is @option{-fno-extern-tls-init}.
3288
d77de738
ML
3289@opindex ffold-simple-inlines
3290@opindex fno-fold-simple-inlines
ddf6fe37
AA
3291@item -ffold-simple-inlines
3292@itemx -fno-fold-simple-inlines
d77de738
ML
3293Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3294@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3295means no debug information will be generated for such calls. Since these
3296functions are rarely interesting to debug, this flag is enabled by default
3297unless @option{-fno-inline} is active.
3298
d77de738
ML
3299@opindex fno-gnu-keywords
3300@opindex fgnu-keywords
ddf6fe37 3301@item -fno-gnu-keywords
d77de738
ML
3302Do not recognize @code{typeof} as a keyword, so that code can use this
3303word as an identifier. You can use the keyword @code{__typeof__} instead.
3304This option is implied by the strict ISO C++ dialects: @option{-ansi},
3305@option{-std=c++98}, @option{-std=c++11}, etc.
3306
d77de738 3307@opindex fimplicit-constexpr
ddf6fe37 3308@item -fimplicit-constexpr
d77de738
ML
3309Make inline functions implicitly constexpr, if they satisfy the
3310requirements for a constexpr function. This option can be used in
3311C++14 mode or later. This can result in initialization changing from
3312dynamic to static and other optimizations.
3313
d77de738
ML
3314@opindex fno-implicit-templates
3315@opindex fimplicit-templates
ddf6fe37 3316@item -fno-implicit-templates
d77de738
ML
3317Never emit code for non-inline templates that are instantiated
3318implicitly (i.e.@: by use); only emit code for explicit instantiations.
3319If you use this option, you must take care to structure your code to
3320include all the necessary explicit instantiations to avoid getting
3321undefined symbols at link time.
3322@xref{Template Instantiation}, for more information.
3323
d77de738
ML
3324@opindex fno-implicit-inline-templates
3325@opindex fimplicit-inline-templates
ddf6fe37 3326@item -fno-implicit-inline-templates
d77de738
ML
3327Don't emit code for implicit instantiations of inline templates, either.
3328The default is to handle inlines differently so that compiles with and
3329without optimization need the same set of explicit instantiations.
3330
d77de738
ML
3331@opindex fno-implement-inlines
3332@opindex fimplement-inlines
ddf6fe37 3333@item -fno-implement-inlines
d77de738
ML
3334To save space, do not emit out-of-line copies of inline functions
3335controlled by @code{#pragma implementation}. This causes linker
3336errors if these functions are not inlined everywhere they are called.
3337
d77de738
ML
3338@opindex fmodules-ts
3339@opindex fno-modules-ts
ddf6fe37
AA
3340@item -fmodules-ts
3341@itemx -fno-modules-ts
d77de738
ML
3342Enable support for C++20 modules (@pxref{C++ Modules}). The
3343@option{-fno-modules-ts} is usually not needed, as that is the
3344default. Even though this is a C++20 feature, it is not currently
3345implicitly enabled by selecting that standard version.
3346
ddf6fe37 3347@opindex fmodule-header
d77de738
ML
3348@item -fmodule-header
3349@itemx -fmodule-header=user
3350@itemx -fmodule-header=system
d77de738
ML
3351Compile a header file to create an importable header unit.
3352
d77de738 3353@opindex fmodule-implicit-inline
ddf6fe37 3354@item -fmodule-implicit-inline
d77de738
ML
3355Member functions defined in their class definitions are not implicitly
3356inline for modular code. This is different to traditional C++
3357behavior, for good reasons. However, it may result in a difficulty
3358during code porting. This option makes such function definitions
3359implicitly inline. It does however generate an ABI incompatibility,
3360so you must use it everywhere or nowhere. (Such definitions outside
3361of a named module remain implicitly inline, regardless.)
3362
d77de738
ML
3363@opindex fno-module-lazy
3364@opindex fmodule-lazy
ddf6fe37 3365@item -fno-module-lazy
d77de738
ML
3366Disable lazy module importing and module mapper creation.
3367
f33d7a88
AA
3368@vindex CXX_MODULE_MAPPER @r{environment variable}
3369@opindex fmodule-mapper
d77de738
ML
3370@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3371@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3372@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3373@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3374@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3375@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
d77de738
ML
3376An oracle to query for module name to filename mappings. If
3377unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3378and if that is unset, an in-process default is provided.
3379
d77de738 3380@opindex fmodule-only
ddf6fe37 3381@item -fmodule-only
d77de738
ML
3382Only emit the Compiled Module Interface, inhibiting any object file.
3383
d77de738 3384@opindex fms-extensions
ddf6fe37 3385@item -fms-extensions
d77de738
ML
3386Disable Wpedantic warnings about constructs used in MFC, such as implicit
3387int and getting a pointer to member function via non-standard syntax.
3388
d77de738 3389@opindex fnew-inheriting-ctors
ddf6fe37 3390@item -fnew-inheriting-ctors
d77de738
ML
3391Enable the P0136 adjustment to the semantics of C++11 constructor
3392inheritance. This is part of C++17 but also considered to be a Defect
3393Report against C++11 and C++14. This flag is enabled by default
3394unless @option{-fabi-version=10} or lower is specified.
3395
d77de738 3396@opindex fnew-ttp-matching
ddf6fe37 3397@item -fnew-ttp-matching
d77de738
ML
3398Enable the P0522 resolution to Core issue 150, template template
3399parameters and default arguments: this allows a template with default
3400template arguments as an argument for a template template parameter
3401with fewer template parameters. This flag is enabled by default for
3402@option{-std=c++17}.
3403
d77de738
ML
3404@opindex fno-nonansi-builtins
3405@opindex fnonansi-builtins
ddf6fe37 3406@item -fno-nonansi-builtins
d77de738
ML
3407Disable built-in declarations of functions that are not mandated by
3408ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3409@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3410
d77de738 3411@opindex fnothrow-opt
ddf6fe37 3412@item -fnothrow-opt
d77de738
ML
3413Treat a @code{throw()} exception specification as if it were a
3414@code{noexcept} specification to reduce or eliminate the text size
3415overhead relative to a function with no exception specification. If
3416the function has local variables of types with non-trivial
3417destructors, the exception specification actually makes the
3418function smaller because the EH cleanups for those variables can be
3419optimized away. The semantic effect is that an exception thrown out of
3420a function with such an exception specification results in a call
3421to @code{terminate} rather than @code{unexpected}.
3422
d77de738
ML
3423@opindex fno-operator-names
3424@opindex foperator-names
ddf6fe37 3425@item -fno-operator-names
d77de738
ML
3426Do not treat the operator name keywords @code{and}, @code{bitand},
3427@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3428synonyms as keywords.
3429
d77de738
ML
3430@opindex fno-optional-diags
3431@opindex foptional-diags
ddf6fe37 3432@item -fno-optional-diags
d77de738
ML
3433Disable diagnostics that the standard says a compiler does not need to
3434issue. Currently, the only such diagnostic issued by G++ is the one for
3435a name having multiple meanings within a class.
3436
d77de738 3437@opindex fpermissive
ddf6fe37 3438@item -fpermissive
d77de738
ML
3439Downgrade some diagnostics about nonconformant code from errors to
3440warnings. Thus, using @option{-fpermissive} allows some
3441nonconforming code to compile.
3442
d77de738
ML
3443@opindex fno-pretty-templates
3444@opindex fpretty-templates
ddf6fe37 3445@item -fno-pretty-templates
d77de738
ML
3446When an error message refers to a specialization of a function
3447template, the compiler normally prints the signature of the
3448template followed by the template arguments and any typedefs or
3449typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3450rather than @code{void f(int)}) so that it's clear which template is
3451involved. When an error message refers to a specialization of a class
3452template, the compiler omits any template arguments that match
3453the default template arguments for that template. If either of these
3454behaviors make it harder to understand the error message rather than
3455easier, you can use @option{-fno-pretty-templates} to disable them.
3456
d77de738
ML
3457@opindex fno-rtti
3458@opindex frtti
ddf6fe37 3459@item -fno-rtti
d77de738
ML
3460Disable generation of information about every class with virtual
3461functions for use by the C++ run-time type identification features
3462(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3463of the language, you can save some space by using this flag. Note that
3464exception handling uses the same information, but G++ generates it as
3465needed. The @code{dynamic_cast} operator can still be used for casts that
3466do not require run-time type information, i.e.@: casts to @code{void *} or to
3467unambiguous base classes.
3468
3469Mixing code compiled with @option{-frtti} with that compiled with
3470@option{-fno-rtti} may not work. For example, programs may
3471fail to link if a class compiled with @option{-fno-rtti} is used as a base
3472for a class compiled with @option{-frtti}.
3473
d77de738 3474@opindex fsized-deallocation
ddf6fe37 3475@item -fsized-deallocation
d77de738
ML
3476Enable the built-in global declarations
3477@smallexample
3478void operator delete (void *, std::size_t) noexcept;
3479void operator delete[] (void *, std::size_t) noexcept;
3480@end smallexample
3481as introduced in C++14. This is useful for user-defined replacement
3482deallocation functions that, for example, use the size of the object
3483to make deallocation faster. Enabled by default under
3484@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3485warns about places that might want to add a definition.
3486
d77de738 3487@opindex fstrict-enums
ddf6fe37 3488@item -fstrict-enums
d77de738
ML
3489Allow the compiler to optimize using the assumption that a value of
3490enumerated type can only be one of the values of the enumeration (as
3491defined in the C++ standard; basically, a value that can be
3492represented in the minimum number of bits needed to represent all the
3493enumerators). This assumption may not be valid if the program uses a
3494cast to convert an arbitrary integer value to the enumerated type.
3495
d77de738 3496@opindex fstrong-eval-order
ddf6fe37 3497@item -fstrong-eval-order
d77de738
ML
3498Evaluate member access, array subscripting, and shift expressions in
3499left-to-right order, and evaluate assignment in right-to-left order,
3500as adopted for C++17. Enabled by default with @option{-std=c++17}.
3501@option{-fstrong-eval-order=some} enables just the ordering of member
3502access and shift expressions, and is the default without
3503@option{-std=c++17}.
3504
d77de738 3505@opindex ftemplate-backtrace-limit
ddf6fe37 3506@item -ftemplate-backtrace-limit=@var{n}
d77de738
ML
3507Set the maximum number of template instantiation notes for a single
3508warning or error to @var{n}. The default value is 10.
3509
d77de738 3510@opindex ftemplate-depth
ddf6fe37 3511@item -ftemplate-depth=@var{n}
d77de738
ML
3512Set the maximum instantiation depth for template classes to @var{n}.
3513A limit on the template instantiation depth is needed to detect
3514endless recursions during template class instantiation. ANSI/ISO C++
3515conforming programs must not rely on a maximum depth greater than 17
3516(changed to 1024 in C++11). The default value is 900, as the compiler
3517can run out of stack space before hitting 1024 in some situations.
3518
d77de738
ML
3519@opindex fno-threadsafe-statics
3520@opindex fthreadsafe-statics
ddf6fe37 3521@item -fno-threadsafe-statics
d77de738
ML
3522Do not emit the extra code to use the routines specified in the C++
3523ABI for thread-safe initialization of local statics. You can use this
3524option to reduce code size slightly in code that doesn't need to be
3525thread-safe.
3526
d77de738 3527@opindex fuse-cxa-atexit
ddf6fe37 3528@item -fuse-cxa-atexit
d77de738
ML
3529Register destructors for objects with static storage duration with the
3530@code{__cxa_atexit} function rather than the @code{atexit} function.
3531This option is required for fully standards-compliant handling of static
3532destructors, but only works if your C library supports
3533@code{__cxa_atexit}.
3534
d77de738
ML
3535@opindex fno-use-cxa-get-exception-ptr
3536@opindex fuse-cxa-get-exception-ptr
ddf6fe37 3537@item -fno-use-cxa-get-exception-ptr
d77de738
ML
3538Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3539causes @code{std::uncaught_exception} to be incorrect, but is necessary
3540if the runtime routine is not available.
3541
d77de738 3542@opindex fvisibility-inlines-hidden
ddf6fe37 3543@item -fvisibility-inlines-hidden
d77de738
ML
3544This switch declares that the user does not attempt to compare
3545pointers to inline functions or methods where the addresses of the two functions
3546are taken in different shared objects.
3547
3548The effect of this is that GCC may, effectively, mark inline methods with
3549@code{__attribute__ ((visibility ("hidden")))} so that they do not
3550appear in the export table of a DSO and do not require a PLT indirection
3551when used within the DSO@. Enabling this option can have a dramatic effect
3552on load and link times of a DSO as it massively reduces the size of the
3553dynamic export table when the library makes heavy use of templates.
3554
3555The behavior of this switch is not quite the same as marking the
3556methods as hidden directly, because it does not affect static variables
3557local to the function or cause the compiler to deduce that
3558the function is defined in only one shared object.
3559
3560You may mark a method as having a visibility explicitly to negate the
3561effect of the switch for that method. For example, if you do want to
3562compare pointers to a particular inline method, you might mark it as
3563having default visibility. Marking the enclosing class with explicit
3564visibility has no effect.
3565
3566Explicitly instantiated inline methods are unaffected by this option
3567as their linkage might otherwise cross a shared library boundary.
3568@xref{Template Instantiation}.
3569
d77de738 3570@opindex fvisibility-ms-compat
ddf6fe37 3571@item -fvisibility-ms-compat
d77de738
ML
3572This flag attempts to use visibility settings to make GCC's C++
3573linkage model compatible with that of Microsoft Visual Studio.
3574
3575The flag makes these changes to GCC's linkage model:
3576
3577@enumerate
3578@item
3579It sets the default visibility to @code{hidden}, like
3580@option{-fvisibility=hidden}.
3581
3582@item
3583Types, but not their members, are not hidden by default.
3584
3585@item
3586The One Definition Rule is relaxed for types without explicit
3587visibility specifications that are defined in more than one
3588shared object: those declarations are permitted if they are
3589permitted when this option is not used.
3590@end enumerate
3591
3592In new code it is better to use @option{-fvisibility=hidden} and
3593export those classes that are intended to be externally visible.
3594Unfortunately it is possible for code to rely, perhaps accidentally,
3595on the Visual Studio behavior.
3596
3597Among the consequences of these changes are that static data members
3598of the same type with the same name but defined in different shared
3599objects are different, so changing one does not change the other;
3600and that pointers to function members defined in different shared
3601objects may not compare equal. When this flag is given, it is a
3602violation of the ODR to define types with the same name differently.
3603
d77de738
ML
3604@opindex fno-weak
3605@opindex fweak
ddf6fe37 3606@item -fno-weak
d77de738
ML
3607Do not use weak symbol support, even if it is provided by the linker.
3608By default, G++ uses weak symbols if they are available. This
3609option exists only for testing, and should not be used by end-users;
3610it results in inferior code and has no benefits. This option may
3611be removed in a future release of G++.
3612
d77de738
ML
3613@opindex fext-numeric-literals
3614@opindex fno-ext-numeric-literals
ddf6fe37 3615@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
d77de738
ML
3616Accept imaginary, fixed-point, or machine-defined
3617literal number suffixes as GNU extensions.
3618When this option is turned off these suffixes are treated
3619as C++11 user-defined literal numeric suffixes.
3620This is on by default for all pre-C++11 dialects and all GNU dialects:
3621@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3622@option{-std=gnu++14}.
3623This option is off by default
3624for ISO C++11 onwards (@option{-std=c++11}, ...).
3625
d77de738 3626@opindex nostdinc++
ddf6fe37 3627@item -nostdinc++
d77de738
ML
3628Do not search for header files in the standard directories specific to
3629C++, but do still search the other standard directories. (This option
3630is used when building the C++ library.)
3631
ddf6fe37
AA
3632@opindex flang-info-include-translate
3633@opindex flang-info-include-translate-not
d77de738
ML
3634@item -flang-info-include-translate
3635@itemx -flang-info-include-translate-not
3636@itemx -flang-info-include-translate=@var{header}
d77de738
ML
3637Inform of include translation events. The first will note accepted
3638include translations, the second will note declined include
3639translations. The @var{header} form will inform of include
3640translations relating to that specific header. If @var{header} is of
3641the form @code{"user"} or @code{<system>} it will be resolved to a
3642specific user or system header using the include path.
3643
ddf6fe37 3644@opindex flang-info-module-cmi
d77de738
ML
3645@item -flang-info-module-cmi
3646@itemx -flang-info-module-cmi=@var{module}
d77de738
ML
3647Inform of Compiled Module Interface pathnames. The first will note
3648all read CMI pathnames. The @var{module} form will not reading a
3649specific module's CMI. @var{module} may be a named module or a
3650header-unit (the latter indicated by either being a pathname containing
3651directory separators or enclosed in @code{<>} or @code{""}).
3652
d77de738 3653@opindex stdlib
ddf6fe37 3654@item -stdlib=@var{libstdc++,libc++}
d77de738
ML
3655When G++ is configured to support this option, it allows specification of
3656alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3657(the default, native C++ runtime for G++) and @var{libc++} which is the
3658C++ runtime installed on some operating systems (e.g. Darwin versions from
3659Darwin11 onwards). The option switches G++ to use the headers from the
3660specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3661when a C++ runtime is required for linking.
3662@end table
3663
3664In addition, these warning options have meanings only for C++ programs:
3665
3666@table @gcctabopt
d77de738 3667@opindex Wabi-tag
ddf6fe37 3668@item -Wabi-tag @r{(C++ and Objective-C++ only)}
d77de738
ML
3669Warn when a type with an ABI tag is used in a context that does not
3670have that ABI tag. See @ref{C++ Attributes} for more information
3671about ABI tags.
3672
d77de738
ML
3673@opindex Wcomma-subscript
3674@opindex Wno-comma-subscript
ddf6fe37 3675@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
d77de738
ML
3676Warn about uses of a comma expression within a subscripting expression.
3677This usage was deprecated in C++20 and is going to be removed in C++23.
3678However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3679
3680@smallexample
3681@group
3682void f(int *a, int b, int c) @{
3683 a[b,c]; // deprecated in C++20, invalid in C++23
3684 a[(b,c)]; // OK
3685@}
3686@end group
3687@end smallexample
3688
3689In C++23 it is valid to have comma separated expressions in a subscript
3690when an overloaded subscript operator is found and supports the right
3691number and types of arguments. G++ will accept the formerly valid syntax
3692for code that is not valid in C++23 but used to be valid but deprecated
3693in C++20 with a pedantic warning that can be disabled with
3694@option{-Wno-comma-subscript}.
3695
3696Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3697and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3698
d77de738
ML
3699@opindex Wctad-maybe-unsupported
3700@opindex Wno-ctad-maybe-unsupported
ddf6fe37 3701@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
d77de738
ML
3702Warn when performing class template argument deduction (CTAD) on a type with
3703no explicitly written deduction guides. This warning will point out cases
3704where CTAD succeeded only because the compiler synthesized the implicit
3705deduction guides, which might not be what the programmer intended. Certain
3706style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3707types that are designed to support CTAD. This warning can be suppressed with
3708the following pattern:
3709
3710@smallexample
3711struct allow_ctad_t; // any name works
3712template <typename T> struct S @{
3713 S(T) @{ @}
3714@};
4ace81b6
SL
3715// Guide with incomplete parameter type will never be considered.
3716S(allow_ctad_t) -> S<void>;
d77de738
ML
3717@end smallexample
3718
d77de738
ML
3719@opindex Wctor-dtor-privacy
3720@opindex Wno-ctor-dtor-privacy
ddf6fe37 3721@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
d77de738
ML
3722Warn when a class seems unusable because all the constructors or
3723destructors in that class are private, and it has neither friends nor
3724public static member functions. Also warn if there are no non-private
3725methods, and there's at least one private member function that isn't
3726a constructor or destructor.
3727
d77de738
ML
3728@opindex Wdangling-reference
3729@opindex Wno-dangling-reference
ddf6fe37 3730@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
d77de738
ML
3731Warn when a reference is bound to a temporary whose lifetime has ended.
3732For example:
3733
3734@smallexample
3735int n = 1;
3736const int& r = std::max(n - 1, n + 1); // r is dangling
3737@end smallexample
3738
3739In the example above, two temporaries are created, one for each
3740argument, and a reference to one of the temporaries is returned.
3741However, both temporaries are destroyed at the end of the full
3742expression, so the reference @code{r} is dangling. This warning
3743also detects dangling references in member initializer lists:
3744
3745@smallexample
3746const int& f(const int& i) @{ return i; @}
3747struct S @{
3748 const int &r; // r is dangling
3749 S() : r(f(10)) @{ @}
3750@};
3751@end smallexample
3752
3753Member functions are checked as well, but only their object argument:
3754
3755@smallexample
3756struct S @{
3757 const S& self () @{ return *this; @}
3758@};
3759const S& s = S().self(); // s is dangling
3760@end smallexample
3761
3762Certain functions are safe in this respect, for example @code{std::use_facet}:
3763they take and return a reference, but they don't return one of its arguments,
3764which can fool the warning. Such functions can be excluded from the warning
3765by wrapping them in a @code{#pragma}:
3766
3767@smallexample
3768#pragma GCC diagnostic push
3769#pragma GCC diagnostic ignored "-Wdangling-reference"
3770const T& foo (const T&) @{ @dots{} @}
3771#pragma GCC diagnostic pop
3772@end smallexample
3773
ce51e843
ML
3774@option{-Wdangling-reference} also warns about code like
3775
3776@smallexample
3777auto p = std::minmax(1, 2);
3778@end smallexample
3779
3780where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3781both references dangle after the end of the full expression that contains
3782the call to @code{std::minmax}.
3783
d77de738
ML
3784This warning is enabled by @option{-Wall}.
3785
d77de738
ML
3786@opindex Wdelete-non-virtual-dtor
3787@opindex Wno-delete-non-virtual-dtor
ddf6fe37 3788@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
3789Warn when @code{delete} is used to destroy an instance of a class that
3790has virtual functions and non-virtual destructor. It is unsafe to delete
3791an instance of a derived class through a pointer to a base class if the
3792base class does not have a virtual destructor. This warning is enabled
3793by @option{-Wall}.
3794
d77de738
ML
3795@opindex Wdeprecated-copy
3796@opindex Wno-deprecated-copy
ddf6fe37 3797@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
d77de738
ML
3798Warn that the implicit declaration of a copy constructor or copy
3799assignment operator is deprecated if the class has a user-provided
3800copy constructor or copy assignment operator, in C++11 and up. This
3801warning is enabled by @option{-Wextra}. With
3802@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3803user-provided destructor.
3804
d77de738
ML
3805@opindex Wdeprecated-enum-enum-conversion
3806@opindex Wno-deprecated-enum-enum-conversion
ddf6fe37 3807@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3808Disable the warning about the case when the usual arithmetic conversions
3809are applied on operands where one is of enumeration type and the other is
3810of a different enumeration type. This conversion was deprecated in C++20.
3811For example:
3812
3813@smallexample
3814enum E1 @{ e @};
3815enum E2 @{ f @};
3816int k = f - e;
3817@end smallexample
3818
3819@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3820@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3821by @option{-Wenum-conversion}.
3822
d77de738
ML
3823@opindex Wdeprecated-enum-float-conversion
3824@opindex Wno-deprecated-enum-float-conversion
ddf6fe37 3825@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
3826Disable the warning about the case when the usual arithmetic conversions
3827are applied on operands where one is of enumeration type and the other is
3828of a floating-point type. This conversion was deprecated in C++20. For
3829example:
3830
3831@smallexample
3832enum E1 @{ e @};
3833enum E2 @{ f @};
3834bool b = e <= 3.7;
3835@end smallexample
3836
3837@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3838@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3839by @option{-Wenum-conversion}.
3840
d77de738
ML
3841@opindex Winit-list-lifetime
3842@opindex Wno-init-list-lifetime
ddf6fe37 3843@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
d77de738
ML
3844Do not warn about uses of @code{std::initializer_list} that are likely
3845to result in dangling pointers. Since the underlying array for an
3846@code{initializer_list} is handled like a normal C++ temporary object,
3847it is easy to inadvertently keep a pointer to the array past the end
3848of the array's lifetime. For example:
3849
3850@itemize @bullet
3851@item
3852If a function returns a temporary @code{initializer_list}, or a local
3853@code{initializer_list} variable, the array's lifetime ends at the end
3854of the return statement, so the value returned has a dangling pointer.
3855
3856@item
3857If a new-expression creates an @code{initializer_list}, the array only
3858lives until the end of the enclosing full-expression, so the
3859@code{initializer_list} in the heap has a dangling pointer.
3860
3861@item
3862When an @code{initializer_list} variable is assigned from a
3863brace-enclosed initializer list, the temporary array created for the
3864right side of the assignment only lives until the end of the
3865full-expression, so at the next statement the @code{initializer_list}
3866variable has a dangling pointer.
3867
3868@smallexample
3869// li's initial underlying array lives as long as li
3870std::initializer_list<int> li = @{ 1,2,3 @};
3871// assignment changes li to point to a temporary array
3872li = @{ 4, 5 @};
3873// now the temporary is gone and li has a dangling pointer
3874int i = li.begin()[0] // undefined behavior
3875@end smallexample
3876
3877@item
3878When a list constructor stores the @code{begin} pointer from the
3879@code{initializer_list} argument, this doesn't extend the lifetime of
3880the array, so if a class variable is constructed from a temporary
3881@code{initializer_list}, the pointer is left dangling by the end of
3882the variable declaration statement.
3883
3884@end itemize
3885
c85f8dbb
MP
3886@opindex Winvalid-constexpr
3887@opindex Wno-invalid-constexpr
ddf6fe37 3888@item -Winvalid-constexpr
c85f8dbb
MP
3889
3890Warn when a function never produces a constant expression. In C++20
3891and earlier, for every @code{constexpr} function and function template,
3892there must be at least one set of function arguments in at least one
3893instantiation such that an invocation of the function or constructor
3894could be an evaluated subexpression of a core constant expression.
3895C++23 removed this restriction, so it's possible to have a function
3896or a function template marked @code{constexpr} for which no invocation
3897satisfies the requirements of a core constant expression.
3898
3899This warning is enabled as a pedantic warning by default in C++20 and
3900earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3901which case it will be an ordinary warning. For example:
3902
3903@smallexample
3904void f (int& i);
3905constexpr void
3906g (int& i)
3907@{
4ace81b6
SL
3908 // Warns by default in C++20, in C++23 only with -Winvalid-constexpr.
3909 f(i);
c85f8dbb
MP
3910@}
3911@end smallexample
3912
d77de738
ML
3913@opindex Winvalid-imported-macros
3914@opindex Wno-invalid-imported-macros
ddf6fe37 3915@item -Winvalid-imported-macros
d77de738
ML
3916Verify all imported macro definitions are valid at the end of
3917compilation. This is not enabled by default, as it requires
3918additional processing to determine. It may be useful when preparing
3919sets of header-units to ensure consistent macros.
3920
d77de738
ML
3921@opindex Wliteral-suffix
3922@opindex Wno-literal-suffix
ddf6fe37 3923@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
d77de738
ML
3924Do not warn when a string or character literal is followed by a
3925ud-suffix which does not begin with an underscore. As a conforming
3926extension, GCC treats such suffixes as separate preprocessing tokens
3927in order to maintain backwards compatibility with code that uses
3928formatting macros from @code{<inttypes.h>}. For example:
3929
3930@smallexample
3931#define __STDC_FORMAT_MACROS
3932#include <inttypes.h>
3933#include <stdio.h>
3934
3935int main() @{
3936 int64_t i64 = 123;
3937 printf("My int64: %" PRId64"\n", i64);
3938@}
3939@end smallexample
3940
3941In this case, @code{PRId64} is treated as a separate preprocessing token.
3942
3943This option also controls warnings when a user-defined literal
3944operator is declared with a literal suffix identifier that doesn't
3945begin with an underscore. Literal suffix identifiers that don't begin
3946with an underscore are reserved for future standardization.
3947
3948These warnings are enabled by default.
3949
d77de738
ML
3950@opindex Wnarrowing
3951@opindex Wno-narrowing
ddf6fe37 3952@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
d77de738
ML
3953For C++11 and later standards, narrowing conversions are diagnosed by default,
3954as required by the standard. A narrowing conversion from a constant produces
3955an error, and a narrowing conversion from a non-constant produces a warning,
3956but @option{-Wno-narrowing} suppresses the diagnostic.
3957Note that this does not affect the meaning of well-formed code;
3958narrowing conversions are still considered ill-formed in SFINAE contexts.
3959
3960With @option{-Wnarrowing} in C++98, warn when a narrowing
3961conversion prohibited by C++11 occurs within
3962@samp{@{ @}}, e.g.
3963
3964@smallexample
3965int i = @{ 2.2 @}; // error: narrowing from double to int
3966@end smallexample
3967
3968This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3969
d77de738
ML
3970@opindex Wnoexcept
3971@opindex Wno-noexcept
ddf6fe37 3972@item -Wnoexcept @r{(C++ and Objective-C++ only)}
d77de738
ML
3973Warn when a noexcept-expression evaluates to false because of a call
3974to a function that does not have a non-throwing exception
3975specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3976the compiler to never throw an exception.
3977
d77de738
ML
3978@opindex Wnoexcept-type
3979@opindex Wno-noexcept-type
ddf6fe37 3980@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
d77de738
ML
3981Warn if the C++17 feature making @code{noexcept} part of a function
3982type changes the mangled name of a symbol relative to C++14. Enabled
3983by @option{-Wabi} and @option{-Wc++17-compat}.
3984
3985As an example:
3986
3987@smallexample
3988template <class T> void f(T t) @{ t(); @};
3989void g() noexcept;
3990void h() @{ f(g); @}
3991@end smallexample
3992
3993@noindent
3994In C++14, @code{f} calls @code{f<void(*)()>}, but in
3995C++17 it calls @code{f<void(*)()noexcept>}.
3996
d77de738
ML
3997@opindex Wclass-memaccess
3998@opindex Wno-class-memaccess
ddf6fe37 3999@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
d77de738
ML
4000Warn when the destination of a call to a raw memory function such as
4001@code{memset} or @code{memcpy} is an object of class type, and when writing
4002into such an object might bypass the class non-trivial or deleted constructor
4003or copy assignment, violate const-correctness or encapsulation, or corrupt
4004virtual table pointers. Modifying the representation of such objects may
4005violate invariants maintained by member functions of the class. For example,
4006the call to @code{memset} below is undefined because it modifies a non-trivial
4007class object and is, therefore, diagnosed. The safe way to either initialize
4008or clear the storage of objects of such types is by using the appropriate
4009constructor or assignment operator, if one is available.
4010@smallexample
4011std::string str = "abc";
4012memset (&str, 0, sizeof str);
4013@end smallexample
4014The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
4015Explicitly casting the pointer to the class object to @code{void *} or
4016to a type that can be safely accessed by the raw memory function suppresses
4017the warning.
4018
d77de738
ML
4019@opindex Wnon-virtual-dtor
4020@opindex Wno-non-virtual-dtor
ddf6fe37 4021@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
d77de738
ML
4022Warn when a class has virtual functions and an accessible non-virtual
4023destructor itself or in an accessible polymorphic base class, in which
4024case it is possible but unsafe to delete an instance of a derived
4025class through a pointer to the class itself or base class. This
4026warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4027The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4028should be preferred because it warns about the unsafe cases without false
4029positives.
d77de738 4030
d77de738
ML
4031@opindex Wregister
4032@opindex Wno-register
ddf6fe37 4033@item -Wregister @r{(C++ and Objective-C++ only)}
d77de738
ML
4034Warn on uses of the @code{register} storage class specifier, except
4035when it is part of the GNU @ref{Explicit Register Variables} extension.
4036The use of the @code{register} keyword as storage class specifier has
4037been deprecated in C++11 and removed in C++17.
4038Enabled by default with @option{-std=c++17}.
4039
d77de738
ML
4040@opindex Wreorder
4041@opindex Wno-reorder
4042@cindex reordering, warning
4043@cindex warning for reordering of member initializers
f33d7a88 4044@item -Wreorder @r{(C++ and Objective-C++ only)}
d77de738
ML
4045Warn when the order of member initializers given in the code does not
4046match the order in which they must be executed. For instance:
4047
4048@smallexample
4049struct A @{
4050 int i;
4051 int j;
4052 A(): j (0), i (1) @{ @}
4053@};
4054@end smallexample
4055
4056@noindent
4057The compiler rearranges the member initializers for @code{i}
4058and @code{j} to match the declaration order of the members, emitting
4059a warning to that effect. This warning is enabled by @option{-Wall}.
4060
d77de738
ML
4061@opindex Wpessimizing-move
4062@opindex Wno-pessimizing-move
ddf6fe37 4063@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4064This warning warns when a call to @code{std::move} prevents copy
4065elision. A typical scenario when copy elision can occur is when returning in
4066a function with a class return type, when the expression being returned is the
4067name of a non-volatile automatic object, and is not a function parameter, and
4068has the same type as the function return type.
4069
4070@smallexample
4071struct T @{
4072@dots{}
4073@};
4074T fn()
4075@{
4076 T t;
4077 @dots{}
4078 return std::move (t);
4079@}
4080@end smallexample
4081
4082But in this example, the @code{std::move} call prevents copy elision.
4083
4084This warning is enabled by @option{-Wall}.
4085
d77de738
ML
4086@opindex Wredundant-move
4087@opindex Wno-redundant-move
ddf6fe37 4088@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
d77de738
ML
4089This warning warns about redundant calls to @code{std::move}; that is, when
4090a move operation would have been performed even without the @code{std::move}
4091call. This happens because the compiler is forced to treat the object as if
4092it were an rvalue in certain situations such as returning a local variable,
4093where copy elision isn't applicable. Consider:
4094
4095@smallexample
4096struct T @{
4097@dots{}
4098@};
4099T fn(T t)
4100@{
4101 @dots{}
4102 return std::move (t);
4103@}
4104@end smallexample
4105
4106Here, the @code{std::move} call is redundant. Because G++ implements Core
4107Issue 1579, another example is:
4108
4109@smallexample
4110struct T @{ // convertible to U
4111@dots{}
4112@};
4113struct U @{
4114@dots{}
4115@};
4116U fn()
4117@{
4118 T t;
4119 @dots{}
4120 return std::move (t);
4121@}
4122@end smallexample
4123In this example, copy elision isn't applicable because the type of the
4124expression being returned and the function return type differ, yet G++
4125treats the return value as if it were designated by an rvalue.
4126
4127This warning is enabled by @option{-Wextra}.
4128
d77de738
ML
4129@opindex Wrange-loop-construct
4130@opindex Wno-range-loop-construct
ddf6fe37 4131@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
d77de738
ML
4132This warning warns when a C++ range-based for-loop is creating an unnecessary
4133copy. This can happen when the range declaration is not a reference, but
4134probably should be. For example:
4135
4136@smallexample
4137struct S @{ char arr[128]; @};
4138void fn () @{
4139 S arr[5];
4140 for (const auto x : arr) @{ @dots{} @}
4141@}
4142@end smallexample
4143
4144It does not warn when the type being copied is a trivially-copyable type whose
4145size is less than 64 bytes.
4146
4147This warning also warns when a loop variable in a range-based for-loop is
4148initialized with a value of a different type resulting in a copy. For example:
4149
4150@smallexample
4151void fn() @{
4152 int arr[10];
4153 for (const double &x : arr) @{ @dots{} @}
4154@}
4155@end smallexample
4156
4157In the example above, in every iteration of the loop a temporary value of
4158type @code{double} is created and destroyed, to which the reference
4159@code{const double &} is bound.
4160
4161This warning is enabled by @option{-Wall}.
4162
d77de738
ML
4163@opindex Wredundant-tags
4164@opindex Wno-redundant-tags
ddf6fe37 4165@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4166Warn about redundant class-key and enum-key in references to class types
4167and enumerated types in contexts where the key can be eliminated without
4168causing an ambiguity. For example:
4169
4170@smallexample
4171struct foo;
4172struct foo *p; // warn that keyword struct can be eliminated
4173@end smallexample
4174
4175@noindent
4176On the other hand, in this example there is no warning:
4177
4178@smallexample
4179struct foo;
4180void foo (); // "hides" struct foo
4181void bar (struct foo&); // no warning, keyword struct is necessary
4182@end smallexample
4183
d77de738
ML
4184@opindex Wsubobject-linkage
4185@opindex Wno-subobject-linkage
ddf6fe37 4186@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
d77de738
ML
4187Do not warn
4188if a class type has a base or a field whose type uses the anonymous
4189namespace or depends on a type with no linkage. If a type A depends on
4190a type B with no or internal linkage, defining it in multiple
4191translation units would be an ODR violation because the meaning of B
4192is different in each translation unit. If A only appears in a single
4193translation unit, the best way to silence the warning is to give it
4194internal linkage by putting it in an anonymous namespace as well. The
4195compiler doesn't give this warning for types defined in the main .C
4196file, as those are unlikely to have multiple definitions.
4197@option{-Wsubobject-linkage} is enabled by default.
4198
d77de738
ML
4199@opindex Weffc++
4200@opindex Wno-effc++
ddf6fe37 4201@item -Weffc++ @r{(C++ and Objective-C++ only)}
d77de738
ML
4202Warn about violations of the following style guidelines from Scott Meyers'
4203@cite{Effective C++} series of books:
4204
4205@itemize @bullet
4206@item
4207Define a copy constructor and an assignment operator for classes
4208with dynamically-allocated memory.
4209
4210@item
4211Prefer initialization to assignment in constructors.
4212
4213@item
4214Have @code{operator=} return a reference to @code{*this}.
4215
4216@item
4217Don't try to return a reference when you must return an object.
4218
4219@item
4220Distinguish between prefix and postfix forms of increment and
4221decrement operators.
4222
4223@item
4224Never overload @code{&&}, @code{||}, or @code{,}.
4225
4226@end itemize
4227
4228This option also enables @option{-Wnon-virtual-dtor}, which is also
4229one of the effective C++ recommendations. However, the check is
4230extended to warn about the lack of virtual destructor in accessible
4231non-polymorphic bases classes too.
4232
4233When selecting this option, be aware that the standard library
4234headers do not obey all of these guidelines; use @samp{grep -v}
4235to filter out those warnings.
4236
d77de738
ML
4237@opindex Wexceptions
4238@opindex Wno-exceptions
ddf6fe37 4239@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
d77de738
ML
4240Disable the warning about the case when an exception handler is shadowed by
4241another handler, which can point out a wrong ordering of exception handlers.
4242
d77de738
ML
4243@opindex Wstrict-null-sentinel
4244@opindex Wno-strict-null-sentinel
ddf6fe37 4245@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
d77de738
ML
4246Warn about the use of an uncasted @code{NULL} as sentinel. When
4247compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4248to @code{__null}. Although it is a null pointer constant rather than a
4249null pointer, it is guaranteed to be of the same size as a pointer.
4250But this use is not portable across different compilers.
4251
d77de738
ML
4252@opindex Wno-non-template-friend
4253@opindex Wnon-template-friend
ddf6fe37 4254@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
d77de738
ML
4255Disable warnings when non-template friend functions are declared
4256within a template. In very old versions of GCC that predate implementation
4257of the ISO standard, declarations such as
4258@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4259could be interpreted as a particular specialization of a template
4260function; the warning exists to diagnose compatibility problems,
4261and is enabled by default.
4262
d77de738
ML
4263@opindex Wold-style-cast
4264@opindex Wno-old-style-cast
ddf6fe37 4265@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4266Warn if an old-style (C-style) cast to a non-void type is used within
4267a C++ program. The new-style casts (@code{dynamic_cast},
4268@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4269less vulnerable to unintended effects and much easier to search for.
4270
d77de738
ML
4271@opindex Woverloaded-virtual
4272@opindex Wno-overloaded-virtual
4273@cindex overloaded virtual function, warning
4274@cindex warning for overloaded virtual function
f33d7a88
AA
4275@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4276@itemx -Woverloaded-virtual=@var{n}
d77de738
ML
4277Warn when a function declaration hides virtual functions from a
4278base class. For example, in:
4279
4280@smallexample
4281struct A @{
4282 virtual void f();
4283@};
4284
4285struct B: public A @{
4286 void f(int); // does not override
4287@};
4288@end smallexample
4289
4290the @code{A} class version of @code{f} is hidden in @code{B}, and code
4291like:
4292
4293@smallexample
4294B* b;
4295b->f();
4296@end smallexample
4297
4298@noindent
4299fails to compile.
4300
d82490d5
JW
4301In cases where the different signatures are not an accident, the
4302simplest solution is to add a using-declaration to the derived class
4303to un-hide the base function, e.g. add @code{using A::f;} to @code{B}.
4304
d77de738
ML
4305The optional level suffix controls the behavior when all the
4306declarations in the derived class override virtual functions in the
4307base class, even if not all of the base functions are overridden:
4308
4309@smallexample
4310struct C @{
4311 virtual void f();
4312 virtual void f(int);
4313@};
4314
4315struct D: public C @{
4316 void f(int); // does override
4317@}
4318@end smallexample
4319
4320This pattern is less likely to be a mistake; if D is only used
4321virtually, the user might have decided that the base class semantics
4322for some of the overloads are fine.
4323
4324At level 1, this case does not warn; at level 2, it does.
4325@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4326included in @option{-Wall}.
4327
d77de738
ML
4328@opindex Wno-pmf-conversions
4329@opindex Wpmf-conversions
ddf6fe37 4330@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
d77de738
ML
4331Disable the diagnostic for converting a bound pointer to member function
4332to a plain pointer.
4333
d77de738
ML
4334@opindex Wsign-promo
4335@opindex Wno-sign-promo
ddf6fe37 4336@item -Wsign-promo @r{(C++ and Objective-C++ only)}
d77de738
ML
4337Warn when overload resolution chooses a promotion from unsigned or
4338enumerated type to a signed type, over a conversion to an unsigned type of
4339the same size. Previous versions of G++ tried to preserve
4340unsignedness, but the standard mandates the current behavior.
4341
d77de738
ML
4342@opindex Wtemplates
4343@opindex Wno-templates
ddf6fe37 4344@item -Wtemplates @r{(C++ and Objective-C++ only)}
d77de738
ML
4345Warn when a primary template declaration is encountered. Some coding
4346rules disallow templates, and this may be used to enforce that rule.
4347The warning is inactive inside a system header file, such as the STL, so
4348one can still use the STL. One may also instantiate or specialize
4349templates.
4350
d77de738
ML
4351@opindex Wmismatched-new-delete
4352@opindex Wno-mismatched-new-delete
ddf6fe37 4353@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
d77de738
ML
4354Warn for mismatches between calls to @code{operator new} or @code{operator
4355delete} and the corresponding call to the allocation or deallocation function.
4356This includes invocations of C++ @code{operator delete} with pointers
4357returned from either mismatched forms of @code{operator new}, or from other
4358functions that allocate objects for which the @code{operator delete} isn't
4359a suitable deallocator, as well as calls to other deallocation functions
4360with pointers returned from @code{operator new} for which the deallocation
4361function isn't suitable.
4362
4363For example, the @code{delete} expression in the function below is diagnosed
4364because it doesn't match the array form of the @code{new} expression
4365the pointer argument was returned from. Similarly, the call to @code{free}
4366is also diagnosed.
4367
4368@smallexample
4369void f ()
4370@{
4371 int *a = new int[n];
4372 delete a; // warning: mismatch in array forms of expressions
4373
4374 char *p = new char[n];
4375 free (p); // warning: mismatch between new and free
4376@}
4377@end smallexample
4378
4379The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4380involving allocation and deallocation functions other than @code{operator
4381new} and @code{operator delete}.
4382
4383@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4384
d77de738
ML
4385@opindex Wmismatched-tags
4386@opindex Wno-mismatched-tags
ddf6fe37 4387@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
d77de738
ML
4388Warn for declarations of structs, classes, and class templates and their
4389specializations with a class-key that does not match either the definition
4390or the first declaration if no definition is provided.
4391
4392For example, the declaration of @code{struct Object} in the argument list
4393of @code{draw} triggers the warning. To avoid it, either remove the redundant
4394class-key @code{struct} or replace it with @code{class} to match its definition.
4395@smallexample
4396class Object @{
4397public:
4398 virtual ~Object () = 0;
4399@};
4400void draw (struct Object*);
4401@end smallexample
4402
4403It is not wrong to declare a class with the class-key @code{struct} as
4404the example above shows. The @option{-Wmismatched-tags} option is intended
4405to help achieve a consistent style of class declarations. In code that is
4406intended to be portable to Windows-based compilers the warning helps prevent
4407unresolved references due to the difference in the mangling of symbols
4408declared with different class-keys. The option can be used either on its
4409own or in conjunction with @option{-Wredundant-tags}.
4410
d77de738
ML
4411@opindex Wmultiple-inheritance
4412@opindex Wno-multiple-inheritance
ddf6fe37 4413@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
d77de738
ML
4414Warn when a class is defined with multiple direct base classes. Some
4415coding rules disallow multiple inheritance, and this may be used to
4416enforce that rule. The warning is inactive inside a system header file,
4417such as the STL, so one can still use the STL. One may also define
4418classes that indirectly use multiple inheritance.
4419
d77de738
ML
4420@opindex Wvirtual-inheritance
4421@opindex Wno-virtual-inheritance
ddf6fe37 4422@item -Wvirtual-inheritance
d77de738
ML
4423Warn when a class is defined with a virtual direct base class. Some
4424coding rules disallow multiple inheritance, and this may be used to
4425enforce that rule. The warning is inactive inside a system header file,
4426such as the STL, so one can still use the STL. One may also define
4427classes that indirectly use virtual inheritance.
4428
d77de738
ML
4429@opindex Wvirtual-move-assign
4430@opindex Wno-virtual-move-assign
ddf6fe37 4431@item -Wno-virtual-move-assign
d77de738
ML
4432Suppress warnings about inheriting from a virtual base with a
4433non-trivial C++11 move assignment operator. This is dangerous because
4434if the virtual base is reachable along more than one path, it is
4435moved multiple times, which can mean both objects end up in the
4436moved-from state. If the move assignment operator is written to avoid
4437moving from a moved-from object, this warning can be disabled.
4438
d77de738
ML
4439@opindex Wnamespaces
4440@opindex Wno-namespaces
ddf6fe37 4441@item -Wnamespaces
d77de738
ML
4442Warn when a namespace definition is opened. Some coding rules disallow
4443namespaces, and this may be used to enforce that rule. The warning is
4444inactive inside a system header file, such as the STL, so one can still
4445use the STL. One may also use using directives and qualified names.
4446
d77de738
ML
4447@opindex Wterminate
4448@opindex Wno-terminate
ddf6fe37 4449@item -Wno-terminate @r{(C++ and Objective-C++ only)}
d77de738
ML
4450Disable the warning about a throw-expression that will immediately
4451result in a call to @code{terminate}.
4452
d77de738
ML
4453@opindex Wvexing-parse
4454@opindex Wno-vexing-parse
ddf6fe37 4455@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
d77de738
ML
4456Warn about the most vexing parse syntactic ambiguity. This warns about
4457the cases when a declaration looks like a variable definition, but the
4458C++ language requires it to be interpreted as a function declaration.
4459For instance:
4460
4461@smallexample
4462void f(double a) @{
4463 int i(); // extern int i (void);
4464 int n(int(a)); // extern int n (int);
4465@}
4466@end smallexample
4467
4468Another example:
4469
4470@smallexample
4471struct S @{ S(int); @};
4472void f(double a) @{
4473 S x(int(a)); // extern struct S x (int);
4474 S y(int()); // extern struct S y (int (*) (void));
4475 S z(); // extern struct S z (void);
4476@}
4477@end smallexample
4478
4479The warning will suggest options how to deal with such an ambiguity; e.g.,
4480it can suggest removing the parentheses or using braces instead.
4481
4482This warning is enabled by default.
4483
d77de738
ML
4484@opindex Wno-class-conversion
4485@opindex Wclass-conversion
ddf6fe37 4486@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
d77de738
ML
4487Do not warn when a conversion function converts an
4488object to the same type, to a base class of that type, or to void; such
4489a conversion function will never be called.
4490
d77de738
ML
4491@opindex Wvolatile
4492@opindex Wno-volatile
ddf6fe37 4493@item -Wvolatile @r{(C++ and Objective-C++ only)}
d77de738
ML
4494Warn about deprecated uses of the @code{volatile} qualifier. This includes
4495postfix and prefix @code{++} and @code{--} expressions of
4496@code{volatile}-qualified types, using simple assignments where the left
4497operand is a @code{volatile}-qualified non-class type for their value,
4498compound assignments where the left operand is a @code{volatile}-qualified
4499non-class type, @code{volatile}-qualified function return type,
4500@code{volatile}-qualified parameter type, and structured bindings of a
4501@code{volatile}-qualified type. This usage was deprecated in C++20.
4502
4503Enabled by default with @option{-std=c++20}.
4504
d77de738
ML
4505@opindex Wzero-as-null-pointer-constant
4506@opindex Wno-zero-as-null-pointer-constant
ddf6fe37 4507@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
d77de738
ML
4508Warn when a literal @samp{0} is used as null pointer constant. This can
4509be useful to facilitate the conversion to @code{nullptr} in C++11.
4510
d77de738
ML
4511@opindex Waligned-new
4512@opindex Wno-aligned-new
ddf6fe37 4513@item -Waligned-new
d77de738
ML
4514Warn about a new-expression of a type that requires greater alignment
4515than the @code{alignof(std::max_align_t)} but uses an allocation
4516function without an explicit alignment parameter. This option is
4517enabled by @option{-Wall}.
4518
4519Normally this only warns about global allocation functions, but
4520@option{-Waligned-new=all} also warns about class member allocation
4521functions.
4522
d77de738
ML
4523@opindex Wplacement-new
4524@opindex Wno-placement-new
ddf6fe37
AA
4525@item -Wno-placement-new
4526@itemx -Wplacement-new=@var{n}
d77de738
ML
4527Warn about placement new expressions with undefined behavior, such as
4528constructing an object in a buffer that is smaller than the type of
4529the object. For example, the placement new expression below is diagnosed
4530because it attempts to construct an array of 64 integers in a buffer only
453164 bytes large.
4532@smallexample
4533char buf [64];
4534new (buf) int[64];
4535@end smallexample
4536This warning is enabled by default.
4537
4538@table @gcctabopt
4539@item -Wplacement-new=1
4540This is the default warning level of @option{-Wplacement-new}. At this
4541level the warning is not issued for some strictly undefined constructs that
4542GCC allows as extensions for compatibility with legacy code. For example,
4543the following @code{new} expression is not diagnosed at this level even
4544though it has undefined behavior according to the C++ standard because
4545it writes past the end of the one-element array.
4546@smallexample
4547struct S @{ int n, a[1]; @};
4548S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4549new (s->a)int [32]();
4550@end smallexample
4551
4552@item -Wplacement-new=2
4553At this level, in addition to diagnosing all the same constructs as at level
45541, a diagnostic is also issued for placement new expressions that construct
4555an object in the last member of structure whose type is an array of a single
4556element and whose size is less than the size of the object being constructed.
4557While the previous example would be diagnosed, the following construct makes
4558use of the flexible member array extension to avoid the warning at level 2.
4559@smallexample
4560struct S @{ int n, a[]; @};
4561S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4562new (s->a)int [32]();
4563@end smallexample
4564
4565@end table
4566
d77de738
ML
4567@opindex Wcatch-value
4568@opindex Wno-catch-value
ddf6fe37
AA
4569@item -Wcatch-value
4570@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
d77de738
ML
4571Warn about catch handlers that do not catch via reference.
4572With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4573warn about polymorphic class types that are caught by value.
4574With @option{-Wcatch-value=2} warn about all class types that are caught
4575by value. With @option{-Wcatch-value=3} warn about all types that are
4576not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4577
d77de738
ML
4578@opindex Wconditionally-supported
4579@opindex Wno-conditionally-supported
ddf6fe37 4580@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
d77de738
ML
4581Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4582
d77de738
ML
4583@opindex Wdelete-incomplete
4584@opindex Wno-delete-incomplete
ddf6fe37 4585@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
d77de738
ML
4586Do not warn when deleting a pointer to incomplete type, which may cause
4587undefined behavior at runtime. This warning is enabled by default.
4588
d77de738
ML
4589@opindex Wextra-semi
4590@opindex Wno-extra-semi
ddf6fe37 4591@item -Wextra-semi @r{(C++, Objective-C++ only)}
d77de738
ML
4592Warn about redundant semicolons after in-class function definitions.
4593
d77de738
ML
4594@opindex Winaccessible-base
4595@opindex Wno-inaccessible-base
ddf6fe37 4596@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
d77de738
ML
4597This option controls warnings
4598when a base class is inaccessible in a class derived from it due to
4599ambiguity. The warning is enabled by default.
4600Note that the warning for ambiguous virtual
4601bases is enabled by the @option{-Wextra} option.
4602@smallexample
4603@group
4604struct A @{ int a; @};
4605
4606struct B : A @{ @};
4607
4608struct C : B, A @{ @};
4609@end group
4610@end smallexample
4611
d77de738
ML
4612@opindex Winherited-variadic-ctor
4613@opindex Wno-inherited-variadic-ctor
ddf6fe37 4614@item -Wno-inherited-variadic-ctor
d77de738
ML
4615Suppress warnings about use of C++11 inheriting constructors when the
4616base class inherited from has a C variadic constructor; the warning is
4617on by default because the ellipsis is not inherited.
4618
d77de738
ML
4619@opindex Wno-invalid-offsetof
4620@opindex Winvalid-offsetof
ddf6fe37 4621@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
d77de738
ML
4622Suppress warnings from applying the @code{offsetof} macro to a non-POD
4623type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4624to a non-standard-layout type is undefined. In existing C++ implementations,
4625however, @code{offsetof} typically gives meaningful results.
4626This flag is for users who are aware that they are
4627writing nonportable code and who have deliberately chosen to ignore the
4628warning about it.
4629
4630The restrictions on @code{offsetof} may be relaxed in a future version
4631of the C++ standard.
4632
d77de738
ML
4633@opindex Wsized-deallocation
4634@opindex Wno-sized-deallocation
ddf6fe37 4635@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
d77de738
ML
4636Warn about a definition of an unsized deallocation function
4637@smallexample
4638void operator delete (void *) noexcept;
4639void operator delete[] (void *) noexcept;
4640@end smallexample
4641without a definition of the corresponding sized deallocation function
4642@smallexample
4643void operator delete (void *, std::size_t) noexcept;
4644void operator delete[] (void *, std::size_t) noexcept;
4645@end smallexample
4646or vice versa. Enabled by @option{-Wextra} along with
4647@option{-fsized-deallocation}.
4648
d77de738
ML
4649@opindex Wno-suggest-final-types
4650@opindex Wsuggest-final-types
ddf6fe37 4651@item -Wsuggest-final-types
d77de738
ML
4652Warn about types with virtual methods where code quality would be improved
4653if the type were declared with the C++11 @code{final} specifier,
4654or, if possible,
4655declared in an anonymous namespace. This allows GCC to more aggressively
4656devirtualize the polymorphic calls. This warning is more effective with
4657link-time optimization,
4658where the information about the class hierarchy graph is
4659more complete.
4660
d77de738
ML
4661@opindex Wno-suggest-final-methods
4662@opindex Wsuggest-final-methods
ddf6fe37 4663@item -Wsuggest-final-methods
d77de738
ML
4664Warn about virtual methods where code quality would be improved if the method
4665were declared with the C++11 @code{final} specifier,
4666or, if possible, its type were
4667declared in an anonymous namespace or with the @code{final} specifier.
4668This warning is
4669more effective with link-time optimization, where the information about the
4670class hierarchy graph is more complete. It is recommended to first consider
4671suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4672annotations.
4673
d77de738
ML
4674@opindex Wsuggest-override
4675@opindex Wno-suggest-override
ddf6fe37 4676@item -Wsuggest-override
d77de738
ML
4677Warn about overriding virtual functions that are not marked with the
4678@code{override} keyword.
4679
d77de738
ML
4680@opindex Wuse-after-free
4681@opindex Wno-use-after-free
ddf6fe37
AA
4682@item -Wuse-after-free
4683@itemx -Wuse-after-free=@var{n}
d77de738
ML
4684Warn about uses of pointers to dynamically allocated objects that have
4685been rendered indeterminate by a call to a deallocation function.
4686The warning is enabled at all optimization levels but may yield different
4687results with optimization than without.
4688
4689@table @gcctabopt
4690@item -Wuse-after-free=1
4691At level 1 the warning attempts to diagnose only unconditional uses
4692of pointers made indeterminate by a deallocation call or a successful
4693call to @code{realloc}, regardless of whether or not the call resulted
4694in an actual reallocatio of memory. This includes double-@code{free}
4695calls as well as uses in arithmetic and relational expressions. Although
4696undefined, uses of indeterminate pointers in equality (or inequality)
4697expressions are not diagnosed at this level.
4698@item -Wuse-after-free=2
4699At level 2, in addition to unconditional uses, the warning also diagnoses
4700conditional uses of pointers made indeterminate by a deallocation call.
4701As at level 2, uses in equality (or inequality) expressions are not
4702diagnosed. For example, the second call to @code{free} in the following
4703function is diagnosed at this level:
4704@smallexample
4705struct A @{ int refcount; void *data; @};
4706
4707void release (struct A *p)
4708@{
4709 int refcount = --p->refcount;
4710 free (p);
4711 if (refcount == 0)
4712 free (p->data); // warning: p may be used after free
4713@}
4714@end smallexample
4715@item -Wuse-after-free=3
4716At level 3, the warning also diagnoses uses of indeterminate pointers in
4717equality expressions. All uses of indeterminate pointers are undefined
4718but equality tests sometimes appear after calls to @code{realloc} as
4719an attempt to determine whether the call resulted in relocating the object
4720to a different address. They are diagnosed at a separate level to aid
4721legacy code gradually transition to safe alternatives. For example,
4722the equality test in the function below is diagnosed at this level:
4723@smallexample
4724void adjust_pointers (int**, int);
4725
4726void grow (int **p, int n)
4727@{
4728 int **q = (int**)realloc (p, n *= 2);
4729 if (q == p)
4730 return;
4731 adjust_pointers ((int**)q, n);
4732@}
4733@end smallexample
4734To avoid the warning at this level, store offsets into allocated memory
4735instead of pointers. This approach obviates needing to adjust the stored
4736pointers after reallocation.
4737@end table
4738
4739@option{-Wuse-after-free=2} is included in @option{-Wall}.
4740
d77de738
ML
4741@opindex Wuseless-cast
4742@opindex Wno-useless-cast
ddf6fe37 4743@item -Wuseless-cast @r{(C++ and Objective-C++ only)}
d77de738
ML
4744Warn when an expression is cast to its own type. This warning does not
4745occur when a class object is converted to a non-reference type as that
4746is a way to create a temporary:
4747
4748@smallexample
4749struct S @{ @};
4750void g (S&&);
4751void f (S&& arg)
4752@{
4753 g (S(arg)); // make arg prvalue so that it can bind to S&&
4754@}
4755@end smallexample
4756
d77de738
ML
4757@opindex Wconversion-null
4758@opindex Wno-conversion-null
ddf6fe37 4759@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
d77de738
ML
4760Do not warn for conversions between @code{NULL} and non-pointer
4761types. @option{-Wconversion-null} is enabled by default.
4762
4763@end table
4764
4765@node Objective-C and Objective-C++ Dialect Options
4766@section Options Controlling Objective-C and Objective-C++ Dialects
4767
4768@cindex compiler options, Objective-C and Objective-C++
4769@cindex Objective-C and Objective-C++ options, command-line
4770@cindex options, Objective-C and Objective-C++
4771(NOTE: This manual does not describe the Objective-C and Objective-C++
4772languages themselves. @xref{Standards,,Language Standards
4773Supported by GCC}, for references.)
4774
4775This section describes the command-line options that are only meaningful
4776for Objective-C and Objective-C++ programs. You can also use most of
4777the language-independent GNU compiler options.
4778For example, you might compile a file @file{some_class.m} like this:
4779
4780@smallexample
4781gcc -g -fgnu-runtime -O -c some_class.m
4782@end smallexample
4783
4784@noindent
4785In this example, @option{-fgnu-runtime} is an option meant only for
4786Objective-C and Objective-C++ programs; you can use the other options with
4787any language supported by GCC@.
4788
4789Note that since Objective-C is an extension of the C language, Objective-C
4790compilations may also use options specific to the C front-end (e.g.,
4791@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4792C++-specific options (e.g., @option{-Wabi}).
4793
4794Here is a list of options that are @emph{only} for compiling Objective-C
4795and Objective-C++ programs:
4796
4797@table @gcctabopt
d77de738 4798@opindex fconstant-string-class
ddf6fe37 4799@item -fconstant-string-class=@var{class-name}
d77de738
ML
4800Use @var{class-name} as the name of the class to instantiate for each
4801literal string specified with the syntax @code{@@"@dots{}"}. The default
4802class name is @code{NXConstantString} if the GNU runtime is being used, and
4803@code{NSConstantString} if the NeXT runtime is being used (see below). The
4804@option{-fconstant-cfstrings} option, if also present, overrides the
4805@option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4806to be laid out as constant CoreFoundation strings.
4807
d77de738 4808@opindex fgnu-runtime
ddf6fe37 4809@item -fgnu-runtime
d77de738
ML
4810Generate object code compatible with the standard GNU Objective-C
4811runtime. This is the default for most types of systems.
4812
d77de738 4813@opindex fnext-runtime
ddf6fe37 4814@item -fnext-runtime
d77de738
ML
4815Generate output compatible with the NeXT runtime. This is the default
4816for NeXT-based systems, including Darwin and Mac OS X@. The macro
4817@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4818used.
4819
d77de738
ML
4820@opindex fno-nil-receivers
4821@opindex fnil-receivers
ddf6fe37 4822@item -fno-nil-receivers
d77de738
ML
4823Assume that all Objective-C message dispatches (@code{[receiver
4824message:arg]}) in this translation unit ensure that the receiver is
4825not @code{nil}. This allows for more efficient entry points in the
4826runtime to be used. This option is only available in conjunction with
4827the NeXT runtime and ABI version 0 or 1.
4828
d77de738 4829@opindex fobjc-abi-version
ddf6fe37 4830@item -fobjc-abi-version=@var{n}
d77de738
ML
4831Use version @var{n} of the Objective-C ABI for the selected runtime.
4832This option is currently supported only for the NeXT runtime. In that
4833case, Version 0 is the traditional (32-bit) ABI without support for
4834properties and other Objective-C 2.0 additions. Version 1 is the
4835traditional (32-bit) ABI with support for properties and other
4836Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4837nothing is specified, the default is Version 0 on 32-bit target
4838machines, and Version 2 on 64-bit target machines.
4839
d77de738 4840@opindex fobjc-call-cxx-cdtors
ddf6fe37 4841@item -fobjc-call-cxx-cdtors
d77de738
ML
4842For each Objective-C class, check if any of its instance variables is a
4843C++ object with a non-trivial default constructor. If so, synthesize a
4844special @code{- (id) .cxx_construct} instance method which runs
4845non-trivial default constructors on any such instance variables, in order,
4846and then return @code{self}. Similarly, check if any instance variable
4847is a C++ object with a non-trivial destructor, and if so, synthesize a
4848special @code{- (void) .cxx_destruct} method which runs
4849all such default destructors, in reverse order.
4850
4851The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4852methods thusly generated only operate on instance variables
4853declared in the current Objective-C class, and not those inherited
4854from superclasses. It is the responsibility of the Objective-C
4855runtime to invoke all such methods in an object's inheritance
4856hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4857by the runtime immediately after a new object instance is allocated;
4858the @code{- (void) .cxx_destruct} methods are invoked immediately
4859before the runtime deallocates an object instance.
4860
4861As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4862support for invoking the @code{- (id) .cxx_construct} and
4863@code{- (void) .cxx_destruct} methods.
4864
d77de738 4865@opindex fobjc-direct-dispatch
ddf6fe37 4866@item -fobjc-direct-dispatch
d77de738
ML
4867Allow fast jumps to the message dispatcher. On Darwin this is
4868accomplished via the comm page.
4869
d77de738 4870@opindex fobjc-exceptions
ddf6fe37 4871@item -fobjc-exceptions
d77de738
ML
4872Enable syntactic support for structured exception handling in
4873Objective-C, similar to what is offered by C++. This option
4874is required to use the Objective-C keywords @code{@@try},
4875@code{@@throw}, @code{@@catch}, @code{@@finally} and
4876@code{@@synchronized}. This option is available with both the GNU
4877runtime and the NeXT runtime (but not available in conjunction with
4878the NeXT runtime on Mac OS X 10.2 and earlier).
4879
d77de738 4880@opindex fobjc-gc
ddf6fe37 4881@item -fobjc-gc
d77de738
ML
4882Enable garbage collection (GC) in Objective-C and Objective-C++
4883programs. This option is only available with the NeXT runtime; the
4884GNU runtime has a different garbage collection implementation that
4885does not require special compiler flags.
4886
d77de738 4887@opindex fobjc-nilcheck
ddf6fe37 4888@item -fobjc-nilcheck
d77de738
ML
4889For the NeXT runtime with version 2 of the ABI, check for a nil
4890receiver in method invocations before doing the actual method call.
4891This is the default and can be disabled using
4892@option{-fno-objc-nilcheck}. Class methods and super calls are never
4893checked for nil in this way no matter what this flag is set to.
4894Currently this flag does nothing when the GNU runtime, or an older
4895version of the NeXT runtime ABI, is used.
4896
d77de738 4897@opindex fobjc-std
ddf6fe37 4898@item -fobjc-std=objc1
d77de738
ML
4899Conform to the language syntax of Objective-C 1.0, the language
4900recognized by GCC 4.0. This only affects the Objective-C additions to
4901the C/C++ language; it does not affect conformance to C/C++ standards,
4902which is controlled by the separate C/C++ dialect option flags. When
4903this option is used with the Objective-C or Objective-C++ compiler,
4904any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4905This is useful if you need to make sure that your Objective-C code can
4906be compiled with older versions of GCC@.
4907
d77de738 4908@opindex freplace-objc-classes
ddf6fe37 4909@item -freplace-objc-classes
d77de738
ML
4910Emit a special marker instructing @command{ld(1)} not to statically link in
4911the resulting object file, and allow @command{dyld(1)} to load it in at
4912run time instead. This is used in conjunction with the Fix-and-Continue
4913debugging mode, where the object file in question may be recompiled and
4914dynamically reloaded in the course of program execution, without the need
4915to restart the program itself. Currently, Fix-and-Continue functionality
4916is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4917and later.
4918
d77de738 4919@opindex fzero-link
ddf6fe37 4920@item -fzero-link
d77de738
ML
4921When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4922to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4923compile time) with static class references that get initialized at load time,
4924which improves run-time performance. Specifying the @option{-fzero-link} flag
4925suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4926to be retained. This is useful in Zero-Link debugging mode, since it allows
4927for individual class implementations to be modified during program execution.
4928The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4929regardless of command-line options.
4930
d77de738
ML
4931@opindex fno-local-ivars
4932@opindex flocal-ivars
ddf6fe37 4933@item -fno-local-ivars
d77de738
ML
4934By default instance variables in Objective-C can be accessed as if
4935they were local variables from within the methods of the class they're
4936declared in. This can lead to shadowing between instance variables
4937and other variables declared either locally inside a class method or
4938globally with the same name. Specifying the @option{-fno-local-ivars}
4939flag disables this behavior thus avoiding variable shadowing issues.
4940
d77de738 4941@opindex fivar-visibility
ddf6fe37 4942@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
d77de738
ML
4943Set the default instance variable visibility to the specified option
4944so that instance variables declared outside the scope of any access
4945modifier directives default to the specified visibility.
4946
d77de738 4947@opindex gen-decls
ddf6fe37 4948@item -gen-decls
d77de738
ML
4949Dump interface declarations for all classes seen in the source file to a
4950file named @file{@var{sourcename}.decl}.
4951
d77de738
ML
4952@opindex Wassign-intercept
4953@opindex Wno-assign-intercept
ddf6fe37 4954@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4955Warn whenever an Objective-C assignment is being intercepted by the
4956garbage collector.
4957
d77de738
ML
4958@opindex Wproperty-assign-default
4959@opindex Wno-property-assign-default
ddf6fe37 4960@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4961Do not warn if a property for an Objective-C object has no assign
4962semantics specified.
4963
d77de738
ML
4964@opindex Wno-protocol
4965@opindex Wprotocol
ddf6fe37 4966@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4967If a class is declared to implement a protocol, a warning is issued for
4968every method in the protocol that is not implemented by the class. The
4969default behavior is to issue a warning for every method not explicitly
4970implemented in the class, even if a method implementation is inherited
4971from the superclass. If you use the @option{-Wno-protocol} option, then
4972methods inherited from the superclass are considered to be implemented,
4973and no warning is issued for them.
4974
d77de738 4975@opindex Wobjc-root-class
ddf6fe37 4976@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4977Warn if a class interface lacks a superclass. Most classes will inherit
4978from @code{NSObject} (or @code{Object}) for example. When declaring
4979classes intended to be root classes, the warning can be suppressed by
4980marking their interfaces with @code{__attribute__((objc_root_class))}.
4981
d77de738
ML
4982@opindex Wselector
4983@opindex Wno-selector
ddf6fe37 4984@item -Wselector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4985Warn if multiple methods of different types for the same selector are
4986found during compilation. The check is performed on the list of methods
4987in the final stage of compilation. Additionally, a check is performed
4988for each selector appearing in a @code{@@selector(@dots{})}
4989expression, and a corresponding method for that selector has been found
4990during compilation. Because these checks scan the method table only at
4991the end of compilation, these warnings are not produced if the final
4992stage of compilation is not reached, for example because an error is
4993found during compilation, or because the @option{-fsyntax-only} option is
4994being used.
4995
d77de738
ML
4996@opindex Wstrict-selector-match
4997@opindex Wno-strict-selector-match
ddf6fe37 4998@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
d77de738
ML
4999Warn if multiple methods with differing argument and/or return types are
5000found for a given selector when attempting to send a message using this
5001selector to a receiver of type @code{id} or @code{Class}. When this flag
5002is off (which is the default behavior), the compiler omits such warnings
5003if any differences found are confined to types that share the same size
5004and alignment.
5005
d77de738
ML
5006@opindex Wundeclared-selector
5007@opindex Wno-undeclared-selector
ddf6fe37 5008@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
d77de738
ML
5009Warn if a @code{@@selector(@dots{})} expression referring to an
5010undeclared selector is found. A selector is considered undeclared if no
5011method with that name has been declared before the
5012@code{@@selector(@dots{})} expression, either explicitly in an
5013@code{@@interface} or @code{@@protocol} declaration, or implicitly in
5014an @code{@@implementation} section. This option always performs its
5015checks as soon as a @code{@@selector(@dots{})} expression is found,
5016while @option{-Wselector} only performs its checks in the final stage of
5017compilation. This also enforces the coding style convention
5018that methods and selectors must be declared before being used.
5019
d77de738 5020@opindex print-objc-runtime-info
ddf6fe37 5021@item -print-objc-runtime-info
d77de738
ML
5022Generate C header describing the largest structure that is passed by
5023value, if any.
5024
5025@end table
5026
5027@node Diagnostic Message Formatting Options
5028@section Options to Control Diagnostic Messages Formatting
5029@cindex options to control diagnostics formatting
5030@cindex diagnostic messages
5031@cindex message formatting
5032
5033Traditionally, diagnostic messages have been formatted irrespective of
5034the output device's aspect (e.g.@: its width, @dots{}). You can use the
5035options described below
5036to control the formatting algorithm for diagnostic messages,
5037e.g.@: how many characters per line, how often source location
5038information should be reported. Note that some language front ends may not
5039honor these options.
5040
5041@table @gcctabopt
d77de738 5042@opindex fmessage-length
ddf6fe37 5043@item -fmessage-length=@var{n}
d77de738
ML
5044Try to format error messages so that they fit on lines of about
5045@var{n} characters. If @var{n} is zero, then no line-wrapping is
5046done; each error message appears on a single line. This is the
5047default for all front ends.
5048
5049Note - this option also affects the display of the @samp{#error} and
5050@samp{#warning} pre-processor directives, and the @samp{deprecated}
5051function/type/variable attribute. It does not however affect the
5052@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5053
5054@item -fdiagnostics-plain-output
5055This option requests that diagnostic output look as plain as possible, which
5056may be useful when running @command{dejagnu} or other utilities that need to
5057parse diagnostics output and prefer that it remain more stable over time.
5058@option{-fdiagnostics-plain-output} is currently equivalent to the following
5059options:
5060@gccoptlist{-fno-diagnostics-show-caret @gol
5061-fno-diagnostics-show-line-numbers @gol
5062-fdiagnostics-color=never @gol
5063-fdiagnostics-urls=never @gol
5064-fdiagnostics-path-format=separate-events}
5065In the future, if GCC changes the default appearance of its diagnostics, the
5066corresponding option to disable the new behavior will be added to this list.
5067
d77de738 5068@opindex fdiagnostics-show-location
ddf6fe37 5069@item -fdiagnostics-show-location=once
d77de738
ML
5070Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5071reporter to emit source location information @emph{once}; that is, in
5072case the message is too long to fit on a single physical line and has to
5073be wrapped, the source location won't be emitted (as prefix) again,
5074over and over, in subsequent continuation lines. This is the default
5075behavior.
5076
5077@item -fdiagnostics-show-location=every-line
5078Only meaningful in line-wrapping mode. Instructs the diagnostic
5079messages reporter to emit the same source location information (as
5080prefix) for physical lines that result from the process of breaking
5081a message which is too long to fit on a single line.
5082
ddf6fe37 5083@opindex fdiagnostics-color
d77de738
ML
5084@cindex highlight, color
5085@vindex GCC_COLORS @r{environment variable}
f33d7a88
AA
5086@item -fdiagnostics-color[=@var{WHEN}]
5087@itemx -fno-diagnostics-color
d77de738
ML
5088Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5089or @samp{auto}. The default depends on how the compiler has been configured,
5090it can be any of the above @var{WHEN} options or also @samp{never}
5091if @env{GCC_COLORS} environment variable isn't present in the environment,
5092and @samp{auto} otherwise.
5093@samp{auto} makes GCC use color only when the standard error is a terminal,
5094and when not executing in an emacs shell.
5095The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5096aliases for @option{-fdiagnostics-color=always} and
5097@option{-fdiagnostics-color=never}, respectively.
5098
5099The colors are defined by the environment variable @env{GCC_COLORS}.
5100Its value is a colon-separated list of capabilities and Select Graphic
5101Rendition (SGR) substrings. SGR commands are interpreted by the
5102terminal or terminal emulator. (See the section in the documentation
5103of your text terminal for permitted values and their meanings as
5104character attributes.) These substring values are integers in decimal
5105representation and can be concatenated with semicolons.
5106Common values to concatenate include
5107@samp{1} for bold,
5108@samp{4} for underline,
5109@samp{5} for blink,
5110@samp{7} for inverse,
5111@samp{39} for default foreground color,
5112@samp{30} to @samp{37} for foreground colors,
5113@samp{90} to @samp{97} for 16-color mode foreground colors,
5114@samp{38;5;0} to @samp{38;5;255}
5115for 88-color and 256-color modes foreground colors,
5116@samp{49} for default background color,
5117@samp{40} to @samp{47} for background colors,
5118@samp{100} to @samp{107} for 16-color mode background colors,
5119and @samp{48;5;0} to @samp{48;5;255}
5120for 88-color and 256-color modes background colors.
5121
5122The default @env{GCC_COLORS} is
5123@smallexample
5124error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5125quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5126diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5127type-diff=01;32:fnname=01;32:targs=35
5128@end smallexample
5129@noindent
5130where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5131@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5132@samp{01} is bold, and @samp{31} is red.
5133Setting @env{GCC_COLORS} to the empty string disables colors.
5134Supported capabilities are as follows.
5135
5136@table @code
d77de738 5137@vindex error GCC_COLORS @r{capability}
f33d7a88 5138@item error=
d77de738
ML
5139SGR substring for error: markers.
5140
d77de738 5141@vindex warning GCC_COLORS @r{capability}
f33d7a88 5142@item warning=
d77de738
ML
5143SGR substring for warning: markers.
5144
d77de738 5145@vindex note GCC_COLORS @r{capability}
f33d7a88 5146@item note=
d77de738
ML
5147SGR substring for note: markers.
5148
d77de738 5149@vindex path GCC_COLORS @r{capability}
f33d7a88 5150@item path=
d77de738
ML
5151SGR substring for colorizing paths of control-flow events as printed
5152via @option{-fdiagnostics-path-format=}, such as the identifiers of
5153individual events and lines indicating interprocedural calls and returns.
5154
d77de738 5155@vindex range1 GCC_COLORS @r{capability}
f33d7a88 5156@item range1=
d77de738
ML
5157SGR substring for first additional range.
5158
d77de738 5159@vindex range2 GCC_COLORS @r{capability}
f33d7a88 5160@item range2=
d77de738
ML
5161SGR substring for second additional range.
5162
d77de738 5163@vindex locus GCC_COLORS @r{capability}
f33d7a88 5164@item locus=
d77de738
ML
5165SGR substring for location information, @samp{file:line} or
5166@samp{file:line:column} etc.
5167
d77de738 5168@vindex quote GCC_COLORS @r{capability}
f33d7a88 5169@item quote=
d77de738
ML
5170SGR substring for information printed within quotes.
5171
d77de738 5172@vindex fnname GCC_COLORS @r{capability}
f33d7a88 5173@item fnname=
d77de738
ML
5174SGR substring for names of C++ functions.
5175
d77de738 5176@vindex targs GCC_COLORS @r{capability}
f33d7a88 5177@item targs=
d77de738
ML
5178SGR substring for C++ function template parameter bindings.
5179
d77de738 5180@vindex fixit-insert GCC_COLORS @r{capability}
f33d7a88 5181@item fixit-insert=
d77de738
ML
5182SGR substring for fix-it hints suggesting text to
5183be inserted or replaced.
5184
d77de738 5185@vindex fixit-delete GCC_COLORS @r{capability}
f33d7a88 5186@item fixit-delete=
d77de738
ML
5187SGR substring for fix-it hints suggesting text to
5188be deleted.
5189
d77de738 5190@vindex diff-filename GCC_COLORS @r{capability}
f33d7a88 5191@item diff-filename=
d77de738
ML
5192SGR substring for filename headers within generated patches.
5193
d77de738 5194@vindex diff-hunk GCC_COLORS @r{capability}
f33d7a88 5195@item diff-hunk=
d77de738
ML
5196SGR substring for the starts of hunks within generated patches.
5197
d77de738 5198@vindex diff-delete GCC_COLORS @r{capability}
f33d7a88 5199@item diff-delete=
d77de738
ML
5200SGR substring for deleted lines within generated patches.
5201
d77de738 5202@vindex diff-insert GCC_COLORS @r{capability}
f33d7a88 5203@item diff-insert=
d77de738
ML
5204SGR substring for inserted lines within generated patches.
5205
d77de738 5206@vindex type-diff GCC_COLORS @r{capability}
f33d7a88 5207@item type-diff=
d77de738
ML
5208SGR substring for highlighting mismatching types within template
5209arguments in the C++ frontend.
5210@end table
5211
d77de738
ML
5212@opindex fdiagnostics-urls
5213@cindex urls
5214@vindex GCC_URLS @r{environment variable}
5215@vindex TERM_URLS @r{environment variable}
f33d7a88 5216@item -fdiagnostics-urls[=@var{WHEN}]
d77de738
ML
5217Use escape sequences to embed URLs in diagnostics. For example, when
5218@option{-fdiagnostics-show-option} emits text showing the command-line
5219option controlling a diagnostic, embed a URL for documentation of that
5220option.
5221
5222@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5223@samp{auto} makes GCC use URL escape sequences only when the standard error
5224is a terminal, and when not executing in an emacs shell or any graphical
5225terminal which is known to be incompatible with this feature, see below.
5226
5227The default depends on how the compiler has been configured.
5228It can be any of the above @var{WHEN} options.
5229
5230GCC can also be configured (via the
5231@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5232so that the default is affected by environment variables.
5233Under such a configuration, GCC defaults to using @samp{auto}
5234if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5235present and non-empty in the environment of the compiler, or @samp{never}
5236if neither are.
5237
5238However, even with @option{-fdiagnostics-urls=always} the behavior is
5239dependent on those environment variables:
5240If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5241diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5242If set to @samp{bel}, the default, URLs use BEL escape sequences.
5243Any other non-empty value enables the feature.
5244If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5245Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5246BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5247
5248At this time GCC tries to detect also a few terminals that are known to
5249not implement the URL feature, and have bugs or at least had bugs in
5250some versions that are still in use, where the URL escapes are likely
5251to misbehave, i.e. print garbage on the screen.
5252That list is currently xfce4-terminal, certain known to be buggy
5253gnome-terminal versions, the linux console, and mingw.
5254This check can be skipped with the @option{-fdiagnostics-urls=always}.
5255
d77de738
ML
5256@opindex fno-diagnostics-show-option
5257@opindex fdiagnostics-show-option
ddf6fe37 5258@item -fno-diagnostics-show-option
d77de738
ML
5259By default, each diagnostic emitted includes text indicating the
5260command-line option that directly controls the diagnostic (if such an
5261option is known to the diagnostic machinery). Specifying the
5262@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5263
d77de738
ML
5264@opindex fno-diagnostics-show-caret
5265@opindex fdiagnostics-show-caret
ddf6fe37 5266@item -fno-diagnostics-show-caret
d77de738
ML
5267By default, each diagnostic emitted includes the original source line
5268and a caret @samp{^} indicating the column. This option suppresses this
5269information. The source line is truncated to @var{n} characters, if
5270the @option{-fmessage-length=n} option is given. When the output is done
5271to the terminal, the width is limited to the width given by the
5272@env{COLUMNS} environment variable or, if not set, to the terminal width.
5273
d77de738
ML
5274@opindex fno-diagnostics-show-labels
5275@opindex fdiagnostics-show-labels
ddf6fe37 5276@item -fno-diagnostics-show-labels
d77de738
ML
5277By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5278diagnostics can label ranges of source code with pertinent information, such
5279as the types of expressions:
5280
5281@smallexample
5282 printf ("foo %s bar", long_i + long_j);
5283 ~^ ~~~~~~~~~~~~~~~
5284 | |
5285 char * long int
5286@end smallexample
5287
5288This option suppresses the printing of these labels (in the example above,
5289the vertical bars and the ``char *'' and ``long int'' text).
5290
d77de738
ML
5291@opindex fno-diagnostics-show-cwe
5292@opindex fdiagnostics-show-cwe
ddf6fe37 5293@item -fno-diagnostics-show-cwe
d77de738
ML
5294Diagnostic messages can optionally have an associated
5295@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5296GCC itself only provides such metadata for some of the @option{-fanalyzer}
5297diagnostics. GCC plugins may also provide diagnostics with such metadata.
5298By default, if this information is present, it will be printed with
5299the diagnostic. This option suppresses the printing of this metadata.
5300
d77de738
ML
5301@opindex fno-diagnostics-show-rules
5302@opindex fdiagnostics-show-rules
ddf6fe37 5303@item -fno-diagnostics-show-rules
d77de738
ML
5304Diagnostic messages can optionally have rules associated with them, such
5305as from a coding standard, or a specification.
5306GCC itself does not do this for any of its diagnostics, but plugins may do so.
5307By default, if this information is present, it will be printed with
5308the diagnostic. This option suppresses the printing of this metadata.
5309
d77de738
ML
5310@opindex fno-diagnostics-show-line-numbers
5311@opindex fdiagnostics-show-line-numbers
ddf6fe37 5312@item -fno-diagnostics-show-line-numbers
d77de738
ML
5313By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5314a left margin is printed, showing line numbers. This option suppresses this
5315left margin.
5316
d77de738 5317@opindex fdiagnostics-minimum-margin-width
ddf6fe37 5318@item -fdiagnostics-minimum-margin-width=@var{width}
d77de738
ML
5319This option controls the minimum width of the left margin printed by
5320@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5321
d77de738 5322@opindex fdiagnostics-parseable-fixits
ddf6fe37 5323@item -fdiagnostics-parseable-fixits
d77de738
ML
5324Emit fix-it hints in a machine-parseable format, suitable for consumption
5325by IDEs. For each fix-it, a line will be printed after the relevant
5326diagnostic, starting with the string ``fix-it:''. For example:
5327
5328@smallexample
5329fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5330@end smallexample
5331
5332The location is expressed as a half-open range, expressed as a count of
5333bytes, starting at byte 1 for the initial column. In the above example,
5334bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5335given string:
5336
5337@smallexample
533800000000011111111112222222222
533912345678901234567890123456789
5340 gtk_widget_showall (dlg);
5341 ^^^^^^^^^^^^^^^^^^
5342 gtk_widget_show_all
5343@end smallexample
5344
5345The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5346newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5347(e.g. vertical tab as ``\013'').
5348
5349An empty replacement string indicates that the given range is to be removed.
5350An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5351be inserted at the given position.
5352
d77de738 5353@opindex fdiagnostics-generate-patch
ddf6fe37 5354@item -fdiagnostics-generate-patch
d77de738
ML
5355Print fix-it hints to stderr in unified diff format, after any diagnostics
5356are printed. For example:
5357
5358@smallexample
5359--- test.c
5360+++ test.c
5361@@ -42,5 +42,5 @@
5362
5363 void show_cb(GtkDialog *dlg)
5364 @{
5365- gtk_widget_showall(dlg);
5366+ gtk_widget_show_all(dlg);
5367 @}
5368
5369@end smallexample
5370
5371The diff may or may not be colorized, following the same rules
5372as for diagnostics (see @option{-fdiagnostics-color}).
5373
d77de738 5374@opindex fdiagnostics-show-template-tree
ddf6fe37 5375@item -fdiagnostics-show-template-tree
d77de738
ML
5376
5377In the C++ frontend, when printing diagnostics showing mismatching
5378template types, such as:
5379
5380@smallexample
5381 could not convert 'std::map<int, std::vector<double> >()'
5382 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5383@end smallexample
5384
5385the @option{-fdiagnostics-show-template-tree} flag enables printing a
5386tree-like structure showing the common and differing parts of the types,
5387such as:
5388
5389@smallexample
5390 map<
5391 [...],
5392 vector<
5393 [double != float]>>
5394@end smallexample
5395
5396The parts that differ are highlighted with color (``double'' and
5397``float'' in this case).
5398
d77de738
ML
5399@opindex fno-elide-type
5400@opindex felide-type
ddf6fe37 5401@item -fno-elide-type
d77de738
ML
5402By default when the C++ frontend prints diagnostics showing mismatching
5403template types, common parts of the types are printed as ``[...]'' to
5404simplify the error message. For example:
5405
5406@smallexample
5407 could not convert 'std::map<int, std::vector<double> >()'
5408 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5409@end smallexample
5410
5411Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5412This flag also affects the output of the
5413@option{-fdiagnostics-show-template-tree} flag.
5414
d77de738 5415@opindex fdiagnostics-path-format
ddf6fe37 5416@item -fdiagnostics-path-format=@var{KIND}
d77de738
ML
5417Specify how to print paths of control-flow events for diagnostics that
5418have such a path associated with them.
5419
5420@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5421the default.
5422
5423@samp{none} means to not print diagnostic paths.
5424
5425@samp{separate-events} means to print a separate ``note'' diagnostic for
5426each event within the diagnostic. For example:
5427
5428@smallexample
5429test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5430test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5431test.c:27:3: note: (2) when 'i < count'
5432test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5433@end smallexample
5434
5435@samp{inline-events} means to print the events ``inline'' within the source
5436code. This view attempts to consolidate the events into runs of
5437sufficiently-close events, printing them as labelled ranges within the source.
5438
5439For example, the same events as above might be printed as:
5440
5441@smallexample
5442 'test': events 1-3
5443 |
5444 | 25 | list = PyList_New(0);
5445 | | ^~~~~~~~~~~~~
5446 | | |
5447 | | (1) when 'PyList_New' fails, returning NULL
5448 | 26 |
5449 | 27 | for (i = 0; i < count; i++) @{
5450 | | ~~~
5451 | | |
5452 | | (2) when 'i < count'
5453 | 28 | item = PyLong_FromLong(random());
5454 | 29 | PyList_Append(list, item);
5455 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5456 | | |
5457 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5458 |
5459@end smallexample
5460
5461Interprocedural control flow is shown by grouping the events by stack frame,
5462and using indentation to show how stack frames are nested, pushed, and popped.
5463
5464For example:
5465
5466@smallexample
5467 'test': events 1-2
5468 |
5469 | 133 | @{
5470 | | ^
5471 | | |
5472 | | (1) entering 'test'
5473 | 134 | boxed_int *obj = make_boxed_int (i);
5474 | | ~~~~~~~~~~~~~~~~~~
5475 | | |
5476 | | (2) calling 'make_boxed_int'
5477 |
5478 +--> 'make_boxed_int': events 3-4
5479 |
5480 | 120 | @{
5481 | | ^
5482 | | |
5483 | | (3) entering 'make_boxed_int'
5484 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5485 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5486 | | |
5487 | | (4) calling 'wrapped_malloc'
5488 |
5489 +--> 'wrapped_malloc': events 5-6
5490 |
5491 | 7 | @{
5492 | | ^
5493 | | |
5494 | | (5) entering 'wrapped_malloc'
5495 | 8 | return malloc (size);
5496 | | ~~~~~~~~~~~~~
5497 | | |
5498 | | (6) calling 'malloc'
5499 |
5500 <-------------+
5501 |
5502 'test': event 7
5503 |
5504 | 138 | free_boxed_int (obj);
5505 | | ^~~~~~~~~~~~~~~~~~~~
5506 | | |
5507 | | (7) calling 'free_boxed_int'
5508 |
5509(etc)
5510@end smallexample
5511
d77de738 5512@opindex fdiagnostics-show-path-depths
ddf6fe37 5513@item -fdiagnostics-show-path-depths
d77de738
ML
5514This option provides additional information when printing control-flow paths
5515associated with a diagnostic.
5516
5517If this is option is provided then the stack depth will be printed for
5518each run of events within @option{-fdiagnostics-path-format=inline-events}.
5519If provided with @option{-fdiagnostics-path-format=separate-events}, then
5520the stack depth and function declaration will be appended when printing
5521each event.
5522
5523This is intended for use by GCC developers and plugin developers when
5524debugging diagnostics that report interprocedural control flow.
5525
d77de738
ML
5526@opindex fno-show-column
5527@opindex fshow-column
ddf6fe37 5528@item -fno-show-column
d77de738
ML
5529Do not print column numbers in diagnostics. This may be necessary if
5530diagnostics are being scanned by a program that does not understand the
5531column numbers, such as @command{dejagnu}.
5532
d77de738 5533@opindex fdiagnostics-column-unit
ddf6fe37 5534@item -fdiagnostics-column-unit=@var{UNIT}
d77de738
ML
5535Select the units for the column number. This affects traditional diagnostics
5536(in the absence of @option{-fno-show-column}), as well as JSON format
5537diagnostics if requested.
5538
5539The default @var{UNIT}, @samp{display}, considers the number of display
5540columns occupied by each character. This may be larger than the number
5541of bytes required to encode the character, in the case of tab
5542characters, or it may be smaller, in the case of multibyte characters.
5543For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5544display column, and its UTF-8 encoding requires two bytes; the character
5545``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5546its UTF-8 encoding requires four bytes.
5547
5548Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5549count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5550
d77de738 5551@opindex fdiagnostics-column-origin
ddf6fe37 5552@item -fdiagnostics-column-origin=@var{ORIGIN}
d77de738
ML
5553Select the origin for column numbers, i.e. the column number assigned to the
5554first column. The default value of 1 corresponds to traditional GCC
5555behavior and to the GNU style guide. Some utilities may perform better with an
5556origin of 0; any non-negative value may be specified.
5557
d77de738 5558@opindex fdiagnostics-escape-format
ddf6fe37 5559@item -fdiagnostics-escape-format=@var{FORMAT}
d77de738
ML
5560When GCC prints pertinent source lines for a diagnostic it normally attempts
5561to print the source bytes directly. However, some diagnostics relate to encoding
5562issues in the source file, such as malformed UTF-8, or issues with Unicode
5563normalization. These diagnostics are flagged so that GCC will escape bytes
5564that are not printable ASCII when printing their pertinent source lines.
5565
5566This option controls how such bytes should be escaped.
5567
5568The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5569are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5570correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5571displayed as hexadecimal in the form @samp{<XX>}.
5572
5573For example, a source line containing the string @samp{before} followed by the
5574Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
55750xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5576the string @samp{after} will be printed for such a diagnostic as:
5577
5578@smallexample
5579 before<U+03C0><BF>after
5580@end smallexample
5581
5582Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5583in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5584Unicode characters. For the example above, the following will be printed:
5585
5586@smallexample
5587 before<CF><80><BF>after
5588@end smallexample
5589
d77de738 5590@opindex fdiagnostics-format
ddf6fe37 5591@item -fdiagnostics-format=@var{FORMAT}
d77de738
ML
5592Select a different format for printing diagnostics.
5593@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5594@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5595
5596The default is @samp{text}.
5597
5598The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5599diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5600named @file{@var{source}.sarif}, respectively.
5601
5602The @samp{json} format is a synonym for @samp{json-stderr}.
5603The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5604where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5605whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5606
5607The emitted JSON consists of a top-level JSON array containing JSON objects
5608representing the diagnostics. The JSON is emitted as one line, without
5609formatting; the examples below have been formatted for clarity.
5610
5611Diagnostics can have child diagnostics. For example, this error and note:
5612
5613@smallexample
5614misleading-indentation.c:15:3: warning: this 'if' clause does not
5615 guard... [-Wmisleading-indentation]
5616 15 | if (flag)
5617 | ^~
5618misleading-indentation.c:17:5: note: ...this statement, but the latter
5619 is misleadingly indented as if it were guarded by the 'if'
5620 17 | y = 2;
5621 | ^
5622@end smallexample
5623
5624@noindent
5625might be printed in JSON form (after formatting) like this:
5626
5627@smallexample
5628[
5629 @{
5630 "kind": "warning",
5631 "locations": [
5632 @{
5633 "caret": @{
5634 "display-column": 3,
5635 "byte-column": 3,
5636 "column": 3,
5637 "file": "misleading-indentation.c",
5638 "line": 15
5639 @},
5640 "finish": @{
5641 "display-column": 4,
5642 "byte-column": 4,
5643 "column": 4,
5644 "file": "misleading-indentation.c",
5645 "line": 15
5646 @}
5647 @}
5648 ],
5649 "message": "this \u2018if\u2019 clause does not guard...",
5650 "option": "-Wmisleading-indentation",
5651 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5652 "children": [
5653 @{
5654 "kind": "note",
5655 "locations": [
5656 @{
5657 "caret": @{
5658 "display-column": 5,
5659 "byte-column": 5,
5660 "column": 5,
5661 "file": "misleading-indentation.c",
5662 "line": 17
5663 @}
5664 @}
5665 ],
5666 "escape-source": false,
5667 "message": "...this statement, but the latter is @dots{}"
5668 @}
5669 ]
5670 "escape-source": false,
5671 "column-origin": 1,
5672 @}
5673]
5674@end smallexample
5675
5676@noindent
5677where the @code{note} is a child of the @code{warning}.
5678
5679A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5680an @code{option} key describing the command-line option controlling the
5681warning.
5682
5683A diagnostic can contain zero or more locations. Each location has an
5684optional @code{label} string and up to three positions within it: a
5685@code{caret} position and optional @code{start} and @code{finish} positions.
5686A position is described by a @code{file} name, a @code{line} number, and
5687three numbers indicating a column position:
5688@itemize @bullet
5689
5690@item
5691@code{display-column} counts display columns, accounting for tabs and
5692multibyte characters.
5693
5694@item
5695@code{byte-column} counts raw bytes.
5696
5697@item
5698@code{column} is equal to one of
5699the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5700option.
5701
5702@end itemize
5703All three columns are relative to the origin specified by
5704@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5705be set, for instance, to 0 for compatibility with other utilities that
5706number columns from 0. The column origin is recorded in the JSON output in
5707the @code{column-origin} tag. In the remaining examples below, the extra
5708column number outputs have been omitted for brevity.
5709
5710For example, this error:
5711
5712@smallexample
5713bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5714 'struct s'@} and 'T' @{aka 'struct t'@})
5715 64 | return callee_4a () + callee_4b ();
5716 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5717 | | |
5718 | | T @{aka struct t@}
5719 | S @{aka struct s@}
5720@end smallexample
5721
5722@noindent
5723has three locations. Its primary location is at the ``+'' token at column
572423. It has two secondary locations, describing the left and right-hand sides
5725of the expression, which have labels. It might be printed in JSON form as:
5726
5727@smallexample
5728 @{
5729 "children": [],
5730 "kind": "error",
5731 "locations": [
5732 @{
5733 "caret": @{
5734 "column": 23, "file": "bad-binary-ops.c", "line": 64
5735 @}
5736 @},
5737 @{
5738 "caret": @{
5739 "column": 10, "file": "bad-binary-ops.c", "line": 64
5740 @},
5741 "finish": @{
5742 "column": 21, "file": "bad-binary-ops.c", "line": 64
5743 @},
5744 "label": "S @{aka struct s@}"
5745 @},
5746 @{
5747 "caret": @{
5748 "column": 25, "file": "bad-binary-ops.c", "line": 64
5749 @},
5750 "finish": @{
5751 "column": 36, "file": "bad-binary-ops.c", "line": 64
5752 @},
5753 "label": "T @{aka struct t@}"
5754 @}
5755 ],
5756 "escape-source": false,
5757 "message": "invalid operands to binary + @dots{}"
5758 @}
5759@end smallexample
5760
5761If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5762consisting of half-open intervals, similar to the output of
5763@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5764with a replacement fix-it hint:
5765
5766@smallexample
5767demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5768 mean 'color'?
5769 8 | return ptr->colour;
5770 | ^~~~~~
5771 | color
5772@end smallexample
5773
5774@noindent
5775might be printed in JSON form as:
5776
5777@smallexample
5778 @{
5779 "children": [],
5780 "fixits": [
5781 @{
5782 "next": @{
5783 "column": 21,
5784 "file": "demo.c",
5785 "line": 8
5786 @},
5787 "start": @{
5788 "column": 15,
5789 "file": "demo.c",
5790 "line": 8
5791 @},
5792 "string": "color"
5793 @}
5794 ],
5795 "kind": "error",
5796 "locations": [
5797 @{
5798 "caret": @{
5799 "column": 15,
5800 "file": "demo.c",
5801 "line": 8
5802 @},
5803 "finish": @{
5804 "column": 20,
5805 "file": "demo.c",
5806 "line": 8
5807 @}
5808 @}
5809 ],
5810 "escape-source": false,
5811 "message": "\u2018struct s\u2019 has no member named @dots{}"
5812 @}
5813@end smallexample
5814
5815@noindent
5816where the fix-it hint suggests replacing the text from @code{start} up
5817to but not including @code{next} with @code{string}'s value. Deletions
5818are expressed via an empty value for @code{string}, insertions by
5819having @code{start} equal @code{next}.
5820
5821If the diagnostic has a path of control-flow events associated with it,
5822it has a @code{path} array of objects representing the events. Each
5823event object has a @code{description} string, a @code{location} object,
5824along with a @code{function} string and a @code{depth} number for
5825representing interprocedural paths. The @code{function} represents the
5826current function at that event, and the @code{depth} represents the
5827stack depth relative to some baseline: the higher, the more frames are
5828within the stack.
5829
5830For example, the intraprocedural example shown for
5831@option{-fdiagnostics-path-format=} might have this JSON for its path:
5832
5833@smallexample
5834 "path": [
5835 @{
5836 "depth": 0,
5837 "description": "when 'PyList_New' fails, returning NULL",
5838 "function": "test",
5839 "location": @{
5840 "column": 10,
5841 "file": "test.c",
5842 "line": 25
5843 @}
5844 @},
5845 @{
5846 "depth": 0,
5847 "description": "when 'i < count'",
5848 "function": "test",
5849 "location": @{
5850 "column": 3,
5851 "file": "test.c",
5852 "line": 27
5853 @}
5854 @},
5855 @{
5856 "depth": 0,
5857 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5858 "function": "test",
5859 "location": @{
5860 "column": 5,
5861 "file": "test.c",
5862 "line": 29
5863 @}
5864 @}
5865 ]
5866@end smallexample
5867
5868Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5869non-ASCII bytes should be escaped when printing the pertinent lines of
5870source code (@code{true} for diagnostics involving source encoding issues).
5871
5872@end table
5873
5874@node Warning Options
5875@section Options to Request or Suppress Warnings
5876@cindex options to control warnings
5877@cindex warning messages
5878@cindex messages, warning
5879@cindex suppressing warnings
5880
5881Warnings are diagnostic messages that report constructions that
5882are not inherently erroneous but that are risky or suggest there
5883may have been an error.
5884
5885The following language-independent options do not enable specific
5886warnings but control the kinds of diagnostics produced by GCC@.
5887
5888@table @gcctabopt
5889@cindex syntax checking
d77de738 5890@opindex fsyntax-only
ddf6fe37 5891@item -fsyntax-only
d77de738
ML
5892Check the code for syntax errors, but don't do anything beyond that.
5893
d77de738 5894@opindex fmax-errors
ddf6fe37 5895@item -fmax-errors=@var{n}
d77de738
ML
5896Limits the maximum number of error messages to @var{n}, at which point
5897GCC bails out rather than attempting to continue processing the source
5898code. If @var{n} is 0 (the default), there is no limit on the number
5899of error messages produced. If @option{-Wfatal-errors} is also
5900specified, then @option{-Wfatal-errors} takes precedence over this
5901option.
5902
d77de738 5903@opindex w
ddf6fe37 5904@item -w
d77de738
ML
5905Inhibit all warning messages.
5906
d77de738
ML
5907@opindex Werror
5908@opindex Wno-error
ddf6fe37 5909@item -Werror
d77de738
ML
5910Make all warnings into errors.
5911
d77de738
ML
5912@opindex Werror=
5913@opindex Wno-error=
ddf6fe37 5914@item -Werror=
d77de738
ML
5915Make the specified warning into an error. The specifier for a warning
5916is appended; for example @option{-Werror=switch} turns the warnings
5917controlled by @option{-Wswitch} into errors. This switch takes a
5918negative form, to be used to negate @option{-Werror} for specific
5919warnings; for example @option{-Wno-error=switch} makes
5920@option{-Wswitch} warnings not be errors, even when @option{-Werror}
5921is in effect.
5922
5923The warning message for each controllable warning includes the
5924option that controls the warning. That option can then be used with
5925@option{-Werror=} and @option{-Wno-error=} as described above.
5926(Printing of the option in the warning message can be disabled using the
5927@option{-fno-diagnostics-show-option} flag.)
5928
5929Note that specifying @option{-Werror=}@var{foo} automatically implies
5930@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5931imply anything.
5932
d77de738
ML
5933@opindex Wfatal-errors
5934@opindex Wno-fatal-errors
ddf6fe37 5935@item -Wfatal-errors
d77de738
ML
5936This option causes the compiler to abort compilation on the first error
5937occurred rather than trying to keep going and printing further error
5938messages.
5939
5940@end table
5941
5942You can request many specific warnings with options beginning with
5943@samp{-W}, for example @option{-Wimplicit} to request warnings on
5944implicit declarations. Each of these specific warning options also
5945has a negative form beginning @samp{-Wno-} to turn off warnings; for
5946example, @option{-Wno-implicit}. This manual lists only one of the
5947two forms, whichever is not the default. For further
5948language-specific options also refer to @ref{C++ Dialect Options} and
5949@ref{Objective-C and Objective-C++ Dialect Options}.
5950Additional warnings can be produced by enabling the static analyzer;
5951@xref{Static Analyzer Options}.
5952
5953Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5954options, such as @option{-Wunused}, which may turn on further options,
5955such as @option{-Wunused-value}. The combined effect of positive and
5956negative forms is that more specific options have priority over less
5957specific ones, independently of their position in the command-line. For
5958options of the same specificity, the last one takes effect. Options
5959enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5960as if they appeared at the end of the command-line.
5961
5962When an unrecognized warning option is requested (e.g.,
5963@option{-Wunknown-warning}), GCC emits a diagnostic stating
5964that the option is not recognized. However, if the @option{-Wno-} form
5965is used, the behavior is slightly different: no diagnostic is
5966produced for @option{-Wno-unknown-warning} unless other diagnostics
5967are being produced. This allows the use of new @option{-Wno-} options
5968with old compilers, but if something goes wrong, the compiler
5969warns that an unrecognized option is present.
5970
5971The effectiveness of some warnings depends on optimizations also being
5972enabled. For example @option{-Wsuggest-final-types} is more effective
5973with link-time optimization and some instances of other warnings may
5974not be issued at all unless optimization is enabled. While optimization
5975in general improves the efficacy of control and data flow sensitive
5976warnings, in some cases it may also cause false positives.
5977
5978@table @gcctabopt
d77de738
ML
5979@opindex pedantic
5980@opindex Wpedantic
5981@opindex Wno-pedantic
ddf6fe37
AA
5982@item -Wpedantic
5983@itemx -pedantic
d77de738
ML
5984Issue all the warnings demanded by strict ISO C and ISO C++;
5985reject all programs that use forbidden extensions, and some other
5986programs that do not follow ISO C and ISO C++. For ISO C, follows the
5987version of the ISO C standard specified by any @option{-std} option used.
5988
5989Valid ISO C and ISO C++ programs should compile properly with or without
5990this option (though a rare few require @option{-ansi} or a
5991@option{-std} option specifying the required version of ISO C)@. However,
5992without this option, certain GNU extensions and traditional C and C++
5993features are supported as well. With this option, they are rejected.
5994
5995@option{-Wpedantic} does not cause warning messages for use of the
5996alternate keywords whose names begin and end with @samp{__}. This alternate
5997format can also be used to disable warnings for non-ISO @samp{__intN} types,
5998i.e. @samp{__intN__}.
5999Pedantic warnings are also disabled in the expression that follows
6000@code{__extension__}. However, only system header files should use
6001these escape routes; application programs should avoid them.
6002@xref{Alternate Keywords}.
6003
6004Some users try to use @option{-Wpedantic} to check programs for strict ISO
6005C conformance. They soon find that it does not do quite what they want:
6006it finds some non-ISO practices, but not all---only those for which
6007ISO C @emph{requires} a diagnostic, and some others for which
6008diagnostics have been added.
6009
6010A feature to report any failure to conform to ISO C might be useful in
6011some instances, but would require considerable additional work and would
6012be quite different from @option{-Wpedantic}. We don't have plans to
6013support such a feature in the near future.
6014
6015Where the standard specified with @option{-std} represents a GNU
6016extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
6017corresponding @dfn{base standard}, the version of ISO C on which the GNU
6018extended dialect is based. Warnings from @option{-Wpedantic} are given
6019where they are required by the base standard. (It does not make sense
6020for such warnings to be given only for features not in the specified GNU
6021C dialect, since by definition the GNU dialects of C include all
6022features the compiler supports with the given option, and there would be
6023nothing to warn about.)
6024
d77de738 6025@opindex pedantic-errors
ddf6fe37 6026@item -pedantic-errors
d77de738
ML
6027Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6028requires a diagnostic, in some cases where there is undefined behavior
6029at compile-time and in some other cases that do not prevent compilation
6030of programs that are valid according to the standard. This is not
6031equivalent to @option{-Werror=pedantic}, since there are errors enabled
6032by this option and not enabled by the latter and vice versa.
6033
d77de738
ML
6034@opindex Wall
6035@opindex Wno-all
ddf6fe37 6036@item -Wall
d77de738
ML
6037This enables all the warnings about constructions that some users
6038consider questionable, and that are easy to avoid (or modify to
6039prevent the warning), even in conjunction with macros. This also
6040enables some language-specific warnings described in @ref{C++ Dialect
6041Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6042
6043@option{-Wall} turns on the following warning flags:
6044
6045@gccoptlist{-Waddress @gol
6046-Warray-bounds=1 @r{(only with} @option{-O2}@r{)} @gol
6047-Warray-compare @gol
6048-Warray-parameter=2 @r{(C and Objective-C only)} @gol
6049-Wbool-compare @gol
6050-Wbool-operation @gol
6051-Wc++11-compat -Wc++14-compat @gol
6052-Wcatch-value @r{(C++ and Objective-C++ only)} @gol
6053-Wchar-subscripts @gol
6054-Wcomment @gol
6055-Wdangling-pointer=2 @gol
6056-Wduplicate-decl-specifier @r{(C and Objective-C only)} @gol
6057-Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol
6058-Wenum-int-mismatch @r{(C and Objective-C only)} @gol
6059-Wformat @gol
6060-Wformat-overflow @gol
6061-Wformat-truncation @gol
6062-Wint-in-bool-context @gol
6063-Wimplicit @r{(C and Objective-C only)} @gol
6064-Wimplicit-int @r{(C and Objective-C only)} @gol
6065-Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
6066-Winit-self @r{(only for C++)} @gol
6067-Wlogical-not-parentheses @gol
6068-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
6069-Wmaybe-uninitialized @gol
6070-Wmemset-elt-size @gol
6071-Wmemset-transposed-args @gol
6072-Wmisleading-indentation @r{(only for C/C++)} @gol
6073-Wmismatched-dealloc @gol
6074-Wmismatched-new-delete @r{(only for C/C++)} @gol
6075-Wmissing-attributes @gol
6076-Wmissing-braces @r{(only for C/ObjC)} @gol
6077-Wmultistatement-macros @gol
6078-Wnarrowing @r{(only for C++)} @gol
6079-Wnonnull @gol
6080-Wnonnull-compare @gol
6081-Wopenmp-simd @gol
6082-Wparentheses @gol
6083-Wpessimizing-move @r{(only for C++)} @gol
6084-Wpointer-sign @gol
6085-Wrange-loop-construct @r{(only for C++)} @gol
6086-Wreorder @gol
6087-Wrestrict @gol
6088-Wreturn-type @gol
6089-Wself-move @r{(only for C++)} @gol
6090-Wsequence-point @gol
6091-Wsign-compare @r{(only in C++)} @gol
6092-Wsizeof-array-div @gol
6093-Wsizeof-pointer-div @gol
6094-Wsizeof-pointer-memaccess @gol
6095-Wstrict-aliasing @gol
6096-Wstrict-overflow=1 @gol
6097-Wswitch @gol
6098-Wtautological-compare @gol
6099-Wtrigraphs @gol
6100-Wuninitialized @gol
6101-Wunknown-pragmas @gol
6102-Wunused-function @gol
6103-Wunused-label @gol
6104-Wunused-value @gol
6105-Wunused-variable @gol
9dcfee4e 6106-Wuse-after-free=2 @gol
d77de738
ML
6107-Wvla-parameter @r{(C and Objective-C only)} @gol
6108-Wvolatile-register-var @gol
6109-Wzero-length-bounds}
6110
6111Note that some warning flags are not implied by @option{-Wall}. Some of
6112them warn about constructions that users generally do not consider
6113questionable, but which occasionally you might wish to check for;
6114others warn about constructions that are necessary or hard to avoid in
6115some cases, and there is no simple way to modify the code to suppress
6116the warning. Some of them are enabled by @option{-Wextra} but many of
6117them must be enabled individually.
6118
d77de738
ML
6119@opindex W
6120@opindex Wextra
6121@opindex Wno-extra
ddf6fe37 6122@item -Wextra
d77de738
ML
6123This enables some extra warning flags that are not enabled by
6124@option{-Wall}. (This option used to be called @option{-W}. The older
6125name is still supported, but the newer name is more descriptive.)
6126
6127@gccoptlist{-Wclobbered @gol
6128-Wcast-function-type @gol
6129-Wdeprecated-copy @r{(C++ only)} @gol
6130-Wempty-body @gol
6131-Wenum-conversion @r{(C only)} @gol
6132-Wignored-qualifiers @gol
6133-Wimplicit-fallthrough=3 @gol
6134-Wmissing-field-initializers @gol
6135-Wmissing-parameter-type @r{(C only)} @gol
6136-Wold-style-declaration @r{(C only)} @gol
6137-Woverride-init @gol
6138-Wsign-compare @r{(C only)} @gol
6139-Wstring-compare @gol
6140-Wredundant-move @r{(only for C++)} @gol
6141-Wtype-limits @gol
6142-Wuninitialized @gol
6143-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} @gol
6144-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol
6145-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6146
6147
6148The option @option{-Wextra} also prints warning messages for the
6149following cases:
6150
6151@itemize @bullet
6152
6153@item
6154A pointer is compared against integer zero with @code{<}, @code{<=},
6155@code{>}, or @code{>=}.
6156
6157@item
6158(C++ only) An enumerator and a non-enumerator both appear in a
6159conditional expression.
6160
6161@item
6162(C++ only) Ambiguous virtual bases.
6163
6164@item
6165(C++ only) Subscripting an array that has been declared @code{register}.
6166
6167@item
6168(C++ only) Taking the address of a variable that has been declared
6169@code{register}.
6170
6171@item
6172(C++ only) A base class is not initialized in the copy constructor
6173of a derived class.
6174
6175@end itemize
6176
d77de738
ML
6177@opindex Wabi
6178@opindex Wno-abi
ddf6fe37 6179@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
6180
6181Warn about code affected by ABI changes. This includes code that may
6182not be compatible with the vendor-neutral C++ ABI as well as the psABI
6183for the particular target.
6184
6185Since G++ now defaults to updating the ABI with each major release,
6186normally @option{-Wabi} warns only about C++ ABI compatibility
6187problems if there is a check added later in a release series for an
6188ABI issue discovered since the initial release. @option{-Wabi} warns
6189about more things if an older ABI version is selected (with
6190@option{-fabi-version=@var{n}}).
6191
6192@option{-Wabi} can also be used with an explicit version number to
6193warn about C++ ABI compatibility with a particular @option{-fabi-version}
6194level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6195@option{-fabi-version=2}.
6196
6197If an explicit version number is provided and
6198@option{-fabi-compat-version} is not specified, the version number
6199from this option is used for compatibility aliases. If no explicit
6200version number is provided with this option, but
6201@option{-fabi-compat-version} is specified, that version number is
6202used for C++ ABI warnings.
6203
6204Although an effort has been made to warn about
6205all such cases, there are probably some cases that are not warned about,
6206even though G++ is generating incompatible code. There may also be
6207cases where warnings are emitted even though the code that is generated
6208is compatible.
6209
6210You should rewrite your code to avoid these warnings if you are
6211concerned about the fact that code generated by G++ may not be binary
6212compatible with code generated by other compilers.
6213
6214Known incompatibilities in @option{-fabi-version=2} (which was the
6215default from GCC 3.4 to 4.9) include:
6216
6217@itemize @bullet
6218
6219@item
6220A template with a non-type template parameter of reference type was
6221mangled incorrectly:
6222@smallexample
6223extern int N;
6224template <int &> struct S @{@};
6225void n (S<N>) @{2@}
6226@end smallexample
6227
6228This was fixed in @option{-fabi-version=3}.
6229
6230@item
6231SIMD vector types declared using @code{__attribute ((vector_size))} were
6232mangled in a non-standard way that does not allow for overloading of
6233functions taking vectors of different sizes.
6234
6235The mangling was changed in @option{-fabi-version=4}.
6236
6237@item
6238@code{__attribute ((const))} and @code{noreturn} were mangled as type
6239qualifiers, and @code{decltype} of a plain declaration was folded away.
6240
6241These mangling issues were fixed in @option{-fabi-version=5}.
6242
6243@item
6244Scoped enumerators passed as arguments to a variadic function are
6245promoted like unscoped enumerators, causing @code{va_arg} to complain.
6246On most targets this does not actually affect the parameter passing
6247ABI, as there is no way to pass an argument smaller than @code{int}.
6248
6249Also, the ABI changed the mangling of template argument packs,
6250@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6251a class scope function used as a template argument.
6252
6253These issues were corrected in @option{-fabi-version=6}.
6254
6255@item
6256Lambdas in default argument scope were mangled incorrectly, and the
6257ABI changed the mangling of @code{nullptr_t}.
6258
6259These issues were corrected in @option{-fabi-version=7}.
6260
6261@item
6262When mangling a function type with function-cv-qualifiers, the
6263un-qualified function type was incorrectly treated as a substitution
6264candidate.
6265
6266This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6267
6268@item
6269@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6270unaligned accesses. Note that this did not affect the ABI of a
6271function with a @code{nullptr_t} parameter, as parameters have a
6272minimum alignment.
6273
6274This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6275
6276@item
6277Target-specific attributes that affect the identity of a type, such as
6278ia32 calling conventions on a function type (stdcall, regparm, etc.),
6279did not affect the mangled name, leading to name collisions when
6280function pointers were used as template arguments.
6281
6282This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6283
6284@end itemize
6285
6286This option also enables warnings about psABI-related changes.
6287The known psABI changes at this point include:
6288
6289@itemize @bullet
6290
6291@item
6292For SysV/x86-64, unions with @code{long double} members are
6293passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6294the case. For example:
6295
6296@smallexample
6297union U @{
6298 long double ld;
6299 int i;
6300@};
6301@end smallexample
6302
6303@noindent
6304@code{union U} is now always passed in memory.
6305
6306@end itemize
6307
e2f939d3
JM
6308@item -Wno-changes-meaning @r{(C++ and Objective-C++ only)}
6309C++ requires that unqualified uses of a name within a class have the
6310same meaning in the complete scope of the class, so declaring the name
6311after using it is ill-formed:
6312@smallexample
6313struct A;
6314struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning
6315struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning
6316@end smallexample
6317By default, the B1 case is only a warning because the two declarations
6318have the same type, while the B2 case is an error. Both diagnostics
6319can be disabled with @option{-Wno-changes-meaning}. Alternately, the
6320error case can be reduced to a warning with
6321@option{-Wno-error=changes-meaning} or @option{-fpermissive}.
6322
6323Both diagnostics are also suppressed by @option{-fms-extensions}.
6324
d77de738
ML
6325@opindex Wchar-subscripts
6326@opindex Wno-char-subscripts
ddf6fe37 6327@item -Wchar-subscripts
d77de738
ML
6328Warn if an array subscript has type @code{char}. This is a common cause
6329of error, as programmers often forget that this type is signed on some
6330machines.
6331This warning is enabled by @option{-Wall}.
6332
d77de738
ML
6333@opindex Wno-coverage-mismatch
6334@opindex Wcoverage-mismatch
ddf6fe37 6335@item -Wno-coverage-mismatch
d77de738
ML
6336Warn if feedback profiles do not match when using the
6337@option{-fprofile-use} option.
6338If a source file is changed between compiling with @option{-fprofile-generate}
6339and with @option{-fprofile-use}, the files with the profile feedback can fail
6340to match the source file and GCC cannot use the profile feedback
6341information. By default, this warning is enabled and is treated as an
6342error. @option{-Wno-coverage-mismatch} can be used to disable the
6343warning or @option{-Wno-error=coverage-mismatch} can be used to
6344disable the error. Disabling the error for this warning can result in
6345poorly optimized code and is useful only in the
6346case of very minor changes such as bug fixes to an existing code-base.
6347Completely disabling the warning is not recommended.
6348
d77de738
ML
6349@opindex Wno-coverage-invalid-line-number
6350@opindex Wcoverage-invalid-line-number
ddf6fe37 6351@item -Wno-coverage-invalid-line-number
d77de738
ML
6352Warn in case a function ends earlier than it begins due
6353to an invalid linenum macros. The warning is emitted only
6354with @option{--coverage} enabled.
6355
6356By default, this warning is enabled and is treated as an
6357error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6358warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6359disable the error.
6360
d77de738
ML
6361@opindex Wno-cpp
6362@opindex Wcpp
ddf6fe37 6363@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
d77de738
ML
6364Suppress warning messages emitted by @code{#warning} directives.
6365
d77de738
ML
6366@opindex Wdouble-promotion
6367@opindex Wno-double-promotion
ddf6fe37 6368@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6369Give a warning when a value of type @code{float} is implicitly
6370promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6371floating-point unit implement @code{float} in hardware, but emulate
6372@code{double} in software. On such a machine, doing computations
6373using @code{double} values is much more expensive because of the
6374overhead required for software emulation.
6375
6376It is easy to accidentally do computations with @code{double} because
6377floating-point literals are implicitly of type @code{double}. For
6378example, in:
6379@smallexample
6380@group
6381float area(float radius)
6382@{
6383 return 3.14159 * radius * radius;
6384@}
6385@end group
6386@end smallexample
6387the compiler performs the entire computation with @code{double}
6388because the floating-point literal is a @code{double}.
6389
d77de738
ML
6390@opindex Wduplicate-decl-specifier
6391@opindex Wno-duplicate-decl-specifier
ddf6fe37 6392@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
d77de738
ML
6393Warn if a declaration has duplicate @code{const}, @code{volatile},
6394@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6395@option{-Wall}.
6396
d77de738
ML
6397@opindex Wformat
6398@opindex Wno-format
6399@opindex ffreestanding
6400@opindex fno-builtin
6401@opindex Wformat=
ddf6fe37
AA
6402@item -Wformat
6403@itemx -Wformat=@var{n}
d77de738
ML
6404Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6405the arguments supplied have types appropriate to the format string
6406specified, and that the conversions specified in the format string make
6407sense. This includes standard functions, and others specified by format
6408attributes (@pxref{Function Attributes}), in the @code{printf},
6409@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6410not in the C standard) families (or other target-specific families).
6411Which functions are checked without format attributes having been
6412specified depends on the standard version selected, and such checks of
6413functions without the attribute specified are disabled by
6414@option{-ffreestanding} or @option{-fno-builtin}.
6415
6416The formats are checked against the format features supported by GNU
6417libc version 2.2. These include all ISO C90 and C99 features, as well
6418as features from the Single Unix Specification and some BSD and GNU
6419extensions. Other library implementations may not support all these
6420features; GCC does not support warning about features that go beyond a
6421particular library's limitations. However, if @option{-Wpedantic} is used
6422with @option{-Wformat}, warnings are given about format features not
6423in the selected standard version (but not for @code{strfmon} formats,
6424since those are not in any version of the C standard). @xref{C Dialect
6425Options,,Options Controlling C Dialect}.
6426
6427@table @gcctabopt
d77de738
ML
6428@opindex Wformat
6429@opindex Wformat=1
ddf6fe37
AA
6430@item -Wformat=1
6431@itemx -Wformat
d77de738
ML
6432Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6433@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6434@option{-Wformat} also checks for null format arguments for several
6435functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6436aspects of this level of format checking can be disabled by the
6437options: @option{-Wno-format-contains-nul},
6438@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6439@option{-Wformat} is enabled by @option{-Wall}.
6440
d77de738 6441@opindex Wformat=2
ddf6fe37 6442@item -Wformat=2
d77de738
ML
6443Enable @option{-Wformat} plus additional format checks. Currently
6444equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6445-Wformat-y2k}.
6446@end table
6447
d77de738
ML
6448@opindex Wno-format-contains-nul
6449@opindex Wformat-contains-nul
ddf6fe37 6450@item -Wno-format-contains-nul
d77de738
ML
6451If @option{-Wformat} is specified, do not warn about format strings that
6452contain NUL bytes.
6453
d77de738
ML
6454@opindex Wno-format-extra-args
6455@opindex Wformat-extra-args
ddf6fe37 6456@item -Wno-format-extra-args
d77de738
ML
6457If @option{-Wformat} is specified, do not warn about excess arguments to a
6458@code{printf} or @code{scanf} format function. The C standard specifies
6459that such arguments are ignored.
6460
6461Where the unused arguments lie between used arguments that are
6462specified with @samp{$} operand number specifications, normally
6463warnings are still given, since the implementation could not know what
6464type to pass to @code{va_arg} to skip the unused arguments. However,
6465in the case of @code{scanf} formats, this option suppresses the
6466warning if the unused arguments are all pointers, since the Single
6467Unix Specification says that such unused arguments are allowed.
6468
d77de738
ML
6469@opindex Wformat-overflow
6470@opindex Wno-format-overflow
ddf6fe37
AA
6471@item -Wformat-overflow
6472@itemx -Wformat-overflow=@var{level}
d77de738
ML
6473Warn about calls to formatted input/output functions such as @code{sprintf}
6474and @code{vsprintf} that might overflow the destination buffer. When the
6475exact number of bytes written by a format directive cannot be determined
6476at compile-time it is estimated based on heuristics that depend on the
6477@var{level} argument and on optimization. While enabling optimization
6478will in most cases improve the accuracy of the warning, it may also
6479result in false positives.
6480
6481@table @gcctabopt
d77de738
ML
6482@opindex Wformat-overflow
6483@opindex Wno-format-overflow
ddf6fe37
AA
6484@item -Wformat-overflow
6485@itemx -Wformat-overflow=1
d77de738
ML
6486Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6487employs a conservative approach that warns only about calls that most
6488likely overflow the buffer. At this level, numeric arguments to format
6489directives with unknown values are assumed to have the value of one, and
6490strings of unknown length to be empty. Numeric arguments that are known
6491to be bounded to a subrange of their type, or string arguments whose output
6492is bounded either by their directive's precision or by a finite set of
6493string literals, are assumed to take on the value within the range that
6494results in the most bytes on output. For example, the call to @code{sprintf}
6495below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6496the terminating NUL character (@code{'\0'}) appended by the function
6497to the destination buffer will be written past its end. Increasing
6498the size of the buffer by a single byte is sufficient to avoid the
6499warning, though it may not be sufficient to avoid the overflow.
6500
6501@smallexample
6502void f (int a, int b)
6503@{
6504 char buf [13];
6505 sprintf (buf, "a = %i, b = %i\n", a, b);
6506@}
6507@end smallexample
6508
6509@item -Wformat-overflow=2
6510Level @var{2} warns also about calls that might overflow the destination
6511buffer given an argument of sufficient length or magnitude. At level
6512@var{2}, unknown numeric arguments are assumed to have the minimum
6513representable value for signed types with a precision greater than 1, and
6514the maximum representable value otherwise. Unknown string arguments whose
6515length cannot be assumed to be bounded either by the directive's precision,
6516or by a finite set of string literals they may evaluate to, or the character
6517array they may point to, are assumed to be 1 character long.
6518
6519At level @var{2}, the call in the example above is again diagnosed, but
6520this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6521@code{%i} directive will write some of its digits beyond the end of
6522the destination buffer. To make the call safe regardless of the values
6523of the two variables, the size of the destination buffer must be increased
6524to at least 34 bytes. GCC includes the minimum size of the buffer in
6525an informational note following the warning.
6526
6527An alternative to increasing the size of the destination buffer is to
6528constrain the range of formatted values. The maximum length of string
6529arguments can be bounded by specifying the precision in the format
6530directive. When numeric arguments of format directives can be assumed
6531to be bounded by less than the precision of their type, choosing
6532an appropriate length modifier to the format specifier will reduce
6533the required buffer size. For example, if @var{a} and @var{b} in the
6534example above can be assumed to be within the precision of
6535the @code{short int} type then using either the @code{%hi} format
6536directive or casting the argument to @code{short} reduces the maximum
6537required size of the buffer to 24 bytes.
6538
6539@smallexample
6540void f (int a, int b)
6541@{
6542 char buf [23];
6543 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6544@}
6545@end smallexample
6546@end table
6547
d77de738
ML
6548@opindex Wno-format-zero-length
6549@opindex Wformat-zero-length
ddf6fe37 6550@item -Wno-format-zero-length
d77de738
ML
6551If @option{-Wformat} is specified, do not warn about zero-length formats.
6552The C standard specifies that zero-length formats are allowed.
6553
d77de738
ML
6554@opindex Wformat-nonliteral
6555@opindex Wno-format-nonliteral
ddf6fe37 6556@item -Wformat-nonliteral
d77de738
ML
6557If @option{-Wformat} is specified, also warn if the format string is not a
6558string literal and so cannot be checked, unless the format function
6559takes its format arguments as a @code{va_list}.
6560
d77de738
ML
6561@opindex Wformat-security
6562@opindex Wno-format-security
ddf6fe37 6563@item -Wformat-security
d77de738
ML
6564If @option{-Wformat} is specified, also warn about uses of format
6565functions that represent possible security problems. At present, this
6566warns about calls to @code{printf} and @code{scanf} functions where the
6567format string is not a string literal and there are no format arguments,
6568as in @code{printf (foo);}. This may be a security hole if the format
6569string came from untrusted input and contains @samp{%n}. (This is
6570currently a subset of what @option{-Wformat-nonliteral} warns about, but
6571in future warnings may be added to @option{-Wformat-security} that are not
6572included in @option{-Wformat-nonliteral}.)
6573
d77de738
ML
6574@opindex Wformat-signedness
6575@opindex Wno-format-signedness
ddf6fe37 6576@item -Wformat-signedness
d77de738
ML
6577If @option{-Wformat} is specified, also warn if the format string
6578requires an unsigned argument and the argument is signed and vice versa.
6579
d77de738
ML
6580@opindex Wformat-truncation
6581@opindex Wno-format-truncation
ddf6fe37
AA
6582@item -Wformat-truncation
6583@itemx -Wformat-truncation=@var{level}
d77de738
ML
6584Warn about calls to formatted input/output functions such as @code{snprintf}
6585and @code{vsnprintf} that might result in output truncation. When the exact
6586number of bytes written by a format directive cannot be determined at
6587compile-time it is estimated based on heuristics that depend on
6588the @var{level} argument and on optimization. While enabling optimization
6589will in most cases improve the accuracy of the warning, it may also result
6590in false positives. Except as noted otherwise, the option uses the same
6591logic @option{-Wformat-overflow}.
6592
6593@table @gcctabopt
d77de738
ML
6594@opindex Wformat-truncation
6595@opindex Wno-format-truncation
ddf6fe37
AA
6596@item -Wformat-truncation
6597@itemx -Wformat-truncation=1
d77de738
ML
6598Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6599employs a conservative approach that warns only about calls to bounded
6600functions whose return value is unused and that will most likely result
6601in output truncation.
6602
6603@item -Wformat-truncation=2
6604Level @var{2} warns also about calls to bounded functions whose return
6605value is used and that might result in truncation given an argument of
6606sufficient length or magnitude.
6607@end table
6608
d77de738
ML
6609@opindex Wformat-y2k
6610@opindex Wno-format-y2k
ddf6fe37 6611@item -Wformat-y2k
d77de738
ML
6612If @option{-Wformat} is specified, also warn about @code{strftime}
6613formats that may yield only a two-digit year.
6614
d77de738
ML
6615@opindex Wnonnull
6616@opindex Wno-nonnull
ddf6fe37 6617@item -Wnonnull
d77de738
ML
6618Warn about passing a null pointer for arguments marked as
6619requiring a non-null value by the @code{nonnull} function attribute.
6620
6621@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6622can be disabled with the @option{-Wno-nonnull} option.
6623
d77de738
ML
6624@opindex Wnonnull-compare
6625@opindex Wno-nonnull-compare
ddf6fe37 6626@item -Wnonnull-compare
d77de738
ML
6627Warn when comparing an argument marked with the @code{nonnull}
6628function attribute against null inside the function.
6629
6630@option{-Wnonnull-compare} is included in @option{-Wall}. It
6631can be disabled with the @option{-Wno-nonnull-compare} option.
6632
d77de738
ML
6633@opindex Wnull-dereference
6634@opindex Wno-null-dereference
ddf6fe37 6635@item -Wnull-dereference
d77de738
ML
6636Warn if the compiler detects paths that trigger erroneous or
6637undefined behavior due to dereferencing a null pointer. This option
6638is only active when @option{-fdelete-null-pointer-checks} is active,
6639which is enabled by optimizations in most targets. The precision of
6640the warnings depends on the optimization options used.
6641
d77de738
ML
6642@opindex Winfinite-recursion
6643@opindex Wno-infinite-recursion
ddf6fe37 6644@item -Winfinite-recursion
d77de738
ML
6645Warn about infinitely recursive calls. The warning is effective at all
6646optimization levels but requires optimization in order to detect infinite
6647recursion in calls between two or more functions.
6648@option{-Winfinite-recursion} is included in @option{-Wall}.
6649
ce51e843
ML
6650Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6651similar diagnostic, but is implemented in a different way (as part of
6652@option{-fanalyzer}).
6653
d77de738
ML
6654@opindex Winit-self
6655@opindex Wno-init-self
ddf6fe37 6656@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6657Warn about uninitialized variables that are initialized with themselves.
6658Note this option can only be used with the @option{-Wuninitialized} option.
6659
6660For example, GCC warns about @code{i} being uninitialized in the
6661following snippet only when @option{-Winit-self} has been specified:
6662@smallexample
6663@group
6664int f()
6665@{
6666 int i = i;
6667 return i;
6668@}
6669@end group
6670@end smallexample
6671
6672This warning is enabled by @option{-Wall} in C++.
6673
d77de738
ML
6674@opindex Wimplicit-int
6675@opindex Wno-implicit-int
ddf6fe37 6676@item -Wno-implicit-int @r{(C and Objective-C only)}
d77de738
ML
6677This option controls warnings when a declaration does not specify a type.
6678This warning is enabled by default in C99 and later dialects of C,
6679and also by @option{-Wall}.
6680
d77de738
ML
6681@opindex Wimplicit-function-declaration
6682@opindex Wno-implicit-function-declaration
ddf6fe37 6683@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
d77de738
ML
6684This option controls warnings when a function is used before being declared.
6685This warning is enabled by default in C99 and later dialects of C,
6686and also by @option{-Wall}.
6687The warning is made into an error by @option{-pedantic-errors}.
6688
d77de738
ML
6689@opindex Wimplicit
6690@opindex Wno-implicit
ddf6fe37 6691@item -Wimplicit @r{(C and Objective-C only)}
d77de738
ML
6692Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6693This warning is enabled by @option{-Wall}.
6694
d77de738
ML
6695@opindex Wimplicit-fallthrough
6696@opindex Wno-implicit-fallthrough
ddf6fe37 6697@item -Wimplicit-fallthrough
d77de738
ML
6698@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6699and @option{-Wno-implicit-fallthrough} is the same as
6700@option{-Wimplicit-fallthrough=0}.
6701
d77de738 6702@opindex Wimplicit-fallthrough=
ddf6fe37 6703@item -Wimplicit-fallthrough=@var{n}
d77de738
ML
6704Warn when a switch case falls through. For example:
6705
6706@smallexample
6707@group
6708switch (cond)
6709 @{
6710 case 1:
6711 a = 1;
6712 break;
6713 case 2:
6714 a = 2;
6715 case 3:
6716 a = 3;
6717 break;
6718 @}
6719@end group
6720@end smallexample
6721
6722This warning does not warn when the last statement of a case cannot
6723fall through, e.g. when there is a return statement or a call to function
6724declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6725also takes into account control flow statements, such as ifs, and only
6726warns when appropriate. E.g.@:
6727
6728@smallexample
6729@group
6730switch (cond)
6731 @{
6732 case 1:
6733 if (i > 3) @{
6734 bar (5);
6735 break;
6736 @} else if (i < 1) @{
6737 bar (0);
6738 @} else
6739 return;
6740 default:
6741 @dots{}
6742 @}
6743@end group
6744@end smallexample
6745
6746Since there are occasions where a switch case fall through is desirable,
6747GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6748to be used along with a null statement to suppress this warning that
6749would normally occur:
6750
6751@smallexample
6752@group
6753switch (cond)
6754 @{
6755 case 1:
6756 bar (0);
6757 __attribute__ ((fallthrough));
6758 default:
6759 @dots{}
6760 @}
6761@end group
6762@end smallexample
6763
6764C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6765warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6766or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6767Instead of these attributes, it is also possible to add a fallthrough comment
6768to silence the warning. The whole body of the C or C++ style comment should
6769match the given regular expressions listed below. The option argument @var{n}
6770specifies what kind of comments are accepted:
6771
6772@itemize @bullet
6773
6774@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6775
6776@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6777expression, any comment is used as fallthrough comment.
6778
6779@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6780@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6781
6782@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6783following regular expressions:
6784
6785@itemize @bullet
6786
6787@item @code{-fallthrough}
6788
6789@item @code{@@fallthrough@@}
6790
6791@item @code{lint -fallthrough[ \t]*}
6792
6793@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6794
6795@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6796
6797@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6798
6799@end itemize
6800
6801@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6802following regular expressions:
6803
6804@itemize @bullet
6805
6806@item @code{-fallthrough}
6807
6808@item @code{@@fallthrough@@}
6809
6810@item @code{lint -fallthrough[ \t]*}
6811
6812@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6813
6814@end itemize
6815
6816@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6817fallthrough comments, only attributes disable the warning.
6818
6819@end itemize
6820
6821The comment needs to be followed after optional whitespace and other comments
6822by @code{case} or @code{default} keywords or by a user label that precedes some
6823@code{case} or @code{default} label.
6824
6825@smallexample
6826@group
6827switch (cond)
6828 @{
6829 case 1:
6830 bar (0);
6831 /* FALLTHRU */
6832 default:
6833 @dots{}
6834 @}
6835@end group
6836@end smallexample
6837
6838The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6839
d77de738
ML
6840@opindex Wif-not-aligned
6841@opindex Wno-if-not-aligned
ddf6fe37 6842@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
6843Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6844should be issued. These warnings are enabled by default.
6845
d77de738
ML
6846@opindex Wignored-qualifiers
6847@opindex Wno-ignored-qualifiers
ddf6fe37 6848@item -Wignored-qualifiers @r{(C and C++ only)}
d77de738
ML
6849Warn if the return type of a function has a type qualifier
6850such as @code{const}. For ISO C such a type qualifier has no effect,
6851since the value returned by a function is not an lvalue.
6852For C++, the warning is only emitted for scalar types or @code{void}.
6853ISO C prohibits qualified @code{void} return types on function
6854definitions, so such return types always receive a warning
6855even without this option.
6856
6857This warning is also enabled by @option{-Wextra}.
6858
d77de738
ML
6859@opindex Wignored-attributes
6860@opindex Wno-ignored-attributes
ddf6fe37 6861@item -Wno-ignored-attributes @r{(C and C++ only)}
d77de738
ML
6862This option controls warnings when an attribute is ignored.
6863This is different from the
6864@option{-Wattributes} option in that it warns whenever the compiler decides
6865to drop an attribute, not that the attribute is either unknown, used in a
6866wrong place, etc. This warning is enabled by default.
6867
d77de738
ML
6868@opindex Wmain
6869@opindex Wno-main
ddf6fe37 6870@item -Wmain
d77de738
ML
6871Warn if the type of @code{main} is suspicious. @code{main} should be
6872a function with external linkage, returning int, taking either zero
6873arguments, two, or three arguments of appropriate types. This warning
6874is enabled by default in C++ and is enabled by either @option{-Wall}
6875or @option{-Wpedantic}.
6876
d77de738
ML
6877@opindex Wmisleading-indentation
6878@opindex Wno-misleading-indentation
ddf6fe37 6879@item -Wmisleading-indentation @r{(C and C++ only)}
d77de738
ML
6880Warn when the indentation of the code does not reflect the block structure.
6881Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6882@code{for} clauses with a guarded statement that does not use braces,
6883followed by an unguarded statement with the same indentation.
6884
6885In the following example, the call to ``bar'' is misleadingly indented as
6886if it were guarded by the ``if'' conditional.
6887
6888@smallexample
6889 if (some_condition ())
6890 foo ();
6891 bar (); /* Gotcha: this is not guarded by the "if". */
6892@end smallexample
6893
6894In the case of mixed tabs and spaces, the warning uses the
6895@option{-ftabstop=} option to determine if the statements line up
6896(defaulting to 8).
6897
6898The warning is not issued for code involving multiline preprocessor logic
6899such as the following example.
6900
6901@smallexample
6902 if (flagA)
6903 foo (0);
6904#if SOME_CONDITION_THAT_DOES_NOT_HOLD
6905 if (flagB)
6906#endif
6907 foo (1);
6908@end smallexample
6909
6910The warning is not issued after a @code{#line} directive, since this
6911typically indicates autogenerated code, and no assumptions can be made
6912about the layout of the file that the directive references.
6913
6914This warning is enabled by @option{-Wall} in C and C++.
6915
d77de738
ML
6916@opindex Wmissing-attributes
6917@opindex Wno-missing-attributes
ddf6fe37 6918@item -Wmissing-attributes
d77de738
ML
6919Warn when a declaration of a function is missing one or more attributes
6920that a related function is declared with and whose absence may adversely
6921affect the correctness or efficiency of generated code. For example,
6922the warning is issued for declarations of aliases that use attributes
6923to specify less restrictive requirements than those of their targets.
6924This typically represents a potential optimization opportunity.
6925By contrast, the @option{-Wattribute-alias=2} option controls warnings
6926issued when the alias is more restrictive than the target, which could
6927lead to incorrect code generation.
6928Attributes considered include @code{alloc_align}, @code{alloc_size},
6929@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6930@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6931@code{returns_nonnull}, and @code{returns_twice}.
6932
6933In C++, the warning is issued when an explicit specialization of a primary
6934template declared with attribute @code{alloc_align}, @code{alloc_size},
6935@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6936or @code{nonnull} is declared without it. Attributes @code{deprecated},
6937@code{error}, and @code{warning} suppress the warning.
6938(@pxref{Function Attributes}).
6939
6940You can use the @code{copy} attribute to apply the same
6941set of attributes to a declaration as that on another declaration without
6942explicitly enumerating the attributes. This attribute can be applied
6943to declarations of functions (@pxref{Common Function Attributes}),
6944variables (@pxref{Common Variable Attributes}), or types
6945(@pxref{Common Type Attributes}).
6946
6947@option{-Wmissing-attributes} is enabled by @option{-Wall}.
6948
6949For example, since the declaration of the primary function template
6950below makes use of both attribute @code{malloc} and @code{alloc_size}
6951the declaration of the explicit specialization of the template is
6952diagnosed because it is missing one of the attributes.
6953
6954@smallexample
6955template <class T>
6956T* __attribute__ ((malloc, alloc_size (1)))
6957allocate (size_t);
6958
6959template <>
6960void* __attribute__ ((malloc)) // missing alloc_size
6961allocate<void> (size_t);
6962@end smallexample
6963
d77de738
ML
6964@opindex Wmissing-braces
6965@opindex Wno-missing-braces
ddf6fe37 6966@item -Wmissing-braces
d77de738
ML
6967Warn if an aggregate or union initializer is not fully bracketed. In
6968the following example, the initializer for @code{a} is not fully
6969bracketed, but that for @code{b} is fully bracketed.
6970
6971@smallexample
6972int a[2][2] = @{ 0, 1, 2, 3 @};
6973int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
6974@end smallexample
6975
6976This warning is enabled by @option{-Wall}.
6977
d77de738
ML
6978@opindex Wmissing-include-dirs
6979@opindex Wno-missing-include-dirs
ddf6fe37 6980@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
d77de738
ML
6981Warn if a user-supplied include directory does not exist. This opions is disabled
6982by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
6983enabled by default by warning for -I and -J, only.
6984
d77de738
ML
6985@opindex Wmissing-profile
6986@opindex Wno-missing-profile
ddf6fe37 6987@item -Wno-missing-profile
d77de738
ML
6988This option controls warnings if feedback profiles are missing when using the
6989@option{-fprofile-use} option.
6990This option diagnoses those cases where a new function or a new file is added
6991between compiling with @option{-fprofile-generate} and with
6992@option{-fprofile-use}, without regenerating the profiles.
6993In these cases, the profile feedback data files do not contain any
6994profile feedback information for
6995the newly added function or file respectively. Also, in the case when profile
6996count data (.gcda) files are removed, GCC cannot use any profile feedback
6997information. In all these cases, warnings are issued to inform you that a
6998profile generation step is due.
6999Ignoring the warning can result in poorly optimized code.
7000@option{-Wno-missing-profile} can be used to
7001disable the warning, but this is not recommended and should be done only
7002when non-existent profile data is justified.
7003
d77de738
ML
7004@opindex Wmismatched-dealloc
7005@opindex Wno-mismatched-dealloc
ddf6fe37 7006@item -Wmismatched-dealloc
d77de738
ML
7007
7008Warn for calls to deallocation functions with pointer arguments returned
7009from from allocations functions for which the former isn't a suitable
7010deallocator. A pair of functions can be associated as matching allocators
7011and deallocators by use of attribute @code{malloc}. Unless disabled by
7012the @option{-fno-builtin} option the standard functions @code{calloc},
7013@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
7014forms of C++ @code{operator new} and @code{operator delete} are implicitly
7015associated as matching allocators and deallocators. In the following
7016example @code{mydealloc} is the deallocator for pointers returned from
7017@code{myalloc}.
7018
7019@smallexample
7020void mydealloc (void*);
7021
7022__attribute__ ((malloc (mydealloc, 1))) void*
7023myalloc (size_t);
7024
7025void f (void)
7026@{
7027 void *p = myalloc (32);
7028 // @dots{}use p@dots{}
7029 free (p); // warning: not a matching deallocator for myalloc
7030 mydealloc (p); // ok
7031@}
7032@end smallexample
7033
7034In C++, the related option @option{-Wmismatched-new-delete} diagnoses
7035mismatches involving either @code{operator new} or @code{operator delete}.
7036
7037Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7038
d77de738
ML
7039@opindex Wmultistatement-macros
7040@opindex Wno-multistatement-macros
ddf6fe37 7041@item -Wmultistatement-macros
d77de738
ML
7042Warn about unsafe multiple statement macros that appear to be guarded
7043by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7044@code{while}, in which only the first statement is actually guarded after
7045the macro is expanded.
7046
7047For example:
7048
7049@smallexample
7050#define DOIT x++; y++
7051if (c)
7052 DOIT;
7053@end smallexample
7054
7055will increment @code{y} unconditionally, not just when @code{c} holds.
7056The can usually be fixed by wrapping the macro in a do-while loop:
7057@smallexample
7058#define DOIT do @{ x++; y++; @} while (0)
7059if (c)
7060 DOIT;
7061@end smallexample
7062
7063This warning is enabled by @option{-Wall} in C and C++.
7064
d77de738
ML
7065@opindex Wparentheses
7066@opindex Wno-parentheses
ddf6fe37 7067@item -Wparentheses
d77de738
ML
7068Warn if parentheses are omitted in certain contexts, such
7069as when there is an assignment in a context where a truth value
7070is expected, or when operators are nested whose precedence people
7071often get confused about.
7072
7073Also warn if a comparison like @code{x<=y<=z} appears; this is
7074equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7075interpretation from that of ordinary mathematical notation.
7076
7077Also warn for dangerous uses of the GNU extension to
7078@code{?:} with omitted middle operand. When the condition
7079in the @code{?}: operator is a boolean expression, the omitted value is
7080always 1. Often programmers expect it to be a value computed
7081inside the conditional expression instead.
7082
7083For C++ this also warns for some cases of unnecessary parentheses in
7084declarations, which can indicate an attempt at a function call instead
7085of a declaration:
7086@smallexample
7087@{
7088 // Declares a local variable called mymutex.
7089 std::unique_lock<std::mutex> (mymutex);
7090 // User meant std::unique_lock<std::mutex> lock (mymutex);
7091@}
7092@end smallexample
7093
7094This warning is enabled by @option{-Wall}.
7095
d77de738
ML
7096@opindex Wself-move
7097@opindex Wno-self-move
ddf6fe37 7098@item -Wno-self-move @r{(C++ and Objective-C++ only)}
d77de738
ML
7099This warning warns when a value is moved to itself with @code{std::move}.
7100Such a @code{std::move} typically has no effect.
7101
7102@smallexample
7103struct T @{
7104@dots{}
7105@};
7106void fn()
7107@{
7108 T t;
7109 @dots{}
7110 t = std::move (t);
7111@}
7112@end smallexample
7113
7114This warning is enabled by @option{-Wall}.
7115
d77de738
ML
7116@opindex Wsequence-point
7117@opindex Wno-sequence-point
ddf6fe37 7118@item -Wsequence-point
d77de738
ML
7119Warn about code that may have undefined semantics because of violations
7120of sequence point rules in the C and C++ standards.
7121
7122The C and C++ standards define the order in which expressions in a C/C++
7123program are evaluated in terms of @dfn{sequence points}, which represent
7124a partial ordering between the execution of parts of the program: those
7125executed before the sequence point, and those executed after it. These
7126occur after the evaluation of a full expression (one which is not part
7127of a larger expression), after the evaluation of the first operand of a
7128@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7129function is called (but after the evaluation of its arguments and the
7130expression denoting the called function), and in certain other places.
7131Other than as expressed by the sequence point rules, the order of
7132evaluation of subexpressions of an expression is not specified. All
7133these rules describe only a partial order rather than a total order,
7134since, for example, if two functions are called within one expression
7135with no sequence point between them, the order in which the functions
7136are called is not specified. However, the standards committee have
7137ruled that function calls do not overlap.
7138
7139It is not specified when between sequence points modifications to the
7140values of objects take effect. Programs whose behavior depends on this
7141have undefined behavior; the C and C++ standards specify that ``Between
7142the previous and next sequence point an object shall have its stored
7143value modified at most once by the evaluation of an expression.
7144Furthermore, the prior value shall be read only to determine the value
7145to be stored.''. If a program breaks these rules, the results on any
7146particular implementation are entirely unpredictable.
7147
7148Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7149= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7150diagnosed by this option, and it may give an occasional false positive
7151result, but in general it has been found fairly effective at detecting
7152this sort of problem in programs.
7153
7154The C++17 standard will define the order of evaluation of operands in
7155more cases: in particular it requires that the right-hand side of an
7156assignment be evaluated before the left-hand side, so the above
7157examples are no longer undefined. But this option will still warn
7158about them, to help people avoid writing code that is undefined in C
7159and earlier revisions of C++.
7160
7161The standard is worded confusingly, therefore there is some debate
7162over the precise meaning of the sequence point rules in subtle cases.
7163Links to discussions of the problem, including proposed formal
7164definitions, may be found on the GCC readings page, at
7165@uref{https://gcc.gnu.org/@/readings.html}.
7166
7167This warning is enabled by @option{-Wall} for C and C++.
7168
d77de738
ML
7169@opindex Wno-return-local-addr
7170@opindex Wreturn-local-addr
ddf6fe37 7171@item -Wno-return-local-addr
d77de738
ML
7172Do not warn about returning a pointer (or in C++, a reference) to a
7173variable that goes out of scope after the function returns.
7174
d77de738
ML
7175@opindex Wreturn-type
7176@opindex Wno-return-type
ddf6fe37 7177@item -Wreturn-type
d77de738
ML
7178Warn whenever a function is defined with a return type that defaults
7179to @code{int}. Also warn about any @code{return} statement with no
7180return value in a function whose return type is not @code{void}
7181(falling off the end of the function body is considered returning
7182without a value).
7183
7184For C only, warn about a @code{return} statement with an expression in a
7185function whose return type is @code{void}, unless the expression type is
7186also @code{void}. As a GNU extension, the latter case is accepted
7187without a warning unless @option{-Wpedantic} is used. Attempting
7188to use the return value of a non-@code{void} function other than @code{main}
7189that flows off the end by reaching the closing curly brace that terminates
7190the function is undefined.
7191
7192Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7193than @code{main} results in undefined behavior even when the value of
7194the function is not used.
7195
7196This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7197
d77de738
ML
7198@opindex Wshift-count-negative
7199@opindex Wno-shift-count-negative
ddf6fe37 7200@item -Wno-shift-count-negative
d77de738
ML
7201Controls warnings if a shift count is negative.
7202This warning is enabled by default.
7203
d77de738
ML
7204@opindex Wshift-count-overflow
7205@opindex Wno-shift-count-overflow
ddf6fe37 7206@item -Wno-shift-count-overflow
d77de738
ML
7207Controls warnings if a shift count is greater than or equal to the bit width
7208of the type. This warning is enabled by default.
7209
d77de738
ML
7210@opindex Wshift-negative-value
7211@opindex Wno-shift-negative-value
ddf6fe37 7212@item -Wshift-negative-value
d77de738
ML
7213Warn if left shifting a negative value. This warning is enabled by
7214@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7215
d77de738
ML
7216@opindex Wshift-overflow
7217@opindex Wno-shift-overflow
ddf6fe37
AA
7218@item -Wno-shift-overflow
7219@itemx -Wshift-overflow=@var{n}
d77de738
ML
7220These options control warnings about left shift overflows.
7221
7222@table @gcctabopt
7223@item -Wshift-overflow=1
7224This is the warning level of @option{-Wshift-overflow} and is enabled
7225by default in C99 and C++11 modes (and newer). This warning level does
7226not warn about left-shifting 1 into the sign bit. (However, in C, such
7227an overflow is still rejected in contexts where an integer constant expression
7228is required.) No warning is emitted in C++20 mode (and newer), as signed left
7229shifts always wrap.
7230
7231@item -Wshift-overflow=2
7232This warning level also warns about left-shifting 1 into the sign bit,
7233unless C++14 mode (or newer) is active.
7234@end table
7235
d77de738
ML
7236@opindex Wswitch
7237@opindex Wno-switch
ddf6fe37 7238@item -Wswitch
d77de738
ML
7239Warn whenever a @code{switch} statement has an index of enumerated type
7240and lacks a @code{case} for one or more of the named codes of that
7241enumeration. (The presence of a @code{default} label prevents this
7242warning.) @code{case} labels outside the enumeration range also
7243provoke warnings when this option is used (even if there is a
7244@code{default} label).
7245This warning is enabled by @option{-Wall}.
7246
d77de738
ML
7247@opindex Wswitch-default
7248@opindex Wno-switch-default
ddf6fe37 7249@item -Wswitch-default
d77de738
ML
7250Warn whenever a @code{switch} statement does not have a @code{default}
7251case.
7252
d77de738
ML
7253@opindex Wswitch-enum
7254@opindex Wno-switch-enum
ddf6fe37 7255@item -Wswitch-enum
d77de738
ML
7256Warn whenever a @code{switch} statement has an index of enumerated type
7257and lacks a @code{case} for one or more of the named codes of that
7258enumeration. @code{case} labels outside the enumeration range also
7259provoke warnings when this option is used. The only difference
7260between @option{-Wswitch} and this option is that this option gives a
7261warning about an omitted enumeration code even if there is a
7262@code{default} label.
7263
d77de738
ML
7264@opindex Wswitch-bool
7265@opindex Wno-switch-bool
ddf6fe37 7266@item -Wno-switch-bool
d77de738
ML
7267Do not warn when a @code{switch} statement has an index of boolean type
7268and the case values are outside the range of a boolean type.
7269It is possible to suppress this warning by casting the controlling
7270expression to a type other than @code{bool}. For example:
7271@smallexample
7272@group
7273switch ((int) (a == 4))
7274 @{
7275 @dots{}
7276 @}
7277@end group
7278@end smallexample
7279This warning is enabled by default for C and C++ programs.
7280
d77de738
ML
7281@opindex Wswitch-outside-range
7282@opindex Wno-switch-outside-range
ddf6fe37 7283@item -Wno-switch-outside-range
d77de738
ML
7284This option controls warnings when a @code{switch} case has a value
7285that is outside of its
7286respective type range. This warning is enabled by default for
7287C and C++ programs.
7288
d77de738
ML
7289@opindex Wswitch-unreachable
7290@opindex Wno-switch-unreachable
ddf6fe37 7291@item -Wno-switch-unreachable
d77de738
ML
7292Do not warn when a @code{switch} statement contains statements between the
7293controlling expression and the first case label, which will never be
7294executed. For example:
7295@smallexample
7296@group
7297switch (cond)
7298 @{
7299 i = 15;
7300 @dots{}
7301 case 5:
7302 @dots{}
7303 @}
7304@end group
7305@end smallexample
7306@option{-Wswitch-unreachable} does not warn if the statement between the
7307controlling expression and the first case label is just a declaration:
7308@smallexample
7309@group
7310switch (cond)
7311 @{
7312 int i;
7313 @dots{}
7314 case 5:
7315 i = 5;
7316 @dots{}
7317 @}
7318@end group
7319@end smallexample
7320This warning is enabled by default for C and C++ programs.
7321
d77de738
ML
7322@opindex Wsync-nand
7323@opindex Wno-sync-nand
ddf6fe37 7324@item -Wsync-nand @r{(C and C++ only)}
d77de738
ML
7325Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7326built-in functions are used. These functions changed semantics in GCC 4.4.
7327
d77de738
ML
7328@opindex Wtrivial-auto-var-init
7329@opindex Wno-trivial-auto-var-init
ddf6fe37 7330@item -Wtrivial-auto-var-init
d77de738
ML
7331Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7332variable. A common situation is an automatic variable that is declared
7333between the controlling expression and the first case label of a @code{switch}
7334statement.
7335
d77de738
ML
7336@opindex Wunused-but-set-parameter
7337@opindex Wno-unused-but-set-parameter
ddf6fe37 7338@item -Wunused-but-set-parameter
d77de738
ML
7339Warn whenever a function parameter is assigned to, but otherwise unused
7340(aside from its declaration).
7341
7342To suppress this warning use the @code{unused} attribute
7343(@pxref{Variable Attributes}).
7344
7345This warning is also enabled by @option{-Wunused} together with
7346@option{-Wextra}.
7347
d77de738
ML
7348@opindex Wunused-but-set-variable
7349@opindex Wno-unused-but-set-variable
ddf6fe37 7350@item -Wunused-but-set-variable
d77de738
ML
7351Warn whenever a local variable is assigned to, but otherwise unused
7352(aside from its declaration).
7353This warning is enabled by @option{-Wall}.
7354
7355To suppress this warning use the @code{unused} attribute
7356(@pxref{Variable Attributes}).
7357
7358This warning is also enabled by @option{-Wunused}, which is enabled
7359by @option{-Wall}.
7360
d77de738
ML
7361@opindex Wunused-function
7362@opindex Wno-unused-function
ddf6fe37 7363@item -Wunused-function
d77de738
ML
7364Warn whenever a static function is declared but not defined or a
7365non-inline static function is unused.
7366This warning is enabled by @option{-Wall}.
7367
d77de738
ML
7368@opindex Wunused-label
7369@opindex Wno-unused-label
ddf6fe37 7370@item -Wunused-label
d77de738
ML
7371Warn whenever a label is declared but not used.
7372This warning is enabled by @option{-Wall}.
7373
7374To suppress this warning use the @code{unused} attribute
7375(@pxref{Variable Attributes}).
7376
d77de738
ML
7377@opindex Wunused-local-typedefs
7378@opindex Wno-unused-local-typedefs
ddf6fe37 7379@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
d77de738
ML
7380Warn when a typedef locally defined in a function is not used.
7381This warning is enabled by @option{-Wall}.
7382
d77de738
ML
7383@opindex Wunused-parameter
7384@opindex Wno-unused-parameter
ddf6fe37 7385@item -Wunused-parameter
d77de738
ML
7386Warn whenever a function parameter is unused aside from its declaration.
7387
7388To suppress this warning use the @code{unused} attribute
7389(@pxref{Variable Attributes}).
7390
d77de738
ML
7391@opindex Wunused-result
7392@opindex Wno-unused-result
ddf6fe37 7393@item -Wno-unused-result
d77de738
ML
7394Do not warn if a caller of a function marked with attribute
7395@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7396its return value. The default is @option{-Wunused-result}.
7397
d77de738
ML
7398@opindex Wunused-variable
7399@opindex Wno-unused-variable
ddf6fe37 7400@item -Wunused-variable
d77de738
ML
7401Warn whenever a local or static variable is unused aside from its
7402declaration. This option implies @option{-Wunused-const-variable=1} for C,
7403but not for C++. This warning is enabled by @option{-Wall}.
7404
7405To suppress this warning use the @code{unused} attribute
7406(@pxref{Variable Attributes}).
7407
d77de738
ML
7408@opindex Wunused-const-variable
7409@opindex Wno-unused-const-variable
ddf6fe37
AA
7410@item -Wunused-const-variable
7411@itemx -Wunused-const-variable=@var{n}
d77de738
ML
7412Warn whenever a constant static variable is unused aside from its declaration.
7413@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7414for C, but not for C++. In C this declares variable storage, but in C++ this
7415is not an error since const variables take the place of @code{#define}s.
7416
7417To suppress this warning use the @code{unused} attribute
7418(@pxref{Variable Attributes}).
7419
7420@table @gcctabopt
7421@item -Wunused-const-variable=1
7422This is the warning level that is enabled by @option{-Wunused-variable} for
7423C. It warns only about unused static const variables defined in the main
7424compilation unit, but not about static const variables declared in any
7425header included.
7426
7427@item -Wunused-const-variable=2
7428This warning level also warns for unused constant static variables in
7429headers (excluding system headers). This is the warning level of
7430@option{-Wunused-const-variable} and must be explicitly requested since
7431in C++ this isn't an error and in C it might be harder to clean up all
7432headers included.
7433@end table
7434
d77de738
ML
7435@opindex Wunused-value
7436@opindex Wno-unused-value
ddf6fe37 7437@item -Wunused-value
d77de738
ML
7438Warn whenever a statement computes a result that is explicitly not
7439used. To suppress this warning cast the unused expression to
7440@code{void}. This includes an expression-statement or the left-hand
7441side of a comma expression that contains no side effects. For example,
7442an expression such as @code{x[i,j]} causes a warning, while
7443@code{x[(void)i,j]} does not.
7444
7445This warning is enabled by @option{-Wall}.
7446
d77de738
ML
7447@opindex Wunused
7448@opindex Wno-unused
ddf6fe37 7449@item -Wunused
d77de738
ML
7450All the above @option{-Wunused} options combined.
7451
7452In order to get a warning about an unused function parameter, you must
7453either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7454@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7455
d77de738
ML
7456@opindex Wuninitialized
7457@opindex Wno-uninitialized
ddf6fe37 7458@item -Wuninitialized
d77de738
ML
7459Warn if an object with automatic or allocated storage duration is used
7460without having been initialized. In C++, also warn if a non-static
7461reference or non-static @code{const} member appears in a class without
7462constructors.
7463
7464In addition, passing a pointer (or in C++, a reference) to an uninitialized
7465object to a @code{const}-qualified argument of a built-in function known to
7466read the object is also diagnosed by this warning.
7467(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7468
7469If you want to warn about code that uses the uninitialized value of the
7470variable in its own initializer, use the @option{-Winit-self} option.
7471
7472These warnings occur for individual uninitialized elements of
7473structure, union or array variables as well as for variables that are
7474uninitialized as a whole. They do not occur for variables or elements
7475declared @code{volatile}. Because these warnings depend on
7476optimization, the exact variables or elements for which there are
7477warnings depend on the precise optimization options and version of GCC
7478used.
7479
7480Note that there may be no warning about a variable that is used only
7481to compute a value that itself is never used, because such
7482computations may be deleted by data flow analysis before the warnings
7483are printed.
7484
7485In C++, this warning also warns about using uninitialized objects in
7486member-initializer-lists. For example, GCC warns about @code{b} being
7487uninitialized in the following snippet:
7488
7489@smallexample
7490struct A @{
7491 int a;
7492 int b;
7493 A() : a(b) @{ @}
7494@};
7495@end smallexample
7496
d77de738
ML
7497@opindex Winvalid-memory-model
7498@opindex Wno-invalid-memory-model
ddf6fe37 7499@item -Wno-invalid-memory-model
d77de738
ML
7500This option controls warnings
7501for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7502and the C11 atomic generic functions with a memory consistency argument
7503that is either invalid for the operation or outside the range of values
7504of the @code{memory_order} enumeration. For example, since the
7505@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7506defined for the relaxed, release, and sequentially consistent memory
7507orders the following code is diagnosed:
7508
7509@smallexample
7510void store (int *i)
7511@{
7512 __atomic_store_n (i, 0, memory_order_consume);
7513@}
7514@end smallexample
7515
7516@option{-Winvalid-memory-model} is enabled by default.
7517
d77de738
ML
7518@opindex Wmaybe-uninitialized
7519@opindex Wno-maybe-uninitialized
ddf6fe37 7520@item -Wmaybe-uninitialized
d77de738
ML
7521For an object with automatic or allocated storage duration, if there exists
7522a path from the function entry to a use of the object that is initialized,
7523but there exist some other paths for which the object is not initialized,
7524the compiler emits a warning if it cannot prove the uninitialized paths
7525are not executed at run time.
7526
7527In addition, passing a pointer (or in C++, a reference) to an uninitialized
7528object to a @code{const}-qualified function argument is also diagnosed by
7529this warning. (@option{-Wuninitialized} is issued for built-in functions
7530known to read the object.) Annotating the function with attribute
7531@code{access (none)} indicates that the argument isn't used to access
7532the object and avoids the warning (@pxref{Common Function Attributes}).
7533
7534These warnings are only possible in optimizing compilation, because otherwise
7535GCC does not keep track of the state of variables.
7536
7537These warnings are made optional because GCC may not be able to determine when
7538the code is correct in spite of appearing to have an error. Here is one
7539example of how this can happen:
7540
7541@smallexample
7542@group
7543@{
7544 int x;
7545 switch (y)
7546 @{
7547 case 1: x = 1;
7548 break;
7549 case 2: x = 4;
7550 break;
7551 case 3: x = 5;
7552 @}
7553 foo (x);
7554@}
7555@end group
7556@end smallexample
7557
7558@noindent
7559If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7560always initialized, but GCC doesn't know this. To suppress the
7561warning, you need to provide a default case with assert(0) or
7562similar code.
7563
7564@cindex @code{longjmp} warnings
7565This option also warns when a non-volatile automatic variable might be
7566changed by a call to @code{longjmp}.
7567The compiler sees only the calls to @code{setjmp}. It cannot know
7568where @code{longjmp} will be called; in fact, a signal handler could
7569call it at any point in the code. As a result, you may get a warning
7570even when there is in fact no problem because @code{longjmp} cannot
7571in fact be called at the place that would cause a problem.
7572
7573Some spurious warnings can be avoided if you declare all the functions
7574you use that never return as @code{noreturn}. @xref{Function
7575Attributes}.
7576
7577This warning is enabled by @option{-Wall} or @option{-Wextra}.
7578
d77de738
ML
7579@opindex Wunknown-pragmas
7580@opindex Wno-unknown-pragmas
7581@cindex warning for unknown pragmas
7582@cindex unknown pragmas, warning
7583@cindex pragmas, warning of unknown
f33d7a88 7584@item -Wunknown-pragmas
d77de738
ML
7585Warn when a @code{#pragma} directive is encountered that is not understood by
7586GCC@. If this command-line option is used, warnings are even issued
7587for unknown pragmas in system header files. This is not the case if
7588the warnings are only enabled by the @option{-Wall} command-line option.
7589
d77de738
ML
7590@opindex Wno-pragmas
7591@opindex Wpragmas
ddf6fe37 7592@item -Wno-pragmas
d77de738
ML
7593Do not warn about misuses of pragmas, such as incorrect parameters,
7594invalid syntax, or conflicts between pragmas. See also
7595@option{-Wunknown-pragmas}.
7596
d77de738
ML
7597@opindex Wno-prio-ctor-dtor
7598@opindex Wprio-ctor-dtor
ddf6fe37 7599@item -Wno-prio-ctor-dtor
d77de738
ML
7600Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7601The use of constructor and destructor attributes allow you to assign a
7602priority to the constructor/destructor to control its order of execution
7603before @code{main} is called or after it returns. The priority values must be
7604greater than 100 as the compiler reserves priority values between 0--100 for
7605the implementation.
7606
d77de738
ML
7607@opindex Wstrict-aliasing
7608@opindex Wno-strict-aliasing
ddf6fe37 7609@item -Wstrict-aliasing
d77de738
ML
7610This option is only active when @option{-fstrict-aliasing} is active.
7611It warns about code that might break the strict aliasing rules that the
7612compiler is using for optimization. The warning does not catch all
7613cases, but does attempt to catch the more common pitfalls. It is
7614included in @option{-Wall}.
7615It is equivalent to @option{-Wstrict-aliasing=3}
7616
d77de738 7617@opindex Wstrict-aliasing=n
ddf6fe37 7618@item -Wstrict-aliasing=n
d77de738
ML
7619This option is only active when @option{-fstrict-aliasing} is active.
7620It warns about code that might break the strict aliasing rules that the
7621compiler is using for optimization.
7622Higher levels correspond to higher accuracy (fewer false positives).
7623Higher levels also correspond to more effort, similar to the way @option{-O}
7624works.
7625@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7626
7627Level 1: Most aggressive, quick, least accurate.
7628Possibly useful when higher levels
7629do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7630false negatives. However, it has many false positives.
7631Warns for all pointer conversions between possibly incompatible types,
7632even if never dereferenced. Runs in the front end only.
7633
7634Level 2: Aggressive, quick, not too precise.
7635May still have many false positives (not as many as level 1 though),
7636and few false negatives (but possibly more than level 1).
7637Unlike level 1, it only warns when an address is taken. Warns about
7638incomplete types. Runs in the front end only.
7639
7640Level 3 (default for @option{-Wstrict-aliasing}):
7641Should have very few false positives and few false
7642negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7643Takes care of the common pun+dereference pattern in the front end:
7644@code{*(int*)&some_float}.
7645If optimization is enabled, it also runs in the back end, where it deals
7646with multiple statement cases using flow-sensitive points-to information.
7647Only warns when the converted pointer is dereferenced.
7648Does not warn about incomplete types.
7649
d77de738
ML
7650@opindex Wstrict-overflow
7651@opindex Wno-strict-overflow
ddf6fe37
AA
7652@item -Wstrict-overflow
7653@itemx -Wstrict-overflow=@var{n}
d77de738
ML
7654This option is only active when signed overflow is undefined.
7655It warns about cases where the compiler optimizes based on the
7656assumption that signed overflow does not occur. Note that it does not
7657warn about all cases where the code might overflow: it only warns
7658about cases where the compiler implements some optimization. Thus
7659this warning depends on the optimization level.
7660
7661An optimization that assumes that signed overflow does not occur is
7662perfectly safe if the values of the variables involved are such that
7663overflow never does, in fact, occur. Therefore this warning can
7664easily give a false positive: a warning about code that is not
7665actually a problem. To help focus on important issues, several
7666warning levels are defined. No warnings are issued for the use of
7667undefined signed overflow when estimating how many iterations a loop
7668requires, in particular when determining whether a loop will be
7669executed at all.
7670
7671@table @gcctabopt
7672@item -Wstrict-overflow=1
7673Warn about cases that are both questionable and easy to avoid. For
7674example the compiler simplifies
7675@code{x + 1 > x} to @code{1}. This level of
7676@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7677are not, and must be explicitly requested.
7678
7679@item -Wstrict-overflow=2
7680Also warn about other cases where a comparison is simplified to a
7681constant. For example: @code{abs (x) >= 0}. This can only be
7682simplified when signed integer overflow is undefined, because
7683@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7684zero. @option{-Wstrict-overflow} (with no level) is the same as
7685@option{-Wstrict-overflow=2}.
7686
7687@item -Wstrict-overflow=3
7688Also warn about other cases where a comparison is simplified. For
7689example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7690
7691@item -Wstrict-overflow=4
7692Also warn about other simplifications not covered by the above cases.
7693For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7694
7695@item -Wstrict-overflow=5
7696Also warn about cases where the compiler reduces the magnitude of a
7697constant involved in a comparison. For example: @code{x + 2 > y} is
7698simplified to @code{x + 1 >= y}. This is reported only at the
7699highest warning level because this simplification applies to many
7700comparisons, so this warning level gives a very large number of
7701false positives.
7702@end table
7703
d77de738
ML
7704@opindex Wstring-compare
7705@opindex Wno-string-compare
ddf6fe37 7706@item -Wstring-compare
d77de738
ML
7707Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7708determined to be either zero or non-zero in tests for such equality
7709owing to the length of one argument being greater than the size of
7710the array the other argument is stored in (or the bound in the case
7711of @code{strncmp}). Such calls could be mistakes. For example,
7712the call to @code{strcmp} below is diagnosed because its result is
7713necessarily non-zero irrespective of the contents of the array @code{a}.
7714
7715@smallexample
7716extern char a[4];
7717void f (char *d)
7718@{
7719 strcpy (d, "string");
7720 @dots{}
7721 if (0 == strcmp (a, d)) // cannot be true
7722 puts ("a and d are the same");
7723@}
7724@end smallexample
7725
7726@option{-Wstring-compare} is enabled by @option{-Wextra}.
7727
ddf6fe37
AA
7728@opindex Wstringop-overflow
7729@opindex Wno-stringop-overflow
d77de738
ML
7730@item -Wno-stringop-overflow
7731@item -Wstringop-overflow
7732@itemx -Wstringop-overflow=@var{type}
d77de738
ML
7733Warn for calls to string manipulation functions such as @code{memcpy} and
7734@code{strcpy} that are determined to overflow the destination buffer. The
7735optional argument is one greater than the type of Object Size Checking to
7736perform to determine the size of the destination. @xref{Object Size Checking}.
7737The argument is meaningful only for functions that operate on character arrays
7738but not for raw memory functions like @code{memcpy} which always make use
7739of Object Size type-0. The option also warns for calls that specify a size
7740in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7741The option produces the best results with optimization enabled but can detect
7742a small subset of simple buffer overflows even without optimization in
7743calls to the GCC built-in functions like @code{__builtin_memcpy} that
7744correspond to the standard functions. In any case, the option warns about
7745just a subset of buffer overflows detected by the corresponding overflow
7746checking built-ins. For example, the option issues a warning for
7747the @code{strcpy} call below because it copies at least 5 characters
7748(the string @code{"blue"} including the terminating NUL) into the buffer
7749of size 4.
7750
7751@smallexample
7752enum Color @{ blue, purple, yellow @};
7753const char* f (enum Color clr)
7754@{
7755 static char buf [4];
7756 const char *str;
7757 switch (clr)
7758 @{
7759 case blue: str = "blue"; break;
7760 case purple: str = "purple"; break;
7761 case yellow: str = "yellow"; break;
7762 @}
7763
7764 return strcpy (buf, str); // warning here
7765@}
7766@end smallexample
7767
7768Option @option{-Wstringop-overflow=2} is enabled by default.
7769
7770@table @gcctabopt
d77de738
ML
7771@opindex Wstringop-overflow
7772@opindex Wno-stringop-overflow
ddf6fe37
AA
7773@item -Wstringop-overflow
7774@itemx -Wstringop-overflow=1
d77de738
ML
7775The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7776to determine the sizes of destination objects. At this setting the option
7777does not warn for writes past the end of subobjects of larger objects accessed
7778by pointers unless the size of the largest surrounding object is known. When
7779the destination may be one of several objects it is assumed to be the largest
7780one of them. On Linux systems, when optimization is enabled at this setting
7781the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7782is defined to a non-zero value.
7783
7784@item -Wstringop-overflow=2
7785The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7786to determine the sizes of destination objects. At this setting the option
7787warns about overflows when writing to members of the largest complete
7788objects whose exact size is known. However, it does not warn for excessive
7789writes to the same members of unknown objects referenced by pointers since
7790they may point to arrays containing unknown numbers of elements. This is
7791the default setting of the option.
7792
7793@item -Wstringop-overflow=3
7794The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7795to determine the sizes of destination objects. At this setting the option
7796warns about overflowing the smallest object or data member. This is the
7797most restrictive setting of the option that may result in warnings for safe
7798code.
7799
7800@item -Wstringop-overflow=4
7801The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7802to determine the sizes of destination objects. At this setting the option
7803warns about overflowing any data members, and when the destination is
7804one of several objects it uses the size of the largest of them to decide
7805whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7806setting of the option may result in warnings for benign code.
7807@end table
7808
d77de738
ML
7809@opindex Wstringop-overread
7810@opindex Wno-stringop-overread
ddf6fe37 7811@item -Wno-stringop-overread
d77de738
ML
7812Warn for calls to string manipulation functions such as @code{memchr}, or
7813@code{strcpy} that are determined to read past the end of the source
7814sequence.
7815
7816Option @option{-Wstringop-overread} is enabled by default.
7817
d77de738
ML
7818@opindex Wstringop-truncation
7819@opindex Wno-stringop-truncation
ddf6fe37 7820@item -Wno-stringop-truncation
d77de738
ML
7821Do not warn for calls to bounded string manipulation functions
7822such as @code{strncat},
7823@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7824or leave the destination unchanged.
7825
7826In the following example, the call to @code{strncat} specifies a bound that
7827is less than the length of the source string. As a result, the copy of
7828the source will be truncated and so the call is diagnosed. To avoid the
7829warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7830
7831@smallexample
7832void append (char *buf, size_t bufsize)
7833@{
7834 strncat (buf, ".txt", 3);
7835@}
7836@end smallexample
7837
7838As another example, the following call to @code{strncpy} results in copying
7839to @code{d} just the characters preceding the terminating NUL, without
7840appending the NUL to the end. Assuming the result of @code{strncpy} is
7841necessarily a NUL-terminated string is a common mistake, and so the call
7842is diagnosed. To avoid the warning when the result is not expected to be
7843NUL-terminated, call @code{memcpy} instead.
7844
7845@smallexample
7846void copy (char *d, const char *s)
7847@{
7848 strncpy (d, s, strlen (s));
7849@}
7850@end smallexample
7851
7852In the following example, the call to @code{strncpy} specifies the size
7853of the destination buffer as the bound. If the length of the source
7854string is equal to or greater than this size the result of the copy will
7855not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7856the warning, specify @code{sizeof buf - 1} as the bound and set the last
7857element of the buffer to @code{NUL}.
7858
7859@smallexample
7860void copy (const char *s)
7861@{
7862 char buf[80];
7863 strncpy (buf, s, sizeof buf);
7864 @dots{}
7865@}
7866@end smallexample
7867
7868In situations where a character array is intended to store a sequence
7869of bytes with no terminating @code{NUL} such an array may be annotated
7870with attribute @code{nonstring} to avoid this warning. Such arrays,
7871however, are not suitable arguments to functions that expect
7872@code{NUL}-terminated strings. To help detect accidental misuses of
7873such arrays GCC issues warnings unless it can prove that the use is
7874safe. @xref{Common Variable Attributes}.
7875
2a27ae32
QZ
7876@opindex Wstrict-flex-arrays
7877@opindex Wno-strict-flex-arrays
ddf6fe37 7878@item -Wstrict-flex-arrays
2a27ae32
QZ
7879Warn about inproper usages of flexible array members
7880according to the @var{level} of the @code{strict_flex_array (@var{level})}
7881attribute attached to the trailing array field of a structure if it's
7882available, otherwise according to the @var{level} of the option
7883@option{-fstrict-flex-arrays=@var{level}}.
7884
7885This option is effective only when @var{level} is bigger than 0. Otherwise,
7886it will be ignored with a warning.
7887
7888when @var{level}=1, warnings will be issued for a trailing array reference
7889of a structure that have 2 or more elements if the trailing array is referenced
7890as a flexible array member.
7891
7892when @var{level}=2, in addition to @var{level}=1, additional warnings will be
7893issued for a trailing one-element array reference of a structure
7894if the array is referenced as a flexible array member.
7895
7896when @var{level}=3, in addition to @var{level}=2, additional warnings will be
7897issued for a trailing zero-length array reference of a structure
7898if the array is referenced as a flexible array member.
7899
7900
d77de738
ML
7901@opindex Wsuggest-attribute=
7902@opindex Wno-suggest-attribute=
ddf6fe37 7903@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
d77de738
ML
7904Warn for cases where adding an attribute may be beneficial. The
7905attributes currently supported are listed below.
7906
7907@table @gcctabopt
d77de738
ML
7908@opindex Wsuggest-attribute=pure
7909@opindex Wno-suggest-attribute=pure
7910@opindex Wsuggest-attribute=const
7911@opindex Wno-suggest-attribute=const
7912@opindex Wsuggest-attribute=noreturn
7913@opindex Wno-suggest-attribute=noreturn
7914@opindex Wmissing-noreturn
7915@opindex Wno-missing-noreturn
7916@opindex Wsuggest-attribute=malloc
7917@opindex Wno-suggest-attribute=malloc
ddf6fe37
AA
7918@item -Wsuggest-attribute=pure
7919@itemx -Wsuggest-attribute=const
7920@itemx -Wsuggest-attribute=noreturn
7921@itemx -Wmissing-noreturn
7922@itemx -Wsuggest-attribute=malloc
d77de738
ML
7923
7924Warn about functions that might be candidates for attributes
7925@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7926only warns for functions visible in other compilation units or (in the case of
7927@code{pure} and @code{const}) if it cannot prove that the function returns
7928normally. A function returns normally if it doesn't contain an infinite loop or
7929return abnormally by throwing, calling @code{abort} or trapping. This analysis
7930requires option @option{-fipa-pure-const}, which is enabled by default at
7931@option{-O} and higher. Higher optimization levels improve the accuracy
7932of the analysis.
7933
d77de738
ML
7934@opindex Wsuggest-attribute=format
7935@opindex Wmissing-format-attribute
7936@opindex Wno-suggest-attribute=format
7937@opindex Wno-missing-format-attribute
7938@opindex Wformat
7939@opindex Wno-format
ddf6fe37
AA
7940@item -Wsuggest-attribute=format
7941@itemx -Wmissing-format-attribute
d77de738
ML
7942
7943Warn about function pointers that might be candidates for @code{format}
7944attributes. Note these are only possible candidates, not absolute ones.
7945GCC guesses that function pointers with @code{format} attributes that
7946are used in assignment, initialization, parameter passing or return
7947statements should have a corresponding @code{format} attribute in the
7948resulting type. I.e.@: the left-hand side of the assignment or
7949initialization, the type of the parameter variable, or the return type
7950of the containing function respectively should also have a @code{format}
7951attribute to avoid the warning.
7952
7953GCC also warns about function definitions that might be
7954candidates for @code{format} attributes. Again, these are only
7955possible candidates. GCC guesses that @code{format} attributes
7956might be appropriate for any function that calls a function like
7957@code{vprintf} or @code{vscanf}, but this might not always be the
7958case, and some functions for which @code{format} attributes are
7959appropriate may not be detected.
7960
d77de738
ML
7961@opindex Wsuggest-attribute=cold
7962@opindex Wno-suggest-attribute=cold
ddf6fe37 7963@item -Wsuggest-attribute=cold
d77de738
ML
7964
7965Warn about functions that might be candidates for @code{cold} attribute. This
7966is based on static detection and generally only warns about functions which
7967always leads to a call to another @code{cold} function such as wrappers of
7968C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
7969@end table
7970
d77de738
ML
7971@opindex Wno-alloc-zero
7972@opindex Walloc-zero
ddf6fe37 7973@item -Walloc-zero
d77de738
ML
7974Warn about calls to allocation functions decorated with attribute
7975@code{alloc_size} that specify zero bytes, including those to the built-in
7976forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
7977@code{malloc}, and @code{realloc}. Because the behavior of these functions
7978when called with a zero size differs among implementations (and in the case
7979of @code{realloc} has been deprecated) relying on it may result in subtle
7980portability bugs and should be avoided.
7981
d77de738
ML
7982@opindex Walloc-size-larger-than=
7983@opindex Wno-alloc-size-larger-than
ddf6fe37 7984@item -Walloc-size-larger-than=@var{byte-size}
d77de738
ML
7985Warn about calls to functions decorated with attribute @code{alloc_size}
7986that attempt to allocate objects larger than the specified number of bytes,
7987or where the result of the size computation in an integer type with infinite
7988precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
7989@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
7990Warnings controlled by the option can be disabled either by specifying
7991@var{byte-size} of @samp{SIZE_MAX} or more or by
7992@option{-Wno-alloc-size-larger-than}.
7993@xref{Function Attributes}.
7994
d77de738 7995@opindex Wno-alloc-size-larger-than
ddf6fe37 7996@item -Wno-alloc-size-larger-than
d77de738
ML
7997Disable @option{-Walloc-size-larger-than=} warnings. The option is
7998equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
7999larger.
8000
d77de738
ML
8001@opindex Wno-alloca
8002@opindex Walloca
ddf6fe37 8003@item -Walloca
d77de738
ML
8004This option warns on all uses of @code{alloca} in the source.
8005
d77de738
ML
8006@opindex Walloca-larger-than=
8007@opindex Wno-alloca-larger-than
ddf6fe37 8008@item -Walloca-larger-than=@var{byte-size}
d77de738
ML
8009This option warns on calls to @code{alloca} with an integer argument whose
8010value is either zero, or that is not bounded by a controlling predicate
8011that limits its value to at most @var{byte-size}. It also warns for calls
8012to @code{alloca} where the bound value is unknown. Arguments of non-integer
8013types are considered unbounded even if they appear to be constrained to
8014the expected range.
8015
8016For example, a bounded case of @code{alloca} could be:
8017
8018@smallexample
8019void func (size_t n)
8020@{
8021 void *p;
8022 if (n <= 1000)
8023 p = alloca (n);
8024 else
8025 p = malloc (n);
8026 f (p);
8027@}
8028@end smallexample
8029
8030In the above example, passing @code{-Walloca-larger-than=1000} would not
8031issue a warning because the call to @code{alloca} is known to be at most
80321000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
8033the compiler would emit a warning.
8034
8035Unbounded uses, on the other hand, are uses of @code{alloca} with no
8036controlling predicate constraining its integer argument. For example:
8037
8038@smallexample
8039void func ()
8040@{
8041 void *p = alloca (n);
8042 f (p);
8043@}
8044@end smallexample
8045
8046If @code{-Walloca-larger-than=500} were passed, the above would trigger
8047a warning, but this time because of the lack of bounds checking.
8048
8049Note, that even seemingly correct code involving signed integers could
8050cause a warning:
8051
8052@smallexample
8053void func (signed int n)
8054@{
8055 if (n < 500)
8056 @{
8057 p = alloca (n);
8058 f (p);
8059 @}
8060@}
8061@end smallexample
8062
8063In the above example, @var{n} could be negative, causing a larger than
8064expected argument to be implicitly cast into the @code{alloca} call.
8065
8066This option also warns when @code{alloca} is used in a loop.
8067
8068@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8069but is usually only effective when @option{-ftree-vrp} is active (default
8070for @option{-O2} and above).
8071
8072See also @option{-Wvla-larger-than=}@samp{byte-size}.
8073
d77de738 8074@opindex Wno-alloca-larger-than
ddf6fe37 8075@item -Wno-alloca-larger-than
d77de738
ML
8076Disable @option{-Walloca-larger-than=} warnings. The option is
8077equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8078
d77de738
ML
8079@opindex Warith-conversion
8080@opindex Wno-arith-conversion
ddf6fe37 8081@item -Warith-conversion
d77de738
ML
8082Do warn about implicit conversions from arithmetic operations even
8083when conversion of the operands to the same type cannot change their
8084values. This affects warnings from @option{-Wconversion},
8085@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8086
8087@smallexample
8088@group
8089void f (char c, int i)
8090@{
8091 c = c + i; // warns with @option{-Wconversion}
8092 c = c + 1; // only warns with @option{-Warith-conversion}
8093@}
8094@end group
8095@end smallexample
8096
d77de738
ML
8097@opindex Wno-array-bounds
8098@opindex Warray-bounds
ddf6fe37
AA
8099@item -Warray-bounds
8100@itemx -Warray-bounds=@var{n}
d77de738
ML
8101Warn about out of bounds subscripts or offsets into arrays. This warning
8102is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8103is active (the default for @option{-O2} and above) but a subset of instances
8104are issued even without optimization.
8105
710c9676
QZ
8106By default, the trailing array of a structure will be treated as a flexible
8107array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8108if it is declared as either a flexible array member per C99 standard onwards
8109(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8110array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8111zero-length arrays or one-element arrays are not warned by default.
8112
8113You can add the option @option{-fstrict-flex-arrays} or
8114@option{-fstrict-flex-arrays=@var{level}} to control how this
8115option treat trailing array of a structure as a flexible array member:
8116
8117when @var{level}<=1, no change to the default behavior.
8118
8119when @var{level}=2, additional warnings will be issued for out of bounds
8120subscripts or offsets into one-element arrays;
8121
8122when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8123issued for out of bounds subscripts or offsets into zero-length arrays.
8124
d77de738
ML
8125@table @gcctabopt
8126@item -Warray-bounds=1
8127This is the default warning level of @option{-Warray-bounds} and is enabled
8128by @option{-Wall}; higher levels are not, and must be explicitly requested.
8129
8130@item -Warray-bounds=2
710c9676
QZ
8131This warning level also warns about the intermediate results of pointer
8132arithmetic that may yield out of bounds values. This warning level may
8133give a larger number of false positives and is deactivated by default.
d77de738
ML
8134@end table
8135
d77de738
ML
8136@opindex Warray-compare
8137@opindex Wno-array-compare
ddf6fe37 8138@item -Warray-compare
d77de738
ML
8139Warn about equality and relational comparisons between two operands of array
8140type. This comparison was deprecated in C++20. For example:
8141
8142@smallexample
8143int arr1[5];
8144int arr2[5];
8145bool same = arr1 == arr2;
8146@end smallexample
8147
8148@option{-Warray-compare} is enabled by @option{-Wall}.
8149
ddf6fe37 8150@opindex Wno-array-parameter
d77de738
ML
8151@item -Warray-parameter
8152@itemx -Warray-parameter=@var{n}
d77de738
ML
8153Warn about redeclarations of functions involving arguments of array or
8154pointer types of inconsistent kinds or forms, and enable the detection
8155of out-of-bounds accesses to such parameters by warnings such as
8156@option{-Warray-bounds}.
8157
8158If the first function declaration uses the array form the bound specified
8159in the array is assumed to be the minimum number of elements expected to
8160be provided in calls to the function and the maximum number of elements
8161accessed by it. Failing to provide arguments of sufficient size or accessing
8162more than the maximum number of elements may be diagnosed by warnings such
8163as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8164involving array parameters declared using the @code{T[static N]} form.
8165
8166For example, the warning triggers for the following redeclarations because
8167the first one allows an array of any size to be passed to @code{f} while
8168the second one with the keyword @code{static} specifies that the array
8169argument must have at least four elements.
8170
8171@smallexample
8172void f (int[static 4]);
8173void f (int[]); // warning (inconsistent array form)
8174
8175void g (void)
8176@{
8177 int *p = (int *)malloc (4);
8178 f (p); // warning (array too small)
8179 @dots{}
8180@}
8181@end smallexample
8182
8183At level 2 the warning also triggers for redeclarations involving any other
8184inconsistency in array or pointer argument forms denoting array sizes.
8185Pointers and arrays of unspecified bound are considered equivalent and do
8186not trigger a warning.
8187
8188@smallexample
8189void g (int*);
8190void g (int[]); // no warning
8191void g (int[8]); // warning (inconsistent array bound)
8192@end smallexample
8193
8194@option{-Warray-parameter=2} is included in @option{-Wall}. The
8195@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8196involving Variable Length Array arguments.
8197
d77de738
ML
8198@opindex Wattribute-alias
8199@opindex Wno-attribute-alias
ddf6fe37
AA
8200@item -Wattribute-alias=@var{n}
8201@itemx -Wno-attribute-alias
d77de738
ML
8202Warn about declarations using the @code{alias} and similar attributes whose
8203target is incompatible with the type of the alias.
8204@xref{Function Attributes,,Declaring Attributes of Functions}.
8205
8206@table @gcctabopt
8207@item -Wattribute-alias=1
8208The default warning level of the @option{-Wattribute-alias} option diagnoses
8209incompatibilities between the type of the alias declaration and that of its
8210target. Such incompatibilities are typically indicative of bugs.
8211
8212@item -Wattribute-alias=2
8213
8214At this level @option{-Wattribute-alias} also diagnoses cases where
8215the attributes of the alias declaration are more restrictive than the
8216attributes applied to its target. These mismatches can potentially
8217result in incorrect code generation. In other cases they may be
8218benign and could be resolved simply by adding the missing attribute to
8219the target. For comparison, see the @option{-Wmissing-attributes}
8220option, which controls diagnostics when the alias declaration is less
8221restrictive than the target, rather than more restrictive.
8222
8223Attributes considered include @code{alloc_align}, @code{alloc_size},
8224@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8225@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8226@code{returns_nonnull}, and @code{returns_twice}.
8227@end table
8228
8229@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8230This is the default. You can disable these warnings with either
8231@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8232
d77de738
ML
8233@opindex Wbidi-chars=
8234@opindex Wbidi-chars
8235@opindex Wno-bidi-chars
ddf6fe37 8236@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
d77de738
ML
8237Warn about possibly misleading UTF-8 bidirectional control characters in
8238comments, string literals, character constants, and identifiers. Such
8239characters can change left-to-right writing direction into right-to-left
8240(and vice versa), which can cause confusion between the logical order and
8241visual order. This may be dangerous; for instance, it may seem that a piece
8242of code is not commented out, whereas it in fact is.
8243
8244There are three levels of warning supported by GCC@. The default is
8245@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8246bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8247@option{-Wbidi-chars=any} warns about any use of bidirectional control
8248characters.
8249
8250By default, this warning does not warn about UCNs. It is, however, possible
8251to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8252@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8253and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8254@option{-Wbidi-chars=any} was specified.
8255
d77de738
ML
8256@opindex Wno-bool-compare
8257@opindex Wbool-compare
ddf6fe37 8258@item -Wbool-compare
d77de738
ML
8259Warn about boolean expression compared with an integer value different from
8260@code{true}/@code{false}. For instance, the following comparison is
8261always false:
8262@smallexample
8263int n = 5;
8264@dots{}
8265if ((n > 1) == 2) @{ @dots{} @}
8266@end smallexample
8267This warning is enabled by @option{-Wall}.
8268
d77de738
ML
8269@opindex Wno-bool-operation
8270@opindex Wbool-operation
ddf6fe37 8271@item -Wbool-operation
d77de738
ML
8272Warn about suspicious operations on expressions of a boolean type. For
8273instance, bitwise negation of a boolean is very likely a bug in the program.
8274For C, this warning also warns about incrementing or decrementing a boolean,
8275which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8276Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8277
8278This warning is enabled by @option{-Wall}.
8279
d77de738
ML
8280@opindex Wno-duplicated-branches
8281@opindex Wduplicated-branches
ddf6fe37 8282@item -Wduplicated-branches
d77de738
ML
8283Warn when an if-else has identical branches. This warning detects cases like
8284@smallexample
8285if (p != NULL)
8286 return 0;
8287else
8288 return 0;
8289@end smallexample
8290It doesn't warn when both branches contain just a null statement. This warning
8291also warn for conditional operators:
8292@smallexample
8293 int i = x ? *p : *p;
8294@end smallexample
8295
d77de738
ML
8296@opindex Wno-duplicated-cond
8297@opindex Wduplicated-cond
ddf6fe37 8298@item -Wduplicated-cond
d77de738
ML
8299Warn about duplicated conditions in an if-else-if chain. For instance,
8300warn for the following code:
8301@smallexample
8302if (p->q != NULL) @{ @dots{} @}
8303else if (p->q != NULL) @{ @dots{} @}
8304@end smallexample
8305
d77de738
ML
8306@opindex Wno-frame-address
8307@opindex Wframe-address
ddf6fe37 8308@item -Wframe-address
d77de738
ML
8309Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8310is called with an argument greater than 0. Such calls may return indeterminate
8311values or crash the program. The warning is included in @option{-Wall}.
8312
d77de738
ML
8313@opindex Wno-discarded-qualifiers
8314@opindex Wdiscarded-qualifiers
ddf6fe37 8315@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8316Do not warn if type qualifiers on pointers are being discarded.
8317Typically, the compiler warns if a @code{const char *} variable is
8318passed to a function that takes a @code{char *} parameter. This option
8319can be used to suppress such a warning.
8320
d77de738
ML
8321@opindex Wno-discarded-array-qualifiers
8322@opindex Wdiscarded-array-qualifiers
ddf6fe37 8323@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
d77de738
ML
8324Do not warn if type qualifiers on arrays which are pointer targets
8325are being discarded. Typically, the compiler warns if a
8326@code{const int (*)[]} variable is passed to a function that
8327takes a @code{int (*)[]} parameter. This option can be used to
8328suppress such a warning.
8329
d77de738
ML
8330@opindex Wno-incompatible-pointer-types
8331@opindex Wincompatible-pointer-types
ddf6fe37 8332@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
d77de738
ML
8333Do not warn when there is a conversion between pointers that have incompatible
8334types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8335which warns for pointer argument passing or assignment with different
8336signedness.
8337
d77de738
ML
8338@opindex Wno-int-conversion
8339@opindex Wint-conversion
ddf6fe37 8340@item -Wno-int-conversion @r{(C and Objective-C only)}
d77de738
ML
8341Do not warn about incompatible integer to pointer and pointer to integer
8342conversions. This warning is about implicit conversions; for explicit
8343conversions the warnings @option{-Wno-int-to-pointer-cast} and
8344@option{-Wno-pointer-to-int-cast} may be used.
8345
d77de738
ML
8346@opindex Wzero-length-bounds
8347@opindex Wzero-length-bounds
ddf6fe37 8348@item -Wzero-length-bounds
d77de738
ML
8349Warn about accesses to elements of zero-length array members that might
8350overlap other members of the same object. Declaring interior zero-length
8e9c65d3 8351arrays is discouraged because accesses to them are undefined.
d77de738
ML
8352@xref{Zero Length}.
8353
8354For example, the first two stores in function @code{bad} are diagnosed
8355because the array elements overlap the subsequent members @code{b} and
8356@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8357because it is beyond the bounds of the enclosing object.
8358
8359@smallexample
8360struct X @{ int a[0]; int b, c; @};
8361struct X x;
8362
8363void bad (void)
8364@{
8365 x.a[0] = 0; // -Wzero-length-bounds
8366 x.a[1] = 1; // -Wzero-length-bounds
8367 x.a[2] = 2; // -Warray-bounds
8368@}
8369@end smallexample
8370
8371Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8372
d77de738
ML
8373@opindex Wno-div-by-zero
8374@opindex Wdiv-by-zero
ddf6fe37 8375@item -Wno-div-by-zero
d77de738
ML
8376Do not warn about compile-time integer division by zero. Floating-point
8377division by zero is not warned about, as it can be a legitimate way of
8378obtaining infinities and NaNs.
8379
d77de738
ML
8380@opindex Wsystem-headers
8381@opindex Wno-system-headers
8382@cindex warnings from system headers
8383@cindex system headers, warnings from
f33d7a88 8384@item -Wsystem-headers
d77de738
ML
8385Print warning messages for constructs found in system header files.
8386Warnings from system headers are normally suppressed, on the assumption
8387that they usually do not indicate real problems and would only make the
8388compiler output harder to read. Using this command-line option tells
8389GCC to emit warnings from system headers as if they occurred in user
8390code. However, note that using @option{-Wall} in conjunction with this
8391option does @emph{not} warn about unknown pragmas in system
8392headers---for that, @option{-Wunknown-pragmas} must also be used.
8393
d77de738
ML
8394@opindex Wtautological-compare
8395@opindex Wno-tautological-compare
ddf6fe37 8396@item -Wtautological-compare
d77de738
ML
8397Warn if a self-comparison always evaluates to true or false. This
8398warning detects various mistakes such as:
8399@smallexample
8400int i = 1;
8401@dots{}
8402if (i > i) @{ @dots{} @}
8403@end smallexample
8404
8405This warning also warns about bitwise comparisons that always evaluate
8406to true or false, for instance:
8407@smallexample
8408if ((a & 16) == 10) @{ @dots{} @}
8409@end smallexample
8410will always be false.
8411
8412This warning is enabled by @option{-Wall}.
8413
d77de738
ML
8414@opindex Wtrampolines
8415@opindex Wno-trampolines
ddf6fe37 8416@item -Wtrampolines
d77de738
ML
8417Warn about trampolines generated for pointers to nested functions.
8418A trampoline is a small piece of data or code that is created at run
8419time on the stack when the address of a nested function is taken, and is
8420used to call the nested function indirectly. For some targets, it is
8421made up of data only and thus requires no special treatment. But, for
8422most targets, it is made up of code and thus requires the stack to be
8423made executable in order for the program to work properly.
8424
d77de738
ML
8425@opindex Wfloat-equal
8426@opindex Wno-float-equal
ddf6fe37 8427@item -Wfloat-equal
d77de738
ML
8428Warn if floating-point values are used in equality comparisons.
8429
8430The idea behind this is that sometimes it is convenient (for the
8431programmer) to consider floating-point values as approximations to
8432infinitely precise real numbers. If you are doing this, then you need
8433to compute (by analyzing the code, or in some other way) the maximum or
8434likely maximum error that the computation introduces, and allow for it
8435when performing comparisons (and when producing output, but that's a
8436different problem). In particular, instead of testing for equality, you
8437should check to see whether the two values have ranges that overlap; and
8438this is done with the relational operators, so equality comparisons are
8439probably mistaken.
8440
d77de738
ML
8441@opindex Wtraditional
8442@opindex Wno-traditional
ddf6fe37 8443@item -Wtraditional @r{(C and Objective-C only)}
d77de738
ML
8444Warn about certain constructs that behave differently in traditional and
8445ISO C@. Also warn about ISO C constructs that have no traditional C
8446equivalent, and/or problematic constructs that should be avoided.
8447
8448@itemize @bullet
8449@item
8450Macro parameters that appear within string literals in the macro body.
8451In traditional C macro replacement takes place within string literals,
8452but in ISO C it does not.
8453
8454@item
8455In traditional C, some preprocessor directives did not exist.
8456Traditional preprocessors only considered a line to be a directive
8457if the @samp{#} appeared in column 1 on the line. Therefore
8458@option{-Wtraditional} warns about directives that traditional C
8459understands but ignores because the @samp{#} does not appear as the
8460first character on the line. It also suggests you hide directives like
8461@code{#pragma} not understood by traditional C by indenting them. Some
8462traditional implementations do not recognize @code{#elif}, so this option
8463suggests avoiding it altogether.
8464
8465@item
8466A function-like macro that appears without arguments.
8467
8468@item
8469The unary plus operator.
8470
8471@item
8472The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8473constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8474constants.) Note, these suffixes appear in macros defined in the system
8475headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8476Use of these macros in user code might normally lead to spurious
8477warnings, however GCC's integrated preprocessor has enough context to
8478avoid warning in these cases.
8479
8480@item
8481A function declared external in one block and then used after the end of
8482the block.
8483
8484@item
8485A @code{switch} statement has an operand of type @code{long}.
8486
8487@item
8488A non-@code{static} function declaration follows a @code{static} one.
8489This construct is not accepted by some traditional C compilers.
8490
8491@item
8492The ISO type of an integer constant has a different width or
8493signedness from its traditional type. This warning is only issued if
8494the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8495typically represent bit patterns, are not warned about.
8496
8497@item
8498Usage of ISO string concatenation is detected.
8499
8500@item
8501Initialization of automatic aggregates.
8502
8503@item
8504Identifier conflicts with labels. Traditional C lacks a separate
8505namespace for labels.
8506
8507@item
8508Initialization of unions. If the initializer is zero, the warning is
8509omitted. This is done under the assumption that the zero initializer in
8510user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8511initializer warnings and relies on default initialization to zero in the
8512traditional C case.
8513
8514@item
8515Conversions by prototypes between fixed/floating-point values and vice
8516versa. The absence of these prototypes when compiling with traditional
8517C causes serious problems. This is a subset of the possible
8518conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8519
8520@item
8521Use of ISO C style function definitions. This warning intentionally is
8522@emph{not} issued for prototype declarations or variadic functions
8523because these ISO C features appear in your code when using
8524libiberty's traditional C compatibility macros, @code{PARAMS} and
8525@code{VPARAMS}. This warning is also bypassed for nested functions
8526because that feature is already a GCC extension and thus not relevant to
8527traditional C compatibility.
8528@end itemize
8529
d77de738
ML
8530@opindex Wtraditional-conversion
8531@opindex Wno-traditional-conversion
ddf6fe37 8532@item -Wtraditional-conversion @r{(C and Objective-C only)}
d77de738
ML
8533Warn if a prototype causes a type conversion that is different from what
8534would happen to the same argument in the absence of a prototype. This
8535includes conversions of fixed point to floating and vice versa, and
8536conversions changing the width or signedness of a fixed-point argument
8537except when the same as the default promotion.
8538
d77de738
ML
8539@opindex Wdeclaration-after-statement
8540@opindex Wno-declaration-after-statement
ddf6fe37 8541@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
d77de738
ML
8542Warn when a declaration is found after a statement in a block. This
8543construct, known from C++, was introduced with ISO C99 and is by default
8544allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8545
d77de738
ML
8546@opindex Wshadow
8547@opindex Wno-shadow
ddf6fe37 8548@item -Wshadow
d77de738
ML
8549Warn whenever a local variable or type declaration shadows another
8550variable, parameter, type, class member (in C++), or instance variable
8551(in Objective-C) or whenever a built-in function is shadowed. Note
8552that in C++, the compiler warns if a local variable shadows an
8553explicit typedef, but not if it shadows a struct/class/enum.
8554If this warning is enabled, it includes also all instances of
8555local shadowing. This means that @option{-Wno-shadow=local}
8556and @option{-Wno-shadow=compatible-local} are ignored when
8557@option{-Wshadow} is used.
8558Same as @option{-Wshadow=global}.
8559
d77de738
ML
8560@opindex Wno-shadow-ivar
8561@opindex Wshadow-ivar
ddf6fe37 8562@item -Wno-shadow-ivar @r{(Objective-C only)}
d77de738
ML
8563Do not warn whenever a local variable shadows an instance variable in an
8564Objective-C method.
8565
d77de738 8566@opindex Wshadow=global
ddf6fe37 8567@item -Wshadow=global
d77de738
ML
8568Warn for any shadowing.
8569Same as @option{-Wshadow}.
8570
d77de738 8571@opindex Wshadow=local
ddf6fe37 8572@item -Wshadow=local
d77de738
ML
8573Warn when a local variable shadows another local variable or parameter.
8574
d77de738 8575@opindex Wshadow=compatible-local
ddf6fe37 8576@item -Wshadow=compatible-local
d77de738
ML
8577Warn when a local variable shadows another local variable or parameter
8578whose type is compatible with that of the shadowing variable. In C++,
8579type compatibility here means the type of the shadowing variable can be
8580converted to that of the shadowed variable. The creation of this flag
8581(in addition to @option{-Wshadow=local}) is based on the idea that when
8582a local variable shadows another one of incompatible type, it is most
8583likely intentional, not a bug or typo, as shown in the following example:
8584
8585@smallexample
8586@group
8587for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8588@{
8589 for (int i = 0; i < N; ++i)
8590 @{
8591 ...
8592 @}
8593 ...
8594@}
8595@end group
8596@end smallexample
8597
8598Since the two variable @code{i} in the example above have incompatible types,
8599enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8600Because their types are incompatible, if a programmer accidentally uses one
8601in place of the other, type checking is expected to catch that and emit an
8602error or warning. Use of this flag instead of @option{-Wshadow=local} can
8603possibly reduce the number of warnings triggered by intentional shadowing.
8604Note that this also means that shadowing @code{const char *i} by
8605@code{char *i} does not emit a warning.
8606
8607This warning is also enabled by @option{-Wshadow=local}.
8608
d77de738
ML
8609@opindex Wlarger-than=
8610@opindex Wlarger-than-@var{byte-size}
ddf6fe37 8611@item -Wlarger-than=@var{byte-size}
d77de738
ML
8612Warn whenever an object is defined whose size exceeds @var{byte-size}.
8613@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8614Warnings controlled by the option can be disabled either by specifying
8615@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8616
8617Also warn for calls to bounded functions such as @code{memchr} or
8618@code{strnlen} that specify a bound greater than the largest possible
8619object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8620can only be disabled by @option{-Wno-larger-than}.
8621
d77de738 8622@opindex Wno-larger-than
ddf6fe37 8623@item -Wno-larger-than
d77de738
ML
8624Disable @option{-Wlarger-than=} warnings. The option is equivalent
8625to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8626
d77de738
ML
8627@opindex Wframe-larger-than=
8628@opindex Wno-frame-larger-than
ddf6fe37 8629@item -Wframe-larger-than=@var{byte-size}
d77de738
ML
8630Warn if the size of a function frame exceeds @var{byte-size}.
8631The computation done to determine the stack frame size is approximate
8632and not conservative.
8633The actual requirements may be somewhat greater than @var{byte-size}
8634even if you do not get a warning. In addition, any space allocated
8635via @code{alloca}, variable-length arrays, or related constructs
8636is not included by the compiler when determining
8637whether or not to issue a warning.
8638@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8639Warnings controlled by the option can be disabled either by specifying
8640@var{byte-size} of @samp{SIZE_MAX} or more or by
8641@option{-Wno-frame-larger-than}.
8642
d77de738 8643@opindex Wno-frame-larger-than
ddf6fe37 8644@item -Wno-frame-larger-than
d77de738
ML
8645Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8646to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8647
d77de738
ML
8648@opindex Wfree-nonheap-object
8649@opindex Wno-free-nonheap-object
ddf6fe37 8650@item -Wfree-nonheap-object
d77de738
ML
8651Warn when attempting to deallocate an object that was either not allocated
8652on the heap, or by using a pointer that was not returned from a prior call
8653to the corresponding allocation function. For example, because the call
8654to @code{stpcpy} returns a pointer to the terminating nul character and
8655not to the beginning of the object, the call to @code{free} below is
8656diagnosed.
8657
8658@smallexample
8659void f (char *p)
8660@{
8661 p = stpcpy (p, "abc");
8662 // ...
8663 free (p); // warning
8664@}
8665@end smallexample
8666
8667@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8668
d77de738
ML
8669@opindex Wstack-usage
8670@opindex Wno-stack-usage
ddf6fe37 8671@item -Wstack-usage=@var{byte-size}
d77de738
ML
8672Warn if the stack usage of a function might exceed @var{byte-size}.
8673The computation done to determine the stack usage is conservative.
8674Any space allocated via @code{alloca}, variable-length arrays, or related
8675constructs is included by the compiler when determining whether or not to
8676issue a warning.
8677
8678The message is in keeping with the output of @option{-fstack-usage}.
8679
8680@itemize
8681@item
8682If the stack usage is fully static but exceeds the specified amount, it's:
8683
8684@smallexample
8685 warning: stack usage is 1120 bytes
8686@end smallexample
8687@item
8688If the stack usage is (partly) dynamic but bounded, it's:
8689
8690@smallexample
8691 warning: stack usage might be 1648 bytes
8692@end smallexample
8693@item
8694If the stack usage is (partly) dynamic and not bounded, it's:
8695
8696@smallexample
8697 warning: stack usage might be unbounded
8698@end smallexample
8699@end itemize
8700
8701@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8702Warnings controlled by the option can be disabled either by specifying
8703@var{byte-size} of @samp{SIZE_MAX} or more or by
8704@option{-Wno-stack-usage}.
8705
d77de738 8706@opindex Wno-stack-usage
ddf6fe37 8707@item -Wno-stack-usage
d77de738
ML
8708Disable @option{-Wstack-usage=} warnings. The option is equivalent
8709to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8710
d77de738
ML
8711@opindex Wunsafe-loop-optimizations
8712@opindex Wno-unsafe-loop-optimizations
ddf6fe37 8713@item -Wunsafe-loop-optimizations
d77de738
ML
8714Warn if the loop cannot be optimized because the compiler cannot
8715assume anything on the bounds of the loop indices. With
8716@option{-funsafe-loop-optimizations} warn if the compiler makes
8717such assumptions.
8718
d77de738
ML
8719@opindex Wno-pedantic-ms-format
8720@opindex Wpedantic-ms-format
ddf6fe37 8721@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
d77de738
ML
8722When used in combination with @option{-Wformat}
8723and @option{-pedantic} without GNU extensions, this option
8724disables the warnings about non-ISO @code{printf} / @code{scanf} format
8725width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8726which depend on the MS runtime.
8727
d77de738
ML
8728@opindex Wpointer-arith
8729@opindex Wno-pointer-arith
ddf6fe37 8730@item -Wpointer-arith
d77de738
ML
8731Warn about anything that depends on the ``size of'' a function type or
8732of @code{void}. GNU C assigns these types a size of 1, for
8733convenience in calculations with @code{void *} pointers and pointers
8734to functions. In C++, warn also when an arithmetic operation involves
8735@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8736
d77de738
ML
8737@opindex Wpointer-compare
8738@opindex Wno-pointer-compare
ddf6fe37 8739@item -Wno-pointer-compare
d77de738
ML
8740Do not warn if a pointer is compared with a zero character constant.
8741This usually
8742means that the pointer was meant to be dereferenced. For example:
8743
8744@smallexample
8745const char *p = foo ();
8746if (p == '\0')
8747 return 42;
8748@end smallexample
8749
8750Note that the code above is invalid in C++11.
8751
8752This warning is enabled by default.
8753
d77de738
ML
8754@opindex Wtsan
8755@opindex Wno-tsan
ddf6fe37 8756@item -Wtsan
d77de738
ML
8757Warn about unsupported features in ThreadSanitizer.
8758
8759ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8760can report false positives.
8761
8762This warning is enabled by default.
8763
d77de738
ML
8764@opindex Wtype-limits
8765@opindex Wno-type-limits
ddf6fe37 8766@item -Wtype-limits
d77de738
ML
8767Warn if a comparison is always true or always false due to the limited
8768range of the data type, but do not warn for constant expressions. For
8769example, warn if an unsigned variable is compared against zero with
8770@code{<} or @code{>=}. This warning is also enabled by
8771@option{-Wextra}.
8772
d77de738
ML
8773@opindex Wabsolute-value
8774@opindex Wno-absolute-value
ddf6fe37 8775@item -Wabsolute-value @r{(C and Objective-C only)}
d77de738
ML
8776Warn for calls to standard functions that compute the absolute value
8777of an argument when a more appropriate standard function is available.
8778For example, calling @code{abs(3.14)} triggers the warning because the
8779appropriate function to call to compute the absolute value of a double
8780argument is @code{fabs}. The option also triggers warnings when the
8781argument in a call to such a function has an unsigned type. This
8782warning can be suppressed with an explicit type cast and it is also
8783enabled by @option{-Wextra}.
8784
8785@include cppwarnopts.texi
8786
d77de738
ML
8787@opindex Wbad-function-cast
8788@opindex Wno-bad-function-cast
ddf6fe37 8789@item -Wbad-function-cast @r{(C and Objective-C only)}
d77de738
ML
8790Warn when a function call is cast to a non-matching type.
8791For example, warn if a call to a function returning an integer type
8792is cast to a pointer type.
8793
d77de738
ML
8794@opindex Wc90-c99-compat
8795@opindex Wno-c90-c99-compat
ddf6fe37 8796@item -Wc90-c99-compat @r{(C and Objective-C only)}
d77de738
ML
8797Warn about features not present in ISO C90, but present in ISO C99.
8798For instance, warn about use of variable length arrays, @code{long long}
8799type, @code{bool} type, compound literals, designated initializers, and so
8800on. This option is independent of the standards mode. Warnings are disabled
8801in the expression that follows @code{__extension__}.
8802
d77de738
ML
8803@opindex Wc99-c11-compat
8804@opindex Wno-c99-c11-compat
ddf6fe37 8805@item -Wc99-c11-compat @r{(C and Objective-C only)}
d77de738
ML
8806Warn about features not present in ISO C99, but present in ISO C11.
8807For instance, warn about use of anonymous structures and unions,
8808@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8809@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8810and so on. This option is independent of the standards mode. Warnings are
8811disabled in the expression that follows @code{__extension__}.
8812
d77de738
ML
8813@opindex Wc11-c2x-compat
8814@opindex Wno-c11-c2x-compat
ddf6fe37 8815@item -Wc11-c2x-compat @r{(C and Objective-C only)}
d77de738
ML
8816Warn about features not present in ISO C11, but present in ISO C2X.
8817For instance, warn about omitting the string in @code{_Static_assert},
8818use of @samp{[[]]} syntax for attributes, use of decimal
8819floating-point types, and so on. This option is independent of the
8820standards mode. Warnings are disabled in the expression that follows
8821@code{__extension__}.
8822
d77de738
ML
8823@opindex Wc++-compat
8824@opindex Wno-c++-compat
ddf6fe37 8825@item -Wc++-compat @r{(C and Objective-C only)}
d77de738
ML
8826Warn about ISO C constructs that are outside of the common subset of
8827ISO C and ISO C++, e.g.@: request for implicit conversion from
8828@code{void *} to a pointer to non-@code{void} type.
8829
d77de738
ML
8830@opindex Wc++11-compat
8831@opindex Wno-c++11-compat
ddf6fe37 8832@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8833Warn about C++ constructs whose meaning differs between ISO C++ 1998
8834and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8835in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8836enabled by @option{-Wall}.
8837
d77de738
ML
8838@opindex Wc++14-compat
8839@opindex Wno-c++14-compat
ddf6fe37 8840@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8841Warn about C++ constructs whose meaning differs between ISO C++ 2011
8842and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8843
d77de738
ML
8844@opindex Wc++17-compat
8845@opindex Wno-c++17-compat
ddf6fe37 8846@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8847Warn about C++ constructs whose meaning differs between ISO C++ 2014
8848and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8849
d77de738
ML
8850@opindex Wc++20-compat
8851@opindex Wno-c++20-compat
ddf6fe37 8852@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
d77de738
ML
8853Warn about C++ constructs whose meaning differs between ISO C++ 2017
8854and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8855
d77de738
ML
8856@opindex Wc++11-extensions
8857@opindex Wno-c++11-extensions
ddf6fe37 8858@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8859Do not warn about C++11 constructs in code being compiled using
8860an older C++ standard. Even without this option, some C++11 constructs
8861will only be diagnosed if @option{-Wpedantic} is used.
8862
d77de738
ML
8863@opindex Wc++14-extensions
8864@opindex Wno-c++14-extensions
ddf6fe37 8865@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8866Do not warn about C++14 constructs in code being compiled using
8867an older C++ standard. Even without this option, some C++14 constructs
8868will only be diagnosed if @option{-Wpedantic} is used.
8869
d77de738
ML
8870@opindex Wc++17-extensions
8871@opindex Wno-c++17-extensions
ddf6fe37 8872@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8873Do not warn about C++17 constructs in code being compiled using
8874an older C++ standard. Even without this option, some C++17 constructs
8875will only be diagnosed if @option{-Wpedantic} is used.
8876
d77de738
ML
8877@opindex Wc++20-extensions
8878@opindex Wno-c++20-extensions
ddf6fe37 8879@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8880Do not warn about C++20 constructs in code being compiled using
8881an older C++ standard. Even without this option, some C++20 constructs
8882will only be diagnosed if @option{-Wpedantic} is used.
8883
d77de738
ML
8884@opindex Wc++23-extensions
8885@opindex Wno-c++23-extensions
ddf6fe37 8886@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
d77de738
ML
8887Do not warn about C++23 constructs in code being compiled using
8888an older C++ standard. Even without this option, some C++23 constructs
8889will only be diagnosed if @option{-Wpedantic} is used.
8890
d77de738
ML
8891@opindex Wcast-qual
8892@opindex Wno-cast-qual
ddf6fe37 8893@item -Wcast-qual
d77de738
ML
8894Warn whenever a pointer is cast so as to remove a type qualifier from
8895the target type. For example, warn if a @code{const char *} is cast
8896to an ordinary @code{char *}.
8897
8898Also warn when making a cast that introduces a type qualifier in an
8899unsafe way. For example, casting @code{char **} to @code{const char **}
8900is unsafe, as in this example:
8901
8902@smallexample
8903 /* p is char ** value. */
8904 const char **q = (const char **) p;
8905 /* Assignment of readonly string to const char * is OK. */
8906 *q = "string";
8907 /* Now char** pointer points to read-only memory. */
8908 **p = 'b';
8909@end smallexample
8910
d77de738
ML
8911@opindex Wcast-align
8912@opindex Wno-cast-align
ddf6fe37 8913@item -Wcast-align
d77de738
ML
8914Warn whenever a pointer is cast such that the required alignment of the
8915target is increased. For example, warn if a @code{char *} is cast to
8916an @code{int *} on machines where integers can only be accessed at
8917two- or four-byte boundaries.
8918
d77de738 8919@opindex Wcast-align=strict
ddf6fe37 8920@item -Wcast-align=strict
d77de738
ML
8921Warn whenever a pointer is cast such that the required alignment of the
8922target is increased. For example, warn if a @code{char *} is cast to
8923an @code{int *} regardless of the target machine.
8924
d77de738
ML
8925@opindex Wcast-function-type
8926@opindex Wno-cast-function-type
ddf6fe37 8927@item -Wcast-function-type
d77de738
ML
8928Warn when a function pointer is cast to an incompatible function pointer.
8929In a cast involving function types with a variable argument list only
8930the types of initial arguments that are provided are considered.
8931Any parameter of pointer-type matches any other pointer-type. Any benign
8932differences in integral types are ignored, like @code{int} vs.@: @code{long}
8933on ILP32 targets. Likewise type qualifiers are ignored. The function
8934type @code{void (*) (void)} is special and matches everything, which can
8935be used to suppress this warning.
8936In a cast involving pointer to member types this warning warns whenever
8937the type cast is changing the pointer to member type.
8938This warning is enabled by @option{-Wextra}.
8939
d77de738
ML
8940@opindex Wwrite-strings
8941@opindex Wno-write-strings
ddf6fe37 8942@item -Wwrite-strings
d77de738
ML
8943When compiling C, give string constants the type @code{const
8944char[@var{length}]} so that copying the address of one into a
8945non-@code{const} @code{char *} pointer produces a warning. These
8946warnings help you find at compile time code that can try to write
8947into a string constant, but only if you have been very careful about
8948using @code{const} in declarations and prototypes. Otherwise, it is
8949just a nuisance. This is why we did not make @option{-Wall} request
8950these warnings.
8951
8952When compiling C++, warn about the deprecated conversion from string
8953literals to @code{char *}. This warning is enabled by default for C++
8954programs.
8955
d77de738
ML
8956@opindex Wclobbered
8957@opindex Wno-clobbered
f33d7a88 8958@item -Wclobbered
d77de738
ML
8959Warn for variables that might be changed by @code{longjmp} or
8960@code{vfork}. This warning is also enabled by @option{-Wextra}.
8961
320dc51c
TS
8962@opindex Wcomplain-wrong-lang
8963@opindex Wno-complain-wrong-lang
f33d7a88 8964@item -Wno-complain-wrong-lang
320dc51c
TS
8965By default, language front ends complain when a command-line option is
8966valid, but not applicable to that front end.
8967This may be disabled with @option{-Wno-complain-wrong-lang},
8968which is mostly useful when invoking a single compiler driver for
8969multiple source files written in different languages, for example:
8970
8971@smallexample
8972$ g++ -fno-rtti a.cc b.f90
8973@end smallexample
8974
8975The driver @file{g++} invokes the C++ front end to compile @file{a.cc}
8976and the Fortran front end to compile @file{b.f90}.
8977The latter front end diagnoses
8978@samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran},
8979which may be disabled with @option{-Wno-complain-wrong-lang}.
8980
d77de738
ML
8981@opindex Wconversion
8982@opindex Wno-conversion
f33d7a88 8983@item -Wconversion
d77de738
ML
8984Warn for implicit conversions that may alter a value. This includes
8985conversions between real and integer, like @code{abs (x)} when
8986@code{x} is @code{double}; conversions between signed and unsigned,
8987like @code{unsigned ui = -1}; and conversions to smaller types, like
8988@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
8989((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
8990changed by the conversion like in @code{abs (2.0)}. Warnings about
8991conversions between signed and unsigned integers can be disabled by
8992using @option{-Wno-sign-conversion}.
8993
8994For C++, also warn for confusing overload resolution for user-defined
8995conversions; and conversions that never use a type conversion
8996operator: conversions to @code{void}, the same type, a base class or a
8997reference to them. Warnings about conversions between signed and
8998unsigned integers are disabled by default in C++ unless
8999@option{-Wsign-conversion} is explicitly enabled.
9000
9001Warnings about conversion from arithmetic on a small type back to that
9002type are only given with @option{-Warith-conversion}.
9003
d77de738
ML
9004@opindex Wdangling-else
9005@opindex Wno-dangling-else
ddf6fe37 9006@item -Wdangling-else
d77de738
ML
9007Warn about constructions where there may be confusion to which
9008@code{if} statement an @code{else} branch belongs. Here is an example of
9009such a case:
9010
9011@smallexample
9012@group
9013@{
9014 if (a)
9015 if (b)
9016 foo ();
9017 else
9018 bar ();
9019@}
9020@end group
9021@end smallexample
9022
9023In C/C++, every @code{else} branch belongs to the innermost possible
9024@code{if} statement, which in this example is @code{if (b)}. This is
9025often not what the programmer expected, as illustrated in the above
9026example by indentation the programmer chose. When there is the
9027potential for this confusion, GCC issues a warning when this flag
9028is specified. To eliminate the warning, add explicit braces around
9029the innermost @code{if} statement so there is no way the @code{else}
9030can belong to the enclosing @code{if}. The resulting code
9031looks like this:
9032
9033@smallexample
9034@group
9035@{
9036 if (a)
9037 @{
9038 if (b)
9039 foo ();
9040 else
9041 bar ();
9042 @}
9043@}
9044@end group
9045@end smallexample
9046
9047This warning is enabled by @option{-Wparentheses}.
9048
d77de738
ML
9049@opindex Wdangling-pointer
9050@opindex Wno-dangling-pointer
ddf6fe37
AA
9051@item -Wdangling-pointer
9052@itemx -Wdangling-pointer=@var{n}
d77de738
ML
9053Warn about uses of pointers (or C++ references) to objects with automatic
9054storage duration after their lifetime has ended. This includes local
9055variables declared in nested blocks, compound literals and other unnamed
9056temporary objects. In addition, warn about storing the address of such
9057objects in escaped pointers. The warning is enabled at all optimization
9058levels but may yield different results with optimization than without.
9059
9060@table @gcctabopt
9061@item -Wdangling-pointer=1
9062At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9063For example
9064@smallexample
9065int f (int c1, int c2, x)
9066@{
9067 char *p = strchr ((char[])@{ c1, c2 @}, c3);
4ace81b6
SL
9068 // warning: dangling pointer to a compound literal
9069 return p ? *p : 'x';
d77de738
ML
9070@}
9071@end smallexample
9072In the following function the store of the address of the local variable
9073@code{x} in the escaped pointer @code{*p} also triggers the warning.
9074@smallexample
9075void g (int **p)
9076@{
9077 int x = 7;
4ace81b6
SL
9078 // warning: storing the address of a local variable in *p
9079 *p = &x;
d77de738
ML
9080@}
9081@end smallexample
9082
9083@item -Wdangling-pointer=2
9084At level 2, in addition to unconditional uses the warning also diagnoses
9085conditional uses of dangling pointers.
9086
9087For example, because the array @var{a} in the following function is out of
9088scope when the pointer @var{s} that was set to point is used, the warning
9089triggers at this level.
9090
9091@smallexample
9092void f (char *s)
9093@{
9094 if (!s)
9095 @{
9096 char a[12] = "tmpname";
9097 s = a;
9098 @}
4ace81b6
SL
9099 // warning: dangling pointer to a may be used
9100 strcat (s, ".tmp");
d77de738
ML
9101 ...
9102@}
9103@end smallexample
9104@end table
9105
9106@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9107
d77de738
ML
9108@opindex Wdate-time
9109@opindex Wno-date-time
ddf6fe37 9110@item -Wdate-time
d77de738
ML
9111Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9112are encountered as they might prevent bit-wise-identical reproducible
9113compilations.
9114
d77de738
ML
9115@opindex Wempty-body
9116@opindex Wno-empty-body
ddf6fe37 9117@item -Wempty-body
d77de738
ML
9118Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9119while} statement. This warning is also enabled by @option{-Wextra}.
9120
d77de738
ML
9121@opindex Wendif-labels
9122@opindex Wno-endif-labels
ddf6fe37 9123@item -Wno-endif-labels
d77de738
ML
9124Do not warn about stray tokens after @code{#else} and @code{#endif}.
9125
d77de738
ML
9126@opindex Wenum-compare
9127@opindex Wno-enum-compare
ddf6fe37 9128@item -Wenum-compare
d77de738
ML
9129Warn about a comparison between values of different enumerated types.
9130In C++ enumerated type mismatches in conditional expressions are also
9131diagnosed and the warning is enabled by default. In C this warning is
9132enabled by @option{-Wall}.
9133
d77de738
ML
9134@opindex Wenum-conversion
9135@opindex Wno-enum-conversion
ddf6fe37 9136@item -Wenum-conversion
d77de738
ML
9137Warn when a value of enumerated type is implicitly converted to a
9138different enumerated type. This warning is enabled by @option{-Wextra}
9139in C@.
9140
d77de738
ML
9141@opindex Wenum-int-mismatch
9142@opindex Wno-enum-int-mismatch
ddf6fe37 9143@item -Wenum-int-mismatch @r{(C and Objective-C only)}
d77de738
ML
9144Warn about mismatches between an enumerated type and an integer type in
9145declarations. For example:
9146
9147@smallexample
9148enum E @{ l = -1, z = 0, g = 1 @};
9149int foo(void);
9150enum E foo(void);
9151@end smallexample
9152
9153In C, an enumerated type is compatible with @code{char}, a signed
9154integer type, or an unsigned integer type. However, since the choice
9155of the underlying type of an enumerated type is implementation-defined,
9156such mismatches may cause portability issues. In C++, such mismatches
9157are an error. In C, this warning is enabled by @option{-Wall} and
9158@option{-Wc++-compat}.
9159
d77de738
ML
9160@opindex Wjump-misses-init
9161@opindex Wno-jump-misses-init
ddf6fe37 9162@item -Wjump-misses-init @r{(C, Objective-C only)}
d77de738
ML
9163Warn if a @code{goto} statement or a @code{switch} statement jumps
9164forward across the initialization of a variable, or jumps backward to a
9165label after the variable has been initialized. This only warns about
9166variables that are initialized when they are declared. This warning is
9167only supported for C and Objective-C; in C++ this sort of branch is an
9168error in any case.
9169
9170@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9171can be disabled with the @option{-Wno-jump-misses-init} option.
9172
d77de738
ML
9173@opindex Wsign-compare
9174@opindex Wno-sign-compare
9175@cindex warning for comparison of signed and unsigned values
9176@cindex comparison of signed and unsigned values, warning
9177@cindex signed and unsigned values, comparison warning
f33d7a88 9178@item -Wsign-compare
d77de738
ML
9179Warn when a comparison between signed and unsigned values could produce
9180an incorrect result when the signed value is converted to unsigned.
9181In C++, this warning is also enabled by @option{-Wall}. In C, it is
9182also enabled by @option{-Wextra}.
9183
d77de738
ML
9184@opindex Wsign-conversion
9185@opindex Wno-sign-conversion
ddf6fe37 9186@item -Wsign-conversion
d77de738
ML
9187Warn for implicit conversions that may change the sign of an integer
9188value, like assigning a signed integer expression to an unsigned
9189integer variable. An explicit cast silences the warning. In C, this
9190option is enabled also by @option{-Wconversion}.
9191
d77de738
ML
9192@opindex Wfloat-conversion
9193@opindex Wno-float-conversion
ddf6fe37 9194@item -Wfloat-conversion
d77de738
ML
9195Warn for implicit conversions that reduce the precision of a real value.
9196This includes conversions from real to integer, and from higher precision
9197real to lower precision real values. This option is also enabled by
9198@option{-Wconversion}.
9199
d77de738
ML
9200@opindex Wno-scalar-storage-order
9201@opindex Wscalar-storage-order
ddf6fe37 9202@item -Wno-scalar-storage-order
d77de738
ML
9203Do not warn on suspicious constructs involving reverse scalar storage order.
9204
d77de738
ML
9205@opindex Wsizeof-array-div
9206@opindex Wno-sizeof-array-div
ddf6fe37 9207@item -Wsizeof-array-div
d77de738
ML
9208Warn about divisions of two sizeof operators when the first one is applied
9209to an array and the divisor does not equal the size of the array element.
9210In such a case, the computation will not yield the number of elements in the
9211array, which is likely what the user intended. This warning warns e.g. about
9212@smallexample
9213int fn ()
9214@{
9215 int arr[10];
9216 return sizeof (arr) / sizeof (short);
9217@}
9218@end smallexample
9219
9220This warning is enabled by @option{-Wall}.
9221
d77de738
ML
9222@opindex Wsizeof-pointer-div
9223@opindex Wno-sizeof-pointer-div
ddf6fe37 9224@item -Wsizeof-pointer-div
d77de738
ML
9225Warn for suspicious divisions of two sizeof expressions that divide
9226the pointer size by the element size, which is the usual way to compute
9227the array size but won't work out correctly with pointers. This warning
9228warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9229not an array, but a pointer. This warning is enabled by @option{-Wall}.
9230
d77de738
ML
9231@opindex Wsizeof-pointer-memaccess
9232@opindex Wno-sizeof-pointer-memaccess
ddf6fe37 9233@item -Wsizeof-pointer-memaccess
d77de738
ML
9234Warn for suspicious length parameters to certain string and memory built-in
9235functions if the argument uses @code{sizeof}. This warning triggers for
9236example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9237an array, but a pointer, and suggests a possible fix, or about
9238@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9239also warns about calls to bounded string copy functions like @code{strncat}
9240or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9241the source array. For example, in the following function the call to
9242@code{strncat} specifies the size of the source string as the bound. That
9243is almost certainly a mistake and so the call is diagnosed.
9244@smallexample
9245void make_file (const char *name)
9246@{
9247 char path[PATH_MAX];
9248 strncpy (path, name, sizeof path - 1);
9249 strncat (path, ".text", sizeof ".text");
9250 @dots{}
9251@}
9252@end smallexample
9253
9254The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9255
d77de738
ML
9256@opindex Wsizeof-array-argument
9257@opindex Wno-sizeof-array-argument
ddf6fe37 9258@item -Wno-sizeof-array-argument
d77de738
ML
9259Do not warn when the @code{sizeof} operator is applied to a parameter that is
9260declared as an array in a function definition. This warning is enabled by
9261default for C and C++ programs.
9262
d77de738
ML
9263@opindex Wmemset-elt-size
9264@opindex Wno-memset-elt-size
ddf6fe37 9265@item -Wmemset-elt-size
d77de738
ML
9266Warn for suspicious calls to the @code{memset} built-in function, if the
9267first argument references an array, and the third argument is a number
9268equal to the number of elements, but not equal to the size of the array
9269in memory. This indicates that the user has omitted a multiplication by
9270the element size. This warning is enabled by @option{-Wall}.
9271
d77de738
ML
9272@opindex Wmemset-transposed-args
9273@opindex Wno-memset-transposed-args
ddf6fe37 9274@item -Wmemset-transposed-args
d77de738
ML
9275Warn for suspicious calls to the @code{memset} built-in function where
9276the second argument is not zero and the third argument is zero. For
9277example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9278@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9279is only emitted if the third argument is a literal zero. Otherwise, if
9280it is an expression that is folded to zero, or a cast of zero to some
9281type, it is far less likely that the arguments have been mistakenly
9282transposed and no warning is emitted. This warning is enabled
9283by @option{-Wall}.
9284
d77de738
ML
9285@opindex Waddress
9286@opindex Wno-address
ddf6fe37 9287@item -Waddress
d77de738
ML
9288Warn about suspicious uses of address expressions. These include comparing
9289the address of a function or a declared object to the null pointer constant
9290such as in
9291@smallexample
9292void f (void);
9293void g (void)
9294@{
9295 if (!f) // warning: expression evaluates to false
9296 abort ();
9297@}
9298@end smallexample
9299comparisons of a pointer to a string literal, such as in
9300@smallexample
9301void f (const char *x)
9302@{
9303 if (x == "abc") // warning: expression evaluates to false
9304 puts ("equal");
9305@}
9306@end smallexample
9307and tests of the results of pointer addition or subtraction for equality
9308to null, such as in
9309@smallexample
9310void f (const int *p, int i)
9311@{
9312 return p + i == NULL;
9313@}
9314@end smallexample
9315Such uses typically indicate a programmer error: the address of most
9316functions and objects necessarily evaluates to true (the exception are
9317weak symbols), so their use in a conditional might indicate missing
9318parentheses in a function call or a missing dereference in an array
9319expression. The subset of the warning for object pointers can be
9320suppressed by casting the pointer operand to an integer type such
9321as @code{intptr_t} or @code{uintptr_t}.
9322Comparisons against string literals result in unspecified behavior
9323and are not portable, and suggest the intent was to call @code{strcmp}.
9324The warning is suppressed if the suspicious expression is the result
9325of macro expansion.
9326@option{-Waddress} warning is enabled by @option{-Wall}.
9327
d77de738
ML
9328@opindex Waddress-of-packed-member
9329@opindex Wno-address-of-packed-member
ddf6fe37 9330@item -Wno-address-of-packed-member
d77de738
ML
9331Do not warn when the address of packed member of struct or union is taken,
9332which usually results in an unaligned pointer value. This is
9333enabled by default.
9334
d77de738
ML
9335@opindex Wlogical-op
9336@opindex Wno-logical-op
ddf6fe37 9337@item -Wlogical-op
d77de738
ML
9338Warn about suspicious uses of logical operators in expressions.
9339This includes using logical operators in contexts where a
9340bit-wise operator is likely to be expected. Also warns when
9341the operands of a logical operator are the same:
9342@smallexample
9343extern int a;
9344if (a < 0 && a < 0) @{ @dots{} @}
9345@end smallexample
9346
d77de738
ML
9347@opindex Wlogical-not-parentheses
9348@opindex Wno-logical-not-parentheses
ddf6fe37 9349@item -Wlogical-not-parentheses
d77de738
ML
9350Warn about logical not used on the left hand side operand of a comparison.
9351This option does not warn if the right operand is considered to be a boolean
9352expression. Its purpose is to detect suspicious code like the following:
9353@smallexample
9354int a;
9355@dots{}
9356if (!a > 1) @{ @dots{} @}
9357@end smallexample
9358
9359It is possible to suppress the warning by wrapping the LHS into
9360parentheses:
9361@smallexample
9362if ((!a) > 1) @{ @dots{} @}
9363@end smallexample
9364
9365This warning is enabled by @option{-Wall}.
9366
d77de738
ML
9367@opindex Waggregate-return
9368@opindex Wno-aggregate-return
ddf6fe37 9369@item -Waggregate-return
d77de738
ML
9370Warn if any functions that return structures or unions are defined or
9371called. (In languages where you can return an array, this also elicits
9372a warning.)
9373
d77de738
ML
9374@opindex Wno-aggressive-loop-optimizations
9375@opindex Waggressive-loop-optimizations
ddf6fe37 9376@item -Wno-aggressive-loop-optimizations
d77de738
ML
9377Warn if in a loop with constant number of iterations the compiler detects
9378undefined behavior in some statement during one or more of the iterations.
9379
d77de738
ML
9380@opindex Wno-attributes
9381@opindex Wattributes
ddf6fe37 9382@item -Wno-attributes
d77de738
ML
9383Do not warn if an unexpected @code{__attribute__} is used, such as
9384unrecognized attributes, function attributes applied to variables,
9385etc. This does not stop errors for incorrect use of supported
9386attributes.
9387
9388Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9389warnings about unknown scoped attributes (in C++11 and C2X). For example,
9390@option{-Wno-attributes=vendor::attr} disables warning about the following
9391declaration:
9392
9393@smallexample
9394[[vendor::attr]] void f();
9395@end smallexample
9396
9397It is also possible to disable warning about all attributes in a namespace
9398using @option{-Wno-attributes=vendor::} which prevents warning about both
9399of these declarations:
9400
9401@smallexample
9402[[vendor::safe]] void f();
9403[[vendor::unsafe]] void f2();
9404@end smallexample
9405
9406Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9407
d77de738
ML
9408@opindex Wno-builtin-declaration-mismatch
9409@opindex Wbuiltin-declaration-mismatch
ddf6fe37 9410@item -Wno-builtin-declaration-mismatch
d77de738
ML
9411Warn if a built-in function is declared with an incompatible signature
9412or as a non-function, or when a built-in function declared with a type
9413that does not include a prototype is called with arguments whose promoted
9414types do not match those expected by the function. When @option{-Wextra}
9415is specified, also warn when a built-in function that takes arguments is
9416declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9417warning is enabled by default. To avoid the warning include the appropriate
9418header to bring the prototypes of built-in functions into scope.
9419
9420For example, the call to @code{memset} below is diagnosed by the warning
9421because the function expects a value of type @code{size_t} as its argument
9422but the type of @code{32} is @code{int}. With @option{-Wextra},
9423the declaration of the function is diagnosed as well.
9424@smallexample
9425extern void* memset ();
9426void f (void *d)
9427@{
9428 memset (d, '\0', 32);
9429@}
9430@end smallexample
9431
d77de738
ML
9432@opindex Wno-builtin-macro-redefined
9433@opindex Wbuiltin-macro-redefined
ddf6fe37 9434@item -Wno-builtin-macro-redefined
d77de738
ML
9435Do not warn if certain built-in macros are redefined. This suppresses
9436warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9437@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9438
d77de738
ML
9439@opindex Wstrict-prototypes
9440@opindex Wno-strict-prototypes
ddf6fe37 9441@item -Wstrict-prototypes @r{(C and Objective-C only)}
d77de738
ML
9442Warn if a function is declared or defined without specifying the
9443argument types. (An old-style function definition is permitted without
9444a warning if preceded by a declaration that specifies the argument
9445types.)
9446
d77de738
ML
9447@opindex Wold-style-declaration
9448@opindex Wno-old-style-declaration
ddf6fe37 9449@item -Wold-style-declaration @r{(C and Objective-C only)}
d77de738
ML
9450Warn for obsolescent usages, according to the C Standard, in a
9451declaration. For example, warn if storage-class specifiers like
9452@code{static} are not the first things in a declaration. This warning
9453is also enabled by @option{-Wextra}.
9454
d77de738
ML
9455@opindex Wold-style-definition
9456@opindex Wno-old-style-definition
ddf6fe37 9457@item -Wold-style-definition @r{(C and Objective-C only)}
d77de738
ML
9458Warn if an old-style function definition is used. A warning is given
9459even if there is a previous prototype. A definition using @samp{()}
9460is not considered an old-style definition in C2X mode, because it is
9461equivalent to @samp{(void)} in that case, but is considered an
9462old-style definition for older standards.
9463
d77de738
ML
9464@opindex Wmissing-parameter-type
9465@opindex Wno-missing-parameter-type
ddf6fe37 9466@item -Wmissing-parameter-type @r{(C and Objective-C only)}
d77de738
ML
9467A function parameter is declared without a type specifier in K&R-style
9468functions:
9469
9470@smallexample
9471void foo(bar) @{ @}
9472@end smallexample
9473
9474This warning is also enabled by @option{-Wextra}.
9475
d77de738
ML
9476@opindex Wmissing-prototypes
9477@opindex Wno-missing-prototypes
ddf6fe37 9478@item -Wmissing-prototypes @r{(C and Objective-C only)}
d77de738
ML
9479Warn if a global function is defined without a previous prototype
9480declaration. This warning is issued even if the definition itself
9481provides a prototype. Use this option to detect global functions
9482that do not have a matching prototype declaration in a header file.
9483This option is not valid for C++ because all function declarations
9484provide prototypes and a non-matching declaration declares an
9485overload rather than conflict with an earlier declaration.
9486Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9487
d77de738
ML
9488@opindex Wmissing-declarations
9489@opindex Wno-missing-declarations
ddf6fe37 9490@item -Wmissing-declarations
d77de738
ML
9491Warn if a global function is defined without a previous declaration.
9492Do so even if the definition itself provides a prototype.
9493Use this option to detect global functions that are not declared in
9494header files. In C, no warnings are issued for functions with previous
9495non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9496missing prototypes. In C++, no warnings are issued for function templates,
9497or for inline functions, or for functions in anonymous namespaces.
9498
d77de738
ML
9499@opindex Wmissing-field-initializers
9500@opindex Wno-missing-field-initializers
9501@opindex W
9502@opindex Wextra
9503@opindex Wno-extra
ddf6fe37 9504@item -Wmissing-field-initializers
d77de738
ML
9505Warn if a structure's initializer has some fields missing. For
9506example, the following code causes such a warning, because
9507@code{x.h} is implicitly zero:
9508
9509@smallexample
9510struct s @{ int f, g, h; @};
9511struct s x = @{ 3, 4 @};
9512@end smallexample
9513
9514This option does not warn about designated initializers, so the following
9515modification does not trigger a warning:
9516
9517@smallexample
9518struct s @{ int f, g, h; @};
9519struct s x = @{ .f = 3, .g = 4 @};
9520@end smallexample
9521
9522In C this option does not warn about the universal zero initializer
9523@samp{@{ 0 @}}:
9524
9525@smallexample
9526struct s @{ int f, g, h; @};
9527struct s x = @{ 0 @};
9528@end smallexample
9529
9530Likewise, in C++ this option does not warn about the empty @{ @}
9531initializer, for example:
9532
9533@smallexample
9534struct s @{ int f, g, h; @};
9535s x = @{ @};
9536@end smallexample
9537
9538This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9539warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9540
d77de738
ML
9541@opindex Wmissing-requires
9542@opindex Wno-missing-requires
ddf6fe37 9543@item -Wno-missing-requires
d77de738
ML
9544
9545By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9546
9547@smallexample
9548bool satisfied = requires @{ C<T> @};
9549@end smallexample
9550
9551Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9552expression, which it is for all T. Presumably the user meant to write
9553
9554@smallexample
9555bool satisfied = requires @{ requires C<T> @};
9556@end smallexample
9557
9558so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9559type @samp{T}.
9560
9561This warning can be disabled with @option{-Wno-missing-requires}.
9562
d77de738
ML
9563@opindex Wmissing-template-keyword
9564@opindex Wno-missing-template-keyword
ddf6fe37 9565@item -Wno-missing-template-keyword
d77de738
ML
9566
9567The member access tokens ., -> and :: must be followed by the @code{template}
9568keyword if the parent object is dependent and the member being named is a
9569template.
9570
9571@smallexample
9572template <class X>
9573void DoStuff (X x)
9574@{
9575 x.template DoSomeOtherStuff<X>(); // Good.
9576 x.DoMoreStuff<X>(); // Warning, x is dependent.
9577@}
9578@end smallexample
9579
9580In rare cases it is possible to get false positives. To silence this, wrap
9581the expression in parentheses. For example, the following is treated as a
9582template, even where m and N are integers:
9583
9584@smallexample
9585void NotATemplate (my_class t)
9586@{
9587 int N = 5;
9588
9589 bool test = t.m < N > (0); // Treated as a template.
9590 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9591@}
9592@end smallexample
9593
9594This warning can be disabled with @option{-Wno-missing-template-keyword}.
9595
d77de738
ML
9596@opindex Wno-multichar
9597@opindex Wmultichar
ddf6fe37 9598@item -Wno-multichar
d77de738
ML
9599Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9600Usually they indicate a typo in the user's code, as they have
9601implementation-defined values, and should not be used in portable code.
9602
d77de738
ML
9603@opindex Wnormalized=
9604@opindex Wnormalized
9605@opindex Wno-normalized
9606@cindex NFC
9607@cindex NFKC
9608@cindex character set, input normalization
f33d7a88 9609@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
d77de738
ML
9610In ISO C and ISO C++, two identifiers are different if they are
9611different sequences of characters. However, sometimes when characters
9612outside the basic ASCII character set are used, you can have two
9613different character sequences that look the same. To avoid confusion,
9614the ISO 10646 standard sets out some @dfn{normalization rules} which
9615when applied ensure that two sequences that look the same are turned into
9616the same sequence. GCC can warn you if you are using identifiers that
9617have not been normalized; this option controls that warning.
9618
9619There are four levels of warning supported by GCC@. The default is
9620@option{-Wnormalized=nfc}, which warns about any identifier that is
9621not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9622recommended form for most uses. It is equivalent to
9623@option{-Wnormalized}.
9624
9625Unfortunately, there are some characters allowed in identifiers by
9626ISO C and ISO C++ that, when turned into NFC, are not allowed in
9627identifiers. That is, there's no way to use these symbols in portable
9628ISO C or C++ and have all your identifiers in NFC@.
9629@option{-Wnormalized=id} suppresses the warning for these characters.
9630It is hoped that future versions of the standards involved will correct
9631this, which is why this option is not the default.
9632
9633You can switch the warning off for all characters by writing
9634@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9635only do this if you are using some other normalization scheme (like
9636``D''), because otherwise you can easily create bugs that are
9637literally impossible to see.
9638
9639Some characters in ISO 10646 have distinct meanings but look identical
9640in some fonts or display methodologies, especially once formatting has
9641been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9642LETTER N'', displays just like a regular @code{n} that has been
9643placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9644normalization scheme to convert all these into a standard form as
9645well, and GCC warns if your code is not in NFKC if you use
9646@option{-Wnormalized=nfkc}. This warning is comparable to warning
9647about every identifier that contains the letter O because it might be
9648confused with the digit 0, and so is not the default, but may be
9649useful as a local coding convention if the programming environment
9650cannot be fixed to display these characters distinctly.
9651
d77de738
ML
9652@opindex Wno-attribute-warning
9653@opindex Wattribute-warning
ddf6fe37 9654@item -Wno-attribute-warning
d77de738
ML
9655Do not warn about usage of functions (@pxref{Function Attributes})
9656declared with @code{warning} attribute. By default, this warning is
9657enabled. @option{-Wno-attribute-warning} can be used to disable the
9658warning or @option{-Wno-error=attribute-warning} can be used to
9659disable the error when compiled with @option{-Werror} flag.
9660
d77de738
ML
9661@opindex Wno-deprecated
9662@opindex Wdeprecated
ddf6fe37 9663@item -Wno-deprecated
d77de738
ML
9664Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9665
d77de738
ML
9666@opindex Wno-deprecated-declarations
9667@opindex Wdeprecated-declarations
ddf6fe37 9668@item -Wno-deprecated-declarations
d77de738
ML
9669Do not warn about uses of functions (@pxref{Function Attributes}),
9670variables (@pxref{Variable Attributes}), and types (@pxref{Type
9671Attributes}) marked as deprecated by using the @code{deprecated}
9672attribute.
9673
d77de738
ML
9674@opindex Wno-overflow
9675@opindex Woverflow
ddf6fe37 9676@item -Wno-overflow
d77de738
ML
9677Do not warn about compile-time overflow in constant expressions.
9678
d77de738
ML
9679@opindex Wno-odr
9680@opindex Wodr
ddf6fe37 9681@item -Wno-odr
d77de738
ML
9682Warn about One Definition Rule violations during link-time optimization.
9683Enabled by default.
9684
d77de738
ML
9685@opindex Wopenacc-parallelism
9686@opindex Wno-openacc-parallelism
9687@cindex OpenACC accelerator programming
f33d7a88 9688@item -Wopenacc-parallelism
d77de738
ML
9689Warn about potentially suboptimal choices related to OpenACC parallelism.
9690
d77de738
ML
9691@opindex Wopenmp-simd
9692@opindex Wno-openmp-simd
ddf6fe37 9693@item -Wopenmp-simd
d77de738
ML
9694Warn if the vectorizer cost model overrides the OpenMP
9695simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9696option can be used to relax the cost model.
9697
d77de738
ML
9698@opindex Woverride-init
9699@opindex Wno-override-init
9700@opindex W
9701@opindex Wextra
9702@opindex Wno-extra
ddf6fe37 9703@item -Woverride-init @r{(C and Objective-C only)}
d77de738
ML
9704Warn if an initialized field without side effects is overridden when
9705using designated initializers (@pxref{Designated Inits, , Designated
9706Initializers}).
9707
9708This warning is included in @option{-Wextra}. To get other
9709@option{-Wextra} warnings without this one, use @option{-Wextra
9710-Wno-override-init}.
9711
d77de738
ML
9712@opindex Woverride-init-side-effects
9713@opindex Wno-override-init-side-effects
ddf6fe37 9714@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
d77de738
ML
9715Do not warn if an initialized field with side effects is overridden when
9716using designated initializers (@pxref{Designated Inits, , Designated
9717Initializers}). This warning is enabled by default.
9718
d77de738
ML
9719@opindex Wpacked
9720@opindex Wno-packed
ddf6fe37 9721@item -Wpacked
d77de738
ML
9722Warn if a structure is given the packed attribute, but the packed
9723attribute has no effect on the layout or size of the structure.
9724Such structures may be mis-aligned for little benefit. For
9725instance, in this code, the variable @code{f.x} in @code{struct bar}
9726is misaligned even though @code{struct bar} does not itself
9727have the packed attribute:
9728
9729@smallexample
9730@group
9731struct foo @{
9732 int x;
9733 char a, b, c, d;
9734@} __attribute__((packed));
9735struct bar @{
9736 char z;
9737 struct foo f;
9738@};
9739@end group
9740@end smallexample
9741
d77de738
ML
9742@opindex Wpacked-bitfield-compat
9743@opindex Wno-packed-bitfield-compat
ddf6fe37 9744@item -Wnopacked-bitfield-compat
d77de738
ML
9745The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9746on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9747the change can lead to differences in the structure layout. GCC
9748informs you when the offset of such a field has changed in GCC 4.4.
9749For example there is no longer a 4-bit padding between field @code{a}
9750and @code{b} in this structure:
9751
9752@smallexample
9753struct foo
9754@{
9755 char a:4;
9756 char b:8;
9757@} __attribute__ ((packed));
9758@end smallexample
9759
9760This warning is enabled by default. Use
9761@option{-Wno-packed-bitfield-compat} to disable this warning.
9762
d77de738
ML
9763@opindex Wpacked-not-aligned
9764@opindex Wno-packed-not-aligned
ddf6fe37 9765@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
9766Warn if a structure field with explicitly specified alignment in a
9767packed struct or union is misaligned. For example, a warning will
9768be issued on @code{struct S}, like, @code{warning: alignment 1 of
9769'struct S' is less than 8}, in this code:
9770
9771@smallexample
9772@group
9773struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9774struct __attribute__ ((packed)) S @{
9775 struct S8 s8;
9776@};
9777@end group
9778@end smallexample
9779
9780This warning is enabled by @option{-Wall}.
9781
d77de738
ML
9782@opindex Wpadded
9783@opindex Wno-padded
ddf6fe37 9784@item -Wpadded
d77de738
ML
9785Warn if padding is included in a structure, either to align an element
9786of the structure or to align the whole structure. Sometimes when this
9787happens it is possible to rearrange the fields of the structure to
9788reduce the padding and so make the structure smaller.
9789
d77de738
ML
9790@opindex Wredundant-decls
9791@opindex Wno-redundant-decls
ddf6fe37 9792@item -Wredundant-decls
d77de738
ML
9793Warn if anything is declared more than once in the same scope, even in
9794cases where multiple declaration is valid and changes nothing.
9795
d77de738
ML
9796@opindex Wrestrict
9797@opindex Wno-restrict
ddf6fe37 9798@item -Wrestrict
d77de738
ML
9799Warn when an object referenced by a @code{restrict}-qualified parameter
9800(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9801argument, or when copies between such objects overlap. For example,
9802the call to the @code{strcpy} function below attempts to truncate the string
9803by replacing its initial characters with the last four. However, because
9804the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9805the call is diagnosed.
9806
9807@smallexample
9808void foo (void)
9809@{
9810 char a[] = "abcd1234";
9811 strcpy (a, a + 4);
9812 @dots{}
9813@}
9814@end smallexample
9815The @option{-Wrestrict} option detects some instances of simple overlap
9816even without optimization but works best at @option{-O2} and above. It
9817is included in @option{-Wall}.
9818
d77de738
ML
9819@opindex Wnested-externs
9820@opindex Wno-nested-externs
ddf6fe37 9821@item -Wnested-externs @r{(C and Objective-C only)}
d77de738
ML
9822Warn if an @code{extern} declaration is encountered within a function.
9823
d77de738
ML
9824@opindex Winline
9825@opindex Wno-inline
ddf6fe37 9826@item -Winline
d77de738
ML
9827Warn if a function that is declared as inline cannot be inlined.
9828Even with this option, the compiler does not warn about failures to
9829inline functions declared in system headers.
9830
9831The compiler uses a variety of heuristics to determine whether or not
9832to inline a function. For example, the compiler takes into account
9833the size of the function being inlined and the amount of inlining
9834that has already been done in the current function. Therefore,
9835seemingly insignificant changes in the source program can cause the
9836warnings produced by @option{-Winline} to appear or disappear.
9837
d77de738 9838@opindex Winterference-size
ddf6fe37 9839@item -Winterference-size
d77de738
ML
9840Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9841without specifying its value with @option{--param destructive-interference-size}.
9842Also warn about questionable values for that option.
9843
9844This variable is intended to be used for controlling class layout, to
9845avoid false sharing in concurrent code:
9846
9847@smallexample
9848struct independent_fields @{
4ace81b6
SL
9849 alignas(std::hardware_destructive_interference_size)
9850 std::atomic<int> one;
9851 alignas(std::hardware_destructive_interference_size)
9852 std::atomic<int> two;
d77de738
ML
9853@};
9854@end smallexample
9855
9856Here @samp{one} and @samp{two} are intended to be far enough apart
9857that stores to one won't require accesses to the other to reload the
9858cache line.
9859
9860By default, @option{--param destructive-interference-size} and
9861@option{--param constructive-interference-size} are set based on the
9862current @option{-mtune} option, typically to the L1 cache line size
9863for the particular target CPU, sometimes to a range if tuning for a
9864generic target. So all translation units that depend on ABI
9865compatibility for the use of these variables must be compiled with
9866the same @option{-mtune} (or @option{-mcpu}).
9867
9868If ABI stability is important, such as if the use is in a header for a
9869library, you should probably not use the hardware interference size
9870variables at all. Alternatively, you can force a particular value
9871with @option{--param}.
9872
9873If you are confident that your use of the variable does not affect ABI
9874outside a single build of your project, you can turn off the warning
9875with @option{-Wno-interference-size}.
9876
d77de738
ML
9877@opindex Wint-in-bool-context
9878@opindex Wno-int-in-bool-context
ddf6fe37 9879@item -Wint-in-bool-context
d77de738
ML
9880Warn for suspicious use of integer values where boolean values are expected,
9881such as conditional expressions (?:) using non-boolean integer constants in
9882boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9883integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9884for all kinds of multiplications regardless of the data type.
9885This warning is enabled by @option{-Wall}.
9886
d77de738
ML
9887@opindex Wno-int-to-pointer-cast
9888@opindex Wint-to-pointer-cast
ddf6fe37 9889@item -Wno-int-to-pointer-cast
d77de738
ML
9890Suppress warnings from casts to pointer type of an integer of a
9891different size. In C++, casting to a pointer type of smaller size is
9892an error. @option{Wint-to-pointer-cast} is enabled by default.
9893
9894
d77de738
ML
9895@opindex Wno-pointer-to-int-cast
9896@opindex Wpointer-to-int-cast
ddf6fe37 9897@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
d77de738
ML
9898Suppress warnings from casts from a pointer to an integer type of a
9899different size.
9900
d77de738
ML
9901@opindex Winvalid-pch
9902@opindex Wno-invalid-pch
ddf6fe37 9903@item -Winvalid-pch
d77de738
ML
9904Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9905the search path but cannot be used.
9906
d77de738
ML
9907@opindex Winvalid-utf8
9908@opindex Wno-invalid-utf8
ddf6fe37 9909@item -Winvalid-utf8
d77de738
ML
9910Warn if an invalid UTF-8 character is found.
9911This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
9912is used and turned into error with @option{-pedantic-errors}.
9913
d77de738
ML
9914@opindex Wunicode
9915@opindex Wno-unicode
ddf6fe37 9916@item -Wno-unicode
d77de738
ML
9917Don't diagnose invalid forms of delimited or named escape sequences which are
9918treated as separate tokens. @option{Wunicode} is enabled by default.
9919
d77de738
ML
9920@opindex Wlong-long
9921@opindex Wno-long-long
ddf6fe37 9922@item -Wlong-long
d77de738
ML
9923Warn if @code{long long} type is used. This is enabled by either
9924@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
9925modes. To inhibit the warning messages, use @option{-Wno-long-long}.
9926
d77de738
ML
9927@opindex Wvariadic-macros
9928@opindex Wno-variadic-macros
ddf6fe37 9929@item -Wvariadic-macros
d77de738
ML
9930Warn if variadic macros are used in ISO C90 mode, or if the GNU
9931alternate syntax is used in ISO C99 mode. This is enabled by either
9932@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
9933messages, use @option{-Wno-variadic-macros}.
9934
d77de738
ML
9935@opindex Wvarargs
9936@opindex Wno-varargs
ddf6fe37 9937@item -Wno-varargs
d77de738
ML
9938Do not warn upon questionable usage of the macros used to handle variable
9939arguments like @code{va_start}. These warnings are enabled by default.
9940
d77de738
ML
9941@opindex Wvector-operation-performance
9942@opindex Wno-vector-operation-performance
ddf6fe37 9943@item -Wvector-operation-performance
d77de738
ML
9944Warn if vector operation is not implemented via SIMD capabilities of the
9945architecture. Mainly useful for the performance tuning.
9946Vector operation can be implemented @code{piecewise}, which means that the
9947scalar operation is performed on every vector element;
9948@code{in parallel}, which means that the vector operation is implemented
9949using scalars of wider type, which normally is more performance efficient;
9950and @code{as a single scalar}, which means that vector fits into a
9951scalar type.
9952
d77de738
ML
9953@opindex Wvla
9954@opindex Wno-vla
ddf6fe37 9955@item -Wvla
d77de738
ML
9956Warn if a variable-length array is used in the code.
9957@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
9958the variable-length array.
9959
d77de738
ML
9960@opindex Wvla-larger-than=
9961@opindex Wno-vla-larger-than
ddf6fe37 9962@item -Wvla-larger-than=@var{byte-size}
d77de738
ML
9963If this option is used, the compiler warns for declarations of
9964variable-length arrays whose size is either unbounded, or bounded
9965by an argument that allows the array size to exceed @var{byte-size}
9966bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
9967works, but with variable-length arrays.
9968
9969Note that GCC may optimize small variable-length arrays of a known
9970value into plain arrays, so this warning may not get triggered for
9971such arrays.
9972
9973@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
9974is typically only effective when @option{-ftree-vrp} is active (default
9975for @option{-O2} and above).
9976
9977See also @option{-Walloca-larger-than=@var{byte-size}}.
9978
d77de738 9979@opindex Wno-vla-larger-than
ddf6fe37 9980@item -Wno-vla-larger-than
d77de738
ML
9981Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
9982to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
9983
d77de738 9984@opindex Wno-vla-parameter
ddf6fe37 9985@item -Wvla-parameter
d77de738
ML
9986Warn about redeclarations of functions involving arguments of Variable
9987Length Array types of inconsistent kinds or forms, and enable the detection
9988of out-of-bounds accesses to such parameters by warnings such as
9989@option{-Warray-bounds}.
9990
9991If the first function declaration uses the VLA form the bound specified
9992in the array is assumed to be the minimum number of elements expected to
9993be provided in calls to the function and the maximum number of elements
9994accessed by it. Failing to provide arguments of sufficient size or
9995accessing more than the maximum number of elements may be diagnosed.
9996
9997For example, the warning triggers for the following redeclarations because
9998the first one allows an array of any size to be passed to @code{f} while
9999the second one specifies that the array argument must have at least @code{n}
10000elements. In addition, calling @code{f} with the associated VLA bound
10001parameter in excess of the actual VLA bound triggers a warning as well.
10002
10003@smallexample
10004void f (int n, int[n]);
4ace81b6
SL
10005// warning: argument 2 previously declared as a VLA
10006void f (int, int[]);
d77de738
ML
10007
10008void g (int n)
10009@{
10010 if (n > 4)
10011 return;
10012 int a[n];
4ace81b6
SL
10013 // warning: access to a by f may be out of bounds
10014 f (sizeof a, a);
d77de738
ML
10015 @dots{}
10016@}
10017
10018@end smallexample
10019
10020@option{-Wvla-parameter} is included in @option{-Wall}. The
10021@option{-Warray-parameter} option triggers warnings for similar problems
10022involving ordinary array arguments.
10023
d77de738
ML
10024@opindex Wvolatile-register-var
10025@opindex Wno-volatile-register-var
ddf6fe37 10026@item -Wvolatile-register-var
d77de738
ML
10027Warn if a register variable is declared volatile. The volatile
10028modifier does not inhibit all optimizations that may eliminate reads
10029and/or writes to register variables. This warning is enabled by
10030@option{-Wall}.
10031
d77de738
ML
10032@opindex Wxor-used-as-pow
10033@opindex Wno-xor-used-as-pow
ddf6fe37 10034@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
d77de738
ML
10035Warn about uses of @code{^}, the exclusive or operator, where it appears
10036the user meant exponentiation. Specifically, the warning occurs when the
10037left-hand side is the decimal constant 2 or 10 and the right-hand side
10038is also a decimal constant.
10039
10040In C and C++, @code{^} means exclusive or, whereas in some other languages
10041(e.g. TeX and some versions of BASIC) it means exponentiation.
10042
10043This warning is enabled by default. It can be silenced by converting one
10044of the operands to hexadecimal.
10045
d77de738
ML
10046@opindex Wdisabled-optimization
10047@opindex Wno-disabled-optimization
ddf6fe37 10048@item -Wdisabled-optimization
d77de738
ML
10049Warn if a requested optimization pass is disabled. This warning does
10050not generally indicate that there is anything wrong with your code; it
10051merely indicates that GCC's optimizers are unable to handle the code
10052effectively. Often, the problem is that your code is too big or too
10053complex; GCC refuses to optimize programs when the optimization
10054itself is likely to take inordinate amounts of time.
10055
d77de738
ML
10056@opindex Wpointer-sign
10057@opindex Wno-pointer-sign
ddf6fe37 10058@item -Wpointer-sign @r{(C and Objective-C only)}
d77de738
ML
10059Warn for pointer argument passing or assignment with different signedness.
10060This option is only supported for C and Objective-C@. It is implied by
10061@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
10062@option{-Wno-pointer-sign}.
10063
d77de738
ML
10064@opindex Wstack-protector
10065@opindex Wno-stack-protector
ddf6fe37 10066@item -Wstack-protector
d77de738
ML
10067This option is only active when @option{-fstack-protector} is active. It
10068warns about functions that are not protected against stack smashing.
10069
d77de738
ML
10070@opindex Woverlength-strings
10071@opindex Wno-overlength-strings
ddf6fe37 10072@item -Woverlength-strings
d77de738
ML
10073Warn about string constants that are longer than the ``minimum
10074maximum'' length specified in the C standard. Modern compilers
10075generally allow string constants that are much longer than the
10076standard's minimum limit, but very portable programs should avoid
10077using longer strings.
10078
10079The limit applies @emph{after} string constant concatenation, and does
10080not count the trailing NUL@. In C90, the limit was 509 characters; in
10081C99, it was raised to 4095. C++98 does not specify a normative
10082minimum maximum, so we do not diagnose overlength strings in C++@.
10083
10084This option is implied by @option{-Wpedantic}, and can be disabled with
10085@option{-Wno-overlength-strings}.
10086
d77de738
ML
10087@opindex Wunsuffixed-float-constants
10088@opindex Wno-unsuffixed-float-constants
ddf6fe37 10089@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
d77de738
ML
10090
10091Issue a warning for any floating constant that does not have
10092a suffix. When used together with @option{-Wsystem-headers} it
10093warns about such constants in system header files. This can be useful
10094when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10095from the decimal floating-point extension to C99.
10096
d77de738
ML
10097@opindex Wlto-type-mismatch
10098@opindex Wno-lto-type-mismatch
ddf6fe37 10099@item -Wno-lto-type-mismatch
d77de738
ML
10100
10101During the link-time optimization, do not warn about type mismatches in
10102global declarations from different compilation units.
10103Requires @option{-flto} to be enabled. Enabled by default.
10104
d77de738
ML
10105@opindex Wdesignated-init
10106@opindex Wno-designated-init
ddf6fe37 10107@item -Wno-designated-init @r{(C and Objective-C only)}
d77de738
ML
10108Suppress warnings when a positional initializer is used to initialize
10109a structure that has been marked with the @code{designated_init}
10110attribute.
10111
10112@end table
10113
10114@node Static Analyzer Options
10115@section Options That Control Static Analysis
10116
10117@table @gcctabopt
d77de738
ML
10118@opindex analyzer
10119@opindex fanalyzer
10120@opindex fno-analyzer
ddf6fe37 10121@item -fanalyzer
d77de738
ML
10122This option enables an static analysis of program flow which looks
10123for ``interesting'' interprocedural paths through the
10124code, and issues warnings for problems found on them.
10125
10126This analysis is much more expensive than other GCC warnings.
10127
a90316c6
DM
10128In technical terms, it performs coverage-guided symbolic execution of
10129the code being compiled. It is neither sound nor complete: it can
10130have false positives and false negatives. It is a bug-finding tool,
10131rather than a tool for proving program correctness.
10132
10133The analyzer is only suitable for use on C code in this release.
10134
d77de738
ML
10135Enabling this option effectively enables the following warnings:
10136
10137@gccoptlist{ @gol
10138-Wanalyzer-allocation-size @gol
ce51e843 10139-Wanalyzer-deref-before-check @gol
d77de738
ML
10140-Wanalyzer-double-fclose @gol
10141-Wanalyzer-double-free @gol
10142-Wanalyzer-exposure-through-output-file @gol
10143-Wanalyzer-exposure-through-uninit-copy @gol
10144-Wanalyzer-fd-access-mode-mismatch @gol
10145-Wanalyzer-fd-double-close @gol
10146-Wanalyzer-fd-leak @gol
86a90006
DM
10147-Wanalyzer-fd-phase-mismatch @gol
10148-Wanalyzer-fd-type-mismatch @gol
d77de738
ML
10149-Wanalyzer-fd-use-after-close @gol
10150-Wanalyzer-fd-use-without-check @gol
10151-Wanalyzer-file-leak @gol
10152-Wanalyzer-free-of-non-heap @gol
10153-Wanalyzer-imprecise-fp-arithmetic @gol
ce51e843 10154-Wanalyzer-infinite-recursion @gol
d77de738
ML
10155-Wanalyzer-jump-through-null @gol
10156-Wanalyzer-malloc-leak @gol
10157-Wanalyzer-mismatching-deallocation @gol
10158-Wanalyzer-null-argument @gol
10159-Wanalyzer-null-dereference @gol
10160-Wanalyzer-out-of-bounds @gol
10161-Wanalyzer-possible-null-argument @gol
10162-Wanalyzer-possible-null-dereference @gol
10163-Wanalyzer-putenv-of-auto-var @gol
10164-Wanalyzer-shift-count-negative @gol
10165-Wanalyzer-shift-count-overflow @gol
10166-Wanalyzer-stale-setjmp-buffer @gol
10167-Wanalyzer-unsafe-call-within-signal-handler @gol
10168-Wanalyzer-use-after-free @gol
10169-Wanalyzer-use-of-pointer-in-stale-stack-frame @gol
10170-Wanalyzer-use-of-uninitialized-value @gol
10171-Wanalyzer-va-arg-type-mismatch @gol
10172-Wanalyzer-va-list-exhausted @gol
10173-Wanalyzer-va-list-leak @gol
10174-Wanalyzer-va-list-use-after-va-end @gol
10175-Wanalyzer-write-to-const @gol
10176-Wanalyzer-write-to-string-literal @gol
10177}
10178@ignore
10179-Wanalyzer-tainted-allocation-size @gol
10180-Wanalyzer-tainted-array-index @gol
10181-Wanalyzer-tainted-divisor @gol
10182-Wanalyzer-tainted-offset @gol
10183-Wanalyzer-tainted-size @gol
10184@end ignore
10185
10186This option is only available if GCC was configured with analyzer
10187support enabled.
10188
d77de738
ML
10189@opindex Wanalyzer-too-complex
10190@opindex Wno-analyzer-too-complex
ddf6fe37 10191@item -Wanalyzer-too-complex
d77de738
ML
10192If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10193to attempt to explore the control flow and data flow in the program,
10194but these can be defeated by sufficiently complicated code.
10195
10196By default, the analysis silently stops if the code is too
10197complicated for the analyzer to fully explore and it reaches an internal
10198limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10199
d77de738
ML
10200@opindex Wanalyzer-allocation-size
10201@opindex Wno-analyzer-allocation-size
ddf6fe37 10202@item -Wno-analyzer-allocation-size
4ace81b6
SL
10203This warning requires @option{-fanalyzer}, which enables it;
10204to disable it, use @option{-Wno-analyzer-allocation-size}.
d77de738
ML
10205
10206This diagnostic warns for paths through the code in which a pointer to
10207a buffer is assigned to point at a buffer with a size that is not a
10208multiple of @code{sizeof (*pointer)}.
10209
10210See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10211
ce51e843
ML
10212@opindex Wanalyzer-deref-before-check
10213@opindex Wno-analyzer-deref-before-check
ddf6fe37 10214@item -Wno-analyzer-deref-before-check
ce51e843
ML
10215This warning requires @option{-fanalyzer}, which enables it; use
10216@option{-Wno-analyzer-deref-before-check}
10217to disable it.
10218
10219This diagnostic warns for paths through the code in which a pointer
10220is checked for @code{NULL} *after* it has already been
10221dereferenced, suggesting that the pointer could have been NULL.
10222Such cases suggest that the check for NULL is either redundant,
10223or that it needs to be moved to before the pointer is dereferenced.
10224
10225This diagnostic also considers values passed to a function argument
10226marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10227value, and thus will complain if such values are checked for @code{NULL}
10228after returning from such a function call.
10229
10230This diagnostic is unlikely to be reported when any level of optimization
10231is enabled, as GCC's optimization logic will typically consider such
10232checks for NULL as being redundant, and optimize them away before the
10233analyzer "sees" them. Hence optimization should be disabled when
10234attempting to trigger this diagnostic.
10235
d77de738
ML
10236@opindex Wanalyzer-double-fclose
10237@opindex Wno-analyzer-double-fclose
ddf6fe37 10238@item -Wno-analyzer-double-fclose
d77de738
ML
10239This warning requires @option{-fanalyzer}, which enables it; use
10240@option{-Wno-analyzer-double-fclose} to disable it.
10241
10242This diagnostic warns for paths through the code in which a @code{FILE *}
10243can have @code{fclose} called on it more than once.
10244
10245See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10246
d77de738
ML
10247@opindex Wanalyzer-double-free
10248@opindex Wno-analyzer-double-free
ddf6fe37 10249@item -Wno-analyzer-double-free
d77de738
ML
10250This warning requires @option{-fanalyzer}, which enables it; use
10251@option{-Wno-analyzer-double-free} to disable it.
10252
10253This diagnostic warns for paths through the code in which a pointer
10254can have a deallocator called on it more than once, either @code{free},
10255or a deallocator referenced by attribute @code{malloc}.
10256
10257See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10258
d77de738
ML
10259@opindex Wanalyzer-exposure-through-output-file
10260@opindex Wno-analyzer-exposure-through-output-file
ddf6fe37 10261@item -Wno-analyzer-exposure-through-output-file
d77de738
ML
10262This warning requires @option{-fanalyzer}, which enables it; use
10263@option{-Wno-analyzer-exposure-through-output-file}
10264to disable it.
10265
10266This diagnostic warns for paths through the code in which a
10267security-sensitive value is written to an output file
10268(such as writing a password to a log file).
10269
10270See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10271
d77de738
ML
10272@opindex Wanalyzer-exposure-through-uninit-copy
10273@opindex Wno-analyzer-exposure-through-uninit-copy
ddf6fe37 10274@item -Wanalyzer-exposure-through-uninit-copy
d77de738
ML
10275This warning requires both @option{-fanalyzer} and the use of a plugin
10276to specify a function that copies across a ``trust boundary''. Use
10277@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10278
10279This diagnostic warns for ``infoleaks'' - paths through the code in which
10280uninitialized values are copied across a security boundary
10281(such as code within an OS kernel that copies a partially-initialized
10282struct on the stack to user space).
10283
10284See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10285
d77de738
ML
10286@opindex Wanalyzer-fd-access-mode-mismatch
10287@opindex Wno-analyzer-fd-access-mode-mismatch
ddf6fe37 10288@item -Wno-analyzer-fd-access-mode-mismatch
d77de738
ML
10289This warning requires @option{-fanalyzer}, which enables it; use
10290@option{-Wno-analyzer-fd-access-mode-mismatch}
10291to disable it.
10292
10293This diagnostic warns for paths through code in which a
10294@code{read} on a write-only file descriptor is attempted, or vice versa.
10295
10296This diagnostic also warns for code paths in a which a function with attribute
10297@code{fd_arg_read (N)} is called with a file descriptor opened with
10298@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10299@code{fd_arg_write (N)} is called with a file descriptor opened with
10300@code{O_RDONLY} at referenced argument @var{N}.
10301
d77de738
ML
10302@opindex Wanalyzer-fd-double-close
10303@opindex Wno-analyzer-fd-double-close
ddf6fe37 10304@item -Wno-analyzer-fd-double-close
d77de738
ML
10305This warning requires @option{-fanalyzer}, which enables it; use
10306@option{-Wno-analyzer-fd-double-close}
10307to disable it.
10308
10309This diagnostic warns for paths through code in which a
10310file descriptor can be closed more than once.
10311
10312See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10313
d77de738
ML
10314@opindex Wanalyzer-fd-leak
10315@opindex Wno-analyzer-fd-leak
ddf6fe37 10316@item -Wno-analyzer-fd-leak
d77de738
ML
10317This warning requires @option{-fanalyzer}, which enables it; use
10318@option{-Wno-analyzer-fd-leak}
10319to disable it.
10320
10321This diagnostic warns for paths through code in which an
10322open file descriptor is leaked.
10323
10324See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10325
86a90006
DM
10326@opindex Wanalyzer-fd-phase-mismatch
10327@opindex Wno-analyzer-fd-phase-mismatch
ddf6fe37 10328@item -Wno-analyzer-fd-phase-mismatch
86a90006
DM
10329This warning requires @option{-fanalyzer}, which enables it; use
10330@option{-Wno-analyzer-fd-phase-mismatch}
10331to disable it.
10332
10333This diagnostic warns for paths through code in which an operation is
10334attempted in the wrong phase of a file descriptor's lifetime.
10335For example, it will warn on attempts to call @code{accept} on a stream
10336socket that has not yet had @code{listen} successfully called on it.
10337
10338See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10339
86a90006
DM
10340@opindex Wanalyzer-fd-type-mismatch
10341@opindex Wno-analyzer-fd-type-mismatch
ddf6fe37 10342@item -Wno-analyzer-fd-type-mismatch
86a90006
DM
10343This warning requires @option{-fanalyzer}, which enables it; use
10344@option{-Wno-analyzer-fd-type-mismatch}
10345to disable it.
10346
10347This diagnostic warns for paths through code in which an
10348operation is attempted on the wrong type of file descriptor.
10349For example, it will warn on attempts to use socket operations
10350on a file descriptor obtained via @code{open}, or when attempting
10351to use a stream socket operation on a datagram socket.
10352
d77de738
ML
10353@opindex Wanalyzer-fd-use-after-close
10354@opindex Wno-analyzer-fd-use-after-close
ddf6fe37 10355@item -Wno-analyzer-fd-use-after-close
d77de738
ML
10356This warning requires @option{-fanalyzer}, which enables it; use
10357@option{-Wno-analyzer-fd-use-after-close}
10358to disable it.
10359
10360This diagnostic warns for paths through code in which a
10361read or write is called on a closed file descriptor.
10362
10363This diagnostic also warns for paths through code in which
10364a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10365or @code{fd_arg_write (N)} is called with a closed file descriptor at
10366referenced argument @code{N}.
10367
d77de738
ML
10368@opindex Wanalyzer-fd-use-without-check
10369@opindex Wno-analyzer-fd-use-without-check
ddf6fe37 10370@item -Wno-analyzer-fd-use-without-check
d77de738
ML
10371This warning requires @option{-fanalyzer}, which enables it; use
10372@option{-Wno-analyzer-fd-use-without-check}
10373to disable it.
10374
10375This diagnostic warns for paths through code in which a
10376file descriptor is used without being checked for validity.
10377
10378This diagnostic also warns for paths through code in which
10379a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10380or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10381argument @code{N}, without being checked for validity.
10382
d77de738
ML
10383@opindex Wanalyzer-file-leak
10384@opindex Wno-analyzer-file-leak
ddf6fe37 10385@item -Wno-analyzer-file-leak
d77de738
ML
10386This warning requires @option{-fanalyzer}, which enables it; use
10387@option{-Wno-analyzer-file-leak}
10388to disable it.
10389
10390This diagnostic warns for paths through the code in which a
10391@code{<stdio.h>} @code{FILE *} stream object is leaked.
10392
10393See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10394
d77de738
ML
10395@opindex Wanalyzer-free-of-non-heap
10396@opindex Wno-analyzer-free-of-non-heap
ddf6fe37 10397@item -Wno-analyzer-free-of-non-heap
d77de738
ML
10398This warning requires @option{-fanalyzer}, which enables it; use
10399@option{-Wno-analyzer-free-of-non-heap}
10400to disable it.
10401
10402This diagnostic warns for paths through the code in which @code{free}
10403is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10404
10405See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10406
d77de738
ML
10407@opindex Wanalyzer-imprecise-fp-arithmetic
10408@opindex Wno-analyzer-imprecise-fp-arithmetic
ddf6fe37 10409@item -Wno-analyzer-imprecise-fp-arithmetic
d77de738
ML
10410This warning requires @option{-fanalyzer}, which enables it; use
10411@option{-Wno-analyzer-imprecise-fp-arithmetic}
10412to disable it.
10413
10414This diagnostic warns for paths through the code in which floating-point
10415arithmetic is used in locations where precise computation is needed. This
10416diagnostic only warns on use of floating-point operands inside the
10417calculation of an allocation size at the moment.
10418
ce51e843
ML
10419@opindex Wanalyzer-infinite-recursion
10420@opindex Wno-analyzer-infinite-recursion
ddf6fe37 10421@item -Wno-analyzer-infinite-recursion
ce51e843
ML
10422This warning requires @option{-fanalyzer}, which enables it; use
10423@option{-Wno-analyzer-infinite-recursion} to disable it.
10424
10425This diagnostics warns for paths through the code which appear to
10426lead to infinite recursion.
10427
10428Specifically, when the analyzer "sees" a recursive call, it will compare
10429the state of memory at the entry to the new frame with that at the entry
10430to the previous frame of that function on the stack. The warning is
10431issued if nothing in memory appears to be changing; any changes observed
10432to parameters or globals are assumed to lead to termination of the
10433recursion and thus suppress the warning.
10434
10435This diagnostic is likely to miss cases of infinite recursion that
10436are convered to iteration by the optimizer before the analyzer "sees"
10437them. Hence optimization should be disabled when attempting to trigger
10438this diagnostic.
10439
10440Compare with @option{-Winfinite-recursion}, which provides a similar
10441diagnostic, but is implemented in a different way.
10442
d77de738
ML
10443@opindex Wanalyzer-jump-through-null
10444@opindex Wno-analyzer-jump-through-null
ddf6fe37 10445@item -Wno-analyzer-jump-through-null
d77de738
ML
10446This warning requires @option{-fanalyzer}, which enables it; use
10447@option{-Wno-analyzer-jump-through-null}
10448to disable it.
10449
10450This diagnostic warns for paths through the code in which a @code{NULL}
10451function pointer is called.
10452
d77de738
ML
10453@opindex Wanalyzer-malloc-leak
10454@opindex Wno-analyzer-malloc-leak
ddf6fe37 10455@item -Wno-analyzer-malloc-leak
d77de738
ML
10456This warning requires @option{-fanalyzer}, which enables it; use
10457@option{-Wno-analyzer-malloc-leak}
10458to disable it.
10459
10460This diagnostic warns for paths through the code in which a
10461pointer allocated via an allocator is leaked: either @code{malloc},
10462or a function marked with attribute @code{malloc}.
10463
10464See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10465
d77de738
ML
10466@opindex Wanalyzer-mismatching-deallocation
10467@opindex Wno-analyzer-mismatching-deallocation
ddf6fe37 10468@item -Wno-analyzer-mismatching-deallocation
d77de738
ML
10469This warning requires @option{-fanalyzer}, which enables it; use
10470@option{-Wno-analyzer-mismatching-deallocation}
10471to disable it.
10472
10473This diagnostic warns for paths through the code in which the
10474wrong deallocation function is called on a pointer value, based on
10475which function was used to allocate the pointer value. The diagnostic
10476will warn about mismatches between @code{free}, scalar @code{delete}
10477and vector @code{delete[]}, and those marked as allocator/deallocator
10478pairs using attribute @code{malloc}.
10479
10480See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10481
d77de738
ML
10482@opindex Wanalyzer-out-of-bounds
10483@opindex Wno-analyzer-out-of-bounds
ddf6fe37 10484@item -Wno-analyzer-out-of-bounds
4ace81b6 10485This warning requires @option{-fanalyzer}, which enables it; use
d77de738
ML
10486@option{-Wno-analyzer-out-of-bounds} to disable it.
10487
4ace81b6 10488This diagnostic warns for paths through the code in which a buffer is
d77de738
ML
10489definitely read or written out-of-bounds. The diagnostic applies for
10490cases where the analyzer is able to determine a constant offset and for
10491accesses past the end of a buffer, also a constant capacity. Further,
10492the diagnostic does limited checking for accesses past the end when the
10493offset as well as the capacity is symbolic.
10494
10495See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10496
d77de738
ML
10497@opindex Wanalyzer-possible-null-argument
10498@opindex Wno-analyzer-possible-null-argument
ddf6fe37 10499@item -Wno-analyzer-possible-null-argument
d77de738
ML
10500This warning requires @option{-fanalyzer}, which enables it; use
10501@option{-Wno-analyzer-possible-null-argument} to disable it.
10502
10503This diagnostic warns for paths through the code in which a
10504possibly-NULL value is passed to a function argument marked
10505with @code{__attribute__((nonnull))} as requiring a non-NULL
10506value.
10507
10508See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10509
d77de738
ML
10510@opindex Wanalyzer-possible-null-dereference
10511@opindex Wno-analyzer-possible-null-dereference
ddf6fe37 10512@item -Wno-analyzer-possible-null-dereference
d77de738
ML
10513This warning requires @option{-fanalyzer}, which enables it; use
10514@option{-Wno-analyzer-possible-null-dereference} to disable it.
10515
10516This diagnostic warns for paths through the code in which a
10517possibly-NULL value is dereferenced.
10518
10519See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10520
d77de738
ML
10521@opindex Wanalyzer-null-argument
10522@opindex Wno-analyzer-null-argument
ddf6fe37 10523@item -Wno-analyzer-null-argument
d77de738
ML
10524This warning requires @option{-fanalyzer}, which enables it; use
10525@option{-Wno-analyzer-null-argument} to disable it.
10526
10527This diagnostic warns for paths through the code in which a
10528value known to be NULL is passed to a function argument marked
10529with @code{__attribute__((nonnull))} as requiring a non-NULL
10530value.
10531
10532See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10533
d77de738
ML
10534@opindex Wanalyzer-null-dereference
10535@opindex Wno-analyzer-null-dereference
ddf6fe37 10536@item -Wno-analyzer-null-dereference
d77de738
ML
10537This warning requires @option{-fanalyzer}, which enables it; use
10538@option{-Wno-analyzer-null-dereference} to disable it.
10539
10540This diagnostic warns for paths through the code in which a
10541value known to be NULL is dereferenced.
10542
10543See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10544
d77de738
ML
10545@opindex Wanalyzer-putenv-of-auto-var
10546@opindex Wno-analyzer-putenv-of-auto-var
ddf6fe37 10547@item -Wno-analyzer-putenv-of-auto-var
d77de738
ML
10548This warning requires @option{-fanalyzer}, which enables it; use
10549@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10550
10551This diagnostic warns for paths through the code in which a
10552call to @code{putenv} is passed a pointer to an automatic variable
10553or an on-stack buffer.
10554
10555See @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}.
10556
d77de738
ML
10557@opindex Wanalyzer-shift-count-negative
10558@opindex Wno-analyzer-shift-count-negative
ddf6fe37 10559@item -Wno-analyzer-shift-count-negative
d77de738
ML
10560This warning requires @option{-fanalyzer}, which enables it; use
10561@option{-Wno-analyzer-shift-count-negative} to disable it.
10562
10563This diagnostic warns for paths through the code in which a
10564shift is attempted with a negative count. It is analogous to
10565the @option{-Wshift-count-negative} diagnostic implemented in
10566the C/C++ front ends, but is implemented based on analyzing
10567interprocedural paths, rather than merely parsing the syntax tree.
10568However, the analyzer does not prioritize detection of such paths, so
10569false negatives are more likely relative to other warnings.
10570
d77de738
ML
10571@opindex Wanalyzer-shift-count-overflow
10572@opindex Wno-analyzer-shift-count-overflow
ddf6fe37 10573@item -Wno-analyzer-shift-count-overflow
d77de738
ML
10574This warning requires @option{-fanalyzer}, which enables it; use
10575@option{-Wno-analyzer-shift-count-overflow} to disable it.
10576
10577This diagnostic warns for paths through the code in which a
10578shift is attempted with a count greater than or equal to the
10579precision of the operand's type. It is analogous to
10580the @option{-Wshift-count-overflow} diagnostic implemented in
10581the C/C++ front ends, but is implemented based on analyzing
10582interprocedural paths, rather than merely parsing the syntax tree.
10583However, the analyzer does not prioritize detection of such paths, so
10584false negatives are more likely relative to other warnings.
10585
d77de738
ML
10586@opindex Wanalyzer-stale-setjmp-buffer
10587@opindex Wno-analyzer-stale-setjmp-buffer
ddf6fe37 10588@item -Wno-analyzer-stale-setjmp-buffer
d77de738
ML
10589This warning requires @option{-fanalyzer}, which enables it; use
10590@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10591
10592This diagnostic warns for paths through the code in which
10593@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10594to a @code{setjmp} call in a function that has returned.
10595
10596When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10597location, it records the stack frame. The stack frame becomes invalid
10598when the function containing the @code{setjmp} call returns. Attempting
10599to rewind to it via @code{longjmp} would reference a stack frame that
10600no longer exists, and likely lead to a crash (or worse).
10601
d77de738
ML
10602@opindex Wanalyzer-tainted-allocation-size
10603@opindex Wno-analyzer-tainted-allocation-size
ddf6fe37 10604@item -Wno-analyzer-tainted-allocation-size
d77de738
ML
10605This warning requires both @option{-fanalyzer} and
10606@option{-fanalyzer-checker=taint} to enable it;
10607use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10608
10609This diagnostic warns for paths through the code in which a value
10610that could be under an attacker's control is used as the size
10611of an allocation without being sanitized, so that an attacker could
10612inject an excessively large allocation and potentially cause a denial
10613of service attack.
10614
10615See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10616
ce51e843
ML
10617@opindex Wanalyzer-tainted-assertion
10618@opindex Wno-analyzer-tainted-assertion
ddf6fe37 10619@item -Wno-analyzer-tainted-assertion
ce51e843
ML
10620
10621This warning requires both @option{-fanalyzer} and
10622@option{-fanalyzer-checker=taint} to enable it;
10623use @option{-Wno-analyzer-tainted-assertion} to disable it.
10624
10625This diagnostic warns for paths through the code in which a value
10626that could be under an attacker's control is used as part of a
10627condition without being first sanitized, and that condition guards a
10628call to a function marked with attribute @code{noreturn}
10629(such as the function @code{__builtin_unreachable}). Such functions
10630typically indicate abnormal termination of the program, such as for
10631assertion failure handlers. For example:
10632
10633@smallexample
10634assert (some_tainted_value < SOME_LIMIT);
10635@end smallexample
10636
10637In such cases:
10638
10639@itemize
10640@item
10641when assertion-checking is enabled: an attacker could trigger
10642a denial of service by injecting an assertion failure
10643
10644@item
10645when assertion-checking is disabled, such as by defining @code{NDEBUG},
10646an attacker could inject data that subverts the process, since it
10647presumably violates a precondition that is being assumed by the code.
10648
10649@end itemize
10650
10651Note that when assertion-checking is disabled, the assertions are
10652typically removed by the preprocessor before the analyzer has a chance
10653to "see" them, so this diagnostic can only generate warnings on builds
10654in which assertion-checking is enabled.
10655
10656For the purpose of this warning, any function marked with attribute
10657@code{noreturn} is considered as a possible assertion failure
10658handler, including @code{__builtin_unreachable}. Note that these functions
10659are sometimes removed by the optimizer before the analyzer "sees" them.
10660Hence optimization should be disabled when attempting to trigger this
10661diagnostic.
10662
10663See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10664
10665The warning can also report problematic constructions such as
10666
10667@smallexample
10668switch (some_tainted_value) @{
10669case 0:
10670 /* [...etc; various valid cases omitted...] */
10671 break;
10672
10673default:
10674 __builtin_unreachable (); /* BUG: attacker can trigger this */
10675@}
10676@end smallexample
10677
10678despite the above not being an assertion failure, strictly speaking.
10679
d77de738
ML
10680@opindex Wanalyzer-tainted-array-index
10681@opindex Wno-analyzer-tainted-array-index
ddf6fe37 10682@item -Wno-analyzer-tainted-array-index
d77de738
ML
10683This warning requires both @option{-fanalyzer} and
10684@option{-fanalyzer-checker=taint} to enable it;
10685use @option{-Wno-analyzer-tainted-array-index} to disable it.
10686
10687This diagnostic warns for paths through the code in which a value
10688that could be under an attacker's control is used as the index
10689of an array access without being sanitized, so that an attacker
10690could inject an out-of-bounds access.
10691
10692See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10693
d77de738
ML
10694@opindex Wanalyzer-tainted-divisor
10695@opindex Wno-analyzer-tainted-divisor
ddf6fe37 10696@item -Wno-analyzer-tainted-divisor
d77de738
ML
10697This warning requires both @option{-fanalyzer} and
10698@option{-fanalyzer-checker=taint} to enable it;
10699use @option{-Wno-analyzer-tainted-divisor} to disable it.
10700
10701This diagnostic warns for paths through the code in which a value
10702that could be under an attacker's control is used as the divisor
10703in a division or modulus operation without being sanitized, so that
10704an attacker could inject a division-by-zero.
10705
10706See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10707
d77de738
ML
10708@opindex Wanalyzer-tainted-offset
10709@opindex Wno-analyzer-tainted-offset
ddf6fe37 10710@item -Wno-analyzer-tainted-offset
d77de738
ML
10711This warning requires both @option{-fanalyzer} and
10712@option{-fanalyzer-checker=taint} to enable it;
10713use @option{-Wno-analyzer-tainted-offset} to disable it.
10714
10715This diagnostic warns for paths through the code in which a value
10716that could be under an attacker's control is used as a pointer offset
10717without being sanitized, so that an attacker could inject an out-of-bounds
10718access.
10719
10720See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10721
d77de738
ML
10722@opindex Wanalyzer-tainted-size
10723@opindex Wno-analyzer-tainted-size
ddf6fe37 10724@item -Wno-analyzer-tainted-size
d77de738
ML
10725This warning requires both @option{-fanalyzer} and
10726@option{-fanalyzer-checker=taint} to enable it;
10727use @option{-Wno-analyzer-tainted-size} to disable it.
10728
10729This diagnostic warns for paths through the code in which a value
10730that could be under an attacker's control is used as the size of
10731an operation such as @code{memset} without being sanitized, so that an
10732attacker could inject an out-of-bounds access.
10733
10734See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10735
d77de738
ML
10736@opindex Wanalyzer-unsafe-call-within-signal-handler
10737@opindex Wno-analyzer-unsafe-call-within-signal-handler
ddf6fe37 10738@item -Wno-analyzer-unsafe-call-within-signal-handler
d77de738
ML
10739This warning requires @option{-fanalyzer}, which enables it; use
10740@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10741
10742This diagnostic warns for paths through the code in which a
10743function known to be async-signal-unsafe (such as @code{fprintf}) is
10744called from a signal handler.
10745
10746See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10747
d77de738
ML
10748@opindex Wanalyzer-use-after-free
10749@opindex Wno-analyzer-use-after-free
ddf6fe37 10750@item -Wno-analyzer-use-after-free
d77de738
ML
10751This warning requires @option{-fanalyzer}, which enables it; use
10752@option{-Wno-analyzer-use-after-free} to disable it.
10753
10754This diagnostic warns for paths through the code in which a
10755pointer is used after a deallocator is called on it: either @code{free},
10756or a deallocator referenced by attribute @code{malloc}.
10757
10758See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
10759
d77de738
ML
10760@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
10761@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
ddf6fe37 10762@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
d77de738
ML
10763This warning requires @option{-fanalyzer}, which enables it; use
10764@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
10765to disable it.
10766
10767This diagnostic warns for paths through the code in which a pointer
10768is dereferenced that points to a variable in a stale stack frame.
10769
d77de738
ML
10770@opindex Wanalyzer-va-arg-type-mismatch
10771@opindex Wno-analyzer-va-arg-type-mismatch
ddf6fe37 10772@item -Wno-analyzer-va-arg-type-mismatch
d77de738
ML
10773This warning requires @option{-fanalyzer}, which enables it; use
10774@option{-Wno-analyzer-va-arg-type-mismatch}
10775to disable it.
10776
10777This diagnostic warns for interprocedural paths through the code for which
10778the analyzer detects an attempt to use @code{va_arg} to extract a value
10779passed to a variadic call, but uses a type that does not match that of
10780the expression passed to the call.
10781
10782See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
10783
d77de738
ML
10784@opindex Wanalyzer-va-list-exhausted
10785@opindex Wno-analyzer-va-list-exhausted
ddf6fe37 10786@item -Wno-analyzer-va-list-exhausted
d77de738
ML
10787This warning requires @option{-fanalyzer}, which enables it; use
10788@option{-Wno-analyzer-va-list-exhausted}
10789to disable it.
10790
10791This diagnostic warns for interprocedural paths through the code for which
10792the analyzer detects an attempt to use @code{va_arg} to access the next
10793value passed to a variadic call, but all of the values in the
10794@code{va_list} have already been consumed.
10795
10796See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
10797
d77de738
ML
10798@opindex Wanalyzer-va-list-leak
10799@opindex Wno-analyzer-va-list-leak
ddf6fe37 10800@item -Wno-analyzer-va-list-leak
d77de738
ML
10801This warning requires @option{-fanalyzer}, which enables it; use
10802@option{-Wno-analyzer-va-list-leak}
10803to disable it.
10804
10805This diagnostic warns for interprocedural paths through the code for which
10806the analyzer detects that @code{va_start} or @code{va_copy} has been called
10807on a @code{va_list} without a corresponding call to @code{va_end}.
10808
d77de738
ML
10809@opindex Wanalyzer-va-list-use-after-va-end
10810@opindex Wno-analyzer-va-list-use-after-va-end
ddf6fe37 10811@item -Wno-analyzer-va-list-use-after-va-end
d77de738
ML
10812This warning requires @option{-fanalyzer}, which enables it; use
10813@option{-Wno-analyzer-va-list-use-after-va-end}
10814to disable it.
10815
10816This diagnostic warns for interprocedural paths through the code for which
10817the analyzer detects an attempt to use a @code{va_list} after
10818@code{va_end} has been called on it.
10819@code{va_list}.
10820
d77de738
ML
10821@opindex Wanalyzer-write-to-const
10822@opindex Wno-analyzer-write-to-const
ddf6fe37 10823@item -Wno-analyzer-write-to-const
d77de738
ML
10824This warning requires @option{-fanalyzer}, which enables it; use
10825@option{-Wno-analyzer-write-to-const}
10826to disable it.
10827
10828This diagnostic warns for paths through the code in which the analyzer
10829detects an attempt to write through a pointer to a @code{const} object.
10830However, the analyzer does not prioritize detection of such paths, so
10831false negatives are more likely relative to other warnings.
10832
d77de738
ML
10833@opindex Wanalyzer-write-to-string-literal
10834@opindex Wno-analyzer-write-to-string-literal
ddf6fe37 10835@item -Wno-analyzer-write-to-string-literal
d77de738
ML
10836This warning requires @option{-fanalyzer}, which enables it; use
10837@option{-Wno-analyzer-write-to-string-literal}
10838to disable it.
10839
10840This diagnostic warns for paths through the code in which the analyzer
10841detects an attempt to write through a pointer to a string literal.
10842However, the analyzer does not prioritize detection of such paths, so
10843false negatives are more likely relative to other warnings.
10844
d77de738
ML
10845@opindex Wanalyzer-use-of-uninitialized-value
10846@opindex Wno-analyzer-use-of-uninitialized-value
ddf6fe37 10847@item -Wno-analyzer-use-of-uninitialized-value
d77de738
ML
10848This warning requires @option{-fanalyzer}, which enables it; use
10849@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
10850
10851This diagnostic warns for paths through the code in which an uninitialized
10852value is used.
10853
10854See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
10855
10856@end table
10857
10858The analyzer has hardcoded knowledge about the behavior of the following
10859memory-management functions:
10860
10861@itemize @bullet
10862@item @code{alloca}
10863@item The built-in functions @code{__builtin_alloc},
10864@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
10865@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
10866@code{__builtin_memcpy_chk}, @code{__builtin_memset},
10867@code{__builtin_memset_chk}, @code{__builtin_realloc},
10868@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
10869@item @code{calloc}
10870@item @code{free}
10871@item @code{malloc}
10872@item @code{memset}
10873@item @code{operator delete}
10874@item @code{operator delete []}
10875@item @code{operator new}
10876@item @code{operator new []}
10877@item @code{realloc}
10878@item @code{strdup}
10879@item @code{strndup}
10880@end itemize
10881
4ace81b6 10882@noindent
d77de738
ML
10883of the following functions for working with file descriptors:
10884
10885@itemize @bullet
10886@item @code{open}
10887@item @code{close}
10888@item @code{creat}
10889@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 10890@item @code{isatty}
d77de738
ML
10891@item @code{pipe}, and @code{pipe2}
10892@item @code{read}
10893@item @code{write}
86a90006 10894@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
10895@end itemize
10896
4ace81b6 10897@noindent
d77de738
ML
10898of the following functions for working with @code{<stdio.h>} streams:
10899@itemize @bullet
10900@item The built-in functions @code{__builtin_fprintf},
10901@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
10902@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
10903@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
10904@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
10905@code{__builtin_printf_unlocked}, @code{__builtin_putc},
10906@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
10907@code{__builtin_putc_unlocked}, @code{__builtin_puts},
10908@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
10909@code{__builtin_vprintf}
10910@item @code{fopen}
10911@item @code{fclose}
78a17f44 10912@item @code{ferror}
d77de738
ML
10913@item @code{fgets}
10914@item @code{fgets_unlocked}
78a17f44 10915@item @code{fileno}
d77de738 10916@item @code{fread}
78a17f44 10917@item @code{getc}
d77de738
ML
10918@item @code{getchar}
10919@item @code{fprintf}
10920@item @code{printf}
10921@item @code{fwrite}
10922@end itemize
10923
4ace81b6 10924@noindent
d77de738
ML
10925and of the following functions:
10926
10927@itemize @bullet
10928@item The built-in functions @code{__builtin_expect},
10929@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
10930@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
10931@code{__builtin_strlen}, @code{__builtin_va_copy}, and
10932@code{__builtin_va_start}
10933@item The GNU extensions @code{error} and @code{error_at_line}
10934@item @code{getpass}
10935@item @code{longjmp}
10936@item @code{putenv}
10937@item @code{setjmp}
10938@item @code{siglongjmp}
10939@item @code{signal}
10940@item @code{sigsetjmp}
10941@item @code{strchr}
10942@item @code{strlen}
10943@end itemize
10944
10945In addition, various functions with an @code{__analyzer_} prefix have
10946special meaning to the analyzer, described in the GCC Internals manual.
10947
10948Pertinent parameters for controlling the exploration are:
4ace81b6
SL
10949@itemize @bullet
10950@item @option{--param analyzer-bb-explosion-factor=@var{value}}
10951@item @option{--param analyzer-max-enodes-per-program-point=@var{value}}
10952@item @option{--param analyzer-max-recursion-depth=@var{value}}
10953@item @option{--param analyzer-min-snodes-for-call-summary=@var{value}}
10954@end itemize
d77de738
ML
10955
10956The following options control the analyzer.
10957
10958@table @gcctabopt
10959
d77de738
ML
10960@opindex fanalyzer-call-summaries
10961@opindex fno-analyzer-call-summaries
ddf6fe37 10962@item -fanalyzer-call-summaries
d77de738
ML
10963Simplify interprocedural analysis by computing the effect of certain calls,
10964rather than exploring all paths through the function from callsite to each
10965possible return.
10966
10967If enabled, call summaries are only used for functions with more than one
10968call site, and that are sufficiently complicated (as per
10969@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
10970
d77de738 10971@opindex fanalyzer-checker
ddf6fe37 10972@item -fanalyzer-checker=@var{name}
d77de738
ML
10973Restrict the analyzer to run just the named checker, and enable it.
10974
10975Some checkers are disabled by default (even with @option{-fanalyzer}),
10976such as the @code{taint} checker that implements
10977@option{-Wanalyzer-tainted-array-index}, and this option is required
10978to enable them.
10979
10980@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
10981following warnings from @option{-fanalyzer}:
10982
10983@gccoptlist{ @gol
ce51e843 10984-Wanalyzer-deref-before-check @gol
d77de738
ML
10985-Wanalyzer-double-fclose @gol
10986-Wanalyzer-double-free @gol
10987-Wanalyzer-exposure-through-output-file @gol
10988-Wanalyzer-fd-access-mode-mismatch @gol
10989-Wanalyzer-fd-double-close @gol
10990-Wanalyzer-fd-leak @gol
10991-Wanalyzer-fd-use-after-close @gol
10992-Wanalyzer-fd-use-without-check @gol
10993-Wanalyzer-file-leak @gol
10994-Wanalyzer-free-of-non-heap @gol
10995-Wanalyzer-malloc-leak @gol
10996-Wanalyzer-mismatching-deallocation @gol
10997-Wanalyzer-null-argument @gol
10998-Wanalyzer-null-dereference @gol
10999-Wanalyzer-possible-null-argument @gol
11000-Wanalyzer-possible-null-dereference @gol
11001-Wanalyzer-unsafe-call-within-signal-handler @gol
11002-Wanalyzer-use-after-free @gol
11003-Wanalyzer-va-list-leak @gol
11004-Wanalyzer-va-list-use-after-va-end @gol
11005}
11006
d77de738
ML
11007@opindex fanalyzer-feasibility
11008@opindex fno-analyzer-feasibility
ddf6fe37 11009@item -fno-analyzer-feasibility
d77de738
ML
11010This option is intended for analyzer developers.
11011
11012By default the analyzer verifies that there is a feasible control flow path
11013for each diagnostic it emits: that the conditions that hold are not mutually
11014exclusive. Diagnostics for which no feasible path can be found are rejected.
11015This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
11016debugging issues in this code.
11017
d77de738
ML
11018@opindex fanalyzer-fine-grained
11019@opindex fno-analyzer-fine-grained
ddf6fe37 11020@item -fanalyzer-fine-grained
d77de738
ML
11021This option is intended for analyzer developers.
11022
11023Internally the analyzer builds an ``exploded graph'' that combines
11024control flow graphs with data flow information.
11025
11026By default, an edge in this graph can contain the effects of a run
11027of multiple statements within a basic block. With
11028@option{-fanalyzer-fine-grained}, each statement gets its own edge.
11029
d77de738
ML
11030@opindex fanalyzer-show-duplicate-count
11031@opindex fno-analyzer-show-duplicate-count
ddf6fe37 11032@item -fanalyzer-show-duplicate-count
d77de738
ML
11033This option is intended for analyzer developers: if multiple diagnostics
11034have been detected as being duplicates of each other, it emits a note when
11035reporting the best diagnostic, giving the number of additional diagnostics
11036that were suppressed by the deduplication logic.
11037
d77de738
ML
11038@opindex fanalyzer-state-merge
11039@opindex fno-analyzer-state-merge
ddf6fe37 11040@item -fno-analyzer-state-merge
d77de738
ML
11041This option is intended for analyzer developers.
11042
11043By default the analyzer attempts to simplify analysis by merging
11044sufficiently similar states at each program point as it builds its
11045``exploded graph''. With @option{-fno-analyzer-state-merge} this
11046merging can be suppressed, for debugging state-handling issues.
11047
d77de738
ML
11048@opindex fanalyzer-state-purge
11049@opindex fno-analyzer-state-purge
ddf6fe37 11050@item -fno-analyzer-state-purge
d77de738
ML
11051This option is intended for analyzer developers.
11052
11053By default the analyzer attempts to simplify analysis by purging
11054aspects of state at a program point that appear to no longer be relevant
11055e.g. the values of locals that aren't accessed later in the function
11056and which aren't relevant to leak analysis.
11057
11058With @option{-fno-analyzer-state-purge} this purging of state can
11059be suppressed, for debugging state-handling issues.
11060
8f636915
DM
11061@opindex fanalyzer-suppress-followups
11062@opindex fno-analyzer-suppress-followups
f33d7a88 11063@item -fno-analyzer-suppress-followups
8f636915
DM
11064This option is intended for analyzer developers.
11065
11066By default the analyzer will stop exploring an execution path after
11067encountering certain diagnostics, in order to avoid potentially issuing a
11068cascade of follow-up diagnostics.
11069
11070The diagnostics that terminate analysis along a path are:
11071
11072@itemize
11073@item @option{-Wanalyzer-null-argument}
11074@item @option{-Wanalyzer-null-dereference}
11075@item @option{-Wanalyzer-use-after-free}
11076@item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame}
11077@item @option{-Wanalyzer-use-of-uninitialized-value}
11078@end itemize
11079
11080With @option{-fno-analyzer-suppress-followups} the analyzer will
11081continue to explore such paths even after such diagnostics, which may
11082be helpful for debugging issues in the analyzer, or for microbenchmarks
11083for detecting undefined behavior.
11084
d77de738
ML
11085@opindex fanalyzer-transitivity
11086@opindex fno-analyzer-transitivity
ddf6fe37 11087@item -fanalyzer-transitivity
d77de738
ML
11088This option enables transitivity of constraints within the analyzer.
11089
d77de738
ML
11090@opindex fanalyzer-undo-inlining
11091@opindex fno-analyzer-undo-inlining
ddf6fe37 11092@item -fno-analyzer-undo-inlining
d77de738
ML
11093This option is intended for analyzer developers.
11094
11095@option{-fanalyzer} runs relatively late compared to other code analysis
11096tools, and some optimizations have already been applied to the code. In
11097particular function inlining may have occurred, leading to the
11098interprocedural execution paths emitted by the analyzer containing
11099function frames that don't correspond to those in the original source
11100code.
11101
11102By default the analyzer attempts to reconstruct the original function
11103frames, and to emit events showing the inlined calls.
11104
11105With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11106the original frame information can be be disabled, which may be of help
11107when debugging issues in the analyzer.
11108
11109@item -fanalyzer-verbose-edges
11110This option is intended for analyzer developers. It enables more
11111verbose, lower-level detail in the descriptions of control flow
11112within diagnostic paths.
11113
11114@item -fanalyzer-verbose-state-changes
11115This option is intended for analyzer developers. It enables more
11116verbose, lower-level detail in the descriptions of events relating
11117to state machines within diagnostic paths.
11118
11119@item -fanalyzer-verbosity=@var{level}
11120This option controls the complexity of the control flow paths that are
11121emitted for analyzer diagnostics.
11122
11123The @var{level} can be one of:
11124
11125@table @samp
11126@item 0
11127At this level, interprocedural call and return events are displayed,
11128along with the most pertinent state-change events relating to
11129a diagnostic. For example, for a double-@code{free} diagnostic,
11130both calls to @code{free} will be shown.
11131
11132@item 1
11133As per the previous level, but also show events for the entry
11134to each function.
11135
11136@item 2
11137As per the previous level, but also show events relating to
11138control flow that are significant to triggering the issue
11139(e.g. ``true path taken'' at a conditional).
11140
11141This level is the default.
11142
11143@item 3
11144As per the previous level, but show all control flow events, not
11145just significant ones.
11146
11147@item 4
11148This level is intended for analyzer developers; it adds various
11149other events intended for debugging the analyzer.
11150
11151@end table
11152
d77de738 11153@opindex fdump-analyzer
ddf6fe37 11154@item -fdump-analyzer
d77de738
ML
11155Dump internal details about what the analyzer is doing to
11156@file{@var{file}.analyzer.txt}.
4ace81b6 11157@option{-fdump-analyzer-stderr} overrides this option.
d77de738 11158
d77de738 11159@opindex fdump-analyzer-stderr
ddf6fe37 11160@item -fdump-analyzer-stderr
d77de738
ML
11161Dump internal details about what the analyzer is doing to stderr.
11162This option overrides @option{-fdump-analyzer}.
11163
d77de738 11164@opindex fdump-analyzer-callgraph
ddf6fe37 11165@item -fdump-analyzer-callgraph
d77de738
ML
11166Dump a representation of the call graph suitable for viewing with
11167GraphViz to @file{@var{file}.callgraph.dot}.
11168
d77de738 11169@opindex fdump-analyzer-exploded-graph
ddf6fe37 11170@item -fdump-analyzer-exploded-graph
d77de738
ML
11171Dump a representation of the ``exploded graph'' suitable for viewing with
11172GraphViz to @file{@var{file}.eg.dot}.
11173Nodes are color-coded based on state-machine states to emphasize
11174state changes.
11175
d77de738 11176@opindex dump-analyzer-exploded-nodes
ddf6fe37 11177@item -fdump-analyzer-exploded-nodes
d77de738
ML
11178Emit diagnostics showing where nodes in the ``exploded graph'' are
11179in relation to the program source.
11180
d77de738 11181@opindex dump-analyzer-exploded-nodes-2
ddf6fe37 11182@item -fdump-analyzer-exploded-nodes-2
d77de738
ML
11183Dump a textual representation of the ``exploded graph'' to
11184@file{@var{file}.eg.txt}.
11185
d77de738 11186@opindex dump-analyzer-exploded-nodes-3
ddf6fe37 11187@item -fdump-analyzer-exploded-nodes-3
d77de738
ML
11188Dump a textual representation of the ``exploded graph'' to
11189one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11190This is typically a large number of dump files.
11191
d77de738 11192@opindex fdump-analyzer-exploded-paths
ddf6fe37 11193@item -fdump-analyzer-exploded-paths
d77de738
ML
11194Dump a textual representation of the ``exploded path'' for each
11195diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11196
d77de738 11197@opindex dump-analyzer-feasibility
ddf6fe37 11198@item -fdump-analyzer-feasibility
d77de738
ML
11199Dump internal details about the analyzer's search for feasible paths.
11200The details are written in a form suitable for viewing with GraphViz
11201to filenames of the form @file{@var{file}.*.fg.dot},
11202@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11203
d77de738 11204@opindex fdump-analyzer-json
ddf6fe37 11205@item -fdump-analyzer-json
d77de738
ML
11206Dump a compressed JSON representation of analyzer internals to
11207@file{@var{file}.analyzer.json.gz}. The precise format is subject
11208to change.
11209
d77de738 11210@opindex fdump-analyzer-state-purge
ddf6fe37 11211@item -fdump-analyzer-state-purge
d77de738
ML
11212As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11213``supergraph'' suitable for viewing with GraphViz, but annotate the
11214graph with information on what state will be purged at each node.
11215The graph is written to @file{@var{file}.state-purge.dot}.
11216
d77de738 11217@opindex fdump-analyzer-supergraph
ddf6fe37 11218@item -fdump-analyzer-supergraph
d77de738
ML
11219Dump representations of the ``supergraph'' suitable for viewing with
11220GraphViz to @file{@var{file}.supergraph.dot} and to
11221@file{@var{file}.supergraph-eg.dot}. These show all of the
11222control flow graphs in the program, with interprocedural edges for
11223calls and returns. The second dump contains annotations showing nodes
11224in the ``exploded graph'' and diagnostics associated with them.
11225
d77de738 11226@opindex fdump-analyzer-untracked
ddf6fe37 11227@item -fdump-analyzer-untracked
d77de738
ML
11228Emit custom warnings with internal details intended for analyzer developers.
11229
11230@end table
11231
11232@node Debugging Options
11233@section Options for Debugging Your Program
11234@cindex options, debugging
11235@cindex debugging information options
11236
11237To tell GCC to emit extra information for use by a debugger, in almost
11238all cases you need only to add @option{-g} to your other options. Some debug
11239formats can co-exist (like DWARF with CTF) when each of them is enabled
11240explicitly by adding the respective command line option to your other options.
11241
11242GCC allows you to use @option{-g} with
11243@option{-O}. The shortcuts taken by optimized code may occasionally
11244be surprising: some variables you declared may not exist
11245at all; flow of control may briefly move where you did not expect it;
11246some statements may not be executed because they compute constant
11247results or their values are already at hand; some statements may
11248execute in different places because they have been moved out of loops.
11249Nevertheless it is possible to debug optimized output. This makes
11250it reasonable to use the optimizer for programs that might have bugs.
11251
11252If you are not using some other optimization option, consider
11253using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11254With no @option{-O} option at all, some compiler passes that collect
11255information useful for debugging do not run at all, so that
11256@option{-Og} may result in a better debugging experience.
11257
11258@table @gcctabopt
d77de738 11259@opindex g
ddf6fe37 11260@item -g
d77de738
ML
11261Produce debugging information in the operating system's native format
11262(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11263information.
11264
11265On most systems that use stabs format, @option{-g} enables use of extra
11266debugging information that only GDB can use; this extra information
11267makes debugging work better in GDB but probably makes other debuggers
11268crash or refuse to read the program. If you want to control for certain whether
11269to generate the extra information, use @option{-gvms} (see below).
11270
d77de738 11271@opindex ggdb
ddf6fe37 11272@item -ggdb
d77de738
ML
11273Produce debugging information for use by GDB@. This means to use the
11274most expressive format available (DWARF, stabs, or the native format
11275if neither of those are supported), including GDB extensions if at all
11276possible.
11277
ddf6fe37 11278@opindex gdwarf
d77de738
ML
11279@item -gdwarf
11280@itemx -gdwarf-@var{version}
d77de738
ML
11281Produce debugging information in DWARF format (if that is supported).
11282The value of @var{version} may be either 2, 3, 4 or 5; the default
11283version for most targets is 5 (with the exception of VxWorks, TPF and
11284Darwin/Mac OS X, which default to version 2, and AIX, which defaults
11285to version 4).
11286
11287Note that with DWARF Version 2, some ports require and always
11288use some non-conflicting DWARF 3 extensions in the unwind tables.
11289
11290Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11291for maximum benefit. Version 5 requires GDB 8.0 or higher.
11292
11293GCC no longer supports DWARF Version 1, which is substantially
11294different than Version 2 and later. For historical reasons, some
11295other DWARF-related options such as
11296@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11297in their names, but apply to all currently-supported versions of DWARF.
11298
d77de738 11299@opindex gbtf
ddf6fe37 11300@item -gbtf
d77de738
ML
11301Request BTF debug information. BTF is the default debugging format for the
11302eBPF target. On other targets, like x86, BTF debug information can be
11303generated along with DWARF debug information when both of the debug formats are
11304enabled explicitly via their respective command line options.
11305
ddf6fe37 11306@opindex gctf
d77de738
ML
11307@item -gctf
11308@itemx -gctf@var{level}
d77de738
ML
11309Request CTF debug information and use level to specify how much CTF debug
11310information should be produced. If @option{-gctf} is specified
11311without a value for level, the default level of CTF debug information is 2.
11312
11313CTF debug information can be generated along with DWARF debug information when
11314both of the debug formats are enabled explicitly via their respective command
11315line options.
11316
11317Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11318negates @option{-gctf}.
11319
11320Level 1 produces CTF information for tracebacks only. This includes callsite
11321information, but does not include type information.
11322
11323Level 2 produces type information for entities (functions, data objects etc.)
11324at file-scope or global-scope only.
11325
d77de738 11326@opindex gvms
ddf6fe37 11327@item -gvms
d77de738
ML
11328Produce debugging information in Alpha/VMS debug format (if that is
11329supported). This is the format used by DEBUG on Alpha/VMS systems.
11330
11331@item -g@var{level}
11332@itemx -ggdb@var{level}
11333@itemx -gvms@var{level}
11334Request debugging information and also use @var{level} to specify how
11335much information. The default level is 2.
11336
11337Level 0 produces no debug information at all. Thus, @option{-g0} negates
11338@option{-g}.
11339
11340Level 1 produces minimal information, enough for making backtraces in
11341parts of the program that you don't plan to debug. This includes
11342descriptions of functions and external variables, and line number
11343tables, but no information about local variables.
11344
11345Level 3 includes extra information, such as all the macro definitions
11346present in the program. Some debuggers support macro expansion when
11347you use @option{-g3}.
11348
11349If you use multiple @option{-g} options, with or without level numbers,
11350the last such option is the one that is effective.
11351
11352@option{-gdwarf} does not accept a concatenated debug level, to avoid
11353confusion with @option{-gdwarf-@var{level}}.
11354Instead use an additional @option{-g@var{level}} option to change the
11355debug level for DWARF.
11356
d77de738
ML
11357@opindex feliminate-unused-debug-symbols
11358@opindex fno-eliminate-unused-debug-symbols
ddf6fe37 11359@item -fno-eliminate-unused-debug-symbols
d77de738
ML
11360By default, no debug information is produced for symbols that are not actually
11361used. Use this option if you want debug information for all symbols.
11362
d77de738 11363@opindex femit-class-debug-always
ddf6fe37 11364@item -femit-class-debug-always
d77de738
ML
11365Instead of emitting debugging information for a C++ class in only one
11366object file, emit it in all object files using the class. This option
11367should be used only with debuggers that are unable to handle the way GCC
11368normally emits debugging information for classes because using this
11369option increases the size of debugging information by as much as a
11370factor of two.
11371
d77de738
ML
11372@opindex fmerge-debug-strings
11373@opindex fno-merge-debug-strings
ddf6fe37 11374@item -fno-merge-debug-strings
d77de738
ML
11375Direct the linker to not merge together strings in the debugging
11376information that are identical in different object files. Merging is
11377not supported by all assemblers or linkers. Merging decreases the size
11378of the debug information in the output file at the cost of increasing
11379link processing time. Merging is enabled by default.
11380
d77de738 11381@opindex fdebug-prefix-map
ddf6fe37 11382@item -fdebug-prefix-map=@var{old}=@var{new}
d77de738
ML
11383When compiling files residing in directory @file{@var{old}}, record
11384debugging information describing them as if the files resided in
11385directory @file{@var{new}} instead. This can be used to replace a
11386build-time path with an install-time path in the debug info. It can
11387also be used to change an absolute path to a relative path by using
11388@file{.} for @var{new}. This can give more reproducible builds, which
11389are location independent, but may require an extra command to tell GDB
2eb0191a
JJ
11390where to find the source files. See also @option{-ffile-prefix-map}
11391and @option{-fcanon-prefix-map}.
d77de738 11392
d77de738 11393@opindex fvar-tracking
ddf6fe37 11394@item -fvar-tracking
d77de738
ML
11395Run variable tracking pass. It computes where variables are stored at each
11396position in code. Better debugging information is then generated
11397(if the debugging information format supports this information).
11398
11399It is enabled by default when compiling with optimization (@option{-Os},
11400@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11401the debug info format supports it.
11402
d77de738
ML
11403@opindex fvar-tracking-assignments
11404@opindex fno-var-tracking-assignments
ddf6fe37 11405@item -fvar-tracking-assignments
d77de738
ML
11406Annotate assignments to user variables early in the compilation and
11407attempt to carry the annotations over throughout the compilation all the
11408way to the end, in an attempt to improve debug information while
11409optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11410
11411It can be enabled even if var-tracking is disabled, in which case
11412annotations are created and maintained, but discarded at the end.
11413By default, this flag is enabled together with @option{-fvar-tracking},
11414except when selective scheduling is enabled.
11415
d77de738 11416@opindex gsplit-dwarf
ddf6fe37 11417@item -gsplit-dwarf
d77de738
ML
11418If DWARF debugging information is enabled, separate as much debugging
11419information as possible into a separate output file with the extension
11420@file{.dwo}. This option allows the build system to avoid linking files with
11421debug information. To be useful, this option requires a debugger capable of
11422reading @file{.dwo} files.
11423
d77de738
ML
11424@opindex gdwarf32
11425@opindex gdwarf64
ddf6fe37
AA
11426@item -gdwarf32
11427@itemx -gdwarf64
d77de738
ML
11428If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11429the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11430DWARF format. The default is target specific, on most targets it is
11431@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11432can't support more than 2GiB of debug information in any of the DWARF
11433debug information sections. The 64-bit DWARF format allows larger debug
11434information and might not be well supported by all consumers yet.
11435
d77de738 11436@opindex gdescribe-dies
ddf6fe37 11437@item -gdescribe-dies
d77de738
ML
11438Add description attributes to some DWARF DIEs that have no name attribute,
11439such as artificial variables, external references and call site
11440parameter DIEs.
11441
d77de738 11442@opindex gpubnames
ddf6fe37 11443@item -gpubnames
d77de738
ML
11444Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11445
d77de738 11446@opindex ggnu-pubnames
ddf6fe37 11447@item -ggnu-pubnames
d77de738
ML
11448Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11449suitable for conversion into a GDB@ index. This option is only useful
11450with a linker that can produce GDB@ index version 7.
11451
d77de738
ML
11452@opindex fdebug-types-section
11453@opindex fno-debug-types-section
ddf6fe37 11454@item -fdebug-types-section
d77de738
ML
11455When using DWARF Version 4 or higher, type DIEs can be put into
11456their own @code{.debug_types} section instead of making them part of the
11457@code{.debug_info} section. It is more efficient to put them in a separate
11458comdat section since the linker can then remove duplicates.
11459But not all DWARF consumers support @code{.debug_types} sections yet
11460and on some objects @code{.debug_types} produces larger instead of smaller
11461debugging information.
11462
d77de738
ML
11463@opindex grecord-gcc-switches
11464@opindex gno-record-gcc-switches
ddf6fe37
AA
11465@item -grecord-gcc-switches
11466@itemx -gno-record-gcc-switches
d77de738
ML
11467This switch causes the command-line options used to invoke the
11468compiler that may affect code generation to be appended to the
11469DW_AT_producer attribute in DWARF debugging information. The options
11470are concatenated with spaces separating them from each other and from
11471the compiler version.
11472It is enabled by default.
11473See also @option{-frecord-gcc-switches} for another
11474way of storing compiler options into the object file.
11475
d77de738 11476@opindex gstrict-dwarf
ddf6fe37 11477@item -gstrict-dwarf
d77de738
ML
11478Disallow using extensions of later DWARF standard version than selected
11479with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11480DWARF extensions from later standard versions is allowed.
11481
d77de738 11482@opindex gno-strict-dwarf
ddf6fe37 11483@item -gno-strict-dwarf
d77de738
ML
11484Allow using extensions of later DWARF standard version than selected with
11485@option{-gdwarf-@var{version}}.
11486
d77de738 11487@opindex gas-loc-support
ddf6fe37 11488@item -gas-loc-support
d77de738
ML
11489Inform the compiler that the assembler supports @code{.loc} directives.
11490It may then use them for the assembler to generate DWARF2+ line number
11491tables.
11492
11493This is generally desirable, because assembler-generated line-number
11494tables are a lot more compact than those the compiler can generate
11495itself.
11496
11497This option will be enabled by default if, at GCC configure time, the
11498assembler was found to support such directives.
11499
d77de738 11500@opindex gno-as-loc-support
ddf6fe37 11501@item -gno-as-loc-support
d77de738
ML
11502Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11503line number tables are to be generated.
11504
d77de738 11505@opindex gas-locview-support
ddf6fe37 11506@item -gas-locview-support
d77de738
ML
11507Inform the compiler that the assembler supports @code{view} assignment
11508and reset assertion checking in @code{.loc} directives.
11509
11510This option will be enabled by default if, at GCC configure time, the
11511assembler was found to support them.
11512
11513@item -gno-as-locview-support
11514Force GCC to assign view numbers internally, if
11515@option{-gvariable-location-views} are explicitly requested.
11516
d77de738
ML
11517@opindex gcolumn-info
11518@opindex gno-column-info
ddf6fe37
AA
11519@item -gcolumn-info
11520@itemx -gno-column-info
d77de738
ML
11521Emit location column information into DWARF debugging information, rather
11522than just file and line.
11523This option is enabled by default.
11524
d77de738
ML
11525@opindex gstatement-frontiers
11526@opindex gno-statement-frontiers
ddf6fe37
AA
11527@item -gstatement-frontiers
11528@itemx -gno-statement-frontiers
d77de738
ML
11529This option causes GCC to create markers in the internal representation
11530at the beginning of statements, and to keep them roughly in place
11531throughout compilation, using them to guide the output of @code{is_stmt}
11532markers in the line number table. This is enabled by default when
11533compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11534@dots{}), and outputting DWARF 2 debug information at the normal level.
11535
d77de738
ML
11536@opindex gvariable-location-views
11537@opindex gvariable-location-views=incompat5
11538@opindex gno-variable-location-views
ddf6fe37
AA
11539@item -gvariable-location-views
11540@itemx -gvariable-location-views=incompat5
11541@itemx -gno-variable-location-views
d77de738
ML
11542Augment variable location lists with progressive view numbers implied
11543from the line number table. This enables debug information consumers to
11544inspect state at certain points of the program, even if no instructions
11545associated with the corresponding source locations are present at that
11546point. If the assembler lacks support for view numbers in line number
11547tables, this will cause the compiler to emit the line number table,
11548which generally makes them somewhat less compact. The augmented line
11549number tables and location lists are fully backward-compatible, so they
11550can be consumed by debug information consumers that are not aware of
11551these augmentations, but they won't derive any benefit from them either.
11552
11553This is enabled by default when outputting DWARF 2 debug information at
11554the normal level, as long as there is assembler support,
11555@option{-fvar-tracking-assignments} is enabled and
11556@option{-gstrict-dwarf} is not. When assembler support is not
11557available, this may still be enabled, but it will force GCC to output
11558internal line number tables, and if
11559@option{-ginternal-reset-location-views} is not enabled, that will most
11560certainly lead to silently mismatching location views.
11561
11562There is a proposed representation for view numbers that is not backward
11563compatible with the location list format introduced in DWARF 5, that can
11564be enabled with @option{-gvariable-location-views=incompat5}. This
11565option may be removed in the future, is only provided as a reference
11566implementation of the proposed representation. Debug information
11567consumers are not expected to support this extended format, and they
11568would be rendered unable to decode location lists using it.
11569
d77de738
ML
11570@opindex ginternal-reset-location-views
11571@opindex gno-internal-reset-location-views
ddf6fe37
AA
11572@item -ginternal-reset-location-views
11573@itemx -gno-internal-reset-location-views
d77de738
ML
11574Attempt to determine location views that can be omitted from location
11575view lists. This requires the compiler to have very accurate insn
11576length estimates, which isn't always the case, and it may cause
11577incorrect view lists to be generated silently when using an assembler
11578that does not support location view lists. The GNU assembler will flag
11579any such error as a @code{view number mismatch}. This is only enabled
11580on ports that define a reliable estimation function.
11581
d77de738
ML
11582@opindex ginline-points
11583@opindex gno-inline-points
ddf6fe37
AA
11584@item -ginline-points
11585@itemx -gno-inline-points
d77de738
ML
11586Generate extended debug information for inlined functions. Location
11587view tracking markers are inserted at inlined entry points, so that
11588address and view numbers can be computed and output in debug
11589information. This can be enabled independently of location views, in
11590which case the view numbers won't be output, but it can only be enabled
11591along with statement frontiers, and it is only enabled by default if
11592location views are enabled.
11593
d77de738 11594@opindex gz
ddf6fe37 11595@item -gz@r{[}=@var{type}@r{]}
d77de738
ML
11596Produce compressed debug sections in DWARF format, if that is supported.
11597If @var{type} is not given, the default type depends on the capabilities
11598of the assembler and linker used. @var{type} may be one of
11599@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11600compression in ELF gABI format). If the linker doesn't support writing
11601compressed debug sections, the option is rejected. Otherwise, if the
11602assembler does not support them, @option{-gz} is silently ignored when
11603producing object files.
11604
d77de738 11605@opindex femit-struct-debug-baseonly
ddf6fe37 11606@item -femit-struct-debug-baseonly
d77de738
ML
11607Emit debug information for struct-like types
11608only when the base name of the compilation source file
11609matches the base name of file in which the struct is defined.
11610
11611This option substantially reduces the size of debugging information,
11612but at significant potential loss in type information to the debugger.
11613See @option{-femit-struct-debug-reduced} for a less aggressive option.
11614See @option{-femit-struct-debug-detailed} for more detailed control.
11615
11616This option works only with DWARF debug output.
11617
d77de738 11618@opindex femit-struct-debug-reduced
ddf6fe37 11619@item -femit-struct-debug-reduced
d77de738
ML
11620Emit debug information for struct-like types
11621only when the base name of the compilation source file
11622matches the base name of file in which the type is defined,
11623unless the struct is a template or defined in a system header.
11624
11625This option significantly reduces the size of debugging information,
11626with some potential loss in type information to the debugger.
11627See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11628See @option{-femit-struct-debug-detailed} for more detailed control.
11629
11630This option works only with DWARF debug output.
11631
d77de738 11632@opindex femit-struct-debug-detailed
ddf6fe37 11633@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
d77de738
ML
11634Specify the struct-like types
11635for which the compiler generates debug information.
11636The intent is to reduce duplicate struct debug information
11637between different object files within the same program.
11638
11639This option is a detailed version of
11640@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11641which serves for most needs.
11642
11643A specification has the syntax@*
11644[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11645
11646The optional first word limits the specification to
11647structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11648A struct type is used directly when it is the type of a variable, member.
11649Indirect uses arise through pointers to structs.
11650That is, when use of an incomplete struct is valid, the use is indirect.
11651An example is
11652@samp{struct one direct; struct two * indirect;}.
11653
11654The optional second word limits the specification to
11655ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11656Generic structs are a bit complicated to explain.
11657For C++, these are non-explicit specializations of template classes,
11658or non-template classes within the above.
11659Other programming languages have generics,
11660but @option{-femit-struct-debug-detailed} does not yet implement them.
11661
11662The third word specifies the source files for those
11663structs for which the compiler should emit debug information.
11664The values @samp{none} and @samp{any} have the normal meaning.
11665The value @samp{base} means that
11666the base of name of the file in which the type declaration appears
11667must match the base of the name of the main compilation file.
11668In practice, this means that when compiling @file{foo.c}, debug information
11669is generated for types declared in that file and @file{foo.h},
11670but not other header files.
11671The value @samp{sys} means those types satisfying @samp{base}
11672or declared in system or compiler headers.
11673
11674You may need to experiment to determine the best settings for your application.
11675
11676The default is @option{-femit-struct-debug-detailed=all}.
11677
11678This option works only with DWARF debug output.
11679
d77de738
ML
11680@opindex fdwarf2-cfi-asm
11681@opindex fno-dwarf2-cfi-asm
ddf6fe37 11682@item -fno-dwarf2-cfi-asm
d77de738
ML
11683Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11684instead of using GAS @code{.cfi_*} directives.
11685
d77de738
ML
11686@opindex feliminate-unused-debug-types
11687@opindex fno-eliminate-unused-debug-types
ddf6fe37 11688@item -fno-eliminate-unused-debug-types
d77de738
ML
11689Normally, when producing DWARF output, GCC avoids producing debug symbol
11690output for types that are nowhere used in the source file being compiled.
11691Sometimes it is useful to have GCC emit debugging
11692information for all types declared in a compilation
11693unit, regardless of whether or not they are actually used
11694in that compilation unit, for example
11695if, in the debugger, you want to cast a value to a type that is
11696not actually used in your program (but is declared). More often,
11697however, this results in a significant amount of wasted space.
11698@end table
11699
11700@node Optimize Options
11701@section Options That Control Optimization
11702@cindex optimize options
11703@cindex options, optimization
11704
11705These options control various sorts of optimizations.
11706
11707Without any optimization option, the compiler's goal is to reduce the
11708cost of compilation and to make debugging produce the expected
11709results. Statements are independent: if you stop the program with a
11710breakpoint between statements, you can then assign a new value to any
11711variable or change the program counter to any other statement in the
11712function and get exactly the results you expect from the source
11713code.
11714
11715Turning on optimization flags makes the compiler attempt to improve
11716the performance and/or code size at the expense of compilation time
11717and possibly the ability to debug the program.
11718
11719The compiler performs optimization based on the knowledge it has of the
11720program. Compiling multiple files at once to a single output file mode allows
11721the compiler to use information gained from all of the files when compiling
11722each of them.
11723
11724Not all optimizations are controlled directly by a flag. Only
11725optimizations that have a flag are listed in this section.
11726
11727Most optimizations are completely disabled at @option{-O0} or if an
11728@option{-O} level is not set on the command line, even if individual
11729optimization flags are specified. Similarly, @option{-Og} suppresses
11730many optimization passes.
11731
11732Depending on the target and how GCC was configured, a slightly different
11733set of optimizations may be enabled at each @option{-O} level than
11734those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11735to find out the exact set of optimizations that are enabled at each level.
11736@xref{Overall Options}, for examples.
11737
11738@table @gcctabopt
d77de738
ML
11739@opindex O
11740@opindex O1
ddf6fe37
AA
11741@item -O
11742@itemx -O1
d77de738
ML
11743Optimize. Optimizing compilation takes somewhat more time, and a lot
11744more memory for a large function.
11745
11746With @option{-O}, the compiler tries to reduce code size and execution
11747time, without performing any optimizations that take a great deal of
11748compilation time.
11749
11750@c Note that in addition to the default_options_table list in opts.cc,
11751@c several optimization flags default to true but control optimization
11752@c passes that are explicitly disabled at -O0.
11753
11754@option{-O} turns on the following optimization flags:
11755
11756@c Please keep the following list alphabetized.
11757@gccoptlist{-fauto-inc-dec @gol
11758-fbranch-count-reg @gol
11759-fcombine-stack-adjustments @gol
11760-fcompare-elim @gol
11761-fcprop-registers @gol
11762-fdce @gol
11763-fdefer-pop @gol
11764-fdelayed-branch @gol
11765-fdse @gol
11766-fforward-propagate @gol
11767-fguess-branch-probability @gol
11768-fif-conversion @gol
11769-fif-conversion2 @gol
11770-finline-functions-called-once @gol
11771-fipa-modref @gol
11772-fipa-profile @gol
11773-fipa-pure-const @gol
11774-fipa-reference @gol
11775-fipa-reference-addressable @gol
11776-fmerge-constants @gol
11777-fmove-loop-invariants @gol
11778-fmove-loop-stores@gol
11779-fomit-frame-pointer @gol
11780-freorder-blocks @gol
11781-fshrink-wrap @gol
11782-fshrink-wrap-separate @gol
11783-fsplit-wide-types @gol
11784-fssa-backprop @gol
11785-fssa-phiopt @gol
11786-ftree-bit-ccp @gol
11787-ftree-ccp @gol
11788-ftree-ch @gol
11789-ftree-coalesce-vars @gol
11790-ftree-copy-prop @gol
11791-ftree-dce @gol
11792-ftree-dominator-opts @gol
11793-ftree-dse @gol
11794-ftree-forwprop @gol
11795-ftree-fre @gol
11796-ftree-phiprop @gol
11797-ftree-pta @gol
11798-ftree-scev-cprop @gol
11799-ftree-sink @gol
11800-ftree-slsr @gol
11801-ftree-sra @gol
11802-ftree-ter @gol
11803-funit-at-a-time}
11804
d77de738 11805@opindex O2
ddf6fe37 11806@item -O2
d77de738
ML
11807Optimize even more. GCC performs nearly all supported optimizations
11808that do not involve a space-speed tradeoff.
11809As compared to @option{-O}, this option increases both compilation time
11810and the performance of the generated code.
11811
11812@option{-O2} turns on all optimization flags specified by @option{-O1}. It
11813also turns on the following optimization flags:
11814
11815@c Please keep the following list alphabetized!
11816@gccoptlist{-falign-functions -falign-jumps @gol
11817-falign-labels -falign-loops @gol
11818-fcaller-saves @gol
11819-fcode-hoisting @gol
11820-fcrossjumping @gol
11821-fcse-follow-jumps -fcse-skip-blocks @gol
11822-fdelete-null-pointer-checks @gol
11823-fdevirtualize -fdevirtualize-speculatively @gol
11824-fexpensive-optimizations @gol
11825-ffinite-loops @gol
11826-fgcse -fgcse-lm @gol
11827-fhoist-adjacent-loads @gol
11828-finline-functions @gol
11829-finline-small-functions @gol
11830-findirect-inlining @gol
11831-fipa-bit-cp -fipa-cp -fipa-icf @gol
11832-fipa-ra -fipa-sra -fipa-vrp @gol
11833-fisolate-erroneous-paths-dereference @gol
11834-flra-remat @gol
11835-foptimize-sibling-calls @gol
11836-foptimize-strlen @gol
11837-fpartial-inlining @gol
11838-fpeephole2 @gol
11839-freorder-blocks-algorithm=stc @gol
11840-freorder-blocks-and-partition -freorder-functions @gol
11841-frerun-cse-after-loop @gol
11842-fschedule-insns -fschedule-insns2 @gol
11843-fsched-interblock -fsched-spec @gol
11844-fstore-merging @gol
11845-fstrict-aliasing @gol
11846-fthread-jumps @gol
11847-ftree-builtin-call-dce @gol
11848-ftree-loop-vectorize @gol
11849-ftree-pre @gol
11850-ftree-slp-vectorize @gol
11851-ftree-switch-conversion -ftree-tail-merge @gol
11852-ftree-vrp @gol
11853-fvect-cost-model=very-cheap}
11854
11855Please note the warning under @option{-fgcse} about
11856invoking @option{-O2} on programs that use computed gotos.
11857
d77de738 11858@opindex O3
ddf6fe37 11859@item -O3
d77de738
ML
11860Optimize yet more. @option{-O3} turns on all optimizations specified
11861by @option{-O2} and also turns on the following optimization flags:
11862
11863@c Please keep the following list alphabetized!
11864@gccoptlist{-fgcse-after-reload @gol
11865-fipa-cp-clone
11866-floop-interchange @gol
11867-floop-unroll-and-jam @gol
11868-fpeel-loops @gol
11869-fpredictive-commoning @gol
11870-fsplit-loops @gol
11871-fsplit-paths @gol
11872-ftree-loop-distribution @gol
11873-ftree-partial-pre @gol
11874-funswitch-loops @gol
11875-fvect-cost-model=dynamic @gol
11876-fversion-loops-for-strides}
11877
d77de738 11878@opindex O0
ddf6fe37 11879@item -O0
d77de738
ML
11880Reduce compilation time and make debugging produce the expected
11881results. This is the default.
11882
d77de738 11883@opindex Os
ddf6fe37 11884@item -Os
d77de738
ML
11885Optimize for size. @option{-Os} enables all @option{-O2} optimizations
11886except those that often increase code size:
11887
11888@gccoptlist{-falign-functions -falign-jumps @gol
11889-falign-labels -falign-loops @gol
11890-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
11891
11892It also enables @option{-finline-functions}, causes the compiler to tune for
11893code size rather than execution speed, and performs further optimizations
11894designed to reduce code size.
11895
d77de738 11896@opindex Ofast
ddf6fe37 11897@item -Ofast
d77de738
ML
11898Disregard strict standards compliance. @option{-Ofast} enables all
11899@option{-O3} optimizations. It also enables optimizations that are not
11900valid for all standard-compliant programs.
11901It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
11902and the Fortran-specific @option{-fstack-arrays}, unless
11903@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
11904It turns off @option{-fsemantic-interposition}.
11905
d77de738 11906@opindex Og
ddf6fe37 11907@item -Og
d77de738
ML
11908Optimize debugging experience. @option{-Og} should be the optimization
11909level of choice for the standard edit-compile-debug cycle, offering
11910a reasonable level of optimization while maintaining fast compilation
11911and a good debugging experience. It is a better choice than @option{-O0}
11912for producing debuggable code because some compiler passes
11913that collect debug information are disabled at @option{-O0}.
11914
11915Like @option{-O0}, @option{-Og} completely disables a number of
11916optimization passes so that individual options controlling them have
11917no effect. Otherwise @option{-Og} enables all @option{-O1}
11918optimization flags except for those that may interfere with debugging:
11919
11920@gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
11921-fdse -fif-conversion -fif-conversion2 @gol
11922-finline-functions-called-once @gol
11923-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol
11924-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
11925
d77de738 11926@opindex Oz
ddf6fe37 11927@item -Oz
d77de738
ML
11928Optimize aggressively for size rather than speed. This may increase
11929the number of instructions executed if those instructions require
11930fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
11931including enabling most @option{-O2} optimizations.
11932
11933@end table
11934
11935If you use multiple @option{-O} options, with or without level numbers,
11936the last such option is the one that is effective.
11937
11938Options of the form @option{-f@var{flag}} specify machine-independent
11939flags. Most flags have both positive and negative forms; the negative
11940form of @option{-ffoo} is @option{-fno-foo}. In the table
11941below, only one of the forms is listed---the one you typically
11942use. You can figure out the other form by either removing @samp{no-}
11943or adding it.
11944
11945The following options control specific optimizations. They are either
11946activated by @option{-O} options or are related to ones that are. You
11947can use the following flags in the rare cases when ``fine-tuning'' of
11948optimizations to be performed is desired.
11949
11950@table @gcctabopt
d77de738
ML
11951@opindex fno-defer-pop
11952@opindex fdefer-pop
ddf6fe37 11953@item -fno-defer-pop
d77de738
ML
11954For machines that must pop arguments after a function call, always pop
11955the arguments as soon as each function returns.
11956At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
11957this allows the compiler to let arguments accumulate on the stack for several
11958function calls and pop them all at once.
11959
d77de738 11960@opindex fforward-propagate
ddf6fe37 11961@item -fforward-propagate
d77de738
ML
11962Perform a forward propagation pass on RTL@. The pass tries to combine two
11963instructions and checks if the result can be simplified. If loop unrolling
11964is active, two passes are performed and the second is scheduled after
11965loop unrolling.
11966
11967This option is enabled by default at optimization levels @option{-O1},
11968@option{-O2}, @option{-O3}, @option{-Os}.
11969
d77de738 11970@opindex ffp-contract
ddf6fe37 11971@item -ffp-contract=@var{style}
d77de738
ML
11972@option{-ffp-contract=off} disables floating-point expression contraction.
11973@option{-ffp-contract=fast} enables floating-point expression contraction
11974such as forming of fused multiply-add operations if the target has
11975native support for them.
11976@option{-ffp-contract=on} enables floating-point expression contraction
11977if allowed by the language standard. This is currently not implemented
11978and treated equal to @option{-ffp-contract=off}.
11979
11980The default is @option{-ffp-contract=fast}.
11981
d77de738 11982@opindex fomit-frame-pointer
ddf6fe37 11983@item -fomit-frame-pointer
d77de738
ML
11984Omit the frame pointer in functions that don't need one. This avoids the
11985instructions to save, set up and restore the frame pointer; on many targets
11986it also makes an extra register available.
11987
11988On some targets this flag has no effect because the standard calling sequence
11989always uses a frame pointer, so it cannot be omitted.
11990
11991Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
11992is used in all functions. Several targets always omit the frame pointer in
11993leaf functions.
11994
11995Enabled by default at @option{-O1} and higher.
11996
d77de738 11997@opindex foptimize-sibling-calls
ddf6fe37 11998@item -foptimize-sibling-calls
d77de738
ML
11999Optimize sibling and tail recursive calls.
12000
12001Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12002
d77de738 12003@opindex foptimize-strlen
ddf6fe37 12004@item -foptimize-strlen
d77de738
ML
12005Optimize various standard C string functions (e.g.@: @code{strlen},
12006@code{strchr} or @code{strcpy}) and
12007their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
12008
12009Enabled at levels @option{-O2}, @option{-O3}.
12010
d77de738
ML
12011@opindex fno-inline
12012@opindex finline
ddf6fe37 12013@item -fno-inline
d77de738
ML
12014Do not expand any functions inline apart from those marked with
12015the @code{always_inline} attribute. This is the default when not
12016optimizing.
12017
12018Single functions can be exempted from inlining by marking them
12019with the @code{noinline} attribute.
12020
d77de738 12021@opindex finline-small-functions
ddf6fe37 12022@item -finline-small-functions
d77de738
ML
12023Integrate functions into their callers when their body is smaller than expected
12024function call code (so overall size of program gets smaller). The compiler
12025heuristically decides which functions are simple enough to be worth integrating
12026in this way. This inlining applies to all functions, even those not declared
12027inline.
12028
12029Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12030
d77de738 12031@opindex findirect-inlining
ddf6fe37 12032@item -findirect-inlining
d77de738
ML
12033Inline also indirect calls that are discovered to be known at compile
12034time thanks to previous inlining. This option has any effect only
12035when inlining itself is turned on by the @option{-finline-functions}
12036or @option{-finline-small-functions} options.
12037
12038Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12039
d77de738 12040@opindex finline-functions
ddf6fe37 12041@item -finline-functions
d77de738
ML
12042Consider all functions for inlining, even if they are not declared inline.
12043The compiler heuristically decides which functions are worth integrating
12044in this way.
12045
12046If all calls to a given function are integrated, and the function is
12047declared @code{static}, then the function is normally not output as
12048assembler code in its own right.
12049
12050Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
12051by @option{-fprofile-use} and @option{-fauto-profile}.
12052
d77de738 12053@opindex finline-functions-called-once
ddf6fe37 12054@item -finline-functions-called-once
d77de738
ML
12055Consider all @code{static} functions called once for inlining into their
12056caller even if they are not marked @code{inline}. If a call to a given
12057function is integrated, then the function is not output as assembler code
12058in its own right.
12059
12060Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
12061but not @option{-Og}.
12062
d77de738 12063@opindex fearly-inlining
ddf6fe37 12064@item -fearly-inlining
d77de738
ML
12065Inline functions marked by @code{always_inline} and functions whose body seems
12066smaller than the function call overhead early before doing
12067@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
12068makes profiling significantly cheaper and usually inlining faster on programs
12069having large chains of nested wrapper functions.
12070
12071Enabled by default.
12072
d77de738 12073@opindex fipa-sra
ddf6fe37 12074@item -fipa-sra
d77de738
ML
12075Perform interprocedural scalar replacement of aggregates, removal of
12076unused parameters and replacement of parameters passed by reference
12077by parameters passed by value.
12078
12079Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
12080
d77de738 12081@opindex finline-limit
ddf6fe37 12082@item -finline-limit=@var{n}
d77de738
ML
12083By default, GCC limits the size of functions that can be inlined. This flag
12084allows coarse control of this limit. @var{n} is the size of functions that
12085can be inlined in number of pseudo instructions.
12086
12087Inlining is actually controlled by a number of parameters, which may be
12088specified individually by using @option{--param @var{name}=@var{value}}.
12089The @option{-finline-limit=@var{n}} option sets some of these parameters
12090as follows:
12091
12092@table @gcctabopt
12093@item max-inline-insns-single
12094is set to @var{n}/2.
12095@item max-inline-insns-auto
12096is set to @var{n}/2.
12097@end table
12098
12099See below for a documentation of the individual
12100parameters controlling inlining and for the defaults of these parameters.
12101
12102@emph{Note:} there may be no value to @option{-finline-limit} that results
12103in default behavior.
12104
12105@emph{Note:} pseudo instruction represents, in this particular context, an
12106abstract measurement of function's size. In no way does it represent a count
12107of assembly instructions and as such its exact meaning might change from one
12108release to an another.
12109
d77de738
ML
12110@opindex fno-keep-inline-dllexport
12111@opindex fkeep-inline-dllexport
ddf6fe37 12112@item -fno-keep-inline-dllexport
d77de738
ML
12113This is a more fine-grained version of @option{-fkeep-inline-functions},
12114which applies only to functions that are declared using the @code{dllexport}
12115attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12116Functions}.
12117
d77de738 12118@opindex fkeep-inline-functions
ddf6fe37 12119@item -fkeep-inline-functions
d77de738
ML
12120In C, emit @code{static} functions that are declared @code{inline}
12121into the object file, even if the function has been inlined into all
12122of its callers. This switch does not affect functions using the
12123@code{extern inline} extension in GNU C90@. In C++, emit any and all
12124inline functions into the object file.
12125
d77de738 12126@opindex fkeep-static-functions
ddf6fe37 12127@item -fkeep-static-functions
d77de738
ML
12128Emit @code{static} functions into the object file, even if the function
12129is never used.
12130
d77de738 12131@opindex fkeep-static-consts
ddf6fe37 12132@item -fkeep-static-consts
d77de738
ML
12133Emit variables declared @code{static const} when optimization isn't turned
12134on, even if the variables aren't referenced.
12135
12136GCC enables this option by default. If you want to force the compiler to
12137check if a variable is referenced, regardless of whether or not
12138optimization is turned on, use the @option{-fno-keep-static-consts} option.
12139
d77de738 12140@opindex fmerge-constants
ddf6fe37 12141@item -fmerge-constants
d77de738
ML
12142Attempt to merge identical constants (string constants and floating-point
12143constants) across compilation units.
12144
12145This option is the default for optimized compilation if the assembler and
12146linker support it. Use @option{-fno-merge-constants} to inhibit this
12147behavior.
12148
12149Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12150
d77de738 12151@opindex fmerge-all-constants
ddf6fe37 12152@item -fmerge-all-constants
d77de738
ML
12153Attempt to merge identical constants and identical variables.
12154
12155This option implies @option{-fmerge-constants}. In addition to
12156@option{-fmerge-constants} this considers e.g.@: even constant initialized
12157arrays or initialized constant variables with integral or floating-point
12158types. Languages like C or C++ require each variable, including multiple
12159instances of the same variable in recursive calls, to have distinct locations,
12160so using this option results in non-conforming
12161behavior.
12162
d77de738 12163@opindex fmodulo-sched
ddf6fe37 12164@item -fmodulo-sched
d77de738
ML
12165Perform swing modulo scheduling immediately before the first scheduling
12166pass. This pass looks at innermost loops and reorders their
12167instructions by overlapping different iterations.
12168
d77de738 12169@opindex fmodulo-sched-allow-regmoves
ddf6fe37 12170@item -fmodulo-sched-allow-regmoves
d77de738
ML
12171Perform more aggressive SMS-based modulo scheduling with register moves
12172allowed. By setting this flag certain anti-dependences edges are
12173deleted, which triggers the generation of reg-moves based on the
12174life-range analysis. This option is effective only with
12175@option{-fmodulo-sched} enabled.
12176
d77de738
ML
12177@opindex fno-branch-count-reg
12178@opindex fbranch-count-reg
ddf6fe37 12179@item -fno-branch-count-reg
d77de738
ML
12180Disable the optimization pass that scans for opportunities to use
12181``decrement and branch'' instructions on a count register instead of
12182instruction sequences that decrement a register, compare it against zero, and
12183then branch based upon the result. This option is only meaningful on
12184architectures that support such instructions, which include x86, PowerPC,
12185IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12186doesn't remove the decrement and branch instructions from the generated
12187instruction stream introduced by other optimization passes.
12188
12189The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12190except for @option{-Og}.
12191
d77de738
ML
12192@opindex fno-function-cse
12193@opindex ffunction-cse
ddf6fe37 12194@item -fno-function-cse
d77de738
ML
12195Do not put function addresses in registers; make each instruction that
12196calls a constant function contain the function's address explicitly.
12197
12198This option results in less efficient code, but some strange hacks
12199that alter the assembler output may be confused by the optimizations
12200performed when this option is not used.
12201
12202The default is @option{-ffunction-cse}
12203
d77de738
ML
12204@opindex fno-zero-initialized-in-bss
12205@opindex fzero-initialized-in-bss
ddf6fe37 12206@item -fno-zero-initialized-in-bss
d77de738
ML
12207If the target supports a BSS section, GCC by default puts variables that
12208are initialized to zero into BSS@. This can save space in the resulting
12209code.
12210
12211This option turns off this behavior because some programs explicitly
12212rely on variables going to the data section---e.g., so that the
12213resulting executable can find the beginning of that section and/or make
12214assumptions based on that.
12215
12216The default is @option{-fzero-initialized-in-bss}.
12217
d77de738 12218@opindex fthread-jumps
ddf6fe37 12219@item -fthread-jumps
d77de738
ML
12220Perform optimizations that check to see if a jump branches to a
12221location where another comparison subsumed by the first is found. If
12222so, the first branch is redirected to either the destination of the
12223second branch or a point immediately following it, depending on whether
12224the condition is known to be true or false.
12225
12226Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12227
d77de738 12228@opindex fsplit-wide-types
ddf6fe37 12229@item -fsplit-wide-types
d77de738
ML
12230When using a type that occupies multiple registers, such as @code{long
12231long} on a 32-bit system, split the registers apart and allocate them
12232independently. This normally generates better code for those types,
12233but may make debugging more difficult.
12234
12235Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12236@option{-Os}.
12237
d77de738 12238@opindex fsplit-wide-types-early
ddf6fe37 12239@item -fsplit-wide-types-early
d77de738
ML
12240Fully split wide types early, instead of very late.
12241This option has no effect unless @option{-fsplit-wide-types} is turned on.
12242
12243This is the default on some targets.
12244
d77de738 12245@opindex fcse-follow-jumps
ddf6fe37 12246@item -fcse-follow-jumps
d77de738
ML
12247In common subexpression elimination (CSE), scan through jump instructions
12248when the target of the jump is not reached by any other path. For
12249example, when CSE encounters an @code{if} statement with an
12250@code{else} clause, CSE follows the jump when the condition
12251tested is false.
12252
12253Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12254
d77de738 12255@opindex fcse-skip-blocks
ddf6fe37 12256@item -fcse-skip-blocks
d77de738
ML
12257This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12258follow jumps that conditionally skip over blocks. When CSE
12259encounters a simple @code{if} statement with no else clause,
12260@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12261body of the @code{if}.
12262
12263Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12264
d77de738 12265@opindex frerun-cse-after-loop
ddf6fe37 12266@item -frerun-cse-after-loop
d77de738
ML
12267Re-run common subexpression elimination after loop optimizations are
12268performed.
12269
12270Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12271
d77de738 12272@opindex fgcse
ddf6fe37 12273@item -fgcse
d77de738
ML
12274Perform a global common subexpression elimination pass.
12275This pass also performs global constant and copy propagation.
12276
12277@emph{Note:} When compiling a program using computed gotos, a GCC
12278extension, you may get better run-time performance if you disable
12279the global common subexpression elimination pass by adding
12280@option{-fno-gcse} to the command line.
12281
12282Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12283
d77de738 12284@opindex fgcse-lm
ddf6fe37 12285@item -fgcse-lm
d77de738
ML
12286When @option{-fgcse-lm} is enabled, global common subexpression elimination
12287attempts to move loads that are only killed by stores into themselves. This
12288allows a loop containing a load/store sequence to be changed to a load outside
12289the loop, and a copy/store within the loop.
12290
12291Enabled by default when @option{-fgcse} is enabled.
12292
d77de738 12293@opindex fgcse-sm
ddf6fe37 12294@item -fgcse-sm
d77de738
ML
12295When @option{-fgcse-sm} is enabled, a store motion pass is run after
12296global common subexpression elimination. This pass attempts to move
12297stores out of loops. When used in conjunction with @option{-fgcse-lm},
12298loops containing a load/store sequence can be changed to a load before
12299the loop and a store after the loop.
12300
12301Not enabled at any optimization level.
12302
d77de738 12303@opindex fgcse-las
ddf6fe37 12304@item -fgcse-las
d77de738
ML
12305When @option{-fgcse-las} is enabled, the global common subexpression
12306elimination pass eliminates redundant loads that come after stores to the
12307same memory location (both partial and full redundancies).
12308
12309Not enabled at any optimization level.
12310
d77de738 12311@opindex fgcse-after-reload
ddf6fe37 12312@item -fgcse-after-reload
d77de738
ML
12313When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12314pass is performed after reload. The purpose of this pass is to clean up
12315redundant spilling.
12316
12317Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12318
d77de738 12319@opindex faggressive-loop-optimizations
ddf6fe37 12320@item -faggressive-loop-optimizations
d77de738
ML
12321This option tells the loop optimizer to use language constraints to
12322derive bounds for the number of iterations of a loop. This assumes that
12323loop code does not invoke undefined behavior by for example causing signed
12324integer overflows or out-of-bound array accesses. The bounds for the
12325number of iterations of a loop are used to guide loop unrolling and peeling
12326and loop exit test optimizations.
12327This option is enabled by default.
12328
d77de738 12329@opindex funconstrained-commons
ddf6fe37 12330@item -funconstrained-commons
d77de738
ML
12331This option tells the compiler that variables declared in common blocks
12332(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12333prevents certain optimizations that depend on knowing the array bounds.
12334
d77de738 12335@opindex fcrossjumping
ddf6fe37 12336@item -fcrossjumping
d77de738
ML
12337Perform cross-jumping transformation.
12338This transformation unifies equivalent code and saves code size. The
12339resulting code may or may not perform better than without cross-jumping.
12340
12341Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12342
d77de738 12343@opindex fauto-inc-dec
ddf6fe37 12344@item -fauto-inc-dec
d77de738
ML
12345Combine increments or decrements of addresses with memory accesses.
12346This pass is always skipped on architectures that do not have
12347instructions to support this. Enabled by default at @option{-O1} and
12348higher on architectures that support this.
12349
d77de738 12350@opindex fdce
ddf6fe37 12351@item -fdce
d77de738
ML
12352Perform dead code elimination (DCE) on RTL@.
12353Enabled by default at @option{-O1} and higher.
12354
d77de738 12355@opindex fdse
ddf6fe37 12356@item -fdse
d77de738
ML
12357Perform dead store elimination (DSE) on RTL@.
12358Enabled by default at @option{-O1} and higher.
12359
d77de738 12360@opindex fif-conversion
ddf6fe37 12361@item -fif-conversion
d77de738
ML
12362Attempt to transform conditional jumps into branch-less equivalents. This
12363includes use of conditional moves, min, max, set flags and abs instructions, and
12364some tricks doable by standard arithmetics. The use of conditional execution
12365on chips where it is available is controlled by @option{-fif-conversion2}.
12366
12367Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12368not with @option{-Og}.
12369
d77de738 12370@opindex fif-conversion2
ddf6fe37 12371@item -fif-conversion2
d77de738
ML
12372Use conditional execution (where available) to transform conditional jumps into
12373branch-less equivalents.
12374
12375Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12376not with @option{-Og}.
12377
d77de738 12378@opindex fdeclone-ctor-dtor
ddf6fe37 12379@item -fdeclone-ctor-dtor
d77de738
ML
12380The C++ ABI requires multiple entry points for constructors and
12381destructors: one for a base subobject, one for a complete object, and
12382one for a virtual destructor that calls operator delete afterwards.
12383For a hierarchy with virtual bases, the base and complete variants are
12384clones, which means two copies of the function. With this option, the
12385base and complete variants are changed to be thunks that call a common
12386implementation.
12387
12388Enabled by @option{-Os}.
12389
d77de738 12390@opindex fdelete-null-pointer-checks
ddf6fe37 12391@item -fdelete-null-pointer-checks
d77de738
ML
12392Assume that programs cannot safely dereference null pointers, and that
12393no code or data element resides at address zero.
12394This option enables simple constant
12395folding optimizations at all optimization levels. In addition, other
12396optimization passes in GCC use this flag to control global dataflow
12397analyses that eliminate useless checks for null pointers; these assume
12398that a memory access to address zero always results in a trap, so
12399that if a pointer is checked after it has already been dereferenced,
12400it cannot be null.
12401
12402Note however that in some environments this assumption is not true.
12403Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12404for programs that depend on that behavior.
12405
12406This option is enabled by default on most targets. On Nios II ELF, it
12407defaults to off. On AVR and MSP430, this option is completely disabled.
12408
12409Passes that use the dataflow information
12410are enabled independently at different optimization levels.
12411
d77de738 12412@opindex fdevirtualize
ddf6fe37 12413@item -fdevirtualize
d77de738
ML
12414Attempt to convert calls to virtual functions to direct calls. This
12415is done both within a procedure and interprocedurally as part of
12416indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12417propagation (@option{-fipa-cp}).
12418Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12419
d77de738 12420@opindex fdevirtualize-speculatively
ddf6fe37 12421@item -fdevirtualize-speculatively
d77de738
ML
12422Attempt to convert calls to virtual functions to speculative direct calls.
12423Based on the analysis of the type inheritance graph, determine for a given call
12424the set of likely targets. If the set is small, preferably of size 1, change
12425the call into a conditional deciding between direct and indirect calls. The
12426speculative calls enable more optimizations, such as inlining. When they seem
12427useless after further optimization, they are converted back into original form.
12428
d77de738 12429@opindex fdevirtualize-at-ltrans
ddf6fe37 12430@item -fdevirtualize-at-ltrans
d77de738
ML
12431Stream extra information needed for aggressive devirtualization when running
12432the link-time optimizer in local transformation mode.
12433This option enables more devirtualization but
12434significantly increases the size of streamed data. For this reason it is
12435disabled by default.
12436
d77de738 12437@opindex fexpensive-optimizations
ddf6fe37 12438@item -fexpensive-optimizations
d77de738
ML
12439Perform a number of minor optimizations that are relatively expensive.
12440
12441Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12442
d77de738 12443@opindex free
ddf6fe37 12444@item -free
d77de738
ML
12445Attempt to remove redundant extension instructions. This is especially
12446helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12447registers after writing to their lower 32-bit half.
12448
12449Enabled for Alpha, AArch64 and x86 at levels @option{-O2},
12450@option{-O3}, @option{-Os}.
12451
d77de738
ML
12452@opindex fno-lifetime-dse
12453@opindex flifetime-dse
ddf6fe37 12454@item -fno-lifetime-dse
d77de738
ML
12455In C++ the value of an object is only affected by changes within its
12456lifetime: when the constructor begins, the object has an indeterminate
12457value, and any changes during the lifetime of the object are dead when
12458the object is destroyed. Normally dead store elimination will take
12459advantage of this; if your code relies on the value of the object
12460storage persisting beyond the lifetime of the object, you can use this
12461flag to disable this optimization. To preserve stores before the
12462constructor starts (e.g.@: because your operator new clears the object
12463storage) but still treat the object as dead after the destructor, you
12464can use @option{-flifetime-dse=1}. The default behavior can be
12465explicitly selected with @option{-flifetime-dse=2}.
12466@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12467
d77de738 12468@opindex flive-range-shrinkage
ddf6fe37 12469@item -flive-range-shrinkage
d77de738
ML
12470Attempt to decrease register pressure through register live range
12471shrinkage. This is helpful for fast processors with small or moderate
12472size register sets.
12473
d77de738 12474@opindex fira-algorithm
ddf6fe37 12475@item -fira-algorithm=@var{algorithm}
d77de738
ML
12476Use the specified coloring algorithm for the integrated register
12477allocator. The @var{algorithm} argument can be @samp{priority}, which
12478specifies Chow's priority coloring, or @samp{CB}, which specifies
12479Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12480for all architectures, but for those targets that do support it, it is
12481the default because it generates better code.
12482
d77de738 12483@opindex fira-region
ddf6fe37 12484@item -fira-region=@var{region}
d77de738
ML
12485Use specified regions for the integrated register allocator. The
12486@var{region} argument should be one of the following:
12487
12488@table @samp
12489
12490@item all
12491Use all loops as register allocation regions.
12492This can give the best results for machines with a small and/or
12493irregular register set.
12494
12495@item mixed
12496Use all loops except for loops with small register pressure
12497as the regions. This value usually gives
12498the best results in most cases and for most architectures,
12499and is enabled by default when compiling with optimization for speed
12500(@option{-O}, @option{-O2}, @dots{}).
12501
12502@item one
12503Use all functions as a single region.
12504This typically results in the smallest code size, and is enabled by default for
12505@option{-Os} or @option{-O0}.
12506
12507@end table
12508
d77de738 12509@opindex fira-hoist-pressure
ddf6fe37 12510@item -fira-hoist-pressure
d77de738
ML
12511Use IRA to evaluate register pressure in the code hoisting pass for
12512decisions to hoist expressions. This option usually results in smaller
12513code, but it can slow the compiler down.
12514
12515This option is enabled at level @option{-Os} for all targets.
12516
d77de738 12517@opindex fira-loop-pressure
ddf6fe37 12518@item -fira-loop-pressure
d77de738
ML
12519Use IRA to evaluate register pressure in loops for decisions to move
12520loop invariants. This option usually results in generation
12521of faster and smaller code on machines with large register files (>= 32
12522registers), but it can slow the compiler down.
12523
12524This option is enabled at level @option{-O3} for some targets.
12525
d77de738
ML
12526@opindex fno-ira-share-save-slots
12527@opindex fira-share-save-slots
ddf6fe37 12528@item -fno-ira-share-save-slots
d77de738
ML
12529Disable sharing of stack slots used for saving call-used hard
12530registers living through a call. Each hard register gets a
12531separate stack slot, and as a result function stack frames are
12532larger.
12533
d77de738
ML
12534@opindex fno-ira-share-spill-slots
12535@opindex fira-share-spill-slots
ddf6fe37 12536@item -fno-ira-share-spill-slots
d77de738
ML
12537Disable sharing of stack slots allocated for pseudo-registers. Each
12538pseudo-register that does not get a hard register gets a separate
12539stack slot, and as a result function stack frames are larger.
12540
d77de738 12541@opindex flra-remat
ddf6fe37 12542@item -flra-remat
d77de738
ML
12543Enable CFG-sensitive rematerialization in LRA. Instead of loading
12544values of spilled pseudos, LRA tries to rematerialize (recalculate)
12545values if it is profitable.
12546
12547Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12548
d77de738 12549@opindex fdelayed-branch
ddf6fe37 12550@item -fdelayed-branch
d77de738
ML
12551If supported for the target machine, attempt to reorder instructions
12552to exploit instruction slots available after delayed branch
12553instructions.
12554
12555Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12556but not at @option{-Og}.
12557
d77de738 12558@opindex fschedule-insns
ddf6fe37 12559@item -fschedule-insns
d77de738
ML
12560If supported for the target machine, attempt to reorder instructions to
12561eliminate execution stalls due to required data being unavailable. This
12562helps machines that have slow floating point or memory load instructions
12563by allowing other instructions to be issued until the result of the load
12564or floating-point instruction is required.
12565
12566Enabled at levels @option{-O2}, @option{-O3}.
12567
d77de738 12568@opindex fschedule-insns2
ddf6fe37 12569@item -fschedule-insns2
d77de738
ML
12570Similar to @option{-fschedule-insns}, but requests an additional pass of
12571instruction scheduling after register allocation has been done. This is
12572especially useful on machines with a relatively small number of
12573registers and where memory load instructions take more than one cycle.
12574
12575Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12576
d77de738
ML
12577@opindex fno-sched-interblock
12578@opindex fsched-interblock
ddf6fe37 12579@item -fno-sched-interblock
d77de738
ML
12580Disable instruction scheduling across basic blocks, which
12581is normally enabled when scheduling before register allocation, i.e.@:
12582with @option{-fschedule-insns} or at @option{-O2} or higher.
12583
d77de738
ML
12584@opindex fno-sched-spec
12585@opindex fsched-spec
ddf6fe37 12586@item -fno-sched-spec
d77de738
ML
12587Disable speculative motion of non-load instructions, which
12588is normally enabled when scheduling before register allocation, i.e.@:
12589with @option{-fschedule-insns} or at @option{-O2} or higher.
12590
d77de738 12591@opindex fsched-pressure
ddf6fe37 12592@item -fsched-pressure
d77de738
ML
12593Enable register pressure sensitive insn scheduling before register
12594allocation. This only makes sense when scheduling before register
12595allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12596@option{-O2} or higher. Usage of this option can improve the
12597generated code and decrease its size by preventing register pressure
12598increase above the number of available hard registers and subsequent
12599spills in register allocation.
12600
d77de738 12601@opindex fsched-spec-load
ddf6fe37 12602@item -fsched-spec-load
d77de738
ML
12603Allow speculative motion of some load instructions. This only makes
12604sense when scheduling before register allocation, i.e.@: with
12605@option{-fschedule-insns} or at @option{-O2} or higher.
12606
d77de738 12607@opindex fsched-spec-load-dangerous
ddf6fe37 12608@item -fsched-spec-load-dangerous
d77de738
ML
12609Allow speculative motion of more load instructions. This only makes
12610sense when scheduling before register allocation, i.e.@: with
12611@option{-fschedule-insns} or at @option{-O2} or higher.
12612
ddf6fe37 12613@opindex fsched-stalled-insns
d77de738
ML
12614@item -fsched-stalled-insns
12615@itemx -fsched-stalled-insns=@var{n}
d77de738
ML
12616Define how many insns (if any) can be moved prematurely from the queue
12617of stalled insns into the ready list during the second scheduling pass.
12618@option{-fno-sched-stalled-insns} means that no insns are moved
12619prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12620on how many queued insns can be moved prematurely.
12621@option{-fsched-stalled-insns} without a value is equivalent to
12622@option{-fsched-stalled-insns=1}.
12623
ddf6fe37 12624@opindex fsched-stalled-insns-dep
d77de738
ML
12625@item -fsched-stalled-insns-dep
12626@itemx -fsched-stalled-insns-dep=@var{n}
d77de738
ML
12627Define how many insn groups (cycles) are examined for a dependency
12628on a stalled insn that is a candidate for premature removal from the queue
12629of stalled insns. This has an effect only during the second scheduling pass,
12630and only if @option{-fsched-stalled-insns} is used.
12631@option{-fno-sched-stalled-insns-dep} is equivalent to
12632@option{-fsched-stalled-insns-dep=0}.
12633@option{-fsched-stalled-insns-dep} without a value is equivalent to
12634@option{-fsched-stalled-insns-dep=1}.
12635
d77de738 12636@opindex fsched2-use-superblocks
ddf6fe37 12637@item -fsched2-use-superblocks
d77de738
ML
12638When scheduling after register allocation, use superblock scheduling.
12639This allows motion across basic block boundaries,
12640resulting in faster schedules. This option is experimental, as not all machine
12641descriptions used by GCC model the CPU closely enough to avoid unreliable
12642results from the algorithm.
12643
12644This only makes sense when scheduling after register allocation, i.e.@: with
12645@option{-fschedule-insns2} or at @option{-O2} or higher.
12646
d77de738 12647@opindex fsched-group-heuristic
ddf6fe37 12648@item -fsched-group-heuristic
d77de738
ML
12649Enable the group heuristic in the scheduler. This heuristic favors
12650the instruction that belongs to a schedule group. This is enabled
12651by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12652or @option{-fschedule-insns2} or at @option{-O2} or higher.
12653
d77de738 12654@opindex fsched-critical-path-heuristic
ddf6fe37 12655@item -fsched-critical-path-heuristic
d77de738
ML
12656Enable the critical-path heuristic in the scheduler. This heuristic favors
12657instructions on the critical path. This is enabled by default when
12658scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12659or @option{-fschedule-insns2} or at @option{-O2} or higher.
12660
d77de738 12661@opindex fsched-spec-insn-heuristic
ddf6fe37 12662@item -fsched-spec-insn-heuristic
d77de738
ML
12663Enable the speculative instruction heuristic in the scheduler. This
12664heuristic favors speculative instructions with greater dependency weakness.
12665This is enabled by default when scheduling is enabled, i.e.@:
12666with @option{-fschedule-insns} or @option{-fschedule-insns2}
12667or at @option{-O2} or higher.
12668
d77de738 12669@opindex fsched-rank-heuristic
ddf6fe37 12670@item -fsched-rank-heuristic
d77de738
ML
12671Enable the rank heuristic in the scheduler. This heuristic favors
12672the instruction belonging to a basic block with greater size or frequency.
12673This is enabled by default when scheduling is enabled, i.e.@:
12674with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12675at @option{-O2} or higher.
12676
d77de738 12677@opindex fsched-last-insn-heuristic
ddf6fe37 12678@item -fsched-last-insn-heuristic
d77de738
ML
12679Enable the last-instruction heuristic in the scheduler. This heuristic
12680favors the instruction that is less dependent on the last instruction
12681scheduled. This is enabled by default when scheduling is enabled,
12682i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12683at @option{-O2} or higher.
12684
d77de738 12685@opindex fsched-dep-count-heuristic
ddf6fe37 12686@item -fsched-dep-count-heuristic
d77de738
ML
12687Enable the dependent-count heuristic in the scheduler. This heuristic
12688favors the instruction that has more instructions depending on it.
12689This is enabled by default when scheduling is enabled, i.e.@:
12690with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12691at @option{-O2} or higher.
12692
d77de738 12693@opindex freschedule-modulo-scheduled-loops
ddf6fe37 12694@item -freschedule-modulo-scheduled-loops
d77de738
ML
12695Modulo scheduling is performed before traditional scheduling. If a loop
12696is modulo scheduled, later scheduling passes may change its schedule.
12697Use this option to control that behavior.
12698
d77de738 12699@opindex fselective-scheduling
ddf6fe37 12700@item -fselective-scheduling
d77de738
ML
12701Schedule instructions using selective scheduling algorithm. Selective
12702scheduling runs instead of the first scheduler pass.
12703
d77de738 12704@opindex fselective-scheduling2
ddf6fe37 12705@item -fselective-scheduling2
d77de738
ML
12706Schedule instructions using selective scheduling algorithm. Selective
12707scheduling runs instead of the second scheduler pass.
12708
d77de738 12709@opindex fsel-sched-pipelining
ddf6fe37 12710@item -fsel-sched-pipelining
d77de738
ML
12711Enable software pipelining of innermost loops during selective scheduling.
12712This option has no effect unless one of @option{-fselective-scheduling} or
12713@option{-fselective-scheduling2} is turned on.
12714
d77de738 12715@opindex fsel-sched-pipelining-outer-loops
ddf6fe37 12716@item -fsel-sched-pipelining-outer-loops
d77de738
ML
12717When pipelining loops during selective scheduling, also pipeline outer loops.
12718This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12719
d77de738 12720@opindex fsemantic-interposition
ddf6fe37 12721@item -fsemantic-interposition
d77de738
ML
12722Some object formats, like ELF, allow interposing of symbols by the
12723dynamic linker.
12724This means that for symbols exported from the DSO, the compiler cannot perform
12725interprocedural propagation, inlining and other optimizations in anticipation
12726that the function or variable in question may change. While this feature is
12727useful, for example, to rewrite memory allocation functions by a debugging
12728implementation, it is expensive in the terms of code quality.
12729With @option{-fno-semantic-interposition} the compiler assumes that
12730if interposition happens for functions the overwriting function will have
12731precisely the same semantics (and side effects).
12732Similarly if interposition happens
12733for variables, the constructor of the variable will be the same. The flag
12734has no effect for functions explicitly declared inline
12735(where it is never allowed for interposition to change semantics)
12736and for symbols explicitly declared weak.
12737
d77de738 12738@opindex fshrink-wrap
ddf6fe37 12739@item -fshrink-wrap
d77de738
ML
12740Emit function prologues only before parts of the function that need it,
12741rather than at the top of the function. This flag is enabled by default at
12742@option{-O} and higher.
12743
d77de738 12744@opindex fshrink-wrap-separate
ddf6fe37 12745@item -fshrink-wrap-separate
d77de738
ML
12746Shrink-wrap separate parts of the prologue and epilogue separately, so that
12747those parts are only executed when needed.
12748This option is on by default, but has no effect unless @option{-fshrink-wrap}
12749is also turned on and the target supports this.
12750
d77de738 12751@opindex fcaller-saves
ddf6fe37 12752@item -fcaller-saves
d77de738
ML
12753Enable allocation of values to registers that are clobbered by
12754function calls, by emitting extra instructions to save and restore the
12755registers around such calls. Such allocation is done only when it
12756seems to result in better code.
12757
12758This option is always enabled by default on certain machines, usually
12759those which have no call-preserved registers to use instead.
12760
12761Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12762
d77de738 12763@opindex fcombine-stack-adjustments
ddf6fe37 12764@item -fcombine-stack-adjustments
d77de738
ML
12765Tracks stack adjustments (pushes and pops) and stack memory references
12766and then tries to find ways to combine them.
12767
12768Enabled by default at @option{-O1} and higher.
12769
d77de738 12770@opindex fipa-ra
ddf6fe37 12771@item -fipa-ra
d77de738
ML
12772Use caller save registers for allocation if those registers are not used by
12773any called function. In that case it is not necessary to save and restore
12774them around calls. This is only possible if called functions are part of
12775same compilation unit as current function and they are compiled before it.
12776
12777Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
12778is disabled if generated code will be instrumented for profiling
12779(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
12780exactly (this happens on targets that do not expose prologues
12781and epilogues in RTL).
12782
d77de738 12783@opindex fconserve-stack
ddf6fe37 12784@item -fconserve-stack
d77de738
ML
12785Attempt to minimize stack usage. The compiler attempts to use less
12786stack space, even if that makes the program slower. This option
12787implies setting the @option{large-stack-frame} parameter to 100
12788and the @option{large-stack-frame-growth} parameter to 400.
12789
d77de738 12790@opindex ftree-reassoc
ddf6fe37 12791@item -ftree-reassoc
d77de738
ML
12792Perform reassociation on trees. This flag is enabled by default
12793at @option{-O1} and higher.
12794
d77de738 12795@opindex fcode-hoisting
ddf6fe37 12796@item -fcode-hoisting
d77de738
ML
12797Perform code hoisting. Code hoisting tries to move the
12798evaluation of expressions executed on all paths to the function exit
12799as early as possible. This is especially useful as a code size
12800optimization, but it often helps for code speed as well.
12801This flag is enabled by default at @option{-O2} and higher.
12802
d77de738 12803@opindex ftree-pre
ddf6fe37 12804@item -ftree-pre
d77de738
ML
12805Perform partial redundancy elimination (PRE) on trees. This flag is
12806enabled by default at @option{-O2} and @option{-O3}.
12807
d77de738 12808@opindex ftree-partial-pre
ddf6fe37 12809@item -ftree-partial-pre
d77de738
ML
12810Make partial redundancy elimination (PRE) more aggressive. This flag is
12811enabled by default at @option{-O3}.
12812
d77de738 12813@opindex ftree-forwprop
ddf6fe37 12814@item -ftree-forwprop
d77de738
ML
12815Perform forward propagation on trees. This flag is enabled by default
12816at @option{-O1} and higher.
12817
d77de738 12818@opindex ftree-fre
ddf6fe37 12819@item -ftree-fre
d77de738
ML
12820Perform full redundancy elimination (FRE) on trees. The difference
12821between FRE and PRE is that FRE only considers expressions
12822that are computed on all paths leading to the redundant computation.
12823This analysis is faster than PRE, though it exposes fewer redundancies.
12824This flag is enabled by default at @option{-O1} and higher.
12825
d77de738 12826@opindex ftree-phiprop
ddf6fe37 12827@item -ftree-phiprop
d77de738
ML
12828Perform hoisting of loads from conditional pointers on trees. This
12829pass is enabled by default at @option{-O1} and higher.
12830
d77de738 12831@opindex fhoist-adjacent-loads
ddf6fe37 12832@item -fhoist-adjacent-loads
d77de738
ML
12833Speculatively hoist loads from both branches of an if-then-else if the
12834loads are from adjacent locations in the same structure and the target
12835architecture has a conditional move instruction. This flag is enabled
12836by default at @option{-O2} and higher.
12837
d77de738 12838@opindex ftree-copy-prop
ddf6fe37 12839@item -ftree-copy-prop
d77de738
ML
12840Perform copy propagation on trees. This pass eliminates unnecessary
12841copy operations. This flag is enabled by default at @option{-O1} and
12842higher.
12843
d77de738 12844@opindex fipa-pure-const
ddf6fe37 12845@item -fipa-pure-const
d77de738
ML
12846Discover which functions are pure or constant.
12847Enabled by default at @option{-O1} and higher.
12848
d77de738 12849@opindex fipa-reference
ddf6fe37 12850@item -fipa-reference
d77de738
ML
12851Discover which static variables do not escape the
12852compilation unit.
12853Enabled by default at @option{-O1} and higher.
12854
d77de738 12855@opindex fipa-reference-addressable
ddf6fe37 12856@item -fipa-reference-addressable
d77de738
ML
12857Discover read-only, write-only and non-addressable static variables.
12858Enabled by default at @option{-O1} and higher.
12859
d77de738 12860@opindex fipa-stack-alignment
ddf6fe37 12861@item -fipa-stack-alignment
d77de738
ML
12862Reduce stack alignment on call sites if possible.
12863Enabled by default.
12864
d77de738 12865@opindex fipa-pta
ddf6fe37 12866@item -fipa-pta
d77de738
ML
12867Perform interprocedural pointer analysis and interprocedural modification
12868and reference analysis. This option can cause excessive memory and
12869compile-time usage on large compilation units. It is not enabled by
12870default at any optimization level.
12871
d77de738 12872@opindex fipa-profile
ddf6fe37 12873@item -fipa-profile
d77de738
ML
12874Perform interprocedural profile propagation. The functions called only from
12875cold functions are marked as cold. Also functions executed once (such as
12876@code{cold}, @code{noreturn}, static constructors or destructors) are
12877identified. Cold functions and loop less parts of functions executed once are
12878then optimized for size.
12879Enabled by default at @option{-O1} and higher.
12880
d77de738 12881@opindex fipa-modref
ddf6fe37 12882@item -fipa-modref
d77de738
ML
12883Perform interprocedural mod/ref analysis. This optimization analyzes the side
12884effects of functions (memory locations that are modified or referenced) and
12885enables better optimization across the function call boundary. This flag is
12886enabled by default at @option{-O1} and higher.
12887
d77de738 12888@opindex fipa-cp
ddf6fe37 12889@item -fipa-cp
d77de738
ML
12890Perform interprocedural constant propagation.
12891This optimization analyzes the program to determine when values passed
12892to functions are constants and then optimizes accordingly.
12893This optimization can substantially increase performance
12894if the application has constants passed to functions.
12895This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
12896It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12897
d77de738 12898@opindex fipa-cp-clone
ddf6fe37 12899@item -fipa-cp-clone
d77de738
ML
12900Perform function cloning to make interprocedural constant propagation stronger.
12901When enabled, interprocedural constant propagation performs function cloning
12902when externally visible function can be called with constant arguments.
12903Because this optimization can create multiple copies of functions,
12904it may significantly increase code size
12905(see @option{--param ipa-cp-unit-growth=@var{value}}).
12906This flag is enabled by default at @option{-O3}.
12907It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12908
d77de738 12909@opindex fipa-bit-cp
ddf6fe37 12910@item -fipa-bit-cp
d77de738
ML
12911When enabled, perform interprocedural bitwise constant
12912propagation. This flag is enabled by default at @option{-O2} and
12913by @option{-fprofile-use} and @option{-fauto-profile}.
12914It requires that @option{-fipa-cp} is enabled.
12915
d77de738 12916@opindex fipa-vrp
ddf6fe37 12917@item -fipa-vrp
d77de738
ML
12918When enabled, perform interprocedural propagation of value
12919ranges. This flag is enabled by default at @option{-O2}. It requires
12920that @option{-fipa-cp} is enabled.
12921
d77de738 12922@opindex fipa-icf
ddf6fe37 12923@item -fipa-icf
d77de738
ML
12924Perform Identical Code Folding for functions and read-only variables.
12925The optimization reduces code size and may disturb unwind stacks by replacing
12926a function by equivalent one with a different name. The optimization works
12927more effectively with link-time optimization enabled.
12928
12929Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
12930works on different levels and thus the optimizations are not same - there are
12931equivalences that are found only by GCC and equivalences found only by Gold.
12932
12933This flag is enabled by default at @option{-O2} and @option{-Os}.
12934
d77de738 12935@opindex flive-patching
ddf6fe37 12936@item -flive-patching=@var{level}
d77de738
ML
12937Control GCC's optimizations to produce output suitable for live-patching.
12938
12939If the compiler's optimization uses a function's body or information extracted
12940from its body to optimize/change another function, the latter is called an
12941impacted function of the former. If a function is patched, its impacted
12942functions should be patched too.
12943
12944The impacted functions are determined by the compiler's interprocedural
12945optimizations. For example, a caller is impacted when inlining a function
12946into its caller,
12947cloning a function and changing its caller to call this new clone,
12948or extracting a function's pureness/constness information to optimize
12949its direct or indirect callers, etc.
12950
12951Usually, the more IPA optimizations enabled, the larger the number of
12952impacted functions for each function. In order to control the number of
12953impacted functions and more easily compute the list of impacted function,
12954IPA optimizations can be partially enabled at two different levels.
12955
12956The @var{level} argument should be one of the following:
12957
12958@table @samp
12959
12960@item inline-clone
12961
12962Only enable inlining and cloning optimizations, which includes inlining,
12963cloning, interprocedural scalar replacement of aggregates and partial inlining.
12964As a result, when patching a function, all its callers and its clones'
12965callers are impacted, therefore need to be patched as well.
12966
12967@option{-flive-patching=inline-clone} disables the following optimization flags:
12968@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra @gol
12969-fipa-icf -fipa-icf-functions -fipa-icf-variables @gol
4ace81b6
SL
12970-fipa-bit-cp -fipa-vrp -fipa-pure-const @gol
12971-fipa-reference-addressable @gol
d77de738
ML
12972-fipa-stack-alignment -fipa-modref}
12973
12974@item inline-only-static
12975
12976Only enable inlining of static functions.
12977As a result, when patching a static function, all its callers are impacted
12978and so need to be patched as well.
12979
12980In addition to all the flags that @option{-flive-patching=inline-clone}
12981disables,
12982@option{-flive-patching=inline-only-static} disables the following additional
12983optimization flags:
12984@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
12985
12986@end table
12987
12988When @option{-flive-patching} is specified without any value, the default value
12989is @var{inline-clone}.
12990
12991This flag is disabled by default.
12992
12993Note that @option{-flive-patching} is not supported with link-time optimization
12994(@option{-flto}).
12995
d77de738 12996@opindex fisolate-erroneous-paths-dereference
ddf6fe37 12997@item -fisolate-erroneous-paths-dereference
d77de738
ML
12998Detect paths that trigger erroneous or undefined behavior due to
12999dereferencing a null pointer. Isolate those paths from the main control
13000flow and turn the statement with erroneous or undefined behavior into a trap.
13001This flag is enabled by default at @option{-O2} and higher and depends on
13002@option{-fdelete-null-pointer-checks} also being enabled.
13003
d77de738 13004@opindex fisolate-erroneous-paths-attribute
ddf6fe37 13005@item -fisolate-erroneous-paths-attribute
d77de738
ML
13006Detect paths that trigger erroneous or undefined behavior due to a null value
13007being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
13008attribute. Isolate those paths from the main control flow and turn the
13009statement with erroneous or undefined behavior into a trap. This is not
13010currently enabled, but may be enabled by @option{-O2} in the future.
13011
d77de738 13012@opindex ftree-sink
ddf6fe37 13013@item -ftree-sink
d77de738
ML
13014Perform forward store motion on trees. This flag is
13015enabled by default at @option{-O1} and higher.
13016
d77de738 13017@opindex ftree-bit-ccp
ddf6fe37 13018@item -ftree-bit-ccp
d77de738
ML
13019Perform sparse conditional bit constant propagation on trees and propagate
13020pointer alignment information.
13021This pass only operates on local scalar variables and is enabled by default
13022at @option{-O1} and higher, except for @option{-Og}.
13023It requires that @option{-ftree-ccp} is enabled.
13024
d77de738 13025@opindex ftree-ccp
ddf6fe37 13026@item -ftree-ccp
d77de738
ML
13027Perform sparse conditional constant propagation (CCP) on trees. This
13028pass only operates on local scalar variables and is enabled by default
13029at @option{-O1} and higher.
13030
d77de738 13031@opindex fssa-backprop
ddf6fe37 13032@item -fssa-backprop
d77de738
ML
13033Propagate information about uses of a value up the definition chain
13034in order to simplify the definitions. For example, this pass strips
13035sign operations if the sign of a value never matters. The flag is
13036enabled by default at @option{-O1} and higher.
13037
d77de738 13038@opindex fssa-phiopt
ddf6fe37 13039@item -fssa-phiopt
d77de738
ML
13040Perform pattern matching on SSA PHI nodes to optimize conditional
13041code. This pass is enabled by default at @option{-O1} and higher,
13042except for @option{-Og}.
13043
d77de738 13044@opindex ftree-switch-conversion
ddf6fe37 13045@item -ftree-switch-conversion
d77de738
ML
13046Perform conversion of simple initializations in a switch to
13047initializations from a scalar array. This flag is enabled by default
13048at @option{-O2} and higher.
13049
d77de738 13050@opindex ftree-tail-merge
ddf6fe37 13051@item -ftree-tail-merge
d77de738
ML
13052Look for identical code sequences. When found, replace one with a jump to the
13053other. This optimization is known as tail merging or cross jumping. This flag
13054is enabled by default at @option{-O2} and higher. The compilation time
13055in this pass can
13056be limited using @option{max-tail-merge-comparisons} parameter and
13057@option{max-tail-merge-iterations} parameter.
13058
d77de738 13059@opindex ftree-dce
ddf6fe37 13060@item -ftree-dce
d77de738
ML
13061Perform dead code elimination (DCE) on trees. This flag is enabled by
13062default at @option{-O1} and higher.
13063
d77de738 13064@opindex ftree-builtin-call-dce
ddf6fe37 13065@item -ftree-builtin-call-dce
d77de738
ML
13066Perform conditional dead code elimination (DCE) for calls to built-in functions
13067that may set @code{errno} but are otherwise free of side effects. This flag is
13068enabled by default at @option{-O2} and higher if @option{-Os} is not also
13069specified.
13070
d77de738
ML
13071@opindex ffinite-loops
13072@opindex fno-finite-loops
ddf6fe37 13073@item -ffinite-loops
d77de738
ML
13074Assume that a loop with an exit will eventually take the exit and not loop
13075indefinitely. This allows the compiler to remove loops that otherwise have
13076no side-effects, not considering eventual endless looping as such.
13077
13078This option is enabled by default at @option{-O2} for C++ with -std=c++11
13079or higher.
13080
d77de738 13081@opindex ftree-dominator-opts
ddf6fe37 13082@item -ftree-dominator-opts
d77de738
ML
13083Perform a variety of simple scalar cleanups (constant/copy
13084propagation, redundancy elimination, range propagation and expression
13085simplification) based on a dominator tree traversal. This also
13086performs jump threading (to reduce jumps to jumps). This flag is
13087enabled by default at @option{-O1} and higher.
13088
d77de738 13089@opindex ftree-dse
ddf6fe37 13090@item -ftree-dse
d77de738
ML
13091Perform dead store elimination (DSE) on trees. A dead store is a store into
13092a memory location that is later overwritten by another store without
13093any intervening loads. In this case the earlier store can be deleted. This
13094flag is enabled by default at @option{-O1} and higher.
13095
d77de738 13096@opindex ftree-ch
ddf6fe37 13097@item -ftree-ch
d77de738
ML
13098Perform loop header copying on trees. This is beneficial since it increases
13099effectiveness of code motion optimizations. It also saves one jump. This flag
13100is enabled by default at @option{-O1} and higher. It is not enabled
13101for @option{-Os}, since it usually increases code size.
13102
d77de738 13103@opindex ftree-loop-optimize
ddf6fe37 13104@item -ftree-loop-optimize
d77de738
ML
13105Perform loop optimizations on trees. This flag is enabled by default
13106at @option{-O1} and higher.
13107
d77de738
ML
13108@opindex ftree-loop-linear
13109@opindex floop-strip-mine
13110@opindex floop-block
ddf6fe37
AA
13111@item -ftree-loop-linear
13112@itemx -floop-strip-mine
13113@itemx -floop-block
d77de738
ML
13114Perform loop nest optimizations. Same as
13115@option{-floop-nest-optimize}. To use this code transformation, GCC has
13116to be configured with @option{--with-isl} to enable the Graphite loop
13117transformation infrastructure.
13118
d77de738 13119@opindex fgraphite-identity
ddf6fe37 13120@item -fgraphite-identity
d77de738
ML
13121Enable the identity transformation for graphite. For every SCoP we generate
13122the polyhedral representation and transform it back to gimple. Using
13123@option{-fgraphite-identity} we can check the costs or benefits of the
13124GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13125are also performed by the code generator isl, like index splitting and
13126dead code elimination in loops.
13127
d77de738 13128@opindex floop-nest-optimize
ddf6fe37 13129@item -floop-nest-optimize
d77de738
ML
13130Enable the isl based loop nest optimizer. This is a generic loop nest
13131optimizer based on the Pluto optimization algorithms. It calculates a loop
13132structure optimized for data-locality and parallelism. This option
13133is experimental.
13134
d77de738 13135@opindex floop-parallelize-all
ddf6fe37 13136@item -floop-parallelize-all
d77de738
ML
13137Use the Graphite data dependence analysis to identify loops that can
13138be parallelized. Parallelize all the loops that can be analyzed to
13139not contain loop carried dependences without checking that it is
13140profitable to parallelize the loops.
13141
d77de738 13142@opindex ftree-coalesce-vars
ddf6fe37 13143@item -ftree-coalesce-vars
d77de738
ML
13144While transforming the program out of the SSA representation, attempt to
13145reduce copying by coalescing versions of different user-defined
13146variables, instead of just compiler temporaries. This may severely
13147limit the ability to debug an optimized program compiled with
13148@option{-fno-var-tracking-assignments}. In the negated form, this flag
13149prevents SSA coalescing of user variables. This option is enabled by
13150default if optimization is enabled, and it does very little otherwise.
13151
d77de738 13152@opindex ftree-loop-if-convert
ddf6fe37 13153@item -ftree-loop-if-convert
d77de738
ML
13154Attempt to transform conditional jumps in the innermost loops to
13155branch-less equivalents. The intent is to remove control-flow from
13156the innermost loops in order to improve the ability of the
13157vectorization pass to handle these loops. This is enabled by default
13158if vectorization is enabled.
13159
d77de738 13160@opindex ftree-loop-distribution
ddf6fe37 13161@item -ftree-loop-distribution
d77de738
ML
13162Perform loop distribution. This flag can improve cache performance on
13163big loop bodies and allow further loop optimizations, like
13164parallelization or vectorization, to take place. For example, the loop
13165@smallexample
13166DO I = 1, N
13167 A(I) = B(I) + C
13168 D(I) = E(I) * F
13169ENDDO
13170@end smallexample
13171is transformed to
13172@smallexample
13173DO I = 1, N
13174 A(I) = B(I) + C
13175ENDDO
13176DO I = 1, N
13177 D(I) = E(I) * F
13178ENDDO
13179@end smallexample
13180This flag is enabled by default at @option{-O3}.
13181It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13182
d77de738 13183@opindex ftree-loop-distribute-patterns
ddf6fe37 13184@item -ftree-loop-distribute-patterns
d77de738
ML
13185Perform loop distribution of patterns that can be code generated with
13186calls to a library. This flag is enabled by default at @option{-O2} and
13187higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13188
13189This pass distributes the initialization loops and generates a call to
13190memset zero. For example, the loop
13191@smallexample
13192DO I = 1, N
13193 A(I) = 0
13194 B(I) = A(I) + I
13195ENDDO
13196@end smallexample
13197is transformed to
13198@smallexample
13199DO I = 1, N
13200 A(I) = 0
13201ENDDO
13202DO I = 1, N
13203 B(I) = A(I) + I
13204ENDDO
13205@end smallexample
13206and the initialization loop is transformed into a call to memset zero.
13207This flag is enabled by default at @option{-O3}.
13208It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13209
d77de738 13210@opindex floop-interchange
ddf6fe37 13211@item -floop-interchange
d77de738
ML
13212Perform loop interchange outside of graphite. This flag can improve cache
13213performance on loop nest and allow further loop optimizations, like
13214vectorization, to take place. For example, the loop
13215@smallexample
13216for (int i = 0; i < N; i++)
13217 for (int j = 0; j < N; j++)
13218 for (int k = 0; k < N; k++)
13219 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13220@end smallexample
13221is transformed to
13222@smallexample
13223for (int i = 0; i < N; i++)
13224 for (int k = 0; k < N; k++)
13225 for (int j = 0; j < N; j++)
13226 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13227@end smallexample
13228This flag is enabled by default at @option{-O3}.
13229It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13230
d77de738 13231@opindex floop-unroll-and-jam
ddf6fe37 13232@item -floop-unroll-and-jam
d77de738
ML
13233Apply unroll and jam transformations on feasible loops. In a loop
13234nest this unrolls the outer loop by some factor and fuses the resulting
13235multiple inner loops. This flag is enabled by default at @option{-O3}.
13236It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13237
d77de738 13238@opindex ftree-loop-im
ddf6fe37 13239@item -ftree-loop-im
d77de738
ML
13240Perform loop invariant motion on trees. This pass moves only invariants that
13241are hard to handle at RTL level (function calls, operations that expand to
13242nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13243operands of conditions that are invariant out of the loop, so that we can use
13244just trivial invariantness analysis in loop unswitching. The pass also includes
13245store motion.
13246
d77de738 13247@opindex ftree-loop-ivcanon
ddf6fe37 13248@item -ftree-loop-ivcanon
d77de738
ML
13249Create a canonical counter for number of iterations in loops for which
13250determining number of iterations requires complicated analysis. Later
13251optimizations then may determine the number easily. Useful especially
13252in connection with unrolling.
13253
d77de738 13254@opindex ftree-scev-cprop
ddf6fe37 13255@item -ftree-scev-cprop
d77de738
ML
13256Perform final value replacement. If a variable is modified in a loop
13257in such a way that its value when exiting the loop can be determined using
13258only its initial value and the number of loop iterations, replace uses of
13259the final value by such a computation, provided it is sufficiently cheap.
13260This reduces data dependencies and may allow further simplifications.
13261Enabled by default at @option{-O1} and higher.
13262
d77de738 13263@opindex fivopts
ddf6fe37 13264@item -fivopts
d77de738
ML
13265Perform induction variable optimizations (strength reduction, induction
13266variable merging and induction variable elimination) on trees.
13267
d77de738 13268@opindex ftree-parallelize-loops
ddf6fe37 13269@item -ftree-parallelize-loops=n
d77de738
ML
13270Parallelize loops, i.e., split their iteration space to run in n threads.
13271This is only possible for loops whose iterations are independent
13272and can be arbitrarily reordered. The optimization is only
13273profitable on multiprocessor machines, for loops that are CPU-intensive,
13274rather than constrained e.g.@: by memory bandwidth. This option
13275implies @option{-pthread}, and thus is only supported on targets
13276that have support for @option{-pthread}.
13277
d77de738 13278@opindex ftree-pta
ddf6fe37 13279@item -ftree-pta
d77de738
ML
13280Perform function-local points-to analysis on trees. This flag is
13281enabled by default at @option{-O1} and higher, except for @option{-Og}.
13282
d77de738 13283@opindex ftree-sra
ddf6fe37 13284@item -ftree-sra
d77de738
ML
13285Perform scalar replacement of aggregates. This pass replaces structure
13286references with scalars to prevent committing structures to memory too
13287early. This flag is enabled by default at @option{-O1} and higher,
13288except for @option{-Og}.
13289
d77de738 13290@opindex fstore-merging
ddf6fe37 13291@item -fstore-merging
d77de738
ML
13292Perform merging of narrow stores to consecutive memory addresses. This pass
13293merges contiguous stores of immediate values narrower than a word into fewer
13294wider stores to reduce the number of instructions. This is enabled by default
13295at @option{-O2} and higher as well as @option{-Os}.
13296
d77de738 13297@opindex ftree-ter
ddf6fe37 13298@item -ftree-ter
d77de738
ML
13299Perform temporary expression replacement during the SSA->normal phase. Single
13300use/single def temporaries are replaced at their use location with their
13301defining expression. This results in non-GIMPLE code, but gives the expanders
13302much more complex trees to work on resulting in better RTL generation. This is
13303enabled by default at @option{-O1} and higher.
13304
d77de738 13305@opindex ftree-slsr
ddf6fe37 13306@item -ftree-slsr
d77de738
ML
13307Perform straight-line strength reduction on trees. This recognizes related
13308expressions involving multiplications and replaces them by less expensive
13309calculations when possible. This is enabled by default at @option{-O1} and
13310higher.
13311
d77de738 13312@opindex ftree-vectorize
ddf6fe37 13313@item -ftree-vectorize
d77de738
ML
13314Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13315and @option{-ftree-slp-vectorize} if not explicitly specified.
13316
d77de738 13317@opindex ftree-loop-vectorize
ddf6fe37 13318@item -ftree-loop-vectorize
d77de738
ML
13319Perform loop vectorization on trees. This flag is enabled by default at
13320@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13321and @option{-fauto-profile}.
13322
d77de738 13323@opindex ftree-slp-vectorize
ddf6fe37 13324@item -ftree-slp-vectorize
d77de738
ML
13325Perform basic block vectorization on trees. This flag is enabled by default at
13326@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13327and @option{-fauto-profile}.
13328
d77de738 13329@opindex ftrivial-auto-var-init
ddf6fe37 13330@item -ftrivial-auto-var-init=@var{choice}
d77de738
ML
13331Initialize automatic variables with either a pattern or with zeroes to increase
13332the security and predictability of a program by preventing uninitialized memory
13333disclosure and use.
13334GCC still considers an automatic variable that doesn't have an explicit
13335initializer as uninitialized, @option{-Wuninitialized} and
13336@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13337warning messages on such automatic variables and the compiler will
13338perform optimization as if the variable were uninitialized.
d77de738
ML
13339With this option, GCC will also initialize any padding of automatic variables
13340that have structure or union types to zeroes.
13341However, the current implementation cannot initialize automatic variables that
13342are declared between the controlling expression and the first case of a
13343@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13344such cases.
13345
13346The three values of @var{choice} are:
13347
13348@itemize @bullet
13349@item
13350@samp{uninitialized} doesn't initialize any automatic variables.
13351This is C and C++'s default.
13352
13353@item
13354@samp{pattern} Initialize automatic variables with values which will likely
13355transform logic bugs into crashes down the line, are easily recognized in a
13356crash dump and without being values that programmers can rely on for useful
13357program semantics.
13358The current value is byte-repeatable pattern with byte "0xFE".
13359The values used for pattern initialization might be changed in the future.
13360
13361@item
13362@samp{zero} Initialize automatic variables with zeroes.
13363@end itemize
13364
13365The default is @samp{uninitialized}.
13366
13367You can control this behavior for a specific variable by using the variable
13368attribute @code{uninitialized} (@pxref{Variable Attributes}).
13369
d77de738 13370@opindex fvect-cost-model
ddf6fe37 13371@item -fvect-cost-model=@var{model}
d77de738
ML
13372Alter the cost model used for vectorization. The @var{model} argument
13373should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13374@samp{very-cheap}.
13375With the @samp{unlimited} model the vectorized code-path is assumed
13376to be profitable while with the @samp{dynamic} model a runtime check
13377guards the vectorized code-path to enable it only for iteration
13378counts that will likely execute faster than when executing the original
13379scalar loop. The @samp{cheap} model disables vectorization of
13380loops where doing so would be cost prohibitive for example due to
13381required runtime checks for data dependence or alignment but otherwise
13382is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13383allows vectorization if the vector code would entirely replace the
13384scalar code that is being vectorized. For example, if each iteration
13385of a vectorized loop would only be able to handle exactly four iterations
13386of the scalar loop, the @samp{very-cheap} model would only allow
13387vectorization if the scalar iteration count is known to be a multiple
13388of four.
13389
13390The default cost model depends on other optimization flags and is
13391either @samp{dynamic} or @samp{cheap}.
13392
d77de738 13393@opindex fsimd-cost-model
ddf6fe37 13394@item -fsimd-cost-model=@var{model}
d77de738
ML
13395Alter the cost model used for vectorization of loops marked with the OpenMP
13396simd directive. The @var{model} argument should be one of
13397@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13398have the same meaning as described in @option{-fvect-cost-model} and by
13399default a cost model defined with @option{-fvect-cost-model} is used.
13400
d77de738 13401@opindex ftree-vrp
ddf6fe37 13402@item -ftree-vrp
d77de738
ML
13403Perform Value Range Propagation on trees. This is similar to the
13404constant propagation pass, but instead of values, ranges of values are
13405propagated. This allows the optimizers to remove unnecessary range
13406checks like array bound checks and null pointer checks. This is
13407enabled by default at @option{-O2} and higher. Null pointer check
13408elimination is only done if @option{-fdelete-null-pointer-checks} is
13409enabled.
13410
d77de738 13411@opindex fsplit-paths
ddf6fe37 13412@item -fsplit-paths
d77de738
ML
13413Split paths leading to loop backedges. This can improve dead code
13414elimination and common subexpression elimination. This is enabled by
13415default at @option{-O3} and above.
13416
d77de738 13417@opindex fsplit-ivs-in-unroller
ddf6fe37 13418@item -fsplit-ivs-in-unroller
d77de738
ML
13419Enables expression of values of induction variables in later iterations
13420of the unrolled loop using the value in the first iteration. This breaks
13421long dependency chains, thus improving efficiency of the scheduling passes.
13422
13423A combination of @option{-fweb} and CSE is often sufficient to obtain the
13424same effect. However, that is not reliable in cases where the loop body
13425is more complicated than a single basic block. It also does not work at all
13426on some architectures due to restrictions in the CSE pass.
13427
13428This optimization is enabled by default.
13429
d77de738 13430@opindex fvariable-expansion-in-unroller
ddf6fe37 13431@item -fvariable-expansion-in-unroller
d77de738
ML
13432With this option, the compiler creates multiple copies of some
13433local variables when unrolling a loop, which can result in superior code.
13434
13435This optimization is enabled by default for PowerPC targets, but disabled
13436by default otherwise.
13437
d77de738 13438@opindex fpartial-inlining
ddf6fe37 13439@item -fpartial-inlining
d77de738
ML
13440Inline parts of functions. This option has any effect only
13441when inlining itself is turned on by the @option{-finline-functions}
13442or @option{-finline-small-functions} options.
13443
13444Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13445
d77de738 13446@opindex fpredictive-commoning
ddf6fe37 13447@item -fpredictive-commoning
d77de738
ML
13448Perform predictive commoning optimization, i.e., reusing computations
13449(especially memory loads and stores) performed in previous
13450iterations of loops.
13451
13452This option is enabled at level @option{-O3}.
13453It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13454
d77de738 13455@opindex fprefetch-loop-arrays
ddf6fe37 13456@item -fprefetch-loop-arrays
d77de738
ML
13457If supported by the target machine, generate instructions to prefetch
13458memory to improve the performance of loops that access large arrays.
13459
13460This option may generate better or worse code; results are highly
13461dependent on the structure of loops within the source code.
13462
13463Disabled at level @option{-Os}.
13464
d77de738
ML
13465@opindex fno-printf-return-value
13466@opindex fprintf-return-value
ddf6fe37 13467@item -fno-printf-return-value
d77de738
ML
13468Do not substitute constants for known return value of formatted output
13469functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13470@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13471transformation allows GCC to optimize or even eliminate branches based
13472on the known return value of these functions called with arguments that
13473are either constant, or whose values are known to be in a range that
13474makes determining the exact return value possible. For example, when
13475@option{-fprintf-return-value} is in effect, both the branch and the
13476body of the @code{if} statement (but not the call to @code{snprint})
13477can be optimized away when @code{i} is a 32-bit or smaller integer
13478because the return value is guaranteed to be at most 8.
13479
13480@smallexample
13481char buf[9];
13482if (snprintf (buf, "%08x", i) >= sizeof buf)
13483 @dots{}
13484@end smallexample
13485
13486The @option{-fprintf-return-value} option relies on other optimizations
13487and yields best results with @option{-O2} and above. It works in tandem
13488with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13489options. The @option{-fprintf-return-value} option is enabled by default.
13490
d77de738
ML
13491@opindex fno-peephole
13492@opindex fpeephole
13493@opindex fno-peephole2
13494@opindex fpeephole2
ddf6fe37
AA
13495@item -fno-peephole
13496@itemx -fno-peephole2
d77de738
ML
13497Disable any machine-specific peephole optimizations. The difference
13498between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13499are implemented in the compiler; some targets use one, some use the
13500other, a few use both.
13501
13502@option{-fpeephole} is enabled by default.
13503@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13504
d77de738
ML
13505@opindex fno-guess-branch-probability
13506@opindex fguess-branch-probability
ddf6fe37 13507@item -fno-guess-branch-probability
d77de738
ML
13508Do not guess branch probabilities using heuristics.
13509
13510GCC uses heuristics to guess branch probabilities if they are
13511not provided by profiling feedback (@option{-fprofile-arcs}). These
13512heuristics are based on the control flow graph. If some branch probabilities
13513are specified by @code{__builtin_expect}, then the heuristics are
13514used to guess branch probabilities for the rest of the control flow graph,
13515taking the @code{__builtin_expect} info into account. The interactions
13516between the heuristics and @code{__builtin_expect} can be complex, and in
13517some cases, it may be useful to disable the heuristics so that the effects
13518of @code{__builtin_expect} are easier to understand.
13519
13520It is also possible to specify expected probability of the expression
13521with @code{__builtin_expect_with_probability} built-in function.
13522
13523The default is @option{-fguess-branch-probability} at levels
13524@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13525
d77de738 13526@opindex freorder-blocks
ddf6fe37 13527@item -freorder-blocks
d77de738
ML
13528Reorder basic blocks in the compiled function in order to reduce number of
13529taken branches and improve code locality.
13530
13531Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13532
d77de738 13533@opindex freorder-blocks-algorithm
ddf6fe37 13534@item -freorder-blocks-algorithm=@var{algorithm}
d77de738
ML
13535Use the specified algorithm for basic block reordering. The
13536@var{algorithm} argument can be @samp{simple}, which does not increase
13537code size (except sometimes due to secondary effects like alignment),
13538or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13539put all often executed code together, minimizing the number of branches
13540executed by making extra copies of code.
13541
13542The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13543@samp{stc} at levels @option{-O2}, @option{-O3}.
13544
d77de738 13545@opindex freorder-blocks-and-partition
ddf6fe37 13546@item -freorder-blocks-and-partition
d77de738
ML
13547In addition to reordering basic blocks in the compiled function, in order
13548to reduce number of taken branches, partitions hot and cold basic blocks
13549into separate sections of the assembly and @file{.o} files, to improve
13550paging and cache locality performance.
13551
13552This optimization is automatically turned off in the presence of
13553exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13554section attribute and on any architecture that does not support named
13555sections. When @option{-fsplit-stack} is used this option is not
13556enabled by default (to avoid linker errors), but may be enabled
13557explicitly (if using a working linker).
13558
13559Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13560
d77de738 13561@opindex freorder-functions
ddf6fe37 13562@item -freorder-functions
d77de738
ML
13563Reorder functions in the object file in order to
13564improve code locality. This is implemented by using special
13565subsections @code{.text.hot} for most frequently executed functions and
13566@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13567the linker so object file format must support named sections and linker must
13568place them in a reasonable way.
13569
13570This option isn't effective unless you either provide profile feedback
13571(see @option{-fprofile-arcs} for details) or manually annotate functions with
13572@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13573
13574Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13575
d77de738 13576@opindex fstrict-aliasing
ddf6fe37 13577@item -fstrict-aliasing
d77de738
ML
13578Allow the compiler to assume the strictest aliasing rules applicable to
13579the language being compiled. For C (and C++), this activates
13580optimizations based on the type of expressions. In particular, an
13581object of one type is assumed never to reside at the same address as an
13582object of a different type, unless the types are almost the same. For
13583example, an @code{unsigned int} can alias an @code{int}, but not a
13584@code{void*} or a @code{double}. A character type may alias any other
13585type.
13586
13587@anchor{Type-punning}Pay special attention to code like this:
13588@smallexample
13589union a_union @{
13590 int i;
13591 double d;
13592@};
13593
13594int f() @{
13595 union a_union t;
13596 t.d = 3.0;
13597 return t.i;
13598@}
13599@end smallexample
13600The practice of reading from a different union member than the one most
13601recently written to (called ``type-punning'') is common. Even with
13602@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13603is accessed through the union type. So, the code above works as
13604expected. @xref{Structures unions enumerations and bit-fields
13605implementation}. However, this code might not:
13606@smallexample
13607int f() @{
13608 union a_union t;
13609 int* ip;
13610 t.d = 3.0;
13611 ip = &t.i;
13612 return *ip;
13613@}
13614@end smallexample
13615
13616Similarly, access by taking the address, casting the resulting pointer
13617and dereferencing the result has undefined behavior, even if the cast
13618uses a union type, e.g.:
13619@smallexample
13620int f() @{
13621 double d = 3.0;
13622 return ((union a_union *) &d)->i;
13623@}
13624@end smallexample
13625
13626The @option{-fstrict-aliasing} option is enabled at levels
13627@option{-O2}, @option{-O3}, @option{-Os}.
13628
d77de738 13629@opindex fipa-strict-aliasing
ddf6fe37 13630@item -fipa-strict-aliasing
d77de738
ML
13631Controls whether rules of @option{-fstrict-aliasing} are applied across
13632function boundaries. Note that if multiple functions gets inlined into a
13633single function the memory accesses are no longer considered to be crossing a
13634function boundary.
13635
13636The @option{-fipa-strict-aliasing} option is enabled by default and is
13637effective only in combination with @option{-fstrict-aliasing}.
13638
ddf6fe37 13639@opindex falign-functions
d77de738
ML
13640@item -falign-functions
13641@itemx -falign-functions=@var{n}
13642@itemx -falign-functions=@var{n}:@var{m}
13643@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13644@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13645Align the start of functions to the next power-of-two greater than or
13646equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13647least the first @var{m} bytes of the function can be fetched by the CPU
13648without crossing an @var{n}-byte alignment boundary.
13649
13650If @var{m} is not specified, it defaults to @var{n}.
13651
13652Examples: @option{-falign-functions=32} aligns functions to the next
1365332-byte boundary, @option{-falign-functions=24} aligns to the next
1365432-byte boundary only if this can be done by skipping 23 bytes or less,
13655@option{-falign-functions=32:7} aligns to the next
1365632-byte boundary only if this can be done by skipping 6 bytes or less.
13657
13658The second pair of @var{n2}:@var{m2} values allows you to specify
13659a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13660the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13661otherwise aligns to the next 32-byte boundary if this can be done
13662by skipping 2 bytes or less.
13663If @var{m2} is not specified, it defaults to @var{n2}.
13664
13665Some assemblers only support this flag when @var{n} is a power of two;
13666in that case, it is rounded up.
13667
13668@option{-fno-align-functions} and @option{-falign-functions=1} are
13669equivalent and mean that functions are not aligned.
13670
13671If @var{n} is not specified or is zero, use a machine-dependent default.
13672The maximum allowed @var{n} option value is 65536.
13673
13674Enabled at levels @option{-O2}, @option{-O3}.
13675
13676@item -flimit-function-alignment
13677If this option is enabled, the compiler tries to avoid unnecessarily
13678overaligning functions. It attempts to instruct the assembler to align
13679by the amount specified by @option{-falign-functions}, but not to
13680skip more bytes than the size of the function.
13681
ddf6fe37 13682@opindex falign-labels
d77de738
ML
13683@item -falign-labels
13684@itemx -falign-labels=@var{n}
13685@itemx -falign-labels=@var{n}:@var{m}
13686@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13687@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13688Align all branch targets to a power-of-two boundary.
13689
13690Parameters of this option are analogous to the @option{-falign-functions} option.
13691@option{-fno-align-labels} and @option{-falign-labels=1} are
13692equivalent and mean that labels are not aligned.
13693
13694If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13695are greater than this value, then their values are used instead.
13696
13697If @var{n} is not specified or is zero, use a machine-dependent default
13698which is very likely to be @samp{1}, meaning no alignment.
13699The maximum allowed @var{n} option value is 65536.
13700
13701Enabled at levels @option{-O2}, @option{-O3}.
13702
ddf6fe37 13703@opindex falign-loops
d77de738
ML
13704@item -falign-loops
13705@itemx -falign-loops=@var{n}
13706@itemx -falign-loops=@var{n}:@var{m}
13707@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13708@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13709Align loops to a power-of-two boundary. If the loops are executed
13710many times, this makes up for any execution of the dummy padding
13711instructions.
13712
13713If @option{-falign-labels} is greater than this value, then its value
13714is used instead.
13715
13716Parameters of this option are analogous to the @option{-falign-functions} option.
13717@option{-fno-align-loops} and @option{-falign-loops=1} are
13718equivalent and mean that loops are not aligned.
13719The maximum allowed @var{n} option value is 65536.
13720
13721If @var{n} is not specified or is zero, use a machine-dependent default.
13722
13723Enabled at levels @option{-O2}, @option{-O3}.
13724
ddf6fe37 13725@opindex falign-jumps
d77de738
ML
13726@item -falign-jumps
13727@itemx -falign-jumps=@var{n}
13728@itemx -falign-jumps=@var{n}:@var{m}
13729@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13730@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
d77de738
ML
13731Align branch targets to a power-of-two boundary, for branch targets
13732where the targets can only be reached by jumping. In this case,
13733no dummy operations need be executed.
13734
13735If @option{-falign-labels} is greater than this value, then its value
13736is used instead.
13737
13738Parameters of this option are analogous to the @option{-falign-functions} option.
13739@option{-fno-align-jumps} and @option{-falign-jumps=1} are
13740equivalent and mean that loops are not aligned.
13741
13742If @var{n} is not specified or is zero, use a machine-dependent default.
13743The maximum allowed @var{n} option value is 65536.
13744
13745Enabled at levels @option{-O2}, @option{-O3}.
13746
d77de738 13747@opindex fno-allocation-dce
ddf6fe37 13748@item -fno-allocation-dce
d77de738
ML
13749Do not remove unused C++ allocations in dead code elimination.
13750
d77de738 13751@opindex fallow-store-data-races
ddf6fe37 13752@item -fallow-store-data-races
d77de738
ML
13753Allow the compiler to perform optimizations that may introduce new data races
13754on stores, without proving that the variable cannot be concurrently accessed
13755by other threads. Does not affect optimization of local data. It is safe to
13756use this option if it is known that global data will not be accessed by
13757multiple threads.
13758
13759Examples of optimizations enabled by @option{-fallow-store-data-races} include
13760hoisting or if-conversions that may cause a value that was already in memory
13761to be re-written with that same value. Such re-writing is safe in a single
13762threaded context but may be unsafe in a multi-threaded context. Note that on
13763some processors, if-conversions may be required in order to enable
13764vectorization.
13765
13766Enabled at level @option{-Ofast}.
13767
d77de738 13768@opindex funit-at-a-time
ddf6fe37 13769@item -funit-at-a-time
d77de738
ML
13770This option is left for compatibility reasons. @option{-funit-at-a-time}
13771has no effect, while @option{-fno-unit-at-a-time} implies
13772@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
13773
13774Enabled by default.
13775
d77de738
ML
13776@opindex fno-toplevel-reorder
13777@opindex ftoplevel-reorder
ddf6fe37 13778@item -fno-toplevel-reorder
d77de738
ML
13779Do not reorder top-level functions, variables, and @code{asm}
13780statements. Output them in the same order that they appear in the
13781input file. When this option is used, unreferenced static variables
13782are not removed. This option is intended to support existing code
13783that relies on a particular ordering. For new code, it is better to
13784use attributes when possible.
13785
13786@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
13787also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
13788Additionally @option{-fno-toplevel-reorder} implies
13789@option{-fno-section-anchors}.
13790
d77de738 13791@opindex funreachable-traps
ddf6fe37 13792@item -funreachable-traps
d77de738
ML
13793With this option, the compiler turns calls to
13794@code{__builtin_unreachable} into traps, instead of using them for
13795optimization. This also affects any such calls implicitly generated
13796by the compiler.
13797
13798This option has the same effect as @option{-fsanitize=unreachable
13799-fsanitize-trap=unreachable}, but does not affect the values of those
13800options. If @option{-fsanitize=unreachable} is enabled, that option
13801takes priority over this one.
13802
13803This option is enabled by default at @option{-O0} and @option{-Og}.
13804
d77de738 13805@opindex fweb
ddf6fe37 13806@item -fweb
d77de738
ML
13807Constructs webs as commonly used for register allocation purposes and assign
13808each web individual pseudo register. This allows the register allocation pass
13809to operate on pseudos directly, but also strengthens several other optimization
13810passes, such as CSE, loop optimizer and trivial dead code remover. It can,
13811however, make debugging impossible, since variables no longer stay in a
13812``home register''.
13813
13814Enabled by default with @option{-funroll-loops}.
13815
d77de738 13816@opindex fwhole-program
ddf6fe37 13817@item -fwhole-program
d77de738
ML
13818Assume that the current compilation unit represents the whole program being
13819compiled. All public functions and variables with the exception of @code{main}
13820and those merged by attribute @code{externally_visible} become static functions
13821and in effect are optimized more aggressively by interprocedural optimizers.
13822
39ebd3a9
JH
13823With @option{-flto} this option has a limited use. In most cases the
13824precise list of symbols used or exported from the binary is known the
13825resolution info passed to the link-time optimizer by the linker plugin. It is
13826still useful if no linker plugin is used or during incremental link step when
13827final code is produced (with @option{-flto}
13828@option{-flinker-output=nolto-rel}).
d77de738 13829
d77de738 13830@opindex flto
ddf6fe37 13831@item -flto[=@var{n}]
d77de738
ML
13832This option runs the standard link-time optimizer. When invoked
13833with source code, it generates GIMPLE (one of GCC's internal
13834representations) and writes it to special ELF sections in the object
13835file. When the object files are linked together, all the function
13836bodies are read from these ELF sections and instantiated as if they
13837had been part of the same translation unit.
13838
13839To use the link-time optimizer, @option{-flto} and optimization
13840options should be specified at compile time and during the final link.
13841It is recommended that you compile all the files participating in the
13842same link with the same options and also specify those options at
13843link time.
13844For example:
13845
13846@smallexample
13847gcc -c -O2 -flto foo.c
13848gcc -c -O2 -flto bar.c
13849gcc -o myprog -flto -O2 foo.o bar.o
13850@end smallexample
13851
13852The first two invocations to GCC save a bytecode representation
13853of GIMPLE into special ELF sections inside @file{foo.o} and
13854@file{bar.o}. The final invocation reads the GIMPLE bytecode from
13855@file{foo.o} and @file{bar.o}, merges the two files into a single
13856internal image, and compiles the result as usual. Since both
13857@file{foo.o} and @file{bar.o} are merged into a single image, this
13858causes all the interprocedural analyses and optimizations in GCC to
13859work across the two files as if they were a single one. This means,
13860for example, that the inliner is able to inline functions in
13861@file{bar.o} into functions in @file{foo.o} and vice-versa.
13862
13863Another (simpler) way to enable link-time optimization is:
13864
13865@smallexample
13866gcc -o myprog -flto -O2 foo.c bar.c
13867@end smallexample
13868
13869The above generates bytecode for @file{foo.c} and @file{bar.c},
13870merges them together into a single GIMPLE representation and optimizes
13871them as usual to produce @file{myprog}.
13872
13873The important thing to keep in mind is that to enable link-time
13874optimizations you need to use the GCC driver to perform the link step.
13875GCC automatically performs link-time optimization if any of the
13876objects involved were compiled with the @option{-flto} command-line option.
13877You can always override
13878the automatic decision to do link-time optimization
13879by passing @option{-fno-lto} to the link command.
13880
13881To make whole program optimization effective, it is necessary to make
13882certain whole program assumptions. The compiler needs to know
13883what functions and variables can be accessed by libraries and runtime
13884outside of the link-time optimized unit. When supported by the linker,
13885the linker plugin (see @option{-fuse-linker-plugin}) passes information
13886to the compiler about used and externally visible symbols. When
13887the linker plugin is not available, @option{-fwhole-program} should be
13888used to allow the compiler to make these assumptions, which leads
13889to more aggressive optimization decisions.
13890
13891When a file is compiled with @option{-flto} without
13892@option{-fuse-linker-plugin}, the generated object file is larger than
13893a regular object file because it contains GIMPLE bytecodes and the usual
13894final code (see @option{-ffat-lto-objects}). This means that
13895object files with LTO information can be linked as normal object
13896files; if @option{-fno-lto} is passed to the linker, no
13897interprocedural optimizations are applied. Note that when
13898@option{-fno-fat-lto-objects} is enabled the compile stage is faster
13899but you cannot perform a regular, non-LTO link on them.
13900
13901When producing the final binary, GCC only
13902applies link-time optimizations to those files that contain bytecode.
13903Therefore, you can mix and match object files and libraries with
13904GIMPLE bytecodes and final object code. GCC automatically selects
13905which files to optimize in LTO mode and which files to link without
13906further processing.
13907
13908Generally, options specified at link time override those
13909specified at compile time, although in some cases GCC attempts to infer
13910link-time options from the settings used to compile the input files.
13911
13912If you do not specify an optimization level option @option{-O} at
13913link time, then GCC uses the highest optimization level
13914used when compiling the object files. Note that it is generally
13915ineffective to specify an optimization level option only at link time and
13916not at compile time, for two reasons. First, compiling without
13917optimization suppresses compiler passes that gather information
13918needed for effective optimization at link time. Second, some early
13919optimization passes can be performed only at compile time and
13920not at link time.
13921
13922There are some code generation flags preserved by GCC when
13923generating bytecodes, as they need to be used during the final link.
13924Currently, the following options and their settings are taken from
13925the first object file that explicitly specifies them:
13926@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
13927@option{-fgnu-tm} and all the @option{-m} target flags.
13928
13929The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
13930@option{-fPIE} are combined based on the following scheme:
13931
13932@smallexample
13933@option{-fPIC} + @option{-fpic} = @option{-fpic}
13934@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
13935@option{-fpic/-fPIC} + (no option) = (no option)
13936@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
13937@option{-fpic} + @option{-fPIE} = @option{-fpie}
13938@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
13939@end smallexample
13940
13941Certain ABI-changing flags are required to match in all compilation units,
13942and trying to override this at link time with a conflicting value
13943is ignored. This includes options such as @option{-freg-struct-return}
13944and @option{-fpcc-struct-return}.
13945
13946Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
13947@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
13948are passed through to the link stage and merged conservatively for
13949conflicting translation units. Specifically
13950@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
13951precedence; and for example @option{-ffp-contract=off} takes precedence
13952over @option{-ffp-contract=fast}. You can override them at link time.
13953
13954Diagnostic options such as @option{-Wstringop-overflow} are passed
13955through to the link stage and their setting matches that of the
13956compile-step at function granularity. Note that this matters only
13957for diagnostics emitted during optimization. Note that code
13958transforms such as inlining can lead to warnings being enabled
13959or disabled for regions if code not consistent with the setting
13960at compile time.
13961
13962When you need to pass options to the assembler via @option{-Wa} or
13963@option{-Xassembler} make sure to either compile such translation
13964units with @option{-fno-lto} or consistently use the same assembler
13965options on all translation units. You can alternatively also
13966specify assembler options at LTO link time.
13967
13968To enable debug info generation you need to supply @option{-g} at
13969compile time. If any of the input files at link time were built
13970with debug info generation enabled the link will enable debug info
13971generation as well. Any elaborate debug info settings
13972like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
13973at the linker command line and mixing different settings in different
13974translation units is discouraged.
13975
13976If LTO encounters objects with C linkage declared with incompatible
13977types in separate translation units to be linked together (undefined
13978behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
13979issued. The behavior is still undefined at run time. Similar
13980diagnostics may be raised for other languages.
13981
13982Another feature of LTO is that it is possible to apply interprocedural
13983optimizations on files written in different languages:
13984
13985@smallexample
13986gcc -c -flto foo.c
13987g++ -c -flto bar.cc
13988gfortran -c -flto baz.f90
13989g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
13990@end smallexample
13991
13992Notice that the final link is done with @command{g++} to get the C++
13993runtime libraries and @option{-lgfortran} is added to get the Fortran
13994runtime libraries. In general, when mixing languages in LTO mode, you
13995should use the same link command options as when mixing languages in a
13996regular (non-LTO) compilation.
13997
13998If object files containing GIMPLE bytecode are stored in a library archive, say
13999@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
14000are using a linker with plugin support. To create static libraries suitable
14001for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
14002and @command{ranlib};
14003to show the symbols of object files with GIMPLE bytecode, use
14004@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
14005and @command{nm} have been compiled with plugin support. At link time, use the
14006flag @option{-fuse-linker-plugin} to ensure that the library participates in
14007the LTO optimization process:
14008
14009@smallexample
14010gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
14011@end smallexample
14012
14013With the linker plugin enabled, the linker extracts the needed
14014GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
14015to make them part of the aggregated GIMPLE image to be optimized.
14016
14017If you are not using a linker with plugin support and/or do not
14018enable the linker plugin, then the objects inside @file{libfoo.a}
14019are extracted and linked as usual, but they do not participate
14020in the LTO optimization process. In order to make a static library suitable
14021for both LTO optimization and usual linkage, compile its object files with
14022@option{-flto} @option{-ffat-lto-objects}.
14023
14024Link-time optimizations do not require the presence of the whole program to
14025operate. If the program does not require any symbols to be exported, it is
14026possible to combine @option{-flto} and @option{-fwhole-program} to allow
14027the interprocedural optimizers to use more aggressive assumptions which may
14028lead to improved optimization opportunities.
14029Use of @option{-fwhole-program} is not needed when linker plugin is
14030active (see @option{-fuse-linker-plugin}).
14031
14032The current implementation of LTO makes no
14033attempt to generate bytecode that is portable between different
14034types of hosts. The bytecode files are versioned and there is a
14035strict version check, so bytecode files generated in one version of
14036GCC do not work with an older or newer version of GCC.
14037
14038Link-time optimization does not work well with generation of debugging
14039information on systems other than those using a combination of ELF and
14040DWARF.
14041
14042If you specify the optional @var{n}, the optimization and code
14043generation done at link time is executed in parallel using @var{n}
14044parallel jobs by utilizing an installed @command{make} program. The
14045environment variable @env{MAKE} may be used to override the program
14046used.
14047
14048You can also specify @option{-flto=jobserver} to use GNU make's
14049job server mode to determine the number of parallel jobs. This
14050is useful when the Makefile calling GCC is already executing in parallel.
14051You must prepend a @samp{+} to the command recipe in the parent Makefile
14052for this to work. This option likely only works if @env{MAKE} is
14053GNU make. Even without the option value, GCC tries to automatically
14054detect a running GNU make's job server.
14055
14056Use @option{-flto=auto} to use GNU make's job server, if available,
14057or otherwise fall back to autodetection of the number of CPU threads
14058present in your system.
14059
d77de738 14060@opindex flto-partition
ddf6fe37 14061@item -flto-partition=@var{alg}
d77de738
ML
14062Specify the partitioning algorithm used by the link-time optimizer.
14063The value is either @samp{1to1} to specify a partitioning mirroring
14064the original source files or @samp{balanced} to specify partitioning
14065into equally sized chunks (whenever possible) or @samp{max} to create
14066new partition for every symbol where possible. Specifying @samp{none}
14067as an algorithm disables partitioning and streaming completely.
14068The default value is @samp{balanced}. While @samp{1to1} can be used
14069as an workaround for various code ordering issues, the @samp{max}
14070partitioning is intended for internal testing only.
14071The value @samp{one} specifies that exactly one partition should be
14072used while the value @samp{none} bypasses partitioning and executes
14073the link-time optimization step directly from the WPA phase.
14074
d77de738 14075@opindex flto-compression-level
ddf6fe37 14076@item -flto-compression-level=@var{n}
d77de738
ML
14077This option specifies the level of compression used for intermediate
14078language written to LTO object files, and is only meaningful in
14079conjunction with LTO mode (@option{-flto}). GCC currently supports two
14080LTO compression algorithms. For zstd, valid values are 0 (no compression)
14081to 19 (maximum compression), while zlib supports values from 0 to 9.
14082Values outside this range are clamped to either minimum or maximum
14083of the supported values. If the option is not given,
14084a default balanced compression setting is used.
14085
d77de738 14086@opindex fuse-linker-plugin
ddf6fe37 14087@item -fuse-linker-plugin
d77de738
ML
14088Enables the use of a linker plugin during link-time optimization. This
14089option relies on plugin support in the linker, which is available in gold
14090or in GNU ld 2.21 or newer.
14091
14092This option enables the extraction of object files with GIMPLE bytecode out
14093of library archives. This improves the quality of optimization by exposing
14094more code to the link-time optimizer. This information specifies what
14095symbols can be accessed externally (by non-LTO object or during dynamic
14096linking). Resulting code quality improvements on binaries (and shared
14097libraries that use hidden visibility) are similar to @option{-fwhole-program}.
14098See @option{-flto} for a description of the effect of this flag and how to
14099use it.
14100
14101This option is enabled by default when LTO support in GCC is enabled
14102and GCC was configured for use with
14103a linker supporting plugins (GNU ld 2.21 or newer or gold).
14104
d77de738 14105@opindex ffat-lto-objects
ddf6fe37 14106@item -ffat-lto-objects
d77de738
ML
14107Fat LTO objects are object files that contain both the intermediate language
14108and the object code. This makes them usable for both LTO linking and normal
14109linking. This option is effective only when compiling with @option{-flto}
14110and is ignored at link time.
14111
14112@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14113requires the complete toolchain to be aware of LTO. It requires a linker with
14114linker plugin support for basic functionality. Additionally,
14115@command{nm}, @command{ar} and @command{ranlib}
14116need to support linker plugins to allow a full-featured build environment
14117(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14118@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14119to these tools. With non fat LTO makefiles need to be modified to use them.
14120
14121Note that modern binutils provide plugin auto-load mechanism.
14122Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14123effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14124@command{gcc-ranlib}).
14125
14126The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14127support.
14128
d77de738 14129@opindex fcompare-elim
ddf6fe37 14130@item -fcompare-elim
d77de738
ML
14131After register allocation and post-register allocation instruction splitting,
14132identify arithmetic instructions that compute processor flags similar to a
14133comparison operation based on that arithmetic. If possible, eliminate the
14134explicit comparison operation.
14135
14136This pass only applies to certain targets that cannot explicitly represent
14137the comparison operation before register allocation is complete.
14138
14139Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14140
d77de738 14141@opindex fcprop-registers
ddf6fe37 14142@item -fcprop-registers
d77de738
ML
14143After register allocation and post-register allocation instruction splitting,
14144perform a copy-propagation pass to try to reduce scheduling dependencies
14145and occasionally eliminate the copy.
14146
14147Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14148
d77de738 14149@opindex fprofile-correction
ddf6fe37 14150@item -fprofile-correction
d77de738
ML
14151Profiles collected using an instrumented binary for multi-threaded programs may
14152be inconsistent due to missed counter updates. When this option is specified,
14153GCC uses heuristics to correct or smooth out such inconsistencies. By
14154default, GCC emits an error message when an inconsistent profile is detected.
14155
14156This option is enabled by @option{-fauto-profile}.
14157
d77de738 14158@opindex fprofile-partial-training
ddf6fe37 14159@item -fprofile-partial-training
d77de738
ML
14160With @code{-fprofile-use} all portions of programs not executed during train
14161run are optimized agressively for size rather than speed. In some cases it is
14162not practical to train all possible hot paths in the program. (For
14163example, program may contain functions specific for a given hardware and
14164trianing may not cover all hardware configurations program is run on.) With
14165@code{-fprofile-partial-training} profile feedback will be ignored for all
14166functions not executed during the train run leading them to be optimized as if
14167they were compiled without profile feedback. This leads to better performance
14168when train run is not representative but also leads to significantly bigger
14169code.
14170
ddf6fe37 14171@opindex fprofile-use
d77de738
ML
14172@item -fprofile-use
14173@itemx -fprofile-use=@var{path}
d77de738
ML
14174Enable profile feedback-directed optimizations,
14175and the following optimizations, many of which
14176are generally profitable only with profile feedback available:
14177
14178@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14179-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14180-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14181-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14182-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14183-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14184-fprofile-reorder-functions}
14185
14186Before you can use this option, you must first generate profiling information.
14187@xref{Instrumentation Options}, for information about the
14188@option{-fprofile-generate} option.
14189
14190By default, GCC emits an error message if the feedback profiles do not
14191match the source code. This error can be turned into a warning by using
14192@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14193optimized code. Additionally, by default, GCC also emits a warning message if
14194the feedback profiles do not exist (see @option{-Wmissing-profile}).
14195
14196If @var{path} is specified, GCC looks at the @var{path} to find
14197the profile feedback data files. See @option{-fprofile-dir}.
14198
ddf6fe37 14199@opindex fauto-profile
d77de738
ML
14200@item -fauto-profile
14201@itemx -fauto-profile=@var{path}
d77de738
ML
14202Enable sampling-based feedback-directed optimizations,
14203and the following optimizations,
14204many of which are generally profitable only with profile feedback available:
14205
14206@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14207-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14208-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14209-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14210-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14211-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14212-fprofile-correction}
14213
14214@var{path} is the name of a file containing AutoFDO profile information.
14215If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14216
14217Producing an AutoFDO profile data file requires running your program
14218with the @command{perf} utility on a supported GNU/Linux target system.
14219For more information, see @uref{https://perf.wiki.kernel.org/}.
14220
14221E.g.
14222@smallexample
14223perf record -e br_inst_retired:near_taken -b -o perf.data \
14224 -- your_program
14225@end smallexample
14226
14227Then use the @command{create_gcov} tool to convert the raw profile data
14228to a format that can be used by GCC.@ You must also supply the
14229unstripped binary for your program to this tool.
14230See @uref{https://github.com/google/autofdo}.
14231
14232E.g.
14233@smallexample
14234create_gcov --binary=your_program.unstripped --profile=perf.data \
14235 --gcov=profile.afdo
14236@end smallexample
14237@end table
14238
14239The following options control compiler behavior regarding floating-point
14240arithmetic. These options trade off between speed and
14241correctness. All must be specifically enabled.
14242
14243@table @gcctabopt
d77de738 14244@opindex ffloat-store
ddf6fe37 14245@item -ffloat-store
d77de738
ML
14246Do not store floating-point variables in registers, and inhibit other
14247options that might change whether a floating-point value is taken from a
14248register or memory.
14249
14250@cindex floating-point precision
14251This option prevents undesirable excess precision on machines such as
14252the 68000 where the floating registers (of the 68881) keep more
14253precision than a @code{double} is supposed to have. Similarly for the
14254x86 architecture. For most programs, the excess precision does only
14255good, but a few programs rely on the precise definition of IEEE floating
14256point. Use @option{-ffloat-store} for such programs, after modifying
14257them to store all pertinent intermediate computations into variables.
14258
d77de738 14259@opindex fexcess-precision
ddf6fe37 14260@item -fexcess-precision=@var{style}
d77de738
ML
14261This option allows further control over excess precision on machines
14262where floating-point operations occur in a format with more precision or
14263range than the IEEE standard and interchange floating-point types. By
14264default, @option{-fexcess-precision=fast} is in effect; this means that
14265operations may be carried out in a wider precision than the types specified
14266in the source if that would result in faster code, and it is unpredictable
14267when rounding to the types specified in the source code takes place.
14268When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14269then excess precision follows the rules specified in ISO C99 or C++; in particular,
14270both casts and assignments cause values to be rounded to their
14271semantic types (whereas @option{-ffloat-store} only affects
14272assignments). This option is enabled by default for C or C++ if a strict
14273conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14274@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14275regardless of whether a strict conformance option is used.
14276
14277@opindex mfpmath
14278@option{-fexcess-precision=standard} is not implemented for languages
14279other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14280or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14281semantics apply without excess precision, and in the latter, rounding
14282is unpredictable.
14283
d77de738 14284@opindex ffast-math
ddf6fe37 14285@item -ffast-math
d77de738
ML
14286Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14287@option{-ffinite-math-only}, @option{-fno-rounding-math},
14288@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14289@option{-fexcess-precision=fast}.
14290
14291This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14292
14293This option is not turned on by any @option{-O} option besides
14294@option{-Ofast} since it can result in incorrect output for programs
14295that depend on an exact implementation of IEEE or ISO rules/specifications
14296for math functions. It may, however, yield faster code for programs
14297that do not require the guarantees of these specifications.
14298
d77de738
ML
14299@opindex fno-math-errno
14300@opindex fmath-errno
ddf6fe37 14301@item -fno-math-errno
d77de738
ML
14302Do not set @code{errno} after calling math functions that are executed
14303with a single instruction, e.g., @code{sqrt}. A program that relies on
14304IEEE exceptions for math error handling may want to use this flag
14305for speed while maintaining IEEE arithmetic compatibility.
14306
14307This option is not turned on by any @option{-O} option since
14308it can result in incorrect output for programs that depend on
14309an exact implementation of IEEE or ISO rules/specifications for
14310math functions. It may, however, yield faster code for programs
14311that do not require the guarantees of these specifications.
14312
14313The default is @option{-fmath-errno}.
14314
14315On Darwin systems, the math library never sets @code{errno}. There is
14316therefore no reason for the compiler to consider the possibility that
14317it might, and @option{-fno-math-errno} is the default.
14318
d77de738 14319@opindex funsafe-math-optimizations
ddf6fe37 14320@item -funsafe-math-optimizations
d77de738
ML
14321
14322Allow optimizations for floating-point arithmetic that (a) assume
14323that arguments and results are valid and (b) may violate IEEE or
14324ANSI standards. When used at link time, it may include libraries
14325or startup files that change the default FPU control word or other
14326similar optimizations.
14327
14328This option is not turned on by any @option{-O} option since
14329it can result in incorrect output for programs that depend on
14330an exact implementation of IEEE or ISO rules/specifications for
14331math functions. It may, however, yield faster code for programs
14332that do not require the guarantees of these specifications.
14333Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14334@option{-fassociative-math} and @option{-freciprocal-math}.
14335
14336The default is @option{-fno-unsafe-math-optimizations}.
14337
d77de738 14338@opindex fassociative-math
ddf6fe37 14339@item -fassociative-math
d77de738
ML
14340
14341Allow re-association of operands in series of floating-point operations.
14342This violates the ISO C and C++ language standard by possibly changing
14343computation result. NOTE: re-ordering may change the sign of zero as
14344well as ignore NaNs and inhibit or create underflow or overflow (and
14345thus cannot be used on code that relies on rounding behavior like
14346@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14347and thus may not be used when ordered comparisons are required.
14348This option requires that both @option{-fno-signed-zeros} and
14349@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14350much sense with @option{-frounding-math}. For Fortran the option
14351is automatically enabled when both @option{-fno-signed-zeros} and
14352@option{-fno-trapping-math} are in effect.
14353
14354The default is @option{-fno-associative-math}.
14355
d77de738 14356@opindex freciprocal-math
ddf6fe37 14357@item -freciprocal-math
d77de738
ML
14358
14359Allow the reciprocal of a value to be used instead of dividing by
14360the value if this enables optimizations. For example @code{x / y}
14361can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14362is subject to common subexpression elimination. Note that this loses
14363precision and increases the number of flops operating on the value.
14364
14365The default is @option{-fno-reciprocal-math}.
14366
d77de738 14367@opindex ffinite-math-only
ddf6fe37 14368@item -ffinite-math-only
d77de738
ML
14369Allow optimizations for floating-point arithmetic that assume
14370that arguments and results are not NaNs or +-Infs.
14371
14372This option is not turned on by any @option{-O} option since
14373it can result in incorrect output for programs that depend on
14374an exact implementation of IEEE or ISO rules/specifications for
14375math functions. It may, however, yield faster code for programs
14376that do not require the guarantees of these specifications.
14377
14378The default is @option{-fno-finite-math-only}.
14379
d77de738
ML
14380@opindex fno-signed-zeros
14381@opindex fsigned-zeros
ddf6fe37 14382@item -fno-signed-zeros
d77de738
ML
14383Allow optimizations for floating-point arithmetic that ignore the
14384signedness of zero. IEEE arithmetic specifies the behavior of
14385distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14386of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14387This option implies that the sign of a zero result isn't significant.
14388
14389The default is @option{-fsigned-zeros}.
14390
d77de738
ML
14391@opindex fno-trapping-math
14392@opindex ftrapping-math
ddf6fe37 14393@item -fno-trapping-math
d77de738
ML
14394Compile code assuming that floating-point operations cannot generate
14395user-visible traps. These traps include division by zero, overflow,
14396underflow, inexact result and invalid operation. This option requires
14397that @option{-fno-signaling-nans} be in effect. Setting this option may
14398allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14399
14400This option should never be turned on by any @option{-O} option since
14401it can result in incorrect output for programs that depend on
14402an exact implementation of IEEE or ISO rules/specifications for
14403math functions.
14404
14405The default is @option{-ftrapping-math}.
14406
14407Future versions of GCC may provide finer control of this setting
14408using C99's @code{FENV_ACCESS} pragma. This command-line option
14409will be used along with @option{-frounding-math} to specify the
14410default state for @code{FENV_ACCESS}.
14411
d77de738 14412@opindex frounding-math
ddf6fe37 14413@item -frounding-math
d77de738
ML
14414Disable transformations and optimizations that assume default floating-point
14415rounding behavior. This is round-to-zero for all floating point
14416to integer conversions, and round-to-nearest for all other arithmetic
14417truncations. This option should be specified for programs that change
14418the FP rounding mode dynamically, or that may be executed with a
14419non-default rounding mode. This option disables constant folding of
14420floating-point expressions at compile time (which may be affected by
14421rounding mode) and arithmetic transformations that are unsafe in the
14422presence of sign-dependent rounding modes.
14423
14424The default is @option{-fno-rounding-math}.
14425
14426This option is experimental and does not currently guarantee to
14427disable all GCC optimizations that are affected by rounding mode.
14428Future versions of GCC may provide finer control of this setting
14429using C99's @code{FENV_ACCESS} pragma. This command-line option
14430will be used along with @option{-ftrapping-math} to specify the
14431default state for @code{FENV_ACCESS}.
14432
d77de738 14433@opindex fsignaling-nans
ddf6fe37 14434@item -fsignaling-nans
d77de738
ML
14435Compile code assuming that IEEE signaling NaNs may generate user-visible
14436traps during floating-point operations. Setting this option disables
14437optimizations that may change the number of exceptions visible with
14438signaling NaNs. This option implies @option{-ftrapping-math}.
14439
14440This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14441be defined.
14442
14443The default is @option{-fno-signaling-nans}.
14444
14445This option is experimental and does not currently guarantee to
14446disable all GCC optimizations that affect signaling NaN behavior.
14447
d77de738
ML
14448@opindex fno-fp-int-builtin-inexact
14449@opindex ffp-int-builtin-inexact
ddf6fe37 14450@item -fno-fp-int-builtin-inexact
d77de738
ML
14451Do not allow the built-in functions @code{ceil}, @code{floor},
14452@code{round} and @code{trunc}, and their @code{float} and @code{long
14453double} variants, to generate code that raises the ``inexact''
14454floating-point exception for noninteger arguments. ISO C99 and C11
14455allow these functions to raise the ``inexact'' exception, but ISO/IEC
14456TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14457ISO C2X, does not allow these functions to do so.
14458
14459The default is @option{-ffp-int-builtin-inexact}, allowing the
14460exception to be raised, unless C2X or a later C standard is selected.
14461This option does nothing unless @option{-ftrapping-math} is in effect.
14462
14463Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14464generate a call to a library function then the ``inexact'' exception
14465may be raised if the library implementation does not follow TS 18661.
14466
d77de738 14467@opindex fsingle-precision-constant
ddf6fe37 14468@item -fsingle-precision-constant
d77de738
ML
14469Treat floating-point constants as single precision instead of
14470implicitly converting them to double-precision constants.
14471
d77de738 14472@opindex fcx-limited-range
ddf6fe37 14473@item -fcx-limited-range
d77de738
ML
14474When enabled, this option states that a range reduction step is not
14475needed when performing complex division. Also, there is no checking
14476whether the result of a complex multiplication or division is @code{NaN
14477+ I*NaN}, with an attempt to rescue the situation in that case. The
14478default is @option{-fno-cx-limited-range}, but is enabled by
14479@option{-ffast-math}.
14480
14481This option controls the default setting of the ISO C99
14482@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14483all languages.
14484
d77de738 14485@opindex fcx-fortran-rules
ddf6fe37 14486@item -fcx-fortran-rules
d77de738
ML
14487Complex multiplication and division follow Fortran rules. Range
14488reduction is done as part of complex division, but there is no checking
14489whether the result of a complex multiplication or division is @code{NaN
14490+ I*NaN}, with an attempt to rescue the situation in that case.
14491
14492The default is @option{-fno-cx-fortran-rules}.
14493
14494@end table
14495
14496The following options control optimizations that may improve
14497performance, but are not enabled by any @option{-O} options. This
14498section includes experimental options that may produce broken code.
14499
14500@table @gcctabopt
d77de738 14501@opindex fbranch-probabilities
ddf6fe37 14502@item -fbranch-probabilities
d77de738
ML
14503After running a program compiled with @option{-fprofile-arcs}
14504(@pxref{Instrumentation Options}),
14505you can compile it a second time using
14506@option{-fbranch-probabilities}, to improve optimizations based on
14507the number of times each branch was taken. When a program
14508compiled with @option{-fprofile-arcs} exits, it saves arc execution
14509counts to a file called @file{@var{sourcename}.gcda} for each source
14510file. The information in this data file is very dependent on the
14511structure of the generated code, so you must use the same source code
14512and the same optimization options for both compilations.
14513See details about the file naming in @option{-fprofile-arcs}.
14514
14515With @option{-fbranch-probabilities}, GCC puts a
14516@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14517These can be used to improve optimization. Currently, they are only
14518used in one place: in @file{reorg.cc}, instead of guessing which path a
14519branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14520exactly determine which path is taken more often.
14521
14522Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14523
d77de738 14524@opindex fprofile-values
ddf6fe37 14525@item -fprofile-values
d77de738
ML
14526If combined with @option{-fprofile-arcs}, it adds code so that some
14527data about values of expressions in the program is gathered.
14528
14529With @option{-fbranch-probabilities}, it reads back the data gathered
14530from profiling values of expressions for usage in optimizations.
14531
14532Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14533@option{-fauto-profile}.
14534
d77de738 14535@opindex fprofile-reorder-functions
ddf6fe37 14536@item -fprofile-reorder-functions
d77de738
ML
14537Function reordering based on profile instrumentation collects
14538first time of execution of a function and orders these functions
14539in ascending order.
14540
14541Enabled with @option{-fprofile-use}.
14542
d77de738 14543@opindex fvpt
ddf6fe37 14544@item -fvpt
d77de738
ML
14545If combined with @option{-fprofile-arcs}, this option instructs the compiler
14546to add code to gather information about values of expressions.
14547
14548With @option{-fbranch-probabilities}, it reads back the data gathered
14549and actually performs the optimizations based on them.
14550Currently the optimizations include specialization of division operations
14551using the knowledge about the value of the denominator.
14552
14553Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14554
d77de738 14555@opindex frename-registers
ddf6fe37 14556@item -frename-registers
d77de738
ML
14557Attempt to avoid false dependencies in scheduled code by making use
14558of registers left over after register allocation. This optimization
14559most benefits processors with lots of registers. Depending on the
14560debug information format adopted by the target, however, it can
14561make debugging impossible, since variables no longer stay in
14562a ``home register''.
14563
14564Enabled by default with @option{-funroll-loops}.
14565
d77de738 14566@opindex fschedule-fusion
ddf6fe37 14567@item -fschedule-fusion
d77de738
ML
14568Performs a target dependent pass over the instruction stream to schedule
14569instructions of same type together because target machine can execute them
14570more efficiently if they are adjacent to each other in the instruction flow.
14571
14572Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14573
d77de738 14574@opindex ftracer
ddf6fe37 14575@item -ftracer
d77de738
ML
14576Perform tail duplication to enlarge superblock size. This transformation
14577simplifies the control flow of the function allowing other optimizations to do
14578a better job.
14579
14580Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14581
d77de738 14582@opindex funroll-loops
ddf6fe37 14583@item -funroll-loops
d77de738
ML
14584Unroll loops whose number of iterations can be determined at compile time or
14585upon entry to the loop. @option{-funroll-loops} implies
14586@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14587It also turns on complete loop peeling (i.e.@: complete removal of loops with
14588a small constant number of iterations). This option makes code larger, and may
14589or may not make it run faster.
14590
14591Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14592
d77de738 14593@opindex funroll-all-loops
ddf6fe37 14594@item -funroll-all-loops
d77de738
ML
14595Unroll all loops, even if their number of iterations is uncertain when
14596the loop is entered. This usually makes programs run more slowly.
14597@option{-funroll-all-loops} implies the same options as
14598@option{-funroll-loops}.
14599
d77de738 14600@opindex fpeel-loops
ddf6fe37 14601@item -fpeel-loops
d77de738
ML
14602Peels loops for which there is enough information that they do not
14603roll much (from profile feedback or static analysis). It also turns on
14604complete loop peeling (i.e.@: complete removal of loops with small constant
14605number of iterations).
14606
14607Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14608
d77de738 14609@opindex fmove-loop-invariants
ddf6fe37 14610@item -fmove-loop-invariants
d77de738
ML
14611Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14612at level @option{-O1} and higher, except for @option{-Og}.
14613
d77de738 14614@opindex fmove-loop-stores
ddf6fe37 14615@item -fmove-loop-stores
d77de738
ML
14616Enables the loop store motion pass in the GIMPLE loop optimizer. This
14617moves invariant stores to after the end of the loop in exchange for
14618carrying the stored value in a register across the iteration.
14619Note for this option to have an effect @option{-ftree-loop-im} has to
14620be enabled as well. Enabled at level @option{-O1} and higher, except
14621for @option{-Og}.
14622
d77de738 14623@opindex fsplit-loops
ddf6fe37 14624@item -fsplit-loops
d77de738
ML
14625Split a loop into two if it contains a condition that's always true
14626for one side of the iteration space and false for the other.
14627
14628Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14629
d77de738 14630@opindex funswitch-loops
ddf6fe37 14631@item -funswitch-loops
d77de738
ML
14632Move branches with loop invariant conditions out of the loop, with duplicates
14633of the loop on both branches (modified according to result of the condition).
14634
14635Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14636
d77de738 14637@opindex fversion-loops-for-strides
ddf6fe37 14638@item -fversion-loops-for-strides
d77de738
ML
14639If a loop iterates over an array with a variable stride, create another
14640version of the loop that assumes the stride is always one. For example:
14641
14642@smallexample
14643for (int i = 0; i < n; ++i)
14644 x[i * stride] = @dots{};
14645@end smallexample
14646
14647becomes:
14648
14649@smallexample
14650if (stride == 1)
14651 for (int i = 0; i < n; ++i)
14652 x[i] = @dots{};
14653else
14654 for (int i = 0; i < n; ++i)
14655 x[i * stride] = @dots{};
14656@end smallexample
14657
14658This is particularly useful for assumed-shape arrays in Fortran where
14659(for example) it allows better vectorization assuming contiguous accesses.
14660This flag is enabled by default at @option{-O3}.
14661It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14662
d77de738
ML
14663@opindex ffunction-sections
14664@opindex fdata-sections
ddf6fe37
AA
14665@item -ffunction-sections
14666@itemx -fdata-sections
d77de738
ML
14667Place each function or data item into its own section in the output
14668file if the target supports arbitrary sections. The name of the
14669function or the name of the data item determines the section's name
14670in the output file.
14671
14672Use these options on systems where the linker can perform optimizations to
14673improve locality of reference in the instruction space. Most systems using the
14674ELF object format have linkers with such optimizations. On AIX, the linker
14675rearranges sections (CSECTs) based on the call graph. The performance impact
14676varies.
14677
14678Together with a linker garbage collection (linker @option{--gc-sections}
14679option) these options may lead to smaller statically-linked executables (after
14680stripping).
14681
14682On ELF/DWARF systems these options do not degenerate the quality of the debug
14683information. There could be issues with other object files/debug info formats.
14684
14685Only use these options when there are significant benefits from doing so. When
14686you specify these options, the assembler and linker create larger object and
14687executable files and are also slower. These options affect code generation.
14688They prevent optimizations by the compiler and assembler using relative
14689locations inside a translation unit since the locations are unknown until
14690link time. An example of such an optimization is relaxing calls to short call
14691instructions.
14692
d77de738 14693@opindex fstdarg-opt
ddf6fe37 14694@item -fstdarg-opt
d77de738
ML
14695Optimize the prologue of variadic argument functions with respect to usage of
14696those arguments.
14697
d77de738 14698@opindex fsection-anchors
ddf6fe37 14699@item -fsection-anchors
d77de738
ML
14700Try to reduce the number of symbolic address calculations by using
14701shared ``anchor'' symbols to address nearby objects. This transformation
14702can help to reduce the number of GOT entries and GOT accesses on some
14703targets.
14704
14705For example, the implementation of the following function @code{foo}:
14706
14707@smallexample
14708static int a, b, c;
14709int foo (void) @{ return a + b + c; @}
14710@end smallexample
14711
14712@noindent
14713usually calculates the addresses of all three variables, but if you
14714compile it with @option{-fsection-anchors}, it accesses the variables
14715from a common anchor point instead. The effect is similar to the
14716following pseudocode (which isn't valid C):
14717
14718@smallexample
14719int foo (void)
14720@{
14721 register int *xr = &x;
14722 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14723@}
14724@end smallexample
14725
14726Not all targets support this option.
14727
d77de738 14728@opindex fzero-call-used-regs
ddf6fe37 14729@item -fzero-call-used-regs=@var{choice}
d77de738
ML
14730Zero call-used registers at function return to increase program
14731security by either mitigating Return-Oriented Programming (ROP)
14732attacks or preventing information leakage through registers.
14733
14734The possible values of @var{choice} are the same as for the
14735@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
14736The default is @samp{skip}.
14737
14738You can control this behavior for a specific function by using the function
14739attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
14740
d77de738 14741@opindex param
ddf6fe37 14742@item --param @var{name}=@var{value}
d77de738
ML
14743In some places, GCC uses various constants to control the amount of
14744optimization that is done. For example, GCC does not inline functions
14745that contain more than a certain number of instructions. You can
14746control some of these constants on the command line using the
14747@option{--param} option.
14748
14749The names of specific parameters, and the meaning of the values, are
14750tied to the internals of the compiler, and are subject to change
14751without notice in future releases.
14752
c381327d
GP
14753In order to get the minimal, maximal and default values of a parameter,
14754use the @option{--help=param -Q} options.
d77de738
ML
14755
14756In each case, the @var{value} is an integer. The following choices
14757of @var{name} are recognized for all targets:
14758
14759@table @gcctabopt
14760@item predictable-branch-outcome
14761When branch is predicted to be taken with probability lower than this threshold
14762(in percent), then it is considered well predictable.
14763
14764@item max-rtl-if-conversion-insns
14765RTL if-conversion tries to remove conditional branches around a block and
14766replace them with conditionally executed instructions. This parameter
14767gives the maximum number of instructions in a block which should be
14768considered for if-conversion. The compiler will
14769also use other heuristics to decide whether if-conversion is likely to be
14770profitable.
14771
14772@item max-rtl-if-conversion-predictable-cost
14773RTL if-conversion will try to remove conditional branches around a block
14774and replace them with conditionally executed instructions. These parameters
14775give the maximum permissible cost for the sequence that would be generated
14776by if-conversion depending on whether the branch is statically determined
14777to be predictable or not. The units for this parameter are the same as
14778those for the GCC internal seq_cost metric. The compiler will try to
14779provide a reasonable default for this parameter using the BRANCH_COST
14780target macro.
14781
14782@item max-crossjump-edges
14783The maximum number of incoming edges to consider for cross-jumping.
14784The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
14785the number of edges incoming to each block. Increasing values mean
14786more aggressive optimization, making the compilation time increase with
14787probably small improvement in executable size.
14788
14789@item min-crossjump-insns
14790The minimum number of instructions that must be matched at the end
14791of two blocks before cross-jumping is performed on them. This
14792value is ignored in the case where all instructions in the block being
14793cross-jumped from are matched.
14794
14795@item max-grow-copy-bb-insns
14796The maximum code size expansion factor when copying basic blocks
14797instead of jumping. The expansion is relative to a jump instruction.
14798
14799@item max-goto-duplication-insns
14800The maximum number of instructions to duplicate to a block that jumps
14801to a computed goto. To avoid @math{O(N^2)} behavior in a number of
14802passes, GCC factors computed gotos early in the compilation process,
14803and unfactors them as late as possible. Only computed jumps at the
14804end of a basic blocks with no more than max-goto-duplication-insns are
14805unfactored.
14806
14807@item max-delay-slot-insn-search
14808The maximum number of instructions to consider when looking for an
14809instruction to fill a delay slot. If more than this arbitrary number of
14810instructions are searched, the time savings from filling the delay slot
14811are minimal, so stop searching. Increasing values mean more
14812aggressive optimization, making the compilation time increase with probably
14813small improvement in execution time.
14814
14815@item max-delay-slot-live-search
14816When trying to fill delay slots, the maximum number of instructions to
14817consider when searching for a block with valid live register
14818information. Increasing this arbitrarily chosen value means more
14819aggressive optimization, increasing the compilation time. This parameter
14820should be removed when the delay slot code is rewritten to maintain the
14821control-flow graph.
14822
14823@item max-gcse-memory
14824The approximate maximum amount of memory in @code{kB} that can be allocated in
14825order to perform the global common subexpression elimination
14826optimization. If more memory than specified is required, the
14827optimization is not done.
14828
14829@item max-gcse-insertion-ratio
14830If the ratio of expression insertions to deletions is larger than this value
14831for any expression, then RTL PRE inserts or removes the expression and thus
14832leaves partially redundant computations in the instruction stream.
14833
14834@item max-pending-list-length
14835The maximum number of pending dependencies scheduling allows
14836before flushing the current state and starting over. Large functions
14837with few branches or calls can create excessively large lists which
14838needlessly consume memory and resources.
14839
14840@item max-modulo-backtrack-attempts
14841The maximum number of backtrack attempts the scheduler should make
14842when modulo scheduling a loop. Larger values can exponentially increase
14843compilation time.
14844
14845@item max-inline-functions-called-once-loop-depth
14846Maximal loop depth of a call considered by inline heuristics that tries to
14847inline all functions called once.
14848
14849@item max-inline-functions-called-once-insns
14850Maximal estimated size of functions produced while inlining functions called
14851once.
14852
14853@item max-inline-insns-single
14854Several parameters control the tree inliner used in GCC@. This number sets the
14855maximum number of instructions (counted in GCC's internal representation) in a
14856single function that the tree inliner considers for inlining. This only
14857affects functions declared inline and methods implemented in a class
14858declaration (C++).
14859
14860
14861@item max-inline-insns-auto
14862When you use @option{-finline-functions} (included in @option{-O3}),
14863a lot of functions that would otherwise not be considered for inlining
14864by the compiler are investigated. To those functions, a different
14865(more restrictive) limit compared to functions declared inline can
14866be applied (@option{--param max-inline-insns-auto}).
14867
14868@item max-inline-insns-small
14869This is bound applied to calls which are considered relevant with
14870@option{-finline-small-functions}.
14871
14872@item max-inline-insns-size
14873This is bound applied to calls which are optimized for size. Small growth
14874may be desirable to anticipate optimization oppurtunities exposed by inlining.
14875
14876@item uninlined-function-insns
14877Number of instructions accounted by inliner for function overhead such as
14878function prologue and epilogue.
14879
14880@item uninlined-function-time
14881Extra time accounted by inliner for function overhead such as time needed to
14882execute function prologue and epilogue.
14883
14884@item inline-heuristics-hint-percent
14885The scale (in percents) applied to @option{inline-insns-single},
14886@option{inline-insns-single-O2}, @option{inline-insns-auto}
14887when inline heuristics hints that inlining is
14888very profitable (will enable later optimizations).
14889
14890@item uninlined-thunk-insns
14891@item uninlined-thunk-time
14892Same as @option{--param uninlined-function-insns} and
14893@option{--param uninlined-function-time} but applied to function thunks.
14894
14895@item inline-min-speedup
14896When estimated performance improvement of caller + callee runtime exceeds this
14897threshold (in percent), the function can be inlined regardless of the limit on
14898@option{--param max-inline-insns-single} and @option{--param
14899max-inline-insns-auto}.
14900
14901@item large-function-insns
14902The limit specifying really large functions. For functions larger than this
14903limit after inlining, inlining is constrained by
14904@option{--param large-function-growth}. This parameter is useful primarily
14905to avoid extreme compilation time caused by non-linear algorithms used by the
14906back end.
14907
14908@item large-function-growth
14909Specifies maximal growth of large function caused by inlining in percents.
14910For example, parameter value 100 limits large function growth to 2.0 times
14911the original size.
14912
14913@item large-unit-insns
14914The limit specifying large translation unit. Growth caused by inlining of
14915units larger than this limit is limited by @option{--param inline-unit-growth}.
14916For small units this might be too tight.
14917For example, consider a unit consisting of function A
14918that is inline and B that just calls A three times. If B is small relative to
14919A, the growth of unit is 300\% and yet such inlining is very sane. For very
14920large units consisting of small inlineable functions, however, the overall unit
14921growth limit is needed to avoid exponential explosion of code size. Thus for
14922smaller units, the size is increased to @option{--param large-unit-insns}
14923before applying @option{--param inline-unit-growth}.
14924
14925@item lazy-modules
14926Maximum number of concurrently open C++ module files when lazy loading.
14927
14928@item inline-unit-growth
14929Specifies maximal overall growth of the compilation unit caused by inlining.
14930For example, parameter value 20 limits unit growth to 1.2 times the original
14931size. Cold functions (either marked cold via an attribute or by profile
14932feedback) are not accounted into the unit size.
14933
14934@item ipa-cp-unit-growth
14935Specifies maximal overall growth of the compilation unit caused by
14936interprocedural constant propagation. For example, parameter value 10 limits
14937unit growth to 1.1 times the original size.
14938
14939@item ipa-cp-large-unit-insns
14940The size of translation unit that IPA-CP pass considers large.
14941
14942@item large-stack-frame
14943The limit specifying large stack frames. While inlining the algorithm is trying
14944to not grow past this limit too much.
14945
14946@item large-stack-frame-growth
14947Specifies maximal growth of large stack frames caused by inlining in percents.
14948For example, parameter value 1000 limits large stack frame growth to 11 times
14949the original size.
14950
14951@item max-inline-insns-recursive
14952@itemx max-inline-insns-recursive-auto
14953Specifies the maximum number of instructions an out-of-line copy of a
14954self-recursive inline
14955function can grow into by performing recursive inlining.
14956
14957@option{--param max-inline-insns-recursive} applies to functions
14958declared inline.
14959For functions not declared inline, recursive inlining
14960happens only when @option{-finline-functions} (included in @option{-O3}) is
14961enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
14962
14963@item max-inline-recursive-depth
14964@itemx max-inline-recursive-depth-auto
14965Specifies the maximum recursion depth used for recursive inlining.
14966
14967@option{--param max-inline-recursive-depth} applies to functions
14968declared inline. For functions not declared inline, recursive inlining
14969happens only when @option{-finline-functions} (included in @option{-O3}) is
14970enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
14971
14972@item min-inline-recursive-probability
14973Recursive inlining is profitable only for function having deep recursion
14974in average and can hurt for function having little recursion depth by
14975increasing the prologue size or complexity of function body to other
14976optimizers.
14977
14978When profile feedback is available (see @option{-fprofile-generate}) the actual
14979recursion depth can be guessed from the probability that function recurses
14980via a given call expression. This parameter limits inlining only to call
14981expressions whose probability exceeds the given threshold (in percents).
14982
14983@item early-inlining-insns
14984Specify growth that the early inliner can make. In effect it increases
14985the amount of inlining for code having a large abstraction penalty.
14986
14987@item max-early-inliner-iterations
14988Limit of iterations of the early inliner. This basically bounds
14989the number of nested indirect calls the early inliner can resolve.
14990Deeper chains are still handled by late inlining.
14991
14992@item comdat-sharing-probability
14993Probability (in percent) that C++ inline function with comdat visibility
14994are shared across multiple compilation units.
14995
14996@item modref-max-bases
14997@item modref-max-refs
14998@item modref-max-accesses
14999Specifies the maximal number of base pointers, references and accesses stored
15000for a single function by mod/ref analysis.
15001
15002@item modref-max-tests
15003Specifies the maxmal number of tests alias oracle can perform to disambiguate
15004memory locations using the mod/ref information. This parameter ought to be
15005bigger than @option{--param modref-max-bases} and @option{--param
15006modref-max-refs}.
15007
15008@item modref-max-depth
15009Specifies the maximum depth of DFS walk used by modref escape analysis.
15010Setting to 0 disables the analysis completely.
15011
15012@item modref-max-escape-points
15013Specifies the maximum number of escape points tracked by modref per SSA-name.
15014
15015@item modref-max-adjustments
15016Specifies the maximum number the access range is enlarged during modref dataflow
15017analysis.
15018
15019@item profile-func-internal-id
15020A parameter to control whether to use function internal id in profile
15021database lookup. If the value is 0, the compiler uses an id that
15022is based on function assembler name and filename, which makes old profile
15023data more tolerant to source changes such as function reordering etc.
15024
15025@item min-vect-loop-bound
15026The minimum number of iterations under which loops are not vectorized
15027when @option{-ftree-vectorize} is used. The number of iterations after
15028vectorization needs to be greater than the value specified by this option
15029to allow vectorization.
15030
15031@item gcse-cost-distance-ratio
15032Scaling factor in calculation of maximum distance an expression
15033can be moved by GCSE optimizations. This is currently supported only in the
15034code hoisting pass. The bigger the ratio, the more aggressive code hoisting
15035is with simple expressions, i.e., the expressions that have cost
15036less than @option{gcse-unrestricted-cost}. Specifying 0 disables
15037hoisting of simple expressions.
15038
15039@item gcse-unrestricted-cost
15040Cost, roughly measured as the cost of a single typical machine
15041instruction, at which GCSE optimizations do not constrain
15042the distance an expression can travel. This is currently
15043supported only in the code hoisting pass. The lesser the cost,
15044the more aggressive code hoisting is. Specifying 0
15045allows all expressions to travel unrestricted distances.
15046
15047@item max-hoist-depth
15048The depth of search in the dominator tree for expressions to hoist.
15049This is used to avoid quadratic behavior in hoisting algorithm.
15050The value of 0 does not limit on the search, but may slow down compilation
15051of huge functions.
15052
15053@item max-tail-merge-comparisons
15054The maximum amount of similar bbs to compare a bb with. This is used to
15055avoid quadratic behavior in tree tail merging.
15056
15057@item max-tail-merge-iterations
15058The maximum amount of iterations of the pass over the function. This is used to
15059limit compilation time in tree tail merging.
15060
15061@item store-merging-allow-unaligned
15062Allow the store merging pass to introduce unaligned stores if it is legal to
15063do so.
15064
15065@item max-stores-to-merge
15066The maximum number of stores to attempt to merge into wider stores in the store
15067merging pass.
15068
15069@item max-store-chains-to-track
15070The maximum number of store chains to track at the same time in the attempt
15071to merge them into wider stores in the store merging pass.
15072
15073@item max-stores-to-track
15074The maximum number of stores to track at the same time in the attemt to
15075to merge them into wider stores in the store merging pass.
15076
15077@item max-unrolled-insns
15078The maximum number of instructions that a loop may have to be unrolled.
15079If a loop is unrolled, this parameter also determines how many times
15080the loop code is unrolled.
15081
15082@item max-average-unrolled-insns
15083The maximum number of instructions biased by probabilities of their execution
15084that a loop may have to be unrolled. If a loop is unrolled,
15085this parameter also determines how many times the loop code is unrolled.
15086
15087@item max-unroll-times
15088The maximum number of unrollings of a single loop.
15089
15090@item max-peeled-insns
15091The maximum number of instructions that a loop may have to be peeled.
15092If a loop is peeled, this parameter also determines how many times
15093the loop code is peeled.
15094
15095@item max-peel-times
15096The maximum number of peelings of a single loop.
15097
15098@item max-peel-branches
15099The maximum number of branches on the hot path through the peeled sequence.
15100
15101@item max-completely-peeled-insns
15102The maximum number of insns of a completely peeled loop.
15103
15104@item max-completely-peel-times
15105The maximum number of iterations of a loop to be suitable for complete peeling.
15106
15107@item max-completely-peel-loop-nest-depth
15108The maximum depth of a loop nest suitable for complete peeling.
15109
15110@item max-unswitch-insns
15111The maximum number of insns of an unswitched loop.
15112
5b50850c
RB
15113@item max-unswitch-depth
15114The maximum depth of a loop nest to be unswitched.
15115
d77de738
ML
15116@item lim-expensive
15117The minimum cost of an expensive expression in the loop invariant motion.
15118
15119@item min-loop-cond-split-prob
15120When FDO profile information is available, @option{min-loop-cond-split-prob}
15121specifies minimum threshold for probability of semi-invariant condition
15122statement to trigger loop split.
15123
15124@item iv-consider-all-candidates-bound
15125Bound on number of candidates for induction variables, below which
15126all candidates are considered for each use in induction variable
15127optimizations. If there are more candidates than this,
15128only the most relevant ones are considered to avoid quadratic time complexity.
15129
15130@item iv-max-considered-uses
15131The induction variable optimizations give up on loops that contain more
15132induction variable uses.
15133
15134@item iv-always-prune-cand-set-bound
15135If the number of candidates in the set is smaller than this value,
15136always try to remove unnecessary ivs from the set
15137when adding a new one.
15138
15139@item avg-loop-niter
15140Average number of iterations of a loop.
15141
15142@item dse-max-object-size
15143Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15144Larger values may result in larger compilation times.
15145
15146@item dse-max-alias-queries-per-store
15147Maximum number of queries into the alias oracle per store.
15148Larger values result in larger compilation times and may result in more
15149removed dead stores.
15150
15151@item scev-max-expr-size
15152Bound on size of expressions used in the scalar evolutions analyzer.
15153Large expressions slow the analyzer.
15154
15155@item scev-max-expr-complexity
15156Bound on the complexity of the expressions in the scalar evolutions analyzer.
15157Complex expressions slow the analyzer.
15158
15159@item max-tree-if-conversion-phi-args
15160Maximum number of arguments in a PHI supported by TREE if conversion
15161unless the loop is marked with simd pragma.
15162
15163@item vect-max-layout-candidates
15164The maximum number of possible vector layouts (such as permutations)
15165to consider when optimizing to-be-vectorized code.
15166
15167@item vect-max-version-for-alignment-checks
15168The maximum number of run-time checks that can be performed when
15169doing loop versioning for alignment in the vectorizer.
15170
15171@item vect-max-version-for-alias-checks
15172The maximum number of run-time checks that can be performed when
15173doing loop versioning for alias in the vectorizer.
15174
15175@item vect-max-peeling-for-alignment
15176The maximum number of loop peels to enhance access alignment
15177for vectorizer. Value -1 means no limit.
15178
15179@item max-iterations-to-track
15180The maximum number of iterations of a loop the brute-force algorithm
15181for analysis of the number of iterations of the loop tries to evaluate.
15182
15183@item hot-bb-count-fraction
15184The denominator n of fraction 1/n of the maximal execution count of a
15185basic block in the entire program that a basic block needs to at least
15186have in order to be considered hot. The default is 10000, which means
15187that a basic block is considered hot if its execution count is greater
15188than 1/10000 of the maximal execution count. 0 means that it is never
15189considered hot. Used in non-LTO mode.
15190
15191@item hot-bb-count-ws-permille
15192The number of most executed permilles, ranging from 0 to 1000, of the
15193profiled execution of the entire program to which the execution count
15194of a basic block must be part of in order to be considered hot. The
15195default is 990, which means that a basic block is considered hot if
15196its execution count contributes to the upper 990 permilles, or 99.0%,
15197of the profiled execution of the entire program. 0 means that it is
15198never considered hot. Used in LTO mode.
15199
15200@item hot-bb-frequency-fraction
15201The denominator n of fraction 1/n of the execution frequency of the
15202entry block of a function that a basic block of this function needs
15203to at least have in order to be considered hot. The default is 1000,
15204which means that a basic block is considered hot in a function if it
15205is executed more frequently than 1/1000 of the frequency of the entry
15206block of the function. 0 means that it is never considered hot.
15207
15208@item unlikely-bb-count-fraction
15209The denominator n of fraction 1/n of the number of profiled runs of
15210the entire program below which the execution count of a basic block
15211must be in order for the basic block to be considered unlikely executed.
15212The default is 20, which means that a basic block is considered unlikely
15213executed if it is executed in fewer than 1/20, or 5%, of the runs of
15214the program. 0 means that it is always considered unlikely executed.
15215
15216@item max-predicted-iterations
15217The maximum number of loop iterations we predict statically. This is useful
15218in cases where a function contains a single loop with known bound and
15219another loop with unknown bound.
15220The known number of iterations is predicted correctly, while
15221the unknown number of iterations average to roughly 10. This means that the
15222loop without bounds appears artificially cold relative to the other one.
15223
15224@item builtin-expect-probability
15225Control the probability of the expression having the specified value. This
15226parameter takes a percentage (i.e.@: 0 ... 100) as input.
15227
15228@item builtin-string-cmp-inline-length
15229The maximum length of a constant string for a builtin string cmp call
15230eligible for inlining.
15231
15232@item align-threshold
15233
15234Select fraction of the maximal frequency of executions of a basic block in
15235a function to align the basic block.
15236
15237@item align-loop-iterations
15238
15239A loop expected to iterate at least the selected number of iterations is
15240aligned.
15241
15242@item tracer-dynamic-coverage
15243@itemx tracer-dynamic-coverage-feedback
15244
15245This value is used to limit superblock formation once the given percentage of
15246executed instructions is covered. This limits unnecessary code size
15247expansion.
15248
15249The @option{tracer-dynamic-coverage-feedback} parameter
15250is used only when profile
15251feedback is available. The real profiles (as opposed to statically estimated
15252ones) are much less balanced allowing the threshold to be larger value.
15253
15254@item tracer-max-code-growth
15255Stop tail duplication once code growth has reached given percentage. This is
15256a rather artificial limit, as most of the duplicates are eliminated later in
15257cross jumping, so it may be set to much higher values than is the desired code
15258growth.
15259
15260@item tracer-min-branch-ratio
15261
15262Stop reverse growth when the reverse probability of best edge is less than this
15263threshold (in percent).
15264
15265@item tracer-min-branch-probability
15266@itemx tracer-min-branch-probability-feedback
15267
15268Stop forward growth if the best edge has probability lower than this
15269threshold.
15270
15271Similarly to @option{tracer-dynamic-coverage} two parameters are
15272provided. @option{tracer-min-branch-probability-feedback} is used for
15273compilation with profile feedback and @option{tracer-min-branch-probability}
15274compilation without. The value for compilation with profile feedback
15275needs to be more conservative (higher) in order to make tracer
15276effective.
15277
15278@item stack-clash-protection-guard-size
15279Specify the size of the operating system provided stack guard as
152802 raised to @var{num} bytes. Higher values may reduce the
15281number of explicit probes, but a value larger than the operating system
15282provided guard will leave code vulnerable to stack clash style attacks.
15283
15284@item stack-clash-protection-probe-interval
15285Stack clash protection involves probing stack space as it is allocated. This
15286param controls the maximum distance between probes into the stack as 2 raised
15287to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15288larger than the operating system provided guard will leave code vulnerable to
15289stack clash style attacks.
15290
15291@item max-cse-path-length
15292
15293The maximum number of basic blocks on path that CSE considers.
15294
15295@item max-cse-insns
15296The maximum number of instructions CSE processes before flushing.
15297
15298@item ggc-min-expand
15299
15300GCC uses a garbage collector to manage its own memory allocation. This
15301parameter specifies the minimum percentage by which the garbage
15302collector's heap should be allowed to expand between collections.
15303Tuning this may improve compilation speed; it has no effect on code
15304generation.
15305
15306The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15307RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15308the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15309GCC is not able to calculate RAM on a particular platform, the lower
15310bound of 30% is used. Setting this parameter and
15311@option{ggc-min-heapsize} to zero causes a full collection to occur at
15312every opportunity. This is extremely slow, but can be useful for
15313debugging.
15314
15315@item ggc-min-heapsize
15316
15317Minimum size of the garbage collector's heap before it begins bothering
15318to collect garbage. The first collection occurs after the heap expands
15319by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15320tuning this may improve compilation speed, and has no effect on code
15321generation.
15322
15323The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15324tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15325with a lower bound of 4096 (four megabytes) and an upper bound of
15326131072 (128 megabytes). If GCC is not able to calculate RAM on a
15327particular platform, the lower bound is used. Setting this parameter
15328very large effectively disables garbage collection. Setting this
15329parameter and @option{ggc-min-expand} to zero causes a full collection
15330to occur at every opportunity.
15331
15332@item max-reload-search-insns
15333The maximum number of instruction reload should look backward for equivalent
15334register. Increasing values mean more aggressive optimization, making the
15335compilation time increase with probably slightly better performance.
15336
15337@item max-cselib-memory-locations
15338The maximum number of memory locations cselib should take into account.
15339Increasing values mean more aggressive optimization, making the compilation time
15340increase with probably slightly better performance.
15341
15342@item max-sched-ready-insns
15343The maximum number of instructions ready to be issued the scheduler should
15344consider at any given time during the first scheduling pass. Increasing
15345values mean more thorough searches, making the compilation time increase
15346with probably little benefit.
15347
15348@item max-sched-region-blocks
15349The maximum number of blocks in a region to be considered for
15350interblock scheduling.
15351
15352@item max-pipeline-region-blocks
15353The maximum number of blocks in a region to be considered for
15354pipelining in the selective scheduler.
15355
15356@item max-sched-region-insns
15357The maximum number of insns in a region to be considered for
15358interblock scheduling.
15359
15360@item max-pipeline-region-insns
15361The maximum number of insns in a region to be considered for
15362pipelining in the selective scheduler.
15363
15364@item min-spec-prob
15365The minimum probability (in percents) of reaching a source block
15366for interblock speculative scheduling.
15367
15368@item max-sched-extend-regions-iters
15369The maximum number of iterations through CFG to extend regions.
15370A value of 0 disables region extensions.
15371
15372@item max-sched-insn-conflict-delay
15373The maximum conflict delay for an insn to be considered for speculative motion.
15374
15375@item sched-spec-prob-cutoff
15376The minimal probability of speculation success (in percents), so that
15377speculative insns are scheduled.
15378
15379@item sched-state-edge-prob-cutoff
15380The minimum probability an edge must have for the scheduler to save its
15381state across it.
15382
15383@item sched-mem-true-dep-cost
15384Minimal distance (in CPU cycles) between store and load targeting same
15385memory locations.
15386
15387@item selsched-max-lookahead
15388The maximum size of the lookahead window of selective scheduling. It is a
15389depth of search for available instructions.
15390
15391@item selsched-max-sched-times
15392The maximum number of times that an instruction is scheduled during
15393selective scheduling. This is the limit on the number of iterations
15394through which the instruction may be pipelined.
15395
15396@item selsched-insns-to-rename
15397The maximum number of best instructions in the ready list that are considered
15398for renaming in the selective scheduler.
15399
15400@item sms-min-sc
15401The minimum value of stage count that swing modulo scheduler
15402generates.
15403
15404@item max-last-value-rtl
15405The maximum size measured as number of RTLs that can be recorded in an expression
15406in combiner for a pseudo register as last known value of that register.
15407
15408@item max-combine-insns
15409The maximum number of instructions the RTL combiner tries to combine.
15410
15411@item integer-share-limit
15412Small integer constants can use a shared data structure, reducing the
15413compiler's memory usage and increasing its speed. This sets the maximum
15414value of a shared integer constant.
15415
15416@item ssp-buffer-size
15417The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15418protection when @option{-fstack-protector} is used.
15419
15420@item min-size-for-stack-sharing
15421The minimum size of variables taking part in stack slot sharing when not
15422optimizing.
15423
15424@item max-jump-thread-duplication-stmts
15425Maximum number of statements allowed in a block that needs to be
15426duplicated when threading jumps.
15427
15428@item max-jump-thread-paths
15429The maximum number of paths to consider when searching for jump threading
15430opportunities. When arriving at a block, incoming edges are only considered
15431if the number of paths to be searched so far multiplied by the number of
15432incoming edges does not exhaust the specified maximum number of paths to
15433consider.
15434
15435@item max-fields-for-field-sensitive
15436Maximum number of fields in a structure treated in
15437a field sensitive manner during pointer analysis.
15438
15439@item prefetch-latency
15440Estimate on average number of instructions that are executed before
15441prefetch finishes. The distance prefetched ahead is proportional
15442to this constant. Increasing this number may also lead to less
15443streams being prefetched (see @option{simultaneous-prefetches}).
15444
15445@item simultaneous-prefetches
15446Maximum number of prefetches that can run at the same time.
15447
15448@item l1-cache-line-size
15449The size of cache line in L1 data cache, in bytes.
15450
15451@item l1-cache-size
15452The size of L1 data cache, in kilobytes.
15453
15454@item l2-cache-size
15455The size of L2 data cache, in kilobytes.
15456
15457@item prefetch-dynamic-strides
15458Whether the loop array prefetch pass should issue software prefetch hints
15459for strides that are non-constant. In some cases this may be
15460beneficial, though the fact the stride is non-constant may make it
15461hard to predict when there is clear benefit to issuing these hints.
15462
15463Set to 1 if the prefetch hints should be issued for non-constant
15464strides. Set to 0 if prefetch hints should be issued only for strides that
15465are known to be constant and below @option{prefetch-minimum-stride}.
15466
15467@item prefetch-minimum-stride
15468Minimum constant stride, in bytes, to start using prefetch hints for. If
15469the stride is less than this threshold, prefetch hints will not be issued.
15470
15471This setting is useful for processors that have hardware prefetchers, in
15472which case there may be conflicts between the hardware prefetchers and
15473the software prefetchers. If the hardware prefetchers have a maximum
15474stride they can handle, it should be used here to improve the use of
15475software prefetchers.
15476
15477A value of -1 means we don't have a threshold and therefore
15478prefetch hints can be issued for any constant stride.
15479
15480This setting is only useful for strides that are known and constant.
15481
15482@item destructive-interference-size
15483@item constructive-interference-size
15484The values for the C++17 variables
15485@code{std::hardware_destructive_interference_size} and
15486@code{std::hardware_constructive_interference_size}. The destructive
15487interference size is the minimum recommended offset between two
15488independent concurrently-accessed objects; the constructive
15489interference size is the maximum recommended size of contiguous memory
15490accessed together. Typically both will be the size of an L1 cache
15491line for the target, in bytes. For a generic target covering a range of L1
15492cache line sizes, typically the constructive interference size will be
15493the small end of the range and the destructive size will be the large
15494end.
15495
15496The destructive interference size is intended to be used for layout,
15497and thus has ABI impact. The default value is not expected to be
15498stable, and on some targets varies with @option{-mtune}, so use of
15499this variable in a context where ABI stability is important, such as
15500the public interface of a library, is strongly discouraged; if it is
15501used in that context, users can stabilize the value using this
15502option.
15503
15504The constructive interference size is less sensitive, as it is
15505typically only used in a @samp{static_assert} to make sure that a type
15506fits within a cache line.
15507
15508See also @option{-Winterference-size}.
15509
15510@item loop-interchange-max-num-stmts
15511The maximum number of stmts in a loop to be interchanged.
15512
15513@item loop-interchange-stride-ratio
15514The minimum ratio between stride of two loops for interchange to be profitable.
15515
15516@item min-insn-to-prefetch-ratio
15517The minimum ratio between the number of instructions and the
15518number of prefetches to enable prefetching in a loop.
15519
15520@item prefetch-min-insn-to-mem-ratio
15521The minimum ratio between the number of instructions and the
15522number of memory references to enable prefetching in a loop.
15523
15524@item use-canonical-types
15525Whether the compiler should use the ``canonical'' type system.
15526Should always be 1, which uses a more efficient internal
15527mechanism for comparing types in C++ and Objective-C++. However, if
15528bugs in the canonical type system are causing compilation failures,
15529set this value to 0 to disable canonical types.
15530
15531@item switch-conversion-max-branch-ratio
15532Switch initialization conversion refuses to create arrays that are
15533bigger than @option{switch-conversion-max-branch-ratio} times the number of
15534branches in the switch.
15535
15536@item max-partial-antic-length
15537Maximum length of the partial antic set computed during the tree
15538partial redundancy elimination optimization (@option{-ftree-pre}) when
15539optimizing at @option{-O3} and above. For some sorts of source code
15540the enhanced partial redundancy elimination optimization can run away,
15541consuming all of the memory available on the host machine. This
15542parameter sets a limit on the length of the sets that are computed,
15543which prevents the runaway behavior. Setting a value of 0 for
15544this parameter allows an unlimited set length.
15545
15546@item rpo-vn-max-loop-depth
15547Maximum loop depth that is value-numbered optimistically.
15548When the limit hits the innermost
15549@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15550loop nest are value-numbered optimistically and the remaining ones not.
15551
15552@item sccvn-max-alias-queries-per-access
15553Maximum number of alias-oracle queries we perform when looking for
15554redundancies for loads and stores. If this limit is hit the search
15555is aborted and the load or store is not considered redundant. The
15556number of queries is algorithmically limited to the number of
15557stores on all paths from the load to the function entry.
15558
15559@item ira-max-loops-num
15560IRA uses regional register allocation by default. If a function
15561contains more loops than the number given by this parameter, only at most
15562the given number of the most frequently-executed loops form regions
15563for regional register allocation.
15564
15565@item ira-max-conflict-table-size
15566Although IRA uses a sophisticated algorithm to compress the conflict
15567table, the table can still require excessive amounts of memory for
15568huge functions. If the conflict table for a function could be more
15569than the size in MB given by this parameter, the register allocator
15570instead uses a faster, simpler, and lower-quality
15571algorithm that does not require building a pseudo-register conflict table.
15572
15573@item ira-loop-reserved-regs
15574IRA can be used to evaluate more accurate register pressure in loops
15575for decisions to move loop invariants (see @option{-O3}). The number
15576of available registers reserved for some other purposes is given
15577by this parameter. Default of the parameter
15578is the best found from numerous experiments.
15579
15580@item ira-consider-dup-in-all-alts
15581Make IRA to consider matching constraint (duplicated operand number)
15582heavily in all available alternatives for preferred register class.
15583If it is set as zero, it means IRA only respects the matching
15584constraint when it's in the only available alternative with an
15585appropriate register class. Otherwise, it means IRA will check all
15586available alternatives for preferred register class even if it has
15587found some choice with an appropriate register class and respect the
15588found qualified matching constraint.
15589
9847c753
ML
15590@item ira-simple-lra-insn-threshold
15591Approximate function insn number in 1K units triggering simple local RA.
15592
d77de738
ML
15593@item lra-inheritance-ebb-probability-cutoff
15594LRA tries to reuse values reloaded in registers in subsequent insns.
15595This optimization is called inheritance. EBB is used as a region to
15596do this optimization. The parameter defines a minimal fall-through
15597edge probability in percentage used to add BB to inheritance EBB in
15598LRA. The default value was chosen
15599from numerous runs of SPEC2000 on x86-64.
15600
15601@item loop-invariant-max-bbs-in-loop
15602Loop invariant motion can be very expensive, both in compilation time and
15603in amount of needed compile-time memory, with very large loops. Loops
15604with more basic blocks than this parameter won't have loop invariant
15605motion optimization performed on them.
15606
15607@item loop-max-datarefs-for-datadeps
15608Building data dependencies is expensive for very large loops. This
15609parameter limits the number of data references in loops that are
15610considered for data dependence analysis. These large loops are no
15611handled by the optimizations using loop data dependencies.
15612
15613@item max-vartrack-size
15614Sets a maximum number of hash table slots to use during variable
15615tracking dataflow analysis of any function. If this limit is exceeded
15616with variable tracking at assignments enabled, analysis for that
15617function is retried without it, after removing all debug insns from
15618the function. If the limit is exceeded even without debug insns, var
15619tracking analysis is completely disabled for the function. Setting
15620the parameter to zero makes it unlimited.
15621
15622@item max-vartrack-expr-depth
15623Sets a maximum number of recursion levels when attempting to map
15624variable names or debug temporaries to value expressions. This trades
15625compilation time for more complete debug information. If this is set too
15626low, value expressions that are available and could be represented in
15627debug information may end up not being used; setting this higher may
15628enable the compiler to find more complex debug expressions, but compile
15629time and memory use may grow.
15630
15631@item max-debug-marker-count
15632Sets a threshold on the number of debug markers (e.g.@: begin stmt
15633markers) to avoid complexity explosion at inlining or expanding to RTL.
15634If a function has more such gimple stmts than the set limit, such stmts
15635will be dropped from the inlined copy of a function, and from its RTL
15636expansion.
15637
15638@item min-nondebug-insn-uid
15639Use uids starting at this parameter for nondebug insns. The range below
15640the parameter is reserved exclusively for debug insns created by
15641@option{-fvar-tracking-assignments}, but debug insns may get
15642(non-overlapping) uids above it if the reserved range is exhausted.
15643
10478270
MJ
15644@item ipa-sra-deref-prob-threshold
15645IPA-SRA replaces a pointer which is known not be NULL with one or more
15646new parameters only when the probability (in percent, relative to
15647function entry) of it being dereferenced is higher than this parameter.
15648
d77de738
ML
15649@item ipa-sra-ptr-growth-factor
15650IPA-SRA replaces a pointer to an aggregate with one or more new
15651parameters only when their cumulative size is less or equal to
15652@option{ipa-sra-ptr-growth-factor} times the size of the original
15653pointer parameter.
15654
69363825
ML
15655@item ipa-sra-ptrwrap-growth-factor
15656Additional maximum allowed growth of total size of new parameters
15657that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
15658if it points to a local variable that the caller only writes to and
15659passes it as an argument to other functions.
69363825 15660
d77de738
ML
15661@item ipa-sra-max-replacements
15662Maximum pieces of an aggregate that IPA-SRA tracks. As a
15663consequence, it is also the maximum number of replacements of a formal
15664parameter.
15665
15666@item sra-max-scalarization-size-Ospeed
15667@itemx sra-max-scalarization-size-Osize
15668The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15669replace scalar parts of aggregates with uses of independent scalar
15670variables. These parameters control the maximum size, in storage units,
15671of aggregate which is considered for replacement when compiling for
15672speed
15673(@option{sra-max-scalarization-size-Ospeed}) or size
15674(@option{sra-max-scalarization-size-Osize}) respectively.
15675
15676@item sra-max-propagations
15677The maximum number of artificial accesses that Scalar Replacement of
15678Aggregates (SRA) will track, per one local variable, in order to
15679facilitate copy propagation.
15680
15681@item tm-max-aggregate-size
15682When making copies of thread-local variables in a transaction, this
15683parameter specifies the size in bytes after which variables are
15684saved with the logging functions as opposed to save/restore code
15685sequence pairs. This option only applies when using
15686@option{-fgnu-tm}.
15687
15688@item graphite-max-nb-scop-params
15689To avoid exponential effects in the Graphite loop transforms, the
15690number of parameters in a Static Control Part (SCoP) is bounded.
15691A value of zero can be used to lift
15692the bound. A variable whose value is unknown at compilation time and
15693defined outside a SCoP is a parameter of the SCoP.
15694
15695@item loop-block-tile-size
15696Loop blocking or strip mining transforms, enabled with
15697@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15698loop in the loop nest by a given number of iterations. The strip
15699length can be changed using the @option{loop-block-tile-size}
15700parameter.
15701
15702@item ipa-jump-function-lookups
15703Specifies number of statements visited during jump function offset discovery.
15704
15705@item ipa-cp-value-list-size
15706IPA-CP attempts to track all possible values and types passed to a function's
15707parameter in order to propagate them and perform devirtualization.
15708@option{ipa-cp-value-list-size} is the maximum number of values and types it
15709stores per one formal parameter of a function.
15710
15711@item ipa-cp-eval-threshold
15712IPA-CP calculates its own score of cloning profitability heuristics
15713and performs those cloning opportunities with scores that exceed
15714@option{ipa-cp-eval-threshold}.
15715
15716@item ipa-cp-max-recursive-depth
15717Maximum depth of recursive cloning for self-recursive function.
15718
15719@item ipa-cp-min-recursive-probability
15720Recursive cloning only when the probability of call being executed exceeds
15721the parameter.
15722
15723@item ipa-cp-profile-count-base
15724When using @option{-fprofile-use} option, IPA-CP will consider the measured
15725execution count of a call graph edge at this percentage position in their
15726histogram as the basis for its heuristics calculation.
15727
15728@item ipa-cp-recursive-freq-factor
15729The number of times interprocedural copy propagation expects recursive
15730functions to call themselves.
15731
15732@item ipa-cp-recursion-penalty
15733Percentage penalty the recursive functions will receive when they
15734are evaluated for cloning.
15735
15736@item ipa-cp-single-call-penalty
15737Percentage penalty functions containing a single call to another
15738function will receive when they are evaluated for cloning.
15739
15740@item ipa-max-agg-items
15741IPA-CP is also capable to propagate a number of scalar values passed
15742in an aggregate. @option{ipa-max-agg-items} controls the maximum
15743number of such values per one parameter.
15744
15745@item ipa-cp-loop-hint-bonus
15746When IPA-CP determines that a cloning candidate would make the number
15747of iterations of a loop known, it adds a bonus of
15748@option{ipa-cp-loop-hint-bonus} to the profitability score of
15749the candidate.
15750
15751@item ipa-max-loop-predicates
15752The maximum number of different predicates IPA will use to describe when
15753loops in a function have known properties.
15754
15755@item ipa-max-aa-steps
15756During its analysis of function bodies, IPA-CP employs alias analysis
15757in order to track values pointed to by function parameters. In order
15758not spend too much time analyzing huge functions, it gives up and
15759consider all memory clobbered after examining
15760@option{ipa-max-aa-steps} statements modifying memory.
15761
15762@item ipa-max-switch-predicate-bounds
15763Maximal number of boundary endpoints of case ranges of switch statement.
15764For switch exceeding this limit, IPA-CP will not construct cloning cost
15765predicate, which is used to estimate cloning benefit, for default case
15766of the switch statement.
15767
15768@item ipa-max-param-expr-ops
15769IPA-CP will analyze conditional statement that references some function
15770parameter to estimate benefit for cloning upon certain constant value.
15771But if number of operations in a parameter expression exceeds
15772@option{ipa-max-param-expr-ops}, the expression is treated as complicated
15773one, and is not handled by IPA analysis.
15774
15775@item lto-partitions
15776Specify desired number of partitions produced during WHOPR compilation.
15777The number of partitions should exceed the number of CPUs used for compilation.
15778
15779@item lto-min-partition
15780Size of minimal partition for WHOPR (in estimated instructions).
15781This prevents expenses of splitting very small programs into too many
15782partitions.
15783
15784@item lto-max-partition
15785Size of max partition for WHOPR (in estimated instructions).
15786to provide an upper bound for individual size of partition.
15787Meant to be used only with balanced partitioning.
15788
15789@item lto-max-streaming-parallelism
15790Maximal number of parallel processes used for LTO streaming.
15791
15792@item cxx-max-namespaces-for-diagnostic-help
15793The maximum number of namespaces to consult for suggestions when C++
15794name lookup fails for an identifier.
15795
15796@item sink-frequency-threshold
15797The maximum relative execution frequency (in percents) of the target block
15798relative to a statement's original block to allow statement sinking of a
15799statement. Larger numbers result in more aggressive statement sinking.
15800A small positive adjustment is applied for
15801statements with memory operands as those are even more profitable so sink.
15802
15803@item max-stores-to-sink
15804The maximum number of conditional store pairs that can be sunk. Set to 0
15805if either vectorization (@option{-ftree-vectorize}) or if-conversion
15806(@option{-ftree-loop-if-convert}) is disabled.
15807
15808@item case-values-threshold
15809The smallest number of different values for which it is best to use a
15810jump-table instead of a tree of conditional branches. If the value is
158110, use the default for the machine.
15812
15813@item jump-table-max-growth-ratio-for-size
15814The maximum code size growth ratio when expanding
15815into a jump table (in percent). The parameter is used when
15816optimizing for size.
15817
15818@item jump-table-max-growth-ratio-for-speed
15819The maximum code size growth ratio when expanding
15820into a jump table (in percent). The parameter is used when
15821optimizing for speed.
15822
15823@item tree-reassoc-width
15824Set the maximum number of instructions executed in parallel in
15825reassociated tree. This parameter overrides target dependent
15826heuristics used by default if has non zero value.
15827
15828@item sched-pressure-algorithm
15829Choose between the two available implementations of
15830@option{-fsched-pressure}. Algorithm 1 is the original implementation
15831and is the more likely to prevent instructions from being reordered.
15832Algorithm 2 was designed to be a compromise between the relatively
15833conservative approach taken by algorithm 1 and the rather aggressive
15834approach taken by the default scheduler. It relies more heavily on
15835having a regular register file and accurate register pressure classes.
15836See @file{haifa-sched.cc} in the GCC sources for more details.
15837
15838The default choice depends on the target.
15839
15840@item max-slsr-cand-scan
15841Set the maximum number of existing candidates that are considered when
15842seeking a basis for a new straight-line strength reduction candidate.
15843
15844@item asan-globals
15845Enable buffer overflow detection for global objects. This kind
15846of protection is enabled by default if you are using
15847@option{-fsanitize=address} option.
15848To disable global objects protection use @option{--param asan-globals=0}.
15849
15850@item asan-stack
15851Enable buffer overflow detection for stack objects. This kind of
15852protection is enabled by default when using @option{-fsanitize=address}.
15853To disable stack protection use @option{--param asan-stack=0} option.
15854
15855@item asan-instrument-reads
15856Enable buffer overflow detection for memory reads. This kind of
15857protection is enabled by default when using @option{-fsanitize=address}.
15858To disable memory reads protection use
15859@option{--param asan-instrument-reads=0}.
15860
15861@item asan-instrument-writes
15862Enable buffer overflow detection for memory writes. This kind of
15863protection is enabled by default when using @option{-fsanitize=address}.
15864To disable memory writes protection use
15865@option{--param asan-instrument-writes=0} option.
15866
15867@item asan-memintrin
15868Enable detection for built-in functions. This kind of protection
15869is enabled by default when using @option{-fsanitize=address}.
15870To disable built-in functions protection use
15871@option{--param asan-memintrin=0}.
15872
15873@item asan-use-after-return
15874Enable detection of use-after-return. This kind of protection
15875is enabled by default when using the @option{-fsanitize=address} option.
15876To disable it use @option{--param asan-use-after-return=0}.
15877
15878Note: By default the check is disabled at run time. To enable it,
15879add @code{detect_stack_use_after_return=1} to the environment variable
15880@env{ASAN_OPTIONS}.
15881
15882@item asan-instrumentation-with-call-threshold
15883If number of memory accesses in function being instrumented
15884is greater or equal to this number, use callbacks instead of inline checks.
15885E.g. to disable inline code use
15886@option{--param asan-instrumentation-with-call-threshold=0}.
15887
545c9f8b 15888@item asan-kernel-mem-intrinsic-prefix
f56ed5b3
SL
15889If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove}
15890with @samp{__asan_} or @samp{__hwasan_}
15891for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress},
15892respectively.
545c9f8b 15893
d77de738
ML
15894@item hwasan-instrument-stack
15895Enable hwasan instrumentation of statically sized stack-allocated variables.
15896This kind of instrumentation is enabled by default when using
15897@option{-fsanitize=hwaddress} and disabled by default when using
15898@option{-fsanitize=kernel-hwaddress}.
15899To disable stack instrumentation use
15900@option{--param hwasan-instrument-stack=0}, and to enable it use
15901@option{--param hwasan-instrument-stack=1}.
15902
15903@item hwasan-random-frame-tag
15904When using stack instrumentation, decide tags for stack variables using a
15905deterministic sequence beginning at a random tag for each frame. With this
15906parameter unset tags are chosen using the same sequence but beginning from 1.
15907This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
15908for @option{-fsanitize=kernel-hwaddress}.
15909To disable it use @option{--param hwasan-random-frame-tag=0}.
15910
15911@item hwasan-instrument-allocas
15912Enable hwasan instrumentation of dynamically sized stack-allocated variables.
15913This kind of instrumentation is enabled by default when using
15914@option{-fsanitize=hwaddress} and disabled by default when using
15915@option{-fsanitize=kernel-hwaddress}.
15916To disable instrumentation of such variables use
15917@option{--param hwasan-instrument-allocas=0}, and to enable it use
15918@option{--param hwasan-instrument-allocas=1}.
15919
15920@item hwasan-instrument-reads
15921Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
15922default for both @option{-fsanitize=hwaddress} and
15923@option{-fsanitize=kernel-hwaddress}.
15924To disable checking memory reads use
15925@option{--param hwasan-instrument-reads=0}.
15926
15927@item hwasan-instrument-writes
15928Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
15929default for both @option{-fsanitize=hwaddress} and
15930@option{-fsanitize=kernel-hwaddress}.
15931To disable checking memory writes use
15932@option{--param hwasan-instrument-writes=0}.
15933
15934@item hwasan-instrument-mem-intrinsics
15935Enable hwasan instrumentation of builtin functions. Instrumentation of these
15936builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
15937and @option{-fsanitize=kernel-hwaddress}.
15938To disable instrumentation of builtin functions use
15939@option{--param hwasan-instrument-mem-intrinsics=0}.
15940
15941@item use-after-scope-direct-emission-threshold
15942If the size of a local variable in bytes is smaller or equal to this
15943number, directly poison (or unpoison) shadow memory instead of using
15944run-time callbacks.
15945
15946@item tsan-distinguish-volatile
15947Emit special instrumentation for accesses to volatiles.
15948
15949@item tsan-instrument-func-entry-exit
15950Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
15951
15952@item max-fsm-thread-path-insns
15953Maximum number of instructions to copy when duplicating blocks on a
15954finite state automaton jump thread path.
15955
15956@item threader-debug
15957threader-debug=[none|all] Enables verbose dumping of the threader solver.
15958
15959@item parloops-chunk-size
15960Chunk size of omp schedule for loops parallelized by parloops.
15961
15962@item parloops-schedule
15963Schedule type of omp schedule for loops parallelized by parloops (static,
15964dynamic, guided, auto, runtime).
15965
15966@item parloops-min-per-thread
15967The minimum number of iterations per thread of an innermost parallelized
15968loop for which the parallelized variant is preferred over the single threaded
15969one. Note that for a parallelized loop nest the
15970minimum number of iterations of the outermost loop per thread is two.
15971
15972@item max-ssa-name-query-depth
15973Maximum depth of recursion when querying properties of SSA names in things
15974like fold routines. One level of recursion corresponds to following a
15975use-def chain.
15976
15977@item max-speculative-devirt-maydefs
15978The maximum number of may-defs we analyze when looking for a must-def
15979specifying the dynamic type of an object that invokes a virtual call
15980we may be able to devirtualize speculatively.
15981
d77de738
ML
15982@item evrp-sparse-threshold
15983Maximum number of basic blocks before EVRP uses a sparse cache.
15984
d77de738
ML
15985@item ranger-debug
15986Specifies the type of debug output to be issued for ranges.
15987
15988@item evrp-switch-limit
15989Specifies the maximum number of switch cases before EVRP ignores a switch.
15990
15991@item unroll-jam-min-percent
15992The minimum percentage of memory references that must be optimized
15993away for the unroll-and-jam transformation to be considered profitable.
15994
15995@item unroll-jam-max-unroll
15996The maximum number of times the outer loop should be unrolled by
15997the unroll-and-jam transformation.
15998
15999@item max-rtl-if-conversion-unpredictable-cost
16000Maximum permissible cost for the sequence that would be generated
16001by the RTL if-conversion pass for a branch that is considered unpredictable.
16002
16003@item max-variable-expansions-in-unroller
16004If @option{-fvariable-expansion-in-unroller} is used, the maximum number
16005of times that an individual variable will be expanded during loop unrolling.
16006
16007@item partial-inlining-entry-probability
16008Maximum probability of the entry BB of split region
16009(in percent relative to entry BB of the function)
16010to make partial inlining happen.
16011
16012@item max-tracked-strlens
16013Maximum number of strings for which strlen optimization pass will
16014track string lengths.
16015
16016@item gcse-after-reload-partial-fraction
16017The threshold ratio for performing partial redundancy
16018elimination after reload.
16019
16020@item gcse-after-reload-critical-fraction
16021The threshold ratio of critical edges execution count that
16022permit performing redundancy elimination after reload.
16023
16024@item max-loop-header-insns
16025The maximum number of insns in loop header duplicated
16026by the copy loop headers pass.
16027
16028@item vect-epilogues-nomask
16029Enable loop epilogue vectorization using smaller vector size.
16030
16031@item vect-partial-vector-usage
16032Controls when the loop vectorizer considers using partial vector loads
16033and stores as an alternative to falling back to scalar code. 0 stops
16034the vectorizer from ever using partial vector loads and stores. 1 allows
16035partial vector loads and stores if vectorization removes the need for the
16036code to iterate. 2 allows partial vector loads and stores in all loops.
16037The parameter only has an effect on targets that support partial
16038vector loads and stores.
16039
16040@item vect-inner-loop-cost-factor
16041The maximum factor which the loop vectorizer applies to the cost of statements
16042in an inner loop relative to the loop being vectorized. The factor applied
16043is the maximum of the estimated number of iterations of the inner loop and
16044this parameter. The default value of this parameter is 50.
16045
16046@item vect-induction-float
16047Enable loop vectorization of floating point inductions.
16048
16049@item avoid-fma-max-bits
16050Maximum number of bits for which we avoid creating FMAs.
16051
16052@item sms-loop-average-count-threshold
16053A threshold on the average loop count considered by the swing modulo scheduler.
16054
16055@item sms-dfa-history
16056The number of cycles the swing modulo scheduler considers when checking
16057conflicts using DFA.
16058
16059@item graphite-allow-codegen-errors
16060Whether codegen errors should be ICEs when @option{-fchecking}.
16061
16062@item sms-max-ii-factor
16063A factor for tuning the upper bound that swing modulo scheduler
16064uses for scheduling a loop.
16065
16066@item lra-max-considered-reload-pseudos
16067The max number of reload pseudos which are considered during
16068spilling a non-reload pseudo.
16069
16070@item max-pow-sqrt-depth
16071Maximum depth of sqrt chains to use when synthesizing exponentiation
16072by a real constant.
16073
16074@item max-dse-active-local-stores
16075Maximum number of active local stores in RTL dead store elimination.
16076
16077@item asan-instrument-allocas
16078Enable asan allocas/VLAs protection.
16079
16080@item max-iterations-computation-cost
16081Bound on the cost of an expression to compute the number of iterations.
16082
16083@item max-isl-operations
16084Maximum number of isl operations, 0 means unlimited.
16085
16086@item graphite-max-arrays-per-scop
16087Maximum number of arrays per scop.
16088
16089@item max-vartrack-reverse-op-size
16090Max. size of loc list for which reverse ops should be added.
16091
16092@item fsm-scale-path-stmts
16093Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
16094crossing a loop backedge when comparing to
16095@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
16096
16097@item uninit-control-dep-attempts
16098Maximum number of nested calls to search for control dependencies
16099during uninitialized variable analysis.
16100
d77de738
ML
16101@item sched-autopref-queue-depth
16102Hardware autoprefetcher scheduler model control flag.
16103Number of lookahead cycles the model looks into; at '
16104' only enable instruction sorting heuristic.
16105
16106@item loop-versioning-max-inner-insns
16107The maximum number of instructions that an inner loop can have
16108before the loop versioning pass considers it too big to copy.
16109
16110@item loop-versioning-max-outer-insns
16111The maximum number of instructions that an outer loop can have
16112before the loop versioning pass considers it too big to copy,
16113discounting any instructions in inner loops that directly benefit
16114from versioning.
16115
16116@item ssa-name-def-chain-limit
16117The maximum number of SSA_NAME assignments to follow in determining
16118a property of a variable such as its value. This limits the number
16119of iterations or recursive calls GCC performs when optimizing certain
16120statements or when determining their validity prior to issuing
16121diagnostics.
16122
16123@item store-merging-max-size
16124Maximum size of a single store merging region in bytes.
16125
16126@item hash-table-verification-limit
16127The number of elements for which hash table verification is done
16128for each searched element.
16129
16130@item max-find-base-term-values
16131Maximum number of VALUEs handled during a single find_base_term call.
16132
16133@item analyzer-max-enodes-per-program-point
16134The maximum number of exploded nodes per program point within
16135the analyzer, before terminating analysis of that point.
16136
16137@item analyzer-max-constraints
16138The maximum number of constraints per state.
16139
16140@item analyzer-min-snodes-for-call-summary
16141The minimum number of supernodes within a function for the
16142analyzer to consider summarizing its effects at call sites.
16143
16144@item analyzer-max-enodes-for-full-dump
16145The maximum depth of exploded nodes that should appear in a dot dump
16146before switching to a less verbose format.
16147
16148@item analyzer-max-recursion-depth
16149The maximum number of times a callsite can appear in a call stack
16150within the analyzer, before terminating analysis of a call that would
16151recurse deeper.
16152
16153@item analyzer-max-svalue-depth
16154The maximum depth of a symbolic value, before approximating
16155the value as unknown.
16156
16157@item analyzer-max-infeasible-edges
16158The maximum number of infeasible edges to reject before declaring
16159a diagnostic as infeasible.
16160
16161@item gimple-fe-computed-hot-bb-threshold
16162The number of executions of a basic block which is considered hot.
16163The parameter is used only in GIMPLE FE.
16164
16165@item analyzer-bb-explosion-factor
16166The maximum number of 'after supernode' exploded nodes within the analyzer
16167per supernode, before terminating analysis.
16168
16169@item ranger-logical-depth
16170Maximum depth of logical expression evaluation ranger will look through
16171when evaluating outgoing edge ranges.
16172
16173@item relation-block-limit
16174Maximum number of relations the oracle will register in a basic block.
16175
16176@item min-pagesize
16177Minimum page size for warning purposes.
16178
16179@item openacc-kernels
16180Specify mode of OpenACC `kernels' constructs handling.
16181With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16182constructs are decomposed into parts, a sequence of compute
16183constructs, each then handled individually.
16184This is work in progress.
16185With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16186constructs are handled by the @samp{parloops} pass, en bloc.
16187This is the current default.
16188
16189@item openacc-privatization
4ace81b6
SL
16190Control whether the @option{-fopt-info-omp-note} and applicable
16191@option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics.
d77de738
ML
16192With @option{--param=openacc-privatization=quiet}, don't diagnose.
16193This is the current default.
16194With @option{--param=openacc-privatization=noisy}, do diagnose.
16195
16196@end table
16197
16198The following choices of @var{name} are available on AArch64 targets:
16199
16200@table @gcctabopt
16201@item aarch64-sve-compare-costs
16202When vectorizing for SVE, consider using ``unpacked'' vectors for
16203smaller elements and use the cost model to pick the cheapest approach.
16204Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16205
16206Using unpacked vectors includes storing smaller elements in larger
16207containers and accessing elements with extending loads and truncating
16208stores.
16209
16210@item aarch64-float-recp-precision
16211The number of Newton iterations for calculating the reciprocal for float type.
16212The precision of division is proportional to this param when division
16213approximation is enabled. The default value is 1.
16214
16215@item aarch64-double-recp-precision
16216The number of Newton iterations for calculating the reciprocal for double type.
16217The precision of division is propotional to this param when division
16218approximation is enabled. The default value is 2.
16219
16220@item aarch64-autovec-preference
16221Force an ISA selection strategy for auto-vectorization. Accepts values from
162220 to 4, inclusive.
16223@table @samp
16224@item 0
16225Use the default heuristics.
16226@item 1
16227Use only Advanced SIMD for auto-vectorization.
16228@item 2
16229Use only SVE for auto-vectorization.
16230@item 3
16231Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16232deemed equal.
16233@item 4
16234Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16235@end table
16236The default value is 0.
16237
16238@item aarch64-loop-vect-issue-rate-niters
16239The tuning for some AArch64 CPUs tries to take both latencies and issue
16240rates into account when deciding whether a loop should be vectorized
16241using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16242If this parameter is set to @var{n}, GCC will not use this heuristic
16243for loops that are known to execute in fewer than @var{n} Advanced
16244SIMD iterations.
16245
16246@item aarch64-vect-unroll-limit
16247The vectorizer will use available tuning information to determine whether it
16248would be beneficial to unroll the main vectorized loop and by how much. This
16249parameter set's the upper bound of how much the vectorizer will unroll the main
16250loop. The default value is four.
16251
16252@end table
16253
16254The following choices of @var{name} are available on i386 and x86_64 targets:
16255
16256@table @gcctabopt
16257@item x86-stlf-window-ninsns
16258Instructions number above which STFL stall penalty can be compensated.
16259
60101899
RB
16260@item x86-stv-max-visits
16261The maximum number of use and def visits when discovering a STV chain before
16262the discovery is aborted.
16263
d77de738
ML
16264@end table
16265
16266@end table
16267
16268@node Instrumentation Options
16269@section Program Instrumentation Options
16270@cindex instrumentation options
16271@cindex program instrumentation options
16272@cindex run-time error checking options
16273@cindex profiling options
16274@cindex options, program instrumentation
16275@cindex options, run-time error checking
16276@cindex options, profiling
16277
16278GCC supports a number of command-line options that control adding
16279run-time instrumentation to the code it normally generates.
16280For example, one purpose of instrumentation is collect profiling
16281statistics for use in finding program hot spots, code coverage
16282analysis, or profile-guided optimizations.
16283Another class of program instrumentation is adding run-time checking
16284to detect programming errors like invalid pointer
16285dereferences or out-of-bounds array accesses, as well as deliberately
16286hostile attacks such as stack smashing or C++ vtable hijacking.
16287There is also a general hook which can be used to implement other
16288forms of tracing or function-level instrumentation for debug or
16289program analysis purposes.
16290
16291@table @gcctabopt
16292@cindex @command{prof}
16293@cindex @command{gprof}
d77de738
ML
16294@opindex p
16295@opindex pg
ddf6fe37
AA
16296@item -p
16297@itemx -pg
d77de738
ML
16298Generate extra code to write profile information suitable for the
16299analysis program @command{prof} (for @option{-p}) or @command{gprof}
16300(for @option{-pg}). You must use this option when compiling
16301the source files you want data about, and you must also use it when
16302linking.
16303
16304You can use the function attribute @code{no_instrument_function} to
16305suppress profiling of individual functions when compiling with these options.
16306@xref{Common Function Attributes}.
16307
d77de738 16308@opindex fprofile-arcs
ddf6fe37 16309@item -fprofile-arcs
d77de738
ML
16310Add code so that program flow @dfn{arcs} are instrumented. During
16311execution the program records how many times each branch and call is
16312executed and how many times it is taken or returns. On targets that support
16313constructors with priority support, profiling properly handles constructors,
16314destructors and C++ constructors (and destructors) of classes which are used
16315as a type of a global variable.
16316
16317When the compiled
16318program exits it saves this data to a file called
16319@file{@var{auxname}.gcda} for each source file. The data may be used for
16320profile-directed optimizations (@option{-fbranch-probabilities}), or for
16321test coverage analysis (@option{-ftest-coverage}). Each object file's
16322@var{auxname} is generated from the name of the output file, if
16323explicitly specified and it is not the final executable, otherwise it is
16324the basename of the source file. In both cases any suffix is removed
16325(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16326@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16327
16328Note that if a command line directly links source files, the corresponding
16329@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16330E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16331@file{binary-b.gcda} files.
16332
16333@xref{Cross-profiling}.
16334
16335@cindex @command{gcov}
d77de738 16336@opindex coverage
ddf6fe37 16337@item --coverage
d77de738
ML
16338
16339This option is used to compile and link code instrumented for coverage
16340analysis. The option is a synonym for @option{-fprofile-arcs}
16341@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16342linking). See the documentation for those options for more details.
16343
16344@itemize
16345
16346@item
16347Compile the source files with @option{-fprofile-arcs} plus optimization
16348and code generation options. For test coverage analysis, use the
16349additional @option{-ftest-coverage} option. You do not need to profile
16350every source file in a program.
16351
16352@item
16353Compile the source files additionally with @option{-fprofile-abs-path}
16354to create absolute path names in the @file{.gcno} files. This allows
16355@command{gcov} to find the correct sources in projects where compilations
16356occur with different working directories.
16357
16358@item
16359Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16360(the latter implies the former).
16361
16362@item
16363Run the program on a representative workload to generate the arc profile
16364information. This may be repeated any number of times. You can run
16365concurrent instances of your program, and provided that the file system
16366supports locking, the data files will be correctly updated. Unless
16367a strict ISO C dialect option is in effect, @code{fork} calls are
16368detected and correctly handled without double counting.
16369
16370Moreover, an object file can be recompiled multiple times
16371and the corresponding @file{.gcda} file merges as long as
16372the source file and the compiler options are unchanged.
16373
16374@item
16375For profile-directed optimizations, compile the source files again with
16376the same optimization and code generation options plus
16377@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16378Control Optimization}).
16379
16380@item
16381For test coverage analysis, use @command{gcov} to produce human readable
16382information from the @file{.gcno} and @file{.gcda} files. Refer to the
16383@command{gcov} documentation for further information.
16384
16385@end itemize
16386
16387With @option{-fprofile-arcs}, for each function of your program GCC
16388creates a program flow graph, then finds a spanning tree for the graph.
16389Only arcs that are not on the spanning tree have to be instrumented: the
16390compiler adds code to count the number of times that these arcs are
16391executed. When an arc is the only exit or only entrance to a block, the
16392instrumentation code can be added to the block; otherwise, a new basic
16393block must be created to hold the instrumentation code.
16394
16395@need 2000
d77de738 16396@opindex ftest-coverage
ddf6fe37 16397@item -ftest-coverage
d77de738
ML
16398Produce a notes file that the @command{gcov} code-coverage utility
16399(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16400show program coverage. Each source file's note file is called
16401@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16402above for a description of @var{auxname} and instructions on how to
16403generate test coverage data. Coverage data matches the source files
16404more closely if you do not optimize.
16405
d77de738 16406@opindex fprofile-abs-path
ddf6fe37 16407@item -fprofile-abs-path
d77de738
ML
16408Automatically convert relative source file names to absolute path names
16409in the @file{.gcno} files. This allows @command{gcov} to find the correct
16410sources in projects where compilations occur with different working
16411directories.
16412
d77de738 16413@opindex fprofile-dir
ddf6fe37 16414@item -fprofile-dir=@var{path}
d77de738
ML
16415
16416Set the directory to search for the profile data files in to @var{path}.
16417This option affects only the profile data generated by
16418@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16419and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16420and its related options. Both absolute and relative paths can be used.
16421By default, GCC uses the current directory as @var{path}, thus the
16422profile data file appears in the same directory as the object file.
16423In order to prevent the file name clashing, if the object file name is
16424not an absolute path, we mangle the absolute path of the
16425@file{@var{sourcename}.gcda} file and use it as the file name of a
16426@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16427See similar option @option{-fprofile-note}.
16428
16429When an executable is run in a massive parallel environment, it is recommended
16430to save profile to different folders. That can be done with variables
16431in @var{path} that are exported during run-time:
16432
16433@table @gcctabopt
16434
16435@item %p
16436process ID.
16437
16438@item %q@{VAR@}
16439value of environment variable @var{VAR}
16440
16441@end table
16442
ddf6fe37 16443@opindex fprofile-generate
d77de738
ML
16444@item -fprofile-generate
16445@itemx -fprofile-generate=@var{path}
d77de738
ML
16446
16447Enable options usually used for instrumenting application to produce
16448profile useful for later recompilation with profile feedback based
16449optimization. You must use @option{-fprofile-generate} both when
16450compiling and when linking your program.
16451
16452The following options are enabled:
16453@option{-fprofile-arcs}, @option{-fprofile-values},
16454@option{-finline-functions}, and @option{-fipa-bit-cp}.
16455
16456If @var{path} is specified, GCC looks at the @var{path} to find
16457the profile feedback data files. See @option{-fprofile-dir}.
16458
16459To optimize the program based on the collected profile information, use
16460@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16461
ddf6fe37 16462@opindex fprofile-info-section
d77de738
ML
16463@item -fprofile-info-section
16464@itemx -fprofile-info-section=@var{name}
d77de738
ML
16465
16466Register the profile information in the specified section instead of using a
16467constructor/destructor. The section name is @var{name} if it is specified,
16468otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16469profile information generated by @option{-fprofile-arcs} is placed in the
16470specified section for each translation unit. This option disables the profile
16471information registration through a constructor and it disables the profile
16472information processing through a destructor. This option is not intended to be
16473used in hosted environments such as GNU/Linux. It targets freestanding
16474environments (for example embedded systems) with limited resources which do not
16475support constructors/destructors or the C library file I/O.
16476
16477The linker could collect the input sections in a continuous memory block and
16478define start and end symbols. A GNU linker script example which defines a
16479linker output section follows:
16480
16481@smallexample
16482 .gcov_info :
16483 @{
16484 PROVIDE (__gcov_info_start = .);
16485 KEEP (*(.gcov_info))
16486 PROVIDE (__gcov_info_end = .);
16487 @}
16488@end smallexample
16489
16490The program could dump the profiling information registered in this linker set
16491for example like this:
16492
16493@smallexample
16494#include <gcov.h>
16495#include <stdio.h>
16496#include <stdlib.h>
16497
16498extern const struct gcov_info *const __gcov_info_start[];
16499extern const struct gcov_info *const __gcov_info_end[];
16500
16501static void
16502dump (const void *d, unsigned n, void *arg)
16503@{
16504 const unsigned char *c = d;
16505
16506 for (unsigned i = 0; i < n; ++i)
16507 printf ("%02x", c[i]);
16508@}
16509
16510static void
16511filename (const char *f, void *arg)
16512@{
16513 __gcov_filename_to_gcfn (f, dump, arg );
16514@}
16515
16516static void *
16517allocate (unsigned length, void *arg)
16518@{
16519 return malloc (length);
16520@}
16521
16522static void
16523dump_gcov_info (void)
16524@{
16525 const struct gcov_info *const *info = __gcov_info_start;
16526 const struct gcov_info *const *end = __gcov_info_end;
16527
16528 /* Obfuscate variable to prevent compiler optimizations. */
16529 __asm__ ("" : "+r" (info));
16530
16531 while (info != end)
16532 @{
16533 void *arg = NULL;
16534 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16535 putchar ('\n');
16536 ++info;
16537 @}
16538@}
16539
16540int
16541main (void)
16542@{
16543 dump_gcov_info ();
16544 return 0;
16545@}
16546@end smallexample
16547
16548The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16549deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16550@code{__gcov_info_to_gcda} functions and merge the profile information into
16551@file{.gcda} files on the host filesystem.
16552
d77de738 16553@opindex fprofile-note
ddf6fe37 16554@item -fprofile-note=@var{path}
d77de738
ML
16555
16556If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16557location. If you combine the option with multiple source files,
16558the @file{.gcno} file will be overwritten.
16559
d77de738 16560@opindex fprofile-prefix-path
ddf6fe37 16561@item -fprofile-prefix-path=@var{path}
d77de738
ML
16562
16563This option can be used in combination with
16564@option{profile-generate=}@var{profile_dir} and
16565@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16566directory of built source tree. By default @var{profile_dir} will contain
16567files with mangled absolute paths of all object files in the built project.
16568This is not desirable when directory used to build the instrumented binary
16569differs from the directory used to build the binary optimized with profile
16570feedback because the profile data will not be found during the optimized build.
16571In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16572pointing to the base directory of the build can be used to strip the irrelevant
16573part of the path and keep all file names relative to the main build directory.
16574
d77de738 16575@opindex fprofile-prefix-map
ddf6fe37 16576@item -fprofile-prefix-map=@var{old}=@var{new}
d77de738
ML
16577When compiling files residing in directory @file{@var{old}}, record
16578profiling information (with @option{--coverage})
16579describing them as if the files resided in
16580directory @file{@var{new}} instead.
2eb0191a 16581See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}.
d77de738 16582
d77de738 16583@opindex fprofile-update
ddf6fe37 16584@item -fprofile-update=@var{method}
d77de738
ML
16585
16586Alter the update method for an application instrumented for profile
16587feedback based optimization. The @var{method} argument should be one of
16588@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16589The first one is useful for single-threaded applications,
16590while the second one prevents profile corruption by emitting thread-safe code.
16591
16592@strong{Warning:} When an application does not properly join all threads
16593(or creates an detached thread), a profile file can be still corrupted.
16594
16595Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16596when supported by a target, or to @samp{single} otherwise. The GCC driver
16597automatically selects @samp{prefer-atomic} when @option{-pthread}
16598is present in the command line.
16599
d77de738 16600@opindex fprofile-filter-files
ddf6fe37 16601@item -fprofile-filter-files=@var{regex}
d77de738
ML
16602
16603Instrument only functions from files whose name matches
16604any of the regular expressions (separated by semi-colons).
16605
16606For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16607only @file{main.c} and all C files starting with 'module'.
16608
d77de738 16609@opindex fprofile-exclude-files
ddf6fe37 16610@item -fprofile-exclude-files=@var{regex}
d77de738
ML
16611
16612Instrument only functions from files whose name does not match
16613any of the regular expressions (separated by semi-colons).
16614
16615For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16616of all files that are located in the @file{/usr/} folder.
16617
d77de738 16618@opindex fprofile-reproducible
ddf6fe37 16619@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
d77de738
ML
16620Control level of reproducibility of profile gathered by
16621@code{-fprofile-generate}. This makes it possible to rebuild program
16622with same outcome which is useful, for example, for distribution
16623packages.
16624
16625With @option{-fprofile-reproducible=serial} the profile gathered by
16626@option{-fprofile-generate} is reproducible provided the trained program
16627behaves the same at each invocation of the train run, it is not
16628multi-threaded and profile data streaming is always done in the same
16629order. Note that profile streaming happens at the end of program run but
16630also before @code{fork} function is invoked.
16631
16632Note that it is quite common that execution counts of some part of
16633programs depends, for example, on length of temporary file names or
16634memory space randomization (that may affect hash-table collision rate).
16635Such non-reproducible part of programs may be annotated by
16636@code{no_instrument_function} function attribute. @command{gcov-dump} with
16637@option{-l} can be used to dump gathered data and verify that they are
16638indeed reproducible.
16639
16640With @option{-fprofile-reproducible=parallel-runs} collected profile
16641stays reproducible regardless the order of streaming of the data into
16642gcda files. This setting makes it possible to run multiple instances of
16643instrumented program in parallel (such as with @code{make -j}). This
16644reduces quality of gathered data, in particular of indirect call
16645profiling.
16646
d77de738 16647@opindex fsanitize=address
ddf6fe37 16648@item -fsanitize=address
d77de738
ML
16649Enable AddressSanitizer, a fast memory error detector.
16650Memory access instructions are instrumented to detect
16651out-of-bounds and use-after-free bugs.
16652The option enables @option{-fsanitize-address-use-after-scope}.
16653See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16654more details. The run-time behavior can be influenced using the
16655@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16656the available options are shown at startup of the instrumented program. See
16657@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16658for a list of supported options.
16659The option cannot be combined with @option{-fsanitize=thread} or
16660@option{-fsanitize=hwaddress}. Note that the only target
16661@option{-fsanitize=hwaddress} is currently supported on is AArch64.
16662
6a07798c
MP
16663To get more accurate stack traces, it is possible to use options such as
16664@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
16665most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
16666optimizing sibling and tail recursive calls; this option is implicit for
16667@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
16668disables Identical Code Folding for functions). Since multiple runs of the
16669program may yield backtraces with different addresses due to ASLR (Address
16670Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
16671this can be achieved with @samp{setarch `uname -m` -R ./prog}.
16672
d77de738 16673@opindex fsanitize=kernel-address
f33d7a88 16674@item -fsanitize=kernel-address
d77de738 16675Enable AddressSanitizer for Linux kernel.
a0bf71be 16676See @uref{https://github.com/google/kernel-sanitizers} for more details.
d77de738 16677
d77de738 16678@opindex fsanitize=hwaddress
f33d7a88 16679@item -fsanitize=hwaddress
d77de738
ML
16680Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16681ignore the top byte of a pointer to allow the detection of memory errors with
16682a low memory overhead.
16683Memory access instructions are instrumented to detect out-of-bounds and
16684use-after-free bugs.
16685The option enables @option{-fsanitize-address-use-after-scope}.
16686See
16687@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
16688for more details. The run-time behavior can be influenced using the
16689@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
16690the available options are shown at startup of the instrumented program.
16691The option cannot be combined with @option{-fsanitize=thread} or
16692@option{-fsanitize=address}, and is currently only available on AArch64.
16693
d77de738 16694@opindex fsanitize=kernel-hwaddress
ddf6fe37 16695@item -fsanitize=kernel-hwaddress
d77de738
ML
16696Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
16697Similar to @option{-fsanitize=kernel-address} but using an alternate
16698instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
16699instrumentation differences necessary for compiling the Linux kernel.
16700These differences are to avoid hwasan library initialization calls and to
16701account for the stack pointer having a different value in its top byte.
16702
16703@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
16704Instrumenting the stack and alloca calls are not on by default but are still
16705possible by specifying the command-line options
16706@option{--param hwasan-instrument-stack=1} and
16707@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
16708tag is not implemented for kernel instrumentation.
16709
d77de738 16710@opindex fsanitize=pointer-compare
ddf6fe37 16711@item -fsanitize=pointer-compare
d77de738
ML
16712Instrument comparison operation (<, <=, >, >=) with pointer operands.
16713The option must be combined with either @option{-fsanitize=kernel-address} or
16714@option{-fsanitize=address}
16715The option cannot be combined with @option{-fsanitize=thread}.
16716Note: By default the check is disabled at run time. To enable it,
16717add @code{detect_invalid_pointer_pairs=2} to the environment variable
16718@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16719invalid operation only when both pointers are non-null.
16720
d77de738 16721@opindex fsanitize=pointer-subtract
ddf6fe37 16722@item -fsanitize=pointer-subtract
d77de738
ML
16723Instrument subtraction with pointer operands.
16724The option must be combined with either @option{-fsanitize=kernel-address} or
16725@option{-fsanitize=address}
16726The option cannot be combined with @option{-fsanitize=thread}.
16727Note: By default the check is disabled at run time. To enable it,
16728add @code{detect_invalid_pointer_pairs=2} to the environment variable
16729@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16730invalid operation only when both pointers are non-null.
16731
d77de738 16732@opindex fsanitize=shadow-call-stack
ddf6fe37 16733@item -fsanitize=shadow-call-stack
d77de738
ML
16734Enable ShadowCallStack, a security enhancement mechanism used to protect
16735programs against return address overwrites (e.g. stack buffer overflows.)
16736It works by saving a function's return address to a separately allocated
16737shadow call stack in the function prologue and restoring the return address
16738from the shadow call stack in the function epilogue. Instrumentation only
16739occurs in functions that need to save the return address to the stack.
16740
16741Currently it only supports the aarch64 platform. It is specifically
16742designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
16743For the user space programs, runtime support is not currently provided
16744in libc and libgcc. Users who want to use this feature in user space need
16745to provide their own support for the runtime. It should be noted that
16746this may cause the ABI rules to be broken.
16747
16748On aarch64, the instrumentation makes use of the platform register @code{x18}.
16749This generally means that any code that may run on the same thread as code
16750compiled with ShadowCallStack must be compiled with the flag
16751@option{-ffixed-x18}, otherwise functions compiled without
16752@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
16753stack pointer.
16754
16755Also, because there is no userspace runtime support, code compiled with
16756ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
16757to turn off exceptions.
16758
16759See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
16760details.
16761
d77de738 16762@opindex fsanitize=thread
ddf6fe37 16763@item -fsanitize=thread
d77de738
ML
16764Enable ThreadSanitizer, a fast data race detector.
16765Memory access instructions are instrumented to detect
16766data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
16767details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
16768environment variable; see
16769@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
16770supported options.
16771The option cannot be combined with @option{-fsanitize=address},
16772@option{-fsanitize=leak}.
16773
16774Note that sanitized atomic builtins cannot throw exceptions when
16775operating on invalid memory addresses with non-call exceptions
16776(@option{-fnon-call-exceptions}).
16777
d77de738 16778@opindex fsanitize=leak
ddf6fe37 16779@item -fsanitize=leak
d77de738 16780Enable LeakSanitizer, a memory leak detector.
c5c4fdac
JG
16781This option only matters for linking of executables.
16782The executable is linked against a library that overrides @code{malloc}
d77de738
ML
16783and other allocator functions. See
16784@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
16785details. The run-time behavior can be influenced using the
16786@env{LSAN_OPTIONS} environment variable.
16787The option cannot be combined with @option{-fsanitize=thread}.
16788
d77de738 16789@opindex fsanitize=undefined
ddf6fe37 16790@item -fsanitize=undefined
d77de738
ML
16791Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
16792Various computations are instrumented to detect undefined behavior
16793at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
16794@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
16795
16796@table @gcctabopt
16797
d77de738 16798@opindex fsanitize=shift
ddf6fe37 16799@item -fsanitize=shift
d77de738
ML
16800This option enables checking that the result of a shift operation is
16801not undefined. Note that what exactly is considered undefined differs
16802slightly between C and C++, as well as between ISO C90 and C99, etc.
16803This option has two suboptions, @option{-fsanitize=shift-base} and
16804@option{-fsanitize=shift-exponent}.
16805
d77de738 16806@opindex fsanitize=shift-exponent
ddf6fe37 16807@item -fsanitize=shift-exponent
d77de738
ML
16808This option enables checking that the second argument of a shift operation
16809is not negative and is smaller than the precision of the promoted first
16810argument.
16811
d77de738 16812@opindex fsanitize=shift-base
ddf6fe37 16813@item -fsanitize=shift-base
d77de738
ML
16814If the second argument of a shift operation is within range, check that the
16815result of a shift operation is not undefined. Note that what exactly is
16816considered undefined differs slightly between C and C++, as well as between
16817ISO C90 and C99, etc.
16818
d77de738 16819@opindex fsanitize=integer-divide-by-zero
ddf6fe37 16820@item -fsanitize=integer-divide-by-zero
d77de738
ML
16821Detect integer division by zero.
16822
d77de738 16823@opindex fsanitize=unreachable
ddf6fe37 16824@item -fsanitize=unreachable
d77de738
ML
16825With this option, the compiler turns the @code{__builtin_unreachable}
16826call into a diagnostics message call instead. When reaching the
16827@code{__builtin_unreachable} call, the behavior is undefined.
16828
d77de738 16829@opindex fsanitize=vla-bound
ddf6fe37 16830@item -fsanitize=vla-bound
d77de738
ML
16831This option instructs the compiler to check that the size of a variable
16832length array is positive.
16833
d77de738 16834@opindex fsanitize=null
ddf6fe37 16835@item -fsanitize=null
d77de738
ML
16836This option enables pointer checking. Particularly, the application
16837built with this option turned on will issue an error message when it
16838tries to dereference a NULL pointer, or if a reference (possibly an
16839rvalue reference) is bound to a NULL pointer, or if a method is invoked
16840on an object pointed by a NULL pointer.
16841
d77de738 16842@opindex fsanitize=return
ddf6fe37 16843@item -fsanitize=return
d77de738
ML
16844This option enables return statement checking. Programs
16845built with this option turned on will issue an error message
16846when the end of a non-void function is reached without actually
16847returning a value. This option works in C++ only.
16848
d77de738 16849@opindex fsanitize=signed-integer-overflow
ddf6fe37 16850@item -fsanitize=signed-integer-overflow
d77de738
ML
16851This option enables signed integer overflow checking. We check that
16852the result of @code{+}, @code{*}, and both unary and binary @code{-}
16853does not overflow in the signed arithmetics. This also detects
16854@code{INT_MIN / -1} signed division. Note, integer promotion
16855rules must be taken into account. That is, the following is not an
16856overflow:
16857@smallexample
16858signed char a = SCHAR_MAX;
16859a++;
16860@end smallexample
16861
d77de738 16862@opindex fsanitize=bounds
ddf6fe37 16863@item -fsanitize=bounds
d77de738
ML
16864This option enables instrumentation of array bounds. Various out of bounds
16865accesses are detected. Flexible array members, flexible array member-like
c7728805
JJ
16866arrays, and initializers of variables with static storage are not
16867instrumented, with the exception of flexible array member-like arrays
16868for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=}
16869options or @code{strict_flex_array} attributes say they shouldn't be treated
16870like flexible array member-like arrays.
d77de738 16871
d77de738 16872@opindex fsanitize=bounds-strict
ddf6fe37 16873@item -fsanitize=bounds-strict
d77de738 16874This option enables strict instrumentation of array bounds. Most out of bounds
c7728805
JJ
16875accesses are detected, including flexible array member-like arrays.
16876Initializers of variables with static storage are not instrumented.
d77de738 16877
d77de738 16878@opindex fsanitize=alignment
ddf6fe37 16879@item -fsanitize=alignment
d77de738
ML
16880
16881This option enables checking of alignment of pointers when they are
16882dereferenced, or when a reference is bound to insufficiently aligned target,
16883or when a method or constructor is invoked on insufficiently aligned object.
16884
d77de738 16885@opindex fsanitize=object-size
ddf6fe37 16886@item -fsanitize=object-size
d77de738 16887This option enables instrumentation of memory references using the
7283380a
SP
16888@code{__builtin_dynamic_object_size} function. Various out of bounds
16889pointer accesses are detected.
d77de738 16890
d77de738 16891@opindex fsanitize=float-divide-by-zero
ddf6fe37 16892@item -fsanitize=float-divide-by-zero
d77de738
ML
16893Detect floating-point division by zero. Unlike other similar options,
16894@option{-fsanitize=float-divide-by-zero} is not enabled by
16895@option{-fsanitize=undefined}, since floating-point division by zero can
16896be a legitimate way of obtaining infinities and NaNs.
16897
d77de738 16898@opindex fsanitize=float-cast-overflow
ddf6fe37 16899@item -fsanitize=float-cast-overflow
d77de738
ML
16900This option enables floating-point type to integer conversion checking.
16901We check that the result of the conversion does not overflow.
16902Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
16903not enabled by @option{-fsanitize=undefined}.
16904This option does not work well with @code{FE_INVALID} exceptions enabled.
16905
d77de738 16906@opindex fsanitize=nonnull-attribute
ddf6fe37 16907@item -fsanitize=nonnull-attribute
d77de738
ML
16908
16909This option enables instrumentation of calls, checking whether null values
16910are not passed to arguments marked as requiring a non-null value by the
16911@code{nonnull} function attribute.
16912
d77de738 16913@opindex fsanitize=returns-nonnull-attribute
ddf6fe37 16914@item -fsanitize=returns-nonnull-attribute
d77de738
ML
16915
16916This option enables instrumentation of return statements in functions
16917marked with @code{returns_nonnull} function attribute, to detect returning
16918of null values from such functions.
16919
d77de738 16920@opindex fsanitize=bool
ddf6fe37 16921@item -fsanitize=bool
d77de738
ML
16922
16923This option enables instrumentation of loads from bool. If a value other
16924than 0/1 is loaded, a run-time error is issued.
16925
d77de738 16926@opindex fsanitize=enum
ddf6fe37 16927@item -fsanitize=enum
d77de738
ML
16928
16929This option enables instrumentation of loads from an enum type. If
16930a value outside the range of values for the enum type is loaded,
16931a run-time error is issued.
16932
d77de738 16933@opindex fsanitize=vptr
ddf6fe37 16934@item -fsanitize=vptr
d77de738
ML
16935
16936This option enables instrumentation of C++ member function calls, member
16937accesses and some conversions between pointers to base and derived classes,
16938to verify the referenced object has the correct dynamic type.
16939
d77de738 16940@opindex fsanitize=pointer-overflow
ddf6fe37 16941@item -fsanitize=pointer-overflow
d77de738
ML
16942
16943This option enables instrumentation of pointer arithmetics. If the pointer
16944arithmetics overflows, a run-time error is issued.
16945
d77de738 16946@opindex fsanitize=builtin
ddf6fe37 16947@item -fsanitize=builtin
d77de738
ML
16948
16949This option enables instrumentation of arguments to selected builtin
16950functions. If an invalid value is passed to such arguments, a run-time
16951error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
16952or @code{__builtin_clz} invokes undefined behavior and is diagnosed
16953by this option.
16954
16955@end table
16956
16957Note that sanitizers tend to increase the rate of false positive
16958warnings, most notably those around @option{-Wmaybe-uninitialized}.
16959We recommend against combining @option{-Werror} and [the use of]
16960sanitizers.
16961
16962While @option{-ftrapv} causes traps for signed overflows to be emitted,
16963@option{-fsanitize=undefined} gives a diagnostic message.
16964This currently works only for the C family of languages.
16965
d77de738 16966@opindex fno-sanitize=all
ddf6fe37 16967@item -fno-sanitize=all
d77de738
ML
16968
16969This option disables all previously enabled sanitizers.
16970@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
16971together.
16972
d77de738 16973@opindex fasan-shadow-offset
ddf6fe37 16974@item -fasan-shadow-offset=@var{number}
d77de738
ML
16975This option forces GCC to use custom shadow offset in AddressSanitizer checks.
16976It is useful for experimenting with different shadow memory layouts in
16977Kernel AddressSanitizer.
16978
d77de738 16979@opindex fsanitize-sections
ddf6fe37 16980@item -fsanitize-sections=@var{s1},@var{s2},...
d77de738
ML
16981Sanitize global variables in selected user-defined sections. @var{si} may
16982contain wildcards.
16983
d77de738
ML
16984@opindex fsanitize-recover
16985@opindex fno-sanitize-recover
ddf6fe37 16986@item -fsanitize-recover@r{[}=@var{opts}@r{]}
d77de738
ML
16987@option{-fsanitize-recover=} controls error recovery mode for sanitizers
16988mentioned in comma-separated list of @var{opts}. Enabling this option
16989for a sanitizer component causes it to attempt to continue
16990running the program as if no error happened. This means multiple
16991runtime errors can be reported in a single program run, and the exit
16992code of the program may indicate success even when errors
16993have been reported. The @option{-fno-sanitize-recover=} option
16994can be used to alter
16995this behavior: only the first detected error is reported
16996and program then exits with a non-zero exit code.
16997
16998Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
16999except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
17000@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
17001@option{-fsanitize=bounds-strict},
17002@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
17003For these sanitizers error recovery is turned on by default,
17004except @option{-fsanitize=address}, for which this feature is experimental.
17005@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
17006accepted, the former enables recovery for all sanitizers that support it,
17007the latter disables recovery for all sanitizers that support it.
17008
17009Even if a recovery mode is turned on the compiler side, it needs to be also
17010enabled on the runtime library side, otherwise the failures are still fatal.
17011The runtime library defaults to @code{halt_on_error=0} for
17012ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
17013AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
17014setting the @code{halt_on_error} flag in the corresponding environment variable.
17015
17016Syntax without an explicit @var{opts} parameter is deprecated. It is
17017equivalent to specifying an @var{opts} list of:
17018
17019@smallexample
17020undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
17021@end smallexample
17022
d77de738 17023@opindex fsanitize-address-use-after-scope
ddf6fe37 17024@item -fsanitize-address-use-after-scope
d77de738
ML
17025Enable sanitization of local variables to detect use-after-scope bugs.
17026The option sets @option{-fstack-reuse} to @samp{none}.
17027
d77de738
ML
17028@opindex fsanitize-trap
17029@opindex fno-sanitize-trap
ddf6fe37 17030@item -fsanitize-trap@r{[}=@var{opts}@r{]}
d77de738
ML
17031The @option{-fsanitize-trap=} option instructs the compiler to
17032report for sanitizers mentioned in comma-separated list of @var{opts}
17033undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
17034library routine. If this option is enabled for certain sanitizer,
17035it takes precedence over the @option{-fsanitizer-recover=} for that
17036sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
17037of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
17038
17039The advantage of this is that the @code{libubsan} library is not needed
17040and is not linked in, so this is usable even in freestanding environments.
17041
17042Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
17043except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
17044@option{-fsanitize=float-divide-by-zero} and
17045@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
17046specified, which enables it for @code{undefined} suboptions,
17047@option{-fsanitize=float-cast-overflow},
17048@option{-fsanitize=float-divide-by-zero} and
17049@option{-fsanitize=bounds-strict}.
17050If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
17051and @code{-fsanitize=vptr} is enabled on the command line, the
17052instrumentation is silently ignored as the instrumentation always needs
17053@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
17054
d77de738 17055@opindex fsanitize-undefined-trap-on-error
ddf6fe37 17056@item -fsanitize-undefined-trap-on-error
d77de738
ML
17057The @option{-fsanitize-undefined-trap-on-error} option is deprecated
17058equivalent of @option{-fsanitize-trap=all}.
17059
d77de738 17060@opindex fsanitize-coverage=trace-pc
ddf6fe37 17061@item -fsanitize-coverage=trace-pc
d77de738
ML
17062Enable coverage-guided fuzzing code instrumentation.
17063Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
17064
d77de738 17065@opindex fsanitize-coverage=trace-cmp
ddf6fe37 17066@item -fsanitize-coverage=trace-cmp
d77de738
ML
17067Enable dataflow guided fuzzing code instrumentation.
17068Inserts a call to @code{__sanitizer_cov_trace_cmp1},
17069@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
17070@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
17071variable or @code{__sanitizer_cov_trace_const_cmp1},
17072@code{__sanitizer_cov_trace_const_cmp2},
17073@code{__sanitizer_cov_trace_const_cmp4} or
17074@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
17075operand constant, @code{__sanitizer_cov_trace_cmpf} or
17076@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
17077@code{__sanitizer_cov_trace_switch} for switch statements.
17078
d77de738 17079@opindex fcf-protection
ddf6fe37 17080@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
d77de738
ML
17081Enable code instrumentation of control-flow transfers to increase
17082program security by checking that target addresses of control-flow
17083transfer instructions (such as indirect function call, function return,
17084indirect jump) are valid. This prevents diverting the flow of control
17085to an unexpected target. This is intended to protect against such
17086threats as Return-oriented Programming (ROP), and similarly
17087call/jmp-oriented programming (COP/JOP).
17088
17089The value @code{branch} tells the compiler to implement checking of
17090validity of control-flow transfer at the point of indirect branch
17091instructions, i.e.@: call/jmp instructions. The value @code{return}
17092implements checking of validity at the point of returning from a
17093function. The value @code{full} is an alias for specifying both
17094@code{branch} and @code{return}. The value @code{none} turns off
17095instrumentation.
17096
17097The value @code{check} is used for the final link with link-time
17098optimization (LTO). An error is issued if LTO object files are
17099compiled with different @option{-fcf-protection} values. The
17100value @code{check} is ignored at the compile time.
17101
17102The macro @code{__CET__} is defined when @option{-fcf-protection} is
17103used. The first bit of @code{__CET__} is set to 1 for the value
17104@code{branch} and the second bit of @code{__CET__} is set to 1 for
17105the @code{return}.
17106
17107You can also use the @code{nocf_check} attribute to identify
17108which functions and calls should be skipped from instrumentation
17109(@pxref{Function Attributes}).
17110
17111Currently the x86 GNU/Linux target provides an implementation based
17112on Intel Control-flow Enforcement Technology (CET) which works for
17113i686 processor or newer.
17114
d77de738 17115@opindex fharden-compares
ddf6fe37 17116@item -fharden-compares
d77de738
ML
17117For every logical test that survives gimple optimizations and is
17118@emph{not} the condition in a conditional branch (for example,
17119conditions tested for conditional moves, or to store in boolean
17120variables), emit extra code to compute and verify the reversed
17121condition, and to call @code{__builtin_trap} if the results do not
17122match. Use with @samp{-fharden-conditional-branches} to cover all
17123conditionals.
17124
d77de738 17125@opindex fharden-conditional-branches
ddf6fe37 17126@item -fharden-conditional-branches
d77de738
ML
17127For every non-vectorized conditional branch that survives gimple
17128optimizations, emit extra code to compute and verify the reversed
17129condition, and to call @code{__builtin_trap} if the result is
17130unexpected. Use with @samp{-fharden-compares} to cover all
17131conditionals.
17132
d77de738 17133@opindex fstack-protector
ddf6fe37 17134@item -fstack-protector
d77de738
ML
17135Emit extra code to check for buffer overflows, such as stack smashing
17136attacks. This is done by adding a guard variable to functions with
17137vulnerable objects. This includes functions that call @code{alloca}, and
17138functions with buffers larger than or equal to 8 bytes. The guards are
17139initialized when a function is entered and then checked when the function
17140exits. If a guard check fails, an error message is printed and the program
17141exits. Only variables that are actually allocated on the stack are
17142considered, optimized away variables or variables allocated in registers
17143don't count.
17144
d77de738 17145@opindex fstack-protector-all
ddf6fe37 17146@item -fstack-protector-all
d77de738
ML
17147Like @option{-fstack-protector} except that all functions are protected.
17148
d77de738 17149@opindex fstack-protector-strong
ddf6fe37 17150@item -fstack-protector-strong
d77de738
ML
17151Like @option{-fstack-protector} but includes additional functions to
17152be protected --- those that have local array definitions, or have
17153references to local frame addresses. Only variables that are actually
17154allocated on the stack are considered, optimized away variables or variables
17155allocated in registers don't count.
17156
d77de738 17157@opindex fstack-protector-explicit
ddf6fe37 17158@item -fstack-protector-explicit
d77de738
ML
17159Like @option{-fstack-protector} but only protects those functions which
17160have the @code{stack_protect} attribute.
17161
d77de738 17162@opindex fstack-check
ddf6fe37 17163@item -fstack-check
d77de738
ML
17164Generate code to verify that you do not go beyond the boundary of the
17165stack. You should specify this flag if you are running in an
17166environment with multiple threads, but you only rarely need to specify it in
17167a single-threaded environment since stack overflow is automatically
17168detected on nearly all systems if there is only one stack.
17169
17170Note that this switch does not actually cause checking to be done; the
17171operating system or the language runtime must do that. The switch causes
17172generation of code to ensure that they see the stack being extended.
17173
17174You can additionally specify a string parameter: @samp{no} means no
17175checking, @samp{generic} means force the use of old-style checking,
17176@samp{specific} means use the best checking method and is equivalent
17177to bare @option{-fstack-check}.
17178
17179Old-style checking is a generic mechanism that requires no specific
17180target support in the compiler but comes with the following drawbacks:
17181
17182@enumerate
17183@item
17184Modified allocation strategy for large objects: they are always
17185allocated dynamically if their size exceeds a fixed threshold. Note this
17186may change the semantics of some code.
17187
17188@item
17189Fixed limit on the size of the static frame of functions: when it is
17190topped by a particular function, stack checking is not reliable and
17191a warning is issued by the compiler.
17192
17193@item
17194Inefficiency: because of both the modified allocation strategy and the
17195generic implementation, code performance is hampered.
17196@end enumerate
17197
17198Note that old-style stack checking is also the fallback method for
17199@samp{specific} if no target support has been added in the compiler.
17200
17201@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17202and stack overflows. @samp{specific} is an excellent choice when compiling
17203Ada code. It is not generally sufficient to protect against stack-clash
17204attacks. To protect against those you want @samp{-fstack-clash-protection}.
17205
d77de738 17206@opindex fstack-clash-protection
ddf6fe37 17207@item -fstack-clash-protection
d77de738
ML
17208Generate code to prevent stack clash style attacks. When this option is
17209enabled, the compiler will only allocate one page of stack space at a time
17210and each page is accessed immediately after allocation. Thus, it prevents
17211allocations from jumping over any stack guard page provided by the
17212operating system.
17213
17214Most targets do not fully support stack clash protection. However, on
17215those targets @option{-fstack-clash-protection} will protect dynamic stack
17216allocations. @option{-fstack-clash-protection} may also provide limited
17217protection for static stack allocations if the target supports
17218@option{-fstack-check=specific}.
17219
d77de738
ML
17220@opindex fstack-limit-register
17221@opindex fstack-limit-symbol
17222@opindex fno-stack-limit
ddf6fe37
AA
17223@item -fstack-limit-register=@var{reg}
17224@itemx -fstack-limit-symbol=@var{sym}
17225@itemx -fno-stack-limit
d77de738
ML
17226Generate code to ensure that the stack does not grow beyond a certain value,
17227either the value of a register or the address of a symbol. If a larger
17228stack is required, a signal is raised at run time. For most targets,
17229the signal is raised before the stack overruns the boundary, so
17230it is possible to catch the signal without taking special precautions.
17231
17232For instance, if the stack starts at absolute address @samp{0x80000000}
17233and grows downwards, you can use the flags
17234@option{-fstack-limit-symbol=__stack_limit} and
17235@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17236of 128KB@. Note that this may only work with the GNU linker.
17237
17238You can locally override stack limit checking by using the
17239@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17240
d77de738 17241@opindex fsplit-stack
ddf6fe37 17242@item -fsplit-stack
d77de738
ML
17243Generate code to automatically split the stack before it overflows.
17244The resulting program has a discontiguous stack which can only
17245overflow if the program is unable to allocate any more memory. This
17246is most useful when running threaded programs, as it is no longer
17247necessary to calculate a good stack size to use for each thread. This
17248is currently only implemented for the x86 targets running
17249GNU/Linux.
17250
17251When code compiled with @option{-fsplit-stack} calls code compiled
17252without @option{-fsplit-stack}, there may not be much stack space
17253available for the latter code to run. If compiling all code,
17254including library code, with @option{-fsplit-stack} is not an option,
17255then the linker can fix up these calls so that the code compiled
17256without @option{-fsplit-stack} always has a large stack. Support for
17257this is implemented in the gold linker in GNU binutils release 2.21
17258and later.
17259
d77de738 17260@opindex fvtable-verify
ddf6fe37 17261@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
d77de738
ML
17262This option is only available when compiling C++ code.
17263It turns on (or off, if using @option{-fvtable-verify=none}) the security
17264feature that verifies at run time, for every virtual call, that
17265the vtable pointer through which the call is made is valid for the type of
17266the object, and has not been corrupted or overwritten. If an invalid vtable
17267pointer is detected at run time, an error is reported and execution of the
17268program is immediately halted.
17269
17270This option causes run-time data structures to be built at program startup,
17271which are used for verifying the vtable pointers.
17272The options @samp{std} and @samp{preinit}
17273control the timing of when these data structures are built. In both cases the
17274data structures are built before execution reaches @code{main}. Using
17275@option{-fvtable-verify=std} causes the data structures to be built after
17276shared libraries have been loaded and initialized.
17277@option{-fvtable-verify=preinit} causes them to be built before shared
17278libraries have been loaded and initialized.
17279
17280If this option appears multiple times in the command line with different
17281values specified, @samp{none} takes highest priority over both @samp{std} and
17282@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17283
d77de738 17284@opindex fvtv-debug
ddf6fe37 17285@item -fvtv-debug
d77de738
ML
17286When used in conjunction with @option{-fvtable-verify=std} or
17287@option{-fvtable-verify=preinit}, causes debug versions of the
17288runtime functions for the vtable verification feature to be called.
17289This flag also causes the compiler to log information about which
17290vtable pointers it finds for each class.
17291This information is written to a file named @file{vtv_set_ptr_data.log}
17292in the directory named by the environment variable @env{VTV_LOGS_DIR}
17293if that is defined or the current working directory otherwise.
17294
17295Note: This feature @emph{appends} data to the log file. If you want a fresh log
17296file, be sure to delete any existing one.
17297
d77de738 17298@opindex fvtv-counts
ddf6fe37 17299@item -fvtv-counts
d77de738
ML
17300This is a debugging flag. When used in conjunction with
17301@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17302causes the compiler to keep track of the total number of virtual calls
17303it encounters and the number of verifications it inserts. It also
17304counts the number of calls to certain run-time library functions
17305that it inserts and logs this information for each compilation unit.
17306The compiler writes this information to a file named
17307@file{vtv_count_data.log} in the directory named by the environment
17308variable @env{VTV_LOGS_DIR} if that is defined or the current working
17309directory otherwise. It also counts the size of the vtable pointer sets
17310for each class, and writes this information to @file{vtv_class_set_sizes.log}
17311in the same directory.
17312
17313Note: This feature @emph{appends} data to the log files. To get fresh log
17314files, be sure to delete any existing ones.
17315
d77de738 17316@opindex finstrument-functions
ddf6fe37 17317@item -finstrument-functions
d77de738
ML
17318Generate instrumentation calls for entry and exit to functions. Just
17319after function entry and just before function exit, the following
17320profiling functions are called with the address of the current
17321function and its call site. (On some platforms,
17322@code{__builtin_return_address} does not work beyond the current
17323function, so the call site information may not be available to the
17324profiling functions otherwise.)
17325
17326@smallexample
17327void __cyg_profile_func_enter (void *this_fn,
17328 void *call_site);
17329void __cyg_profile_func_exit (void *this_fn,
17330 void *call_site);
17331@end smallexample
17332
17333The first argument is the address of the start of the current function,
17334which may be looked up exactly in the symbol table.
17335
17336This instrumentation is also done for functions expanded inline in other
17337functions. The profiling calls indicate where, conceptually, the
17338inline function is entered and exited. This means that addressable
17339versions of such functions must be available. If all your uses of a
17340function are expanded inline, this may mean an additional expansion of
17341code size. If you use @code{extern inline} in your C code, an
17342addressable version of such functions must be provided. (This is
17343normally the case anyway, but if you get lucky and the optimizer always
17344expands the functions inline, you might have gotten away without
17345providing static copies.)
17346
17347A function may be given the attribute @code{no_instrument_function}, in
17348which case this instrumentation is not done. This can be used, for
17349example, for the profiling functions listed above, high-priority
17350interrupt routines, and any functions from which the profiling functions
17351cannot safely be called (perhaps signal handlers, if the profiling
17352routines generate output or allocate memory).
17353@xref{Common Function Attributes}.
17354
9c19597c 17355@opindex finstrument-functions-once
ddf6fe37 17356@item -finstrument-functions-once
d77de738
ML
17357This is similar to @option{-finstrument-functions}, but the profiling
17358functions are called only once per instrumented function, i.e. the first
17359profiling function is called after the first entry into the instrumented
17360function and the second profiling function is called before the exit
17361corresponding to this first entry.
17362
17363The definition of @code{once} for the purpose of this option is a little
17364vague because the implementation is not protected against data races.
17365As a result, the implementation only guarantees that the profiling
17366functions are called at @emph{least} once per process and at @emph{most}
17367once per thread, but the calls are always paired, that is to say, if a
17368thread calls the first function, then it will call the second function,
17369unless it never reaches the exit of the instrumented function.
17370
d77de738 17371@opindex finstrument-functions-exclude-file-list
ddf6fe37 17372@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
d77de738
ML
17373
17374Set the list of functions that are excluded from instrumentation (see
17375the description of @option{-finstrument-functions}). If the file that
17376contains a function definition matches with one of @var{file}, then
17377that function is not instrumented. The match is done on substrings:
17378if the @var{file} parameter is a substring of the file name, it is
17379considered to be a match.
17380
17381For example:
17382
17383@smallexample
17384-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17385@end smallexample
17386
17387@noindent
17388excludes any inline function defined in files whose pathnames
17389contain @file{/bits/stl} or @file{include/sys}.
17390
17391If, for some reason, you want to include letter @samp{,} in one of
17392@var{sym}, write @samp{\,}. For example,
17393@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17394(note the single quote surrounding the option).
17395
d77de738 17396@opindex finstrument-functions-exclude-function-list
ddf6fe37 17397@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
d77de738
ML
17398
17399This is similar to @option{-finstrument-functions-exclude-file-list},
17400but this option sets the list of function names to be excluded from
17401instrumentation. The function name to be matched is its user-visible
17402name, such as @code{vector<int> blah(const vector<int> &)}, not the
17403internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17404match is done on substrings: if the @var{sym} parameter is a substring
17405of the function name, it is considered to be a match. For C99 and C++
17406extended identifiers, the function name must be given in UTF-8, not
17407using universal character names.
17408
d77de738 17409@opindex fpatchable-function-entry
ddf6fe37 17410@item -fpatchable-function-entry=@var{N}[,@var{M}]
d77de738
ML
17411Generate @var{N} NOPs right at the beginning
17412of each function, with the function entry point before the @var{M}th NOP.
17413If @var{M} is omitted, it defaults to @code{0} so the
17414function entry points to the address just at the first NOP.
17415The NOP instructions reserve extra space which can be used to patch in
17416any desired instrumentation at run time, provided that the code segment
17417is writable. The amount of space is controllable indirectly via
17418the number of NOPs; the NOP instruction used corresponds to the instruction
17419emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17420is target-specific and may also depend on the architecture variant and/or
17421other compilation options.
17422
17423For run-time identification, the starting addresses of these areas,
17424which correspond to their respective function entries minus @var{M},
17425are additionally collected in the @code{__patchable_function_entries}
17426section of the resulting binary.
17427
17428Note that the value of @code{__attribute__ ((patchable_function_entry
17429(N,M)))} takes precedence over command-line option
17430@option{-fpatchable-function-entry=N,M}. This can be used to increase
17431the area size or to remove it completely on a single function.
17432If @code{N=0}, no pad location is recorded.
17433
17434The NOP instructions are inserted at---and maybe before, depending on
17435@var{M}---the function entry address, even before the prologue. On
17436PowerPC with the ELFv2 ABI, for a function with dual entry points,
17437the local entry point is this function entry address.
17438
17439The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17440ELFv2 ABI, for a function with dual entry points, the supported values
17441for @var{M} are 0, 2, 6 and 14.
17442@end table
17443
17444
17445@node Preprocessor Options
17446@section Options Controlling the Preprocessor
17447@cindex preprocessor options
17448@cindex options, preprocessor
17449
17450These options control the C preprocessor, which is run on each C source
17451file before actual compilation.
17452
17453If you use the @option{-E} option, nothing is done except preprocessing.
17454Some of these options make sense only together with @option{-E} because
17455they cause the preprocessor output to be unsuitable for actual
17456compilation.
17457
17458In addition to the options listed here, there are a number of options
17459to control search paths for include files documented in
17460@ref{Directory Options}.
17461Options to control preprocessor diagnostics are listed in
17462@ref{Warning Options}.
17463
17464@table @gcctabopt
17465@include cppopts.texi
17466
d77de738 17467@opindex Wp
ddf6fe37 17468@item -Wp,@var{option}
d77de738
ML
17469You can use @option{-Wp,@var{option}} to bypass the compiler driver
17470and pass @var{option} directly through to the preprocessor. If
17471@var{option} contains commas, it is split into multiple options at the
17472commas. However, many options are modified, translated or interpreted
17473by the compiler driver before being passed to the preprocessor, and
17474@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17475interface is undocumented and subject to change, so whenever possible
17476you should avoid using @option{-Wp} and let the driver handle the
17477options instead.
17478
d77de738 17479@opindex Xpreprocessor
ddf6fe37 17480@item -Xpreprocessor @var{option}
d77de738
ML
17481Pass @var{option} as an option to the preprocessor. You can use this to
17482supply system-specific preprocessor options that GCC does not
17483recognize.
17484
17485If you want to pass an option that takes an argument, you must use
17486@option{-Xpreprocessor} twice, once for the option and once for the argument.
17487
d77de738 17488@opindex no-integrated-cpp
ddf6fe37 17489@item -no-integrated-cpp
d77de738
ML
17490Perform preprocessing as a separate pass before compilation.
17491By default, GCC performs preprocessing as an integrated part of
17492input tokenization and parsing.
17493If this option is provided, the appropriate language front end
17494(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17495and Objective-C, respectively) is instead invoked twice,
17496once for preprocessing only and once for actual compilation
17497of the preprocessed input.
17498This option may be useful in conjunction with the @option{-B} or
17499@option{-wrapper} options to specify an alternate preprocessor or
17500perform additional processing of the program source between
17501normal preprocessing and compilation.
17502
d77de738 17503@opindex flarge-source-files
ddf6fe37 17504@item -flarge-source-files
d77de738
ML
17505Adjust GCC to expect large source files, at the expense of slower
17506compilation and higher memory usage.
17507
17508Specifically, GCC normally tracks both column numbers and line numbers
17509within source files and it normally prints both of these numbers in
17510diagnostics. However, once it has processed a certain number of source
17511lines, it stops tracking column numbers and only tracks line numbers.
17512This means that diagnostics for later lines do not include column numbers.
17513It also means that options like @option{-Wmisleading-indentation} cease to work
17514at that point, although the compiler prints a note if this happens.
17515Passing @option{-flarge-source-files} significantly increases the number
17516of source lines that GCC can process before it stops tracking columns.
17517
17518@end table
17519
17520@node Assembler Options
17521@section Passing Options to the Assembler
17522
17523@c prevent bad page break with this line
17524You can pass options to the assembler.
17525
17526@table @gcctabopt
d77de738 17527@opindex Wa
ddf6fe37 17528@item -Wa,@var{option}
d77de738
ML
17529Pass @var{option} as an option to the assembler. If @var{option}
17530contains commas, it is split into multiple options at the commas.
17531
d77de738 17532@opindex Xassembler
ddf6fe37 17533@item -Xassembler @var{option}
d77de738
ML
17534Pass @var{option} as an option to the assembler. You can use this to
17535supply system-specific assembler options that GCC does not
17536recognize.
17537
17538If you want to pass an option that takes an argument, you must use
17539@option{-Xassembler} twice, once for the option and once for the argument.
17540
17541@end table
17542
17543@node Link Options
17544@section Options for Linking
17545@cindex link options
17546@cindex options, linking
17547
17548These options come into play when the compiler links object files into
17549an executable output file. They are meaningless if the compiler is
17550not doing a link step.
17551
17552@table @gcctabopt
17553@cindex file names
17554@item @var{object-file-name}
17555A file name that does not end in a special recognized suffix is
17556considered to name an object file or library. (Object files are
17557distinguished from libraries by the linker according to the file
17558contents.) If linking is done, these object files are used as input
17559to the linker.
17560
d77de738
ML
17561@opindex c
17562@opindex S
17563@opindex E
ddf6fe37
AA
17564@item -c
17565@itemx -S
17566@itemx -E
d77de738
ML
17567If any of these options is used, then the linker is not run, and
17568object file names should not be used as arguments. @xref{Overall
17569Options}.
17570
d77de738 17571@opindex flinker-output
ddf6fe37 17572@item -flinker-output=@var{type}
d77de738
ML
17573This option controls code generation of the link-time optimizer. By
17574default the linker output is automatically determined by the linker
17575plugin. For debugging the compiler and if incremental linking with a
17576non-LTO object file is desired, it may be useful to control the type
17577manually.
17578
17579If @var{type} is @samp{exec}, code generation produces a static
17580binary. In this case @option{-fpic} and @option{-fpie} are both
17581disabled.
17582
17583If @var{type} is @samp{dyn}, code generation produces a shared
17584library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17585but not enabled automatically. This allows to build shared libraries
17586without position-independent code on architectures where this is
17587possible, i.e.@: on x86.
17588
17589If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17590executable. This results in similar optimizations as @samp{exec}
17591except that @option{-fpie} is not disabled if specified at compilation
17592time.
17593
17594If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17595done. The sections containing intermediate code for link-time optimization are
17596merged, pre-optimized, and output to the resulting object file. In addition, if
17597@option{-ffat-lto-objects} is specified, binary code is produced for future
17598non-LTO linking. The object file produced by incremental linking is smaller
17599than a static library produced from the same object files. At link time the
17600result of incremental linking also loads faster than a static
17601library assuming that the majority of objects in the library are used.
17602
17603Finally @samp{nolto-rel} configures the compiler for incremental linking where
17604code generation is forced, a final binary is produced, and the intermediate
17605code for later link-time optimization is stripped. When multiple object files
17606are linked together the resulting code is better optimized than with
17607link-time optimizations disabled (for example, cross-module inlining
17608happens), but most of benefits of whole program optimizations are lost.
17609
17610During the incremental link (by @option{-r}) the linker plugin defaults to
17611@option{rel}. With current interfaces to GNU Binutils it is however not
17612possible to incrementally link LTO objects and non-LTO objects into a single
17613mixed object file. If any of object files in incremental link cannot
17614be used for link-time optimization, the linker plugin issues a warning and
17615uses @samp{nolto-rel}. To maintain whole program optimization, it is
17616recommended to link such objects into static library instead. Alternatively it
17617is possible to use H.J. Lu's binutils with support for mixed objects.
17618
d77de738 17619@opindex fuse-ld=bfd
ddf6fe37 17620@item -fuse-ld=bfd
d77de738
ML
17621Use the @command{bfd} linker instead of the default linker.
17622
d77de738 17623@opindex fuse-ld=gold
ddf6fe37 17624@item -fuse-ld=gold
d77de738
ML
17625Use the @command{gold} linker instead of the default linker.
17626
d77de738 17627@opindex fuse-ld=lld
ddf6fe37 17628@item -fuse-ld=lld
d77de738
ML
17629Use the LLVM @command{lld} linker instead of the default linker.
17630
d77de738 17631@opindex fuse-ld=mold
ddf6fe37 17632@item -fuse-ld=mold
d77de738
ML
17633Use the Modern Linker (@command{mold}) instead of the default linker.
17634
17635@cindex Libraries
ddf6fe37 17636@opindex l
d77de738
ML
17637@item -l@var{library}
17638@itemx -l @var{library}
d77de738
ML
17639Search the library named @var{library} when linking. (The second
17640alternative with the library as a separate argument is only for
17641POSIX compliance and is not recommended.)
17642
17643The @option{-l} option is passed directly to the linker by GCC. Refer
17644to your linker documentation for exact details. The general
17645description below applies to the GNU linker.
17646
17647The linker searches a standard list of directories for the library.
17648The directories searched include several standard system directories
17649plus any that you specify with @option{-L}.
17650
17651Static libraries are archives of object files, and have file names
17652like @file{lib@var{library}.a}. Some targets also support shared
17653libraries, which typically have names like @file{lib@var{library}.so}.
17654If both static and shared libraries are found, the linker gives
17655preference to linking with the shared library unless the
17656@option{-static} option is used.
17657
17658It makes a difference where in the command you write this option; the
17659linker searches and processes libraries and object files in the order they
17660are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17661after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17662to functions in @samp{z}, those functions may not be loaded.
17663
d77de738 17664@opindex lobjc
ddf6fe37 17665@item -lobjc
d77de738
ML
17666You need this special case of the @option{-l} option in order to
17667link an Objective-C or Objective-C++ program.
17668
d77de738 17669@opindex nostartfiles
ddf6fe37 17670@item -nostartfiles
d77de738
ML
17671Do not use the standard system startup files when linking.
17672The standard system libraries are used normally, unless @option{-nostdlib},
17673@option{-nolibc}, or @option{-nodefaultlibs} is used.
17674
d77de738 17675@opindex nodefaultlibs
ddf6fe37 17676@item -nodefaultlibs
d77de738
ML
17677Do not use the standard system libraries when linking.
17678Only the libraries you specify are passed to the linker, and options
17679specifying linkage of the system libraries, such as @option{-static-libgcc}
17680or @option{-shared-libgcc}, are ignored.
17681The standard startup files are used normally, unless @option{-nostartfiles}
17682is used.
17683
17684The compiler may generate calls to @code{memcmp},
17685@code{memset}, @code{memcpy} and @code{memmove}.
17686These entries are usually resolved by entries in
17687libc. These entry points should be supplied through some other
17688mechanism when this option is specified.
17689
d77de738 17690@opindex nolibc
ddf6fe37 17691@item -nolibc
d77de738
ML
17692Do not use the C library or system libraries tightly coupled with it when
17693linking. Still link with the startup files, @file{libgcc} or toolchain
17694provided language support libraries such as @file{libgnat}, @file{libgfortran}
17695or @file{libstdc++} unless options preventing their inclusion are used as
17696well. This typically removes @option{-lc} from the link command line, as well
17697as system libraries that normally go with it and become meaningless when
17698absence of a C library is assumed, for example @option{-lpthread} or
17699@option{-lm} in some configurations. This is intended for bare-board
17700targets when there is indeed no C library available.
17701
d77de738 17702@opindex nostdlib
ddf6fe37 17703@item -nostdlib
d77de738
ML
17704Do not use the standard system startup files or libraries when linking.
17705No startup files and only the libraries you specify are passed to
17706the linker, and options specifying linkage of the system libraries, such as
17707@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
17708
17709The compiler may generate calls to @code{memcmp}, @code{memset},
17710@code{memcpy} and @code{memmove}.
17711These entries are usually resolved by entries in
17712libc. These entry points should be supplied through some other
17713mechanism when this option is specified.
17714
17715@cindex @option{-lgcc}, use with @option{-nostdlib}
17716@cindex @option{-nostdlib} and unresolved references
17717@cindex unresolved references and @option{-nostdlib}
17718@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
17719@cindex @option{-nodefaultlibs} and unresolved references
17720@cindex unresolved references and @option{-nodefaultlibs}
17721One of the standard libraries bypassed by @option{-nostdlib} and
17722@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
17723which GCC uses to overcome shortcomings of particular machines, or special
17724needs for some languages.
17725(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
17726Collection (GCC) Internals},
17727for more discussion of @file{libgcc.a}.)
17728In most cases, you need @file{libgcc.a} even when you want to avoid
17729other standard libraries. In other words, when you specify @option{-nostdlib}
17730or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
17731This ensures that you have no unresolved references to internal GCC
17732library subroutines.
17733(An example of such an internal subroutine is @code{__main}, used to ensure C++
17734constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
17735GNU Compiler Collection (GCC) Internals}.)
17736
d77de738 17737@opindex nostdlib++
ddf6fe37 17738@item -nostdlib++
d77de738
ML
17739Do not implicitly link with standard C++ libraries.
17740
d77de738
ML
17741@opindex e
17742@opindex entry
ddf6fe37
AA
17743@item -e @var{entry}
17744@itemx --entry=@var{entry}
d77de738
ML
17745
17746Specify that the program entry point is @var{entry}. The argument is
17747interpreted by the linker; the GNU linker accepts either a symbol name
17748or an address.
17749
d77de738 17750@opindex pie
ddf6fe37 17751@item -pie
d77de738
ML
17752Produce a dynamically linked position independent executable on targets
17753that support it. For predictable results, you must also specify the same
17754set of options used for compilation (@option{-fpie}, @option{-fPIE},
17755or model suboptions) when you specify this linker option.
17756
d77de738 17757@opindex no-pie
ddf6fe37 17758@item -no-pie
d77de738
ML
17759Don't produce a dynamically linked position independent executable.
17760
d77de738 17761@opindex static-pie
ddf6fe37 17762@item -static-pie
d77de738
ML
17763Produce a static position independent executable on targets that support
17764it. A static position independent executable is similar to a static
17765executable, but can be loaded at any address without a dynamic linker.
17766For predictable results, you must also specify the same set of options
17767used for compilation (@option{-fpie}, @option{-fPIE}, or model
17768suboptions) when you specify this linker option.
17769
d77de738 17770@opindex pthread
ddf6fe37 17771@item -pthread
d77de738
ML
17772Link with the POSIX threads library. This option is supported on
17773GNU/Linux targets, most other Unix derivatives, and also on
17774x86 Cygwin and MinGW targets. On some targets this option also sets
17775flags for the preprocessor, so it should be used consistently for both
17776compilation and linking.
17777
d77de738 17778@opindex r
ddf6fe37 17779@item -r
d77de738
ML
17780Produce a relocatable object as output. This is also known as partial
17781linking.
17782
d77de738 17783@opindex rdynamic
ddf6fe37 17784@item -rdynamic
d77de738
ML
17785Pass the flag @option{-export-dynamic} to the ELF linker, on targets
17786that support it. This instructs the linker to add all symbols, not
17787only used ones, to the dynamic symbol table. This option is needed
17788for some uses of @code{dlopen} or to allow obtaining backtraces
17789from within a program.
17790
d77de738 17791@opindex s
ddf6fe37 17792@item -s
d77de738
ML
17793Remove all symbol table and relocation information from the executable.
17794
d77de738 17795@opindex static
ddf6fe37 17796@item -static
d77de738
ML
17797On systems that support dynamic linking, this overrides @option{-pie}
17798and prevents linking with the shared libraries. On other systems, this
17799option has no effect.
17800
d77de738 17801@opindex shared
ddf6fe37 17802@item -shared
d77de738
ML
17803Produce a shared object which can then be linked with other objects to
17804form an executable. Not all systems support this option. For predictable
17805results, you must also specify the same set of options used for compilation
17806(@option{-fpic}, @option{-fPIC}, or model suboptions) when
17807you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
17808needs to build supplementary stub code for constructors to work. On
17809multi-libbed systems, @samp{gcc -shared} must select the correct support
17810libraries to link against. Failing to supply the correct flags may lead
17811to subtle defects. Supplying them in cases where they are not necessary
b799acef
RB
17812is innocuous. @option{-shared} suppresses the addition of startup code
17813to alter the floating-point environment as done with @option{-ffast-math},
17814@option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.}
d77de738 17815
d77de738
ML
17816@opindex shared-libgcc
17817@opindex static-libgcc
ddf6fe37
AA
17818@item -shared-libgcc
17819@itemx -static-libgcc
d77de738
ML
17820On systems that provide @file{libgcc} as a shared library, these options
17821force the use of either the shared or static version, respectively.
17822If no shared version of @file{libgcc} was built when the compiler was
17823configured, these options have no effect.
17824
17825There are several situations in which an application should use the
17826shared @file{libgcc} instead of the static version. The most common
17827of these is when the application wishes to throw and catch exceptions
17828across different shared libraries. In that case, each of the libraries
17829as well as the application itself should use the shared @file{libgcc}.
17830
17831Therefore, the G++ driver automatically adds @option{-shared-libgcc}
17832whenever you build a shared library or a main executable, because C++
17833programs typically use exceptions, so this is the right thing to do.
17834
17835If, instead, you use the GCC driver to create shared libraries, you may
17836find that they are not always linked with the shared @file{libgcc}.
17837If GCC finds, at its configuration time, that you have a non-GNU linker
17838or a GNU linker that does not support option @option{--eh-frame-hdr},
17839it links the shared version of @file{libgcc} into shared libraries
17840by default. Otherwise, it takes advantage of the linker and optimizes
17841away the linking with the shared version of @file{libgcc}, linking with
17842the static version of libgcc by default. This allows exceptions to
17843propagate through such shared libraries, without incurring relocation
17844costs at library load time.
17845
17846However, if a library or main executable is supposed to throw or catch
17847exceptions, you must link it using the G++ driver, or using the option
17848@option{-shared-libgcc}, such that it is linked with the shared
17849@file{libgcc}.
17850
d77de738 17851@opindex static-libasan
ddf6fe37 17852@item -static-libasan
d77de738
ML
17853When the @option{-fsanitize=address} option is used to link a program,
17854the GCC driver automatically links against @option{libasan}. If
17855@file{libasan} is available as a shared library, and the @option{-static}
17856option is not used, then this links against the shared version of
17857@file{libasan}. The @option{-static-libasan} option directs the GCC
17858driver to link @file{libasan} statically, without necessarily linking
17859other libraries statically.
17860
d77de738 17861@opindex static-libtsan
ddf6fe37 17862@item -static-libtsan
d77de738
ML
17863When the @option{-fsanitize=thread} option is used to link a program,
17864the GCC driver automatically links against @option{libtsan}. If
17865@file{libtsan} is available as a shared library, and the @option{-static}
17866option is not used, then this links against the shared version of
17867@file{libtsan}. The @option{-static-libtsan} option directs the GCC
17868driver to link @file{libtsan} statically, without necessarily linking
17869other libraries statically.
17870
d77de738 17871@opindex static-liblsan
ddf6fe37 17872@item -static-liblsan
d77de738
ML
17873When the @option{-fsanitize=leak} option is used to link a program,
17874the GCC driver automatically links against @option{liblsan}. If
17875@file{liblsan} is available as a shared library, and the @option{-static}
17876option is not used, then this links against the shared version of
17877@file{liblsan}. The @option{-static-liblsan} option directs the GCC
17878driver to link @file{liblsan} statically, without necessarily linking
17879other libraries statically.
17880
d77de738 17881@opindex static-libubsan
ddf6fe37 17882@item -static-libubsan
d77de738
ML
17883When the @option{-fsanitize=undefined} option is used to link a program,
17884the GCC driver automatically links against @option{libubsan}. If
17885@file{libubsan} is available as a shared library, and the @option{-static}
17886option is not used, then this links against the shared version of
17887@file{libubsan}. The @option{-static-libubsan} option directs the GCC
17888driver to link @file{libubsan} statically, without necessarily linking
17889other libraries statically.
17890
d77de738 17891@opindex static-libstdc++
ddf6fe37 17892@item -static-libstdc++
d77de738
ML
17893When the @command{g++} program is used to link a C++ program, it
17894normally automatically links against @option{libstdc++}. If
17895@file{libstdc++} is available as a shared library, and the
17896@option{-static} option is not used, then this links against the
17897shared version of @file{libstdc++}. That is normally fine. However, it
17898is sometimes useful to freeze the version of @file{libstdc++} used by
17899the program without going all the way to a fully static link. The
17900@option{-static-libstdc++} option directs the @command{g++} driver to
17901link @file{libstdc++} statically, without necessarily linking other
17902libraries statically.
17903
d77de738 17904@opindex symbolic
ddf6fe37 17905@item -symbolic
d77de738
ML
17906Bind references to global symbols when building a shared object. Warn
17907about any unresolved references (unless overridden by the link editor
17908option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
17909this option.
17910
d77de738
ML
17911@opindex T
17912@cindex linker script
f33d7a88 17913@item -T @var{script}
d77de738
ML
17914Use @var{script} as the linker script. This option is supported by most
17915systems using the GNU linker. On some targets, such as bare-board
17916targets without an operating system, the @option{-T} option may be required
17917when linking to avoid references to undefined symbols.
17918
d77de738 17919@opindex Xlinker
ddf6fe37 17920@item -Xlinker @var{option}
d77de738
ML
17921Pass @var{option} as an option to the linker. You can use this to
17922supply system-specific linker options that GCC does not recognize.
17923
17924If you want to pass an option that takes a separate argument, you must use
17925@option{-Xlinker} twice, once for the option and once for the argument.
17926For example, to pass @option{-assert definitions}, you must write
17927@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
17928@option{-Xlinker "-assert definitions"}, because this passes the entire
17929string as a single argument, which is not what the linker expects.
17930
17931When using the GNU linker, it is usually more convenient to pass
17932arguments to linker options using the @option{@var{option}=@var{value}}
17933syntax than as separate arguments. For example, you can specify
17934@option{-Xlinker -Map=output.map} rather than
17935@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
17936this syntax for command-line options.
17937
d77de738 17938@opindex Wl
ddf6fe37 17939@item -Wl,@var{option}
d77de738
ML
17940Pass @var{option} as an option to the linker. If @var{option} contains
17941commas, it is split into multiple options at the commas. You can use this
17942syntax to pass an argument to the option.
17943For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
17944linker. When using the GNU linker, you can also get the same effect with
17945@option{-Wl,-Map=output.map}.
17946
d77de738 17947@opindex u
ddf6fe37 17948@item -u @var{symbol}
d77de738
ML
17949Pretend the symbol @var{symbol} is undefined, to force linking of
17950library modules to define it. You can use @option{-u} multiple times with
17951different symbols to force loading of additional library modules.
17952
d77de738 17953@opindex z
ddf6fe37 17954@item -z @var{keyword}
d77de738
ML
17955@option{-z} is passed directly on to the linker along with the keyword
17956@var{keyword}. See the section in the documentation of your linker for
17957permitted values and their meanings.
17958@end table
17959
17960@node Directory Options
17961@section Options for Directory Search
17962@cindex directory options
17963@cindex options, directory search
17964@cindex search path
17965
17966These options specify directories to search for header files, for
17967libraries and for parts of the compiler:
17968
17969@table @gcctabopt
17970@include cppdiropts.texi
17971
d77de738 17972@opindex iplugindir=
ddf6fe37 17973@item -iplugindir=@var{dir}
d77de738
ML
17974Set the directory to search for plugins that are passed
17975by @option{-fplugin=@var{name}} instead of
17976@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
17977to be used by the user, but only passed by the driver.
17978
d77de738 17979@opindex L
ddf6fe37 17980@item -L@var{dir}
d77de738
ML
17981Add directory @var{dir} to the list of directories to be searched
17982for @option{-l}.
17983
d77de738 17984@opindex B
ddf6fe37 17985@item -B@var{prefix}
d77de738
ML
17986This option specifies where to find the executables, libraries,
17987include files, and data files of the compiler itself.
17988
17989The compiler driver program runs one or more of the subprograms
17990@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
17991@var{prefix} as a prefix for each program it tries to run, both with and
17992without @samp{@var{machine}/@var{version}/} for the corresponding target
17993machine and compiler version.
17994
17995For each subprogram to be run, the compiler driver first tries the
17996@option{-B} prefix, if any. If that name is not found, or if @option{-B}
17997is not specified, the driver tries two standard prefixes,
17998@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
17999those results in a file name that is found, the unmodified program
18000name is searched for using the directories specified in your
18001@env{PATH} environment variable.
18002
18003The compiler checks to see if the path provided by @option{-B}
18004refers to a directory, and if necessary it adds a directory
18005separator character at the end of the path.
18006
18007@option{-B} prefixes that effectively specify directory names also apply
18008to libraries in the linker, because the compiler translates these
18009options into @option{-L} options for the linker. They also apply to
18010include files in the preprocessor, because the compiler translates these
18011options into @option{-isystem} options for the preprocessor. In this case,
18012the compiler appends @samp{include} to the prefix.
18013
18014The runtime support file @file{libgcc.a} can also be searched for using
18015the @option{-B} prefix, if needed. If it is not found there, the two
18016standard prefixes above are tried, and that is all. The file is left
18017out of the link if it is not found by those means.
18018
18019Another way to specify a prefix much like the @option{-B} prefix is to use
18020the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
18021Variables}.
18022
18023As a special kludge, if the path provided by @option{-B} is
18024@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
180259, then it is replaced by @file{[dir/]include}. This is to help
18026with boot-strapping the compiler.
18027
d77de738 18028@opindex no-canonical-prefixes
ddf6fe37 18029@item -no-canonical-prefixes
d77de738
ML
18030Do not expand any symbolic links, resolve references to @samp{/../}
18031or @samp{/./}, or make the path absolute when generating a relative
18032prefix.
18033
d77de738 18034@opindex sysroot
ddf6fe37 18035@item --sysroot=@var{dir}
d77de738
ML
18036Use @var{dir} as the logical root directory for headers and libraries.
18037For example, if the compiler normally searches for headers in
18038@file{/usr/include} and libraries in @file{/usr/lib}, it instead
18039searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
18040
18041If you use both this option and the @option{-isysroot} option, then
18042the @option{--sysroot} option applies to libraries, but the
18043@option{-isysroot} option applies to header files.
18044
18045The GNU linker (beginning with version 2.16) has the necessary support
18046for this option. If your linker does not support this option, the
18047header file aspect of @option{--sysroot} still works, but the
18048library aspect does not.
18049
d77de738 18050@opindex no-sysroot-suffix
ddf6fe37 18051@item --no-sysroot-suffix
d77de738
ML
18052For some targets, a suffix is added to the root directory specified
18053with @option{--sysroot}, depending on the other options used, so that
18054headers may for example be found in
18055@file{@var{dir}/@var{suffix}/usr/include} instead of
18056@file{@var{dir}/usr/include}. This option disables the addition of
18057such a suffix.
18058
18059@end table
18060
18061@node Code Gen Options
18062@section Options for Code Generation Conventions
18063@cindex code generation conventions
18064@cindex options, code generation
18065@cindex run-time options
18066
18067These machine-independent options control the interface conventions
18068used in code generation.
18069
18070Most of them have both positive and negative forms; the negative form
18071of @option{-ffoo} is @option{-fno-foo}. In the table below, only
18072one of the forms is listed---the one that is not the default. You
18073can figure out the other form by either removing @samp{no-} or adding
18074it.
18075
18076@table @gcctabopt
d77de738 18077@opindex fstack_reuse
ddf6fe37 18078@item -fstack-reuse=@var{reuse-level}
d77de738
ML
18079This option controls stack space reuse for user declared local/auto variables
18080and compiler generated temporaries. @var{reuse_level} can be @samp{all},
18081@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
18082local variables and temporaries, @samp{named_vars} enables the reuse only for
18083user defined local variables with names, and @samp{none} disables stack reuse
18084completely. The default value is @samp{all}. The option is needed when the
18085program extends the lifetime of a scoped local variable or a compiler generated
18086temporary beyond the end point defined by the language. When a lifetime of
18087a variable ends, and if the variable lives in memory, the optimizing compiler
18088has the freedom to reuse its stack space with other temporaries or scoped
18089local variables whose live range does not overlap with it. Legacy code extending
18090local lifetime is likely to break with the stack reuse optimization.
18091
18092For example,
18093
18094@smallexample
18095 int *p;
18096 @{
18097 int local1;
18098
18099 p = &local1;
18100 local1 = 10;
18101 ....
18102 @}
18103 @{
18104 int local2;
18105 local2 = 20;
18106 ...
18107 @}
18108
18109 if (*p == 10) // out of scope use of local1
18110 @{
18111
18112 @}
18113@end smallexample
18114
18115Another example:
18116@smallexample
18117
18118 struct A
18119 @{
18120 A(int k) : i(k), j(k) @{ @}
18121 int i;
18122 int j;
18123 @};
18124
18125 A *ap;
18126
18127 void foo(const A& ar)
18128 @{
18129 ap = &ar;
18130 @}
18131
18132 void bar()
18133 @{
18134 foo(A(10)); // temp object's lifetime ends when foo returns
18135
18136 @{
18137 A a(20);
18138 ....
18139 @}
18140 ap->i+= 10; // ap references out of scope temp whose space
18141 // is reused with a. What is the value of ap->i?
18142 @}
18143
18144@end smallexample
18145
18146The lifetime of a compiler generated temporary is well defined by the C++
18147standard. When a lifetime of a temporary ends, and if the temporary lives
18148in memory, the optimizing compiler has the freedom to reuse its stack
18149space with other temporaries or scoped local variables whose live range
18150does not overlap with it. However some of the legacy code relies on
18151the behavior of older compilers in which temporaries' stack space is
18152not reused, the aggressive stack reuse can lead to runtime errors. This
18153option is used to control the temporary stack reuse optimization.
18154
d77de738 18155@opindex ftrapv
ddf6fe37 18156@item -ftrapv
d77de738
ML
18157This option generates traps for signed overflow on addition, subtraction,
18158multiplication operations.
18159The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18160@option{-ftrapv} @option{-fwrapv} on the command-line results in
18161@option{-fwrapv} being effective. Note that only active options override, so
18162using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18163results in @option{-ftrapv} being effective.
18164
d77de738 18165@opindex fwrapv
ddf6fe37 18166@item -fwrapv
d77de738
ML
18167This option instructs the compiler to assume that signed arithmetic
18168overflow of addition, subtraction and multiplication wraps around
18169using twos-complement representation. This flag enables some optimizations
18170and disables others.
18171The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18172@option{-ftrapv} @option{-fwrapv} on the command-line results in
18173@option{-fwrapv} being effective. Note that only active options override, so
18174using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18175results in @option{-ftrapv} being effective.
18176
d77de738 18177@opindex fwrapv-pointer
ddf6fe37 18178@item -fwrapv-pointer
d77de738
ML
18179This option instructs the compiler to assume that pointer arithmetic
18180overflow on addition and subtraction wraps around using twos-complement
18181representation. This flag disables some optimizations which assume
18182pointer overflow is invalid.
18183
d77de738 18184@opindex fstrict-overflow
ddf6fe37 18185@item -fstrict-overflow
d77de738
ML
18186This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18187negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18188
d77de738 18189@opindex fexceptions
ddf6fe37 18190@item -fexceptions
d77de738
ML
18191Enable exception handling. Generates extra code needed to propagate
18192exceptions. For some targets, this implies GCC generates frame
18193unwind information for all functions, which can produce significant data
18194size overhead, although it does not affect execution. If you do not
18195specify this option, GCC enables it by default for languages like
18196C++ that normally require exception handling, and disables it for
18197languages like C that do not normally require it. However, you may need
18198to enable this option when compiling C code that needs to interoperate
18199properly with exception handlers written in C++. You may also wish to
18200disable this option if you are compiling older C++ programs that don't
18201use exception handling.
18202
d77de738 18203@opindex fnon-call-exceptions
ddf6fe37 18204@item -fnon-call-exceptions
d77de738
ML
18205Generate code that allows trapping instructions to throw exceptions.
18206Note that this requires platform-specific runtime support that does
18207not exist everywhere. Moreover, it only allows @emph{trapping}
18208instructions to throw exceptions, i.e.@: memory references or floating-point
18209instructions. It does not allow exceptions to be thrown from
18210arbitrary signal handlers such as @code{SIGALRM}. This enables
18211@option{-fexceptions}.
18212
d77de738 18213@opindex fdelete-dead-exceptions
ddf6fe37 18214@item -fdelete-dead-exceptions
d77de738
ML
18215Consider that instructions that may throw exceptions but don't otherwise
18216contribute to the execution of the program can be optimized away.
18217This does not affect calls to functions except those with the
18218@code{pure} or @code{const} attributes.
18219This option is enabled by default for the Ada and C++ compilers, as permitted by
18220the language specifications.
18221Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18222
d77de738 18223@opindex funwind-tables
ddf6fe37 18224@item -funwind-tables
d77de738
ML
18225Similar to @option{-fexceptions}, except that it just generates any needed
18226static data, but does not affect the generated code in any other way.
18227You normally do not need to enable this option; instead, a language processor
18228that needs this handling enables it on your behalf.
18229
d77de738 18230@opindex fasynchronous-unwind-tables
ddf6fe37 18231@item -fasynchronous-unwind-tables
d77de738
ML
18232Generate unwind table in DWARF format, if supported by target machine. The
18233table is exact at each instruction boundary, so it can be used for stack
18234unwinding from asynchronous events (such as debugger or garbage collector).
18235
d77de738
ML
18236@opindex fno-gnu-unique
18237@opindex fgnu-unique
ddf6fe37 18238@item -fno-gnu-unique
d77de738
ML
18239On systems with recent GNU assembler and C library, the C++ compiler
18240uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18241of template static data members and static local variables in inline
18242functions are unique even in the presence of @code{RTLD_LOCAL}; this
18243is necessary to avoid problems with a library used by two different
18244@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18245therefore disagreeing with the other one about the binding of the
18246symbol. But this causes @code{dlclose} to be ignored for affected
18247DSOs; if your program relies on reinitialization of a DSO via
18248@code{dlclose} and @code{dlopen}, you can use
18249@option{-fno-gnu-unique}.
18250
d77de738 18251@opindex fpcc-struct-return
ddf6fe37 18252@item -fpcc-struct-return
d77de738
ML
18253Return ``short'' @code{struct} and @code{union} values in memory like
18254longer ones, rather than in registers. This convention is less
18255efficient, but it has the advantage of allowing intercallability between
18256GCC-compiled files and files compiled with other compilers, particularly
18257the Portable C Compiler (pcc).
18258
18259The precise convention for returning structures in memory depends
18260on the target configuration macros.
18261
18262Short structures and unions are those whose size and alignment match
18263that of some integer type.
18264
18265@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18266switch is not binary compatible with code compiled with the
18267@option{-freg-struct-return} switch.
18268Use it to conform to a non-default application binary interface.
18269
d77de738 18270@opindex freg-struct-return
ddf6fe37 18271@item -freg-struct-return
d77de738
ML
18272Return @code{struct} and @code{union} values in registers when possible.
18273This is more efficient for small structures than
18274@option{-fpcc-struct-return}.
18275
18276If you specify neither @option{-fpcc-struct-return} nor
18277@option{-freg-struct-return}, GCC defaults to whichever convention is
18278standard for the target. If there is no standard convention, GCC
18279defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18280the principal compiler. In those cases, we can choose the standard, and
18281we chose the more efficient register return alternative.
18282
18283@strong{Warning:} code compiled with the @option{-freg-struct-return}
18284switch is not binary compatible with code compiled with the
18285@option{-fpcc-struct-return} switch.
18286Use it to conform to a non-default application binary interface.
18287
d77de738 18288@opindex fshort-enums
ddf6fe37 18289@item -fshort-enums
d77de738
ML
18290Allocate to an @code{enum} type only as many bytes as it needs for the
18291declared range of possible values. Specifically, the @code{enum} type
18292is equivalent to the smallest integer type that has enough room.
18293
18294@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18295code that is not binary compatible with code generated without that switch.
18296Use it to conform to a non-default application binary interface.
18297
d77de738 18298@opindex fshort-wchar
ddf6fe37 18299@item -fshort-wchar
d77de738
ML
18300Override the underlying type for @code{wchar_t} to be @code{short
18301unsigned int} instead of the default for the target. This option is
18302useful for building programs to run under WINE@.
18303
18304@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18305code that is not binary compatible with code generated without that switch.
18306Use it to conform to a non-default application binary interface.
18307
d77de738
ML
18308@opindex fcommon
18309@opindex fno-common
18310@cindex tentative definitions
f33d7a88 18311@item -fcommon
d77de738
ML
18312In C code, this option controls the placement of global variables
18313defined without an initializer, known as @dfn{tentative definitions}
18314in the C standard. Tentative definitions are distinct from declarations
18315of a variable with the @code{extern} keyword, which do not allocate storage.
18316
18317The default is @option{-fno-common}, which specifies that the compiler places
18318uninitialized global variables in the BSS section of the object file.
18319This inhibits the merging of tentative definitions by the linker so you get a
18320multiple-definition error if the same variable is accidentally defined in more
18321than one compilation unit.
18322
18323The @option{-fcommon} places uninitialized global variables in a common block.
18324This allows the linker to resolve all tentative definitions of the same variable
18325in different compilation units to the same object, or to a non-tentative
18326definition. This behavior is inconsistent with C++, and on many targets implies
18327a speed and code size penalty on global variable references. It is mainly
18328useful to enable legacy code to link without errors.
18329
d77de738
ML
18330@opindex fno-ident
18331@opindex fident
ddf6fe37 18332@item -fno-ident
d77de738
ML
18333Ignore the @code{#ident} directive.
18334
d77de738 18335@opindex finhibit-size-directive
ddf6fe37 18336@item -finhibit-size-directive
d77de738
ML
18337Don't output a @code{.size} assembler directive, or anything else that
18338would cause trouble if the function is split in the middle, and the
18339two halves are placed at locations far apart in memory. This option is
18340used when compiling @file{crtstuff.c}; you should not need to use it
18341for anything else.
18342
d77de738 18343@opindex fverbose-asm
ddf6fe37 18344@item -fverbose-asm
d77de738
ML
18345Put extra commentary information in the generated assembly code to
18346make it more readable. This option is generally only of use to those
18347who actually need to read the generated assembly code (perhaps while
18348debugging the compiler itself).
18349
18350@option{-fno-verbose-asm}, the default, causes the
18351extra information to be omitted and is useful when comparing two assembler
18352files.
18353
18354The added comments include:
18355
18356@itemize @bullet
18357
18358@item
18359information on the compiler version and command-line options,
18360
18361@item
18362the source code lines associated with the assembly instructions,
18363in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18364
18365@item
18366hints on which high-level expressions correspond to
18367the various assembly instruction operands.
18368
18369@end itemize
18370
18371For example, given this C source file:
18372
18373@smallexample
18374int test (int n)
18375@{
18376 int i;
18377 int total = 0;
18378
18379 for (i = 0; i < n; i++)
18380 total += i * i;
18381
18382 return total;
18383@}
18384@end smallexample
18385
18386compiling to (x86_64) assembly via @option{-S} and emitting the result
18387direct to stdout via @option{-o} @option{-}
18388
18389@smallexample
18390gcc -S test.c -fverbose-asm -Os -o -
18391@end smallexample
18392
18393gives output similar to this:
18394
18395@smallexample
18396 .file "test.c"
18397# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18398 [...snip...]
18399# options passed:
18400 [...snip...]
18401
18402 .text
18403 .globl test
18404 .type test, @@function
18405test:
18406.LFB0:
18407 .cfi_startproc
18408# test.c:4: int total = 0;
18409 xorl %eax, %eax # <retval>
18410# test.c:6: for (i = 0; i < n; i++)
18411 xorl %edx, %edx # i
18412.L2:
18413# test.c:6: for (i = 0; i < n; i++)
18414 cmpl %edi, %edx # n, i
18415 jge .L5 #,
18416# test.c:7: total += i * i;
18417 movl %edx, %ecx # i, tmp92
18418 imull %edx, %ecx # i, tmp92
18419# test.c:6: for (i = 0; i < n; i++)
18420 incl %edx # i
18421# test.c:7: total += i * i;
18422 addl %ecx, %eax # tmp92, <retval>
18423 jmp .L2 #
18424.L5:
18425# test.c:10: @}
18426 ret
18427 .cfi_endproc
18428.LFE0:
18429 .size test, .-test
18430 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18431 .section .note.GNU-stack,"",@@progbits
18432@end smallexample
18433
18434The comments are intended for humans rather than machines and hence the
18435precise format of the comments is subject to change.
18436
d77de738 18437@opindex frecord-gcc-switches
ddf6fe37 18438@item -frecord-gcc-switches
d77de738
ML
18439This switch causes the command line used to invoke the
18440compiler to be recorded into the object file that is being created.
18441This switch is only implemented on some targets and the exact format
18442of the recording is target and binary file format dependent, but it
18443usually takes the form of a section containing ASCII text. This
18444switch is related to the @option{-fverbose-asm} switch, but that
18445switch only records information in the assembler output file as
18446comments, so it never reaches the object file.
18447See also @option{-grecord-gcc-switches} for another
18448way of storing compiler options into the object file.
18449
d77de738
ML
18450@opindex fpic
18451@cindex global offset table
18452@cindex PIC
f33d7a88 18453@item -fpic
d77de738
ML
18454Generate position-independent code (PIC) suitable for use in a shared
18455library, if supported for the target machine. Such code accesses all
18456constant addresses through a global offset table (GOT)@. The dynamic
18457loader resolves the GOT entries when the program starts (the dynamic
18458loader is not part of GCC; it is part of the operating system). If
18459the GOT size for the linked executable exceeds a machine-specific
18460maximum size, you get an error message from the linker indicating that
18461@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18462instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18463on the m68k and RS/6000. The x86 has no such limit.)
18464
18465Position-independent code requires special support, and therefore works
18466only on certain machines. For the x86, GCC supports PIC for System V
18467but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18468position-independent.
18469
18470When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18471are defined to 1.
18472
d77de738 18473@opindex fPIC
ddf6fe37 18474@item -fPIC
d77de738
ML
18475If supported for the target machine, emit position-independent code,
18476suitable for dynamic linking and avoiding any limit on the size of the
18477global offset table. This option makes a difference on AArch64, m68k,
18478PowerPC and SPARC@.
18479
18480Position-independent code requires special support, and therefore works
18481only on certain machines.
18482
18483When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18484are defined to 2.
18485
d77de738
ML
18486@opindex fpie
18487@opindex fPIE
ddf6fe37
AA
18488@item -fpie
18489@itemx -fPIE
d77de738
ML
18490These options are similar to @option{-fpic} and @option{-fPIC}, but the
18491generated position-independent code can be only linked into executables.
18492Usually these options are used to compile code that will be linked using
18493the @option{-pie} GCC option.
18494
18495@option{-fpie} and @option{-fPIE} both define the macros
18496@code{__pie__} and @code{__PIE__}. The macros have the value 1
18497for @option{-fpie} and 2 for @option{-fPIE}.
18498
d77de738
ML
18499@opindex fno-plt
18500@opindex fplt
ddf6fe37 18501@item -fno-plt
d77de738
ML
18502Do not use the PLT for external function calls in position-independent code.
18503Instead, load the callee address at call sites from the GOT and branch to it.
18504This leads to more efficient code by eliminating PLT stubs and exposing
18505GOT loads to optimizations. On architectures such as 32-bit x86 where
18506PLT stubs expect the GOT pointer in a specific register, this gives more
18507register allocation freedom to the compiler.
18508Lazy binding requires use of the PLT;
18509with @option{-fno-plt} all external symbols are resolved at load time.
18510
18511Alternatively, the function attribute @code{noplt} can be used to avoid calls
18512through the PLT for specific external functions.
18513
18514In position-dependent code, a few targets also convert calls to
18515functions that are marked to not use the PLT to use the GOT instead.
18516
d77de738
ML
18517@opindex fno-jump-tables
18518@opindex fjump-tables
ddf6fe37 18519@item -fno-jump-tables
d77de738
ML
18520Do not use jump tables for switch statements even where it would be
18521more efficient than other code generation strategies. This option is
18522of use in conjunction with @option{-fpic} or @option{-fPIC} for
18523building code that forms part of a dynamic linker and cannot
18524reference the address of a jump table. On some targets, jump tables
18525do not require a GOT and this option is not needed.
18526
d77de738
ML
18527@opindex fno-bit-tests
18528@opindex fbit-tests
ddf6fe37 18529@item -fno-bit-tests
d77de738
ML
18530Do not use bit tests for switch statements even where it would be
18531more efficient than other code generation strategies.
18532
d77de738 18533@opindex ffixed
ddf6fe37 18534@item -ffixed-@var{reg}
d77de738
ML
18535Treat the register named @var{reg} as a fixed register; generated code
18536should never refer to it (except perhaps as a stack pointer, frame
18537pointer or in some other fixed role).
18538
18539@var{reg} must be the name of a register. The register names accepted
18540are machine-specific and are defined in the @code{REGISTER_NAMES}
18541macro in the machine description macro file.
18542
18543This flag does not have a negative form, because it specifies a
18544three-way choice.
18545
d77de738 18546@opindex fcall-used
ddf6fe37 18547@item -fcall-used-@var{reg}
d77de738
ML
18548Treat the register named @var{reg} as an allocable register that is
18549clobbered by function calls. It may be allocated for temporaries or
18550variables that do not live across a call. Functions compiled this way
18551do not save and restore the register @var{reg}.
18552
18553It is an error to use this flag with the frame pointer or stack pointer.
18554Use of this flag for other registers that have fixed pervasive roles in
18555the machine's execution model produces disastrous results.
18556
18557This flag does not have a negative form, because it specifies a
18558three-way choice.
18559
d77de738 18560@opindex fcall-saved
ddf6fe37 18561@item -fcall-saved-@var{reg}
d77de738
ML
18562Treat the register named @var{reg} as an allocable register saved by
18563functions. It may be allocated even for temporaries or variables that
18564live across a call. Functions compiled this way save and restore
18565the register @var{reg} if they use it.
18566
18567It is an error to use this flag with the frame pointer or stack pointer.
18568Use of this flag for other registers that have fixed pervasive roles in
18569the machine's execution model produces disastrous results.
18570
18571A different sort of disaster results from the use of this flag for
18572a register in which function values may be returned.
18573
18574This flag does not have a negative form, because it specifies a
18575three-way choice.
18576
d77de738 18577@opindex fpack-struct
ddf6fe37 18578@item -fpack-struct[=@var{n}]
d77de738
ML
18579Without a value specified, pack all structure members together without
18580holes. When a value is specified (which must be a small power of two), pack
18581structure members according to this value, representing the maximum
18582alignment (that is, objects with default alignment requirements larger than
18583this are output potentially unaligned at the next fitting location.
18584
18585@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18586code that is not binary compatible with code generated without that switch.
18587Additionally, it makes the code suboptimal.
18588Use it to conform to a non-default application binary interface.
18589
d77de738 18590@opindex fleading-underscore
ddf6fe37 18591@item -fleading-underscore
d77de738
ML
18592This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18593change the way C symbols are represented in the object file. One use
18594is to help link with legacy assembly code.
18595
18596@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18597generate code that is not binary compatible with code generated without that
18598switch. Use it to conform to a non-default application binary interface.
18599Not all targets provide complete support for this switch.
18600
d77de738 18601@opindex ftls-model
ddf6fe37 18602@item -ftls-model=@var{model}
d77de738
ML
18603Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18604The @var{model} argument should be one of @samp{global-dynamic},
18605@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18606Note that the choice is subject to optimization: the compiler may use
18607a more efficient model for symbols not visible outside of the translation
18608unit, or if @option{-fpic} is not given on the command line.
18609
18610The default without @option{-fpic} is @samp{initial-exec}; with
18611@option{-fpic} the default is @samp{global-dynamic}.
18612
d77de738 18613@opindex ftrampolines
ddf6fe37 18614@item -ftrampolines
d77de738
ML
18615For targets that normally need trampolines for nested functions, always
18616generate them instead of using descriptors. Otherwise, for targets that
18617do not need them, like for example HP-PA or IA-64, do nothing.
18618
18619A trampoline is a small piece of code that is created at run time on the
18620stack when the address of a nested function is taken, and is used to call
18621the nested function indirectly. Therefore, it requires the stack to be
18622made executable in order for the program to work properly.
18623
18624@option{-fno-trampolines} is enabled by default on a language by language
18625basis to let the compiler avoid generating them, if it computes that this
18626is safe, and replace them with descriptors. Descriptors are made up of data
18627only, but the generated code must be prepared to deal with them. As of this
18628writing, @option{-fno-trampolines} is enabled by default only for Ada.
18629
18630Moreover, code compiled with @option{-ftrampolines} and code compiled with
18631@option{-fno-trampolines} are not binary compatible if nested functions are
18632present. This option must therefore be used on a program-wide basis and be
18633manipulated with extreme care.
18634
18635For languages other than Ada, the @code{-ftrampolines} and
18636@code{-fno-trampolines} options currently have no effect, and
18637trampolines are always generated on platforms that need them
18638for nested functions.
18639
d77de738 18640@opindex fvisibility
ddf6fe37 18641@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
d77de738
ML
18642Set the default ELF image symbol visibility to the specified option---all
18643symbols are marked with this unless overridden within the code.
18644Using this feature can very substantially improve linking and
18645load times of shared object libraries, produce more optimized
18646code, provide near-perfect API export and prevent symbol clashes.
18647It is @strong{strongly} recommended that you use this in any shared objects
18648you distribute.
18649
18650Despite the nomenclature, @samp{default} always means public; i.e.,
18651available to be linked against from outside the shared object.
18652@samp{protected} and @samp{internal} are pretty useless in real-world
18653usage so the only other commonly used option is @samp{hidden}.
18654The default if @option{-fvisibility} isn't specified is
18655@samp{default}, i.e., make every symbol public.
18656
18657A good explanation of the benefits offered by ensuring ELF
18658symbols have the correct visibility is given by ``How To Write
18659Shared Libraries'' by Ulrich Drepper (which can be found at
18660@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18661solution made possible by this option to marking things hidden when
18662the default is public is to make the default hidden and mark things
18663public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18664and @code{__attribute__ ((visibility("default")))} instead of
18665@code{__declspec(dllexport)} you get almost identical semantics with
18666identical syntax. This is a great boon to those working with
18667cross-platform projects.
18668
18669For those adding visibility support to existing code, you may find
18670@code{#pragma GCC visibility} of use. This works by you enclosing
18671the declarations you wish to set visibility for with (for example)
18672@code{#pragma GCC visibility push(hidden)} and
18673@code{#pragma GCC visibility pop}.
18674Bear in mind that symbol visibility should be viewed @strong{as
18675part of the API interface contract} and thus all new code should
18676always specify visibility when it is not the default; i.e., declarations
18677only for use within the local DSO should @strong{always} be marked explicitly
18678as hidden as so to avoid PLT indirection overheads---making this
18679abundantly clear also aids readability and self-documentation of the code.
18680Note that due to ISO C++ specification requirements, @code{operator new} and
18681@code{operator delete} must always be of default visibility.
18682
18683Be aware that headers from outside your project, in particular system
18684headers and headers from any other library you use, may not be
18685expecting to be compiled with visibility other than the default. You
18686may need to explicitly say @code{#pragma GCC visibility push(default)}
18687before including any such headers.
18688
18689@code{extern} declarations are not affected by @option{-fvisibility}, so
18690a lot of code can be recompiled with @option{-fvisibility=hidden} with
18691no modifications. However, this means that calls to @code{extern}
18692functions with no explicit visibility use the PLT, so it is more
18693effective to use @code{__attribute ((visibility))} and/or
18694@code{#pragma GCC visibility} to tell the compiler which @code{extern}
18695declarations should be treated as hidden.
18696
18697Note that @option{-fvisibility} does affect C++ vague linkage
18698entities. This means that, for instance, an exception class that is
18699be thrown between DSOs must be explicitly marked with default
18700visibility so that the @samp{type_info} nodes are unified between
18701the DSOs.
18702
18703An overview of these techniques, their benefits and how to use them
18704is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
18705
d77de738 18706@opindex fstrict-volatile-bitfields
ddf6fe37 18707@item -fstrict-volatile-bitfields
d77de738
ML
18708This option should be used if accesses to volatile bit-fields (or other
18709structure fields, although the compiler usually honors those types
18710anyway) should use a single access of the width of the
18711field's type, aligned to a natural alignment if possible. For
18712example, targets with memory-mapped peripheral registers might require
18713all such accesses to be 16 bits wide; with this flag you can
18714declare all peripheral bit-fields as @code{unsigned short} (assuming short
18715is 16 bits on these targets) to force GCC to use 16-bit accesses
18716instead of, perhaps, a more efficient 32-bit access.
18717
18718If this option is disabled, the compiler uses the most efficient
18719instruction. In the previous example, that might be a 32-bit load
18720instruction, even though that accesses bytes that do not contain
18721any portion of the bit-field, or memory-mapped registers unrelated to
18722the one being updated.
18723
18724In some cases, such as when the @code{packed} attribute is applied to a
18725structure field, it may not be possible to access the field with a single
18726read or write that is correctly aligned for the target machine. In this
18727case GCC falls back to generating multiple accesses rather than code that
18728will fault or truncate the result at run time.
18729
18730Note: Due to restrictions of the C/C++11 memory model, write accesses are
18731not allowed to touch non bit-field members. It is therefore recommended
18732to define all bits of the field's type as bit-field members.
18733
18734The default value of this option is determined by the application binary
18735interface for the target processor.
18736
d77de738 18737@opindex fsync-libcalls
ddf6fe37 18738@item -fsync-libcalls
d77de738
ML
18739This option controls whether any out-of-line instance of the @code{__sync}
18740family of functions may be used to implement the C++11 @code{__atomic}
18741family of functions.
18742
18743The default value of this option is enabled, thus the only useful form
18744of the option is @option{-fno-sync-libcalls}. This option is used in
18745the implementation of the @file{libatomic} runtime library.
18746
18747@end table
18748
18749@node Developer Options
18750@section GCC Developer Options
18751@cindex developer options
18752@cindex debugging GCC
18753@cindex debug dump options
18754@cindex dump options
18755@cindex compilation statistics
18756
18757This section describes command-line options that are primarily of
18758interest to GCC developers, including options to support compiler
18759testing and investigation of compiler bugs and compile-time
18760performance problems. This includes options that produce debug dumps
18761at various points in the compilation; that print statistics such as
18762memory use and execution time; and that print information about GCC's
18763configuration, such as where it searches for libraries. You should
18764rarely need to use any of these options for ordinary compilation and
18765linking tasks.
18766
18767Many developer options that cause GCC to dump output to a file take an
18768optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
18769or @samp{-} to dump to standard output, and @samp{stderr} for standard
18770error.
18771
18772If @samp{=@var{filename}} is omitted, a default dump file name is
18773constructed by concatenating the base dump file name, a pass number,
18774phase letter, and pass name. The base dump file name is the name of
18775output file produced by the compiler if explicitly specified and not
18776an executable; otherwise it is the source file name.
18777The pass number is determined by the order passes are registered with
18778the compiler's pass manager.
18779This is generally the same as the order of execution, but passes
18780registered by plugins, target-specific passes, or passes that are
18781otherwise registered late are numbered higher than the pass named
18782@samp{final}, even if they are executed earlier. The phase letter is
18783one of @samp{i} (inter-procedural analysis), @samp{l}
18784(language-specific), @samp{r} (RTL), or @samp{t} (tree).
18785The files are created in the directory of the output file.
18786
18787@table @gcctabopt
18788
ddf6fe37 18789@opindex fcallgraph-info
d77de738
ML
18790@item -fcallgraph-info
18791@itemx -fcallgraph-info=@var{MARKERS}
d77de738
ML
18792Makes the compiler output callgraph information for the program, on a
18793per-object-file basis. The information is generated in the common VCG
18794format. It can be decorated with additional, per-node and/or per-edge
18795information, if a list of comma-separated markers is additionally
18796specified. When the @code{su} marker is specified, the callgraph is
18797decorated with stack usage information; it is equivalent to
18798@option{-fstack-usage}. When the @code{da} marker is specified, the
18799callgraph is decorated with information about dynamically allocated
18800objects.
18801
18802When compiling with @option{-flto}, no callgraph information is output
18803along with the object file. At LTO link time, @option{-fcallgraph-info}
18804may generate multiple callgraph information files next to intermediate
18805LTO output files.
18806
ddf6fe37
AA
18807@opindex d
18808@opindex fdump-rtl-@var{pass}
d77de738
ML
18809@item -d@var{letters}
18810@itemx -fdump-rtl-@var{pass}
18811@itemx -fdump-rtl-@var{pass}=@var{filename}
d77de738
ML
18812Says to make debugging dumps during compilation at times specified by
18813@var{letters}. This is used for debugging the RTL-based passes of the
18814compiler.
18815
18816Some @option{-d@var{letters}} switches have different meaning when
18817@option{-E} is used for preprocessing. @xref{Preprocessor Options},
18818for information about preprocessor-specific dump options.
18819
18820Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
18821@option{-d} option @var{letters}. Here are the possible
18822letters for use in @var{pass} and @var{letters}, and their meanings:
18823
18824@table @gcctabopt
18825
d77de738 18826@opindex fdump-rtl-alignments
ddf6fe37 18827@item -fdump-rtl-alignments
d77de738
ML
18828Dump after branch alignments have been computed.
18829
d77de738 18830@opindex fdump-rtl-asmcons
ddf6fe37 18831@item -fdump-rtl-asmcons
d77de738
ML
18832Dump after fixing rtl statements that have unsatisfied in/out constraints.
18833
d77de738 18834@opindex fdump-rtl-auto_inc_dec
ddf6fe37 18835@item -fdump-rtl-auto_inc_dec
d77de738
ML
18836Dump after auto-inc-dec discovery. This pass is only run on
18837architectures that have auto inc or auto dec instructions.
18838
d77de738 18839@opindex fdump-rtl-barriers
ddf6fe37 18840@item -fdump-rtl-barriers
d77de738
ML
18841Dump after cleaning up the barrier instructions.
18842
d77de738 18843@opindex fdump-rtl-bbpart
ddf6fe37 18844@item -fdump-rtl-bbpart
d77de738
ML
18845Dump after partitioning hot and cold basic blocks.
18846
d77de738 18847@opindex fdump-rtl-bbro
ddf6fe37 18848@item -fdump-rtl-bbro
d77de738
ML
18849Dump after block reordering.
18850
d77de738
ML
18851@opindex fdump-rtl-btl2
18852@opindex fdump-rtl-btl2
ddf6fe37
AA
18853@item -fdump-rtl-btl1
18854@itemx -fdump-rtl-btl2
d77de738
ML
18855@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
18856after the two branch
18857target load optimization passes.
18858
d77de738 18859@opindex fdump-rtl-bypass
ddf6fe37 18860@item -fdump-rtl-bypass
d77de738
ML
18861Dump after jump bypassing and control flow optimizations.
18862
d77de738 18863@opindex fdump-rtl-combine
ddf6fe37 18864@item -fdump-rtl-combine
d77de738
ML
18865Dump after the RTL instruction combination pass.
18866
d77de738 18867@opindex fdump-rtl-compgotos
ddf6fe37 18868@item -fdump-rtl-compgotos
d77de738
ML
18869Dump after duplicating the computed gotos.
18870
d77de738
ML
18871@opindex fdump-rtl-ce1
18872@opindex fdump-rtl-ce2
18873@opindex fdump-rtl-ce3
ddf6fe37
AA
18874@item -fdump-rtl-ce1
18875@itemx -fdump-rtl-ce2
18876@itemx -fdump-rtl-ce3
d77de738
ML
18877@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
18878@option{-fdump-rtl-ce3} enable dumping after the three
18879if conversion passes.
18880
d77de738 18881@opindex fdump-rtl-cprop_hardreg
ddf6fe37 18882@item -fdump-rtl-cprop_hardreg
d77de738
ML
18883Dump after hard register copy propagation.
18884
d77de738 18885@opindex fdump-rtl-csa
ddf6fe37 18886@item -fdump-rtl-csa
d77de738
ML
18887Dump after combining stack adjustments.
18888
d77de738
ML
18889@opindex fdump-rtl-cse1
18890@opindex fdump-rtl-cse2
ddf6fe37
AA
18891@item -fdump-rtl-cse1
18892@itemx -fdump-rtl-cse2
d77de738
ML
18893@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
18894the two common subexpression elimination passes.
18895
d77de738 18896@opindex fdump-rtl-dce
ddf6fe37 18897@item -fdump-rtl-dce
d77de738
ML
18898Dump after the standalone dead code elimination passes.
18899
d77de738 18900@opindex fdump-rtl-dbr
ddf6fe37 18901@item -fdump-rtl-dbr
d77de738
ML
18902Dump after delayed branch scheduling.
18903
d77de738
ML
18904@opindex fdump-rtl-dce1
18905@opindex fdump-rtl-dce2
ddf6fe37
AA
18906@item -fdump-rtl-dce1
18907@itemx -fdump-rtl-dce2
d77de738
ML
18908@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
18909the two dead store elimination passes.
18910
d77de738 18911@opindex fdump-rtl-eh
ddf6fe37 18912@item -fdump-rtl-eh
d77de738
ML
18913Dump after finalization of EH handling code.
18914
d77de738 18915@opindex fdump-rtl-eh_ranges
ddf6fe37 18916@item -fdump-rtl-eh_ranges
d77de738
ML
18917Dump after conversion of EH handling range regions.
18918
d77de738 18919@opindex fdump-rtl-expand
ddf6fe37 18920@item -fdump-rtl-expand
d77de738
ML
18921Dump after RTL generation.
18922
d77de738
ML
18923@opindex fdump-rtl-fwprop1
18924@opindex fdump-rtl-fwprop2
ddf6fe37
AA
18925@item -fdump-rtl-fwprop1
18926@itemx -fdump-rtl-fwprop2
d77de738
ML
18927@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
18928dumping after the two forward propagation passes.
18929
d77de738
ML
18930@opindex fdump-rtl-gcse1
18931@opindex fdump-rtl-gcse2
ddf6fe37
AA
18932@item -fdump-rtl-gcse1
18933@itemx -fdump-rtl-gcse2
d77de738
ML
18934@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
18935after global common subexpression elimination.
18936
d77de738 18937@opindex fdump-rtl-init-regs
ddf6fe37 18938@item -fdump-rtl-init-regs
d77de738
ML
18939Dump after the initialization of the registers.
18940
d77de738 18941@opindex fdump-rtl-initvals
ddf6fe37 18942@item -fdump-rtl-initvals
d77de738
ML
18943Dump after the computation of the initial value sets.
18944
d77de738 18945@opindex fdump-rtl-into_cfglayout
ddf6fe37 18946@item -fdump-rtl-into_cfglayout
d77de738
ML
18947Dump after converting to cfglayout mode.
18948
d77de738 18949@opindex fdump-rtl-ira
ddf6fe37 18950@item -fdump-rtl-ira
d77de738
ML
18951Dump after iterated register allocation.
18952
d77de738 18953@opindex fdump-rtl-jump
ddf6fe37 18954@item -fdump-rtl-jump
d77de738
ML
18955Dump after the second jump optimization.
18956
d77de738 18957@opindex fdump-rtl-loop2
ddf6fe37 18958@item -fdump-rtl-loop2
d77de738
ML
18959@option{-fdump-rtl-loop2} enables dumping after the rtl
18960loop optimization passes.
18961
d77de738 18962@opindex fdump-rtl-mach
ddf6fe37 18963@item -fdump-rtl-mach
d77de738
ML
18964Dump after performing the machine dependent reorganization pass, if that
18965pass exists.
18966
d77de738 18967@opindex fdump-rtl-mode_sw
ddf6fe37 18968@item -fdump-rtl-mode_sw
d77de738
ML
18969Dump after removing redundant mode switches.
18970
d77de738 18971@opindex fdump-rtl-rnreg
ddf6fe37 18972@item -fdump-rtl-rnreg
d77de738
ML
18973Dump after register renumbering.
18974
d77de738 18975@opindex fdump-rtl-outof_cfglayout
ddf6fe37 18976@item -fdump-rtl-outof_cfglayout
d77de738
ML
18977Dump after converting from cfglayout mode.
18978
d77de738 18979@opindex fdump-rtl-peephole2
ddf6fe37 18980@item -fdump-rtl-peephole2
d77de738
ML
18981Dump after the peephole pass.
18982
d77de738 18983@opindex fdump-rtl-postreload
ddf6fe37 18984@item -fdump-rtl-postreload
d77de738
ML
18985Dump after post-reload optimizations.
18986
d77de738 18987@opindex fdump-rtl-pro_and_epilogue
ddf6fe37 18988@item -fdump-rtl-pro_and_epilogue
d77de738
ML
18989Dump after generating the function prologues and epilogues.
18990
d77de738
ML
18991@opindex fdump-rtl-sched1
18992@opindex fdump-rtl-sched2
ddf6fe37
AA
18993@item -fdump-rtl-sched1
18994@itemx -fdump-rtl-sched2
d77de738
ML
18995@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
18996after the basic block scheduling passes.
18997
d77de738 18998@opindex fdump-rtl-ree
ddf6fe37 18999@item -fdump-rtl-ree
d77de738
ML
19000Dump after sign/zero extension elimination.
19001
d77de738 19002@opindex fdump-rtl-seqabstr
ddf6fe37 19003@item -fdump-rtl-seqabstr
d77de738
ML
19004Dump after common sequence discovery.
19005
d77de738 19006@opindex fdump-rtl-shorten
ddf6fe37 19007@item -fdump-rtl-shorten
d77de738
ML
19008Dump after shortening branches.
19009
d77de738 19010@opindex fdump-rtl-sibling
ddf6fe37 19011@item -fdump-rtl-sibling
d77de738
ML
19012Dump after sibling call optimizations.
19013
d77de738
ML
19014@opindex fdump-rtl-split1
19015@opindex fdump-rtl-split2
19016@opindex fdump-rtl-split3
19017@opindex fdump-rtl-split4
19018@opindex fdump-rtl-split5
ddf6fe37
AA
19019@item -fdump-rtl-split1
19020@itemx -fdump-rtl-split2
19021@itemx -fdump-rtl-split3
19022@itemx -fdump-rtl-split4
19023@itemx -fdump-rtl-split5
d77de738
ML
19024These options enable dumping after five rounds of
19025instruction splitting.
19026
d77de738 19027@opindex fdump-rtl-sms
ddf6fe37 19028@item -fdump-rtl-sms
d77de738
ML
19029Dump after modulo scheduling. This pass is only run on some
19030architectures.
19031
d77de738 19032@opindex fdump-rtl-stack
ddf6fe37 19033@item -fdump-rtl-stack
d77de738
ML
19034Dump after conversion from GCC's ``flat register file'' registers to the
19035x87's stack-like registers. This pass is only run on x86 variants.
19036
d77de738
ML
19037@opindex fdump-rtl-subreg1
19038@opindex fdump-rtl-subreg2
ddf6fe37
AA
19039@item -fdump-rtl-subreg1
19040@itemx -fdump-rtl-subreg2
d77de738
ML
19041@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
19042the two subreg expansion passes.
19043
d77de738 19044@opindex fdump-rtl-unshare
ddf6fe37 19045@item -fdump-rtl-unshare
d77de738
ML
19046Dump after all rtl has been unshared.
19047
d77de738 19048@opindex fdump-rtl-vartrack
ddf6fe37 19049@item -fdump-rtl-vartrack
d77de738
ML
19050Dump after variable tracking.
19051
d77de738 19052@opindex fdump-rtl-vregs
ddf6fe37 19053@item -fdump-rtl-vregs
d77de738
ML
19054Dump after converting virtual registers to hard registers.
19055
d77de738 19056@opindex fdump-rtl-web
ddf6fe37 19057@item -fdump-rtl-web
d77de738
ML
19058Dump after live range splitting.
19059
d77de738
ML
19060@opindex fdump-rtl-regclass
19061@opindex fdump-rtl-subregs_of_mode_init
19062@opindex fdump-rtl-subregs_of_mode_finish
19063@opindex fdump-rtl-dfinit
19064@opindex fdump-rtl-dfinish
ddf6fe37
AA
19065@item -fdump-rtl-regclass
19066@itemx -fdump-rtl-subregs_of_mode_init
19067@itemx -fdump-rtl-subregs_of_mode_finish
19068@itemx -fdump-rtl-dfinit
19069@itemx -fdump-rtl-dfinish
d77de738
ML
19070These dumps are defined but always produce empty files.
19071
d77de738
ML
19072@opindex da
19073@opindex fdump-rtl-all
ddf6fe37
AA
19074@item -da
19075@itemx -fdump-rtl-all
d77de738
ML
19076Produce all the dumps listed above.
19077
d77de738 19078@opindex dA
ddf6fe37 19079@item -dA
d77de738
ML
19080Annotate the assembler output with miscellaneous debugging information.
19081
d77de738 19082@opindex dD
ddf6fe37 19083@item -dD
d77de738
ML
19084Dump all macro definitions, at the end of preprocessing, in addition to
19085normal output.
19086
d77de738 19087@opindex dH
ddf6fe37 19088@item -dH
d77de738
ML
19089Produce a core dump whenever an error occurs.
19090
d77de738 19091@opindex dp
ddf6fe37 19092@item -dp
d77de738
ML
19093Annotate the assembler output with a comment indicating which
19094pattern and alternative is used. The length and cost of each instruction are
19095also printed.
19096
d77de738 19097@opindex dP
ddf6fe37 19098@item -dP
d77de738
ML
19099Dump the RTL in the assembler output as a comment before each instruction.
19100Also turns on @option{-dp} annotation.
19101
d77de738 19102@opindex dx
ddf6fe37 19103@item -dx
d77de738
ML
19104Just generate RTL for a function instead of compiling it. Usually used
19105with @option{-fdump-rtl-expand}.
19106@end table
19107
d77de738 19108@opindex fdump-debug
ddf6fe37 19109@item -fdump-debug
d77de738
ML
19110Dump debugging information generated during the debug
19111generation phase.
19112
d77de738 19113@opindex fdump-earlydebug
ddf6fe37 19114@item -fdump-earlydebug
d77de738
ML
19115Dump debugging information generated during the early debug
19116generation phase.
19117
d77de738 19118@opindex fdump-noaddr
ddf6fe37 19119@item -fdump-noaddr
d77de738
ML
19120When doing debugging dumps, suppress address output. This makes it more
19121feasible to use diff on debugging dumps for compiler invocations with
19122different compiler binaries and/or different
19123text / bss / data / heap / stack / dso start locations.
19124
d77de738 19125@opindex freport-bug
ddf6fe37 19126@item -freport-bug
d77de738
ML
19127Collect and dump debug information into a temporary file if an
19128internal compiler error (ICE) occurs.
19129
d77de738 19130@opindex fdump-unnumbered
ddf6fe37 19131@item -fdump-unnumbered
d77de738
ML
19132When doing debugging dumps, suppress instruction numbers and address output.
19133This makes it more feasible to use diff on debugging dumps for compiler
19134invocations with different options, in particular with and without
19135@option{-g}.
19136
d77de738 19137@opindex fdump-unnumbered-links
ddf6fe37 19138@item -fdump-unnumbered-links
d77de738
ML
19139When doing debugging dumps (see @option{-d} option above), suppress
19140instruction numbers for the links to the previous and next instructions
19141in a sequence.
19142
ddf6fe37 19143@opindex fdump-ipa
d77de738
ML
19144@item -fdump-ipa-@var{switch}
19145@itemx -fdump-ipa-@var{switch}-@var{options}
d77de738
ML
19146Control the dumping at various stages of inter-procedural analysis
19147language tree to a file. The file name is generated by appending a
19148switch specific suffix to the source file name, and the file is created
19149in the same directory as the output file. The following dumps are
19150possible:
19151
19152@table @samp
19153@item all
19154Enables all inter-procedural analysis dumps.
19155
19156@item cgraph
19157Dumps information about call-graph optimization, unused function removal,
19158and inlining decisions.
19159
19160@item inline
19161Dump after function inlining.
19162
19163@end table
19164
19165Additionally, the options @option{-optimized}, @option{-missed},
19166@option{-note}, and @option{-all} can be provided, with the same meaning
19167as for @option{-fopt-info}, defaulting to @option{-optimized}.
19168
19169For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19170information on callsites that were inlined, along with callsites
19171that were not inlined.
19172
19173By default, the dump will contain messages about successful
19174optimizations (equivalent to @option{-optimized}) together with
19175low-level details about the analysis.
19176
d77de738 19177@opindex fdump-lang
ddf6fe37 19178@item -fdump-lang
d77de738
ML
19179Dump language-specific information. The file name is made by appending
19180@file{.lang} to the source file name.
19181
ddf6fe37
AA
19182@opindex fdump-lang-all
19183@opindex fdump-lang
d77de738
ML
19184@item -fdump-lang-all
19185@itemx -fdump-lang-@var{switch}
19186@itemx -fdump-lang-@var{switch}-@var{options}
19187@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19188Control the dumping of language-specific information. The @var{options}
19189and @var{filename} portions behave as described in the
19190@option{-fdump-tree} option. The following @var{switch} values are
19191accepted:
19192
19193@table @samp
19194@item all
19195
19196Enable all language-specific dumps.
19197
19198@item class
19199Dump class hierarchy information. Virtual table information is emitted
19200unless '@option{slim}' is specified. This option is applicable to C++ only.
19201
19202@item module
19203Dump module information. Options @option{lineno} (locations),
19204@option{graph} (reachability), @option{blocks} (clusters),
19205@option{uid} (serialization), @option{alias} (mergeable),
19206@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19207(macros) may provide additional information. This option is
19208applicable to C++ only.
19209
19210@item raw
19211Dump the raw internal tree data. This option is applicable to C++ only.
19212
19213@end table
19214
d77de738 19215@opindex fdump-passes
ddf6fe37 19216@item -fdump-passes
d77de738
ML
19217Print on @file{stderr} the list of optimization passes that are turned
19218on and off by the current command-line options.
19219
d77de738 19220@opindex fdump-statistics
ddf6fe37 19221@item -fdump-statistics-@var{option}
d77de738
ML
19222Enable and control dumping of pass statistics in a separate file. The
19223file name is generated by appending a suffix ending in
19224@samp{.statistics} to the source file name, and the file is created in
19225the same directory as the output file. If the @samp{-@var{option}}
19226form is used, @samp{-stats} causes counters to be summed over the
19227whole compilation unit while @samp{-details} dumps every event as
19228the passes generate them. The default with no option is to sum
19229counters for each function compiled.
19230
ddf6fe37
AA
19231@opindex fdump-tree-all
19232@opindex fdump-tree
d77de738
ML
19233@item -fdump-tree-all
19234@itemx -fdump-tree-@var{switch}
19235@itemx -fdump-tree-@var{switch}-@var{options}
19236@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
d77de738
ML
19237Control the dumping at various stages of processing the intermediate
19238language tree to a file. If the @samp{-@var{options}}
19239form is used, @var{options} is a list of @samp{-} separated options
19240which control the details of the dump. Not all options are applicable
19241to all dumps; those that are not meaningful are ignored. The
19242following options are available
19243
19244@table @samp
19245@item address
19246Print the address of each node. Usually this is not meaningful as it
19247changes according to the environment and source file. Its primary use
19248is for tying up a dump file with a debug environment.
19249@item asmname
19250If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19251in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19252use working backward from mangled names in the assembly file.
19253@item slim
19254When dumping front-end intermediate representations, inhibit dumping
19255of members of a scope or body of a function merely because that scope
19256has been reached. Only dump such items when they are directly reachable
19257by some other path.
19258
19259When dumping pretty-printed trees, this option inhibits dumping the
19260bodies of control structures.
19261
19262When dumping RTL, print the RTL in slim (condensed) form instead of
19263the default LISP-like representation.
19264@item raw
19265Print a raw representation of the tree. By default, trees are
19266pretty-printed into a C-like representation.
19267@item details
19268Enable more detailed dumps (not honored by every dump option). Also
19269include information from the optimization passes.
19270@item stats
19271Enable dumping various statistics about the pass (not honored by every dump
19272option).
19273@item blocks
19274Enable showing basic block boundaries (disabled in raw dumps).
19275@item graph
19276For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19277dump a representation of the control flow graph suitable for viewing with
19278GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19279the file is pretty-printed as a subgraph, so that GraphViz can render them
19280all in a single plot.
19281
19282This option currently only works for RTL dumps, and the RTL is always
19283dumped in slim form.
19284@item vops
19285Enable showing virtual operands for every statement.
19286@item lineno
19287Enable showing line numbers for statements.
19288@item uid
19289Enable showing the unique ID (@code{DECL_UID}) for each variable.
19290@item verbose
19291Enable showing the tree dump for each statement.
19292@item eh
19293Enable showing the EH region number holding each statement.
19294@item scev
19295Enable showing scalar evolution analysis details.
19296@item optimized
19297Enable showing optimization information (only available in certain
19298passes).
19299@item missed
19300Enable showing missed optimization information (only available in certain
19301passes).
19302@item note
19303Enable other detailed optimization information (only available in
19304certain passes).
19305@item all
19306Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19307and @option{lineno}.
19308@item optall
19309Turn on all optimization options, i.e., @option{optimized},
19310@option{missed}, and @option{note}.
19311@end table
19312
19313To determine what tree dumps are available or find the dump for a pass
19314of interest follow the steps below.
19315
19316@enumerate
19317@item
19318Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19319look for a code that corresponds to the pass you are interested in.
19320For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19321@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19322The number at the end distinguishes distinct invocations of the same pass.
19323@item
19324To enable the creation of the dump file, append the pass code to
19325the @option{-fdump-} option prefix and invoke GCC with it. For example,
19326to enable the dump from the Early Value Range Propagation pass, invoke
19327GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19328specify the name of the dump file. If you don't specify one, GCC
19329creates as described below.
19330@item
19331Find the pass dump in a file whose name is composed of three components
19332separated by a period: the name of the source file GCC was invoked to
19333compile, a numeric suffix indicating the pass number followed by the
19334letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19335and finally the pass code. For example, the Early VRP pass dump might
19336be in a file named @file{myfile.c.038t.evrp} in the current working
19337directory. Note that the numeric codes are not stable and may change
19338from one version of GCC to another.
19339@end enumerate
19340
ddf6fe37 19341@opindex fopt-info
d77de738
ML
19342@item -fopt-info
19343@itemx -fopt-info-@var{options}
19344@itemx -fopt-info-@var{options}=@var{filename}
d77de738
ML
19345Controls optimization dumps from various optimization passes. If the
19346@samp{-@var{options}} form is used, @var{options} is a list of
19347@samp{-} separated option keywords to select the dump details and
19348optimizations.
19349
19350The @var{options} can be divided into three groups:
19351@enumerate
19352@item
19353options describing what kinds of messages should be emitted,
19354@item
19355options describing the verbosity of the dump, and
19356@item
19357options describing which optimizations should be included.
19358@end enumerate
19359The options from each group can be freely mixed as they are
19360non-overlapping. However, in case of any conflicts,
19361the later options override the earlier options on the command
19362line.
19363
19364The following options control which kinds of messages should be emitted:
19365
19366@table @samp
19367@item optimized
19368Print information when an optimization is successfully applied. It is
19369up to a pass to decide which information is relevant. For example, the
19370vectorizer passes print the source location of loops which are
19371successfully vectorized.
19372@item missed
19373Print information about missed optimizations. Individual passes
19374control which information to include in the output.
19375@item note
19376Print verbose information about optimizations, such as certain
19377transformations, more detailed messages about decisions etc.
19378@item all
19379Print detailed optimization information. This includes
19380@samp{optimized}, @samp{missed}, and @samp{note}.
19381@end table
19382
19383The following option controls the dump verbosity:
19384
19385@table @samp
19386@item internals
19387By default, only ``high-level'' messages are emitted. This option enables
19388additional, more detailed, messages, which are likely to only be of interest
19389to GCC developers.
19390@end table
19391
19392One or more of the following option keywords can be used to describe a
19393group of optimizations:
19394
19395@table @samp
19396@item ipa
19397Enable dumps from all interprocedural optimizations.
19398@item loop
19399Enable dumps from all loop optimizations.
19400@item inline
19401Enable dumps from all inlining optimizations.
19402@item omp
19403Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19404@item vec
19405Enable dumps from all vectorization optimizations.
19406@item optall
19407Enable dumps from all optimizations. This is a superset of
19408the optimization groups listed above.
19409@end table
19410
19411If @var{options} is
19412omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19413about successful optimizations from all the passes, omitting messages
19414that are treated as ``internals''.
19415
19416If the @var{filename} is provided, then the dumps from all the
19417applicable optimizations are concatenated into the @var{filename}.
19418Otherwise the dump is output onto @file{stderr}. Though multiple
19419@option{-fopt-info} options are accepted, only one of them can include
19420a @var{filename}. If other filenames are provided then all but the
19421first such option are ignored.
19422
19423Note that the output @var{filename} is overwritten
19424in case of multiple translation units. If a combined output from
19425multiple translation units is desired, @file{stderr} should be used
19426instead.
19427
19428In the following example, the optimization info is output to
19429@file{stderr}:
19430
19431@smallexample
19432gcc -O3 -fopt-info
19433@end smallexample
19434
19435This example:
19436@smallexample
19437gcc -O3 -fopt-info-missed=missed.all
19438@end smallexample
19439
19440@noindent
19441outputs missed optimization report from all the passes into
19442@file{missed.all}, and this one:
19443
19444@smallexample
19445gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19446@end smallexample
19447
19448@noindent
19449prints information about missed optimization opportunities from
19450vectorization passes on @file{stderr}.
19451Note that @option{-fopt-info-vec-missed} is equivalent to
19452@option{-fopt-info-missed-vec}. The order of the optimization group
19453names and message types listed after @option{-fopt-info} does not matter.
19454
19455As another example,
19456@smallexample
19457gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19458@end smallexample
19459
19460@noindent
19461outputs information about missed optimizations as well as
19462optimized locations from all the inlining passes into
19463@file{inline.txt}.
19464
19465Finally, consider:
19466
19467@smallexample
19468gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19469@end smallexample
19470
19471@noindent
19472Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19473in conflict since only one output file is allowed. In this case, only
19474the first option takes effect and the subsequent options are
19475ignored. Thus only @file{vec.miss} is produced which contains
19476dumps from the vectorizer about missed opportunities.
19477
d77de738 19478@opindex fsave-optimization-record
ddf6fe37 19479@item -fsave-optimization-record
d77de738
ML
19480Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19481were performed, for those optimizations that support @option{-fopt-info}.
19482
19483This option is experimental and the format of the data within the
19484compressed JSON file is subject to change.
19485
19486It is roughly equivalent to a machine-readable version of
19487@option{-fopt-info-all}, as a collection of messages with source file,
19488line number and column number, with the following additional data for
19489each message:
19490
19491@itemize @bullet
19492
19493@item
19494the execution count of the code being optimized, along with metadata about
19495whether this was from actual profile data, or just an estimate, allowing
19496consumers to prioritize messages by code hotness,
19497
19498@item
19499the function name of the code being optimized, where applicable,
19500
19501@item
19502the ``inlining chain'' for the code being optimized, so that when
19503a function is inlined into several different places (which might
19504themselves be inlined), the reader can distinguish between the copies,
19505
19506@item
19507objects identifying those parts of the message that refer to expressions,
19508statements or symbol-table nodes, which of these categories they are, and,
19509when available, their source code location,
19510
19511@item
19512the GCC pass that emitted the message, and
19513
19514@item
19515the location in GCC's own code from which the message was emitted
19516
19517@end itemize
19518
19519Additionally, some messages are logically nested within other
19520messages, reflecting implementation details of the optimization
19521passes.
19522
d77de738 19523@opindex fsched-verbose
ddf6fe37 19524@item -fsched-verbose=@var{n}
d77de738
ML
19525On targets that use instruction scheduling, this option controls the
19526amount of debugging output the scheduler prints to the dump files.
19527
19528For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19529same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19530For @var{n} greater than one, it also output basic block probabilities,
19531detailed ready list information and unit/insn info. For @var{n} greater
19532than two, it includes RTL at abort point, control-flow and regions info.
19533And for @var{n} over four, @option{-fsched-verbose} also includes
19534dependence info.
19535
19536
19537
d77de738
ML
19538@opindex fdisable-
19539@opindex fenable-
ddf6fe37
AA
19540@item -fenable-@var{kind}-@var{pass}
19541@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
d77de738
ML
19542
19543This is a set of options that are used to explicitly disable/enable
19544optimization passes. These options are intended for use for debugging GCC.
19545Compiler users should use regular options for enabling/disabling
19546passes instead.
19547
19548@table @gcctabopt
19549
19550@item -fdisable-ipa-@var{pass}
19551Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19552statically invoked in the compiler multiple times, the pass name should be
19553appended with a sequential number starting from 1.
19554
19555@item -fdisable-rtl-@var{pass}
19556@itemx -fdisable-rtl-@var{pass}=@var{range-list}
19557Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19558statically invoked in the compiler multiple times, the pass name should be
19559appended with a sequential number starting from 1. @var{range-list} is a
19560comma-separated list of function ranges or assembler names. Each range is a number
19561pair separated by a colon. The range is inclusive in both ends. If the range
19562is trivial, the number pair can be simplified as a single number. If the
19563function's call graph node's @var{uid} falls within one of the specified ranges,
19564the @var{pass} is disabled for that function. The @var{uid} is shown in the
19565function header of a dump file, and the pass names can be dumped by using
19566option @option{-fdump-passes}.
19567
19568@item -fdisable-tree-@var{pass}
19569@itemx -fdisable-tree-@var{pass}=@var{range-list}
19570Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19571option arguments.
19572
19573@item -fenable-ipa-@var{pass}
19574Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19575statically invoked in the compiler multiple times, the pass name should be
19576appended with a sequential number starting from 1.
19577
19578@item -fenable-rtl-@var{pass}
19579@itemx -fenable-rtl-@var{pass}=@var{range-list}
19580Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19581description and examples.
19582
19583@item -fenable-tree-@var{pass}
19584@itemx -fenable-tree-@var{pass}=@var{range-list}
19585Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19586of option arguments.
19587
19588@end table
19589
19590Here are some examples showing uses of these options.
19591
19592@smallexample
19593
19594# disable ccp1 for all functions
19595 -fdisable-tree-ccp1
19596# disable complete unroll for function whose cgraph node uid is 1
19597 -fenable-tree-cunroll=1
19598# disable gcse2 for functions at the following ranges [1,1],
19599# [300,400], and [400,1000]
19600# disable gcse2 for functions foo and foo2
19601 -fdisable-rtl-gcse2=foo,foo2
19602# disable early inlining
19603 -fdisable-tree-einline
19604# disable ipa inlining
19605 -fdisable-ipa-inline
19606# enable tree full unroll
19607 -fenable-tree-unroll
19608
19609@end smallexample
19610
d77de738
ML
19611@opindex fchecking
19612@opindex fno-checking
ddf6fe37
AA
19613@item -fchecking
19614@itemx -fchecking=@var{n}
d77de738
ML
19615Enable internal consistency checking. The default depends on
19616the compiler configuration. @option{-fchecking=2} enables further
19617internal consistency checking that might affect code generation.
19618
d77de738 19619@opindex frandom-seed
ddf6fe37 19620@item -frandom-seed=@var{string}
d77de738
ML
19621This option provides a seed that GCC uses in place of
19622random numbers in generating certain symbol names
19623that have to be different in every compiled file. It is also used to
19624place unique stamps in coverage data files and the object files that
19625produce them. You can use the @option{-frandom-seed} option to produce
19626reproducibly identical object files.
19627
19628The @var{string} can either be a number (decimal, octal or hex) or an
19629arbitrary string (in which case it's converted to a number by
19630computing CRC32).
19631
19632The @var{string} should be different for every file you compile.
19633
d77de738 19634@opindex save-temps
ddf6fe37 19635@item -save-temps
d77de738
ML
19636Store the usual ``temporary'' intermediate files permanently; name them
19637as auxiliary output files, as specified described under
19638@option{-dumpbase} and @option{-dumpdir}.
19639
19640When used in combination with the @option{-x} command-line option,
19641@option{-save-temps} is sensible enough to avoid overwriting an
19642input source file with the same extension as an intermediate file.
19643The corresponding intermediate file may be obtained by renaming the
19644source file before using @option{-save-temps}.
19645
d77de738 19646@opindex save-temps=cwd
ddf6fe37 19647@item -save-temps=cwd
d77de738
ML
19648Equivalent to @option{-save-temps -dumpdir ./}.
19649
d77de738 19650@opindex save-temps=obj
ddf6fe37 19651@item -save-temps=obj
d77de738
ML
19652Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19653@file{outdir/} is the directory of the output file specified after the
19654@option{-o} option, including any directory separators. If the
19655@option{-o} option is not used, the @option{-save-temps=obj} switch
19656behaves like @option{-save-temps=cwd}.
19657
d77de738 19658@opindex time
ddf6fe37 19659@item -time@r{[}=@var{file}@r{]}
d77de738
ML
19660Report the CPU time taken by each subprocess in the compilation
19661sequence. For C source files, this is the compiler proper and assembler
19662(plus the linker if linking is done).
19663
19664Without the specification of an output file, the output looks like this:
19665
19666@smallexample
19667# cc1 0.12 0.01
19668# as 0.00 0.01
19669@end smallexample
19670
19671The first number on each line is the ``user time'', that is time spent
19672executing the program itself. The second number is ``system time'',
19673time spent executing operating system routines on behalf of the program.
19674Both numbers are in seconds.
19675
19676With the specification of an output file, the output is appended to the
19677named file, and it looks like this:
19678
19679@smallexample
196800.12 0.01 cc1 @var{options}
196810.00 0.01 as @var{options}
19682@end smallexample
19683
19684The ``user time'' and the ``system time'' are moved before the program
19685name, and the options passed to the program are displayed, so that one
19686can later tell what file was being compiled, and with which options.
19687
d77de738 19688@opindex fdump-final-insns
ddf6fe37 19689@item -fdump-final-insns@r{[}=@var{file}@r{]}
d77de738
ML
19690Dump the final internal representation (RTL) to @var{file}. If the
19691optional argument is omitted (or if @var{file} is @code{.}), the name
19692of the dump file is determined by appending @code{.gkd} to the
19693dump base name, see @option{-dumpbase}.
19694
d77de738
ML
19695@opindex fcompare-debug
19696@opindex fno-compare-debug
ddf6fe37 19697@item -fcompare-debug@r{[}=@var{opts}@r{]}
d77de738
ML
19698If no error occurs during compilation, run the compiler a second time,
19699adding @var{opts} and @option{-fcompare-debug-second} to the arguments
19700passed to the second compilation. Dump the final internal
19701representation in both compilations, and print an error if they differ.
19702
19703If the equal sign is omitted, the default @option{-gtoggle} is used.
19704
19705The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
19706and nonzero, implicitly enables @option{-fcompare-debug}. If
19707@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
19708then it is used for @var{opts}, otherwise the default @option{-gtoggle}
19709is used.
19710
19711@option{-fcompare-debug=}, with the equal sign but without @var{opts},
19712is equivalent to @option{-fno-compare-debug}, which disables the dumping
19713of the final representation and the second compilation, preventing even
19714@env{GCC_COMPARE_DEBUG} from taking effect.
19715
19716To verify full coverage during @option{-fcompare-debug} testing, set
19717@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
19718which GCC rejects as an invalid option in any actual compilation
19719(rather than preprocessing, assembly or linking). To get just a
19720warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
19721not overridden} will do.
19722
d77de738 19723@opindex fcompare-debug-second
ddf6fe37 19724@item -fcompare-debug-second
d77de738
ML
19725This option is implicitly passed to the compiler for the second
19726compilation requested by @option{-fcompare-debug}, along with options to
19727silence warnings, and omitting other options that would cause the compiler
19728to produce output to files or to standard output as a side effect. Dump
19729files and preserved temporary files are renamed so as to contain the
19730@code{.gk} additional extension during the second compilation, to avoid
19731overwriting those generated by the first.
19732
19733When this option is passed to the compiler driver, it causes the
19734@emph{first} compilation to be skipped, which makes it useful for little
19735other than debugging the compiler proper.
19736
d77de738 19737@opindex gtoggle
ddf6fe37 19738@item -gtoggle
d77de738
ML
19739Turn off generation of debug info, if leaving out this option
19740generates it, or turn it on at level 2 otherwise. The position of this
19741argument in the command line does not matter; it takes effect after all
19742other options are processed, and it does so only once, no matter how
19743many times it is given. This is mainly intended to be used with
19744@option{-fcompare-debug}.
19745
d77de738
ML
19746@opindex fvar-tracking-assignments-toggle
19747@opindex fno-var-tracking-assignments-toggle
ddf6fe37 19748@item -fvar-tracking-assignments-toggle
d77de738
ML
19749Toggle @option{-fvar-tracking-assignments}, in the same way that
19750@option{-gtoggle} toggles @option{-g}.
19751
d77de738 19752@opindex Q
ddf6fe37 19753@item -Q
d77de738
ML
19754Makes the compiler print out each function name as it is compiled, and
19755print some statistics about each pass when it finishes.
19756
d77de738 19757@opindex ftime-report
ddf6fe37 19758@item -ftime-report
d77de738
ML
19759Makes the compiler print some statistics about the time consumed by each
19760pass when it finishes.
19761
d77de738 19762@opindex ftime-report-details
ddf6fe37 19763@item -ftime-report-details
d77de738
ML
19764Record the time consumed by infrastructure parts separately for each pass.
19765
d77de738 19766@opindex fira-verbose
ddf6fe37 19767@item -fira-verbose=@var{n}
d77de738
ML
19768Control the verbosity of the dump file for the integrated register allocator.
19769The default value is 5. If the value @var{n} is greater or equal to 10,
19770the dump output is sent to stderr using the same format as @var{n} minus 10.
19771
d77de738 19772@opindex flto-report
ddf6fe37 19773@item -flto-report
d77de738
ML
19774Prints a report with internal details on the workings of the link-time
19775optimizer. The contents of this report vary from version to version.
19776It is meant to be useful to GCC developers when processing object
19777files in LTO mode (via @option{-flto}).
19778
19779Disabled by default.
19780
d77de738 19781@opindex flto-report-wpa
ddf6fe37 19782@item -flto-report-wpa
d77de738
ML
19783Like @option{-flto-report}, but only print for the WPA phase of link-time
19784optimization.
19785
d77de738 19786@opindex fmem-report
ddf6fe37 19787@item -fmem-report
d77de738
ML
19788Makes the compiler print some statistics about permanent memory
19789allocation when it finishes.
19790
d77de738 19791@opindex fmem-report-wpa
ddf6fe37 19792@item -fmem-report-wpa
d77de738
ML
19793Makes the compiler print some statistics about permanent memory
19794allocation for the WPA phase only.
19795
d77de738 19796@opindex fpre-ipa-mem-report
d77de738 19797@opindex fpost-ipa-mem-report
ddf6fe37
AA
19798@item -fpre-ipa-mem-report
19799@item -fpost-ipa-mem-report
d77de738
ML
19800Makes the compiler print some statistics about permanent memory
19801allocation before or after interprocedural optimization.
19802
d77de738 19803@opindex fmultiflags
ddf6fe37 19804@item -fmultiflags
d77de738
ML
19805This option enables multilib-aware @code{TFLAGS} to be used to build
19806target libraries with options different from those the compiler is
19807configured to use by default, through the use of specs (@xref{Spec
19808Files}) set up by compiler internals, by the target, or by builders at
19809configure time.
19810
19811Like @code{TFLAGS}, this allows the target libraries to be built for
19812portable baseline environments, while the compiler defaults to more
19813demanding ones. That's useful because users can easily override the
19814defaults the compiler is configured to use to build their own programs,
19815if the defaults are not ideal for their target environment, whereas
19816rebuilding the runtime libraries is usually not as easy or desirable.
19817
19818Unlike @code{TFLAGS}, the use of specs enables different flags to be
19819selected for different multilibs. The way to accomplish that is to
19820build with @samp{make TFLAGS=-fmultiflags}, after configuring
19821@samp{--with-specs=%@{fmultiflags:...@}}.
19822
19823This option is discarded by the driver once it's done processing driver
19824self spec.
19825
19826It is also useful to check that @code{TFLAGS} are being used to build
19827all target libraries, by configuring a non-bootstrap compiler
19828@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
19829the compiler and target libraries.
19830
d77de738 19831@opindex fprofile-report
ddf6fe37 19832@item -fprofile-report
d77de738
ML
19833Makes the compiler print some statistics about consistency of the
19834(estimated) profile and effect of individual passes.
19835
d77de738 19836@opindex fstack-usage
ddf6fe37 19837@item -fstack-usage
d77de738
ML
19838Makes the compiler output stack usage information for the program, on a
19839per-function basis. The filename for the dump is made by appending
19840@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
19841the output file, if explicitly specified and it is not an executable,
19842otherwise it is the basename of the source file. An entry is made up
19843of three fields:
19844
19845@itemize
19846@item
19847The name of the function.
19848@item
19849A number of bytes.
19850@item
19851One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
19852@end itemize
19853
19854The qualifier @code{static} means that the function manipulates the stack
19855statically: a fixed number of bytes are allocated for the frame on function
19856entry and released on function exit; no stack adjustments are otherwise made
19857in the function. The second field is this fixed number of bytes.
19858
19859The qualifier @code{dynamic} means that the function manipulates the stack
19860dynamically: in addition to the static allocation described above, stack
19861adjustments are made in the body of the function, for example to push/pop
19862arguments around function calls. If the qualifier @code{bounded} is also
19863present, the amount of these adjustments is bounded at compile time and
19864the second field is an upper bound of the total amount of stack used by
19865the function. If it is not present, the amount of these adjustments is
19866not bounded at compile time and the second field only represents the
19867bounded part.
19868
d77de738 19869@opindex fstats
ddf6fe37 19870@item -fstats
d77de738
ML
19871Emit statistics about front-end processing at the end of the compilation.
19872This option is supported only by the C++ front end, and
19873the information is generally only useful to the G++ development team.
19874
d77de738 19875@opindex fdbg-cnt-list
ddf6fe37 19876@item -fdbg-cnt-list
d77de738
ML
19877Print the name and the counter upper bound for all debug counters.
19878
19879
d77de738 19880@opindex fdbg-cnt
ddf6fe37 19881@item -fdbg-cnt=@var{counter-value-list}
d77de738
ML
19882Set the internal debug counter lower and upper bound. @var{counter-value-list}
19883is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
19884[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
19885the name of the counter and list of closed intervals.
19886The @var{lower_bound} is optional and is zero
19887initialized if not set.
19888For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
19889@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
19890eleventh invocation.
19891For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
19892
d77de738 19893@opindex print-file-name
ddf6fe37 19894@item -print-file-name=@var{library}
d77de738
ML
19895Print the full absolute name of the library file @var{library} that
19896would be used when linking---and don't do anything else. With this
19897option, GCC does not compile or link anything; it just prints the
19898file name.
19899
d77de738 19900@opindex print-multi-directory
ddf6fe37 19901@item -print-multi-directory
d77de738
ML
19902Print the directory name corresponding to the multilib selected by any
19903other switches present in the command line. This directory is supposed
19904to exist in @env{GCC_EXEC_PREFIX}.
19905
d77de738 19906@opindex print-multi-lib
ddf6fe37 19907@item -print-multi-lib
d77de738
ML
19908Print the mapping from multilib directory names to compiler switches
19909that enable them. The directory name is separated from the switches by
19910@samp{;}, and each switch starts with an @samp{@@} instead of the
19911@samp{-}, without spaces between multiple switches. This is supposed to
19912ease shell processing.
19913
d77de738 19914@opindex print-multi-os-directory
ddf6fe37 19915@item -print-multi-os-directory
d77de738
ML
19916Print the path to OS libraries for the selected
19917multilib, relative to some @file{lib} subdirectory. If OS libraries are
19918present in the @file{lib} subdirectory and no multilibs are used, this is
19919usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
19920sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
19921@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
19922subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
19923
d77de738 19924@opindex print-multiarch
ddf6fe37 19925@item -print-multiarch
d77de738
ML
19926Print the path to OS libraries for the selected multiarch,
19927relative to some @file{lib} subdirectory.
19928
d77de738 19929@opindex print-prog-name
ddf6fe37 19930@item -print-prog-name=@var{program}
d77de738
ML
19931Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
19932
d77de738 19933@opindex print-libgcc-file-name
ddf6fe37 19934@item -print-libgcc-file-name
d77de738
ML
19935Same as @option{-print-file-name=libgcc.a}.
19936
19937This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
19938but you do want to link with @file{libgcc.a}. You can do:
19939
19940@smallexample
19941gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
19942@end smallexample
19943
d77de738 19944@opindex print-search-dirs
ddf6fe37 19945@item -print-search-dirs
d77de738
ML
19946Print the name of the configured installation directory and a list of
19947program and library directories @command{gcc} searches---and don't do anything else.
19948
19949This is useful when @command{gcc} prints the error message
19950@samp{installation problem, cannot exec cpp0: No such file or directory}.
19951To resolve this you either need to put @file{cpp0} and the other compiler
19952components where @command{gcc} expects to find them, or you can set the environment
19953variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
19954Don't forget the trailing @samp{/}.
19955@xref{Environment Variables}.
19956
d77de738 19957@opindex print-sysroot
ddf6fe37 19958@item -print-sysroot
d77de738
ML
19959Print the target sysroot directory that is used during
19960compilation. This is the target sysroot specified either at configure
19961time or using the @option{--sysroot} option, possibly with an extra
19962suffix that depends on compilation options. If no target sysroot is
19963specified, the option prints nothing.
19964
d77de738 19965@opindex print-sysroot-headers-suffix
ddf6fe37 19966@item -print-sysroot-headers-suffix
d77de738
ML
19967Print the suffix added to the target sysroot when searching for
19968headers, or give an error if the compiler is not configured with such
19969a suffix---and don't do anything else.
19970
d77de738 19971@opindex dumpmachine
ddf6fe37 19972@item -dumpmachine
d77de738
ML
19973Print the compiler's target machine (for example,
19974@samp{i686-pc-linux-gnu})---and don't do anything else.
19975
d77de738 19976@opindex dumpversion
ddf6fe37 19977@item -dumpversion
d77de738
ML
19978Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
19979anything else. This is the compiler version used in filesystem paths and
19980specs. Depending on how the compiler has been configured it can be just
19981a single number (major version), two numbers separated by a dot (major and
19982minor version) or three numbers separated by dots (major, minor and patchlevel
19983version).
19984
d77de738 19985@opindex dumpfullversion
ddf6fe37 19986@item -dumpfullversion
d77de738
ML
19987Print the full compiler version---and don't do anything else. The output is
19988always three numbers separated by dots, major, minor and patchlevel version.
19989
d77de738 19990@opindex dumpspecs
ddf6fe37 19991@item -dumpspecs
d77de738
ML
19992Print the compiler's built-in specs---and don't do anything else. (This
19993is used when GCC itself is being built.) @xref{Spec Files}.
19994@end table
19995
19996@node Submodel Options
19997@section Machine-Dependent Options
19998@cindex submodel options
19999@cindex specifying hardware config
20000@cindex hardware models and configurations, specifying
20001@cindex target-dependent options
20002@cindex machine-dependent options
20003
20004Each target machine supported by GCC can have its own options---for
20005example, to allow you to compile for a particular processor variant or
20006ABI, or to control optimizations specific to that machine. By
20007convention, the names of machine-specific options start with
20008@samp{-m}.
20009
20010Some configurations of the compiler also support additional target-specific
20011options, usually for compatibility with other compilers on the same
20012platform.
20013
20014@c This list is ordered alphanumerically by subsection name.
20015@c It should be the same order and spelling as these options are listed
20016@c in Machine Dependent Options
20017
20018@menu
20019* AArch64 Options::
20020* Adapteva Epiphany Options::
20021* AMD GCN Options::
20022* ARC Options::
20023* ARM Options::
20024* AVR Options::
20025* Blackfin Options::
20026* C6X Options::
20027* CRIS Options::
20028* C-SKY Options::
20029* Darwin Options::
20030* DEC Alpha Options::
20031* eBPF Options::
20032* FR30 Options::
20033* FT32 Options::
20034* FRV Options::
20035* GNU/Linux Options::
20036* H8/300 Options::
20037* HPPA Options::
20038* IA-64 Options::
20039* LM32 Options::
20040* LoongArch Options::
20041* M32C Options::
20042* M32R/D Options::
20043* M680x0 Options::
20044* MCore Options::
d77de738
ML
20045* MicroBlaze Options::
20046* MIPS Options::
20047* MMIX Options::
20048* MN10300 Options::
20049* Moxie Options::
20050* MSP430 Options::
20051* NDS32 Options::
20052* Nios II Options::
20053* Nvidia PTX Options::
20054* OpenRISC Options::
20055* PDP-11 Options::
d77de738
ML
20056* PowerPC Options::
20057* PRU Options::
20058* RISC-V Options::
20059* RL78 Options::
20060* RS/6000 and PowerPC Options::
20061* RX Options::
20062* S/390 and zSeries Options::
d77de738
ML
20063* SH Options::
20064* Solaris 2 Options::
20065* SPARC Options::
20066* System V Options::
20067* V850 Options::
20068* VAX Options::
20069* Visium Options::
20070* VMS Options::
20071* VxWorks Options::
20072* x86 Options::
20073* x86 Windows Options::
20074* Xstormy16 Options::
20075* Xtensa Options::
20076* zSeries Options::
20077@end menu
20078
20079@node AArch64 Options
20080@subsection AArch64 Options
20081@cindex AArch64 Options
20082
20083These options are defined for AArch64 implementations:
20084
20085@table @gcctabopt
20086
d77de738 20087@opindex mabi
ddf6fe37 20088@item -mabi=@var{name}
d77de738
ML
20089Generate code for the specified data model. Permissible values
20090are @samp{ilp32} for SysV-like data model where int, long int and pointers
20091are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
20092but long int and pointers are 64 bits.
20093
20094The default depends on the specific target configuration. Note that
20095the LP64 and ILP32 ABIs are not link-compatible; you must compile your
20096entire program with the same ABI, and link with a compatible set of libraries.
20097
d77de738 20098@opindex mbig-endian
ddf6fe37 20099@item -mbig-endian
d77de738
ML
20100Generate big-endian code. This is the default when GCC is configured for an
20101@samp{aarch64_be-*-*} target.
20102
d77de738 20103@opindex mgeneral-regs-only
ddf6fe37 20104@item -mgeneral-regs-only
d77de738
ML
20105Generate code which uses only the general-purpose registers. This will prevent
20106the compiler from using floating-point and Advanced SIMD registers but will not
20107impose any restrictions on the assembler.
20108
d77de738 20109@opindex mlittle-endian
ddf6fe37 20110@item -mlittle-endian
d77de738
ML
20111Generate little-endian code. This is the default when GCC is configured for an
20112@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
20113
d77de738 20114@opindex mcmodel=tiny
ddf6fe37 20115@item -mcmodel=tiny
d77de738
ML
20116Generate code for the tiny code model. The program and its statically defined
20117symbols must be within 1MB of each other. Programs can be statically or
20118dynamically linked.
20119
d77de738 20120@opindex mcmodel=small
ddf6fe37 20121@item -mcmodel=small
d77de738
ML
20122Generate code for the small code model. The program and its statically defined
20123symbols must be within 4GB of each other. Programs can be statically or
20124dynamically linked. This is the default code model.
20125
d77de738 20126@opindex mcmodel=large
ddf6fe37 20127@item -mcmodel=large
d77de738
ML
20128Generate code for the large code model. This makes no assumptions about
20129addresses and sizes of sections. Programs can be statically linked only. The
20130@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20131@option{-fpic} and @option{-fPIC}.
20132
d77de738
ML
20133@opindex mstrict-align
20134@opindex mno-strict-align
ddf6fe37
AA
20135@item -mstrict-align
20136@itemx -mno-strict-align
d77de738
ML
20137Avoid or allow generating memory accesses that may not be aligned on a natural
20138object boundary as described in the architecture specification.
20139
d77de738
ML
20140@opindex momit-leaf-frame-pointer
20141@opindex mno-omit-leaf-frame-pointer
ddf6fe37
AA
20142@item -momit-leaf-frame-pointer
20143@itemx -mno-omit-leaf-frame-pointer
d77de738
ML
20144Omit or keep the frame pointer in leaf functions. The former behavior is the
20145default.
20146
d77de738
ML
20147@opindex mstack-protector-guard
20148@opindex mstack-protector-guard-reg
20149@opindex mstack-protector-guard-offset
ddf6fe37
AA
20150@item -mstack-protector-guard=@var{guard}
20151@itemx -mstack-protector-guard-reg=@var{reg}
20152@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
20153Generate stack protection code using canary at @var{guard}. Supported
20154locations are @samp{global} for a global canary or @samp{sysreg} for a
20155canary in an appropriate system register.
20156
20157With the latter choice the options
20158@option{-mstack-protector-guard-reg=@var{reg}} and
20159@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20160which system register to use as base register for reading the canary,
20161and from what offset from that base register. There is no default
20162register or offset as this is entirely for use within the Linux
20163kernel.
20164
d77de738 20165@opindex mtls-dialect=desc
ddf6fe37 20166@item -mtls-dialect=desc
d77de738
ML
20167Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20168of TLS variables. This is the default.
20169
d77de738 20170@opindex mtls-dialect=traditional
ddf6fe37 20171@item -mtls-dialect=traditional
d77de738
ML
20172Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20173of TLS variables.
20174
d77de738 20175@opindex mtls-size
ddf6fe37 20176@item -mtls-size=@var{size}
d77de738
ML
20177Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20178This option requires binutils 2.26 or newer.
20179
d77de738
ML
20180@opindex mfix-cortex-a53-835769
20181@opindex mno-fix-cortex-a53-835769
ddf6fe37
AA
20182@item -mfix-cortex-a53-835769
20183@itemx -mno-fix-cortex-a53-835769
d77de738
ML
20184Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20185This involves inserting a NOP instruction between memory instructions and
2018664-bit integer multiply-accumulate instructions.
20187
d77de738
ML
20188@opindex mfix-cortex-a53-843419
20189@opindex mno-fix-cortex-a53-843419
ddf6fe37
AA
20190@item -mfix-cortex-a53-843419
20191@itemx -mno-fix-cortex-a53-843419
d77de738
ML
20192Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20193This erratum workaround is made at link time and this will only pass the
20194corresponding flag to the linker.
20195
d77de738
ML
20196@opindex mlow-precision-recip-sqrt
20197@opindex mno-low-precision-recip-sqrt
ddf6fe37
AA
20198@item -mlow-precision-recip-sqrt
20199@itemx -mno-low-precision-recip-sqrt
d77de738
ML
20200Enable or disable the reciprocal square root approximation.
20201This option only has an effect if @option{-ffast-math} or
20202@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20203precision of reciprocal square root results to about 16 bits for
20204single precision and to 32 bits for double precision.
20205
d77de738
ML
20206@opindex mlow-precision-sqrt
20207@opindex mno-low-precision-sqrt
ddf6fe37
AA
20208@item -mlow-precision-sqrt
20209@itemx -mno-low-precision-sqrt
d77de738
ML
20210Enable or disable the square root approximation.
20211This option only has an effect if @option{-ffast-math} or
20212@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20213precision of square root results to about 16 bits for
20214single precision and to 32 bits for double precision.
20215If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20216
d77de738
ML
20217@opindex mlow-precision-div
20218@opindex mno-low-precision-div
ddf6fe37
AA
20219@item -mlow-precision-div
20220@itemx -mno-low-precision-div
d77de738
ML
20221Enable or disable the division approximation.
20222This option only has an effect if @option{-ffast-math} or
20223@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20224precision of division results to about 16 bits for
20225single precision and to 32 bits for double precision.
20226
20227@item -mtrack-speculation
20228@itemx -mno-track-speculation
20229Enable or disable generation of additional code to track speculative
20230execution through conditional branches. The tracking state can then
20231be used by the compiler when expanding calls to
20232@code{__builtin_speculation_safe_copy} to permit a more efficient code
20233sequence to be generated.
20234
20235@item -moutline-atomics
20236@itemx -mno-outline-atomics
20237Enable or disable calls to out-of-line helpers to implement atomic operations.
20238These helpers will, at runtime, determine if the LSE instructions from
20239ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20240instructions that are present in the base ARMv8.0 ISA.
20241
20242This option is only applicable when compiling for the base ARMv8.0
20243instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20244or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20245used directly. The same applies when using @option{-mcpu=} when the
20246selected cpu supports the @samp{lse} feature.
20247This option is on by default.
20248
d77de738 20249@opindex march
ddf6fe37 20250@item -march=@var{name}
d77de738
ML
20251Specify the name of the target architecture and, optionally, one or
20252more feature modifiers. This option has the form
20253@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20254
20255The table below summarizes the permissible values for @var{arch}
20256and the features that they enable by default:
20257
20258@multitable @columnfractions 0.20 0.20 0.60
20259@headitem @var{arch} value @tab Architecture @tab Includes by default
20260@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20261@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20262@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20263@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20264@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20265@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20266@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20267@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20268@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20269@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20270@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20271@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20272@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20273@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20274@end multitable
20275
20276The value @samp{native} is available on native AArch64 GNU/Linux and
20277causes the compiler to pick the architecture of the host system. This
20278option has no effect if the compiler is unable to recognize the
20279architecture of the host system,
20280
20281The permissible values for @var{feature} are listed in the sub-section
20282on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20283Feature Modifiers}. Where conflicting feature modifiers are
20284specified, the right-most feature is used.
20285
20286GCC uses @var{name} to determine what kind of instructions it can emit
20287when generating assembly code. If @option{-march} is specified
20288without either of @option{-mtune} or @option{-mcpu} also being
20289specified, the code is tuned to perform well across a range of target
20290processors implementing the target architecture.
20291
d77de738 20292@opindex mtune
ddf6fe37 20293@item -mtune=@var{name}
d77de738
ML
20294Specify the name of the target processor for which GCC should tune the
20295performance of the code. Permissible values for this option are:
20296@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20297@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20298@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20299@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20300@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20301@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20302@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20303@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20304@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20305@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20306@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20307@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20308@samp{octeontx2f95mm},
20309@samp{a64fx},
20310@samp{thunderx}, @samp{thunderxt88},
20311@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20312@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20313@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20314@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20315@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20316@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
e07556a8
SP
20317@samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715},
20318@samp{ampere1}, @samp{ampere1a}, and @samp{native}.
d77de738
ML
20319
20320The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20321@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20322@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20323should tune for a big.LITTLE system.
20324
20325The value @samp{neoverse-512tvb} specifies that GCC should tune
20326for Neoverse cores that (a) implement SVE and (b) have a total vector
20327bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20328tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20329instructions a cycle and that can execute an equivalent number of SVE
20330arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20331This is more general than tuning for a specific core like Neoverse V1
20332but is more specific than the default tuning described below.
20333
20334Additionally on native AArch64 GNU/Linux systems the value
20335@samp{native} tunes performance to the host system. This option has no effect
20336if the compiler is unable to recognize the processor of the host system.
20337
20338Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20339are specified, the code is tuned to perform well across a range
20340of target processors.
20341
20342This option cannot be suffixed by feature modifiers.
20343
d77de738 20344@opindex mcpu
ddf6fe37 20345@item -mcpu=@var{name}
d77de738
ML
20346Specify the name of the target processor, optionally suffixed by one
20347or more feature modifiers. This option has the form
20348@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20349the permissible values for @var{cpu} are the same as those available
20350for @option{-mtune}. The permissible values for @var{feature} are
20351documented in the sub-section on
20352@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20353Feature Modifiers}. Where conflicting feature modifiers are
20354specified, the right-most feature is used.
20355
20356GCC uses @var{name} to determine what kind of instructions it can emit when
20357generating assembly code (as if by @option{-march}) and to determine
20358the target processor for which to tune for performance (as if
20359by @option{-mtune}). Where this option is used in conjunction
20360with @option{-march} or @option{-mtune}, those options take precedence
20361over the appropriate part of this option.
20362
20363@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20364to a specific core, but instead refers to all Neoverse cores that
20365(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20366a cycle. Unless overridden by @option{-march},
20367@option{-mcpu=neoverse-512tvb} generates code that can run on a
20368Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20369these properties. Unless overridden by @option{-mtune},
20370@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20371@option{-mtune=neoverse-512tvb}.
20372
d77de738 20373@opindex moverride
ddf6fe37 20374@item -moverride=@var{string}
d77de738
ML
20375Override tuning decisions made by the back-end in response to a
20376@option{-mtune=} switch. The syntax, semantics, and accepted values
20377for @var{string} in this option are not guaranteed to be consistent
20378across releases.
20379
20380This option is only intended to be useful when developing GCC.
20381
d77de738 20382@opindex mverbose-cost-dump
ddf6fe37 20383@item -mverbose-cost-dump
d77de738
ML
20384Enable verbose cost model dumping in the debug dump files. This option is
20385provided for use in debugging the compiler.
20386
d77de738
ML
20387@opindex mpc-relative-literal-loads
20388@opindex mno-pc-relative-literal-loads
ddf6fe37
AA
20389@item -mpc-relative-literal-loads
20390@itemx -mno-pc-relative-literal-loads
d77de738
ML
20391Enable or disable PC-relative literal loads. With this option literal pools are
20392accessed using a single instruction and emitted after each function. This
20393limits the maximum size of functions to 1MB. This is enabled by default for
20394@option{-mcmodel=tiny}.
20395
d77de738 20396@opindex msign-return-address
ddf6fe37 20397@item -msign-return-address=@var{scope}
d77de738
ML
20398Select the function scope on which return address signing will be applied.
20399Permissible values are @samp{none}, which disables return address signing,
20400@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20401functions, and @samp{all}, which enables pointer signing for all functions. The
20402default value is @samp{none}. This option has been deprecated by
20403-mbranch-protection.
20404
d77de738 20405@opindex mbranch-protection
ddf6fe37 20406@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
d77de738
ML
20407Select the branch protection features to use.
20408@samp{none} is the default and turns off all types of branch protection.
20409@samp{standard} turns on all types of branch protection features. If a feature
20410has additional tuning options, then @samp{standard} sets it to its standard
20411level.
20412@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20413level: signing functions that save the return address to memory (non-leaf
20414functions will practically always do this) using the a-key. The optional
20415argument @samp{leaf} can be used to extend the signing to include leaf
20416functions. The optional argument @samp{b-key} can be used to sign the functions
20417with the B-key instead of the A-key.
20418@samp{bti} turns on branch target identification mechanism.
20419
d77de738 20420@opindex mharden-sls
ddf6fe37 20421@item -mharden-sls=@var{opts}
d77de738
ML
20422Enable compiler hardening against straight line speculation (SLS).
20423@var{opts} is a comma-separated list of the following options:
20424@table @samp
20425@item retbr
20426@item blr
20427@end table
20428In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20429@samp{-mharden-sls=none} disables all SLS hardening.
20430
d77de738 20431@opindex msve-vector-bits
ddf6fe37 20432@item -msve-vector-bits=@var{bits}
d77de738
ML
20433Specify the number of bits in an SVE vector register. This option only has
20434an effect when SVE is enabled.
20435
20436GCC supports two forms of SVE code generation: ``vector-length
20437agnostic'' output that works with any size of vector register and
20438``vector-length specific'' output that allows GCC to make assumptions
20439about the vector length when it is useful for optimization reasons.
20440The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20441@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20442Specifying @samp{scalable} selects vector-length agnostic
20443output. At present @samp{-msve-vector-bits=128} also generates vector-length
20444agnostic output for big-endian targets. All other values generate
20445vector-length specific code. The behavior of these values may change
20446in future releases and no value except @samp{scalable} should be
20447relied on for producing code that is portable across different
20448hardware SVE vector lengths.
20449
20450The default is @samp{-msve-vector-bits=scalable}, which produces
20451vector-length agnostic code.
20452@end table
20453
20454@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20455@anchor{aarch64-feature-modifiers}
20456@cindex @option{-march} feature modifiers
20457@cindex @option{-mcpu} feature modifiers
20458Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20459the following and their inverses @option{no@var{feature}}:
20460
20461@table @samp
20462@item crc
20463Enable CRC extension. This is on by default for
20464@option{-march=armv8.1-a}.
20465@item crypto
20466Enable Crypto extension. This also enables Advanced SIMD and floating-point
20467instructions.
20468@item fp
20469Enable floating-point instructions. This is on by default for all possible
20470values for options @option{-march} and @option{-mcpu}.
20471@item simd
20472Enable Advanced SIMD instructions. This also enables floating-point
20473instructions. This is on by default for all possible values for options
20474@option{-march} and @option{-mcpu}.
20475@item sve
20476Enable Scalable Vector Extension instructions. This also enables Advanced
20477SIMD and floating-point instructions.
20478@item lse
20479Enable Large System Extension instructions. This is on by default for
20480@option{-march=armv8.1-a}.
20481@item rdma
20482Enable Round Double Multiply Accumulate instructions. This is on by default
20483for @option{-march=armv8.1-a}.
20484@item fp16
20485Enable FP16 extension. This also enables floating-point instructions.
20486@item fp16fml
20487Enable FP16 fmla extension. This also enables FP16 extensions and
20488floating-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.
20489
20490@item rcpc
0431e8ae
AV
20491Enable the RCpc extension. This enables the use of the LDAPR instructions for
20492load-acquire atomic semantics, and passes it on to the assembler, enabling
20493inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20494@item dotprod
20495Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20496@item aes
20497Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20498SIMD instructions.
20499@item sha2
20500Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20501@item sha3
20502Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20503instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20504@item sm4
20505Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20506Use of this option with architectures prior to Armv8.2-A is not supported.
20507@item profile
20508Enable the Statistical Profiling extension. This option is only to enable the
20509extension at the assembler level and does not affect code generation.
20510@item rng
20511Enable the Armv8.5-a Random Number instructions. This option is only to
20512enable the extension at the assembler level and does not affect code
20513generation.
20514@item memtag
20515Enable the Armv8.5-a Memory Tagging Extensions.
20516Use of this option with architectures prior to Armv8.5-A is not supported.
20517@item sb
20518Enable the Armv8-a Speculation Barrier instruction. This option is only to
20519enable the extension at the assembler level and does not affect code
20520generation. This option is enabled by default for @option{-march=armv8.5-a}.
20521@item ssbs
20522Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20523is only to enable the extension at the assembler level and does not affect code
20524generation. This option is enabled by default for @option{-march=armv8.5-a}.
20525@item predres
20526Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20527This option is only to enable the extension at the assembler level and does
20528not affect code generation. This option is enabled by default for
20529@option{-march=armv8.5-a}.
20530@item sve2
20531Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20532instructions.
20533@item sve2-bitperm
20534Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20535@item sve2-sm4
20536Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20537@item sve2-aes
20538Enable SVE2 aes instructions. This also enables SVE2 instructions.
20539@item sve2-sha3
20540Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20541@item tme
20542Enable the Transactional Memory Extension.
20543@item i8mm
20544Enable 8-bit Integer Matrix Multiply instructions. This also enables
20545Advanced SIMD and floating-point instructions. This option is enabled by
20546default for @option{-march=armv8.6-a}. Use of this option with architectures
20547prior to Armv8.2-A is not supported.
20548@item f32mm
20549Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20550SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20551not supported.
20552@item f64mm
20553Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20554SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20555not supported.
20556@item bf16
20557Enable brain half-precision floating-point instructions. This also enables
20558Advanced SIMD and floating-point instructions. This option is enabled by
20559default for @option{-march=armv8.6-a}. Use of this option with architectures
20560prior to Armv8.2-A is not supported.
20561@item ls64
20562Enable the 64-byte atomic load and store instructions for accelerators.
20563This option is enabled by default for @option{-march=armv8.7-a}.
20564@item mops
20565Enable the instructions to accelerate memory operations like @code{memcpy},
20566@code{memmove}, @code{memset}. This option is enabled by default for
20567@option{-march=armv8.8-a}
20568@item flagm
20569Enable the Flag Manipulation instructions Extension.
20570@item pauth
20571Enable the Pointer Authentication Extension.
d758d190
KT
20572@item cssc
20573Enable the Common Short Sequence Compression instructions.
d77de738
ML
20574
20575@end table
20576
20577Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20578which implies @option{fp}.
20579Conversely, @option{nofp} implies @option{nosimd}, which implies
20580@option{nocrypto}, @option{noaes} and @option{nosha2}.
20581
20582@node Adapteva Epiphany Options
20583@subsection Adapteva Epiphany Options
20584
20585These @samp{-m} options are defined for Adapteva Epiphany:
20586
20587@table @gcctabopt
d77de738 20588@opindex mhalf-reg-file
ddf6fe37 20589@item -mhalf-reg-file
d77de738
ML
20590Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20591That allows code to run on hardware variants that lack these registers.
20592
d77de738 20593@opindex mprefer-short-insn-regs
ddf6fe37 20594@item -mprefer-short-insn-regs
d77de738
ML
20595Preferentially allocate registers that allow short instruction generation.
20596This can result in increased instruction count, so this may either reduce or
20597increase overall code size.
20598
d77de738 20599@opindex mbranch-cost
ddf6fe37 20600@item -mbranch-cost=@var{num}
d77de738
ML
20601Set the cost of branches to roughly @var{num} ``simple'' instructions.
20602This cost is only a heuristic and is not guaranteed to produce
20603consistent results across releases.
20604
d77de738 20605@opindex mcmove
ddf6fe37 20606@item -mcmove
d77de738
ML
20607Enable the generation of conditional moves.
20608
d77de738 20609@opindex mnops
ddf6fe37 20610@item -mnops=@var{num}
d77de738
ML
20611Emit @var{num} NOPs before every other generated instruction.
20612
d77de738
ML
20613@opindex mno-soft-cmpsf
20614@opindex msoft-cmpsf
ddf6fe37 20615@item -mno-soft-cmpsf
d77de738
ML
20616For single-precision floating-point comparisons, emit an @code{fsub} instruction
20617and test the flags. This is faster than a software comparison, but can
20618get incorrect results in the presence of NaNs, or when two different small
20619numbers are compared such that their difference is calculated as zero.
20620The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20621software comparisons.
20622
d77de738 20623@opindex mstack-offset
ddf6fe37 20624@item -mstack-offset=@var{num}
d77de738
ML
20625Set the offset between the top of the stack and the stack pointer.
20626E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20627can be used by leaf functions without stack allocation.
20628Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20629Note also that this option changes the ABI; compiling a program with a
20630different stack offset than the libraries have been compiled with
20631generally does not work.
20632This option can be useful if you want to evaluate if a different stack
20633offset would give you better code, but to actually use a different stack
20634offset to build working programs, it is recommended to configure the
20635toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20636
d77de738
ML
20637@opindex mno-round-nearest
20638@opindex mround-nearest
ddf6fe37 20639@item -mno-round-nearest
d77de738
ML
20640Make the scheduler assume that the rounding mode has been set to
20641truncating. The default is @option{-mround-nearest}.
20642
d77de738 20643@opindex mlong-calls
ddf6fe37 20644@item -mlong-calls
d77de738
ML
20645If not otherwise specified by an attribute, assume all calls might be beyond
20646the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20647function address into a register before performing a (otherwise direct) call.
20648This is the default.
20649
d77de738 20650@opindex short-calls
ddf6fe37 20651@item -mshort-calls
d77de738
ML
20652If not otherwise specified by an attribute, assume all direct calls are
20653in the range of the @code{b} / @code{bl} instructions, so use these instructions
20654for direct calls. The default is @option{-mlong-calls}.
20655
d77de738 20656@opindex msmall16
ddf6fe37 20657@item -msmall16
d77de738
ML
20658Assume addresses can be loaded as 16-bit unsigned values. This does not
20659apply to function addresses for which @option{-mlong-calls} semantics
20660are in effect.
20661
d77de738 20662@opindex mfp-mode
ddf6fe37 20663@item -mfp-mode=@var{mode}
d77de738
ML
20664Set the prevailing mode of the floating-point unit.
20665This determines the floating-point mode that is provided and expected
20666at function call and return time. Making this mode match the mode you
20667predominantly need at function start can make your programs smaller and
20668faster by avoiding unnecessary mode switches.
20669
20670@var{mode} can be set to one the following values:
20671
20672@table @samp
20673@item caller
20674Any mode at function entry is valid, and retained or restored when
20675the function returns, and when it calls other functions.
20676This mode is useful for compiling libraries or other compilation units
20677you might want to incorporate into different programs with different
20678prevailing FPU modes, and the convenience of being able to use a single
20679object file outweighs the size and speed overhead for any extra
20680mode switching that might be needed, compared with what would be needed
20681with a more specific choice of prevailing FPU mode.
20682
20683@item truncate
20684This is the mode used for floating-point calculations with
20685truncating (i.e.@: round towards zero) rounding mode. That includes
20686conversion from floating point to integer.
20687
20688@item round-nearest
20689This is the mode used for floating-point calculations with
20690round-to-nearest-or-even rounding mode.
20691
20692@item int
20693This is the mode used to perform integer calculations in the FPU, e.g.@:
20694integer multiply, or integer multiply-and-accumulate.
20695@end table
20696
20697The default is @option{-mfp-mode=caller}
20698
d77de738
ML
20699@opindex mno-split-lohi
20700@opindex msplit-lohi
20701@opindex mno-postinc
20702@opindex mpostinc
20703@opindex mno-postmodify
20704@opindex mpostmodify
ddf6fe37
AA
20705@item -mno-split-lohi
20706@itemx -mno-postinc
20707@itemx -mno-postmodify
d77de738
ML
20708Code generation tweaks that disable, respectively, splitting of 32-bit
20709loads, generation of post-increment addresses, and generation of
20710post-modify addresses. The defaults are @option{msplit-lohi},
20711@option{-mpost-inc}, and @option{-mpost-modify}.
20712
d77de738
ML
20713@opindex mno-vect-double
20714@opindex mvect-double
ddf6fe37 20715@item -mnovect-double
d77de738
ML
20716Change the preferred SIMD mode to SImode. The default is
20717@option{-mvect-double}, which uses DImode as preferred SIMD mode.
20718
d77de738 20719@opindex max-vect-align
ddf6fe37 20720@item -max-vect-align=@var{num}
d77de738
ML
20721The maximum alignment for SIMD vector mode types.
20722@var{num} may be 4 or 8. The default is 8.
20723Note that this is an ABI change, even though many library function
20724interfaces are unaffected if they don't use SIMD vector modes
20725in places that affect size and/or alignment of relevant types.
20726
d77de738 20727@opindex msplit-vecmove-early
ddf6fe37 20728@item -msplit-vecmove-early
d77de738
ML
20729Split vector moves into single word moves before reload. In theory this
20730can give better register allocation, but so far the reverse seems to be
20731generally the case.
20732
d77de738 20733@opindex m1reg-
ddf6fe37 20734@item -m1reg-@var{reg}
d77de738
ML
20735Specify a register to hold the constant @minus{}1, which makes loading small negative
20736constants and certain bitmasks faster.
20737Allowable values for @var{reg} are @samp{r43} and @samp{r63},
20738which specify use of that register as a fixed register,
20739and @samp{none}, which means that no register is used for this
20740purpose. The default is @option{-m1reg-none}.
20741
20742@end table
20743
20744@node AMD GCN Options
20745@subsection AMD GCN Options
20746@cindex AMD GCN Options
20747
20748These options are defined specifically for the AMD GCN port.
20749
20750@table @gcctabopt
20751
d77de738 20752@opindex march
d77de738 20753@opindex mtune
ddf6fe37
AA
20754@item -march=@var{gpu}
20755@itemx -mtune=@var{gpu}
d77de738
ML
20756Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
20757are
20758
20759@table @samp
20760@item fiji
20761Compile for GCN3 Fiji devices (gfx803).
20762
20763@item gfx900
20764Compile for GCN5 Vega 10 devices (gfx900).
20765
20766@item gfx906
20767Compile for GCN5 Vega 20 devices (gfx906).
20768
20769@item gfx908
20770Compile for CDNA1 Instinct MI100 series devices (gfx908).
20771
20772@item gfx90a
20773Compile for CDNA2 Instinct MI200 series devices (gfx90a).
20774
20775@end table
20776
ddf6fe37 20777@opindex msram-ecc
d77de738
ML
20778@item -msram-ecc=on
20779@itemx -msram-ecc=off
20780@itemx -msram-ecc=any
d77de738
ML
20781Compile binaries suitable for devices with the SRAM-ECC feature enabled,
20782disabled, or either mode. This feature can be enabled per-process on some
20783devices. The compiled code must match the device mode. The default is
20784@samp{any}, for devices that support it.
20785
d77de738 20786@opindex mstack-size
ddf6fe37 20787@item -mstack-size=@var{bytes}
d77de738
ML
20788Specify how many @var{bytes} of stack space will be requested for each GPU
20789thread (wave-front). Beware that there may be many threads and limited memory
20790available. The size of the stack allocation may also have an impact on
20791run-time performance. The default is 32KB when using OpenACC or OpenMP, and
207921MB otherwise.
20793
d77de738 20794@opindex mxnack
ddf6fe37 20795@item -mxnack
d77de738
ML
20796Compile binaries suitable for devices with the XNACK feature enabled. Some
20797devices always require XNACK and some allow the user to configure XNACK. The
20798compiled code must match the device mode. The default is @samp{-mno-xnack}.
20799At present this option is a placeholder for support that is not yet
20800implemented.
20801
20802@end table
20803
20804@node ARC Options
20805@subsection ARC Options
20806@cindex ARC options
20807
20808The following options control the architecture variant for which code
20809is being compiled:
20810
20811@c architecture variants
20812@table @gcctabopt
20813
d77de738 20814@opindex mbarrel-shifter
ddf6fe37 20815@item -mbarrel-shifter
d77de738
ML
20816Generate instructions supported by barrel shifter. This is the default
20817unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
20818
d77de738 20819@opindex mjli-always
ddf6fe37 20820@item -mjli-always
d77de738
ML
20821Force to call a function using jli_s instruction. This option is
20822valid only for ARCv2 architecture.
20823
d77de738 20824@opindex mcpu
ddf6fe37 20825@item -mcpu=@var{cpu}
d77de738
ML
20826Set architecture type, register usage, and instruction scheduling
20827parameters for @var{cpu}. There are also shortcut alias options
20828available for backward compatibility and convenience. Supported
20829values for @var{cpu} are
20830
20831@table @samp
20832@opindex mA6
20833@opindex mARC600
20834@item arc600
20835Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
20836
d77de738 20837@opindex mARC601
ddf6fe37 20838@item arc601
d77de738
ML
20839Compile for ARC601. Alias: @option{-mARC601}.
20840
d77de738
ML
20841@opindex mA7
20842@opindex mARC700
ddf6fe37 20843@item arc700
d77de738
ML
20844Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
20845This is the default when configured with @option{--with-cpu=arc700}@.
20846
20847@item arcem
20848Compile for ARC EM.
20849
20850@item archs
20851Compile for ARC HS.
20852
20853@item em
20854Compile for ARC EM CPU with no hardware extensions.
20855
20856@item em4
20857Compile for ARC EM4 CPU.
20858
20859@item em4_dmips
20860Compile for ARC EM4 DMIPS CPU.
20861
20862@item em4_fpus
20863Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
20864extension.
20865
20866@item em4_fpuda
20867Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
20868double assist instructions.
20869
20870@item hs
20871Compile for ARC HS CPU with no hardware extensions except the atomic
20872instructions.
20873
20874@item hs34
20875Compile for ARC HS34 CPU.
20876
20877@item hs38
20878Compile for ARC HS38 CPU.
20879
20880@item hs38_linux
20881Compile for ARC HS38 CPU with all hardware extensions on.
20882
20883@item hs4x
20884Compile for ARC HS4x CPU.
20885
20886@item hs4xd
20887Compile for ARC HS4xD CPU.
20888
20889@item hs4x_rel31
20890Compile for ARC HS4x CPU release 3.10a.
20891
20892@item arc600_norm
20893Compile for ARC 600 CPU with @code{norm} instructions enabled.
20894
20895@item arc600_mul32x16
20896Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
20897instructions enabled.
20898
20899@item arc600_mul64
20900Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
20901instructions enabled.
20902
20903@item arc601_norm
20904Compile for ARC 601 CPU with @code{norm} instructions enabled.
20905
20906@item arc601_mul32x16
20907Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
20908instructions enabled.
20909
20910@item arc601_mul64
20911Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
20912instructions enabled.
20913
20914@item nps400
20915Compile for ARC 700 on NPS400 chip.
20916
20917@item em_mini
20918Compile for ARC EM minimalist configuration featuring reduced register
20919set.
20920
20921@end table
20922
d77de738 20923@opindex mdpfp
d77de738 20924@opindex mdpfp-compact
ddf6fe37
AA
20925@item -mdpfp
20926@itemx -mdpfp-compact
d77de738
ML
20927Generate double-precision FPX instructions, tuned for the compact
20928implementation.
20929
d77de738 20930@opindex mdpfp-fast
ddf6fe37 20931@item -mdpfp-fast
d77de738
ML
20932Generate double-precision FPX instructions, tuned for the fast
20933implementation.
20934
d77de738 20935@opindex mno-dpfp-lrsr
ddf6fe37 20936@item -mno-dpfp-lrsr
d77de738
ML
20937Disable @code{lr} and @code{sr} instructions from using FPX extension
20938aux registers.
20939
d77de738 20940@opindex mea
ddf6fe37 20941@item -mea
d77de738
ML
20942Generate extended arithmetic instructions. Currently only
20943@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
20944supported. Only valid for @option{-mcpu=ARC700}.
20945
d77de738
ML
20946@opindex mno-mpy
20947@opindex mmpy
ddf6fe37 20948@item -mno-mpy
d77de738
ML
20949Do not generate @code{mpy}-family instructions for ARC700. This option is
20950deprecated.
20951
d77de738 20952@opindex mmul32x16
ddf6fe37 20953@item -mmul32x16
d77de738
ML
20954Generate 32x16-bit multiply and multiply-accumulate instructions.
20955
d77de738 20956@opindex mmul64
ddf6fe37 20957@item -mmul64
d77de738
ML
20958Generate @code{mul64} and @code{mulu64} instructions.
20959Only valid for @option{-mcpu=ARC600}.
20960
d77de738 20961@opindex mnorm
ddf6fe37 20962@item -mnorm
d77de738
ML
20963Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
20964is in effect.
20965
d77de738 20966@opindex mspfp
d77de738 20967@opindex mspfp-compact
ddf6fe37
AA
20968@item -mspfp
20969@itemx -mspfp-compact
d77de738
ML
20970Generate single-precision FPX instructions, tuned for the compact
20971implementation.
20972
d77de738 20973@opindex mspfp-fast
ddf6fe37 20974@item -mspfp-fast
d77de738
ML
20975Generate single-precision FPX instructions, tuned for the fast
20976implementation.
20977
d77de738 20978@opindex msimd
ddf6fe37 20979@item -msimd
d77de738
ML
20980Enable generation of ARC SIMD instructions via target-specific
20981builtins. Only valid for @option{-mcpu=ARC700}.
20982
d77de738 20983@opindex msoft-float
ddf6fe37 20984@item -msoft-float
d77de738
ML
20985This option ignored; it is provided for compatibility purposes only.
20986Software floating-point code is emitted by default, and this default
20987can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
20988@option{-mspfp-fast} for single precision, and @option{-mdpfp},
20989@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
20990
d77de738 20991@opindex mswap
ddf6fe37 20992@item -mswap
d77de738
ML
20993Generate @code{swap} instructions.
20994
d77de738 20995@opindex matomic
ddf6fe37 20996@item -matomic
d77de738
ML
20997This enables use of the locked load/store conditional extension to implement
20998atomic memory built-in functions. Not available for ARC 6xx or ARC
20999EM cores.
21000
d77de738 21001@opindex mdiv-rem
ddf6fe37 21002@item -mdiv-rem
d77de738
ML
21003Enable @code{div} and @code{rem} instructions for ARCv2 cores.
21004
d77de738 21005@opindex mcode-density
ddf6fe37 21006@item -mcode-density
d77de738
ML
21007Enable code density instructions for ARC EM.
21008This option is on by default for ARC HS.
21009
d77de738 21010@opindex mll64
ddf6fe37 21011@item -mll64
d77de738
ML
21012Enable double load/store operations for ARC HS cores.
21013
d77de738 21014@opindex mtp-regno
ddf6fe37 21015@item -mtp-regno=@var{regno}
d77de738
ML
21016Specify thread pointer register number.
21017
d77de738 21018@opindex mmpy-option
ddf6fe37 21019@item -mmpy-option=@var{multo}
d77de738
ML
21020Compile ARCv2 code with a multiplier design option. You can specify
21021the option using either a string or numeric value for @var{multo}.
21022@samp{wlh1} is the default value. The recognized values are:
21023
21024@table @samp
21025@item 0
21026@itemx none
21027No multiplier available.
21028
21029@item 1
21030@itemx w
2103116x16 multiplier, fully pipelined.
21032The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
21033
21034@item 2
21035@itemx wlh1
2103632x32 multiplier, fully
21037pipelined (1 stage). The following instructions are additionally
21038enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21039
21040@item 3
21041@itemx wlh2
2104232x32 multiplier, fully pipelined
21043(2 stages). The following instructions are additionally enabled: @code{mpy},
21044@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21045
21046@item 4
21047@itemx wlh3
21048Two 16x16 multipliers, blocking,
21049sequential. The following instructions are additionally enabled: @code{mpy},
21050@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21051
21052@item 5
21053@itemx wlh4
21054One 16x16 multiplier, blocking,
21055sequential. The following instructions are additionally enabled: @code{mpy},
21056@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21057
21058@item 6
21059@itemx wlh5
21060One 32x4 multiplier, blocking,
21061sequential. The following instructions are additionally enabled: @code{mpy},
21062@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
21063
21064@item 7
21065@itemx plus_dmpy
21066ARC HS SIMD support.
21067
21068@item 8
21069@itemx plus_macd
21070ARC HS SIMD support.
21071
21072@item 9
21073@itemx plus_qmacw
21074ARC HS SIMD support.
21075
21076@end table
21077
21078This option is only available for ARCv2 cores@.
21079
d77de738 21080@opindex mfpu
ddf6fe37 21081@item -mfpu=@var{fpu}
d77de738
ML
21082Enables support for specific floating-point hardware extensions for ARCv2
21083cores. Supported values for @var{fpu} are:
21084
21085@table @samp
21086
21087@item fpus
21088Enables support for single-precision floating-point hardware
21089extensions@.
21090
21091@item fpud
21092Enables support for double-precision floating-point hardware
21093extensions. The single-precision floating-point extension is also
21094enabled. Not available for ARC EM@.
21095
21096@item fpuda
21097Enables support for double-precision floating-point hardware
21098extensions using double-precision assist instructions. The single-precision
21099floating-point extension is also enabled. This option is
21100only available for ARC EM@.
21101
21102@item fpuda_div
21103Enables support for double-precision floating-point hardware
21104extensions using double-precision assist instructions.
21105The single-precision floating-point, square-root, and divide
21106extensions are also enabled. This option is
21107only available for ARC EM@.
21108
21109@item fpuda_fma
21110Enables support for double-precision floating-point hardware
21111extensions using double-precision assist instructions.
21112The single-precision floating-point and fused multiply and add
21113hardware extensions are also enabled. This option is
21114only available for ARC EM@.
21115
21116@item fpuda_all
21117Enables support for double-precision floating-point hardware
21118extensions using double-precision assist instructions.
21119All single-precision floating-point hardware extensions are also
21120enabled. This option is only available for ARC EM@.
21121
21122@item fpus_div
21123Enables support for single-precision floating-point, square-root and divide
21124hardware extensions@.
21125
21126@item fpud_div
21127Enables support for double-precision floating-point, square-root and divide
21128hardware extensions. This option
21129includes option @samp{fpus_div}. Not available for ARC EM@.
21130
21131@item fpus_fma
21132Enables support for single-precision floating-point and
21133fused multiply and add hardware extensions@.
21134
21135@item fpud_fma
21136Enables support for double-precision floating-point and
21137fused multiply and add hardware extensions. This option
21138includes option @samp{fpus_fma}. Not available for ARC EM@.
21139
21140@item fpus_all
21141Enables support for all single-precision floating-point hardware
21142extensions@.
21143
21144@item fpud_all
21145Enables support for all single- and double-precision floating-point
21146hardware extensions. Not available for ARC EM@.
21147
21148@end table
21149
d77de738 21150@opindex mirq-ctrl-saved
ddf6fe37 21151@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
d77de738
ML
21152Specifies general-purposes registers that the processor automatically
21153saves/restores on interrupt entry and exit. @var{register-range} is
21154specified as two registers separated by a dash. The register range
21155always starts with @code{r0}, the upper limit is @code{fp} register.
21156@var{blink} and @var{lp_count} are optional. This option is only
21157valid for ARC EM and ARC HS cores.
21158
d77de738 21159@opindex mrgf-banked-regs
ddf6fe37 21160@item -mrgf-banked-regs=@var{number}
d77de738
ML
21161Specifies the number of registers replicated in second register bank
21162on entry to fast interrupt. Fast interrupts are interrupts with the
21163highest priority level P0. These interrupts save only PC and STATUS32
21164registers to avoid memory transactions during interrupt entry and exit
21165sequences. Use this option when you are using fast interrupts in an
21166ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21167
d77de738 21168@opindex mlpc-width
ddf6fe37 21169@item -mlpc-width=@var{width}
d77de738
ML
21170Specify the width of the @code{lp_count} register. Valid values for
21171@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21172fixed to 32 bits. If the width is less than 32, the compiler does not
21173attempt to transform loops in your program to use the zero-delay loop
21174mechanism unless it is known that the @code{lp_count} register can
21175hold the required loop-counter value. Depending on the width
21176specified, the compiler and run-time library might continue to use the
21177loop mechanism for various needs. This option defines macro
21178@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21179
d77de738 21180@opindex mrf16
ddf6fe37 21181@item -mrf16
d77de738
ML
21182This option instructs the compiler to generate code for a 16-entry
21183register file. This option defines the @code{__ARC_RF16__}
21184preprocessor macro.
21185
d77de738 21186@opindex mbranch-index
ddf6fe37 21187@item -mbranch-index
d77de738
ML
21188Enable use of @code{bi} or @code{bih} instructions to implement jump
21189tables.
21190
21191@end table
21192
21193The following options are passed through to the assembler, and also
21194define preprocessor macro symbols.
21195
21196@c Flags used by the assembler, but for which we define preprocessor
21197@c macro symbols as well.
21198@table @gcctabopt
d77de738 21199@opindex mdsp-packa
ddf6fe37 21200@item -mdsp-packa
d77de738
ML
21201Passed down to the assembler to enable the DSP Pack A extensions.
21202Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21203deprecated.
21204
d77de738 21205@opindex mdvbf
ddf6fe37 21206@item -mdvbf
d77de738
ML
21207Passed down to the assembler to enable the dual Viterbi butterfly
21208extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21209option is deprecated.
21210
21211@c ARC700 4.10 extension instruction
d77de738 21212@opindex mlock
ddf6fe37 21213@item -mlock
d77de738
ML
21214Passed down to the assembler to enable the locked load/store
21215conditional extension. Also sets the preprocessor symbol
21216@code{__Xlock}.
21217
d77de738 21218@opindex mmac-d16
ddf6fe37 21219@item -mmac-d16
d77de738
ML
21220Passed down to the assembler. Also sets the preprocessor symbol
21221@code{__Xxmac_d16}. This option is deprecated.
21222
d77de738 21223@opindex mmac-24
ddf6fe37 21224@item -mmac-24
d77de738
ML
21225Passed down to the assembler. Also sets the preprocessor symbol
21226@code{__Xxmac_24}. This option is deprecated.
21227
21228@c ARC700 4.10 extension instruction
d77de738 21229@opindex mrtsc
ddf6fe37 21230@item -mrtsc
d77de738
ML
21231Passed down to the assembler to enable the 64-bit time-stamp counter
21232extension instruction. Also sets the preprocessor symbol
21233@code{__Xrtsc}. This option is deprecated.
21234
21235@c ARC700 4.10 extension instruction
d77de738 21236@opindex mswape
ddf6fe37 21237@item -mswape
d77de738
ML
21238Passed down to the assembler to enable the swap byte ordering
21239extension instruction. Also sets the preprocessor symbol
21240@code{__Xswape}.
21241
d77de738 21242@opindex mtelephony
ddf6fe37 21243@item -mtelephony
d77de738
ML
21244Passed down to the assembler to enable dual- and single-operand
21245instructions for telephony. Also sets the preprocessor symbol
21246@code{__Xtelephony}. This option is deprecated.
21247
d77de738 21248@opindex mxy
ddf6fe37 21249@item -mxy
d77de738
ML
21250Passed down to the assembler to enable the XY memory extension. Also
21251sets the preprocessor symbol @code{__Xxy}.
21252
21253@end table
21254
21255The following options control how the assembly code is annotated:
21256
21257@c Assembly annotation options
21258@table @gcctabopt
d77de738 21259@opindex misize
ddf6fe37 21260@item -misize
d77de738
ML
21261Annotate assembler instructions with estimated addresses.
21262
d77de738 21263@opindex mannotate-align
ddf6fe37 21264@item -mannotate-align
d77de738
ML
21265Explain what alignment considerations lead to the decision to make an
21266instruction short or long.
21267
21268@end table
21269
21270The following options are passed through to the linker:
21271
21272@c options passed through to the linker
21273@table @gcctabopt
d77de738 21274@opindex marclinux
ddf6fe37 21275@item -marclinux
d77de738
ML
21276Passed through to the linker, to specify use of the @code{arclinux} emulation.
21277This option is enabled by default in tool chains built for
21278@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21279when profiling is not requested.
21280
d77de738 21281@opindex marclinux_prof
ddf6fe37 21282@item -marclinux_prof
d77de738
ML
21283Passed through to the linker, to specify use of the
21284@code{arclinux_prof} emulation. This option is enabled by default in
21285tool chains built for @w{@code{arc-linux-uclibc}} and
21286@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21287
21288@end table
21289
21290The following options control the semantics of generated code:
21291
21292@c semantically relevant code generation options
21293@table @gcctabopt
d77de738 21294@opindex mlong-calls
ddf6fe37 21295@item -mlong-calls
d77de738
ML
21296Generate calls as register indirect calls, thus providing access
21297to the full 32-bit address range.
21298
d77de738 21299@opindex mmedium-calls
ddf6fe37 21300@item -mmedium-calls
d77de738
ML
21301Don't use less than 25-bit addressing range for calls, which is the
21302offset available for an unconditional branch-and-link
21303instruction. Conditional execution of function calls is suppressed, to
21304allow use of the 25-bit range, rather than the 21-bit range with
21305conditional branch-and-link. This is the default for tool chains built
21306for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21307
d77de738 21308@opindex G
ddf6fe37 21309@item -G @var{num}
d77de738
ML
21310Put definitions of externally-visible data in a small data section if
21311that data is no bigger than @var{num} bytes. The default value of
21312@var{num} is 4 for any ARC configuration, or 8 when we have double
21313load/store operations.
21314
d77de738
ML
21315@opindex mno-sdata
21316@opindex msdata
ddf6fe37 21317@item -mno-sdata
d77de738
ML
21318Do not generate sdata references. This is the default for tool chains
21319built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21320targets.
21321
d77de738 21322@opindex mvolatile-cache
ddf6fe37 21323@item -mvolatile-cache
d77de738
ML
21324Use ordinarily cached memory accesses for volatile references. This is the
21325default.
21326
d77de738
ML
21327@opindex mno-volatile-cache
21328@opindex mvolatile-cache
ddf6fe37 21329@item -mno-volatile-cache
d77de738
ML
21330Enable cache bypass for volatile references.
21331
21332@end table
21333
21334The following options fine tune code generation:
21335@c code generation tuning options
21336@table @gcctabopt
d77de738 21337@opindex malign-call
ddf6fe37 21338@item -malign-call
d77de738
ML
21339Does nothing. Preserved for backward compatibility.
21340
d77de738 21341@opindex mauto-modify-reg
ddf6fe37 21342@item -mauto-modify-reg
d77de738
ML
21343Enable the use of pre/post modify with register displacement.
21344
d77de738 21345@opindex mbbit-peephole
ddf6fe37 21346@item -mbbit-peephole
d77de738
ML
21347Enable bbit peephole2.
21348
d77de738 21349@opindex mno-brcc
ddf6fe37 21350@item -mno-brcc
d77de738
ML
21351This option disables a target-specific pass in @file{arc_reorg} to
21352generate compare-and-branch (@code{br@var{cc}}) instructions.
21353It has no effect on
21354generation of these instructions driven by the combiner pass.
21355
d77de738 21356@opindex mcase-vector-pcrel
ddf6fe37 21357@item -mcase-vector-pcrel
d77de738
ML
21358Use PC-relative switch case tables to enable case table shortening.
21359This is the default for @option{-Os}.
21360
d77de738 21361@opindex mcompact-casesi
ddf6fe37 21362@item -mcompact-casesi
d77de738
ML
21363Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21364and only available for ARCv1 cores. This option is deprecated.
21365
d77de738 21366@opindex mno-cond-exec
ddf6fe37 21367@item -mno-cond-exec
d77de738
ML
21368Disable the ARCompact-specific pass to generate conditional
21369execution instructions.
21370
21371Due to delay slot scheduling and interactions between operand numbers,
21372literal sizes, instruction lengths, and the support for conditional execution,
21373the target-independent pass to generate conditional execution is often lacking,
21374so the ARC port has kept a special pass around that tries to find more
21375conditional execution generation opportunities after register allocation,
21376branch shortening, and delay slot scheduling have been done. This pass
21377generally, but not always, improves performance and code size, at the cost of
21378extra compilation time, which is why there is an option to switch it off.
21379If you have a problem with call instructions exceeding their allowable
21380offset range because they are conditionalized, you should consider using
21381@option{-mmedium-calls} instead.
21382
d77de738 21383@opindex mearly-cbranchsi
ddf6fe37 21384@item -mearly-cbranchsi
d77de738
ML
21385Enable pre-reload use of the @code{cbranchsi} pattern.
21386
d77de738 21387@opindex mexpand-adddi
ddf6fe37 21388@item -mexpand-adddi
d77de738
ML
21389Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21390@code{add.f}, @code{adc} etc. This option is deprecated.
21391
d77de738 21392@opindex mindexed-loads
ddf6fe37 21393@item -mindexed-loads
d77de738
ML
21394Enable the use of indexed loads. This can be problematic because some
21395optimizers then assume that indexed stores exist, which is not
21396the case.
21397
d77de738 21398@opindex mlra
ddf6fe37 21399@item -mlra
d77de738
ML
21400Enable Local Register Allocation. This is still experimental for ARC,
21401so by default the compiler uses standard reload
21402(i.e.@: @option{-mno-lra}).
21403
d77de738 21404@opindex mlra-priority-none
ddf6fe37 21405@item -mlra-priority-none
d77de738
ML
21406Don't indicate any priority for target registers.
21407
d77de738 21408@opindex mlra-priority-compact
ddf6fe37 21409@item -mlra-priority-compact
d77de738
ML
21410Indicate target register priority for r0..r3 / r12..r15.
21411
d77de738 21412@opindex mlra-priority-noncompact
ddf6fe37 21413@item -mlra-priority-noncompact
d77de738
ML
21414Reduce target register priority for r0..r3 / r12..r15.
21415
d77de738 21416@opindex mmillicode
ddf6fe37 21417@item -mmillicode
d77de738
ML
21418When optimizing for size (using @option{-Os}), prologues and epilogues
21419that have to save or restore a large number of registers are often
21420shortened by using call to a special function in libgcc; this is
21421referred to as a @emph{millicode} call. As these calls can pose
21422performance issues, and/or cause linking issues when linking in a
21423nonstandard way, this option is provided to turn on or off millicode
21424call generation.
21425
d77de738 21426@opindex mcode-density-frame
ddf6fe37 21427@item -mcode-density-frame
d77de738
ML
21428This option enable the compiler to emit @code{enter} and @code{leave}
21429instructions. These instructions are only valid for CPUs with
21430code-density feature.
21431
d77de738 21432@opindex mmixed-code
ddf6fe37 21433@item -mmixed-code
d77de738
ML
21434Does nothing. Preserved for backward compatibility.
21435
d77de738 21436@opindex mq-class
ddf6fe37 21437@item -mq-class
d77de738
ML
21438Ths option is deprecated. Enable @samp{q} instruction alternatives.
21439This is the default for @option{-Os}.
21440
d77de738 21441@opindex mRcq
ddf6fe37 21442@item -mRcq
d77de738
ML
21443Does nothing. Preserved for backward compatibility.
21444
d77de738 21445@opindex mRcw
ddf6fe37 21446@item -mRcw
d77de738
ML
21447Does nothing. Preserved for backward compatibility.
21448
d77de738 21449@opindex msize-level
ddf6fe37 21450@item -msize-level=@var{level}
d77de738
ML
21451Fine-tune size optimization with regards to instruction lengths and alignment.
21452The recognized values for @var{level} are:
21453@table @samp
21454@item 0
21455No size optimization. This level is deprecated and treated like @samp{1}.
21456
21457@item 1
21458Short instructions are used opportunistically.
21459
21460@item 2
21461In addition, alignment of loops and of code after barriers are dropped.
21462
21463@item 3
21464In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21465
21466@end table
21467
21468This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21469the behavior when this is not set is equivalent to level @samp{1}.
21470
d77de738 21471@opindex mtune
ddf6fe37 21472@item -mtune=@var{cpu}
d77de738
ML
21473Set instruction scheduling parameters for @var{cpu}, overriding any implied
21474by @option{-mcpu=}.
21475
21476Supported values for @var{cpu} are
21477
21478@table @samp
21479@item ARC600
21480Tune for ARC600 CPU.
21481
21482@item ARC601
21483Tune for ARC601 CPU.
21484
21485@item ARC700
21486Tune for ARC700 CPU with standard multiplier block.
21487
21488@item ARC700-xmac
21489Tune for ARC700 CPU with XMAC block.
21490
21491@item ARC725D
21492Tune for ARC725D CPU.
21493
21494@item ARC750D
21495Tune for ARC750D CPU.
21496
21497@item core3
21498Tune for ARCv2 core3 type CPU. This option enable usage of
21499@code{dbnz} instruction.
21500
21501@item release31a
21502Tune for ARC4x release 3.10a.
21503
21504@end table
21505
d77de738 21506@opindex mmultcost
ddf6fe37 21507@item -mmultcost=@var{num}
d77de738
ML
21508Cost to assume for a multiply instruction, with @samp{4} being equal to a
21509normal instruction.
21510
d77de738 21511@opindex munalign-prob-threshold
ddf6fe37 21512@item -munalign-prob-threshold=@var{probability}
d77de738
ML
21513Does nothing. Preserved for backward compatibility.
21514
21515@end table
21516
21517The following options are maintained for backward compatibility, but
21518are now deprecated and will be removed in a future release:
21519
21520@c Deprecated options
21521@table @gcctabopt
21522
d77de738 21523@opindex margonaut
ddf6fe37 21524@item -margonaut
d77de738
ML
21525Obsolete FPX.
21526
d77de738 21527@opindex mbig-endian
d77de738 21528@opindex EB
ddf6fe37
AA
21529@item -mbig-endian
21530@itemx -EB
d77de738
ML
21531Compile code for big-endian targets. Use of these options is now
21532deprecated. Big-endian code is supported by configuring GCC to build
21533@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21534for which big endian is the default.
21535
d77de738 21536@opindex mlittle-endian
d77de738 21537@opindex EL
ddf6fe37
AA
21538@item -mlittle-endian
21539@itemx -EL
d77de738
ML
21540Compile code for little-endian targets. Use of these options is now
21541deprecated. Little-endian code is supported by configuring GCC to build
21542@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21543for which little endian is the default.
21544
d77de738 21545@opindex mbarrel_shifter
ddf6fe37 21546@item -mbarrel_shifter
d77de738
ML
21547Replaced by @option{-mbarrel-shifter}.
21548
d77de738 21549@opindex mdpfp_compact
ddf6fe37 21550@item -mdpfp_compact
d77de738
ML
21551Replaced by @option{-mdpfp-compact}.
21552
d77de738 21553@opindex mdpfp_fast
ddf6fe37 21554@item -mdpfp_fast
d77de738
ML
21555Replaced by @option{-mdpfp-fast}.
21556
d77de738 21557@opindex mdsp_packa
ddf6fe37 21558@item -mdsp_packa
d77de738
ML
21559Replaced by @option{-mdsp-packa}.
21560
d77de738 21561@opindex mEA
ddf6fe37 21562@item -mEA
d77de738
ML
21563Replaced by @option{-mea}.
21564
d77de738 21565@opindex mmac_24
ddf6fe37 21566@item -mmac_24
d77de738
ML
21567Replaced by @option{-mmac-24}.
21568
d77de738 21569@opindex mmac_d16
ddf6fe37 21570@item -mmac_d16
d77de738
ML
21571Replaced by @option{-mmac-d16}.
21572
d77de738 21573@opindex mspfp_compact
ddf6fe37 21574@item -mspfp_compact
d77de738
ML
21575Replaced by @option{-mspfp-compact}.
21576
d77de738 21577@opindex mspfp_fast
ddf6fe37 21578@item -mspfp_fast
d77de738
ML
21579Replaced by @option{-mspfp-fast}.
21580
d77de738 21581@opindex mtune
ddf6fe37 21582@item -mtune=@var{cpu}
d77de738
ML
21583Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21584@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21585@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21586
d77de738 21587@opindex multcost
ddf6fe37 21588@item -multcost=@var{num}
d77de738
ML
21589Replaced by @option{-mmultcost}.
21590
21591@end table
21592
21593@node ARM Options
21594@subsection ARM Options
21595@cindex ARM options
21596
21597These @samp{-m} options are defined for the ARM port:
21598
21599@table @gcctabopt
d77de738 21600@opindex mabi
ddf6fe37 21601@item -mabi=@var{name}
d77de738
ML
21602Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21603@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21604
d77de738 21605@opindex mapcs-frame
ddf6fe37 21606@item -mapcs-frame
d77de738
ML
21607Generate a stack frame that is compliant with the ARM Procedure Call
21608Standard for all functions, even if this is not strictly necessary for
21609correct execution of the code. Specifying @option{-fomit-frame-pointer}
21610with this option causes the stack frames not to be generated for
21611leaf functions. The default is @option{-mno-apcs-frame}.
21612This option is deprecated.
21613
d77de738 21614@opindex mapcs
ddf6fe37 21615@item -mapcs
d77de738
ML
21616This is a synonym for @option{-mapcs-frame} and is deprecated.
21617
21618@ignore
21619@c not currently implemented
d77de738 21620@opindex mapcs-stack-check
ddf6fe37 21621@item -mapcs-stack-check
d77de738
ML
21622Generate code to check the amount of stack space available upon entry to
21623every function (that actually uses some stack space). If there is
21624insufficient space available then either the function
21625@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21626called, depending upon the amount of stack space required. The runtime
21627system is required to provide these functions. The default is
21628@option{-mno-apcs-stack-check}, since this produces smaller code.
21629
21630@c not currently implemented
d77de738 21631@opindex mapcs-reentrant
ddf6fe37 21632@item -mapcs-reentrant
d77de738
ML
21633Generate reentrant, position-independent code. The default is
21634@option{-mno-apcs-reentrant}.
21635@end ignore
21636
d77de738 21637@opindex mthumb-interwork
ddf6fe37 21638@item -mthumb-interwork
d77de738
ML
21639Generate code that supports calling between the ARM and Thumb
21640instruction sets. Without this option, on pre-v5 architectures, the
21641two instruction sets cannot be reliably used inside one program. The
21642default is @option{-mno-thumb-interwork}, since slightly larger code
21643is generated when @option{-mthumb-interwork} is specified. In AAPCS
21644configurations this option is meaningless.
21645
d77de738
ML
21646@opindex mno-sched-prolog
21647@opindex msched-prolog
ddf6fe37 21648@item -mno-sched-prolog
d77de738
ML
21649Prevent the reordering of instructions in the function prologue, or the
21650merging of those instruction with the instructions in the function's
21651body. This means that all functions start with a recognizable set
21652of instructions (or in fact one of a choice from a small set of
21653different function prologues), and this information can be used to
21654locate the start of functions inside an executable piece of code. The
21655default is @option{-msched-prolog}.
21656
d77de738 21657@opindex mfloat-abi
ddf6fe37 21658@item -mfloat-abi=@var{name}
d77de738
ML
21659Specifies which floating-point ABI to use. Permissible values
21660are: @samp{soft}, @samp{softfp} and @samp{hard}.
21661
21662Specifying @samp{soft} causes GCC to generate output containing
21663library calls for floating-point operations.
21664@samp{softfp} allows the generation of code using hardware floating-point
21665instructions, but still uses the soft-float calling conventions.
21666@samp{hard} allows generation of floating-point instructions
21667and uses FPU-specific calling conventions.
21668
21669The default depends on the specific target configuration. Note that
21670the hard-float and soft-float ABIs are not link-compatible; you must
21671compile your entire program with the same ABI, and link with a
21672compatible set of libraries.
21673
d77de738 21674@opindex mgeneral-regs-only
ddf6fe37 21675@item -mgeneral-regs-only
d77de738
ML
21676Generate code which uses only the general-purpose registers. This will prevent
21677the compiler from using floating-point and Advanced SIMD registers but will not
21678impose any restrictions on the assembler.
21679
d77de738 21680@opindex mlittle-endian
ddf6fe37 21681@item -mlittle-endian
d77de738
ML
21682Generate code for a processor running in little-endian mode. This is
21683the default for all standard configurations.
21684
d77de738 21685@opindex mbig-endian
ddf6fe37 21686@item -mbig-endian
d77de738
ML
21687Generate code for a processor running in big-endian mode; the default is
21688to compile code for a little-endian processor.
21689
ddf6fe37 21690@opindex mbe8
d77de738
ML
21691@item -mbe8
21692@itemx -mbe32
d77de738
ML
21693When linking a big-endian image select between BE8 and BE32 formats.
21694The option has no effect for little-endian images and is ignored. The
21695default is dependent on the selected target architecture. For ARMv6
21696and later architectures the default is BE8, for older architectures
21697the default is BE32. BE32 format has been deprecated by ARM.
21698
d77de738 21699@opindex march
ddf6fe37 21700@item -march=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
21701This specifies the name of the target ARM architecture. GCC uses this
21702name to determine what kind of instructions it can emit when generating
21703assembly code. This option can be used in conjunction with or instead
21704of the @option{-mcpu=} option.
21705
21706Permissible names are:
21707@samp{armv4t},
21708@samp{armv5t}, @samp{armv5te},
21709@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
21710@samp{armv6z}, @samp{armv6zk},
21711@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
21712@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
21713@samp{armv8.4-a},
21714@samp{armv8.5-a},
21715@samp{armv8.6-a},
21716@samp{armv9-a},
21717@samp{armv7-r},
21718@samp{armv8-r},
21719@samp{armv6-m}, @samp{armv6s-m},
21720@samp{armv7-m}, @samp{armv7e-m},
21721@samp{armv8-m.base}, @samp{armv8-m.main},
21722@samp{armv8.1-m.main},
21723@samp{armv9-a},
21724@samp{iwmmxt} and @samp{iwmmxt2}.
21725
21726Additionally, the following architectures, which lack support for the
21727Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
21728
21729Many of the architectures support extensions. These can be added by
21730appending @samp{+@var{extension}} to the architecture name. Extension
21731options are processed in order and capabilities accumulate. An extension
21732will also enable any necessary base extensions
21733upon which it depends. For example, the @samp{+crypto} extension
21734will always enable the @samp{+simd} extension. The exception to the
21735additive construction is for extensions that are prefixed with
21736@samp{+no@dots{}}: these extensions disable the specified option and
21737any other extensions that may depend on the presence of that
21738extension.
21739
21740For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
21741writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
21742entirely disabled by the @samp{+nofp} option that follows it.
21743
21744Most extension names are generically named, but have an effect that is
21745dependent upon the architecture to which it is applied. For example,
21746the @samp{+simd} option can be applied to both @samp{armv7-a} and
21747@samp{armv8-a} architectures, but will enable the original ARMv7-A
21748Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
21749variant for @samp{armv8-a}.
21750
21751The table below lists the supported extensions for each architecture.
21752Architectures not mentioned do not support any extensions.
21753
21754@table @samp
21755@item armv5te
21756@itemx armv6
21757@itemx armv6j
21758@itemx armv6k
21759@itemx armv6kz
21760@itemx armv6t2
21761@itemx armv6z
21762@itemx armv6zk
21763@table @samp
21764@item +fp
21765The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
21766used as an alias for this extension.
21767
21768@item +nofp
21769Disable the floating-point instructions.
21770@end table
21771
21772@item armv7
21773The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
21774@table @samp
21775@item +fp
21776The VFPv3 floating-point instructions, with 16 double-precision
21777registers. The extension @samp{+vfpv3-d16} can be used as an alias
21778for this extension. Note that floating-point is not supported by the
21779base ARMv7-M architecture, but is compatible with both the ARMv7-A and
21780ARMv7-R architectures.
21781
21782@item +nofp
21783Disable the floating-point instructions.
21784@end table
21785
21786@item armv7-a
21787@table @samp
21788@item +mp
21789The multiprocessing extension.
21790
21791@item +sec
21792The security extension.
21793
21794@item +fp
21795The VFPv3 floating-point instructions, with 16 double-precision
21796registers. The extension @samp{+vfpv3-d16} can be used as an alias
21797for this extension.
21798
21799@item +simd
21800The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21801The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
21802for this extension.
21803
21804@item +vfpv3
21805The VFPv3 floating-point instructions, with 32 double-precision
21806registers.
21807
21808@item +vfpv3-d16-fp16
21809The VFPv3 floating-point instructions, with 16 double-precision
21810registers and the half-precision floating-point conversion operations.
21811
21812@item +vfpv3-fp16
21813The VFPv3 floating-point instructions, with 32 double-precision
21814registers and the half-precision floating-point conversion operations.
21815
21816@item +vfpv4-d16
21817The VFPv4 floating-point instructions, with 16 double-precision
21818registers.
21819
21820@item +vfpv4
21821The VFPv4 floating-point instructions, with 32 double-precision
21822registers.
21823
21824@item +neon-fp16
21825The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21826the half-precision floating-point conversion operations.
21827
21828@item +neon-vfpv4
21829The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
21830
21831@item +nosimd
21832Disable the Advanced SIMD instructions (does not disable floating point).
21833
21834@item +nofp
21835Disable the floating-point and Advanced SIMD instructions.
21836@end table
21837
21838@item armv7ve
21839The extended version of the ARMv7-A architecture with support for
21840virtualization.
21841@table @samp
21842@item +fp
21843The VFPv4 floating-point instructions, with 16 double-precision registers.
21844The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
21845
21846@item +simd
21847The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
21848extension @samp{+neon-vfpv4} can be used as an alias for this extension.
21849
21850@item +vfpv3-d16
21851The VFPv3 floating-point instructions, with 16 double-precision
21852registers.
21853
21854@item +vfpv3
21855The VFPv3 floating-point instructions, with 32 double-precision
21856registers.
21857
21858@item +vfpv3-d16-fp16
21859The VFPv3 floating-point instructions, with 16 double-precision
21860registers and the half-precision floating-point conversion operations.
21861
21862@item +vfpv3-fp16
21863The VFPv3 floating-point instructions, with 32 double-precision
21864registers and the half-precision floating-point conversion operations.
21865
21866@item +vfpv4-d16
21867The VFPv4 floating-point instructions, with 16 double-precision
21868registers.
21869
21870@item +vfpv4
21871The VFPv4 floating-point instructions, with 32 double-precision
21872registers.
21873
21874@item +neon
21875The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21876The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
21877
21878@item +neon-fp16
21879The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21880the half-precision floating-point conversion operations.
21881
21882@item +nosimd
21883Disable the Advanced SIMD instructions (does not disable floating point).
21884
21885@item +nofp
21886Disable the floating-point and Advanced SIMD instructions.
21887@end table
21888
21889@item armv8-a
21890@table @samp
21891@item +crc
21892The Cyclic Redundancy Check (CRC) instructions.
21893@item +simd
21894The ARMv8-A Advanced SIMD and floating-point instructions.
21895@item +crypto
21896The cryptographic instructions.
21897@item +nocrypto
21898Disable the cryptographic instructions.
21899@item +nofp
21900Disable the floating-point, Advanced SIMD and cryptographic instructions.
21901@item +sb
21902Speculation Barrier Instruction.
21903@item +predres
21904Execution and Data Prediction Restriction Instructions.
21905@end table
21906
21907@item armv8.1-a
21908@table @samp
21909@item +simd
21910The ARMv8.1-A Advanced SIMD and floating-point instructions.
21911
21912@item +crypto
21913The cryptographic instructions. This also enables the Advanced SIMD and
21914floating-point instructions.
21915
21916@item +nocrypto
21917Disable the cryptographic instructions.
21918
21919@item +nofp
21920Disable the floating-point, Advanced SIMD and cryptographic instructions.
21921
21922@item +sb
21923Speculation Barrier Instruction.
21924
21925@item +predres
21926Execution and Data Prediction Restriction Instructions.
21927@end table
21928
21929@item armv8.2-a
21930@itemx armv8.3-a
21931@table @samp
21932@item +fp16
21933The half-precision floating-point data processing instructions.
21934This also enables the Advanced SIMD and floating-point instructions.
21935
21936@item +fp16fml
21937The half-precision floating-point fmla extension. This also enables
21938the half-precision floating-point extension and Advanced SIMD and
21939floating-point instructions.
21940
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 +dotprod
21949Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21950
21951@item +nocrypto
21952Disable the cryptographic extension.
21953
21954@item +nofp
21955Disable the floating-point, Advanced SIMD and cryptographic instructions.
21956
21957@item +sb
21958Speculation Barrier Instruction.
21959
21960@item +predres
21961Execution and Data Prediction Restriction Instructions.
21962
21963@item +i8mm
219648-bit Integer Matrix Multiply instructions.
21965This also enables Advanced SIMD and floating-point instructions.
21966
21967@item +bf16
21968Brain half-precision floating-point instructions.
21969This also enables Advanced SIMD and floating-point instructions.
21970@end table
21971
21972@item armv8.4-a
21973@table @samp
21974@item +fp16
21975The half-precision floating-point data processing instructions.
21976This also enables the Advanced SIMD and floating-point instructions as well
21977as the Dot Product extension and the half-precision floating-point fmla
21978extension.
21979
21980@item +simd
21981The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21982Dot Product extension.
21983
21984@item +crypto
21985The cryptographic instructions. This also enables the Advanced SIMD and
21986floating-point instructions as well as the Dot Product extension.
21987
21988@item +nocrypto
21989Disable the cryptographic extension.
21990
21991@item +nofp
21992Disable the floating-point, Advanced SIMD and cryptographic instructions.
21993
21994@item +sb
21995Speculation Barrier Instruction.
21996
21997@item +predres
21998Execution and Data Prediction Restriction Instructions.
21999
22000@item +i8mm
220018-bit Integer Matrix Multiply instructions.
22002This also enables Advanced SIMD and floating-point instructions.
22003
22004@item +bf16
22005Brain half-precision floating-point instructions.
22006This also enables Advanced SIMD and floating-point instructions.
22007@end table
22008
22009@item armv8.5-a
22010@table @samp
22011@item +fp16
22012The half-precision floating-point data processing instructions.
22013This also enables the Advanced SIMD and floating-point instructions as well
22014as the Dot Product extension and the half-precision floating-point fmla
22015extension.
22016
22017@item +simd
22018The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22019Dot Product extension.
22020
22021@item +crypto
22022The cryptographic instructions. This also enables the Advanced SIMD and
22023floating-point instructions as well as the Dot Product extension.
22024
22025@item +nocrypto
22026Disable the cryptographic extension.
22027
22028@item +nofp
22029Disable the floating-point, Advanced SIMD and cryptographic instructions.
22030
22031@item +i8mm
220328-bit Integer Matrix Multiply instructions.
22033This also enables Advanced SIMD and floating-point instructions.
22034
22035@item +bf16
22036Brain half-precision floating-point instructions.
22037This also enables Advanced SIMD and floating-point instructions.
22038@end table
22039
22040@item armv8.6-a
22041@table @samp
22042@item +fp16
22043The half-precision floating-point data processing instructions.
22044This also enables the Advanced SIMD and floating-point instructions as well
22045as the Dot Product extension and the half-precision floating-point fmla
22046extension.
22047
22048@item +simd
22049The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
22050Dot Product extension.
22051
22052@item +crypto
22053The cryptographic instructions. This also enables the Advanced SIMD and
22054floating-point instructions as well as the Dot Product extension.
22055
22056@item +nocrypto
22057Disable the cryptographic extension.
22058
22059@item +nofp
22060Disable the floating-point, Advanced SIMD and cryptographic instructions.
22061
22062@item +i8mm
220638-bit Integer Matrix Multiply instructions.
22064This also enables Advanced SIMD and floating-point instructions.
22065
22066@item +bf16
22067Brain half-precision floating-point instructions.
22068This also enables Advanced SIMD and floating-point instructions.
22069@end table
22070
22071@item armv7-r
22072@table @samp
22073@item +fp.sp
22074The single-precision VFPv3 floating-point instructions. The extension
22075@samp{+vfpv3xd} can be used as an alias for this extension.
22076
22077@item +fp
22078The VFPv3 floating-point instructions with 16 double-precision registers.
22079The extension +vfpv3-d16 can be used as an alias for this extension.
22080
22081@item +vfpv3xd-d16-fp16
22082The single-precision VFPv3 floating-point instructions with 16 double-precision
22083registers and the half-precision floating-point conversion operations.
22084
22085@item +vfpv3-d16-fp16
22086The VFPv3 floating-point instructions with 16 double-precision
22087registers and the half-precision floating-point conversion operations.
22088
22089@item +nofp
22090Disable the floating-point extension.
22091
22092@item +idiv
22093The ARM-state integer division instructions.
22094
22095@item +noidiv
22096Disable the ARM-state integer division extension.
22097@end table
22098
22099@item armv7e-m
22100@table @samp
22101@item +fp
22102The single-precision VFPv4 floating-point instructions.
22103
22104@item +fpv5
22105The single-precision FPv5 floating-point instructions.
22106
22107@item +fp.dp
22108The single- and double-precision FPv5 floating-point instructions.
22109
22110@item +nofp
22111Disable the floating-point extensions.
22112@end table
22113
22114@item armv8.1-m.main
22115@table @samp
22116
22117@item +dsp
22118The DSP instructions.
22119
22120@item +mve
22121The M-Profile Vector Extension (MVE) integer instructions.
22122
22123@item +mve.fp
22124The M-Profile Vector Extension (MVE) integer and single precision
22125floating-point instructions.
22126
22127@item +fp
22128The single-precision floating-point instructions.
22129
22130@item +fp.dp
22131The single- and double-precision floating-point instructions.
22132
22133@item +nofp
22134Disable the floating-point extension.
22135
22136@item +cdecp0, +cdecp1, ... , +cdecp7
22137Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22138to the numbers given in the options in the range 0 to 7.
c91bb7b9
AC
22139
22140@item +pacbti
22141Enable the Pointer Authentication and Branch Target Identification Extension.
d77de738
ML
22142@end table
22143
22144@item armv8-m.main
22145@table @samp
22146@item +dsp
22147The DSP instructions.
22148
22149@item +nodsp
22150Disable the DSP extension.
22151
22152@item +fp
22153The single-precision floating-point instructions.
22154
22155@item +fp.dp
22156The single- and double-precision floating-point instructions.
22157
22158@item +nofp
22159Disable the floating-point extension.
22160
22161@item +cdecp0, +cdecp1, ... , +cdecp7
22162Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22163to the numbers given in the options in the range 0 to 7.
22164@end table
22165
22166@item armv8-r
22167@table @samp
22168@item +crc
22169The Cyclic Redundancy Check (CRC) instructions.
22170@item +fp.sp
22171The single-precision FPv5 floating-point instructions.
22172@item +simd
22173The ARMv8-A Advanced SIMD and floating-point instructions.
22174@item +crypto
22175The cryptographic instructions.
22176@item +nocrypto
22177Disable the cryptographic instructions.
22178@item +nofp
22179Disable the floating-point, Advanced SIMD and cryptographic instructions.
22180@end table
22181
22182@end table
22183
22184@option{-march=native} causes the compiler to auto-detect the architecture
22185of the build computer. At present, this feature is only supported on
22186GNU/Linux, and not all architectures are recognized. If the auto-detect
22187is unsuccessful the option has no effect.
22188
d77de738 22189@opindex mtune
ddf6fe37 22190@item -mtune=@var{name}
d77de738
ML
22191This option specifies the name of the target ARM processor for
22192which GCC should tune the performance of the code.
22193For some ARM implementations better performance can be obtained by using
22194this option.
22195Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22196@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22197@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22198@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22199@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22200@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22201@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22202@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22203@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22204@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22205@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22206@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22207@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22208@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22209@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22210@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22211@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22212@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22213@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
ccfd1e7f
SP
22214@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1},
22215@samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
d77de738
ML
22216@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22217@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22218@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22219@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22220@samp{xgene1}.
22221
22222Additionally, this option can specify that GCC should tune the performance
22223of the code for a big.LITTLE system. Permissible names are:
22224@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22225@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22226@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22227@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22228
22229@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22230performance for a blend of processors within architecture @var{arch}.
22231The aim is to generate code that run well on the current most popular
22232processors, balancing between optimizations that benefit some CPUs in the
22233range, and avoiding performance pitfalls of other CPUs. The effects of
22234this option may change in future GCC versions as CPU models come and go.
22235
22236@option{-mtune} permits the same extension options as @option{-mcpu}, but
22237the extension options do not affect the tuning of the generated code.
22238
22239@option{-mtune=native} causes the compiler to auto-detect the CPU
22240of the build computer. At present, this feature is only supported on
22241GNU/Linux, and not all architectures are recognized. If the auto-detect is
22242unsuccessful the option has no effect.
22243
d77de738 22244@opindex mcpu
ddf6fe37 22245@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
d77de738
ML
22246This specifies the name of the target ARM processor. GCC uses this name
22247to derive the name of the target ARM architecture (as if specified
22248by @option{-march}) and the ARM processor type for which to tune for
22249performance (as if specified by @option{-mtune}). Where this option
22250is used in conjunction with @option{-march} or @option{-mtune},
22251those options take precedence over the appropriate part of this option.
22252
22253Many of the supported CPUs implement optional architectural
22254extensions. Where this is so the architectural extensions are
22255normally enabled by default. If implementations that lack the
22256extension exist, then the extension syntax can be used to disable
22257those extensions that have been omitted. For floating-point and
22258Advanced SIMD (Neon) instructions, the settings of the options
22259@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22260floating-point and Advanced SIMD instructions will only be used if
22261@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22262@option{-mfpu} other than @samp{auto} will override the available
22263floating-point and SIMD extension instructions.
22264
22265For example, @samp{cortex-a9} can be found in three major
22266configurations: integer only, with just a floating-point unit or with
22267floating-point and Advanced SIMD. The default is to enable all the
22268instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22269be used to disable just the SIMD or both the SIMD and floating-point
22270instructions respectively.
22271
22272Permissible names for this option are the same as those for
22273@option{-mtune}.
22274
22275The following extension options are common to the listed CPUs:
22276
22277@table @samp
22278@item +nodsp
ccfd1e7f
SP
22279Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p},
22280@samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector
22281Extension (MVE) integer and single precision floating-point instructions on
22282@samp{cortex-m55} and @samp{cortex-m85}.
22283
22284@item +nopacbti
22285Disable the Pointer Authentication and Branch Target Identification Extension
22286on @samp{cortex-m85}.
d77de738
ML
22287
22288@item +nomve
22289Disable the M-Profile Vector Extension (MVE) integer and single precision
ccfd1e7f 22290floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22291
22292@item +nomve.fp
22293Disable the M-Profile Vector Extension (MVE) single precision floating-point
ccfd1e7f 22294instructions on @samp{cortex-m55} and @samp{cortex-m85}.
d77de738 22295
798a0d05
SP
22296@item +cdecp0, +cdecp1, ... , +cdecp7
22297Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22298to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22299
d77de738
ML
22300@item +nofp
22301Disables the floating-point instructions on @samp{arm9e},
22302@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22303@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22304@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22305@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
ccfd1e7f
SP
22306@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p},
22307@samp{cortex-m55} and @samp{cortex-m85}.
d77de738
ML
22308Disables the floating-point and SIMD instructions on
22309@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22310@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22311@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22312@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22313@samp{cortex-a53} and @samp{cortex-a55}.
22314
22315@item +nofp.dp
22316Disables the double-precision component of the floating-point instructions
22317on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22318@samp{cortex-r52plus} and @samp{cortex-m7}.
22319
22320@item +nosimd
22321Disables the SIMD (but not floating-point) instructions on
22322@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22323and @samp{cortex-a9}.
22324
22325@item +crypto
22326Enables the cryptographic instructions on @samp{cortex-a32},
22327@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22328@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22329@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22330@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22331@samp{cortex-a75.cortex-a55}.
22332@end table
22333
22334Additionally the @samp{generic-armv7-a} pseudo target defaults to
22335VFPv3 with 16 double-precision registers. It supports the following
22336extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22337@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22338@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22339@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22340the extensions to @option{-march=armv7-a}.
22341
22342@option{-mcpu=generic-@var{arch}} is also permissible, and is
22343equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22344See @option{-mtune} for more information.
22345
22346@option{-mcpu=native} causes the compiler to auto-detect the CPU
22347of the build computer. At present, this feature is only supported on
22348GNU/Linux, and not all architectures are recognized. If the auto-detect
22349is unsuccessful the option has no effect.
22350
d77de738 22351@opindex mfpu
ddf6fe37 22352@item -mfpu=@var{name}
d77de738
ML
22353This specifies what floating-point hardware (or hardware emulation) is
22354available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22355@samp{vfpv3},
22356@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22357@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22358@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22359@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22360@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22361Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22362is an alias for @samp{vfpv2}.
22363
22364The setting @samp{auto} is the default and is special. It causes the
22365compiler to select the floating-point and Advanced SIMD instructions
22366based on the settings of @option{-mcpu} and @option{-march}.
22367
22368If the selected floating-point hardware includes the NEON extension
22369(e.g.@: @option{-mfpu=neon}), note that floating-point
22370operations are not generated by GCC's auto-vectorization pass unless
22371@option{-funsafe-math-optimizations} is also specified. This is
22372because NEON hardware does not fully implement the IEEE 754 standard for
22373floating-point arithmetic (in particular denormal values are treated as
22374zero), so the use of NEON instructions may lead to a loss of precision.
22375
22376You 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}).
22377
d77de738 22378@opindex mfp16-format
ddf6fe37 22379@item -mfp16-format=@var{name}
d77de738
ML
22380Specify the format of the @code{__fp16} half-precision floating-point type.
22381Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22382the default is @samp{none}, in which case the @code{__fp16} type is not
22383defined. @xref{Half-Precision}, for more information.
22384
d77de738 22385@opindex mstructure-size-boundary
ddf6fe37 22386@item -mstructure-size-boundary=@var{n}
d77de738
ML
22387The sizes of all structures and unions are rounded up to a multiple
22388of the number of bits set by this option. Permissible values are 8, 32
22389and 64. The default value varies for different toolchains. For the COFF
22390targeted toolchain the default value is 8. A value of 64 is only allowed
22391if the underlying ABI supports it.
22392
22393Specifying a larger number can produce faster, more efficient code, but
22394can also increase the size of the program. Different values are potentially
22395incompatible. Code compiled with one value cannot necessarily expect to
22396work with code or libraries compiled with another value, if they exchange
22397information using structures or unions.
22398
22399This option is deprecated.
22400
d77de738 22401@opindex mabort-on-noreturn
ddf6fe37 22402@item -mabort-on-noreturn
d77de738
ML
22403Generate a call to the function @code{abort} at the end of a
22404@code{noreturn} function. It is executed if the function tries to
22405return.
22406
d77de738
ML
22407@opindex mlong-calls
22408@opindex mno-long-calls
ddf6fe37
AA
22409@item -mlong-calls
22410@itemx -mno-long-calls
d77de738
ML
22411Tells the compiler to perform function calls by first loading the
22412address of the function into a register and then performing a subroutine
22413call on this register. This switch is needed if the target function
22414lies outside of the 64-megabyte addressing range of the offset-based
22415version of subroutine call instruction.
22416
22417Even if this switch is enabled, not all function calls are turned
22418into long calls. The heuristic is that static functions, functions
22419that have the @code{short_call} attribute, functions that are inside
22420the scope of a @code{#pragma no_long_calls} directive, and functions whose
22421definitions have already been compiled within the current compilation
22422unit are not turned into long calls. The exceptions to this rule are
22423that weak function definitions, functions with the @code{long_call}
22424attribute or the @code{section} attribute, and functions that are within
22425the scope of a @code{#pragma long_calls} directive are always
22426turned into long calls.
22427
22428This feature is not enabled by default. Specifying
22429@option{-mno-long-calls} restores the default behavior, as does
22430placing the function calls within the scope of a @code{#pragma
22431long_calls_off} directive. Note these switches have no effect on how
22432the compiler generates code to handle function calls via function
22433pointers.
22434
d77de738 22435@opindex msingle-pic-base
ddf6fe37 22436@item -msingle-pic-base
d77de738
ML
22437Treat the register used for PIC addressing as read-only, rather than
22438loading it in the prologue for each function. The runtime system is
22439responsible for initializing this register with an appropriate value
22440before execution begins.
22441
d77de738 22442@opindex mpic-register
ddf6fe37 22443@item -mpic-register=@var{reg}
d77de738
ML
22444Specify the register to be used for PIC addressing.
22445For standard PIC base case, the default is any suitable register
22446determined by compiler. For single PIC base case, the default is
22447@samp{R9} if target is EABI based or stack-checking is enabled,
22448otherwise the default is @samp{R10}.
22449
d77de738 22450@opindex mpic-data-is-text-relative
ddf6fe37 22451@item -mpic-data-is-text-relative
d77de738
ML
22452Assume that the displacement between the text and data segments is fixed
22453at static link time. This permits using PC-relative addressing
22454operations to access data known to be in the data segment. For
22455non-VxWorks RTP targets, this option is enabled by default. When
22456disabled on such targets, it will enable @option{-msingle-pic-base} by
22457default.
22458
d77de738 22459@opindex mpoke-function-name
ddf6fe37 22460@item -mpoke-function-name
d77de738
ML
22461Write the name of each function into the text section, directly
22462preceding the function prologue. The generated code is similar to this:
22463
22464@smallexample
22465 t0
22466 .ascii "arm_poke_function_name", 0
22467 .align
22468 t1
22469 .word 0xff000000 + (t1 - t0)
22470 arm_poke_function_name
22471 mov ip, sp
22472 stmfd sp!, @{fp, ip, lr, pc@}
22473 sub fp, ip, #4
22474@end smallexample
22475
22476When performing a stack backtrace, code can inspect the value of
22477@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22478location @code{pc - 12} and the top 8 bits are set, then we know that
22479there is a function name embedded immediately preceding this location
22480and has length @code{((pc[-3]) & 0xff000000)}.
22481
d77de738
ML
22482@opindex marm
22483@opindex mthumb
ddf6fe37
AA
22484@item -mthumb
22485@itemx -marm
d77de738
ML
22486
22487Select between generating code that executes in ARM and Thumb
22488states. The default for most configurations is to generate code
22489that executes in ARM state, but the default can be changed by
22490configuring GCC with the @option{--with-mode=}@var{state}
22491configure option.
22492
22493You can also override the ARM and Thumb mode for each function
22494by using the @code{target("thumb")} and @code{target("arm")} function attributes
22495(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22496
d77de738 22497@opindex mflip-thumb
ddf6fe37 22498@item -mflip-thumb
d77de738
ML
22499Switch ARM/Thumb modes on alternating functions.
22500This option is provided for regression testing of mixed Thumb/ARM code
22501generation, and is not intended for ordinary use in compiling code.
22502
d77de738 22503@opindex mtpcs-frame
ddf6fe37 22504@item -mtpcs-frame
d77de738
ML
22505Generate a stack frame that is compliant with the Thumb Procedure Call
22506Standard for all non-leaf functions. (A leaf function is one that does
22507not call any other functions.) The default is @option{-mno-tpcs-frame}.
22508
d77de738 22509@opindex mtpcs-leaf-frame
ddf6fe37 22510@item -mtpcs-leaf-frame
d77de738
ML
22511Generate a stack frame that is compliant with the Thumb Procedure Call
22512Standard for all leaf functions. (A leaf function is one that does
22513not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22514
d77de738 22515@opindex mcallee-super-interworking
ddf6fe37 22516@item -mcallee-super-interworking
d77de738
ML
22517Gives all externally visible functions in the file being compiled an ARM
22518instruction set header which switches to Thumb mode before executing the
22519rest of the function. This allows these functions to be called from
22520non-interworking code. This option is not valid in AAPCS configurations
22521because interworking is enabled by default.
22522
d77de738 22523@opindex mcaller-super-interworking
ddf6fe37 22524@item -mcaller-super-interworking
d77de738
ML
22525Allows calls via function pointers (including virtual functions) to
22526execute correctly regardless of whether the target code has been
22527compiled for interworking or not. There is a small overhead in the cost
22528of executing a function pointer if this option is enabled. This option
22529is not valid in AAPCS configurations because interworking is enabled
22530by default.
22531
d77de738 22532@opindex mtp
ddf6fe37 22533@item -mtp=@var{name}
d77de738
ML
22534Specify the access model for the thread local storage pointer. The valid
22535models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
22536@samp{cp15}, which fetches the thread pointer from @code{cp15} directly
22537(supported in the arm6k architecture), and @samp{auto}, which uses the
22538best available method for the selected processor. The default setting is
22539@samp{auto}.
22540
d77de738 22541@opindex mtls-dialect
ddf6fe37 22542@item -mtls-dialect=@var{dialect}
d77de738
ML
22543Specify the dialect to use for accessing thread local storage. Two
22544@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22545@samp{gnu} dialect selects the original GNU scheme for supporting
22546local and global dynamic TLS models. The @samp{gnu2} dialect
22547selects the GNU descriptor scheme, which provides better performance
22548for shared libraries. The GNU descriptor scheme is compatible with
22549the original scheme, but does require new assembler, linker and
22550library support. Initial and local exec TLS models are unaffected by
22551this option and always use the original scheme.
22552
d77de738 22553@opindex mword-relocations
ddf6fe37 22554@item -mword-relocations
d77de738
ML
22555Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22556This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22557loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22558is specified. This option conflicts with @option{-mslow-flash-data}.
22559
d77de738 22560@opindex mfix-cortex-m3-ldrd
ddf6fe37 22561@item -mfix-cortex-m3-ldrd
d77de738
ML
22562Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22563with overlapping destination and base registers are used. This option avoids
22564generating these instructions. This option is enabled by default when
22565@option{-mcpu=cortex-m3} is specified.
22566
22567@item -mfix-cortex-a57-aes-1742098
22568@itemx -mno-fix-cortex-a57-aes-1742098
22569@itemx -mfix-cortex-a72-aes-1655431
22570@itemx -mno-fix-cortex-a72-aes-1655431
22571Enable (disable) mitigation for an erratum on Cortex-A57 and
22572Cortex-A72 that affects the AES cryptographic instructions. This
22573option is enabled by default when either @option{-mcpu=cortex-a57} or
22574@option{-mcpu=cortex-a72} is specified.
22575
d77de738
ML
22576@opindex munaligned-access
22577@opindex mno-unaligned-access
ddf6fe37
AA
22578@item -munaligned-access
22579@itemx -mno-unaligned-access
d77de738
ML
22580Enables (or disables) reading and writing of 16- and 32- bit values
22581from addresses that are not 16- or 32- bit aligned. By default
22582unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22583ARMv8-M Baseline architectures, and enabled for all other
22584architectures. If unaligned access is not enabled then words in packed
22585data structures are accessed a byte at a time.
22586
22587The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22588generated object file to either true or false, depending upon the
22589setting of this option. If unaligned access is enabled then the
22590preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22591defined.
22592
d77de738 22593@opindex mneon-for-64bits
ddf6fe37 22594@item -mneon-for-64bits
d77de738
ML
22595This option is deprecated and has no effect.
22596
d77de738 22597@opindex mslow-flash-data
ddf6fe37 22598@item -mslow-flash-data
d77de738
ML
22599Assume loading data from flash is slower than fetching instruction.
22600Therefore literal load is minimized for better performance.
22601This option is only supported when compiling for ARMv7 M-profile and
22602off by default. It conflicts with @option{-mword-relocations}.
22603
d77de738 22604@opindex masm-syntax-unified
ddf6fe37 22605@item -masm-syntax-unified
d77de738
ML
22606Assume inline assembler is using unified asm syntax. The default is
22607currently off which implies divided syntax. This option has no impact
22608on Thumb2. However, this may change in future releases of GCC.
22609Divided syntax should be considered deprecated.
22610
d77de738 22611@opindex mrestrict-it
ddf6fe37 22612@item -mrestrict-it
d77de738
ML
22613Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22614IT blocks can only contain a single 16-bit instruction from a select
22615set of instructions. This option is on by default for ARMv8-A Thumb mode.
22616
d77de738 22617@opindex mprint-tune-info
ddf6fe37 22618@item -mprint-tune-info
d77de738
ML
22619Print CPU tuning information as comment in assembler file. This is
22620an option used only for regression testing of the compiler and not
22621intended for ordinary use in compiling code. This option is disabled
22622by default.
22623
d77de738 22624@opindex mverbose-cost-dump
ddf6fe37 22625@item -mverbose-cost-dump
d77de738
ML
22626Enable verbose cost model dumping in the debug dump files. This option is
22627provided for use in debugging the compiler.
22628
d77de738 22629@opindex mpure-code
ddf6fe37 22630@item -mpure-code
d77de738
ML
22631Do not allow constant data to be placed in code sections.
22632Additionally, when compiling for ELF object format give all text sections the
22633ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22634is only available when generating non-pic code for M-profile targets.
22635
d77de738 22636@opindex mcmse
ddf6fe37 22637@item -mcmse
d77de738
ML
22638Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22639Development Tools Engineering Specification", which can be found on
22640@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22641
d77de738 22642@opindex mfix-cmse-cve-2021-35465
ddf6fe37 22643@item -mfix-cmse-cve-2021-35465
d77de738
ML
22644Mitigate against a potential security issue with the @code{VLLDM} instruction
22645in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22646enabled by default when the option @option{-mcpu=} is used with
ccfd1e7f
SP
22647@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85}
22648or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used
22649to disable the mitigation.
d77de738 22650
d77de738
ML
22651@opindex mstack-protector-guard
22652@opindex mstack-protector-guard-offset
ddf6fe37
AA
22653@item -mstack-protector-guard=@var{guard}
22654@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
22655Generate stack protection code using canary at @var{guard}. Supported
22656locations are @samp{global} for a global canary or @samp{tls} for a
22657canary accessible via the TLS register. The option
22658@option{-mstack-protector-guard-offset=} is for use with
22659@option{-fstack-protector-guard=tls} and not for use in user-land code.
22660
d77de738
ML
22661@opindex mfdpic
22662@opindex mno-fdpic
ddf6fe37
AA
22663@item -mfdpic
22664@itemx -mno-fdpic
d77de738
ML
22665Select the FDPIC ABI, which uses 64-bit function descriptors to
22666represent pointers to functions. When the compiler is configured for
22667@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
22668and implies @option{-fPIE} if none of the PIC/PIE-related options is
22669provided. On other targets, it only enables the FDPIC-specific code
22670generation features, and the user should explicitly provide the
22671PIC/PIE-related options as needed.
22672
22673Note that static linking is not supported because it would still
22674involve the dynamic linker when the program self-relocates. If such
22675behavior is acceptable, use -static and -Wl,-dynamic-linker options.
22676
22677The opposite @option{-mno-fdpic} option is useful (and required) to
22678build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
22679toolchain as the one used to build the userland programs.
22680
14fab5fb 22681@opindex mbranch-protection
ddf6fe37 22682@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]
14fab5fb
AC
22683Enable branch protection features (armv8.1-m.main only).
22684@samp{none} generate code without branch protection or return address
22685signing.
22686@samp{standard[+@var{leaf}]} generate code with all branch protection
22687features enabled at their standard level.
22688@samp{pac-ret[+@var{leaf}]} generate code with return address signing
22689set to its standard level, which is to sign all functions that save
22690the return address to memory.
22691@samp{leaf} When return address signing is enabled, also sign leaf
22692functions even if they do not write the return address to memory.
22693+@samp{bti} Add landing-pad instructions at the permitted targets of
22694indirect branch instructions.
22695
22696If the @samp{+pacbti} architecture extension is not enabled, then all
22697branch protection and return address signing operations are
22698constrained to use only the instructions defined in the
22699architectural-NOP space. The generated code will remain
22700backwards-compatible with earlier versions of the architecture, but
22701the additional security can be enabled at run time on processors that
22702support the @samp{PACBTI} extension.
22703
22704Branch target enforcement using BTI can only be enabled at runtime if
22705all code in the application has been compiled with at least
22706@samp{-mbranch-protection=bti}.
22707
22708Any setting other than @samp{none} is supported only on armv8-m.main
22709or later.
22710
22711The default is to generate code without branch protection or return
22712address signing.
22713
d77de738
ML
22714@end table
22715
22716@node AVR Options
22717@subsection AVR Options
22718@cindex AVR Options
22719
22720These options are defined for AVR implementations:
22721
22722@table @gcctabopt
d77de738 22723@opindex mmcu
ddf6fe37 22724@item -mmcu=@var{mcu}
d77de738
ML
22725Specify Atmel AVR instruction set architectures (ISA) or MCU type.
22726
22727The default for this option is@tie{}@samp{avr2}.
22728
22729GCC supports the following AVR devices and ISAs:
22730
22731@include avr-mmcu.texi
22732
d77de738 22733@opindex mabsdata
ddf6fe37 22734@item -mabsdata
d77de738
ML
22735
22736Assume that all data in static storage can be accessed by LDS / STS
22737instructions. This option has only an effect on reduced Tiny devices like
22738ATtiny40. See also the @code{absdata}
22739@ref{AVR Variable Attributes,variable attribute}.
22740
d77de738 22741@opindex maccumulate-args
ddf6fe37 22742@item -maccumulate-args
d77de738
ML
22743Accumulate outgoing function arguments and acquire/release the needed
22744stack space for outgoing function arguments once in function
22745prologue/epilogue. Without this option, outgoing arguments are pushed
22746before calling a function and popped afterwards.
22747
22748Popping the arguments after the function call can be expensive on
22749AVR so that accumulating the stack space might lead to smaller
22750executables because arguments need not be removed from the
22751stack after such a function call.
22752
22753This option can lead to reduced code size for functions that perform
22754several calls to functions that get their arguments on the stack like
22755calls to printf-like functions.
22756
d77de738 22757@opindex mbranch-cost
ddf6fe37 22758@item -mbranch-cost=@var{cost}
d77de738
ML
22759Set the branch costs for conditional branch instructions to
22760@var{cost}. Reasonable values for @var{cost} are small, non-negative
22761integers. The default branch cost is 0.
22762
d77de738 22763@opindex mcall-prologues
ddf6fe37 22764@item -mcall-prologues
d77de738
ML
22765Functions prologues/epilogues are expanded as calls to appropriate
22766subroutines. Code size is smaller.
22767
d77de738
ML
22768@opindex mdouble
22769@opindex mlong-double
ddf6fe37
AA
22770@item -mdouble=@var{bits}
22771@itemx -mlong-double=@var{bits}
d77de738
ML
22772Set the size (in bits) of the @code{double} or @code{long double} type,
22773respectively. Possible values for @var{bits} are 32 and 64.
22774Whether or not a specific value for @var{bits} is allowed depends on
22775the @code{--with-double=} and @code{--with-long-double=}
22776@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
22777and the same applies for the default values of the options.
22778
d77de738 22779@opindex mgas-isr-prologues
ddf6fe37 22780@item -mgas-isr-prologues
d77de738
ML
22781Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
22782instruction supported by GNU Binutils.
22783If this option is on, the feature can still be disabled for individual
22784ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
22785function attribute. This feature is activated per default
22786if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
22787and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
22788
d77de738 22789@opindex mint8
ddf6fe37 22790@item -mint8
d77de738
ML
22791Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
22792@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
22793and @code{long long} is 4 bytes. Please note that this option does not
22794conform to the C standards, but it results in smaller code
22795size.
22796
d77de738 22797@opindex mmain-is-OS_task
ddf6fe37 22798@item -mmain-is-OS_task
d77de738
ML
22799Do not save registers in @code{main}. The effect is the same like
22800attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
22801to @code{main}. It is activated per default if optimization is on.
22802
d77de738 22803@opindex mn-flash
ddf6fe37 22804@item -mn-flash=@var{num}
d77de738
ML
22805Assume that the flash memory has a size of
22806@var{num} times 64@tie{}KiB.
22807
d77de738 22808@opindex mno-interrupts
ddf6fe37 22809@item -mno-interrupts
d77de738
ML
22810Generated code is not compatible with hardware interrupts.
22811Code size is smaller.
22812
d77de738 22813@opindex mrelax
ddf6fe37 22814@item -mrelax
d77de738
ML
22815Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
22816@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
22817Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
22818the assembler's command line and the @option{--relax} option to the
22819linker's command line.
22820
22821Jump relaxing is performed by the linker because jump offsets are not
22822known before code is located. Therefore, the assembler code generated by the
22823compiler is the same, but the instructions in the executable may
22824differ from instructions in the assembler code.
22825
22826Relaxing must be turned on if linker stubs are needed, see the
22827section on @code{EIND} and linker stubs below.
22828
d77de738 22829@opindex mrmw
ddf6fe37 22830@item -mrmw
d77de738
ML
22831Assume that the device supports the Read-Modify-Write
22832instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
22833
d77de738 22834@opindex mshort-calls
ddf6fe37 22835@item -mshort-calls
d77de738
ML
22836
22837Assume that @code{RJMP} and @code{RCALL} can target the whole
22838program memory.
22839
22840This option is used internally for multilib selection. It is
22841not an optimization option, and you don't need to set it by hand.
22842
d77de738 22843@opindex msp8
ddf6fe37 22844@item -msp8
d77de738
ML
22845Treat the stack pointer register as an 8-bit register,
22846i.e.@: assume the high byte of the stack pointer is zero.
22847In general, you don't need to set this option by hand.
22848
22849This option is used internally by the compiler to select and
22850build multilibs for architectures @code{avr2} and @code{avr25}.
22851These architectures mix devices with and without @code{SPH}.
22852For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
22853the compiler driver adds or removes this option from the compiler
22854proper's command line, because the compiler then knows if the device
22855or architecture has an 8-bit stack pointer and thus no @code{SPH}
22856register or not.
22857
d77de738 22858@opindex mstrict-X
ddf6fe37 22859@item -mstrict-X
d77de738
ML
22860Use address register @code{X} in a way proposed by the hardware. This means
22861that @code{X} is only used in indirect, post-increment or
22862pre-decrement addressing.
22863
22864Without this option, the @code{X} register may be used in the same way
22865as @code{Y} or @code{Z} which then is emulated by additional
22866instructions.
22867For example, loading a value with @code{X+const} addressing with a
22868small non-negative @code{const < 64} to a register @var{Rn} is
22869performed as
22870
22871@example
22872adiw r26, const ; X += const
22873ld @var{Rn}, X ; @var{Rn} = *X
22874sbiw r26, const ; X -= const
22875@end example
22876
d77de738 22877@opindex mtiny-stack
ddf6fe37 22878@item -mtiny-stack
d77de738
ML
22879Only change the lower 8@tie{}bits of the stack pointer.
22880
d77de738 22881@opindex mfract-convert-truncate
ddf6fe37 22882@item -mfract-convert-truncate
d77de738
ML
22883Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
22884
d77de738 22885@opindex nodevicelib
ddf6fe37 22886@item -nodevicelib
d77de738
ML
22887Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
22888
d77de738 22889@opindex nodevicespecs
ddf6fe37 22890@item -nodevicespecs
d77de738
ML
22891Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
22892command line. The user takes responsibility for supplying the sub-processes
22893like compiler proper, assembler and linker with appropriate command line
22894options. This means that the user has to supply her private device specs
22895file by means of @option{-specs=@var{path-to-specs-file}}. There is no
22896more need for option @option{-mmcu=@var{mcu}}.
22897
22898This option can also serve as a replacement for the older way of
22899specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
22900which contains a folder named @code{device-specs} which contains a specs file named
22901@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
22902
d77de738
ML
22903@opindex Waddr-space-convert
22904@opindex Wno-addr-space-convert
ddf6fe37 22905@item -Waddr-space-convert
d77de738
ML
22906Warn about conversions between address spaces in the case where the
22907resulting address space is not contained in the incoming address space.
22908
d77de738
ML
22909@opindex Wmisspelled-isr
22910@opindex Wno-misspelled-isr
ddf6fe37 22911@item -Wmisspelled-isr
d77de738
ML
22912Warn if the ISR is misspelled, i.e.@: without __vector prefix.
22913Enabled by default.
22914@end table
22915
22916@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
22917@cindex @code{EIND}
22918Pointers in the implementation are 16@tie{}bits wide.
22919The address of a function or label is represented as word address so
22920that indirect jumps and calls can target any code address in the
22921range of 64@tie{}Ki words.
22922
22923In order to facilitate indirect jump on devices with more than 128@tie{}Ki
22924bytes of program memory space, there is a special function register called
22925@code{EIND} that serves as most significant part of the target address
22926when @code{EICALL} or @code{EIJMP} instructions are used.
22927
22928Indirect jumps and calls on these devices are handled as follows by
22929the compiler and are subject to some limitations:
22930
22931@itemize @bullet
22932
22933@item
22934The compiler never sets @code{EIND}.
22935
22936@item
22937The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
22938instructions or might read @code{EIND} directly in order to emulate an
22939indirect call/jump by means of a @code{RET} instruction.
22940
22941@item
22942The compiler assumes that @code{EIND} never changes during the startup
22943code or during the application. In particular, @code{EIND} is not
22944saved/restored in function or interrupt service routine
22945prologue/epilogue.
22946
22947@item
22948For indirect calls to functions and computed goto, the linker
22949generates @emph{stubs}. Stubs are jump pads sometimes also called
22950@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
22951The stub contains a direct jump to the desired address.
22952
22953@item
22954Linker relaxation must be turned on so that the linker generates
22955the stubs correctly in all situations. See the compiler option
22956@option{-mrelax} and the linker option @option{--relax}.
22957There are corner cases where the linker is supposed to generate stubs
22958but aborts without relaxation and without a helpful error message.
22959
22960@item
22961The default linker script is arranged for code with @code{EIND = 0}.
22962If code is supposed to work for a setup with @code{EIND != 0}, a custom
22963linker script has to be used in order to place the sections whose
22964name start with @code{.trampolines} into the segment where @code{EIND}
22965points to.
22966
22967@item
22968The startup code from libgcc never sets @code{EIND}.
22969Notice that startup code is a blend of code from libgcc and AVR-LibC.
22970For the impact of AVR-LibC on @code{EIND}, see the
a65da9be 22971@w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
d77de738
ML
22972
22973@item
22974It is legitimate for user-specific startup code to set up @code{EIND}
22975early, for example by means of initialization code located in
22976section @code{.init3}. Such code runs prior to general startup code
22977that initializes RAM and calls constructors, but after the bit
22978of startup code from AVR-LibC that sets @code{EIND} to the segment
22979where the vector table is located.
22980@example
22981#include <avr/io.h>
22982
22983static void
22984__attribute__((section(".init3"),naked,used,no_instrument_function))
22985init3_set_eind (void)
22986@{
22987 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
22988 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
22989@}
22990@end example
22991
22992@noindent
22993The @code{__trampolines_start} symbol is defined in the linker script.
22994
22995@item
22996Stubs are generated automatically by the linker if
22997the following two conditions are met:
22998@itemize @minus
22999
23000@item The address of a label is taken by means of the @code{gs} modifier
23001(short for @emph{generate stubs}) like so:
23002@example
23003LDI r24, lo8(gs(@var{func}))
23004LDI r25, hi8(gs(@var{func}))
23005@end example
23006@item The final location of that label is in a code segment
23007@emph{outside} the segment where the stubs are located.
23008@end itemize
23009
23010@item
23011The compiler emits such @code{gs} modifiers for code labels in the
23012following situations:
23013@itemize @minus
23014@item Taking address of a function or code label.
23015@item Computed goto.
23016@item If prologue-save function is used, see @option{-mcall-prologues}
23017command-line option.
23018@item Switch/case dispatch tables. If you do not want such dispatch
23019tables you can specify the @option{-fno-jump-tables} command-line option.
23020@item C and C++ constructors/destructors called during startup/shutdown.
23021@item If the tools hit a @code{gs()} modifier explained above.
23022@end itemize
23023
23024@item
23025Jumping to non-symbolic addresses like so is @emph{not} supported:
23026
23027@example
23028int main (void)
23029@{
23030 /* Call function at word address 0x2 */
23031 return ((int(*)(void)) 0x2)();
23032@}
23033@end example
23034
23035Instead, a stub has to be set up, i.e.@: the function has to be called
23036through a symbol (@code{func_4} in the example):
23037
23038@example
23039int main (void)
23040@{
23041 extern int func_4 (void);
23042
23043 /* Call function at byte address 0x4 */
23044 return func_4();
23045@}
23046@end example
23047
23048and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
23049Alternatively, @code{func_4} can be defined in the linker script.
23050@end itemize
23051
23052@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
23053@cindex @code{RAMPD}
23054@cindex @code{RAMPX}
23055@cindex @code{RAMPY}
23056@cindex @code{RAMPZ}
23057Some AVR devices support memories larger than the 64@tie{}KiB range
23058that can be accessed with 16-bit pointers. To access memory locations
23059outside this 64@tie{}KiB range, the content of a @code{RAMP}
23060register is used as high part of the address:
23061The @code{X}, @code{Y}, @code{Z} address register is concatenated
23062with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
23063register, respectively, to get a wide address. Similarly,
23064@code{RAMPD} is used together with direct addressing.
23065
23066@itemize
23067@item
23068The startup code initializes the @code{RAMP} special function
23069registers with zero.
23070
23071@item
23072If a @ref{AVR Named Address Spaces,named address space} other than
23073generic or @code{__flash} is used, then @code{RAMPZ} is set
23074as needed before the operation.
23075
23076@item
23077If the device supports RAM larger than 64@tie{}KiB and the compiler
23078needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
23079is reset to zero after the operation.
23080
23081@item
23082If the device comes with a specific @code{RAMP} register, the ISR
23083prologue/epilogue saves/restores that SFR and initializes it with
23084zero in case the ISR code might (implicitly) use it.
23085
23086@item
23087RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
23088If you use inline assembler to read from locations outside the
2308916-bit address range and change one of the @code{RAMP} registers,
23090you must reset it to zero after the access.
23091
23092@end itemize
23093
23094@subsubsection AVR Built-in Macros
23095
23096GCC defines several built-in macros so that the user code can test
23097for the presence or absence of features. Almost any of the following
23098built-in macros are deduced from device capabilities and thus
23099triggered by the @option{-mmcu=} command-line option.
23100
23101For even more AVR-specific built-in macros see
23102@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
23103
23104@table @code
23105
23106@item __AVR_ARCH__
23107Build-in macro that resolves to a decimal number that identifies the
23108architecture and depends on the @option{-mmcu=@var{mcu}} option.
23109Possible values are:
23110
23111@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
23112@code{4}, @code{5}, @code{51}, @code{6}
23113
23114for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
23115@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
23116
23117respectively and
23118
23119@code{100},
23120@code{102}, @code{103}, @code{104},
23121@code{105}, @code{106}, @code{107}
23122
23123for @var{mcu}=@code{avrtiny},
23124@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
23125@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
23126If @var{mcu} specifies a device, this built-in macro is set
23127accordingly. For example, with @option{-mmcu=atmega8} the macro is
23128defined to @code{4}.
23129
23130@item __AVR_@var{Device}__
23131Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
23132the device's name. For example, @option{-mmcu=atmega8} defines the
23133built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
23134@code{__AVR_ATtiny261A__}, etc.
23135
23136The built-in macros' names follow
23137the scheme @code{__AVR_@var{Device}__} where @var{Device} is
23138the device name as from the AVR user manual. The difference between
23139@var{Device} in the built-in macro and @var{device} in
23140@option{-mmcu=@var{device}} is that the latter is always lowercase.
23141
23142If @var{device} is not a device but only a core architecture like
23143@samp{avr51}, this macro is not defined.
23144
23145@item __AVR_DEVICE_NAME__
23146Setting @option{-mmcu=@var{device}} defines this built-in macro to
23147the device's name. For example, with @option{-mmcu=atmega8} the macro
23148is defined to @code{atmega8}.
23149
23150If @var{device} is not a device but only a core architecture like
23151@samp{avr51}, this macro is not defined.
23152
23153@item __AVR_XMEGA__
23154The device / architecture belongs to the XMEGA family of devices.
23155
23156@item __AVR_HAVE_ELPM__
23157The device has the @code{ELPM} instruction.
23158
23159@item __AVR_HAVE_ELPMX__
23160The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23161R@var{n},Z+} instructions.
23162
23163@item __AVR_HAVE_MOVW__
23164The device has the @code{MOVW} instruction to perform 16-bit
23165register-register moves.
23166
23167@item __AVR_HAVE_LPMX__
23168The device has the @code{LPM R@var{n},Z} and
23169@code{LPM R@var{n},Z+} instructions.
23170
23171@item __AVR_HAVE_MUL__
23172The device has a hardware multiplier.
23173
23174@item __AVR_HAVE_JMP_CALL__
23175The device has the @code{JMP} and @code{CALL} instructions.
23176This is the case for devices with more than 8@tie{}KiB of program
23177memory.
23178
23179@item __AVR_HAVE_EIJMP_EICALL__
23180@itemx __AVR_3_BYTE_PC__
23181The device has the @code{EIJMP} and @code{EICALL} instructions.
23182This is the case for devices with more than 128@tie{}KiB of program memory.
23183This also means that the program counter
23184(PC) is 3@tie{}bytes wide.
23185
23186@item __AVR_2_BYTE_PC__
23187The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23188with up to 128@tie{}KiB of program memory.
23189
23190@item __AVR_HAVE_8BIT_SP__
23191@itemx __AVR_HAVE_16BIT_SP__
23192The stack pointer (SP) register is treated as 8-bit respectively
2319316-bit register by the compiler.
23194The definition of these macros is affected by @option{-mtiny-stack}.
23195
23196@item __AVR_HAVE_SPH__
23197@itemx __AVR_SP8__
23198The device has the SPH (high part of stack pointer) special function
23199register or has an 8-bit stack pointer, respectively.
23200The definition of these macros is affected by @option{-mmcu=} and
23201in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23202by @option{-msp8}.
23203
23204@item __AVR_HAVE_RAMPD__
23205@itemx __AVR_HAVE_RAMPX__
23206@itemx __AVR_HAVE_RAMPY__
23207@itemx __AVR_HAVE_RAMPZ__
23208The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23209@code{RAMPZ} special function register, respectively.
23210
23211@item __NO_INTERRUPTS__
23212This macro reflects the @option{-mno-interrupts} command-line option.
23213
23214@item __AVR_ERRATA_SKIP__
23215@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23216Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23217instructions because of a hardware erratum. Skip instructions are
23218@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23219The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23220set.
23221
23222@item __AVR_ISA_RMW__
23223The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23224
23225@item __AVR_SFR_OFFSET__=@var{offset}
23226Instructions that can address I/O special function registers directly
23227like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23228address as if addressed by an instruction to access RAM like @code{LD}
23229or @code{STS}. This offset depends on the device architecture and has
23230to be subtracted from the RAM address in order to get the
23231respective I/O@tie{}address.
23232
23233@item __AVR_SHORT_CALLS__
23234The @option{-mshort-calls} command line option is set.
23235
23236@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23237Some devices support reading from flash memory by means of @code{LD*}
23238instructions. The flash memory is seen in the data address space
23239at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23240is not defined, this feature is not available. If defined,
23241the address space is linear and there is no need to put
23242@code{.rodata} into RAM. This is handled by the default linker
23243description file, and is currently available for
23244@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23245there is no need to use address spaces like @code{__flash} or
23246features like attribute @code{progmem} and @code{pgm_read_*}.
23247
23248@item __WITH_AVRLIBC__
23249The compiler is configured to be used together with AVR-Libc.
23250See the @option{--with-avrlibc} configure option.
23251
23252@item __HAVE_DOUBLE_MULTILIB__
23253Defined if @option{-mdouble=} acts as a multilib option.
23254
23255@item __HAVE_DOUBLE32__
23256@itemx __HAVE_DOUBLE64__
23257Defined if the compiler supports 32-bit double resp. 64-bit double.
23258The actual layout is specified by option @option{-mdouble=}.
23259
23260@item __DEFAULT_DOUBLE__
23261The size in bits of @code{double} if @option{-mdouble=} is not set.
23262To test the layout of @code{double} in a program, use the built-in
23263macro @code{__SIZEOF_DOUBLE__}.
23264
23265@item __HAVE_LONG_DOUBLE32__
23266@itemx __HAVE_LONG_DOUBLE64__
23267@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23268@itemx __DEFAULT_LONG_DOUBLE__
23269Same as above, but for @code{long double} instead of @code{double}.
23270
23271@item __WITH_DOUBLE_COMPARISON__
23272Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23273@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23274and is defined to @code{2} or @code{3}.
23275
23276@item __WITH_LIBF7_LIBGCC__
23277@itemx __WITH_LIBF7_MATH__
23278@itemx __WITH_LIBF7_MATH_SYMBOLS__
23279Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23280@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23281
23282@end table
23283
23284@node Blackfin Options
23285@subsection Blackfin Options
23286@cindex Blackfin Options
23287
23288@table @gcctabopt
d77de738 23289@opindex mcpu=
ddf6fe37 23290@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
d77de738
ML
23291Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23292can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23293@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23294@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23295@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23296@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23297@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23298@samp{bf561}, @samp{bf592}.
23299
23300The optional @var{sirevision} specifies the silicon revision of the target
23301Blackfin processor. Any workarounds available for the targeted silicon revision
23302are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23303If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23304are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23305hexadecimal digits representing the major and minor numbers in the silicon
23306revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23307is not defined. If @var{sirevision} is @samp{any}, the
23308@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23309If this optional @var{sirevision} is not used, GCC assumes the latest known
23310silicon revision of the targeted Blackfin processor.
23311
23312GCC defines a preprocessor macro for the specified @var{cpu}.
23313For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23314provided by libgloss to be linked in if @option{-msim} is not given.
23315
23316Without this option, @samp{bf532} is used as the processor by default.
23317
23318Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23319only the preprocessor macro is defined.
23320
d77de738 23321@opindex msim
ddf6fe37 23322@item -msim
d77de738
ML
23323Specifies that the program will be run on the simulator. This causes
23324the simulator BSP provided by libgloss to be linked in. This option
23325has effect only for @samp{bfin-elf} toolchain.
23326Certain other options, such as @option{-mid-shared-library} and
23327@option{-mfdpic}, imply @option{-msim}.
23328
d77de738 23329@opindex momit-leaf-frame-pointer
ddf6fe37 23330@item -momit-leaf-frame-pointer
d77de738
ML
23331Don't keep the frame pointer in a register for leaf functions. This
23332avoids the instructions to save, set up and restore frame pointers and
23333makes an extra register available in leaf functions.
23334
d77de738 23335@opindex mspecld-anomaly
ddf6fe37 23336@item -mspecld-anomaly
d77de738
ML
23337When enabled, the compiler ensures that the generated code does not
23338contain speculative loads after jump instructions. If this option is used,
23339@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23340
d77de738
ML
23341@opindex mno-specld-anomaly
23342@opindex mspecld-anomaly
ddf6fe37 23343@item -mno-specld-anomaly
d77de738
ML
23344Don't generate extra code to prevent speculative loads from occurring.
23345
d77de738 23346@opindex mcsync-anomaly
ddf6fe37 23347@item -mcsync-anomaly
d77de738
ML
23348When enabled, the compiler ensures that the generated code does not
23349contain CSYNC or SSYNC instructions too soon after conditional branches.
23350If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23351
d77de738
ML
23352@opindex mno-csync-anomaly
23353@opindex mcsync-anomaly
ddf6fe37 23354@item -mno-csync-anomaly
d77de738
ML
23355Don't generate extra code to prevent CSYNC or SSYNC instructions from
23356occurring too soon after a conditional branch.
23357
d77de738 23358@opindex mlow64k
ddf6fe37 23359@item -mlow64k
d77de738
ML
23360When enabled, the compiler is free to take advantage of the knowledge that
23361the entire program fits into the low 64k of memory.
23362
d77de738 23363@opindex mno-low64k
ddf6fe37 23364@item -mno-low64k
d77de738
ML
23365Assume that the program is arbitrarily large. This is the default.
23366
d77de738 23367@opindex mstack-check-l1
ddf6fe37 23368@item -mstack-check-l1
d77de738
ML
23369Do stack checking using information placed into L1 scratchpad memory by the
23370uClinux kernel.
23371
d77de738 23372@opindex mid-shared-library
ddf6fe37 23373@item -mid-shared-library
d77de738
ML
23374Generate code that supports shared libraries via the library ID method.
23375This allows for execute in place and shared libraries in an environment
23376without virtual memory management. This option implies @option{-fPIC}.
23377With a @samp{bfin-elf} target, this option implies @option{-msim}.
23378
d77de738
ML
23379@opindex mno-id-shared-library
23380@opindex mid-shared-library
ddf6fe37 23381@item -mno-id-shared-library
d77de738
ML
23382Generate code that doesn't assume ID-based shared libraries are being used.
23383This is the default.
23384
d77de738 23385@opindex mleaf-id-shared-library
ddf6fe37 23386@item -mleaf-id-shared-library
d77de738
ML
23387Generate code that supports shared libraries via the library ID method,
23388but assumes that this library or executable won't link against any other
23389ID shared libraries. That allows the compiler to use faster code for jumps
23390and calls.
23391
d77de738
ML
23392@opindex mno-leaf-id-shared-library
23393@opindex mleaf-id-shared-library
ddf6fe37 23394@item -mno-leaf-id-shared-library
d77de738
ML
23395Do not assume that the code being compiled won't link against any ID shared
23396libraries. Slower code is generated for jump and call insns.
23397
d77de738 23398@opindex mshared-library-id
ddf6fe37 23399@item -mshared-library-id=n
d77de738
ML
23400Specifies the identification number of the ID-based shared library being
23401compiled. Specifying a value of 0 generates more compact code; specifying
23402other values forces the allocation of that number to the current
23403library but is no more space- or time-efficient than omitting this option.
23404
d77de738 23405@opindex msep-data
ddf6fe37 23406@item -msep-data
d77de738
ML
23407Generate code that allows the data segment to be located in a different
23408area of memory from the text segment. This allows for execute in place in
23409an environment without virtual memory management by eliminating relocations
23410against the text section.
23411
d77de738
ML
23412@opindex mno-sep-data
23413@opindex msep-data
ddf6fe37 23414@item -mno-sep-data
d77de738
ML
23415Generate code that assumes that the data segment follows the text segment.
23416This is the default.
23417
d77de738
ML
23418@opindex mlong-calls
23419@opindex mno-long-calls
ddf6fe37
AA
23420@item -mlong-calls
23421@itemx -mno-long-calls
d77de738
ML
23422Tells the compiler to perform function calls by first loading the
23423address of the function into a register and then performing a subroutine
23424call on this register. This switch is needed if the target function
23425lies outside of the 24-bit addressing range of the offset-based
23426version of subroutine call instruction.
23427
23428This feature is not enabled by default. Specifying
23429@option{-mno-long-calls} restores the default behavior. Note these
23430switches have no effect on how the compiler generates code to handle
23431function calls via function pointers.
23432
d77de738 23433@opindex mfast-fp
ddf6fe37 23434@item -mfast-fp
d77de738
ML
23435Link with the fast floating-point library. This library relaxes some of
23436the IEEE floating-point standard's rules for checking inputs against
23437Not-a-Number (NAN), in the interest of performance.
23438
d77de738 23439@opindex minline-plt
ddf6fe37 23440@item -minline-plt
d77de738
ML
23441Enable inlining of PLT entries in function calls to functions that are
23442not known to bind locally. It has no effect without @option{-mfdpic}.
23443
d77de738 23444@opindex mmulticore
ddf6fe37 23445@item -mmulticore
d77de738
ML
23446Build a standalone application for multicore Blackfin processors.
23447This option causes proper start files and link scripts supporting
23448multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23449It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23450
23451This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23452selects the one-application-per-core programming model. Without
23453@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23454programming model is used. In this model, the main function of Core B
23455should be named as @code{coreb_main}.
23456
23457If this option is not used, the single-core application programming
23458model is used.
23459
d77de738 23460@opindex mcorea
ddf6fe37 23461@item -mcorea
d77de738
ML
23462Build a standalone application for Core A of BF561 when using
23463the one-application-per-core programming model. Proper start files
23464and link scripts are used to support Core A, and the macro
23465@code{__BFIN_COREA} is defined.
23466This option can only be used in conjunction with @option{-mmulticore}.
23467
d77de738 23468@opindex mcoreb
ddf6fe37 23469@item -mcoreb
d77de738
ML
23470Build a standalone application for Core B of BF561 when using
23471the one-application-per-core programming model. Proper start files
23472and link scripts are used to support Core B, and the macro
23473@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23474should be used instead of @code{main}.
23475This option can only be used in conjunction with @option{-mmulticore}.
23476
d77de738 23477@opindex msdram
ddf6fe37 23478@item -msdram
d77de738
ML
23479Build a standalone application for SDRAM. Proper start files and
23480link scripts are used to put the application into SDRAM, and the macro
23481@code{__BFIN_SDRAM} is defined.
23482The loader should initialize SDRAM before loading the application.
23483
d77de738 23484@opindex micplb
ddf6fe37 23485@item -micplb
d77de738
ML
23486Assume that ICPLBs are enabled at run time. This has an effect on certain
23487anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23488are enabled; for standalone applications the default is off.
23489@end table
23490
23491@node C6X Options
23492@subsection C6X Options
23493@cindex C6X Options
23494
23495@table @gcctabopt
d77de738 23496@opindex march
ddf6fe37 23497@item -march=@var{name}
d77de738
ML
23498This specifies the name of the target architecture. GCC uses this
23499name to determine what kind of instructions it can emit when generating
23500assembly code. Permissible names are: @samp{c62x},
23501@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23502
d77de738 23503@opindex mbig-endian
ddf6fe37 23504@item -mbig-endian
d77de738
ML
23505Generate code for a big-endian target.
23506
d77de738 23507@opindex mlittle-endian
ddf6fe37 23508@item -mlittle-endian
d77de738
ML
23509Generate code for a little-endian target. This is the default.
23510
d77de738 23511@opindex msim
ddf6fe37 23512@item -msim
d77de738
ML
23513Choose startup files and linker script suitable for the simulator.
23514
d77de738 23515@opindex msdata=default
ddf6fe37 23516@item -msdata=default
d77de738
ML
23517Put small global and static data in the @code{.neardata} section,
23518which is pointed to by register @code{B14}. Put small uninitialized
23519global and static data in the @code{.bss} section, which is adjacent
23520to the @code{.neardata} section. Put small read-only data into the
23521@code{.rodata} section. The corresponding sections used for large
23522pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23523
d77de738 23524@opindex msdata=all
ddf6fe37 23525@item -msdata=all
d77de738
ML
23526Put all data, not just small objects, into the sections reserved for
23527small data, and use addressing relative to the @code{B14} register to
23528access them.
23529
d77de738 23530@opindex msdata=none
ddf6fe37 23531@item -msdata=none
d77de738
ML
23532Make no use of the sections reserved for small data, and use absolute
23533addresses to access all data. Put all initialized global and static
23534data in the @code{.fardata} section, and all uninitialized data in the
23535@code{.far} section. Put all constant data into the @code{.const}
23536section.
23537@end table
23538
23539@node CRIS Options
23540@subsection CRIS Options
23541@cindex CRIS Options
23542
23543These options are defined specifically for the CRIS ports.
23544
23545@table @gcctabopt
d77de738
ML
23546@opindex march
23547@opindex mcpu
ddf6fe37
AA
23548@item -march=@var{architecture-type}
23549@itemx -mcpu=@var{architecture-type}
d77de738
ML
23550Generate code for the specified architecture. The choices for
23551@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23552respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23553Default is @samp{v0}.
23554
d77de738 23555@opindex mtune
ddf6fe37 23556@item -mtune=@var{architecture-type}
d77de738
ML
23557Tune to @var{architecture-type} everything applicable about the generated
23558code, except for the ABI and the set of available instructions. The
23559choices for @var{architecture-type} are the same as for
23560@option{-march=@var{architecture-type}}.
23561
d77de738 23562@opindex mmax-stack-frame
ddf6fe37 23563@item -mmax-stack-frame=@var{n}
d77de738
ML
23564Warn when the stack frame of a function exceeds @var{n} bytes.
23565
d77de738
ML
23566@opindex metrax4
23567@opindex metrax100
ddf6fe37
AA
23568@item -metrax4
23569@itemx -metrax100
d77de738
ML
23570The options @option{-metrax4} and @option{-metrax100} are synonyms for
23571@option{-march=v3} and @option{-march=v8} respectively.
23572
d77de738
ML
23573@opindex mmul-bug-workaround
23574@opindex mno-mul-bug-workaround
ddf6fe37
AA
23575@item -mmul-bug-workaround
23576@itemx -mno-mul-bug-workaround
d77de738
ML
23577Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23578models where it applies. This option is disabled by default.
23579
d77de738 23580@opindex mpdebug
ddf6fe37 23581@item -mpdebug
d77de738
ML
23582Enable CRIS-specific verbose debug-related information in the assembly
23583code. This option also has the effect of turning off the @samp{#NO_APP}
23584formatted-code indicator to the assembler at the beginning of the
23585assembly file.
23586
d77de738 23587@opindex mcc-init
ddf6fe37 23588@item -mcc-init
d77de738
ML
23589Do not use condition-code results from previous instruction; always emit
23590compare and test instructions before use of condition codes.
23591
d77de738
ML
23592@opindex mno-side-effects
23593@opindex mside-effects
ddf6fe37 23594@item -mno-side-effects
d77de738
ML
23595Do not emit instructions with side effects in addressing modes other than
23596post-increment.
23597
d77de738
ML
23598@opindex mstack-align
23599@opindex mno-stack-align
23600@opindex mdata-align
23601@opindex mno-data-align
23602@opindex mconst-align
23603@opindex mno-const-align
ddf6fe37
AA
23604@item -mstack-align
23605@itemx -mno-stack-align
23606@itemx -mdata-align
23607@itemx -mno-data-align
23608@itemx -mconst-align
23609@itemx -mno-const-align
d77de738
ML
23610These options (@samp{no-} options) arrange (eliminate arrangements) for the
23611stack frame, individual data and constants to be aligned for the maximum
23612single data access size for the chosen CPU model. The default is to
23613arrange for 32-bit alignment. ABI details such as structure layout are
23614not affected by these options.
23615
d77de738
ML
23616@opindex m32-bit
23617@opindex m16-bit
23618@opindex m8-bit
ddf6fe37
AA
23619@item -m32-bit
23620@itemx -m16-bit
23621@itemx -m8-bit
d77de738
ML
23622Similar to the stack- data- and const-align options above, these options
23623arrange for stack frame, writable data and constants to all be 32-bit,
2362416-bit or 8-bit aligned. The default is 32-bit alignment.
23625
d77de738
ML
23626@opindex mno-prologue-epilogue
23627@opindex mprologue-epilogue
ddf6fe37
AA
23628@item -mno-prologue-epilogue
23629@itemx -mprologue-epilogue
d77de738
ML
23630With @option{-mno-prologue-epilogue}, the normal function prologue and
23631epilogue which set up the stack frame are omitted and no return
23632instructions or return sequences are generated in the code. Use this
23633option only together with visual inspection of the compiled code: no
23634warnings or errors are generated when call-saved registers must be saved,
23635or storage for local variables needs to be allocated.
23636
d77de738 23637@opindex melf
ddf6fe37 23638@item -melf
d77de738
ML
23639Legacy no-op option.
23640
d77de738 23641@opindex sim
ddf6fe37 23642@item -sim
d77de738
ML
23643This option arranges
23644to link with input-output functions from a simulator library. Code,
23645initialized data and zero-initialized data are allocated consecutively.
23646
d77de738 23647@opindex sim2
ddf6fe37 23648@item -sim2
d77de738
ML
23649Like @option{-sim}, but pass linker options to locate initialized data at
236500x40000000 and zero-initialized data at 0x80000000.
23651@end table
23652
23653@node C-SKY Options
23654@subsection C-SKY Options
23655@cindex C-SKY Options
23656
23657GCC supports these options when compiling for C-SKY V2 processors.
23658
23659@table @gcctabopt
23660
d77de738 23661@opindex march=
ddf6fe37 23662@item -march=@var{arch}
d77de738
ML
23663Specify the C-SKY target architecture. Valid values for @var{arch} are:
23664@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
23665The default is @samp{ck810}.
23666
d77de738 23667@opindex mcpu=
ddf6fe37 23668@item -mcpu=@var{cpu}
d77de738
ML
23669Specify the C-SKY target processor. Valid values for @var{cpu} are:
23670@samp{ck801}, @samp{ck801t},
23671@samp{ck802}, @samp{ck802t}, @samp{ck802j},
23672@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
23673@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
23674@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
23675@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
23676@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
23677@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
23678@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
23679@samp{ck803eftr1}, @samp{ck803efhtr1},
23680@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
23681@samp{ck803sef}, @samp{ck803seft},
23682@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
23683@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
23684@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
23685@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
23686
d77de738 23687@opindex mbig-endian
d77de738 23688@opindex EB
d77de738 23689@opindex mlittle-endian
d77de738 23690@opindex EL
ddf6fe37
AA
23691@item -mbig-endian
23692@itemx -EB
23693@itemx -mlittle-endian
23694@itemx -EL
d77de738
ML
23695
23696Select big- or little-endian code. The default is little-endian.
23697
d77de738 23698@opindex mfloat-abi
ddf6fe37 23699@item -mfloat-abi=@var{name}
d77de738
ML
23700Specifies which floating-point ABI to use. Permissible values
23701are: @samp{soft}, @samp{softfp} and @samp{hard}.
23702
23703Specifying @samp{soft} causes GCC to generate output containing
23704library calls for floating-point operations.
23705@samp{softfp} allows the generation of code using hardware floating-point
23706instructions, but still uses the soft-float calling conventions.
23707@samp{hard} allows generation of floating-point instructions
23708and uses FPU-specific calling conventions.
23709
23710The default depends on the specific target configuration. Note that
23711the hard-float and soft-float ABIs are not link-compatible; you must
23712compile your entire program with the same ABI, and link with a
23713compatible set of libraries.
23714
d77de738 23715@opindex mhard-float
d77de738 23716@opindex msoft-float
ddf6fe37
AA
23717@item -mhard-float
23718@itemx -msoft-float
d77de738
ML
23719
23720Select hardware or software floating-point implementations.
23721The default is soft float.
23722
ddf6fe37 23723@opindex mdouble-float
d77de738
ML
23724@item -mdouble-float
23725@itemx -mno-double-float
d77de738
ML
23726When @option{-mhard-float} is in effect, enable generation of
23727double-precision float instructions. This is the default except
23728when compiling for CK803.
23729
ddf6fe37 23730@opindex mfdivdu
d77de738
ML
23731@item -mfdivdu
23732@itemx -mno-fdivdu
d77de738
ML
23733When @option{-mhard-float} is in effect, enable generation of
23734@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
23735This is the default except when compiling for CK803.
23736
d77de738 23737@opindex mfpu=
ddf6fe37 23738@item -mfpu=@var{fpu}
d77de738
ML
23739Select the floating-point processor. This option can only be used with
23740@option{-mhard-float}.
23741Values for @var{fpu} are
23742@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
23743@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
23744@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
23745
ddf6fe37 23746@opindex melrw
d77de738
ML
23747@item -melrw
23748@itemx -mno-elrw
d77de738
ML
23749Enable the extended @code{lrw} instruction. This option defaults to on
23750for CK801 and off otherwise.
23751
ddf6fe37 23752@opindex mistack
d77de738
ML
23753@item -mistack
23754@itemx -mno-istack
d77de738
ML
23755Enable interrupt stack instructions; the default is off.
23756
23757The @option{-mistack} option is required to handle the
23758@code{interrupt} and @code{isr} function attributes
23759(@pxref{C-SKY Function Attributes}).
23760
d77de738 23761@opindex mmp
ddf6fe37 23762@item -mmp
d77de738
ML
23763Enable multiprocessor instructions; the default is off.
23764
d77de738 23765@opindex mcp
ddf6fe37 23766@item -mcp
d77de738
ML
23767Enable coprocessor instructions; the default is off.
23768
d77de738 23769@opindex mcache
ddf6fe37 23770@item -mcache
d77de738
ML
23771Enable coprocessor instructions; the default is off.
23772
d77de738 23773@opindex msecurity
ddf6fe37 23774@item -msecurity
d77de738
ML
23775Enable C-SKY security instructions; the default is off.
23776
d77de738 23777@opindex mtrust
ddf6fe37 23778@item -mtrust
d77de738
ML
23779Enable C-SKY trust instructions; the default is off.
23780
d77de738 23781@opindex mdsp
d77de738 23782@opindex medsp
d77de738 23783@opindex mvdsp
ddf6fe37
AA
23784@item -mdsp
23785@itemx -medsp
23786@itemx -mvdsp
d77de738
ML
23787Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
23788All of these options default to off.
23789
ddf6fe37 23790@opindex mdiv
d77de738
ML
23791@item -mdiv
23792@itemx -mno-div
d77de738
ML
23793Generate divide instructions. Default is off.
23794
ddf6fe37 23795@opindex msmart
d77de738
ML
23796@item -msmart
23797@itemx -mno-smart
d77de738
ML
23798Generate code for Smart Mode, using only registers numbered 0-7 to allow
23799use of 16-bit instructions. This option is ignored for CK801 where this
23800is the required behavior, and it defaults to on for CK802.
23801For other targets, the default is off.
23802
ddf6fe37 23803@opindex mhigh-registers
d77de738
ML
23804@item -mhigh-registers
23805@itemx -mno-high-registers
d77de738
ML
23806Generate code using the high registers numbered 16-31. This option
23807is not supported on CK801, CK802, or CK803, and is enabled by default
23808for other processors.
23809
ddf6fe37 23810@opindex manchor
d77de738
ML
23811@item -manchor
23812@itemx -mno-anchor
d77de738
ML
23813Generate code using global anchor symbol addresses.
23814
ddf6fe37 23815@opindex mpushpop
d77de738
ML
23816@item -mpushpop
23817@itemx -mno-pushpop
d77de738
ML
23818Generate code using @code{push} and @code{pop} instructions. This option
23819defaults to on.
23820
ddf6fe37 23821@opindex mmultiple-stld
d77de738
ML
23822@item -mmultiple-stld
23823@itemx -mstm
23824@itemx -mno-multiple-stld
23825@itemx -mno-stm
d77de738
ML
23826Generate code using @code{stm} and @code{ldm} instructions. This option
23827isn't supported on CK801 but is enabled by default on other processors.
23828
ddf6fe37 23829@opindex mconstpool
d77de738
ML
23830@item -mconstpool
23831@itemx -mno-constpool
d77de738
ML
23832Create constant pools in the compiler instead of deferring it to the
23833assembler. This option is the default and required for correct code
23834generation on CK801 and CK802, and is optional on other processors.
23835
ddf6fe37 23836@opindex mstack-size
d77de738
ML
23837@item -mstack-size
23838@item -mno-stack-size
d77de738
ML
23839Emit @code{.stack_size} directives for each function in the assembly
23840output. This option defaults to off.
23841
ddf6fe37 23842@opindex mccrt
d77de738
ML
23843@item -mccrt
23844@itemx -mno-ccrt
d77de738
ML
23845Generate code for the C-SKY compiler runtime instead of libgcc. This
23846option defaults to off.
23847
d77de738 23848@opindex mbranch-cost=
ddf6fe37 23849@item -mbranch-cost=@var{n}
d77de738
ML
23850Set the branch costs to roughly @code{n} instructions. The default is 1.
23851
ddf6fe37 23852@opindex msched-prolog
d77de738
ML
23853@item -msched-prolog
23854@itemx -mno-sched-prolog
d77de738
ML
23855Permit scheduling of function prologue and epilogue sequences. Using
23856this option can result in code that is not compliant with the C-SKY V2 ABI
23857prologue requirements and that cannot be debugged or backtraced.
23858It is disabled by default.
23859
d77de738 23860@opindex msim
ddf6fe37 23861@item -msim
d77de738
ML
23862Links the library libsemi.a which is in compatible with simulator. Applicable
23863to ELF compiler only.
23864
23865@end table
23866
23867@node Darwin Options
23868@subsection Darwin Options
23869@cindex Darwin options
23870
23871These options are defined for all architectures running the Darwin operating
23872system.
23873
23874FSF GCC on Darwin does not create ``fat'' object files; it creates
23875an object file for the single architecture that GCC was built to
23876target. Apple's GCC on Darwin does create ``fat'' files if multiple
23877@option{-arch} options are used; it does so by running the compiler or
23878linker multiple times and joining the results together with
23879@file{lipo}.
23880
23881The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
23882@samp{i686}) is determined by the flags that specify the ISA
23883that GCC is targeting, like @option{-mcpu} or @option{-march}. The
23884@option{-force_cpusubtype_ALL} option can be used to override this.
23885
23886The Darwin tools vary in their behavior when presented with an ISA
23887mismatch. The assembler, @file{as}, only permits instructions to
23888be used that are valid for the subtype of the file it is generating,
23889so you cannot put 64-bit instructions in a @samp{ppc750} object file.
23890The linker for shared libraries, @file{/usr/bin/libtool}, fails
23891and prints an error if asked to create a shared library with a less
23892restrictive subtype than its input files (for instance, trying to put
23893a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
23894for executables, @command{ld}, quietly gives the executable the most
23895restrictive subtype of any of its input files.
23896
23897@table @gcctabopt
d77de738 23898@opindex F
ddf6fe37 23899@item -F@var{dir}
d77de738
ML
23900Add the framework directory @var{dir} to the head of the list of
23901directories to be searched for header files. These directories are
23902interleaved with those specified by @option{-I} options and are
23903scanned in a left-to-right order.
23904
23905A framework directory is a directory with frameworks in it. A
23906framework is a directory with a @file{Headers} and/or
23907@file{PrivateHeaders} directory contained directly in it that ends
23908in @file{.framework}. The name of a framework is the name of this
23909directory excluding the @file{.framework}. Headers associated with
23910the framework are found in one of those two directories, with
23911@file{Headers} being searched first. A subframework is a framework
23912directory that is in a framework's @file{Frameworks} directory.
23913Includes of subframework headers can only appear in a header of a
23914framework that contains the subframework, or in a sibling subframework
23915header. Two subframeworks are siblings if they occur in the same
23916framework. A subframework should not have the same name as a
23917framework; a warning is issued if this is violated. Currently a
23918subframework cannot have subframeworks; in the future, the mechanism
23919may be extended to support this. The standard frameworks can be found
23920in @file{/System/Library/Frameworks} and
23921@file{/Library/Frameworks}. An example include looks like
23922@code{#include <Framework/header.h>}, where @file{Framework} denotes
23923the name of the framework and @file{header.h} is found in the
23924@file{PrivateHeaders} or @file{Headers} directory.
23925
d77de738 23926@opindex iframework
ddf6fe37 23927@item -iframework@var{dir}
d77de738
ML
23928Like @option{-F} except the directory is a treated as a system
23929directory. The main difference between this @option{-iframework} and
23930@option{-F} is that with @option{-iframework} the compiler does not
23931warn about constructs contained within header files found via
23932@var{dir}. This option is valid only for the C family of languages.
23933
d77de738 23934@opindex gused
ddf6fe37 23935@item -gused
d77de738
ML
23936Emit debugging information for symbols that are used. For stabs
23937debugging format, this enables @option{-feliminate-unused-debug-symbols}.
23938This is by default ON@.
23939
d77de738 23940@opindex gfull
ddf6fe37 23941@item -gfull
d77de738
ML
23942Emit debugging information for all symbols and types.
23943
23944@item -mmacosx-version-min=@var{version}
23945The earliest version of MacOS X that this executable will run on
23946is @var{version}. Typical values of @var{version} include @code{10.1},
23947@code{10.2}, and @code{10.3.9}.
23948
23949If the compiler was built to use the system's headers by default,
23950then the default for this option is the system version on which the
23951compiler is running, otherwise the default is to make choices that
23952are compatible with as many systems and code bases as possible.
23953
d77de738 23954@opindex mkernel
ddf6fe37 23955@item -mkernel
d77de738
ML
23956Enable kernel development mode. The @option{-mkernel} option sets
23957@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
23958@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
23959@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
23960applicable. This mode also sets @option{-mno-altivec},
23961@option{-msoft-float}, @option{-fno-builtin} and
23962@option{-mlong-branch} for PowerPC targets.
23963
d77de738 23964@opindex mone-byte-bool
ddf6fe37 23965@item -mone-byte-bool
d77de738
ML
23966Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
23967By default @code{sizeof(bool)} is @code{4} when compiling for
23968Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
23969option has no effect on x86.
23970
23971@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
23972to generate code that is not binary compatible with code generated
23973without that switch. Using this switch may require recompiling all
23974other modules in a program, including system libraries. Use this
23975switch to conform to a non-default data model.
23976
d77de738
ML
23977@opindex mfix-and-continue
23978@opindex ffix-and-continue
23979@opindex findirect-data
ddf6fe37
AA
23980@item -mfix-and-continue
23981@itemx -ffix-and-continue
23982@itemx -findirect-data
d77de738
ML
23983Generate code suitable for fast turnaround development, such as to
23984allow GDB to dynamically load @file{.o} files into already-running
23985programs. @option{-findirect-data} and @option{-ffix-and-continue}
23986are provided for backwards compatibility.
23987
d77de738 23988@opindex all_load
ddf6fe37 23989@item -all_load
d77de738
ML
23990Loads all members of static archive libraries.
23991See man ld(1) for more information.
23992
d77de738 23993@opindex arch_errors_fatal
ddf6fe37 23994@item -arch_errors_fatal
d77de738
ML
23995Cause the errors having to do with files that have the wrong architecture
23996to be fatal.
23997
d77de738 23998@opindex bind_at_load
ddf6fe37 23999@item -bind_at_load
d77de738
ML
24000Causes the output file to be marked such that the dynamic linker will
24001bind all undefined references when the file is loaded or launched.
24002
d77de738 24003@opindex bundle
ddf6fe37 24004@item -bundle
d77de738
ML
24005Produce a Mach-o bundle format file.
24006See man ld(1) for more information.
24007
d77de738 24008@opindex bundle_loader
ddf6fe37 24009@item -bundle_loader @var{executable}
d77de738
ML
24010This option specifies the @var{executable} that will load the build
24011output file being linked. See man ld(1) for more information.
24012
d77de738 24013@opindex dynamiclib
ddf6fe37 24014@item -dynamiclib
d77de738
ML
24015When passed this option, GCC produces a dynamic library instead of
24016an executable when linking, using the Darwin @file{libtool} command.
24017
d77de738 24018@opindex force_cpusubtype_ALL
ddf6fe37 24019@item -force_cpusubtype_ALL
d77de738
ML
24020This causes GCC's output file to have the @samp{ALL} subtype, instead of
24021one controlled by the @option{-mcpu} or @option{-march} option.
24022
24023@item -allowable_client @var{client_name}
24024@itemx -client_name
24025@itemx -compatibility_version
24026@itemx -current_version
24027@itemx -dead_strip
24028@itemx -dependency-file
24029@itemx -dylib_file
24030@itemx -dylinker_install_name
24031@itemx -dynamic
24032@itemx -exported_symbols_list
24033@itemx -filelist
24034@need 800
24035@itemx -flat_namespace
24036@itemx -force_flat_namespace
24037@itemx -headerpad_max_install_names
24038@itemx -image_base
24039@itemx -init
24040@itemx -install_name
24041@itemx -keep_private_externs
24042@itemx -multi_module
24043@itemx -multiply_defined
24044@itemx -multiply_defined_unused
24045@need 800
24046@itemx -noall_load
24047@itemx -no_dead_strip_inits_and_terms
24048@itemx -nofixprebinding
24049@itemx -nomultidefs
24050@itemx -noprebind
24051@itemx -noseglinkedit
24052@itemx -pagezero_size
24053@itemx -prebind
24054@itemx -prebind_all_twolevel_modules
24055@itemx -private_bundle
24056@need 800
24057@itemx -read_only_relocs
24058@itemx -sectalign
24059@itemx -sectobjectsymbols
24060@itemx -whyload
24061@itemx -seg1addr
24062@itemx -sectcreate
24063@itemx -sectobjectsymbols
24064@itemx -sectorder
24065@itemx -segaddr
24066@itemx -segs_read_only_addr
24067@need 800
24068@itemx -segs_read_write_addr
24069@itemx -seg_addr_table
24070@itemx -seg_addr_table_filename
24071@itemx -seglinkedit
24072@itemx -segprot
24073@itemx -segs_read_only_addr
24074@itemx -segs_read_write_addr
24075@itemx -single_module
24076@itemx -static
24077@itemx -sub_library
24078@need 800
d77de738
ML
24079@opindex allowable_client
24080@opindex client_name
24081@opindex compatibility_version
24082@opindex current_version
24083@opindex dead_strip
24084@opindex dependency-file
24085@opindex dylib_file
24086@opindex dylinker_install_name
24087@opindex dynamic
24088@opindex exported_symbols_list
24089@opindex filelist
24090@opindex flat_namespace
24091@opindex force_flat_namespace
24092@opindex headerpad_max_install_names
24093@opindex image_base
24094@opindex init
24095@opindex install_name
24096@opindex keep_private_externs
24097@opindex multi_module
24098@opindex multiply_defined
24099@opindex multiply_defined_unused
24100@opindex noall_load
24101@opindex no_dead_strip_inits_and_terms
24102@opindex nofixprebinding
24103@opindex nomultidefs
24104@opindex noprebind
24105@opindex noseglinkedit
24106@opindex pagezero_size
24107@opindex prebind
24108@opindex prebind_all_twolevel_modules
24109@opindex private_bundle
24110@opindex read_only_relocs
24111@opindex sectalign
24112@opindex sectobjectsymbols
24113@opindex whyload
24114@opindex seg1addr
24115@opindex sectcreate
24116@opindex sectobjectsymbols
24117@opindex sectorder
24118@opindex segaddr
24119@opindex segs_read_only_addr
24120@opindex segs_read_write_addr
24121@opindex seg_addr_table
24122@opindex seg_addr_table_filename
24123@opindex seglinkedit
24124@opindex segprot
24125@opindex segs_read_only_addr
24126@opindex segs_read_write_addr
24127@opindex single_module
24128@opindex static
24129@opindex sub_library
24130@opindex sub_umbrella
24131@opindex twolevel_namespace
24132@opindex umbrella
24133@opindex undefined
24134@opindex unexported_symbols_list
24135@opindex weak_reference_mismatches
24136@opindex whatsloaded
ddf6fe37
AA
24137@itemx -sub_umbrella
24138@itemx -twolevel_namespace
24139@itemx -umbrella
24140@itemx -undefined
24141@itemx -unexported_symbols_list
24142@itemx -weak_reference_mismatches
24143@itemx -whatsloaded
d77de738
ML
24144These options are passed to the Darwin linker. The Darwin linker man page
24145describes them in detail.
24146@end table
24147
24148@node DEC Alpha Options
24149@subsection DEC Alpha Options
24150
24151These @samp{-m} options are defined for the DEC Alpha implementations:
24152
24153@table @gcctabopt
d77de738
ML
24154@opindex mno-soft-float
24155@opindex msoft-float
ddf6fe37
AA
24156@item -mno-soft-float
24157@itemx -msoft-float
d77de738
ML
24158Use (do not use) the hardware floating-point instructions for
24159floating-point operations. When @option{-msoft-float} is specified,
24160functions in @file{libgcc.a} are used to perform floating-point
24161operations. Unless they are replaced by routines that emulate the
24162floating-point operations, or compiled in such a way as to call such
24163emulations routines, these routines issue floating-point
24164operations. If you are compiling for an Alpha without floating-point
24165operations, you must ensure that the library is built so as not to call
24166them.
24167
24168Note that Alpha implementations without floating-point operations are
24169required to have floating-point registers.
24170
d77de738
ML
24171@opindex mfp-reg
24172@opindex mno-fp-regs
ddf6fe37
AA
24173@item -mfp-reg
24174@itemx -mno-fp-regs
d77de738
ML
24175Generate code that uses (does not use) the floating-point register set.
24176@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24177register set is not used, floating-point operands are passed in integer
24178registers as if they were integers and floating-point results are passed
24179in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24180so any function with a floating-point argument or return value called by code
24181compiled with @option{-mno-fp-regs} must also be compiled with that
24182option.
24183
24184A typical use of this option is building a kernel that does not use,
24185and hence need not save and restore, any floating-point registers.
24186
d77de738 24187@opindex mieee
ddf6fe37 24188@item -mieee
d77de738
ML
24189The Alpha architecture implements floating-point hardware optimized for
24190maximum performance. It is mostly compliant with the IEEE floating-point
24191standard. However, for full compliance, software assistance is
24192required. This option generates code fully IEEE-compliant code
24193@emph{except} that the @var{inexact-flag} is not maintained (see below).
24194If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24195defined during compilation. The resulting code is less efficient but is
24196able to correctly support denormalized numbers and exceptional IEEE
24197values such as not-a-number and plus/minus infinity. Other Alpha
24198compilers call this option @option{-ieee_with_no_inexact}.
24199
d77de738 24200@opindex mieee-with-inexact
ddf6fe37 24201@item -mieee-with-inexact
d77de738
ML
24202This is like @option{-mieee} except the generated code also maintains
24203the IEEE @var{inexact-flag}. Turning on this option causes the
24204generated code to implement fully-compliant IEEE math. In addition to
24205@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24206macro. On some Alpha implementations the resulting code may execute
24207significantly slower than the code generated by default. Since there is
24208very little code that depends on the @var{inexact-flag}, you should
24209normally not specify this option. Other Alpha compilers call this
24210option @option{-ieee_with_inexact}.
24211
d77de738 24212@opindex mfp-trap-mode
ddf6fe37 24213@item -mfp-trap-mode=@var{trap-mode}
d77de738
ML
24214This option controls what floating-point related traps are enabled.
24215Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24216The trap mode can be set to one of four values:
24217
24218@table @samp
24219@item n
24220This is the default (normal) setting. The only traps that are enabled
24221are the ones that cannot be disabled in software (e.g., division by zero
24222trap).
24223
24224@item u
24225In addition to the traps enabled by @samp{n}, underflow traps are enabled
24226as well.
24227
24228@item su
24229Like @samp{u}, but the instructions are marked to be safe for software
24230completion (see Alpha architecture manual for details).
24231
24232@item sui
24233Like @samp{su}, but inexact traps are enabled as well.
24234@end table
24235
d77de738 24236@opindex mfp-rounding-mode
ddf6fe37 24237@item -mfp-rounding-mode=@var{rounding-mode}
d77de738
ML
24238Selects the IEEE rounding mode. Other Alpha compilers call this option
24239@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24240of:
24241
24242@table @samp
24243@item n
24244Normal IEEE rounding mode. Floating-point numbers are rounded towards
24245the nearest machine number or towards the even machine number in case
24246of a tie.
24247
24248@item m
24249Round towards minus infinity.
24250
24251@item c
24252Chopped rounding mode. Floating-point numbers are rounded towards zero.
24253
24254@item d
24255Dynamic rounding mode. A field in the floating-point control register
24256(@var{fpcr}, see Alpha architecture reference manual) controls the
24257rounding mode in effect. The C library initializes this register for
24258rounding towards plus infinity. Thus, unless your program modifies the
24259@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24260@end table
24261
d77de738 24262@opindex mtrap-precision
ddf6fe37 24263@item -mtrap-precision=@var{trap-precision}
d77de738
ML
24264In the Alpha architecture, floating-point traps are imprecise. This
24265means without software assistance it is impossible to recover from a
24266floating trap and program execution normally needs to be terminated.
24267GCC can generate code that can assist operating system trap handlers
24268in determining the exact location that caused a floating-point trap.
24269Depending on the requirements of an application, different levels of
24270precisions can be selected:
24271
24272@table @samp
24273@item p
24274Program precision. This option is the default and means a trap handler
24275can only identify which program caused a floating-point exception.
24276
24277@item f
24278Function precision. The trap handler can determine the function that
24279caused a floating-point exception.
24280
24281@item i
24282Instruction precision. The trap handler can determine the exact
24283instruction that caused a floating-point exception.
24284@end table
24285
24286Other Alpha compilers provide the equivalent options called
24287@option{-scope_safe} and @option{-resumption_safe}.
24288
d77de738 24289@opindex mieee-conformant
ddf6fe37 24290@item -mieee-conformant
d77de738
ML
24291This option marks the generated code as IEEE conformant. You must not
24292use this option unless you also specify @option{-mtrap-precision=i} and either
24293@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24294is to emit the line @samp{.eflag 48} in the function prologue of the
24295generated assembly file.
24296
d77de738 24297@opindex mbuild-constants
ddf6fe37 24298@item -mbuild-constants
d77de738
ML
24299Normally GCC examines a 32- or 64-bit integer constant to
24300see if it can construct it from smaller constants in two or three
24301instructions. If it cannot, it outputs the constant as a literal and
24302generates code to load it from the data segment at run time.
24303
24304Use this option to require GCC to construct @emph{all} integer constants
24305using code, even if it takes more instructions (the maximum is six).
24306
24307You typically use this option to build a shared library dynamic
24308loader. Itself a shared library, it must relocate itself in memory
24309before it can find the variables and constants in its own data segment.
24310
d77de738
ML
24311@opindex mbwx
24312@opindex mno-bwx
24313@opindex mcix
24314@opindex mno-cix
24315@opindex mfix
24316@opindex mno-fix
24317@opindex mmax
24318@opindex mno-max
ddf6fe37
AA
24319@item -mbwx
24320@itemx -mno-bwx
24321@itemx -mcix
24322@itemx -mno-cix
24323@itemx -mfix
24324@itemx -mno-fix
24325@itemx -mmax
24326@itemx -mno-max
d77de738
ML
24327Indicate whether GCC should generate code to use the optional BWX,
24328CIX, FIX and MAX instruction sets. The default is to use the instruction
24329sets supported by the CPU type specified via @option{-mcpu=} option or that
24330of the CPU on which GCC was built if none is specified.
24331
d77de738
ML
24332@opindex mfloat-vax
24333@opindex mfloat-ieee
ddf6fe37
AA
24334@item -mfloat-vax
24335@itemx -mfloat-ieee
d77de738
ML
24336Generate code that uses (does not use) VAX F and G floating-point
24337arithmetic instead of IEEE single and double precision.
24338
d77de738
ML
24339@opindex mexplicit-relocs
24340@opindex mno-explicit-relocs
ddf6fe37
AA
24341@item -mexplicit-relocs
24342@itemx -mno-explicit-relocs
d77de738
ML
24343Older Alpha assemblers provided no way to generate symbol relocations
24344except via assembler macros. Use of these macros does not allow
24345optimal instruction scheduling. GNU binutils as of version 2.12
24346supports a new syntax that allows the compiler to explicitly mark
24347which relocations should apply to which instructions. This option
24348is mostly useful for debugging, as GCC detects the capabilities of
24349the assembler when it is built and sets the default accordingly.
24350
d77de738
ML
24351@opindex msmall-data
24352@opindex mlarge-data
ddf6fe37
AA
24353@item -msmall-data
24354@itemx -mlarge-data
d77de738
ML
24355When @option{-mexplicit-relocs} is in effect, static data is
24356accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24357is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24358(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2435916-bit relocations off of the @code{$gp} register. This limits the
24360size of the small data area to 64KB, but allows the variables to be
24361directly accessed via a single instruction.
24362
24363The default is @option{-mlarge-data}. With this option the data area
24364is limited to just below 2GB@. Programs that require more than 2GB of
24365data must use @code{malloc} or @code{mmap} to allocate the data in the
24366heap instead of in the program's data segment.
24367
24368When generating code for shared libraries, @option{-fpic} implies
24369@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24370
d77de738
ML
24371@opindex msmall-text
24372@opindex mlarge-text
ddf6fe37
AA
24373@item -msmall-text
24374@itemx -mlarge-text
d77de738
ML
24375When @option{-msmall-text} is used, the compiler assumes that the
24376code of the entire program (or shared library) fits in 4MB, and is
24377thus reachable with a branch instruction. When @option{-msmall-data}
24378is used, the compiler can assume that all local symbols share the
24379same @code{$gp} value, and thus reduce the number of instructions
24380required for a function call from 4 to 1.
24381
24382The default is @option{-mlarge-text}.
24383
d77de738 24384@opindex mcpu
ddf6fe37 24385@item -mcpu=@var{cpu_type}
d77de738
ML
24386Set the instruction set and instruction scheduling parameters for
24387machine type @var{cpu_type}. You can specify either the @samp{EV}
24388style name or the corresponding chip number. GCC supports scheduling
24389parameters for the EV4, EV5 and EV6 family of processors and
24390chooses the default values for the instruction set from the processor
24391you specify. If you do not specify a processor type, GCC defaults
24392to the processor on which the compiler was built.
24393
24394Supported values for @var{cpu_type} are
24395
24396@table @samp
24397@item ev4
24398@itemx ev45
24399@itemx 21064
24400Schedules as an EV4 and has no instruction set extensions.
24401
24402@item ev5
24403@itemx 21164
24404Schedules as an EV5 and has no instruction set extensions.
24405
24406@item ev56
24407@itemx 21164a
24408Schedules as an EV5 and supports the BWX extension.
24409
24410@item pca56
24411@itemx 21164pc
24412@itemx 21164PC
24413Schedules as an EV5 and supports the BWX and MAX extensions.
24414
24415@item ev6
24416@itemx 21264
24417Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24418
24419@item ev67
24420@itemx 21264a
24421Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24422@end table
24423
24424Native toolchains also support the value @samp{native},
24425which selects the best architecture option for the host processor.
24426@option{-mcpu=native} has no effect if GCC does not recognize
24427the processor.
24428
d77de738 24429@opindex mtune
ddf6fe37 24430@item -mtune=@var{cpu_type}
d77de738
ML
24431Set only the instruction scheduling parameters for machine type
24432@var{cpu_type}. The instruction set is not changed.
24433
24434Native toolchains also support the value @samp{native},
24435which selects the best architecture option for the host processor.
24436@option{-mtune=native} has no effect if GCC does not recognize
24437the processor.
24438
d77de738 24439@opindex mmemory-latency
ddf6fe37 24440@item -mmemory-latency=@var{time}
d77de738
ML
24441Sets the latency the scheduler should assume for typical memory
24442references as seen by the application. This number is highly
24443dependent on the memory access patterns used by the application
24444and the size of the external cache on the machine.
24445
24446Valid options for @var{time} are
24447
24448@table @samp
24449@item @var{number}
24450A decimal number representing clock cycles.
24451
24452@item L1
24453@itemx L2
24454@itemx L3
24455@itemx main
24456The compiler contains estimates of the number of clock cycles for
24457``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24458(also called Dcache, Scache, and Bcache), as well as to main memory.
24459Note that L3 is only valid for EV5.
24460
24461@end table
24462@end table
24463
24464@node eBPF Options
24465@subsection eBPF Options
24466@cindex eBPF Options
24467
24468@table @gcctabopt
24469@item -mframe-limit=@var{bytes}
24470This specifies the hard limit for frame sizes, in bytes. Currently,
24471the value that can be specified should be less than or equal to
24472@samp{32767}. Defaults to whatever limit is imposed by the version of
24473the Linux kernel targeted.
24474
d77de738 24475@opindex mkernel
ddf6fe37 24476@item -mkernel=@var{version}
d77de738
ML
24477This specifies the minimum version of the kernel that will run the
24478compiled program. GCC uses this version to determine which
24479instructions to use, what kernel helpers to allow, etc. Currently,
24480@var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
24481@samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
24482@samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
24483@samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
24484@samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
24485@samp{5.2}, @samp{latest} and @samp{native}.
24486
d77de738 24487@opindex mbig-endian
ddf6fe37 24488@item -mbig-endian
d77de738
ML
24489Generate code for a big-endian target.
24490
d77de738 24491@opindex mlittle-endian
ddf6fe37 24492@item -mlittle-endian
d77de738
ML
24493Generate code for a little-endian target. This is the default.
24494
d77de738 24495@opindex mjmpext
ddf6fe37 24496@item -mjmpext
d77de738
ML
24497Enable generation of extra conditional-branch instructions.
24498Enabled for CPU v2 and above.
24499
d77de738 24500@opindex mjmp32
ddf6fe37 24501@item -mjmp32
d77de738
ML
24502Enable 32-bit jump instructions. Enabled for CPU v3 and above.
24503
d77de738 24504@opindex malu32
ddf6fe37 24505@item -malu32
d77de738
ML
24506Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
24507
d77de738 24508@opindex mcpu
ddf6fe37 24509@item -mcpu=@var{version}
d77de738
ML
24510This specifies which version of the eBPF ISA to target. Newer versions
24511may not be supported by all kernels. The default is @samp{v3}.
24512
24513Supported values for @var{version} are:
24514
24515@table @samp
24516@item v1
24517The first stable eBPF ISA with no special features or extensions.
24518
24519@item v2
24520Supports the jump extensions, as in @option{-mjmpext}.
24521
24522@item v3
24523All features of v2, plus:
24524@itemize @minus
24525@item 32-bit jump operations, as in @option{-mjmp32}
24526@item 32-bit ALU operations, as in @option{-malu32}
24527@end itemize
24528
24529@end table
24530
d77de738 24531@opindex mco-re
ddf6fe37 24532@item -mco-re
d77de738
ML
24533Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24534is implied by @option{-gbtf}.
24535
d77de738 24536@opindex mno-co-re
ddf6fe37 24537@item -mno-co-re
d77de738
ML
24538Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24539support is enabled by default when generating BTF debug information for
24540the BPF target.
24541
24542@item -mxbpf
24543Generate code for an expanded version of BPF, which relaxes some of
24544the restrictions imposed by the BPF architecture:
24545@itemize @minus
24546@item Save and restore callee-saved registers at function entry and
24547exit, respectively.
24548@end itemize
24549@end table
24550
24551@node FR30 Options
24552@subsection FR30 Options
24553@cindex FR30 Options
24554
24555These options are defined specifically for the FR30 port.
24556
24557@table @gcctabopt
24558
d77de738 24559@opindex msmall-model
ddf6fe37 24560@item -msmall-model
d77de738
ML
24561Use the small address space model. This can produce smaller code, but
24562it does assume that all symbolic values and addresses fit into a
2456320-bit range.
24564
d77de738 24565@opindex mno-lsim
ddf6fe37 24566@item -mno-lsim
d77de738
ML
24567Assume that runtime support has been provided and so there is no need
24568to include the simulator library (@file{libsim.a}) on the linker
24569command line.
24570
24571@end table
24572
24573@node FT32 Options
24574@subsection FT32 Options
24575@cindex FT32 Options
24576
24577These options are defined specifically for the FT32 port.
24578
24579@table @gcctabopt
24580
d77de738 24581@opindex msim
ddf6fe37 24582@item -msim
d77de738
ML
24583Specifies that the program will be run on the simulator. This causes
24584an alternate runtime startup and library to be linked.
24585You must not use this option when generating programs that will run on
24586real hardware; you must provide your own runtime library for whatever
24587I/O functions are needed.
24588
d77de738 24589@opindex mlra
ddf6fe37 24590@item -mlra
d77de738
ML
24591Enable Local Register Allocation. This is still experimental for FT32,
24592so by default the compiler uses standard reload.
24593
d77de738 24594@opindex mnodiv
ddf6fe37 24595@item -mnodiv
d77de738
ML
24596Do not use div and mod instructions.
24597
d77de738 24598@opindex mft32b
ddf6fe37 24599@item -mft32b
d77de738
ML
24600Enable use of the extended instructions of the FT32B processor.
24601
d77de738 24602@opindex mcompress
ddf6fe37 24603@item -mcompress
d77de738
ML
24604Compress all code using the Ft32B code compression scheme.
24605
d77de738 24606@opindex mnopm
ddf6fe37 24607@item -mnopm
d77de738
ML
24608Do not generate code that reads program memory.
24609
24610@end table
24611
24612@node FRV Options
24613@subsection FRV Options
24614@cindex FRV Options
24615
24616@table @gcctabopt
d77de738 24617@opindex mgpr-32
ddf6fe37 24618@item -mgpr-32
d77de738
ML
24619
24620Only use the first 32 general-purpose registers.
24621
d77de738 24622@opindex mgpr-64
ddf6fe37 24623@item -mgpr-64
d77de738
ML
24624
24625Use all 64 general-purpose registers.
24626
d77de738 24627@opindex mfpr-32
ddf6fe37 24628@item -mfpr-32
d77de738
ML
24629
24630Use only the first 32 floating-point registers.
24631
d77de738 24632@opindex mfpr-64
ddf6fe37 24633@item -mfpr-64
d77de738
ML
24634
24635Use all 64 floating-point registers.
24636
d77de738 24637@opindex mhard-float
ddf6fe37 24638@item -mhard-float
d77de738
ML
24639
24640Use hardware instructions for floating-point operations.
24641
d77de738 24642@opindex msoft-float
ddf6fe37 24643@item -msoft-float
d77de738
ML
24644
24645Use library routines for floating-point operations.
24646
d77de738 24647@opindex malloc-cc
ddf6fe37 24648@item -malloc-cc
d77de738
ML
24649
24650Dynamically allocate condition code registers.
24651
d77de738 24652@opindex mfixed-cc
ddf6fe37 24653@item -mfixed-cc
d77de738
ML
24654
24655Do not try to dynamically allocate condition code registers, only
24656use @code{icc0} and @code{fcc0}.
24657
d77de738 24658@opindex mdword
ddf6fe37 24659@item -mdword
d77de738
ML
24660
24661Change ABI to use double word insns.
24662
d77de738
ML
24663@opindex mno-dword
24664@opindex mdword
ddf6fe37 24665@item -mno-dword
d77de738
ML
24666
24667Do not use double word instructions.
24668
d77de738 24669@opindex mdouble
ddf6fe37 24670@item -mdouble
d77de738
ML
24671
24672Use floating-point double instructions.
24673
d77de738 24674@opindex mno-double
ddf6fe37 24675@item -mno-double
d77de738
ML
24676
24677Do not use floating-point double instructions.
24678
d77de738 24679@opindex mmedia
ddf6fe37 24680@item -mmedia
d77de738
ML
24681
24682Use media instructions.
24683
d77de738 24684@opindex mno-media
ddf6fe37 24685@item -mno-media
d77de738
ML
24686
24687Do not use media instructions.
24688
d77de738 24689@opindex mmuladd
ddf6fe37 24690@item -mmuladd
d77de738
ML
24691
24692Use multiply and add/subtract instructions.
24693
d77de738 24694@opindex mno-muladd
ddf6fe37 24695@item -mno-muladd
d77de738
ML
24696
24697Do not use multiply and add/subtract instructions.
24698
d77de738 24699@opindex mfdpic
ddf6fe37 24700@item -mfdpic
d77de738
ML
24701
24702Select the FDPIC ABI, which uses function descriptors to represent
24703pointers to functions. Without any PIC/PIE-related options, it
24704implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
24705assumes GOT entries and small data are within a 12-bit range from the
24706GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
24707are computed with 32 bits.
24708With a @samp{bfin-elf} target, this option implies @option{-msim}.
24709
d77de738 24710@opindex minline-plt
ddf6fe37 24711@item -minline-plt
d77de738
ML
24712
24713Enable inlining of PLT entries in function calls to functions that are
24714not known to bind locally. It has no effect without @option{-mfdpic}.
24715It's enabled by default if optimizing for speed and compiling for
24716shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
24717optimization option such as @option{-O3} or above is present in the
24718command line.
24719
d77de738 24720@opindex mTLS
ddf6fe37 24721@item -mTLS
d77de738
ML
24722
24723Assume a large TLS segment when generating thread-local code.
24724
d77de738 24725@opindex mtls
ddf6fe37 24726@item -mtls
d77de738
ML
24727
24728Do not assume a large TLS segment when generating thread-local code.
24729
d77de738 24730@opindex mgprel-ro
ddf6fe37 24731@item -mgprel-ro
d77de738
ML
24732
24733Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
24734that is known to be in read-only sections. It's enabled by default,
24735except for @option{-fpic} or @option{-fpie}: even though it may help
24736make the global offset table smaller, it trades 1 instruction for 4.
24737With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
24738one of which may be shared by multiple symbols, and it avoids the need
24739for a GOT entry for the referenced symbol, so it's more likely to be a
24740win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
24741
d77de738 24742@opindex multilib-library-pic
ddf6fe37 24743@item -multilib-library-pic
d77de738
ML
24744
24745Link with the (library, not FD) pic libraries. It's implied by
24746@option{-mlibrary-pic}, as well as by @option{-fPIC} and
24747@option{-fpic} without @option{-mfdpic}. You should never have to use
24748it explicitly.
24749
d77de738 24750@opindex mlinked-fp
ddf6fe37 24751@item -mlinked-fp
d77de738
ML
24752
24753Follow the EABI requirement of always creating a frame pointer whenever
24754a stack frame is allocated. This option is enabled by default and can
24755be disabled with @option{-mno-linked-fp}.
24756
d77de738 24757@opindex mlong-calls
ddf6fe37 24758@item -mlong-calls
d77de738
ML
24759
24760Use indirect addressing to call functions outside the current
24761compilation unit. This allows the functions to be placed anywhere
24762within the 32-bit address space.
24763
d77de738 24764@opindex malign-labels
ddf6fe37 24765@item -malign-labels
d77de738
ML
24766
24767Try to align labels to an 8-byte boundary by inserting NOPs into the
24768previous packet. This option only has an effect when VLIW packing
24769is enabled. It doesn't create new packets; it merely adds NOPs to
24770existing ones.
24771
d77de738 24772@opindex mlibrary-pic
ddf6fe37 24773@item -mlibrary-pic
d77de738
ML
24774
24775Generate position-independent EABI code.
24776
d77de738 24777@opindex macc-4
ddf6fe37 24778@item -macc-4
d77de738
ML
24779
24780Use only the first four media accumulator registers.
24781
d77de738 24782@opindex macc-8
ddf6fe37 24783@item -macc-8
d77de738
ML
24784
24785Use all eight media accumulator registers.
24786
d77de738 24787@opindex mpack
ddf6fe37 24788@item -mpack
d77de738
ML
24789
24790Pack VLIW instructions.
24791
d77de738 24792@opindex mno-pack
ddf6fe37 24793@item -mno-pack
d77de738
ML
24794
24795Do not pack VLIW instructions.
24796
d77de738 24797@opindex mno-eflags
ddf6fe37 24798@item -mno-eflags
d77de738
ML
24799
24800Do not mark ABI switches in e_flags.
24801
d77de738 24802@opindex mcond-move
ddf6fe37 24803@item -mcond-move
d77de738
ML
24804
24805Enable the use of conditional-move instructions (default).
24806
24807This switch is mainly for debugging the compiler and will likely be removed
24808in a future version.
24809
d77de738 24810@opindex mno-cond-move
ddf6fe37 24811@item -mno-cond-move
d77de738
ML
24812
24813Disable the use of conditional-move instructions.
24814
24815This switch is mainly for debugging the compiler and will likely be removed
24816in a future version.
24817
d77de738 24818@opindex mscc
ddf6fe37 24819@item -mscc
d77de738
ML
24820
24821Enable the use of conditional set instructions (default).
24822
24823This switch is mainly for debugging the compiler and will likely be removed
24824in a future version.
24825
d77de738 24826@opindex mno-scc
ddf6fe37 24827@item -mno-scc
d77de738
ML
24828
24829Disable the use of conditional set instructions.
24830
24831This switch is mainly for debugging the compiler and will likely be removed
24832in a future version.
24833
d77de738 24834@opindex mcond-exec
ddf6fe37 24835@item -mcond-exec
d77de738
ML
24836
24837Enable the use of conditional execution (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-exec
ddf6fe37 24843@item -mno-cond-exec
d77de738
ML
24844
24845Disable the use of conditional execution.
24846
24847This switch is mainly for debugging the compiler and will likely be removed
24848in a future version.
24849
d77de738 24850@opindex mvliw-branch
ddf6fe37 24851@item -mvliw-branch
d77de738
ML
24852
24853Run a pass to pack branches into VLIW 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-vliw-branch
ddf6fe37 24859@item -mno-vliw-branch
d77de738
ML
24860
24861Do not run a pass to pack branches into VLIW instructions.
24862
24863This switch is mainly for debugging the compiler and will likely be removed
24864in a future version.
24865
d77de738 24866@opindex mmulti-cond-exec
ddf6fe37 24867@item -mmulti-cond-exec
d77de738
ML
24868
24869Enable optimization of @code{&&} and @code{||} in conditional execution
24870(default).
24871
24872This switch is mainly for debugging the compiler and will likely be removed
24873in a future version.
24874
d77de738 24875@opindex mno-multi-cond-exec
ddf6fe37 24876@item -mno-multi-cond-exec
d77de738
ML
24877
24878Disable optimization of @code{&&} and @code{||} in conditional execution.
24879
24880This switch is mainly for debugging the compiler and will likely be removed
24881in a future version.
24882
d77de738 24883@opindex mnested-cond-exec
ddf6fe37 24884@item -mnested-cond-exec
d77de738
ML
24885
24886Enable nested conditional execution optimizations (default).
24887
24888This switch is mainly for debugging the compiler and will likely be removed
24889in a future version.
24890
d77de738 24891@opindex mno-nested-cond-exec
ddf6fe37 24892@item -mno-nested-cond-exec
d77de738
ML
24893
24894Disable nested conditional execution optimizations.
24895
24896This switch is mainly for debugging the compiler and will likely be removed
24897in a future version.
24898
d77de738 24899@opindex moptimize-membar
ddf6fe37 24900@item -moptimize-membar
d77de738
ML
24901
24902This switch removes redundant @code{membar} instructions from the
24903compiler-generated code. It is enabled by default.
24904
d77de738
ML
24905@opindex mno-optimize-membar
24906@opindex moptimize-membar
ddf6fe37 24907@item -mno-optimize-membar
d77de738
ML
24908
24909This switch disables the automatic removal of redundant @code{membar}
24910instructions from the generated code.
24911
d77de738 24912@opindex mtomcat-stats
ddf6fe37 24913@item -mtomcat-stats
d77de738
ML
24914
24915Cause gas to print out tomcat statistics.
24916
d77de738 24917@opindex mcpu
ddf6fe37 24918@item -mcpu=@var{cpu}
d77de738
ML
24919
24920Select the processor type for which to generate code. Possible values are
24921@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
24922@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
24923
24924@end table
24925
24926@node GNU/Linux Options
24927@subsection GNU/Linux Options
24928
24929These @samp{-m} options are defined for GNU/Linux targets:
24930
24931@table @gcctabopt
d77de738 24932@opindex mglibc
ddf6fe37 24933@item -mglibc
d77de738
ML
24934Use the GNU C library. This is the default except
24935on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
24936@samp{*-*-linux-*android*} targets.
24937
d77de738 24938@opindex muclibc
ddf6fe37 24939@item -muclibc
d77de738
ML
24940Use uClibc C library. This is the default on
24941@samp{*-*-linux-*uclibc*} targets.
24942
d77de738 24943@opindex mmusl
ddf6fe37 24944@item -mmusl
d77de738
ML
24945Use the musl C library. This is the default on
24946@samp{*-*-linux-*musl*} targets.
24947
d77de738 24948@opindex mbionic
ddf6fe37 24949@item -mbionic
d77de738
ML
24950Use Bionic C library. This is the default on
24951@samp{*-*-linux-*android*} targets.
24952
d77de738 24953@opindex mandroid
ddf6fe37 24954@item -mandroid
d77de738
ML
24955Compile code compatible with Android platform. This is the default on
24956@samp{*-*-linux-*android*} targets.
24957
24958When compiling, this option enables @option{-mbionic}, @option{-fPIC},
24959@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
24960this option makes the GCC driver pass Android-specific options to the linker.
24961Finally, this option causes the preprocessor macro @code{__ANDROID__}
24962to be defined.
24963
d77de738 24964@opindex tno-android-cc
ddf6fe37 24965@item -tno-android-cc
d77de738
ML
24966Disable compilation effects of @option{-mandroid}, i.e., do not enable
24967@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
24968@option{-fno-rtti} by default.
24969
d77de738 24970@opindex tno-android-ld
ddf6fe37 24971@item -tno-android-ld
d77de738
ML
24972Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
24973linking options to the linker.
24974
24975@end table
24976
24977@node H8/300 Options
24978@subsection H8/300 Options
24979
24980These @samp{-m} options are defined for the H8/300 implementations:
24981
24982@table @gcctabopt
d77de738 24983@opindex mrelax
ddf6fe37 24984@item -mrelax
d77de738
ML
24985Shorten some address references at link time, when possible; uses the
24986linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
24987ld, Using ld}, for a fuller description.
24988
d77de738 24989@opindex mh
ddf6fe37 24990@item -mh
d77de738
ML
24991Generate code for the H8/300H@.
24992
d77de738 24993@opindex ms
ddf6fe37 24994@item -ms
d77de738
ML
24995Generate code for the H8S@.
24996
d77de738 24997@opindex mn
ddf6fe37 24998@item -mn
d77de738
ML
24999Generate code for the H8S and H8/300H in the normal mode. This switch
25000must be used either with @option{-mh} or @option{-ms}.
25001
d77de738 25002@opindex ms2600
ddf6fe37 25003@item -ms2600
d77de738
ML
25004Generate code for the H8S/2600. This switch must be used with @option{-ms}.
25005
d77de738 25006@opindex mexr
ddf6fe37 25007@item -mexr
d77de738
ML
25008Extended registers are stored on stack before execution of function
25009with monitor attribute. Default option is @option{-mexr}.
25010This option is valid only for H8S targets.
25011
d77de738
ML
25012@opindex mno-exr
25013@opindex mexr
ddf6fe37 25014@item -mno-exr
d77de738
ML
25015Extended registers are not stored on stack before execution of function
25016with monitor attribute. Default option is @option{-mno-exr}.
25017This option is valid only for H8S targets.
25018
d77de738 25019@opindex mint32
ddf6fe37 25020@item -mint32
d77de738
ML
25021Make @code{int} data 32 bits by default.
25022
d77de738 25023@opindex malign-300
ddf6fe37 25024@item -malign-300
d77de738
ML
25025On the H8/300H and H8S, use the same alignment rules as for the H8/300.
25026The default for the H8/300H and H8S is to align longs and floats on
250274-byte boundaries.
25028@option{-malign-300} causes them to be aligned on 2-byte boundaries.
25029This option has no effect on the H8/300.
25030@end table
25031
25032@node HPPA Options
25033@subsection HPPA Options
25034@cindex HPPA Options
25035
25036These @samp{-m} options are defined for the HPPA family of computers:
25037
25038@table @gcctabopt
d77de738 25039@opindex march
ddf6fe37 25040@item -march=@var{architecture-type}
d77de738
ML
25041Generate code for the specified architecture. The choices for
25042@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
250431.1, and @samp{2.0} for PA 2.0 processors. Refer to
25044@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
25045architecture option for your machine. Code compiled for lower numbered
25046architectures runs on higher numbered architectures, but not the
25047other way around.
25048
d77de738
ML
25049@opindex mpa-risc-1-0
25050@opindex mpa-risc-1-1
25051@opindex mpa-risc-2-0
ddf6fe37
AA
25052@item -mpa-risc-1-0
25053@itemx -mpa-risc-1-1
25054@itemx -mpa-risc-2-0
d77de738
ML
25055Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
25056
cf467fb9
JDA
25057@opindex matomic-libcalls
25058@opindex mno-atomic-libcalls
ddf6fe37 25059@item -matomic-libcalls
cf467fb9
JDA
25060Generate libcalls for atomic loads and stores when sync libcalls are disabled.
25061This option is enabled by default. It only affects the generation of
25062atomic libcalls by the HPPA backend.
25063
25064Both the sync and @file{libatomic} libcall implementations use locking.
25065As a result, processor stores are not atomic with respect to other
25066atomic operations. Processor loads up to DImode are atomic with
25067respect to other atomic operations provided they are implemented as
25068a single access.
25069
25070The PA-RISC architecture does not support any atomic operations in
25071hardware except for the @code{ldcw} instruction. Thus, all atomic
25072support is implemented using sync and atomic libcalls. Sync libcall
25073support is in @file{libgcc.a}. Atomic libcall support is in
25074@file{libatomic}.
25075
25076This option generates @code{__atomic_exchange} calls for atomic stores.
25077It also provides special handling for atomic DImode accesses on 32-bit
25078targets.
25079
cf467fb9 25080@opindex mbig-switch
ddf6fe37 25081@item -mbig-switch
cf467fb9
JDA
25082Does nothing. Preserved for backward compatibility.
25083
d77de738 25084@opindex mcaller-copies
ddf6fe37 25085@item -mcaller-copies
d77de738
ML
25086The caller copies function arguments passed by hidden reference. This
25087option should be used with care as it is not compatible with the default
2508832-bit runtime. However, only aggregates larger than eight bytes are
25089passed by hidden reference and the option provides better compatibility
25090with OpenMP.
25091
cf467fb9 25092@opindex mcoherent-ldcw
ddf6fe37 25093@item -mcoherent-ldcw
cf467fb9 25094Use ldcw/ldcd coherent cache-control hint.
d77de738 25095
d77de738 25096@opindex mdisable-fpregs
ddf6fe37 25097@item -mdisable-fpregs
cf467fb9 25098Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738 25099
d77de738 25100@opindex mdisable-indexing
ddf6fe37 25101@item -mdisable-indexing
d77de738
ML
25102Prevent the compiler from using indexing address modes. This avoids some
25103rather obscure problems when compiling MIG generated code under MACH@.
25104
d77de738 25105@opindex mfast-indirect-calls
ddf6fe37 25106@item -mfast-indirect-calls
d77de738
ML
25107Generate code that assumes calls never cross space boundaries. This
25108allows GCC to emit code that performs faster indirect calls.
25109
25110This option does not work in the presence of shared libraries or nested
25111functions.
25112
d77de738 25113@opindex mfixed-range
ddf6fe37 25114@item -mfixed-range=@var{register-range}
d77de738
ML
25115Generate code treating the given register range as fixed registers.
25116A fixed register is one that the register allocator cannot use. This is
25117useful when compiling kernel code. A register range is specified as
25118two registers separated by a dash. Multiple register ranges can be
25119specified separated by a comma.
25120
d77de738 25121@opindex mgas
ddf6fe37 25122@item -mgas
d77de738
ML
25123Enable the use of assembler directives only GAS understands.
25124
d77de738 25125@opindex mgnu-ld
ddf6fe37 25126@item -mgnu-ld
d77de738
ML
25127Use options specific to GNU @command{ld}.
25128This passes @option{-shared} to @command{ld} when
25129building a shared library. It is the default when GCC is configured,
25130explicitly or implicitly, with the GNU linker. This option does not
25131affect which @command{ld} is called; it only changes what parameters
25132are passed to that @command{ld}.
25133The @command{ld} that is called is determined by the
25134@option{--with-ld} configure option, GCC's program search path, and
25135finally by the user's @env{PATH}. The linker used by GCC can be printed
25136using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25137on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25138
d77de738 25139@opindex mhp-ld
ddf6fe37 25140@item -mhp-ld
d77de738
ML
25141Use options specific to HP @command{ld}.
25142This passes @option{-b} to @command{ld} when building
25143a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25144links. It is the default when GCC is configured, explicitly or
25145implicitly, with the HP linker. This option does not affect
25146which @command{ld} is called; it only changes what parameters are passed to that
25147@command{ld}.
25148The @command{ld} that is called is determined by the @option{--with-ld}
25149configure option, GCC's program search path, and finally by the user's
25150@env{PATH}. The linker used by GCC can be printed using @samp{which
25151`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25152HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25153
cf467fb9 25154@opindex mlinker-opt
ddf6fe37 25155@item -mlinker-opt
cf467fb9
JDA
25156Enable the optimization pass in the HP-UX linker. Note this makes symbolic
25157debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25158linkers in which they give bogus error messages when linking some programs.
25159
d77de738
ML
25160@opindex mno-long-calls
25161@opindex mlong-calls
ddf6fe37 25162@item -mlong-calls
d77de738
ML
25163Generate code that uses long call sequences. This ensures that a call
25164is always able to reach linker generated stubs. The default is to generate
25165long calls only when the distance from the call site to the beginning
25166of the function or translation unit, as the case may be, exceeds a
25167predefined limit set by the branch type being used. The limits for
25168normal calls are 7,600,000 and 240,000 bytes, respectively for the
25169PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25170240,000 bytes.
25171
25172Distances are measured from the beginning of functions when using the
25173@option{-ffunction-sections} option, or when using the @option{-mgas}
25174and @option{-mno-portable-runtime} options together under HP-UX with
25175the SOM linker.
25176
25177It is normally not desirable to use this option as it degrades
25178performance. However, it may be useful in large applications,
25179particularly when partial linking is used to build the application.
25180
25181The types of long calls used depends on the capabilities of the
25182assembler and linker, and the type of code being generated. The
25183impact on systems that support long absolute calls, and long pic
25184symbol-difference or pc-relative calls should be relatively small.
25185However, an indirect call is used on 32-bit ELF systems in pic code
25186and it is quite long.
25187
cf467fb9 25188@opindex mlong-load-store
ddf6fe37 25189@item -mlong-load-store
cf467fb9
JDA
25190Generate 3-instruction load and store sequences as sometimes required by
25191the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25192the HP compilers.
25193
cf467fb9 25194@opindex mjump-in-delay
ddf6fe37 25195@item -mjump-in-delay
cf467fb9
JDA
25196This option is ignored and provided for compatibility purposes only.
25197
cf467fb9
JDA
25198@opindex mno-space-regs
25199@opindex mspace-regs
ddf6fe37 25200@item -mno-space-regs
cf467fb9
JDA
25201Generate code that assumes the target has no space registers. This allows
25202GCC to generate faster indirect calls and use unscaled index address modes.
25203
25204Such code is suitable for level 0 PA systems and kernels.
25205
cf467fb9 25206@opindex mordered
ddf6fe37 25207@item -mordered
cf467fb9
JDA
25208Assume memory references are ordered and barriers are not needed.
25209
cf467fb9 25210@opindex mportable-runtime
ddf6fe37 25211@item -mportable-runtime
cf467fb9
JDA
25212Use the portable calling conventions proposed by HP for ELF systems.
25213
cf467fb9 25214@opindex mschedule
ddf6fe37 25215@item -mschedule=@var{cpu-type}
cf467fb9
JDA
25216Schedule code according to the constraints for the machine type
25217@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25218@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25219to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25220proper scheduling option for your machine. The default scheduling is
25221@samp{8000}.
25222
cf467fb9 25223@opindex msio
ddf6fe37 25224@item -msio
cf467fb9
JDA
25225Generate the predefine, @code{_SIO}, for server IO@. The default is
25226@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25227@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25228options are available under HP-UX and HI-UX@.
25229
cf467fb9 25230@opindex msoft-float
ddf6fe37 25231@item -msoft-float
cf467fb9
JDA
25232Generate output containing library calls for floating point.
25233@strong{Warning:} the requisite libraries are not available for all HPPA
25234targets. Normally the facilities of the machine's usual C compiler are
25235used, but this cannot be done directly in cross-compilation. You must make
25236your own arrangements to provide suitable library functions for
25237cross-compilation.
25238
25239@option{-msoft-float} changes the calling convention in the output file;
25240therefore, it is only useful if you compile @emph{all} of a program with
25241this option. In particular, you need to compile @file{libgcc.a}, the
25242library that comes with GCC, with @option{-msoft-float} in order for
25243this to work.
25244
cf467fb9 25245@opindex msoft-mult
ddf6fe37 25246@item -msoft-mult
cf467fb9
JDA
25247Use software integer multiplication.
25248
25249This disables the use of the @code{xmpyu} instruction.
25250
d77de738 25251@opindex march
ddf6fe37 25252@item -munix=@var{unix-std}
d77de738
ML
25253Generate compiler predefines and select a startfile for the specified
25254UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25255and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25256is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2525711.11 and later. The default values are @samp{93} for HP-UX 10.00,
25258@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25259and later.
25260
25261@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25262@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25263and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25264@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25265@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25266@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25267
25268It is @emph{important} to note that this option changes the interfaces
25269for various library routines. It also affects the operational behavior
25270of the C library. Thus, @emph{extreme} care is needed in using this
25271option.
25272
25273Library code that is intended to operate with more than one UNIX
25274standard must test, set and restore the variable @code{__xpg4_extended_mask}
25275as appropriate. Most GNU software doesn't provide this capability.
25276
d77de738 25277@opindex nolibdld
ddf6fe37 25278@item -nolibdld
d77de738
ML
25279Suppress the generation of link options to search libdld.sl when the
25280@option{-static} option is specified on HP-UX 10 and later.
25281
d77de738 25282@opindex static
ddf6fe37 25283@item -static
d77de738
ML
25284The HP-UX implementation of setlocale in libc has a dependency on
25285libdld.sl. There isn't an archive version of libdld.sl. Thus,
25286when the @option{-static} option is specified, special link options
25287are needed to resolve this dependency.
25288
25289On HP-UX 10 and later, the GCC driver adds the necessary options to
25290link with libdld.sl when the @option{-static} option is specified.
25291This causes the resulting binary to be dynamic. On the 64-bit port,
25292the linkers generate dynamic binaries by default in any case. The
25293@option{-nolibdld} option can be used to prevent the GCC driver from
25294adding these link options.
25295
d77de738 25296@opindex threads
ddf6fe37 25297@item -threads
d77de738
ML
25298Add support for multithreading with the @dfn{dce thread} library
25299under HP-UX@. This option sets flags for both the preprocessor and
25300linker.
25301@end table
25302
25303@node IA-64 Options
25304@subsection IA-64 Options
25305@cindex IA-64 Options
25306
25307These are the @samp{-m} options defined for the Intel IA-64 architecture.
25308
25309@table @gcctabopt
d77de738 25310@opindex mbig-endian
ddf6fe37 25311@item -mbig-endian
d77de738
ML
25312Generate code for a big-endian target. This is the default for HP-UX@.
25313
d77de738 25314@opindex mlittle-endian
ddf6fe37 25315@item -mlittle-endian
d77de738
ML
25316Generate code for a little-endian target. This is the default for AIX5
25317and GNU/Linux.
25318
d77de738
ML
25319@opindex mgnu-as
25320@opindex mno-gnu-as
ddf6fe37
AA
25321@item -mgnu-as
25322@itemx -mno-gnu-as
d77de738
ML
25323Generate (or don't) code for the GNU assembler. This is the default.
25324@c Also, this is the default if the configure option @option{--with-gnu-as}
25325@c is used.
25326
d77de738
ML
25327@opindex mgnu-ld
25328@opindex mno-gnu-ld
ddf6fe37
AA
25329@item -mgnu-ld
25330@itemx -mno-gnu-ld
d77de738
ML
25331Generate (or don't) code for the GNU linker. This is the default.
25332@c Also, this is the default if the configure option @option{--with-gnu-ld}
25333@c is used.
25334
d77de738 25335@opindex mno-pic
ddf6fe37 25336@item -mno-pic
d77de738
ML
25337Generate code that does not use a global pointer register. The result
25338is not position independent code, and violates the IA-64 ABI@.
25339
d77de738
ML
25340@opindex mvolatile-asm-stop
25341@opindex mno-volatile-asm-stop
ddf6fe37
AA
25342@item -mvolatile-asm-stop
25343@itemx -mno-volatile-asm-stop
d77de738
ML
25344Generate (or don't) a stop bit immediately before and after volatile asm
25345statements.
25346
d77de738
ML
25347@opindex mregister-names
25348@opindex mno-register-names
ddf6fe37
AA
25349@item -mregister-names
25350@itemx -mno-register-names
d77de738
ML
25351Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25352the stacked registers. This may make assembler output more readable.
25353
d77de738
ML
25354@opindex mno-sdata
25355@opindex msdata
ddf6fe37
AA
25356@item -mno-sdata
25357@itemx -msdata
d77de738
ML
25358Disable (or enable) optimizations that use the small data section. This may
25359be useful for working around optimizer bugs.
25360
d77de738 25361@opindex mconstant-gp
ddf6fe37 25362@item -mconstant-gp
d77de738
ML
25363Generate code that uses a single constant global pointer value. This is
25364useful when compiling kernel code.
25365
d77de738 25366@opindex mauto-pic
ddf6fe37 25367@item -mauto-pic
d77de738
ML
25368Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25369This is useful when compiling firmware code.
25370
d77de738 25371@opindex minline-float-divide-min-latency
ddf6fe37 25372@item -minline-float-divide-min-latency
d77de738
ML
25373Generate code for inline divides of floating-point values
25374using the minimum latency algorithm.
25375
d77de738 25376@opindex minline-float-divide-max-throughput
ddf6fe37 25377@item -minline-float-divide-max-throughput
d77de738
ML
25378Generate code for inline divides of floating-point values
25379using the maximum throughput algorithm.
25380
d77de738 25381@opindex mno-inline-float-divide
ddf6fe37 25382@item -mno-inline-float-divide
d77de738
ML
25383Do not generate inline code for divides of floating-point values.
25384
d77de738 25385@opindex minline-int-divide-min-latency
ddf6fe37 25386@item -minline-int-divide-min-latency
d77de738
ML
25387Generate code for inline divides of integer values
25388using the minimum latency algorithm.
25389
d77de738 25390@opindex minline-int-divide-max-throughput
ddf6fe37 25391@item -minline-int-divide-max-throughput
d77de738
ML
25392Generate code for inline divides of integer values
25393using the maximum throughput algorithm.
25394
d77de738
ML
25395@opindex mno-inline-int-divide
25396@opindex minline-int-divide
ddf6fe37 25397@item -mno-inline-int-divide
d77de738
ML
25398Do not generate inline code for divides of integer values.
25399
d77de738 25400@opindex minline-sqrt-min-latency
ddf6fe37 25401@item -minline-sqrt-min-latency
d77de738
ML
25402Generate code for inline square roots
25403using the minimum latency algorithm.
25404
d77de738 25405@opindex minline-sqrt-max-throughput
ddf6fe37 25406@item -minline-sqrt-max-throughput
d77de738
ML
25407Generate code for inline square roots
25408using the maximum throughput algorithm.
25409
d77de738 25410@opindex mno-inline-sqrt
ddf6fe37 25411@item -mno-inline-sqrt
d77de738
ML
25412Do not generate inline code for @code{sqrt}.
25413
d77de738
ML
25414@opindex mfused-madd
25415@opindex mno-fused-madd
ddf6fe37
AA
25416@item -mfused-madd
25417@itemx -mno-fused-madd
d77de738
ML
25418Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25419instructions. The default is to use these instructions.
25420
d77de738
ML
25421@opindex mno-dwarf2-asm
25422@opindex mdwarf2-asm
ddf6fe37
AA
25423@item -mno-dwarf2-asm
25424@itemx -mdwarf2-asm
d77de738
ML
25425Don't (or do) generate assembler code for the DWARF line number debugging
25426info. This may be useful when not using the GNU assembler.
25427
d77de738
ML
25428@opindex mearly-stop-bits
25429@opindex mno-early-stop-bits
ddf6fe37
AA
25430@item -mearly-stop-bits
25431@itemx -mno-early-stop-bits
d77de738
ML
25432Allow stop bits to be placed earlier than immediately preceding the
25433instruction that triggered the stop bit. This can improve instruction
25434scheduling, but does not always do so.
25435
d77de738 25436@opindex mfixed-range
ddf6fe37 25437@item -mfixed-range=@var{register-range}
d77de738
ML
25438Generate code treating the given register range as fixed registers.
25439A fixed register is one that the register allocator cannot use. This is
25440useful when compiling kernel code. A register range is specified as
25441two registers separated by a dash. Multiple register ranges can be
25442specified separated by a comma.
25443
d77de738 25444@opindex mtls-size
ddf6fe37 25445@item -mtls-size=@var{tls-size}
d77de738
ML
25446Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2544764.
25448
d77de738 25449@opindex mtune
ddf6fe37 25450@item -mtune=@var{cpu-type}
d77de738
ML
25451Tune the instruction scheduling for a particular CPU, Valid values are
25452@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25453and @samp{mckinley}.
25454
d77de738
ML
25455@opindex milp32
25456@opindex mlp64
ddf6fe37
AA
25457@item -milp32
25458@itemx -mlp64
d77de738
ML
25459Generate code for a 32-bit or 64-bit environment.
25460The 32-bit environment sets int, long and pointer to 32 bits.
25461The 64-bit environment sets int to 32 bits and long and pointer
25462to 64 bits. These are HP-UX specific flags.
25463
d77de738
ML
25464@opindex mno-sched-br-data-spec
25465@opindex msched-br-data-spec
ddf6fe37
AA
25466@item -mno-sched-br-data-spec
25467@itemx -msched-br-data-spec
d77de738
ML
25468(Dis/En)able data speculative scheduling before reload.
25469This results in generation of @code{ld.a} instructions and
25470the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25471The default setting is disabled.
25472
d77de738
ML
25473@opindex msched-ar-data-spec
25474@opindex mno-sched-ar-data-spec
ddf6fe37
AA
25475@item -msched-ar-data-spec
25476@itemx -mno-sched-ar-data-spec
d77de738
ML
25477(En/Dis)able data speculative scheduling after reload.
25478This results in generation of @code{ld.a} instructions and
25479the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25480The default setting is enabled.
25481
d77de738
ML
25482@opindex mno-sched-control-spec
25483@opindex msched-control-spec
ddf6fe37
AA
25484@item -mno-sched-control-spec
25485@itemx -msched-control-spec
d77de738
ML
25486(Dis/En)able control speculative scheduling. This feature is
25487available only during region scheduling (i.e.@: before reload).
25488This results in generation of the @code{ld.s} instructions and
25489the corresponding check instructions @code{chk.s}.
25490The default setting is disabled.
25491
d77de738
ML
25492@opindex msched-br-in-data-spec
25493@opindex mno-sched-br-in-data-spec
ddf6fe37
AA
25494@item -msched-br-in-data-spec
25495@itemx -mno-sched-br-in-data-spec
d77de738
ML
25496(En/Dis)able speculative scheduling of the instructions that
25497are dependent on the data speculative loads before reload.
25498This is effective only with @option{-msched-br-data-spec} enabled.
25499The default setting is enabled.
25500
d77de738
ML
25501@opindex msched-ar-in-data-spec
25502@opindex mno-sched-ar-in-data-spec
ddf6fe37
AA
25503@item -msched-ar-in-data-spec
25504@itemx -mno-sched-ar-in-data-spec
d77de738
ML
25505(En/Dis)able speculative scheduling of the instructions that
25506are dependent on the data speculative loads after reload.
25507This is effective only with @option{-msched-ar-data-spec} enabled.
25508The default setting is enabled.
25509
d77de738
ML
25510@opindex msched-in-control-spec
25511@opindex mno-sched-in-control-spec
ddf6fe37
AA
25512@item -msched-in-control-spec
25513@itemx -mno-sched-in-control-spec
d77de738
ML
25514(En/Dis)able speculative scheduling of the instructions that
25515are dependent on the control speculative loads.
25516This is effective only with @option{-msched-control-spec} enabled.
25517The default setting is enabled.
25518
d77de738
ML
25519@opindex mno-sched-prefer-non-data-spec-insns
25520@opindex msched-prefer-non-data-spec-insns
ddf6fe37
AA
25521@item -mno-sched-prefer-non-data-spec-insns
25522@itemx -msched-prefer-non-data-spec-insns
d77de738
ML
25523If enabled, data-speculative instructions are chosen for schedule
25524only if there are no other choices at the moment. This makes
25525the use of the data speculation much more conservative.
25526The default setting is disabled.
25527
d77de738
ML
25528@opindex mno-sched-prefer-non-control-spec-insns
25529@opindex msched-prefer-non-control-spec-insns
ddf6fe37
AA
25530@item -mno-sched-prefer-non-control-spec-insns
25531@itemx -msched-prefer-non-control-spec-insns
d77de738
ML
25532If enabled, control-speculative instructions are chosen for schedule
25533only if there are no other choices at the moment. This makes
25534the use of the control speculation much more conservative.
25535The default setting is disabled.
25536
d77de738
ML
25537@opindex mno-sched-count-spec-in-critical-path
25538@opindex msched-count-spec-in-critical-path
ddf6fe37
AA
25539@item -mno-sched-count-spec-in-critical-path
25540@itemx -msched-count-spec-in-critical-path
d77de738
ML
25541If enabled, speculative dependencies are considered during
25542computation of the instructions priorities. This makes the use of the
25543speculation a bit more conservative.
25544The default setting is disabled.
25545
d77de738 25546@opindex msched-spec-ldc
ddf6fe37 25547@item -msched-spec-ldc
d77de738
ML
25548Use a simple data speculation check. This option is on by default.
25549
d77de738 25550@opindex msched-spec-ldc
ddf6fe37 25551@item -msched-control-spec-ldc
d77de738
ML
25552Use a simple check for control speculation. This option is on by default.
25553
d77de738 25554@opindex msched-stop-bits-after-every-cycle
ddf6fe37 25555@item -msched-stop-bits-after-every-cycle
d77de738
ML
25556Place a stop bit after every cycle when scheduling. This option is on
25557by default.
25558
d77de738 25559@opindex msched-fp-mem-deps-zero-cost
ddf6fe37 25560@item -msched-fp-mem-deps-zero-cost
d77de738
ML
25561Assume that floating-point stores and loads are not likely to cause a conflict
25562when placed into the same instruction group. This option is disabled by
25563default.
25564
d77de738 25565@opindex msel-sched-dont-check-control-spec
ddf6fe37 25566@item -msel-sched-dont-check-control-spec
d77de738
ML
25567Generate checks for control speculation in selective scheduling.
25568This flag is disabled by default.
25569
d77de738 25570@opindex msched-max-memory-insns
ddf6fe37 25571@item -msched-max-memory-insns=@var{max-insns}
d77de738
ML
25572Limit on the number of memory insns per instruction group, giving lower
25573priority to subsequent memory insns attempting to schedule in the same
25574instruction group. Frequently useful to prevent cache bank conflicts.
25575The default value is 1.
25576
d77de738 25577@opindex msched-max-memory-insns-hard-limit
ddf6fe37 25578@item -msched-max-memory-insns-hard-limit
d77de738
ML
25579Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25580disallowing more than that number in an instruction group.
25581Otherwise, the limit is ``soft'', meaning that non-memory operations
25582are preferred when the limit is reached, but memory operations may still
25583be scheduled.
25584
25585@end table
25586
25587@node LM32 Options
25588@subsection LM32 Options
25589@cindex LM32 options
25590
25591These @option{-m} options are defined for the LatticeMico32 architecture:
25592
25593@table @gcctabopt
d77de738 25594@opindex mbarrel-shift-enabled
ddf6fe37 25595@item -mbarrel-shift-enabled
d77de738
ML
25596Enable barrel-shift instructions.
25597
d77de738 25598@opindex mdivide-enabled
ddf6fe37 25599@item -mdivide-enabled
d77de738
ML
25600Enable divide and modulus instructions.
25601
d77de738 25602@opindex multiply-enabled
ddf6fe37 25603@item -mmultiply-enabled
d77de738
ML
25604Enable multiply instructions.
25605
d77de738 25606@opindex msign-extend-enabled
ddf6fe37 25607@item -msign-extend-enabled
d77de738
ML
25608Enable sign extend instructions.
25609
d77de738 25610@opindex muser-enabled
ddf6fe37 25611@item -muser-enabled
d77de738
ML
25612Enable user-defined instructions.
25613
25614@end table
25615
25616@node LoongArch Options
25617@subsection LoongArch Options
25618@cindex LoongArch Options
25619
25620These command-line options are defined for LoongArch targets:
25621
25622@table @gcctabopt
9c19597c 25623@opindex march
ddf6fe37 25624@item -march=@var{cpu-type}
d77de738
ML
25625Generate instructions for the machine type @var{cpu-type}. In contrast to
25626@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
25627for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
25628to generate code that may not run at all on processors other than the one
25629indicated. Specifying @option{-march=@var{cpu-type}} implies
25630@option{-mtune=@var{cpu-type}}, except where noted otherwise.
25631
25632The choices for @var{cpu-type} are:
25633
25634@table @samp
25635@item native
25636This selects the CPU to generate code for at compilation time by determining
25637the processor type of the compiling machine. Using @option{-march=native}
25638enables all instruction subsets supported by the local machine (hence
25639the result might not run on different machines). Using @option{-mtune=native}
25640produces code optimized for the local machine under the constraints
25641of the selected instruction set.
25642@item loongarch64
25643A generic CPU with 64-bit extensions.
25644@item la464
25645LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
25646@end table
25647
d77de738 25648@opindex mtune
ddf6fe37 25649@item -mtune=@var{cpu-type}
d77de738
ML
25650Optimize the output for the given processor, specified by microarchitecture
25651name.
25652
d77de738 25653@opindex mabi
ddf6fe37 25654@item -mabi=@var{base-abi-type}
d77de738
ML
25655Generate code for the specified calling convention.
25656@var{base-abi-type} can be one of:
25657@table @samp
25658@item lp64d
25659Uses 64-bit general purpose registers and 32/64-bit floating-point
25660registers for parameter passing. Data model is LP64, where @samp{int}
25661is 32 bits, while @samp{long int} and pointers are 64 bits.
25662@item lp64f
25663Uses 64-bit general purpose registers and 32-bit floating-point
25664registers for parameter passing. Data model is LP64, where @samp{int}
25665is 32 bits, while @samp{long int} and pointers are 64 bits.
25666@item lp64s
25667Uses 64-bit general purpose registers and no floating-point
25668registers for parameter passing. Data model is LP64, where @samp{int}
25669is 32 bits, while @samp{long int} and pointers are 64 bits.
25670@end table
25671
d77de738 25672@opindex mfpu
ddf6fe37 25673@item -mfpu=@var{fpu-type}
d77de738
ML
25674Generate code for the specified FPU type, which can be one of:
25675@table @samp
25676@item 64
25677Allow the use of hardware floating-point instructions for 32-bit
25678and 64-bit operations.
25679@item 32
25680Allow the use of hardware floating-point instructions for 32-bit
25681operations.
25682@item none
25683@item 0
25684Prevent the use of hardware floating-point instructions.
25685@end table
25686
d77de738 25687@opindex msoft-float
ddf6fe37 25688@item -msoft-float
d77de738
ML
25689Force @option{-mfpu=none} and prevents the use of floating-point
25690registers for parameter passing. This option may change the target
25691ABI.
25692
9c19597c 25693@opindex msingle-float
ddf6fe37 25694@item -msingle-float
d77de738
ML
25695Force @option{-mfpu=32} and allow the use of 32-bit floating-point
25696registers for parameter passing. This option may change the target
25697ABI.
25698
9c19597c 25699@opindex mdouble-float
ddf6fe37 25700@item -mdouble-float
d77de738
ML
25701Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
25702registers for parameter passing. This option may change the target
25703ABI.
25704
9c19597c 25705@opindex mbranch-cost
ddf6fe37 25706@item -mbranch-cost=@var{n}
d77de738
ML
25707Set the cost of branches to roughly @var{n} instructions.
25708
ddf6fe37 25709@opindex mcheck-zero-division
d77de738
ML
25710@item -mcheck-zero-division
25711@itemx -mno-check-zero-divison
d77de738
ML
25712Trap (do not trap) on integer division by zero. The default is
25713@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
25714@option{-mno-check-zero-division} for other optimization levels.
25715
ddf6fe37 25716@opindex mcond-move-int
d77de738
ML
25717@item -mcond-move-int
25718@itemx -mno-cond-move-int
d77de738
ML
25719Conditional moves for integral data in general-purpose registers
25720are enabled (disabled). The default is @option{-mcond-move-int}.
25721
ddf6fe37 25722@opindex mcond-move-float
d77de738
ML
25723@item -mcond-move-float
25724@itemx -mno-cond-move-float
d77de738
ML
25725Conditional moves for floating-point registers are enabled (disabled).
25726The default is @option{-mcond-move-float}.
25727
ddf6fe37 25728@opindex mmemcpy
d77de738
ML
25729@item -mmemcpy
25730@itemx -mno-memcpy
d77de738
ML
25731Force (do not force) the use of @code{memcpy} for non-trivial block moves.
25732The default is @option{-mno-memcpy}, which allows GCC to inline most
25733constant-sized copies. Setting optimization level to @option{-Os} also
25734forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
25735behavior if explicitly specified, regardless of the order these options on
25736the command line.
25737
ddf6fe37 25738@opindex mstrict-align
d77de738
ML
25739@item -mstrict-align
25740@itemx -mno-strict-align
d77de738
ML
25741Avoid or allow generating memory accesses that may not be aligned on a natural
25742object boundary as described in the architecture specification. The default is
25743@option{-mno-strict-align}.
25744
9c19597c 25745@opindex msmall-data-limit
ddf6fe37 25746@item -msmall-data-limit=@var{number}
d77de738
ML
25747Put global and static data smaller than @var{number} bytes into a special
25748section (on some targets). The default value is 0.
25749
9c19597c 25750@opindex mmax-inline-memcpy-size
ddf6fe37 25751@item -mmax-inline-memcpy-size=@var{n}
d77de738
ML
25752Inline all block moves (such as calls to @code{memcpy} or structure copies)
25753less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
25754
25755@item -mcmodel=@var{code-model}
25756Set the code model to one of:
25757@table @samp
25758@item tiny-static (Not implemented yet)
25759@item tiny (Not implemented yet)
25760
25761@item normal
25762The text segment must be within 128MB addressing space. The data segment must
25763be within 2GB addressing space.
25764
25765@item medium
25766The text segment and data segment must be within 2GB addressing space.
25767
25768@item large (Not implemented yet)
25769
25770@item extreme
25771This mode does not limit the size of the code segment and data segment.
25772The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
25773@option{-mno-explicit-relocs}.
25774@end table
25775The default code model is @code{normal}.
25776
d77de738
ML
25777@opindex mexplicit-relocs
25778@opindex mno-explicit-relocs
ddf6fe37
AA
25779@item -mexplicit-relocs
25780@itemx -mno-explicit-relocs
d77de738
ML
25781Use or do not use assembler relocation operators when dealing with symbolic
25782addresses. The alternative is to use assembler macros instead, which may
25783limit optimization. The default value for the option is determined during
25784GCC build-time by detecting corresponding assembler support:
25785@code{-mexplicit-relocs} if said support is present,
25786@code{-mno-explicit-relocs} otherwise. This option is mostly useful for
25787debugging, or interoperation with assemblers different from the build-time
25788one.
25789
ddf6fe37 25790@opindex mdirect-extern-access
d77de738
ML
25791@item -mdirect-extern-access
25792@itemx -mno-direct-extern-access
d77de738
ML
25793Do not use or use GOT to access external symbols. The default is
25794@option{-mno-direct-extern-access}: GOT is used for external symbols with
25795default visibility, but not used for other external symbols.
25796
25797With @option{-mdirect-extern-access}, GOT is not used and all external
25798symbols are PC-relatively addressed. It is @strong{only} suitable for
25799environments where no dynamic link is performed, like firmwares, OS
25800kernels, executables linked with @option{-static} or @option{-static-pie}.
25801@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
25802@option{-fpic}.
25803@end table
25804
25805@node M32C Options
25806@subsection M32C Options
25807@cindex M32C options
25808
25809@table @gcctabopt
d77de738 25810@opindex mcpu=
ddf6fe37 25811@item -mcpu=@var{name}
d77de738
ML
25812Select the CPU for which code is generated. @var{name} may be one of
25813@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
25814/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
25815the M32C/80 series.
25816
d77de738 25817@opindex msim
ddf6fe37 25818@item -msim
d77de738
ML
25819Specifies that the program will be run on the simulator. This causes
25820an alternate runtime library to be linked in which supports, for
25821example, file I/O@. You must not use this option when generating
25822programs that will run on real hardware; you must provide your own
25823runtime library for whatever I/O functions are needed.
25824
d77de738 25825@opindex memregs=
ddf6fe37 25826@item -memregs=@var{number}
d77de738
ML
25827Specifies the number of memory-based pseudo-registers GCC uses
25828during code generation. These pseudo-registers are used like real
25829registers, so there is a tradeoff between GCC's ability to fit the
25830code into available registers, and the performance penalty of using
25831memory instead of registers. Note that all modules in a program must
25832be compiled with the same value for this option. Because of that, you
25833must not use this option with GCC's default runtime libraries.
25834
25835@end table
25836
25837@node M32R/D Options
25838@subsection M32R/D Options
25839@cindex M32R/D options
25840
25841These @option{-m} options are defined for Renesas M32R/D architectures:
25842
25843@table @gcctabopt
d77de738 25844@opindex m32r2
ddf6fe37 25845@item -m32r2
d77de738
ML
25846Generate code for the M32R/2@.
25847
d77de738 25848@opindex m32rx
ddf6fe37 25849@item -m32rx
d77de738
ML
25850Generate code for the M32R/X@.
25851
d77de738 25852@opindex m32r
ddf6fe37 25853@item -m32r
d77de738
ML
25854Generate code for the M32R@. This is the default.
25855
d77de738 25856@opindex mmodel=small
ddf6fe37 25857@item -mmodel=small
d77de738
ML
25858Assume all objects live in the lower 16MB of memory (so that their addresses
25859can be loaded with the @code{ld24} instruction), and assume all subroutines
25860are reachable with the @code{bl} instruction.
25861This is the default.
25862
25863The addressability of a particular object can be set with the
25864@code{model} attribute.
25865
d77de738 25866@opindex mmodel=medium
ddf6fe37 25867@item -mmodel=medium
d77de738
ML
25868Assume objects may be anywhere in the 32-bit address space (the compiler
25869generates @code{seth/add3} instructions to load their addresses), and
25870assume all subroutines are reachable with the @code{bl} instruction.
25871
d77de738 25872@opindex mmodel=large
ddf6fe37 25873@item -mmodel=large
d77de738
ML
25874Assume objects may be anywhere in the 32-bit address space (the compiler
25875generates @code{seth/add3} instructions to load their addresses), and
25876assume subroutines may not be reachable with the @code{bl} instruction
25877(the compiler generates the much slower @code{seth/add3/jl}
25878instruction sequence).
25879
d77de738 25880@opindex msdata=none
ddf6fe37 25881@item -msdata=none
d77de738
ML
25882Disable use of the small data area. Variables are put into
25883one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
25884@code{section} attribute has been specified).
25885This is the default.
25886
25887The small data area consists of sections @code{.sdata} and @code{.sbss}.
25888Objects may be explicitly put in the small data area with the
25889@code{section} attribute using one of these sections.
25890
d77de738 25891@opindex msdata=sdata
ddf6fe37 25892@item -msdata=sdata
d77de738
ML
25893Put small global and static data in the small data area, but do not
25894generate special code to reference them.
25895
d77de738 25896@opindex msdata=use
ddf6fe37 25897@item -msdata=use
d77de738
ML
25898Put small global and static data in the small data area, and generate
25899special instructions to reference them.
25900
d77de738
ML
25901@opindex G
25902@cindex smaller data references
f33d7a88 25903@item -G @var{num}
d77de738
ML
25904Put global and static objects less than or equal to @var{num} bytes
25905into the small data or BSS sections instead of the normal data or BSS
25906sections. The default value of @var{num} is 8.
25907The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
25908for this option to have any effect.
25909
25910All modules should be compiled with the same @option{-G @var{num}} value.
25911Compiling with different values of @var{num} may or may not work; if it
25912doesn't the linker gives an error message---incorrect code is not
25913generated.
25914
d77de738 25915@opindex mdebug
ddf6fe37 25916@item -mdebug
d77de738
ML
25917Makes the M32R-specific code in the compiler display some statistics
25918that might help in debugging programs.
25919
d77de738 25920@opindex malign-loops
ddf6fe37 25921@item -malign-loops
d77de738
ML
25922Align all loops to a 32-byte boundary.
25923
d77de738 25924@opindex mno-align-loops
ddf6fe37 25925@item -mno-align-loops
d77de738
ML
25926Do not enforce a 32-byte alignment for loops. This is the default.
25927
d77de738 25928@opindex missue-rate=@var{number}
ddf6fe37 25929@item -missue-rate=@var{number}
d77de738
ML
25930Issue @var{number} instructions per cycle. @var{number} can only be 1
25931or 2.
25932
d77de738 25933@opindex mbranch-cost=@var{number}
ddf6fe37 25934@item -mbranch-cost=@var{number}
d77de738
ML
25935@var{number} can only be 1 or 2. If it is 1 then branches are
25936preferred over conditional code, if it is 2, then the opposite applies.
25937
d77de738 25938@opindex mflush-trap=@var{number}
ddf6fe37 25939@item -mflush-trap=@var{number}
d77de738
ML
25940Specifies the trap number to use to flush the cache. The default is
2594112. Valid numbers are between 0 and 15 inclusive.
25942
d77de738 25943@opindex mno-flush-trap
ddf6fe37 25944@item -mno-flush-trap
d77de738
ML
25945Specifies that the cache cannot be flushed by using a trap.
25946
d77de738 25947@opindex mflush-func=@var{name}
ddf6fe37 25948@item -mflush-func=@var{name}
d77de738
ML
25949Specifies the name of the operating system function to call to flush
25950the cache. The default is @samp{_flush_cache}, but a function call
25951is only used if a trap is not available.
25952
d77de738 25953@opindex mno-flush-func
ddf6fe37 25954@item -mno-flush-func
d77de738
ML
25955Indicates that there is no OS function for flushing the cache.
25956
25957@end table
25958
25959@node M680x0 Options
25960@subsection M680x0 Options
25961@cindex M680x0 options
25962
25963These are the @samp{-m} options defined for M680x0 and ColdFire processors.
25964The default settings depend on which architecture was selected when
25965the compiler was configured; the defaults for the most common choices
25966are given below.
25967
25968@table @gcctabopt
d77de738 25969@opindex march
ddf6fe37 25970@item -march=@var{arch}
d77de738
ML
25971Generate code for a specific M680x0 or ColdFire instruction set
25972architecture. Permissible values of @var{arch} for M680x0
25973architectures are: @samp{68000}, @samp{68010}, @samp{68020},
25974@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
25975architectures are selected according to Freescale's ISA classification
25976and the permissible values are: @samp{isaa}, @samp{isaaplus},
25977@samp{isab} and @samp{isac}.
25978
25979GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
25980code for a ColdFire target. The @var{arch} in this macro is one of the
25981@option{-march} arguments given above.
25982
25983When used together, @option{-march} and @option{-mtune} select code
25984that runs on a family of similar processors but that is optimized
25985for a particular microarchitecture.
25986
d77de738 25987@opindex mcpu
ddf6fe37 25988@item -mcpu=@var{cpu}
d77de738
ML
25989Generate code for a specific M680x0 or ColdFire processor.
25990The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
25991@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
25992and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
25993below, which also classifies the CPUs into families:
25994
25995@multitable @columnfractions 0.20 0.80
25996@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
25997@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}
25998@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
25999@item @samp{5206e} @tab @samp{5206e}
26000@item @samp{5208} @tab @samp{5207} @samp{5208}
26001@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
26002@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
26003@item @samp{5216} @tab @samp{5214} @samp{5216}
26004@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
26005@item @samp{5225} @tab @samp{5224} @samp{5225}
26006@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
26007@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
26008@item @samp{5249} @tab @samp{5249}
26009@item @samp{5250} @tab @samp{5250}
26010@item @samp{5271} @tab @samp{5270} @samp{5271}
26011@item @samp{5272} @tab @samp{5272}
26012@item @samp{5275} @tab @samp{5274} @samp{5275}
26013@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
26014@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
26015@item @samp{5307} @tab @samp{5307}
26016@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
26017@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
26018@item @samp{5407} @tab @samp{5407}
26019@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}
26020@end multitable
26021
26022@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
26023@var{arch} is compatible with @var{cpu}. Other combinations of
26024@option{-mcpu} and @option{-march} are rejected.
26025
26026GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
26027@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
26028where the value of @var{family} is given by the table above.
26029
d77de738 26030@opindex mtune
ddf6fe37 26031@item -mtune=@var{tune}
d77de738
ML
26032Tune the code for a particular microarchitecture within the
26033constraints set by @option{-march} and @option{-mcpu}.
26034The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
26035@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
26036and @samp{cpu32}. The ColdFire microarchitectures
26037are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
26038
26039You can also use @option{-mtune=68020-40} for code that needs
26040to run relatively well on 68020, 68030 and 68040 targets.
26041@option{-mtune=68020-60} is similar but includes 68060 targets
26042as well. These two options select the same tuning decisions as
26043@option{-m68020-40} and @option{-m68020-60} respectively.
26044
26045GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
26046when tuning for 680x0 architecture @var{arch}. It also defines
26047@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
26048option is used. If GCC is tuning for a range of architectures,
26049as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
26050it defines the macros for every architecture in the range.
26051
26052GCC also defines the macro @code{__m@var{uarch}__} when tuning for
26053ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
26054of the arguments given above.
26055
d77de738
ML
26056@opindex m68000
26057@opindex mc68000
ddf6fe37
AA
26058@item -m68000
26059@itemx -mc68000
d77de738
ML
26060Generate output for a 68000. This is the default
26061when the compiler is configured for 68000-based systems.
26062It is equivalent to @option{-march=68000}.
26063
26064Use this option for microcontrollers with a 68000 or EC000 core,
26065including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
26066
d77de738 26067@opindex m68010
ddf6fe37 26068@item -m68010
d77de738
ML
26069Generate output for a 68010. This is the default
26070when the compiler is configured for 68010-based systems.
26071It is equivalent to @option{-march=68010}.
26072
d77de738
ML
26073@opindex m68020
26074@opindex mc68020
ddf6fe37
AA
26075@item -m68020
26076@itemx -mc68020
d77de738
ML
26077Generate output for a 68020. This is the default
26078when the compiler is configured for 68020-based systems.
26079It is equivalent to @option{-march=68020}.
26080
d77de738 26081@opindex m68030
ddf6fe37 26082@item -m68030
d77de738
ML
26083Generate output for a 68030. This is the default when the compiler is
26084configured for 68030-based systems. It is equivalent to
26085@option{-march=68030}.
26086
d77de738 26087@opindex m68040
ddf6fe37 26088@item -m68040
d77de738
ML
26089Generate output for a 68040. This is the default when the compiler is
26090configured for 68040-based systems. It is equivalent to
26091@option{-march=68040}.
26092
26093This option inhibits the use of 68881/68882 instructions that have to be
26094emulated by software on the 68040. Use this option if your 68040 does not
26095have code to emulate those instructions.
26096
d77de738 26097@opindex m68060
ddf6fe37 26098@item -m68060
d77de738
ML
26099Generate output for a 68060. This is the default when the compiler is
26100configured for 68060-based systems. It is equivalent to
26101@option{-march=68060}.
26102
26103This option inhibits the use of 68020 and 68881/68882 instructions that
26104have to be emulated by software on the 68060. Use this option if your 68060
26105does not have code to emulate those instructions.
26106
d77de738 26107@opindex mcpu32
ddf6fe37 26108@item -mcpu32
d77de738
ML
26109Generate output for a CPU32. This is the default
26110when the compiler is configured for CPU32-based systems.
26111It is equivalent to @option{-march=cpu32}.
26112
26113Use this option for microcontrollers with a
26114CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2611568336, 68340, 68341, 68349 and 68360.
26116
d77de738 26117@opindex m5200
ddf6fe37 26118@item -m5200
d77de738
ML
26119Generate output for a 520X ColdFire CPU@. This is the default
26120when the compiler is configured for 520X-based systems.
26121It is equivalent to @option{-mcpu=5206}, and is now deprecated
26122in favor of that option.
26123
26124Use this option for microcontroller with a 5200 core, including
26125the MCF5202, MCF5203, MCF5204 and MCF5206.
26126
d77de738 26127@opindex m5206e
ddf6fe37 26128@item -m5206e
d77de738
ML
26129Generate output for a 5206e ColdFire CPU@. The option is now
26130deprecated in favor of the equivalent @option{-mcpu=5206e}.
26131
d77de738 26132@opindex m528x
ddf6fe37 26133@item -m528x
d77de738
ML
26134Generate output for a member of the ColdFire 528X family.
26135The option is now deprecated in favor of the equivalent
26136@option{-mcpu=528x}.
26137
d77de738 26138@opindex m5307
ddf6fe37 26139@item -m5307
d77de738
ML
26140Generate output for a ColdFire 5307 CPU@. The option is now deprecated
26141in favor of the equivalent @option{-mcpu=5307}.
26142
d77de738 26143@opindex m5407
ddf6fe37 26144@item -m5407
d77de738
ML
26145Generate output for a ColdFire 5407 CPU@. The option is now deprecated
26146in favor of the equivalent @option{-mcpu=5407}.
26147
d77de738 26148@opindex mcfv4e
ddf6fe37 26149@item -mcfv4e
d77de738
ML
26150Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
26151This includes use of hardware floating-point instructions.
26152The option is equivalent to @option{-mcpu=547x}, and is now
26153deprecated in favor of that option.
26154
d77de738 26155@opindex m68020-40
ddf6fe37 26156@item -m68020-40
d77de738
ML
26157Generate output for a 68040, without using any of the new instructions.
26158This results in code that can run relatively efficiently on either a
2615968020/68881 or a 68030 or a 68040. The generated code does use the
2616068881 instructions that are emulated on the 68040.
26161
26162The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26163
d77de738 26164@opindex m68020-60
ddf6fe37 26165@item -m68020-60
d77de738
ML
26166Generate output for a 68060, without using any of the new instructions.
26167This results in code that can run relatively efficiently on either a
2616868020/68881 or a 68030 or a 68040. The generated code does use the
2616968881 instructions that are emulated on the 68060.
26170
26171The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26172
d77de738
ML
26173@opindex mhard-float
26174@opindex m68881
ddf6fe37
AA
26175@item -mhard-float
26176@itemx -m68881
d77de738
ML
26177Generate floating-point instructions. This is the default for 68020
26178and above, and for ColdFire devices that have an FPU@. It defines the
26179macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26180on ColdFire targets.
26181
d77de738 26182@opindex msoft-float
ddf6fe37 26183@item -msoft-float
d77de738
ML
26184Do not generate floating-point instructions; use library calls instead.
26185This is the default for 68000, 68010, and 68832 targets. It is also
26186the default for ColdFire devices that have no FPU.
26187
d77de738
ML
26188@opindex mdiv
26189@opindex mno-div
ddf6fe37
AA
26190@item -mdiv
26191@itemx -mno-div
d77de738
ML
26192Generate (do not generate) ColdFire hardware divide and remainder
26193instructions. If @option{-march} is used without @option{-mcpu},
26194the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26195architectures. Otherwise, the default is taken from the target CPU
26196(either the default CPU, or the one specified by @option{-mcpu}). For
26197example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26198@option{-mcpu=5206e}.
26199
26200GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26201
d77de738 26202@opindex mshort
ddf6fe37 26203@item -mshort
d77de738
ML
26204Consider type @code{int} to be 16 bits wide, like @code{short int}.
26205Additionally, parameters passed on the stack are also aligned to a
2620616-bit boundary even on targets whose API mandates promotion to 32-bit.
26207
d77de738 26208@opindex mno-short
ddf6fe37 26209@item -mno-short
d77de738
ML
26210Do not consider type @code{int} to be 16 bits wide. This is the default.
26211
d77de738
ML
26212@opindex mnobitfield
26213@opindex mno-bitfield
ddf6fe37
AA
26214@item -mnobitfield
26215@itemx -mno-bitfield
d77de738
ML
26216Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26217and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26218
d77de738 26219@opindex mbitfield
ddf6fe37 26220@item -mbitfield
d77de738
ML
26221Do use the bit-field instructions. The @option{-m68020} option implies
26222@option{-mbitfield}. This is the default if you use a configuration
26223designed for a 68020.
26224
d77de738 26225@opindex mrtd
ddf6fe37 26226@item -mrtd
d77de738
ML
26227Use a different function-calling convention, in which functions
26228that take a fixed number of arguments return with the @code{rtd}
26229instruction, which pops their arguments while returning. This
26230saves one instruction in the caller since there is no need to pop
26231the arguments there.
26232
26233This calling convention is incompatible with the one normally
26234used on Unix, so you cannot use it if you need to call libraries
26235compiled with the Unix compiler.
26236
26237Also, you must provide function prototypes for all functions that
26238take variable numbers of arguments (including @code{printf});
26239otherwise incorrect code is generated for calls to those
26240functions.
26241
26242In addition, seriously incorrect code results if you call a
26243function with too many arguments. (Normally, extra arguments are
26244harmlessly ignored.)
26245
26246The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2624768040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26248
26249The default is @option{-mno-rtd}.
26250
d77de738
ML
26251@opindex malign-int
26252@opindex mno-align-int
ddf6fe37
AA
26253@item -malign-int
26254@itemx -mno-align-int
d77de738
ML
26255Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26256@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26257boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26258Aligning variables on 32-bit boundaries produces code that runs somewhat
26259faster on processors with 32-bit busses at the expense of more memory.
26260
26261@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26262aligns structures containing the above types differently than
26263most published application binary interface specifications for the m68k.
26264
26265@opindex mpcrel
26266Use the pc-relative addressing mode of the 68000 directly, instead of
26267using a global offset table. At present, this option implies @option{-fpic},
26268allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26269not presently supported with @option{-mpcrel}, though this could be supported for
2627068020 and higher processors.
26271
d77de738
ML
26272@opindex mno-strict-align
26273@opindex mstrict-align
ddf6fe37
AA
26274@item -mno-strict-align
26275@itemx -mstrict-align
d77de738
ML
26276Do not (do) assume that unaligned memory references are handled by
26277the system.
26278
26279@item -msep-data
26280Generate code that allows the data segment to be located in a different
26281area of memory from the text segment. This allows for execute-in-place in
26282an environment without virtual memory management. This option implies
26283@option{-fPIC}.
26284
26285@item -mno-sep-data
26286Generate code that assumes that the data segment follows the text segment.
26287This is the default.
26288
26289@item -mid-shared-library
26290Generate code that supports shared libraries via the library ID method.
26291This allows for execute-in-place and shared libraries in an environment
26292without virtual memory management. This option implies @option{-fPIC}.
26293
26294@item -mno-id-shared-library
26295Generate code that doesn't assume ID-based shared libraries are being used.
26296This is the default.
26297
26298@item -mshared-library-id=n
26299Specifies the identification number of the ID-based shared library being
26300compiled. Specifying a value of 0 generates more compact code; specifying
26301other values forces the allocation of that number to the current
26302library, but is no more space- or time-efficient than omitting this option.
26303
d77de738
ML
26304@opindex mxgot
26305@opindex mno-xgot
ddf6fe37
AA
26306@item -mxgot
26307@itemx -mno-xgot
d77de738
ML
26308When generating position-independent code for ColdFire, generate code
26309that works if the GOT has more than 8192 entries. This code is
26310larger and slower than code generated without this option. On M680x0
26311processors, this option is not needed; @option{-fPIC} suffices.
26312
26313GCC normally uses a single instruction to load values from the GOT@.
26314While this is relatively efficient, it only works if the GOT
26315is smaller than about 64k. Anything larger causes the linker
26316to report an error such as:
26317
26318@cindex relocation truncated to fit (ColdFire)
26319@smallexample
26320relocation truncated to fit: R_68K_GOT16O foobar
26321@end smallexample
26322
26323If this happens, you should recompile your code with @option{-mxgot}.
26324It should then work with very large GOTs. However, code generated with
26325@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26326the value of a global symbol.
26327
26328Note that some linkers, including newer versions of the GNU linker,
26329can create multiple GOTs and sort GOT entries. If you have such a linker,
26330you should only need to use @option{-mxgot} when compiling a single
26331object file that accesses more than 8192 GOT entries. Very few do.
26332
26333These options have no effect unless GCC is generating
26334position-independent code.
26335
d77de738 26336@opindex mlong-jump-table-offsets
ddf6fe37 26337@item -mlong-jump-table-offsets
d77de738
ML
26338Use 32-bit offsets in @code{switch} tables. The default is to use
2633916-bit offsets.
26340
26341@end table
26342
26343@node MCore Options
26344@subsection MCore Options
26345@cindex MCore options
26346
26347These are the @samp{-m} options defined for the Motorola M*Core
26348processors.
26349
26350@table @gcctabopt
26351
d77de738
ML
26352@opindex mhardlit
26353@opindex mno-hardlit
ddf6fe37
AA
26354@item -mhardlit
26355@itemx -mno-hardlit
d77de738
ML
26356Inline constants into the code stream if it can be done in two
26357instructions or less.
26358
d77de738
ML
26359@opindex mdiv
26360@opindex mno-div
ddf6fe37
AA
26361@item -mdiv
26362@itemx -mno-div
d77de738
ML
26363Use the divide instruction. (Enabled by default).
26364
d77de738
ML
26365@opindex mrelax-immediate
26366@opindex mno-relax-immediate
ddf6fe37
AA
26367@item -mrelax-immediate
26368@itemx -mno-relax-immediate
d77de738
ML
26369Allow arbitrary-sized immediates in bit operations.
26370
d77de738
ML
26371@opindex mwide-bitfields
26372@opindex mno-wide-bitfields
ddf6fe37
AA
26373@item -mwide-bitfields
26374@itemx -mno-wide-bitfields
d77de738
ML
26375Always treat bit-fields as @code{int}-sized.
26376
d77de738
ML
26377@opindex m4byte-functions
26378@opindex mno-4byte-functions
ddf6fe37
AA
26379@item -m4byte-functions
26380@itemx -mno-4byte-functions
d77de738
ML
26381Force all functions to be aligned to a 4-byte boundary.
26382
d77de738
ML
26383@opindex mcallgraph-data
26384@opindex mno-callgraph-data
ddf6fe37
AA
26385@item -mcallgraph-data
26386@itemx -mno-callgraph-data
d77de738
ML
26387Emit callgraph information.
26388
d77de738
ML
26389@opindex mslow-bytes
26390@opindex mno-slow-bytes
ddf6fe37
AA
26391@item -mslow-bytes
26392@itemx -mno-slow-bytes
d77de738
ML
26393Prefer word access when reading byte quantities.
26394
d77de738
ML
26395@opindex mlittle-endian
26396@opindex mbig-endian
ddf6fe37
AA
26397@item -mlittle-endian
26398@itemx -mbig-endian
d77de738
ML
26399Generate code for a little-endian target.
26400
d77de738
ML
26401@opindex m210
26402@opindex m340
ddf6fe37
AA
26403@item -m210
26404@itemx -m340
d77de738
ML
26405Generate code for the 210 processor.
26406
d77de738 26407@opindex mno-lsim
ddf6fe37 26408@item -mno-lsim
d77de738
ML
26409Assume that runtime support has been provided and so omit the
26410simulator library (@file{libsim.a)} from the linker command line.
26411
d77de738 26412@opindex mstack-increment
ddf6fe37 26413@item -mstack-increment=@var{size}
d77de738
ML
26414Set the maximum amount for a single stack increment operation. Large
26415values can increase the speed of programs that contain functions
26416that need a large amount of stack space, but they can also trigger a
26417segmentation fault if the stack is extended too much. The default
26418value is 0x1000.
26419
26420@end table
26421
d77de738
ML
26422@node MicroBlaze Options
26423@subsection MicroBlaze Options
26424@cindex MicroBlaze Options
26425
26426@table @gcctabopt
26427
d77de738 26428@opindex msoft-float
ddf6fe37 26429@item -msoft-float
d77de738
ML
26430Use software emulation for floating point (default).
26431
d77de738 26432@opindex mhard-float
ddf6fe37 26433@item -mhard-float
d77de738
ML
26434Use hardware floating-point instructions.
26435
d77de738 26436@opindex mmemcpy
ddf6fe37 26437@item -mmemcpy
d77de738
ML
26438Do not optimize block moves, use @code{memcpy}.
26439
d77de738 26440@opindex mno-clearbss
ddf6fe37 26441@item -mno-clearbss
d77de738
ML
26442This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26443
d77de738 26444@opindex mcpu=
ddf6fe37 26445@item -mcpu=@var{cpu-type}
d77de738
ML
26446Use features of, and schedule code for, the given CPU.
26447Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26448where @var{X} is a major version, @var{YY} is the minor version, and
26449@var{Z} is compatibility code. Example values are @samp{v3.00.a},
26450@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26451
d77de738 26452@opindex mxl-soft-mul
ddf6fe37 26453@item -mxl-soft-mul
d77de738
ML
26454Use software multiply emulation (default).
26455
d77de738 26456@opindex mxl-soft-div
ddf6fe37 26457@item -mxl-soft-div
d77de738
ML
26458Use software emulation for divides (default).
26459
d77de738 26460@opindex mxl-barrel-shift
ddf6fe37 26461@item -mxl-barrel-shift
d77de738
ML
26462Use the hardware barrel shifter.
26463
d77de738 26464@opindex mxl-pattern-compare
ddf6fe37 26465@item -mxl-pattern-compare
d77de738
ML
26466Use pattern compare instructions.
26467
d77de738 26468@opindex msmall-divides
ddf6fe37 26469@item -msmall-divides
d77de738
ML
26470Use table lookup optimization for small signed integer divisions.
26471
d77de738 26472@opindex mxl-stack-check
ddf6fe37 26473@item -mxl-stack-check
d77de738
ML
26474This option is deprecated. Use @option{-fstack-check} instead.
26475
d77de738 26476@opindex mxl-gp-opt
ddf6fe37 26477@item -mxl-gp-opt
d77de738
ML
26478Use GP-relative @code{.sdata}/@code{.sbss} sections.
26479
d77de738 26480@opindex mxl-multiply-high
ddf6fe37 26481@item -mxl-multiply-high
d77de738
ML
26482Use multiply high instructions for high part of 32x32 multiply.
26483
d77de738 26484@opindex mxl-float-convert
ddf6fe37 26485@item -mxl-float-convert
d77de738
ML
26486Use hardware floating-point conversion instructions.
26487
d77de738 26488@opindex mxl-float-sqrt
ddf6fe37 26489@item -mxl-float-sqrt
d77de738
ML
26490Use hardware floating-point square root instruction.
26491
d77de738 26492@opindex mbig-endian
ddf6fe37 26493@item -mbig-endian
d77de738
ML
26494Generate code for a big-endian target.
26495
d77de738 26496@opindex mlittle-endian
ddf6fe37 26497@item -mlittle-endian
d77de738
ML
26498Generate code for a little-endian target.
26499
d77de738 26500@opindex mxl-reorder
ddf6fe37 26501@item -mxl-reorder
d77de738
ML
26502Use reorder instructions (swap and byte reversed load/store).
26503
26504@item -mxl-mode-@var{app-model}
26505Select application model @var{app-model}. Valid models are
26506@table @samp
26507@item executable
26508normal executable (default), uses startup code @file{crt0.o}.
26509
26510@item xmdstub
26511for use with Xilinx Microprocessor Debugger (XMD) based
26512software intrusive debug agent called xmdstub. This uses startup file
26513@file{crt1.o} and sets the start address of the program to 0x800.
26514
26515@item bootstrap
26516for applications that are loaded using a bootloader.
26517This model uses startup file @file{crt2.o} which does not contain a processor
26518reset vector handler. This is suitable for transferring control on a
26519processor reset to the bootloader rather than the application.
26520
26521@item novectors
26522for applications that do not require any of the
26523MicroBlaze vectors. This option may be useful for applications running
26524within a monitoring application. This model uses @file{crt3.o} as a startup file.
26525@end table
26526
26527Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26528@option{-mxl-mode-@var{app-model}}.
26529
d77de738 26530@opindex mpic-data-is-text-relative
ddf6fe37 26531@item -mpic-data-is-text-relative
d77de738
ML
26532Assume that the displacement between the text and data segments is fixed
26533at static link time. This allows data to be referenced by offset from start of
26534text address instead of GOT since PC-relative addressing is not supported.
26535
26536@end table
26537
26538@node MIPS Options
26539@subsection MIPS Options
26540@cindex MIPS options
26541
26542@table @gcctabopt
26543
d77de738 26544@opindex EB
ddf6fe37 26545@item -EB
d77de738
ML
26546Generate big-endian code.
26547
d77de738 26548@opindex EL
ddf6fe37 26549@item -EL
d77de738
ML
26550Generate little-endian code. This is the default for @samp{mips*el-*-*}
26551configurations.
26552
d77de738 26553@opindex march
ddf6fe37 26554@item -march=@var{arch}
d77de738
ML
26555Generate code that runs on @var{arch}, which can be the name of a
26556generic MIPS ISA, or the name of a particular processor.
26557The ISA names are:
26558@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26559@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26560@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26561@samp{mips64r5} and @samp{mips64r6}.
26562The processor names are:
26563@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26564@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26565@samp{5kc}, @samp{5kf},
26566@samp{20kc},
26567@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26568@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26569@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26570@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26571@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26572@samp{i6400}, @samp{i6500},
26573@samp{interaptiv},
26574@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
26575@samp{gs464e}, @samp{gs264e},
26576@samp{m4k},
26577@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
26578@samp{m5100}, @samp{m5101},
26579@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
26580@samp{orion},
26581@samp{p5600}, @samp{p6600},
26582@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
26583@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
26584@samp{r6000}, @samp{r8000},
26585@samp{rm7000}, @samp{rm9000},
26586@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
26587@samp{sb1},
26588@samp{sr71000},
26589@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
26590@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
26591@samp{xlr} and @samp{xlp}.
26592The special value @samp{from-abi} selects the
26593most compatible architecture for the selected ABI (that is,
26594@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
26595
26596The native Linux/GNU toolchain also supports the value @samp{native},
26597which selects the best architecture option for the host processor.
26598@option{-march=native} has no effect if GCC does not recognize
26599the processor.
26600
26601In processor names, a final @samp{000} can be abbreviated as @samp{k}
26602(for example, @option{-march=r2k}). Prefixes are optional, and
26603@samp{vr} may be written @samp{r}.
26604
26605Names of the form @samp{@var{n}f2_1} refer to processors with
26606FPUs clocked at half the rate of the core, names of the form
26607@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
26608rate as the core, and names of the form @samp{@var{n}f3_2} refer to
26609processors with FPUs clocked a ratio of 3:2 with respect to the core.
26610For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
26611for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
26612accepted as synonyms for @samp{@var{n}f1_1}.
26613
26614GCC defines two macros based on the value of this option. The first
26615is @code{_MIPS_ARCH}, which gives the name of target architecture, as
26616a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
26617where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
26618For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
26619to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
26620
26621Note that the @code{_MIPS_ARCH} macro uses the processor names given
26622above. In other words, it has the full prefix and does not
26623abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
26624the macro names the resolved architecture (either @code{"mips1"} or
26625@code{"mips3"}). It names the default architecture when no
26626@option{-march} option is given.
26627
d77de738 26628@opindex mtune
ddf6fe37 26629@item -mtune=@var{arch}
d77de738
ML
26630Optimize for @var{arch}. Among other things, this option controls
26631the way instructions are scheduled, and the perceived cost of arithmetic
26632operations. The list of @var{arch} values is the same as for
26633@option{-march}.
26634
26635When this option is not used, GCC optimizes for the processor
26636specified by @option{-march}. By using @option{-march} and
26637@option{-mtune} together, it is possible to generate code that
26638runs on a family of processors, but optimize the code for one
26639particular member of that family.
26640
26641@option{-mtune} defines the macros @code{_MIPS_TUNE} and
26642@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
26643@option{-march} ones described above.
26644
d77de738 26645@opindex mips1
ddf6fe37 26646@item -mips1
d77de738
ML
26647Equivalent to @option{-march=mips1}.
26648
d77de738 26649@opindex mips2
ddf6fe37 26650@item -mips2
d77de738
ML
26651Equivalent to @option{-march=mips2}.
26652
d77de738 26653@opindex mips3
ddf6fe37 26654@item -mips3
d77de738
ML
26655Equivalent to @option{-march=mips3}.
26656
d77de738 26657@opindex mips4
ddf6fe37 26658@item -mips4
d77de738
ML
26659Equivalent to @option{-march=mips4}.
26660
d77de738 26661@opindex mips32
ddf6fe37 26662@item -mips32
d77de738
ML
26663Equivalent to @option{-march=mips32}.
26664
d77de738 26665@opindex mips32r3
ddf6fe37 26666@item -mips32r3
d77de738
ML
26667Equivalent to @option{-march=mips32r3}.
26668
d77de738 26669@opindex mips32r5
ddf6fe37 26670@item -mips32r5
d77de738
ML
26671Equivalent to @option{-march=mips32r5}.
26672
d77de738 26673@opindex mips32r6
ddf6fe37 26674@item -mips32r6
d77de738
ML
26675Equivalent to @option{-march=mips32r6}.
26676
d77de738 26677@opindex mips64
ddf6fe37 26678@item -mips64
d77de738
ML
26679Equivalent to @option{-march=mips64}.
26680
d77de738 26681@opindex mips64r2
ddf6fe37 26682@item -mips64r2
d77de738
ML
26683Equivalent to @option{-march=mips64r2}.
26684
d77de738 26685@opindex mips64r3
ddf6fe37 26686@item -mips64r3
d77de738
ML
26687Equivalent to @option{-march=mips64r3}.
26688
d77de738 26689@opindex mips64r5
ddf6fe37 26690@item -mips64r5
d77de738
ML
26691Equivalent to @option{-march=mips64r5}.
26692
d77de738 26693@opindex mips64r6
ddf6fe37 26694@item -mips64r6
d77de738
ML
26695Equivalent to @option{-march=mips64r6}.
26696
d77de738
ML
26697@opindex mips16
26698@opindex mno-mips16
ddf6fe37
AA
26699@item -mips16
26700@itemx -mno-mips16
d77de738
ML
26701Generate (do not generate) MIPS16 code. If GCC is targeting a
26702MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
26703
26704MIPS16 code generation can also be controlled on a per-function basis
26705by means of @code{mips16} and @code{nomips16} attributes.
26706@xref{Function Attributes}, for more information.
26707
d77de738 26708@opindex mflip-mips16
ddf6fe37 26709@item -mflip-mips16
d77de738
ML
26710Generate MIPS16 code on alternating functions. This option is provided
26711for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
26712not intended for ordinary use in compiling user code.
26713
d77de738
ML
26714@opindex minterlink-compressed
26715@opindex mno-interlink-compressed
ddf6fe37
AA
26716@item -minterlink-compressed
26717@itemx -mno-interlink-compressed
d77de738
ML
26718Require (do not require) that code using the standard (uncompressed) MIPS ISA
26719be link-compatible with MIPS16 and microMIPS code, and vice versa.
26720
26721For example, code using the standard ISA encoding cannot jump directly
26722to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
26723@option{-minterlink-compressed} therefore disables direct jumps unless GCC
26724knows that the target of the jump is not compressed.
26725
d77de738
ML
26726@opindex minterlink-mips16
26727@opindex mno-interlink-mips16
ddf6fe37
AA
26728@item -minterlink-mips16
26729@itemx -mno-interlink-mips16
d77de738
ML
26730Aliases of @option{-minterlink-compressed} and
26731@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
26732and are retained for backwards compatibility.
26733
d77de738
ML
26734@opindex mabi=32
26735@opindex mabi=o64
26736@opindex mabi=n32
26737@opindex mabi=64
26738@opindex mabi=eabi
ddf6fe37
AA
26739@item -mabi=32
26740@itemx -mabi=o64
26741@itemx -mabi=n32
26742@itemx -mabi=64
26743@itemx -mabi=eabi
d77de738
ML
26744Generate code for the given ABI@.
26745
26746Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
26747generates 64-bit code when you select a 64-bit architecture, but you
26748can use @option{-mgp32} to get 32-bit code instead.
26749
26750For information about the O64 ABI, see
26751@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
26752
26753GCC supports a variant of the o32 ABI in which floating-point registers
26754are 64 rather than 32 bits wide. You can select this combination with
26755@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
26756and @code{mfhc1} instructions and is therefore only supported for
26757MIPS32R2, MIPS32R3 and MIPS32R5 processors.
26758
26759The register assignments for arguments and return values remain the
26760same, but each scalar value is passed in a single 64-bit register
26761rather than a pair of 32-bit registers. For example, scalar
26762floating-point values are returned in @samp{$f0} only, not a
26763@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
26764remains the same in that the even-numbered double-precision registers
26765are saved.
26766
26767Two additional variants of the o32 ABI are supported to enable
26768a transition from 32-bit to 64-bit registers. These are FPXX
26769(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
26770The FPXX extension mandates that all code must execute correctly
26771when run using 32-bit or 64-bit registers. The code can be interlinked
26772with either FP32 or FP64, but not both.
26773The FP64A extension is similar to the FP64 extension but forbids the
26774use of odd-numbered single-precision registers. This can be used
26775in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
26776processors and allows both FP32 and FP64A code to interlink and
26777run in the same process without changing FPU modes.
26778
d77de738
ML
26779@opindex mabicalls
26780@opindex mno-abicalls
ddf6fe37
AA
26781@item -mabicalls
26782@itemx -mno-abicalls
d77de738
ML
26783Generate (do not generate) code that is suitable for SVR4-style
26784dynamic objects. @option{-mabicalls} is the default for SVR4-based
26785systems.
26786
26787@item -mshared
26788@itemx -mno-shared
26789Generate (do not generate) code that is fully position-independent,
26790and that can therefore be linked into shared libraries. This option
26791only affects @option{-mabicalls}.
26792
26793All @option{-mabicalls} code has traditionally been position-independent,
26794regardless of options like @option{-fPIC} and @option{-fpic}. However,
26795as an extension, the GNU toolchain allows executables to use absolute
26796accesses for locally-binding symbols. It can also use shorter GP
26797initialization sequences and generate direct calls to locally-defined
26798functions. This mode is selected by @option{-mno-shared}.
26799
26800@option{-mno-shared} depends on binutils 2.16 or higher and generates
26801objects that can only be linked by the GNU linker. However, the option
26802does not affect the ABI of the final executable; it only affects the ABI
26803of relocatable objects. Using @option{-mno-shared} generally makes
26804executables both smaller and quicker.
26805
26806@option{-mshared} is the default.
26807
d77de738
ML
26808@opindex mplt
26809@opindex mno-plt
ddf6fe37
AA
26810@item -mplt
26811@itemx -mno-plt
d77de738
ML
26812Assume (do not assume) that the static and dynamic linkers
26813support PLTs and copy relocations. This option only affects
26814@option{-mno-shared -mabicalls}. For the n64 ABI, this option
26815has no effect without @option{-msym32}.
26816
26817You can make @option{-mplt} the default by configuring
26818GCC with @option{--with-mips-plt}. The default is
26819@option{-mno-plt} otherwise.
26820
d77de738
ML
26821@opindex mxgot
26822@opindex mno-xgot
ddf6fe37
AA
26823@item -mxgot
26824@itemx -mno-xgot
d77de738
ML
26825Lift (do not lift) the usual restrictions on the size of the global
26826offset table.
26827
26828GCC normally uses a single instruction to load values from the GOT@.
26829While this is relatively efficient, it only works if the GOT
26830is smaller than about 64k. Anything larger causes the linker
26831to report an error such as:
26832
26833@cindex relocation truncated to fit (MIPS)
26834@smallexample
26835relocation truncated to fit: R_MIPS_GOT16 foobar
26836@end smallexample
26837
26838If this happens, you should recompile your code with @option{-mxgot}.
26839This works with very large GOTs, although the code is also
26840less efficient, since it takes three instructions to fetch the
26841value of a global symbol.
26842
26843Note that some linkers can create multiple GOTs. If you have such a
26844linker, you should only need to use @option{-mxgot} when a single object
26845file accesses more than 64k's worth of GOT entries. Very few do.
26846
26847These options have no effect unless GCC is generating position
26848independent code.
26849
d77de738 26850@opindex mgp32
ddf6fe37 26851@item -mgp32
d77de738
ML
26852Assume that general-purpose registers are 32 bits wide.
26853
d77de738 26854@opindex mgp64
ddf6fe37 26855@item -mgp64
d77de738
ML
26856Assume that general-purpose registers are 64 bits wide.
26857
d77de738 26858@opindex mfp32
ddf6fe37 26859@item -mfp32
d77de738
ML
26860Assume that floating-point registers are 32 bits wide.
26861
d77de738 26862@opindex mfp64
ddf6fe37 26863@item -mfp64
d77de738
ML
26864Assume that floating-point registers are 64 bits wide.
26865
d77de738 26866@opindex mfpxx
ddf6fe37 26867@item -mfpxx
d77de738
ML
26868Do not assume the width of floating-point registers.
26869
d77de738 26870@opindex mhard-float
ddf6fe37 26871@item -mhard-float
d77de738
ML
26872Use floating-point coprocessor instructions.
26873
d77de738 26874@opindex msoft-float
ddf6fe37 26875@item -msoft-float
d77de738
ML
26876Do not use floating-point coprocessor instructions. Implement
26877floating-point calculations using library calls instead.
26878
d77de738 26879@opindex mno-float
ddf6fe37 26880@item -mno-float
d77de738
ML
26881Equivalent to @option{-msoft-float}, but additionally asserts that the
26882program being compiled does not perform any floating-point operations.
26883This option is presently supported only by some bare-metal MIPS
26884configurations, where it may select a special set of libraries
26885that lack all floating-point support (including, for example, the
26886floating-point @code{printf} formats).
26887If code compiled with @option{-mno-float} accidentally contains
26888floating-point operations, it is likely to suffer a link-time
26889or run-time failure.
26890
d77de738 26891@opindex msingle-float
ddf6fe37 26892@item -msingle-float
d77de738
ML
26893Assume that the floating-point coprocessor only supports single-precision
26894operations.
26895
d77de738 26896@opindex mdouble-float
ddf6fe37 26897@item -mdouble-float
d77de738
ML
26898Assume that the floating-point coprocessor supports double-precision
26899operations. This is the default.
26900
d77de738
ML
26901@opindex modd-spreg
26902@opindex mno-odd-spreg
ddf6fe37
AA
26903@item -modd-spreg
26904@itemx -mno-odd-spreg
d77de738
ML
26905Enable the use of odd-numbered single-precision floating-point registers
26906for the o32 ABI. This is the default for processors that are known to
26907support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
26908is set by default.
26909
d77de738
ML
26910@opindex mabs=2008
26911@opindex mabs=legacy
ddf6fe37
AA
26912@item -mabs=2008
26913@itemx -mabs=legacy
d77de738
ML
26914These options control the treatment of the special not-a-number (NaN)
26915IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
26916@code{neg.@i{fmt}} machine instructions.
26917
26918By default or when @option{-mabs=legacy} is used the legacy
26919treatment is selected. In this case these instructions are considered
26920arithmetic and avoided where correct operation is required and the
26921input operand might be a NaN. A longer sequence of instructions that
26922manipulate the sign bit of floating-point datum manually is used
26923instead unless the @option{-ffinite-math-only} option has also been
26924specified.
26925
26926The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
26927this case these instructions are considered non-arithmetic and therefore
26928operating correctly in all cases, including in particular where the
26929input operand is a NaN. These instructions are therefore always used
26930for the respective operations.
26931
d77de738
ML
26932@opindex mnan=2008
26933@opindex mnan=legacy
ddf6fe37
AA
26934@item -mnan=2008
26935@itemx -mnan=legacy
d77de738
ML
26936These options control the encoding of the special not-a-number (NaN)
26937IEEE 754 floating-point data.
26938
26939The @option{-mnan=legacy} option selects the legacy encoding. In this
26940case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
26941significand field being 0, whereas signaling NaNs (sNaNs) are denoted
26942by the first bit of their trailing significand field being 1.
26943
26944The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
26945this case qNaNs are denoted by the first bit of their trailing
26946significand field being 1, whereas sNaNs are denoted by the first bit of
26947their trailing significand field being 0.
26948
26949The default is @option{-mnan=legacy} unless GCC has been configured with
26950@option{--with-nan=2008}.
26951
d77de738
ML
26952@opindex mllsc
26953@opindex mno-llsc
ddf6fe37
AA
26954@item -mllsc
26955@itemx -mno-llsc
d77de738
ML
26956Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
26957implement atomic memory built-in functions. When neither option is
26958specified, GCC uses the instructions if the target architecture
26959supports them.
26960
26961@option{-mllsc} is useful if the runtime environment can emulate the
26962instructions and @option{-mno-llsc} can be useful when compiling for
26963nonstandard ISAs. You can make either option the default by
26964configuring GCC with @option{--with-llsc} and @option{--without-llsc}
26965respectively. @option{--with-llsc} is the default for some
26966configurations; see the installation documentation for details.
26967
d77de738
ML
26968@opindex mdsp
26969@opindex mno-dsp
ddf6fe37
AA
26970@item -mdsp
26971@itemx -mno-dsp
d77de738
ML
26972Use (do not use) revision 1 of the MIPS DSP ASE@.
26973@xref{MIPS DSP Built-in Functions}. This option defines the
26974preprocessor macro @code{__mips_dsp}. It also defines
26975@code{__mips_dsp_rev} to 1.
26976
d77de738
ML
26977@opindex mdspr2
26978@opindex mno-dspr2
ddf6fe37
AA
26979@item -mdspr2
26980@itemx -mno-dspr2
d77de738
ML
26981Use (do not use) revision 2 of the MIPS DSP ASE@.
26982@xref{MIPS DSP Built-in Functions}. This option defines the
26983preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
26984It also defines @code{__mips_dsp_rev} to 2.
26985
d77de738
ML
26986@opindex msmartmips
26987@opindex mno-smartmips
ddf6fe37
AA
26988@item -msmartmips
26989@itemx -mno-smartmips
d77de738
ML
26990Use (do not use) the MIPS SmartMIPS ASE.
26991
d77de738
ML
26992@opindex mpaired-single
26993@opindex mno-paired-single
ddf6fe37
AA
26994@item -mpaired-single
26995@itemx -mno-paired-single
d77de738
ML
26996Use (do not use) paired-single floating-point instructions.
26997@xref{MIPS Paired-Single Support}. This option requires
26998hardware floating-point support to be enabled.
26999
d77de738
ML
27000@opindex mdmx
27001@opindex mno-mdmx
ddf6fe37
AA
27002@item -mdmx
27003@itemx -mno-mdmx
d77de738
ML
27004Use (do not use) MIPS Digital Media Extension instructions.
27005This option can only be used when generating 64-bit code and requires
27006hardware floating-point support to be enabled.
27007
d77de738
ML
27008@opindex mips3d
27009@opindex mno-mips3d
ddf6fe37
AA
27010@item -mips3d
27011@itemx -mno-mips3d
d77de738
ML
27012Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
27013The option @option{-mips3d} implies @option{-mpaired-single}.
27014
d77de738
ML
27015@opindex mmicromips
27016@opindex mno-mmicromips
ddf6fe37
AA
27017@item -mmicromips
27018@itemx -mno-micromips
d77de738
ML
27019Generate (do not generate) microMIPS code.
27020
27021MicroMIPS code generation can also be controlled on a per-function basis
27022by means of @code{micromips} and @code{nomicromips} attributes.
27023@xref{Function Attributes}, for more information.
27024
d77de738
ML
27025@opindex mmt
27026@opindex mno-mt
ddf6fe37
AA
27027@item -mmt
27028@itemx -mno-mt
d77de738
ML
27029Use (do not use) MT Multithreading instructions.
27030
d77de738
ML
27031@opindex mmcu
27032@opindex mno-mcu
ddf6fe37
AA
27033@item -mmcu
27034@itemx -mno-mcu
d77de738
ML
27035Use (do not use) the MIPS MCU ASE instructions.
27036
d77de738
ML
27037@opindex meva
27038@opindex mno-eva
ddf6fe37
AA
27039@item -meva
27040@itemx -mno-eva
d77de738
ML
27041Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
27042
d77de738
ML
27043@opindex mvirt
27044@opindex mno-virt
ddf6fe37
AA
27045@item -mvirt
27046@itemx -mno-virt
d77de738
ML
27047Use (do not use) the MIPS Virtualization (VZ) instructions.
27048
d77de738
ML
27049@opindex mxpa
27050@opindex mno-xpa
ddf6fe37
AA
27051@item -mxpa
27052@itemx -mno-xpa
d77de738
ML
27053Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
27054
d77de738
ML
27055@opindex mcrc
27056@opindex mno-crc
ddf6fe37
AA
27057@item -mcrc
27058@itemx -mno-crc
d77de738
ML
27059Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
27060
d77de738
ML
27061@opindex mginv
27062@opindex mno-ginv
ddf6fe37
AA
27063@item -mginv
27064@itemx -mno-ginv
d77de738
ML
27065Use (do not use) the MIPS Global INValidate (GINV) instructions.
27066
d77de738
ML
27067@opindex mloongson-mmi
27068@opindex mno-loongson-mmi
ddf6fe37
AA
27069@item -mloongson-mmi
27070@itemx -mno-loongson-mmi
d77de738
ML
27071Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
27072
d77de738
ML
27073@opindex mloongson-ext
27074@opindex mno-loongson-ext
ddf6fe37
AA
27075@item -mloongson-ext
27076@itemx -mno-loongson-ext
d77de738
ML
27077Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
27078
d77de738
ML
27079@opindex mloongson-ext2
27080@opindex mno-loongson-ext2
ddf6fe37
AA
27081@item -mloongson-ext2
27082@itemx -mno-loongson-ext2
d77de738
ML
27083Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
27084
d77de738 27085@opindex mlong64
ddf6fe37 27086@item -mlong64
d77de738
ML
27087Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
27088an explanation of the default and the way that the pointer size is
27089determined.
27090
d77de738 27091@opindex mlong32
ddf6fe37 27092@item -mlong32
d77de738
ML
27093Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
27094
27095The default size of @code{int}s, @code{long}s and pointers depends on
27096the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
27097uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2709832-bit @code{long}s. Pointers are the same size as @code{long}s,
27099or the same size as integer registers, whichever is smaller.
27100
d77de738
ML
27101@opindex msym32
27102@opindex mno-sym32
ddf6fe37
AA
27103@item -msym32
27104@itemx -mno-sym32
d77de738
ML
27105Assume (do not assume) that all symbols have 32-bit values, regardless
27106of the selected ABI@. This option is useful in combination with
27107@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
27108to generate shorter and faster references to symbolic addresses.
27109
d77de738 27110@opindex G
ddf6fe37 27111@item -G @var{num}
d77de738
ML
27112Put definitions of externally-visible data in a small data section
27113if that data is no bigger than @var{num} bytes. GCC can then generate
27114more efficient accesses to the data; see @option{-mgpopt} for details.
27115
27116The default @option{-G} option depends on the configuration.
27117
d77de738
ML
27118@opindex mlocal-sdata
27119@opindex mno-local-sdata
ddf6fe37
AA
27120@item -mlocal-sdata
27121@itemx -mno-local-sdata
d77de738
ML
27122Extend (do not extend) the @option{-G} behavior to local data too,
27123such as to static variables in C@. @option{-mlocal-sdata} is the
27124default for all configurations.
27125
27126If the linker complains that an application is using too much small data,
27127you might want to try rebuilding the less performance-critical parts with
27128@option{-mno-local-sdata}. You might also want to build large
27129libraries with @option{-mno-local-sdata}, so that the libraries leave
27130more room for the main program.
27131
d77de738
ML
27132@opindex mextern-sdata
27133@opindex mno-extern-sdata
ddf6fe37
AA
27134@item -mextern-sdata
27135@itemx -mno-extern-sdata
d77de738
ML
27136Assume (do not assume) that externally-defined data is in
27137a small data section if the size of that data is within the @option{-G} limit.
27138@option{-mextern-sdata} is the default for all configurations.
27139
27140If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
27141@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
27142that is no bigger than @var{num} bytes, you must make sure that @var{Var}
27143is placed in a small data section. If @var{Var} is defined by another
27144module, you must either compile that module with a high-enough
27145@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
27146definition. If @var{Var} is common, you must link the application
27147with a high-enough @option{-G} setting.
27148
27149The easiest way of satisfying these restrictions is to compile
27150and link every module with the same @option{-G} option. However,
27151you may wish to build a library that supports several different
27152small data limits. You can do this by compiling the library with
27153the highest supported @option{-G} setting and additionally using
27154@option{-mno-extern-sdata} to stop the library from making assumptions
27155about externally-defined data.
27156
d77de738
ML
27157@opindex mgpopt
27158@opindex mno-gpopt
ddf6fe37
AA
27159@item -mgpopt
27160@itemx -mno-gpopt
d77de738
ML
27161Use (do not use) GP-relative accesses for symbols that are known to be
27162in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27163@option{-mextern-sdata}. @option{-mgpopt} is the default for all
27164configurations.
27165
27166@option{-mno-gpopt} is useful for cases where the @code{$gp} register
27167might not hold the value of @code{_gp}. For example, if the code is
27168part of a library that might be used in a boot monitor, programs that
27169call boot monitor routines pass an unknown value in @code{$gp}.
27170(In such situations, the boot monitor itself is usually compiled
27171with @option{-G0}.)
27172
27173@option{-mno-gpopt} implies @option{-mno-local-sdata} and
27174@option{-mno-extern-sdata}.
27175
d77de738
ML
27176@opindex membedded-data
27177@opindex mno-embedded-data
ddf6fe37
AA
27178@item -membedded-data
27179@itemx -mno-embedded-data
d77de738
ML
27180Allocate variables to the read-only data section first if possible, then
27181next in the small data section if possible, otherwise in data. This gives
27182slightly slower code than the default, but reduces the amount of RAM required
27183when executing, and thus may be preferred for some embedded systems.
27184
d77de738
ML
27185@opindex muninit-const-in-rodata
27186@opindex mno-uninit-const-in-rodata
ddf6fe37
AA
27187@item -muninit-const-in-rodata
27188@itemx -mno-uninit-const-in-rodata
d77de738
ML
27189Put uninitialized @code{const} variables in the read-only data section.
27190This option is only meaningful in conjunction with @option{-membedded-data}.
27191
d77de738 27192@opindex mcode-readable
ddf6fe37 27193@item -mcode-readable=@var{setting}
d77de738
ML
27194Specify whether GCC may generate code that reads from executable sections.
27195There are three possible settings:
27196
27197@table @gcctabopt
27198@item -mcode-readable=yes
27199Instructions may freely access executable sections. This is the
27200default setting.
27201
27202@item -mcode-readable=pcrel
27203MIPS16 PC-relative load instructions can access executable sections,
27204but other instructions must not do so. This option is useful on 4KSc
27205and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27206It is also useful on processors that can be configured to have a dual
27207instruction/data SRAM interface and that, like the M4K, automatically
27208redirect PC-relative loads to the instruction RAM.
27209
27210@item -mcode-readable=no
27211Instructions must not access executable sections. This option can be
27212useful on targets that are configured to have a dual instruction/data
27213SRAM interface but that (unlike the M4K) do not automatically redirect
27214PC-relative loads to the instruction RAM.
27215@end table
27216
d77de738
ML
27217@opindex msplit-addresses
27218@opindex mno-split-addresses
ddf6fe37
AA
27219@item -msplit-addresses
27220@itemx -mno-split-addresses
d77de738
ML
27221Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27222relocation operators. This option has been superseded by
27223@option{-mexplicit-relocs} but is retained for backwards compatibility.
27224
d77de738
ML
27225@opindex mexplicit-relocs
27226@opindex mno-explicit-relocs
ddf6fe37
AA
27227@item -mexplicit-relocs
27228@itemx -mno-explicit-relocs
d77de738
ML
27229Use (do not use) assembler relocation operators when dealing with symbolic
27230addresses. The alternative, selected by @option{-mno-explicit-relocs},
27231is to use assembler macros instead.
27232
27233@option{-mexplicit-relocs} is the default if GCC was configured
27234to use an assembler that supports relocation operators.
27235
d77de738
ML
27236@opindex mcheck-zero-division
27237@opindex mno-check-zero-division
ddf6fe37
AA
27238@item -mcheck-zero-division
27239@itemx -mno-check-zero-division
d77de738
ML
27240Trap (do not trap) on integer division by zero.
27241
27242The default is @option{-mcheck-zero-division}.
27243
d77de738
ML
27244@opindex mdivide-traps
27245@opindex mdivide-breaks
ddf6fe37
AA
27246@item -mdivide-traps
27247@itemx -mdivide-breaks
d77de738
ML
27248MIPS systems check for division by zero by generating either a
27249conditional trap or a break instruction. Using traps results in
27250smaller code, but is only supported on MIPS II and later. Also, some
27251versions of the Linux kernel have a bug that prevents trap from
27252generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27253allow conditional traps on architectures that support them and
27254@option{-mdivide-breaks} to force the use of breaks.
27255
27256The default is usually @option{-mdivide-traps}, but this can be
27257overridden at configure time using @option{--with-divide=breaks}.
27258Divide-by-zero checks can be completely disabled using
27259@option{-mno-check-zero-division}.
27260
d77de738
ML
27261@opindex mload-store-pairs
27262@opindex mno-load-store-pairs
ddf6fe37
AA
27263@item -mload-store-pairs
27264@itemx -mno-load-store-pairs
d77de738
ML
27265Enable (disable) an optimization that pairs consecutive load or store
27266instructions to enable load/store bonding. This option is enabled by
27267default but only takes effect when the selected architecture is known
27268to support bonding.
27269
d77de738
ML
27270@opindex munaligned-access
27271@opindex mno-unaligned-access
ddf6fe37
AA
27272@item -munaligned-access
27273@itemx -mno-unaligned-access
d77de738
ML
27274Enable (disable) direct unaligned access for MIPS Release 6.
27275MIPSr6 requires load/store unaligned-access support,
27276by hardware or trap&emulate.
27277So @option{-mno-unaligned-access} may be needed by kernel.
27278
d77de738
ML
27279@opindex mmemcpy
27280@opindex mno-memcpy
ddf6fe37
AA
27281@item -mmemcpy
27282@itemx -mno-memcpy
d77de738
ML
27283Force (do not force) the use of @code{memcpy} for non-trivial block
27284moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27285most constant-sized copies.
27286
d77de738
ML
27287@opindex mlong-calls
27288@opindex mno-long-calls
ddf6fe37
AA
27289@item -mlong-calls
27290@itemx -mno-long-calls
d77de738
ML
27291Disable (do not disable) use of the @code{jal} instruction. Calling
27292functions using @code{jal} is more efficient but requires the caller
27293and callee to be in the same 256 megabyte segment.
27294
27295This option has no effect on abicalls code. The default is
27296@option{-mno-long-calls}.
27297
d77de738
ML
27298@opindex mmad
27299@opindex mno-mad
ddf6fe37
AA
27300@item -mmad
27301@itemx -mno-mad
d77de738
ML
27302Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27303instructions, as provided by the R4650 ISA@.
27304
d77de738
ML
27305@opindex mimadd
27306@opindex mno-imadd
ddf6fe37
AA
27307@item -mimadd
27308@itemx -mno-imadd
d77de738
ML
27309Enable (disable) use of the @code{madd} and @code{msub} integer
27310instructions. The default is @option{-mimadd} on architectures
27311that support @code{madd} and @code{msub} except for the 74k
27312architecture where it was found to generate slower code.
27313
d77de738
ML
27314@opindex mfused-madd
27315@opindex mno-fused-madd
ddf6fe37
AA
27316@item -mfused-madd
27317@itemx -mno-fused-madd
d77de738
ML
27318Enable (disable) use of the floating-point multiply-accumulate
27319instructions, when they are available. The default is
27320@option{-mfused-madd}.
27321
27322On the R8000 CPU when multiply-accumulate instructions are used,
27323the intermediate product is calculated to infinite precision
27324and is not subject to the FCSR Flush to Zero bit. This may be
27325undesirable in some circumstances. On other processors the result
27326is numerically identical to the equivalent computation using
27327separate multiply, add, subtract and negate instructions.
27328
d77de738 27329@opindex nocpp
ddf6fe37 27330@item -nocpp
d77de738
ML
27331Tell the MIPS assembler to not run its preprocessor over user
27332assembler files (with a @samp{.s} suffix) when assembling them.
27333
d77de738
ML
27334@opindex mfix-24k
27335@opindex mno-fix-24k
ddf6fe37
AA
27336@item -mfix-24k
27337@itemx -mno-fix-24k
d77de738
ML
27338Work around the 24K E48 (lost data on stores during refill) errata.
27339The workarounds are implemented by the assembler rather than by GCC@.
27340
d77de738
ML
27341@opindex mfix-r4000
27342@opindex mno-fix-r4000
ddf6fe37
AA
27343@item -mfix-r4000
27344@itemx -mno-fix-r4000
d77de738
ML
27345Work around certain R4000 CPU errata:
27346@itemize @minus
27347@item
27348A double-word or a variable shift may give an incorrect result if executed
27349immediately after starting an integer division.
27350@item
27351A double-word or a variable shift may give an incorrect result if executed
27352while an integer multiplication is in progress.
27353@item
27354An integer division may give an incorrect result if started in a delay slot
27355of a taken branch or a jump.
27356@end itemize
27357
d77de738
ML
27358@opindex mfix-r4400
27359@opindex mno-fix-r4400
ddf6fe37
AA
27360@item -mfix-r4400
27361@itemx -mno-fix-r4400
d77de738
ML
27362Work around certain R4400 CPU errata:
27363@itemize @minus
27364@item
27365A double-word or a variable shift may give an incorrect result if executed
27366immediately after starting an integer division.
27367@end itemize
27368
d77de738
ML
27369@opindex mfix-r10000
27370@opindex mno-fix-r10000
ddf6fe37
AA
27371@item -mfix-r10000
27372@itemx -mno-fix-r10000
d77de738
ML
27373Work around certain R10000 errata:
27374@itemize @minus
27375@item
27376@code{ll}/@code{sc} sequences may not behave atomically on revisions
27377prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27378@end itemize
27379
27380This option can only be used if the target architecture supports
27381branch-likely instructions. @option{-mfix-r10000} is the default when
27382@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27383otherwise.
27384
ddf6fe37 27385@opindex mfix-r5900
d77de738
ML
27386@item -mfix-r5900
27387@itemx -mno-fix-r5900
d77de738
ML
27388Do not attempt to schedule the preceding instruction into the delay slot
27389of a branch instruction placed at the end of a short loop of six
27390instructions or fewer and always schedule a @code{nop} instruction there
27391instead. The short loop bug under certain conditions causes loops to
27392execute only once or twice, due to a hardware bug in the R5900 chip. The
27393workaround is implemented by the assembler rather than by GCC@.
27394
ddf6fe37 27395@opindex mfix-rm7000
d77de738
ML
27396@item -mfix-rm7000
27397@itemx -mno-fix-rm7000
d77de738
ML
27398Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27399workarounds are implemented by the assembler rather than by GCC@.
27400
ddf6fe37 27401@opindex mfix-vr4120
d77de738
ML
27402@item -mfix-vr4120
27403@itemx -mno-fix-vr4120
d77de738
ML
27404Work around certain VR4120 errata:
27405@itemize @minus
27406@item
27407@code{dmultu} does not always produce the correct result.
27408@item
27409@code{div} and @code{ddiv} do not always produce the correct result if one
27410of the operands is negative.
27411@end itemize
27412The workarounds for the division errata rely on special functions in
27413@file{libgcc.a}. At present, these functions are only provided by
27414the @code{mips64vr*-elf} configurations.
27415
27416Other VR4120 errata require a NOP to be inserted between certain pairs of
27417instructions. These errata are handled by the assembler, not by GCC itself.
27418
d77de738 27419@opindex mfix-vr4130
ddf6fe37 27420@item -mfix-vr4130
d77de738
ML
27421Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27422workarounds are implemented by the assembler rather than by GCC,
27423although GCC avoids using @code{mflo} and @code{mfhi} if the
27424VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27425instructions are available instead.
27426
ddf6fe37 27427@opindex mfix-sb1
d77de738
ML
27428@item -mfix-sb1
27429@itemx -mno-fix-sb1
d77de738
ML
27430Work around certain SB-1 CPU core errata.
27431(This flag currently works around the SB-1 revision 2
27432``F1'' and ``F2'' floating-point errata.)
27433
d77de738 27434@opindex mr10k-cache-barrier
ddf6fe37 27435@item -mr10k-cache-barrier=@var{setting}
d77de738
ML
27436Specify whether GCC should insert cache barriers to avoid the
27437side effects of speculation on R10K processors.
27438
27439In common with many processors, the R10K tries to predict the outcome
27440of a conditional branch and speculatively executes instructions from
27441the ``taken'' branch. It later aborts these instructions if the
27442predicted outcome is wrong. However, on the R10K, even aborted
27443instructions can have side effects.
27444
27445This problem only affects kernel stores and, depending on the system,
27446kernel loads. As an example, a speculatively-executed store may load
27447the target memory into cache and mark the cache line as dirty, even if
27448the store itself is later aborted. If a DMA operation writes to the
27449same area of memory before the ``dirty'' line is flushed, the cached
27450data overwrites the DMA-ed data. See the R10K processor manual
27451for a full description, including other potential problems.
27452
27453One workaround is to insert cache barrier instructions before every memory
27454access that might be speculatively executed and that might have side
27455effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27456controls GCC's implementation of this workaround. It assumes that
27457aborted accesses to any byte in the following regions does not have
27458side effects:
27459
27460@enumerate
27461@item
27462the memory occupied by the current function's stack frame;
27463
27464@item
27465the memory occupied by an incoming stack argument;
27466
27467@item
27468the memory occupied by an object with a link-time-constant address.
27469@end enumerate
27470
27471It is the kernel's responsibility to ensure that speculative
27472accesses to these regions are indeed safe.
27473
27474If the input program contains a function declaration such as:
27475
27476@smallexample
27477void foo (void);
27478@end smallexample
27479
27480then the implementation of @code{foo} must allow @code{j foo} and
27481@code{jal foo} to be executed speculatively. GCC honors this
27482restriction for functions it compiles itself. It expects non-GCC
27483functions (such as hand-written assembly code) to do the same.
27484
27485The option has three forms:
27486
27487@table @gcctabopt
27488@item -mr10k-cache-barrier=load-store
27489Insert a cache barrier before a load or store that might be
27490speculatively executed and that might have side effects even
27491if aborted.
27492
27493@item -mr10k-cache-barrier=store
27494Insert a cache barrier before a store that might be speculatively
27495executed and that might have side effects even if aborted.
27496
27497@item -mr10k-cache-barrier=none
27498Disable the insertion of cache barriers. This is the default setting.
27499@end table
27500
ddf6fe37 27501@opindex mflush-func
d77de738
ML
27502@item -mflush-func=@var{func}
27503@itemx -mno-flush-func
d77de738
ML
27504Specifies the function to call to flush the I and D caches, or to not
27505call any such function. If called, the function must take the same
27506arguments as the common @code{_flush_func}, that is, the address of the
27507memory range for which the cache is being flushed, the size of the
27508memory range, and the number 3 (to flush both caches). The default
27509depends on the target GCC was configured for, but commonly is either
27510@code{_flush_func} or @code{__cpu_flush}.
27511
d77de738 27512@opindex mbranch-cost
ddf6fe37 27513@item mbranch-cost=@var{num}
d77de738
ML
27514Set the cost of branches to roughly @var{num} ``simple'' instructions.
27515This cost is only a heuristic and is not guaranteed to produce
27516consistent results across releases. A zero cost redundantly selects
27517the default, which is based on the @option{-mtune} setting.
27518
d77de738
ML
27519@opindex mbranch-likely
27520@opindex mno-branch-likely
ddf6fe37
AA
27521@item -mbranch-likely
27522@itemx -mno-branch-likely
d77de738
ML
27523Enable or disable use of Branch Likely instructions, regardless of the
27524default for the selected architecture. By default, Branch Likely
27525instructions may be generated if they are supported by the selected
27526architecture. An exception is for the MIPS32 and MIPS64 architectures
27527and processors that implement those architectures; for those, Branch
27528Likely instructions are not be generated by default because the MIPS32
27529and MIPS64 architectures specifically deprecate their use.
27530
d77de738
ML
27531@opindex mcompact-branches=never
27532@opindex mcompact-branches=optimal
27533@opindex mcompact-branches=always
ddf6fe37
AA
27534@item -mcompact-branches=never
27535@itemx -mcompact-branches=optimal
27536@itemx -mcompact-branches=always
d77de738
ML
27537These options control which form of branches will be generated. The
27538default is @option{-mcompact-branches=optimal}.
27539
27540The @option{-mcompact-branches=never} option ensures that compact branch
27541instructions will never be generated.
27542
27543The @option{-mcompact-branches=always} option ensures that a compact
27544branch instruction will be generated if available for MIPS Release 6 onwards.
27545If a compact branch instruction is not available (or pre-R6),
27546a delay slot form of the branch will be used instead.
27547
27548If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27549The behaviour for MIPS16/microMIPS may change in future,
27550since they do have some compact branch instructions.
27551
27552The @option{-mcompact-branches=optimal} option will cause a delay slot
27553branch to be used if one is available in the current ISA and the delay
27554slot is successfully filled. If the delay slot is not filled, a compact
27555branch will be chosen if one is available.
27556
ddf6fe37 27557@opindex mfp-exceptions
d77de738
ML
27558@item -mfp-exceptions
27559@itemx -mno-fp-exceptions
d77de738
ML
27560Specifies whether FP exceptions are enabled. This affects how
27561FP instructions are scheduled for some processors.
27562The default is that FP exceptions are
27563enabled.
27564
27565For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2756664-bit code, then we can use both FP pipes. Otherwise, we can only use one
27567FP pipe.
27568
ddf6fe37 27569@opindex mvr4130-align
d77de738
ML
27570@item -mvr4130-align
27571@itemx -mno-vr4130-align
d77de738
ML
27572The VR4130 pipeline is two-way superscalar, but can only issue two
27573instructions together if the first one is 8-byte aligned. When this
27574option is enabled, GCC aligns pairs of instructions that it
27575thinks should execute in parallel.
27576
27577This option only has an effect when optimizing for the VR4130.
27578It normally makes code faster, but at the expense of making it bigger.
27579It is enabled by default at optimization level @option{-O3}.
27580
ddf6fe37 27581@opindex msynci
d77de738
ML
27582@item -msynci
27583@itemx -mno-synci
d77de738
ML
27584Enable (disable) generation of @code{synci} instructions on
27585architectures that support it. The @code{synci} instructions (if
27586enabled) are generated when @code{__builtin___clear_cache} is
27587compiled.
27588
27589This option defaults to @option{-mno-synci}, but the default can be
27590overridden by configuring GCC with @option{--with-synci}.
27591
27592When compiling code for single processor systems, it is generally safe
27593to use @code{synci}. However, on many multi-core (SMP) systems, it
27594does not invalidate the instruction caches on all cores and may lead
27595to undefined behavior.
27596
ddf6fe37 27597@opindex mrelax-pic-calls
d77de738
ML
27598@item -mrelax-pic-calls
27599@itemx -mno-relax-pic-calls
d77de738
ML
27600Try to turn PIC calls that are normally dispatched via register
27601@code{$25} into direct calls. This is only possible if the linker can
27602resolve the destination at link time and if the destination is within
27603range for a direct call.
27604
27605@option{-mrelax-pic-calls} is the default if GCC was configured to use
27606an assembler and a linker that support the @code{.reloc} assembly
27607directive and @option{-mexplicit-relocs} is in effect. With
27608@option{-mno-explicit-relocs}, this optimization can be performed by the
27609assembler and the linker alone without help from the compiler.
27610
d77de738
ML
27611@opindex mmcount-ra-address
27612@opindex mno-mcount-ra-address
ddf6fe37
AA
27613@item -mmcount-ra-address
27614@itemx -mno-mcount-ra-address
d77de738
ML
27615Emit (do not emit) code that allows @code{_mcount} to modify the
27616calling function's return address. When enabled, this option extends
27617the usual @code{_mcount} interface with a new @var{ra-address}
27618parameter, which has type @code{intptr_t *} and is passed in register
27619@code{$12}. @code{_mcount} can then modify the return address by
27620doing both of the following:
27621@itemize
27622@item
27623Returning the new address in register @code{$31}.
27624@item
27625Storing the new address in @code{*@var{ra-address}},
27626if @var{ra-address} is nonnull.
27627@end itemize
27628
27629The default is @option{-mno-mcount-ra-address}.
27630
ddf6fe37 27631@opindex mframe-header-opt
d77de738
ML
27632@item -mframe-header-opt
27633@itemx -mno-frame-header-opt
d77de738
ML
27634Enable (disable) frame header optimization in the o32 ABI. When using the
27635o32 ABI, calling functions will allocate 16 bytes on the stack for the called
27636function to write out register arguments. When enabled, this optimization
27637will suppress the allocation of the frame header if it can be determined that
27638it is unused.
27639
27640This optimization is off by default at all optimization levels.
27641
ddf6fe37 27642@opindex mlxc1-sxc1
d77de738
ML
27643@item -mlxc1-sxc1
27644@itemx -mno-lxc1-sxc1
d77de738
ML
27645When applicable, enable (disable) the generation of @code{lwxc1},
27646@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
27647
ddf6fe37 27648@opindex mmadd4
d77de738
ML
27649@item -mmadd4
27650@itemx -mno-madd4
d77de738
ML
27651When applicable, enable (disable) the generation of 4-operand @code{madd.s},
27652@code{madd.d} and related instructions. Enabled by default.
27653
27654@end table
27655
27656@node MMIX Options
27657@subsection MMIX Options
27658@cindex MMIX Options
27659
27660These options are defined for the MMIX:
27661
27662@table @gcctabopt
d77de738
ML
27663@opindex mlibfuncs
27664@opindex mno-libfuncs
ddf6fe37
AA
27665@item -mlibfuncs
27666@itemx -mno-libfuncs
d77de738
ML
27667Specify that intrinsic library functions are being compiled, passing all
27668values in registers, no matter the size.
27669
d77de738
ML
27670@opindex mepsilon
27671@opindex mno-epsilon
ddf6fe37
AA
27672@item -mepsilon
27673@itemx -mno-epsilon
d77de738
ML
27674Generate floating-point comparison instructions that compare with respect
27675to the @code{rE} epsilon register.
27676
d77de738
ML
27677@opindex mabi=mmixware
27678@opindex mabi=gnu
ddf6fe37
AA
27679@item -mabi=mmixware
27680@itemx -mabi=gnu
d77de738
ML
27681Generate code that passes function parameters and return values that (in
27682the called function) are seen as registers @code{$0} and up, as opposed to
27683the GNU ABI which uses global registers @code{$231} and up.
27684
d77de738
ML
27685@opindex mzero-extend
27686@opindex mno-zero-extend
ddf6fe37
AA
27687@item -mzero-extend
27688@itemx -mno-zero-extend
d77de738
ML
27689When reading data from memory in sizes shorter than 64 bits, use (do not
27690use) zero-extending load instructions by default, rather than
27691sign-extending ones.
27692
d77de738
ML
27693@opindex mknuthdiv
27694@opindex mno-knuthdiv
ddf6fe37
AA
27695@item -mknuthdiv
27696@itemx -mno-knuthdiv
d77de738
ML
27697Make the result of a division yielding a remainder have the same sign as
27698the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
27699remainder follows the sign of the dividend. Both methods are
27700arithmetically valid, the latter being almost exclusively used.
27701
d77de738
ML
27702@opindex mtoplevel-symbols
27703@opindex mno-toplevel-symbols
ddf6fe37
AA
27704@item -mtoplevel-symbols
27705@itemx -mno-toplevel-symbols
d77de738
ML
27706Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
27707code can be used with the @code{PREFIX} assembly directive.
27708
d77de738 27709@opindex melf
ddf6fe37 27710@item -melf
d77de738
ML
27711Generate an executable in the ELF format, rather than the default
27712@samp{mmo} format used by the @command{mmix} simulator.
27713
d77de738
ML
27714@opindex mbranch-predict
27715@opindex mno-branch-predict
ddf6fe37
AA
27716@item -mbranch-predict
27717@itemx -mno-branch-predict
d77de738
ML
27718Use (do not use) the probable-branch instructions, when static branch
27719prediction indicates a probable branch.
27720
d77de738
ML
27721@opindex mbase-addresses
27722@opindex mno-base-addresses
ddf6fe37
AA
27723@item -mbase-addresses
27724@itemx -mno-base-addresses
d77de738
ML
27725Generate (do not generate) code that uses @emph{base addresses}. Using a
27726base address automatically generates a request (handled by the assembler
27727and the linker) for a constant to be set up in a global register. The
27728register is used for one or more base address requests within the range 0
27729to 255 from the value held in the register. The generally leads to short
27730and fast code, but the number of different data items that can be
27731addressed is limited. This means that a program that uses lots of static
27732data may require @option{-mno-base-addresses}.
27733
d77de738
ML
27734@opindex msingle-exit
27735@opindex mno-single-exit
ddf6fe37
AA
27736@item -msingle-exit
27737@itemx -mno-single-exit
d77de738
ML
27738Force (do not force) generated code to have a single exit point in each
27739function.
27740@end table
27741
27742@node MN10300 Options
27743@subsection MN10300 Options
27744@cindex MN10300 options
27745
27746These @option{-m} options are defined for Matsushita MN10300 architectures:
27747
27748@table @gcctabopt
d77de738 27749@opindex mmult-bug
ddf6fe37 27750@item -mmult-bug
d77de738
ML
27751Generate code to avoid bugs in the multiply instructions for the MN10300
27752processors. This is the default.
27753
d77de738 27754@opindex mno-mult-bug
ddf6fe37 27755@item -mno-mult-bug
d77de738
ML
27756Do not generate code to avoid bugs in the multiply instructions for the
27757MN10300 processors.
27758
d77de738 27759@opindex mam33
ddf6fe37 27760@item -mam33
d77de738
ML
27761Generate code using features specific to the AM33 processor.
27762
d77de738 27763@opindex mno-am33
ddf6fe37 27764@item -mno-am33
d77de738
ML
27765Do not generate code using features specific to the AM33 processor. This
27766is the default.
27767
d77de738 27768@opindex mam33-2
ddf6fe37 27769@item -mam33-2
d77de738
ML
27770Generate code using features specific to the AM33/2.0 processor.
27771
d77de738 27772@opindex mam34
ddf6fe37 27773@item -mam34
d77de738
ML
27774Generate code using features specific to the AM34 processor.
27775
d77de738 27776@opindex mtune
ddf6fe37 27777@item -mtune=@var{cpu-type}
d77de738
ML
27778Use the timing characteristics of the indicated CPU type when
27779scheduling instructions. This does not change the targeted processor
27780type. The CPU type must be one of @samp{mn10300}, @samp{am33},
27781@samp{am33-2} or @samp{am34}.
27782
d77de738 27783@opindex mreturn-pointer-on-d0
ddf6fe37 27784@item -mreturn-pointer-on-d0
d77de738
ML
27785When generating a function that returns a pointer, return the pointer
27786in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
27787only in @code{a0}, and attempts to call such functions without a prototype
27788result in errors. Note that this option is on by default; use
27789@option{-mno-return-pointer-on-d0} to disable it.
27790
d77de738 27791@opindex mno-crt0
ddf6fe37 27792@item -mno-crt0
d77de738
ML
27793Do not link in the C run-time initialization object file.
27794
d77de738 27795@opindex mrelax
ddf6fe37 27796@item -mrelax
d77de738
ML
27797Indicate to the linker that it should perform a relaxation optimization pass
27798to shorten branches, calls and absolute memory addresses. This option only
27799has an effect when used on the command line for the final link step.
27800
27801This option makes symbolic debugging impossible.
27802
d77de738 27803@opindex mliw
ddf6fe37 27804@item -mliw
d77de738
ML
27805Allow the compiler to generate @emph{Long Instruction Word}
27806instructions if the target is the @samp{AM33} or later. This is the
27807default. This option defines the preprocessor macro @code{__LIW__}.
27808
d77de738 27809@opindex mno-liw
ddf6fe37 27810@item -mno-liw
d77de738
ML
27811Do not allow the compiler to generate @emph{Long Instruction Word}
27812instructions. This option defines the preprocessor macro
27813@code{__NO_LIW__}.
27814
d77de738 27815@opindex msetlb
ddf6fe37 27816@item -msetlb
d77de738
ML
27817Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
27818instructions if the target is the @samp{AM33} or later. This is the
27819default. This option defines the preprocessor macro @code{__SETLB__}.
27820
d77de738 27821@opindex mno-setlb
ddf6fe37 27822@item -mno-setlb
d77de738
ML
27823Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
27824instructions. This option defines the preprocessor macro
27825@code{__NO_SETLB__}.
27826
27827@end table
27828
27829@node Moxie Options
27830@subsection Moxie Options
27831@cindex Moxie Options
27832
27833@table @gcctabopt
27834
d77de738 27835@opindex meb
ddf6fe37 27836@item -meb
d77de738
ML
27837Generate big-endian code. This is the default for @samp{moxie-*-*}
27838configurations.
27839
d77de738 27840@opindex mel
ddf6fe37 27841@item -mel
d77de738
ML
27842Generate little-endian code.
27843
d77de738 27844@opindex mmul.x
ddf6fe37 27845@item -mmul.x
d77de738
ML
27846Generate mul.x and umul.x instructions. This is the default for
27847@samp{moxiebox-*-*} configurations.
27848
d77de738 27849@opindex mno-crt0
ddf6fe37 27850@item -mno-crt0
d77de738
ML
27851Do not link in the C run-time initialization object file.
27852
27853@end table
27854
27855@node MSP430 Options
27856@subsection MSP430 Options
27857@cindex MSP430 Options
27858
27859These options are defined for the MSP430:
27860
27861@table @gcctabopt
27862
d77de738 27863@opindex masm-hex
ddf6fe37 27864@item -masm-hex
d77de738
ML
27865Force assembly output to always use hex constants. Normally such
27866constants are signed decimals, but this option is available for
27867testsuite and/or aesthetic purposes.
27868
d77de738 27869@opindex mmcu=
ddf6fe37 27870@item -mmcu=
d77de738
ML
27871Select the MCU to target. This is used to create a C preprocessor
27872symbol based upon the MCU name, converted to upper case and pre- and
27873post-fixed with @samp{__}. This in turn is used by the
27874@file{msp430.h} header file to select an MCU-specific supplementary
27875header file.
27876
27877The option also sets the ISA to use. If the MCU name is one that is
27878known to only support the 430 ISA then that is selected, otherwise the
27879430X ISA is selected. A generic MCU name of @samp{msp430} can also be
27880used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
27881name selects the 430X ISA.
27882
27883In addition an MCU-specific linker script is added to the linker
27884command line. The script's name is the name of the MCU with
27885@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
27886command line defines the C preprocessor symbol @code{__XXX__} and
27887cause the linker to search for a script called @file{xxx.ld}.
27888
27889The ISA and hardware multiply supported for the different MCUs is hard-coded
27890into GCC. However, an external @samp{devices.csv} file can be used to
27891extend device support beyond those that have been hard-coded.
27892
27893GCC searches for the @samp{devices.csv} file using the following methods in the
27894given precedence order, where the first method takes precendence over the
27895second which takes precedence over the third.
27896
27897@table @asis
27898@item Include path specified with @code{-I} and @code{-L}
27899@samp{devices.csv} will be searched for in each of the directories specified by
27900include paths and linker library search paths.
27901@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
27902Define the value of the global environment variable
27903@samp{MSP430_GCC_INCLUDE_DIR}
27904to the full path to the directory containing devices.csv, and GCC will search
27905this directory for devices.csv. If devices.csv is found, this directory will
27906also be registered as an include path, and linker library path. Header files
27907and linker scripts in this directory can therefore be used without manually
27908specifying @code{-I} and @code{-L} on the command line.
27909@item The @samp{msp430-elf@{,bare@}/include/devices} directory
27910Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
27911toolchain root directory. This directory does not exist in a default
27912installation, but if the user has created it and copied @samp{devices.csv}
27913there, then the MCU data will be read. As above, this directory will
27914also be registered as an include path, and linker library path.
27915
27916@end table
27917If none of the above search methods find @samp{devices.csv}, then the
27918hard-coded MCU data is used.
27919
27920
d77de738
ML
27921@opindex mwarn-mcu
27922@opindex mno-warn-mcu
ddf6fe37
AA
27923@item -mwarn-mcu
27924@itemx -mno-warn-mcu
d77de738
ML
27925This option enables or disables warnings about conflicts between the
27926MCU name specified by the @option{-mmcu} option and the ISA set by the
27927@option{-mcpu} option and/or the hardware multiply support set by the
27928@option{-mhwmult} option. It also toggles warnings about unrecognized
27929MCU names. This option is on by default.
27930
d77de738 27931@opindex mcpu=
ddf6fe37 27932@item -mcpu=
d77de738
ML
27933Specifies the ISA to use. Accepted values are @samp{msp430},
27934@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
27935@option{-mmcu=} option should be used to select the ISA.
27936
d77de738 27937@opindex msim
ddf6fe37 27938@item -msim
d77de738
ML
27939Link to the simulator runtime libraries and linker script. Overrides
27940any scripts that would be selected by the @option{-mmcu=} option.
27941
d77de738 27942@opindex mlarge
ddf6fe37 27943@item -mlarge
d77de738
ML
27944Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
27945
d77de738 27946@opindex msmall
ddf6fe37 27947@item -msmall
d77de738
ML
27948Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
27949
d77de738 27950@opindex mrelax
ddf6fe37 27951@item -mrelax
d77de738
ML
27952This option is passed to the assembler and linker, and allows the
27953linker to perform certain optimizations that cannot be done until
27954the final link.
27955
d77de738 27956@opindex mhwmult=
ddf6fe37 27957@item mhwmult=
d77de738
ML
27958Describes the type of hardware multiply supported by the target.
27959Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
27960for the original 16-bit-only multiply supported by early MCUs.
27961@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
27962@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
27963A value of @samp{auto} can also be given. This tells GCC to deduce
27964the hardware multiply support based upon the MCU name provided by the
27965@option{-mmcu} option. If no @option{-mmcu} option is specified or if
27966the MCU name is not recognized then no hardware multiply support is
27967assumed. @code{auto} is the default setting.
27968
27969Hardware multiplies are normally performed by calling a library
27970routine. This saves space in the generated code. When compiling at
27971@option{-O3} or higher however the hardware multiplier is invoked
27972inline. This makes for bigger, but faster code.
27973
27974The hardware multiply routines disable interrupts whilst running and
27975restore the previous interrupt state when they finish. This makes
27976them safe to use inside interrupt handlers as well as in normal code.
27977
d77de738 27978@opindex minrt
ddf6fe37 27979@item -minrt
d77de738
ML
27980Enable the use of a minimum runtime environment - no static
27981initializers or constructors. This is intended for memory-constrained
27982devices. The compiler includes special symbols in some objects
27983that tell the linker and runtime which code fragments are required.
27984
d77de738 27985@opindex mtiny-printf
ddf6fe37 27986@item -mtiny-printf
d77de738
ML
27987Enable reduced code size @code{printf} and @code{puts} library functions.
27988The @samp{tiny} implementations of these functions are not reentrant, so
27989must be used with caution in multi-threaded applications.
27990
27991Support for streams has been removed and the string to be printed will
27992always be sent to stdout via the @code{write} syscall. The string is not
27993buffered before it is sent to write.
27994
27995This option requires Newlib Nano IO, so GCC must be configured with
27996@samp{--enable-newlib-nano-formatted-io}.
27997
d77de738 27998@opindex mmax-inline-shift=
ddf6fe37 27999@item -mmax-inline-shift=
d77de738
ML
28000This option takes an integer between 0 and 64 inclusive, and sets
28001the maximum number of inline shift instructions which should be emitted to
28002perform a shift operation by a constant amount. When this value needs to be
28003exceeded, an mspabi helper function is used instead. The default value is 4.
28004
28005This only affects cases where a shift by multiple positions cannot be
28006completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
28007
28008Shifts of a 32-bit value are at least twice as costly, so the value passed for
28009this option is divided by 2 and the resulting value used instead.
28010
d77de738
ML
28011@opindex mcode-region
28012@opindex mdata-region
ddf6fe37
AA
28013@item -mcode-region=
28014@itemx -mdata-region=
d77de738
ML
28015These options tell the compiler where to place functions and data that
28016do not have one of the @code{lower}, @code{upper}, @code{either} or
28017@code{section} attributes. Possible values are @code{lower},
28018@code{upper}, @code{either} or @code{any}. The first three behave
28019like the corresponding attribute. The fourth possible value -
28020@code{any} - is the default. It leaves placement entirely up to the
28021linker script and how it assigns the standard sections
28022(@code{.text}, @code{.data}, etc) to the memory regions.
28023
d77de738 28024@opindex msilicon-errata
ddf6fe37 28025@item -msilicon-errata=
d77de738
ML
28026This option passes on a request to assembler to enable the fixes for
28027the named silicon errata.
28028
d77de738 28029@opindex msilicon-errata-warn
ddf6fe37 28030@item -msilicon-errata-warn=
d77de738
ML
28031This option passes on a request to the assembler to enable warning
28032messages when a silicon errata might need to be applied.
28033
d77de738
ML
28034@opindex mwarn-devices-csv
28035@opindex mno-warn-devices-csv
ddf6fe37
AA
28036@item -mwarn-devices-csv
28037@itemx -mno-warn-devices-csv
d77de738
ML
28038Warn if @samp{devices.csv} is not found or there are problem parsing it
28039(default: on).
28040
28041@end table
28042
28043@node NDS32 Options
28044@subsection NDS32 Options
28045@cindex NDS32 Options
28046
28047These options are defined for NDS32 implementations:
28048
28049@table @gcctabopt
28050
d77de738 28051@opindex mbig-endian
ddf6fe37 28052@item -mbig-endian
d77de738
ML
28053Generate code in big-endian mode.
28054
d77de738 28055@opindex mlittle-endian
ddf6fe37 28056@item -mlittle-endian
d77de738
ML
28057Generate code in little-endian mode.
28058
d77de738 28059@opindex mreduced-regs
ddf6fe37 28060@item -mreduced-regs
d77de738
ML
28061Use reduced-set registers for register allocation.
28062
d77de738 28063@opindex mfull-regs
ddf6fe37 28064@item -mfull-regs
d77de738
ML
28065Use full-set registers for register allocation.
28066
d77de738 28067@opindex mcmov
ddf6fe37 28068@item -mcmov
d77de738
ML
28069Generate conditional move instructions.
28070
d77de738 28071@opindex mno-cmov
ddf6fe37 28072@item -mno-cmov
d77de738
ML
28073Do not generate conditional move instructions.
28074
d77de738 28075@opindex mext-perf
ddf6fe37 28076@item -mext-perf
d77de738
ML
28077Generate performance extension instructions.
28078
d77de738 28079@opindex mno-ext-perf
ddf6fe37 28080@item -mno-ext-perf
d77de738
ML
28081Do not generate performance extension instructions.
28082
d77de738 28083@opindex mext-perf2
ddf6fe37 28084@item -mext-perf2
d77de738
ML
28085Generate performance extension 2 instructions.
28086
d77de738 28087@opindex mno-ext-perf2
ddf6fe37 28088@item -mno-ext-perf2
d77de738
ML
28089Do not generate performance extension 2 instructions.
28090
d77de738 28091@opindex mext-string
ddf6fe37 28092@item -mext-string
d77de738
ML
28093Generate string extension instructions.
28094
d77de738 28095@opindex mno-ext-string
ddf6fe37 28096@item -mno-ext-string
d77de738
ML
28097Do not generate string extension instructions.
28098
d77de738 28099@opindex mv3push
ddf6fe37 28100@item -mv3push
d77de738
ML
28101Generate v3 push25/pop25 instructions.
28102
d77de738 28103@opindex mno-v3push
ddf6fe37 28104@item -mno-v3push
d77de738
ML
28105Do not generate v3 push25/pop25 instructions.
28106
d77de738 28107@opindex m16-bit
ddf6fe37 28108@item -m16-bit
d77de738
ML
28109Generate 16-bit instructions.
28110
d77de738 28111@opindex mno-16-bit
ddf6fe37 28112@item -mno-16-bit
d77de738
ML
28113Do not generate 16-bit instructions.
28114
d77de738 28115@opindex misr-vector-size
ddf6fe37 28116@item -misr-vector-size=@var{num}
d77de738
ML
28117Specify the size of each interrupt vector, which must be 4 or 16.
28118
d77de738 28119@opindex mcache-block-size
ddf6fe37 28120@item -mcache-block-size=@var{num}
d77de738
ML
28121Specify the size of each cache block,
28122which must be a power of 2 between 4 and 512.
28123
d77de738 28124@opindex march
ddf6fe37 28125@item -march=@var{arch}
d77de738
ML
28126Specify the name of the target architecture.
28127
d77de738 28128@opindex mcmodel
ddf6fe37 28129@item -mcmodel=@var{code-model}
d77de738
ML
28130Set the code model to one of
28131@table @asis
28132@item @samp{small}
28133All the data and read-only data segments must be within 512KB addressing space.
28134The text segment must be within 16MB addressing space.
28135@item @samp{medium}
28136The data segment must be within 512KB while the read-only data segment can be
28137within 4GB addressing space. The text segment should be still within 16MB
28138addressing space.
28139@item @samp{large}
28140All the text and data segments can be within 4GB addressing space.
28141@end table
28142
d77de738 28143@opindex mctor-dtor
ddf6fe37 28144@item -mctor-dtor
d77de738
ML
28145Enable constructor/destructor feature.
28146
d77de738 28147@opindex mrelax
ddf6fe37 28148@item -mrelax
d77de738
ML
28149Guide linker to relax instructions.
28150
28151@end table
28152
28153@node Nios II Options
28154@subsection Nios II Options
28155@cindex Nios II options
28156@cindex Altera Nios II options
28157
28158These are the options defined for the Altera Nios II processor.
28159
28160@table @gcctabopt
28161
d77de738
ML
28162@opindex G
28163@cindex smaller data references
f33d7a88 28164@item -G @var{num}
d77de738
ML
28165Put global and static objects less than or equal to @var{num} bytes
28166into the small data or BSS sections instead of the normal data or BSS
28167sections. The default value of @var{num} is 8.
28168
ddf6fe37
AA
28169@opindex mgpopt
28170@opindex mno-gpopt
d77de738
ML
28171@item -mgpopt=@var{option}
28172@itemx -mgpopt
28173@itemx -mno-gpopt
d77de738
ML
28174Generate (do not generate) GP-relative accesses. The following
28175@var{option} names are recognized:
28176
28177@table @samp
28178
28179@item none
28180Do not generate GP-relative accesses.
28181
28182@item local
28183Generate GP-relative accesses for small data objects that are not
28184external, weak, or uninitialized common symbols.
28185Also use GP-relative addressing for objects that
28186have been explicitly placed in a small data section via a @code{section}
28187attribute.
28188
28189@item global
28190As for @samp{local}, but also generate GP-relative accesses for
28191small data objects that are external, weak, or common. If you use this option,
28192you must ensure that all parts of your program (including libraries) are
28193compiled with the same @option{-G} setting.
28194
28195@item data
28196Generate GP-relative accesses for all data objects in the program. If you
28197use this option, the entire data and BSS segments
28198of your program must fit in 64K of memory and you must use an appropriate
28199linker script to allocate them within the addressable range of the
28200global pointer.
28201
28202@item all
28203Generate GP-relative addresses for function pointers as well as data
28204pointers. If you use this option, the entire text, data, and BSS segments
28205of your program must fit in 64K of memory and you must use an appropriate
28206linker script to allocate them within the addressable range of the
28207global pointer.
28208
28209@end table
28210
28211@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28212@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28213
28214The default is @option{-mgpopt} except when @option{-fpic} or
28215@option{-fPIC} is specified to generate position-independent code.
28216Note that the Nios II ABI does not permit GP-relative accesses from
28217shared libraries.
28218
28219You may need to specify @option{-mno-gpopt} explicitly when building
28220programs that include large amounts of small data, including large
28221GOT data sections. In this case, the 16-bit offset for GP-relative
28222addressing may not be large enough to allow access to the entire
28223small data section.
28224
d77de738 28225@opindex mgprel-sec
ddf6fe37 28226@item -mgprel-sec=@var{regexp}
d77de738
ML
28227This option specifies additional section names that can be accessed via
28228GP-relative addressing. It is most useful in conjunction with
28229@code{section} attributes on variable declarations
28230(@pxref{Common Variable Attributes}) and a custom linker script.
28231The @var{regexp} is a POSIX Extended Regular Expression.
28232
28233This option does not affect the behavior of the @option{-G} option, and
28234the specified sections are in addition to the standard @code{.sdata}
28235and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28236
d77de738 28237@opindex mr0rel-sec
ddf6fe37 28238@item -mr0rel-sec=@var{regexp}
d77de738
ML
28239This option specifies names of sections that can be accessed via a
2824016-bit offset from @code{r0}; that is, in the low 32K or high 32K
28241of the 32-bit address space. It is most useful in conjunction with
28242@code{section} attributes on variable declarations
28243(@pxref{Common Variable Attributes}) and a custom linker script.
28244The @var{regexp} is a POSIX Extended Regular Expression.
28245
28246In contrast to the use of GP-relative addressing for small data,
28247zero-based addressing is never generated by default and there are no
28248conventional section names used in standard linker scripts for sections
28249in the low or high areas of memory.
28250
d77de738
ML
28251@opindex mel
28252@opindex meb
ddf6fe37
AA
28253@item -mel
28254@itemx -meb
d77de738
ML
28255Generate little-endian (default) or big-endian (experimental) code,
28256respectively.
28257
d77de738 28258@opindex march
ddf6fe37 28259@item -march=@var{arch}
d77de738
ML
28260This specifies the name of the target Nios II architecture. GCC uses this
28261name to determine what kind of instructions it can emit when generating
28262assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28263
28264The preprocessor macro @code{__nios2_arch__} is available to programs,
28265with value 1 or 2, indicating the targeted ISA level.
28266
d77de738
ML
28267@opindex mno-bypass-cache
28268@opindex mbypass-cache
ddf6fe37
AA
28269@item -mbypass-cache
28270@itemx -mno-bypass-cache
d77de738
ML
28271Force all load and store instructions to always bypass cache by
28272using I/O variants of the instructions. The default is not to
28273bypass the cache.
28274
d77de738
ML
28275@opindex mcache-volatile
28276@opindex mno-cache-volatile
ddf6fe37
AA
28277@item -mno-cache-volatile
28278@itemx -mcache-volatile
d77de738
ML
28279Volatile memory access bypass the cache using the I/O variants of
28280the load and store instructions. The default is not to bypass the cache.
28281
d77de738
ML
28282@opindex mno-fast-sw-div
28283@opindex mfast-sw-div
ddf6fe37
AA
28284@item -mno-fast-sw-div
28285@itemx -mfast-sw-div
d77de738
ML
28286Do not use table-based fast divide for small numbers. The default
28287is to use the fast divide at @option{-O3} and above.
28288
d77de738
ML
28289@opindex mno-hw-mul
28290@opindex mhw-mul
28291@opindex mno-hw-mulx
28292@opindex mhw-mulx
28293@opindex mno-hw-div
28294@opindex mhw-div
ddf6fe37
AA
28295@item -mno-hw-mul
28296@itemx -mhw-mul
28297@itemx -mno-hw-mulx
28298@itemx -mhw-mulx
28299@itemx -mno-hw-div
28300@itemx -mhw-div
d77de738
ML
28301Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28302instructions by the compiler. The default is to emit @code{mul}
28303and not emit @code{div} and @code{mulx}.
28304
28305@item -mbmx
28306@itemx -mno-bmx
28307@itemx -mcdx
28308@itemx -mno-cdx
28309Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28310CDX (code density) instructions. Enabling these instructions also
28311requires @option{-march=r2}. Since these instructions are optional
28312extensions to the R2 architecture, the default is not to emit them.
28313
d77de738
ML
28314@opindex mcustom-@var{insn}
28315@opindex mno-custom-@var{insn}
ddf6fe37
AA
28316@item -mcustom-@var{insn}=@var{N}
28317@itemx -mno-custom-@var{insn}
d77de738
ML
28318Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28319custom instruction with encoding @var{N} when generating code that uses
28320@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28321instruction 253 for single-precision floating-point add operations instead
28322of the default behavior of using a library call.
28323
28324The following values of @var{insn} are supported. Except as otherwise
28325noted, floating-point operations are expected to be implemented with
28326normal IEEE 754 semantics and correspond directly to the C operators or the
28327equivalent GCC built-in functions (@pxref{Other Builtins}).
28328
28329Single-precision floating point:
28330@table @asis
28331
28332@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28333Binary arithmetic operations.
28334
28335@item @samp{fnegs}
28336Unary negation.
28337
28338@item @samp{fabss}
28339Unary absolute value.
28340
28341@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28342Comparison operations.
28343
28344@item @samp{fmins}, @samp{fmaxs}
28345Floating-point minimum and maximum. These instructions are only
28346generated if @option{-ffinite-math-only} is specified.
28347
28348@item @samp{fsqrts}
28349Unary square root operation.
28350
28351@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28352Floating-point trigonometric and exponential functions. These instructions
28353are only generated if @option{-funsafe-math-optimizations} is also specified.
28354
28355@end table
28356
28357Double-precision floating point:
28358@table @asis
28359
28360@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28361Binary arithmetic operations.
28362
28363@item @samp{fnegd}
28364Unary negation.
28365
28366@item @samp{fabsd}
28367Unary absolute value.
28368
28369@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28370Comparison operations.
28371
28372@item @samp{fmind}, @samp{fmaxd}
28373Double-precision minimum and maximum. These instructions are only
28374generated if @option{-ffinite-math-only} is specified.
28375
28376@item @samp{fsqrtd}
28377Unary square root operation.
28378
28379@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28380Double-precision trigonometric and exponential functions. These instructions
28381are only generated if @option{-funsafe-math-optimizations} is also specified.
28382
28383@end table
28384
28385Conversions:
28386@table @asis
28387@item @samp{fextsd}
28388Conversion from single precision to double precision.
28389
28390@item @samp{ftruncds}
28391Conversion from double precision to single precision.
28392
28393@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28394Conversion from floating point to signed or unsigned integer types, with
28395truncation towards zero.
28396
28397@item @samp{round}
28398Conversion from single-precision floating point to signed integer,
28399rounding to the nearest integer and ties away from zero.
28400This corresponds to the @code{__builtin_lroundf} function when
28401@option{-fno-math-errno} is used.
28402
28403@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28404Conversion from signed or unsigned integer types to floating-point types.
28405
28406@end table
28407
28408In addition, all of the following transfer instructions for internal
28409registers X and Y must be provided to use any of the double-precision
28410floating-point instructions. Custom instructions taking two
28411double-precision source operands expect the first operand in the
2841264-bit register X. The other operand (or only operand of a unary
28413operation) is given to the custom arithmetic instruction with the
28414least significant half in source register @var{src1} and the most
28415significant half in @var{src2}. A custom instruction that returns a
28416double-precision result returns the most significant 32 bits in the
28417destination register and the other half in 32-bit register Y.
28418GCC automatically generates the necessary code sequences to write
28419register X and/or read register Y when double-precision floating-point
28420instructions are used.
28421
28422@table @asis
28423
28424@item @samp{fwrx}
28425Write @var{src1} into the least significant half of X and @var{src2} into
28426the most significant half of X.
28427
28428@item @samp{fwry}
28429Write @var{src1} into Y.
28430
28431@item @samp{frdxhi}, @samp{frdxlo}
28432Read the most or least (respectively) significant half of X and store it in
28433@var{dest}.
28434
28435@item @samp{frdy}
28436Read the value of Y and store it into @var{dest}.
28437@end table
28438
28439Note that you can gain more local control over generation of Nios II custom
28440instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28441and @code{target("no-custom-@var{insn}")} function attributes
28442(@pxref{Function Attributes})
28443or pragmas (@pxref{Function Specific Option Pragmas}).
28444
d77de738 28445@opindex mcustom-fpu-cfg
ddf6fe37 28446@item -mcustom-fpu-cfg=@var{name}
d77de738
ML
28447
28448This option enables a predefined, named set of custom instruction encodings
28449(see @option{-mcustom-@var{insn}} above).
28450Currently, the following sets are defined:
28451
28452@option{-mcustom-fpu-cfg=60-1} is equivalent to:
28453@gccoptlist{-mcustom-fmuls=252 @gol
28454-mcustom-fadds=253 @gol
28455-mcustom-fsubs=254 @gol
28456-fsingle-precision-constant}
28457
28458@option{-mcustom-fpu-cfg=60-2} is equivalent to:
28459@gccoptlist{-mcustom-fmuls=252 @gol
28460-mcustom-fadds=253 @gol
28461-mcustom-fsubs=254 @gol
28462-mcustom-fdivs=255 @gol
28463-fsingle-precision-constant}
28464
28465@option{-mcustom-fpu-cfg=72-3} is equivalent to:
28466@gccoptlist{-mcustom-floatus=243 @gol
28467-mcustom-fixsi=244 @gol
28468-mcustom-floatis=245 @gol
28469-mcustom-fcmpgts=246 @gol
28470-mcustom-fcmples=249 @gol
28471-mcustom-fcmpeqs=250 @gol
28472-mcustom-fcmpnes=251 @gol
28473-mcustom-fmuls=252 @gol
28474-mcustom-fadds=253 @gol
28475-mcustom-fsubs=254 @gol
28476-mcustom-fdivs=255 @gol
28477-fsingle-precision-constant}
28478
28479@option{-mcustom-fpu-cfg=fph2} is equivalent to:
28480@gccoptlist{-mcustom-fabss=224 @gol
28481-mcustom-fnegs=225 @gol
28482-mcustom-fcmpnes=226 @gol
28483-mcustom-fcmpeqs=227 @gol
28484-mcustom-fcmpges=228 @gol
28485-mcustom-fcmpgts=229 @gol
28486-mcustom-fcmples=230 @gol
28487-mcustom-fcmplts=231 @gol
28488-mcustom-fmaxs=232 @gol
28489-mcustom-fmins=233 @gol
28490-mcustom-round=248 @gol
28491-mcustom-fixsi=249 @gol
28492-mcustom-floatis=250 @gol
28493-mcustom-fsqrts=251 @gol
28494-mcustom-fmuls=252 @gol
28495-mcustom-fadds=253 @gol
28496-mcustom-fsubs=254 @gol
28497-mcustom-fdivs=255 @gol}
28498
28499Custom instruction assignments given by individual
28500@option{-mcustom-@var{insn}=} options override those given by
28501@option{-mcustom-fpu-cfg=}, regardless of the
28502order of the options on the command line.
28503
28504Note that you can gain more local control over selection of a FPU
28505configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28506function attribute (@pxref{Function Attributes})
28507or pragma (@pxref{Function Specific Option Pragmas}).
28508
28509The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28510Hardware 2 Component}. Please note that the custom instructions enabled by
28511@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28512if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28513@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28514specified. In contrast to the other configurations,
28515@option{-fsingle-precision-constant} is not set.
28516
28517@end table
28518
28519These additional @samp{-m} options are available for the Altera Nios II
28520ELF (bare-metal) target:
28521
28522@table @gcctabopt
28523
d77de738 28524@opindex mhal
ddf6fe37 28525@item -mhal
d77de738
ML
28526Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28527startup and termination code, and is typically used in conjunction with
28528@option{-msys-crt0=} to specify the location of the alternate startup code
28529provided by the HAL BSP.
28530
d77de738 28531@opindex msmallc
ddf6fe37 28532@item -msmallc
d77de738
ML
28533Link with a limited version of the C library, @option{-lsmallc}, rather than
28534Newlib.
28535
d77de738 28536@opindex msys-crt0
ddf6fe37 28537@item -msys-crt0=@var{startfile}
d77de738
ML
28538@var{startfile} is the file name of the startfile (crt0) to use
28539when linking. This option is only useful in conjunction with @option{-mhal}.
28540
d77de738 28541@opindex msys-lib
ddf6fe37 28542@item -msys-lib=@var{systemlib}
d77de738
ML
28543@var{systemlib} is the library name of the library that provides
28544low-level system calls required by the C library,
28545e.g.@: @code{read} and @code{write}.
28546This option is typically used to link with a library provided by a HAL BSP.
28547
28548@end table
28549
28550@node Nvidia PTX Options
28551@subsection Nvidia PTX Options
28552@cindex Nvidia PTX options
28553@cindex nvptx options
28554
28555These options are defined for Nvidia PTX:
28556
28557@table @gcctabopt
28558
d77de738 28559@opindex m64
ddf6fe37 28560@item -m64
d77de738
ML
28561Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28562supported.
28563
d77de738 28564@opindex march
ddf6fe37 28565@item -march=@var{architecture-string}
d77de738
ML
28566Generate code for the specified PTX ISA target architecture
28567(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
28568@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
28569@samp{sm_80}.
28570The default depends on how the compiler has been configured, see
28571@option{--with-arch}.
28572
28573This option sets the value of the preprocessor macro
28574@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
28575@samp{350}.
28576
d77de738 28577@opindex misa
ddf6fe37 28578@item -misa=@var{architecture-string}
d77de738
ML
28579Alias of @option{-march=}.
28580
d77de738 28581@opindex march
ddf6fe37 28582@item -march-map=@var{architecture-string}
d77de738
ML
28583Select the closest available @option{-march=} value that is not more
28584capable. For instance, for @option{-march-map=sm_50} select
28585@option{-march=sm_35}, and for @option{-march-map=sm_53} select
28586@option{-march=sm_53}.
28587
d77de738 28588@opindex mptx
ddf6fe37 28589@item -mptx=@var{version-string}
d77de738
ML
28590Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
28591Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
28592@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
28593version is required for specified PTX ISA target architecture via
28594option @option{-march=}.
28595
28596This option sets the values of the preprocessor macros
28597@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
28598for instance, for @samp{3.1} the macros have the values @samp{3} and
28599@samp{1}, respectively.
28600
d77de738 28601@opindex mmainkernel
ddf6fe37 28602@item -mmainkernel
d77de738
ML
28603Link in code for a __main kernel. This is for stand-alone instead of
28604offloading execution.
28605
d77de738 28606@opindex moptimize
ddf6fe37 28607@item -moptimize
d77de738
ML
28608Apply partitioned execution optimizations. This is the default when any
28609level of optimization is selected.
28610
d77de738 28611@opindex msoft-stack
ddf6fe37 28612@item -msoft-stack
d77de738
ML
28613Generate code that does not use @code{.local} memory
28614directly for stack storage. Instead, a per-warp stack pointer is
28615maintained explicitly. This enables variable-length stack allocation (with
28616variable-length arrays or @code{alloca}), and when global memory is used for
28617underlying storage, makes it possible to access automatic variables from other
28618threads, or with atomic instructions. This code generation variant is used
28619for OpenMP offloading, but the option is exposed on its own for the purpose
28620of testing the compiler; to generate code suitable for linking into programs
28621using OpenMP offloading, use option @option{-mgomp}.
28622
d77de738 28623@opindex muniform-simt
ddf6fe37 28624@item -muniform-simt
d77de738
ML
28625Switch to code generation variant that allows to execute all threads in each
28626warp, while maintaining memory state and side effects as if only one thread
28627in each warp was active outside of OpenMP SIMD regions. All atomic operations
28628and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
28629current lane index equals the master lane index), and the register being
28630assigned is copied via a shuffle instruction from the master lane. Outside of
28631SIMD regions lane 0 is the master; inside, each thread sees itself as the
28632master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
28633all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
28634regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
28635with current lane index to compute the master lane index.
28636
d77de738 28637@opindex mgomp
ddf6fe37 28638@item -mgomp
d77de738
ML
28639Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
28640@option{-muniform-simt} options, and selects corresponding multilib variant.
28641
28642@end table
28643
28644@node OpenRISC Options
28645@subsection OpenRISC Options
28646@cindex OpenRISC Options
28647
28648These options are defined for OpenRISC:
28649
28650@table @gcctabopt
28651
d77de738 28652@opindex mboard
ddf6fe37 28653@item -mboard=@var{name}
d77de738
ML
28654Configure a board specific runtime. This will be passed to the linker for
28655newlib board library linking. The default is @code{or1ksim}.
28656
d77de738 28657@opindex mnewlib
ddf6fe37 28658@item -mnewlib
d77de738
ML
28659This option is ignored; it is for compatibility purposes only. This used to
28660select linker and preprocessor options for use with newlib.
28661
d77de738
ML
28662@opindex msoft-div
28663@opindex mhard-div
ddf6fe37
AA
28664@item -msoft-div
28665@itemx -mhard-div
d77de738
ML
28666Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
28667This default is hardware divide.
28668
d77de738
ML
28669@opindex msoft-mul
28670@opindex mhard-mul
ddf6fe37
AA
28671@item -msoft-mul
28672@itemx -mhard-mul
d77de738
ML
28673Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
28674This default is hardware multiply.
28675
d77de738
ML
28676@opindex msoft-float
28677@opindex mhard-float
ddf6fe37
AA
28678@item -msoft-float
28679@itemx -mhard-float
d77de738
ML
28680Select software or hardware for floating point operations.
28681The default is software.
28682
d77de738 28683@opindex mdouble-float
ddf6fe37 28684@item -mdouble-float
d77de738
ML
28685When @option{-mhard-float} is selected, enables generation of double-precision
28686floating point instructions. By default functions from @file{libgcc} are used
28687to perform double-precision floating point operations.
28688
d77de738 28689@opindex munordered-float
ddf6fe37 28690@item -munordered-float
d77de738
ML
28691When @option{-mhard-float} is selected, enables generation of unordered
28692floating point compare and set flag (@code{lf.sfun*}) instructions. By default
28693functions from @file{libgcc} are used to perform unordered floating point
28694compare and set flag operations.
28695
d77de738 28696@opindex mcmov
ddf6fe37 28697@item -mcmov
d77de738
ML
28698Enable generation of conditional move (@code{l.cmov}) instructions. By
28699default the equivalent will be generated using set and branch.
28700
d77de738 28701@opindex mror
ddf6fe37 28702@item -mror
d77de738
ML
28703Enable generation of rotate right (@code{l.ror}) instructions. By default
28704functions from @file{libgcc} are used to perform rotate right operations.
28705
d77de738 28706@opindex mrori
ddf6fe37 28707@item -mrori
d77de738
ML
28708Enable generation of rotate right with immediate (@code{l.rori}) instructions.
28709By default functions from @file{libgcc} are used to perform rotate right with
28710immediate operations.
28711
d77de738 28712@opindex msext
ddf6fe37 28713@item -msext
d77de738
ML
28714Enable generation of sign extension (@code{l.ext*}) instructions. By default
28715memory loads are used to perform sign extension.
28716
d77de738 28717@opindex msfimm
ddf6fe37 28718@item -msfimm
d77de738
ML
28719Enable generation of compare and set flag with immediate (@code{l.sf*i})
28720instructions. By default extra instructions will be generated to store the
28721immediate to a register first.
28722
d77de738 28723@opindex mshftimm
ddf6fe37 28724@item -mshftimm
d77de738
ML
28725Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
28726@code{l.slli}) instructions. By default extra instructions will be generated
28727to store the immediate to a register first.
28728
d77de738 28729@opindex mcmodel=small
ddf6fe37 28730@item -mcmodel=small
d77de738
ML
28731Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
28732the default model.
28733
d77de738 28734@opindex mcmodel=large
ddf6fe37 28735@item -mcmodel=large
d77de738
ML
28736Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
28737
28738
28739@end table
28740
28741@node PDP-11 Options
28742@subsection PDP-11 Options
28743@cindex PDP-11 Options
28744
28745These options are defined for the PDP-11:
28746
28747@table @gcctabopt
d77de738 28748@opindex mfpu
ddf6fe37 28749@item -mfpu
d77de738
ML
28750Use hardware FPP floating point. This is the default. (FIS floating
28751point on the PDP-11/40 is not supported.) Implies -m45.
28752
d77de738 28753@opindex msoft-float
ddf6fe37 28754@item -msoft-float
d77de738
ML
28755Do not use hardware floating point.
28756
d77de738 28757@opindex mac0
ddf6fe37 28758@item -mac0
d77de738
ML
28759Return floating-point results in ac0 (fr0 in Unix assembler syntax).
28760
d77de738 28761@opindex mno-ac0
ddf6fe37 28762@item -mno-ac0
d77de738
ML
28763Return floating-point results in memory. This is the default.
28764
d77de738 28765@opindex m40
ddf6fe37 28766@item -m40
d77de738
ML
28767Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
28768
d77de738 28769@opindex m45
ddf6fe37 28770@item -m45
d77de738
ML
28771Generate code for a PDP-11/45. This is the default.
28772
d77de738 28773@opindex m10
ddf6fe37 28774@item -m10
d77de738
ML
28775Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
28776
d77de738
ML
28777@opindex mint16
28778@opindex mno-int32
ddf6fe37
AA
28779@item -mint16
28780@itemx -mno-int32
d77de738
ML
28781Use 16-bit @code{int}. This is the default.
28782
d77de738
ML
28783@opindex mint32
28784@opindex mno-int16
ddf6fe37
AA
28785@item -mint32
28786@itemx -mno-int16
d77de738
ML
28787Use 32-bit @code{int}.
28788
d77de738 28789@opindex msplit
ddf6fe37 28790@item -msplit
d77de738
ML
28791Target has split instruction and data space. Implies -m45.
28792
d77de738 28793@opindex munix-asm
ddf6fe37 28794@item -munix-asm
d77de738
ML
28795Use Unix assembler syntax.
28796
d77de738 28797@opindex mdec-asm
ddf6fe37 28798@item -mdec-asm
d77de738
ML
28799Use DEC assembler syntax.
28800
d77de738 28801@opindex mgnu-asm
ddf6fe37 28802@item -mgnu-asm
d77de738
ML
28803Use GNU assembler syntax. This is the default.
28804
d77de738 28805@opindex mlra
ddf6fe37 28806@item -mlra
d77de738
ML
28807Use the new LRA register allocator. By default, the old ``reload''
28808allocator is used.
28809@end table
28810
d77de738
ML
28811@node PowerPC Options
28812@subsection PowerPC Options
28813@cindex PowerPC options
28814
28815These are listed under @xref{RS/6000 and PowerPC Options}.
28816
28817@node PRU Options
28818@subsection PRU Options
28819@cindex PRU Options
28820
28821These command-line options are defined for PRU target:
28822
28823@table @gcctabopt
d77de738 28824@opindex minrt
ddf6fe37 28825@item -minrt
d77de738
ML
28826Link with a minimum runtime environment, with no support for static
28827initializers and constructors. Using this option can significantly reduce
28828the size of the final ELF binary. Beware that the compiler could still
28829generate code with static initializers and constructors. It is up to the
28830programmer to ensure that the source program will not use those features.
28831
d77de738 28832@opindex mmcu
ddf6fe37 28833@item -mmcu=@var{mcu}
d77de738
ML
28834Specify the PRU MCU variant to use. Check Newlib for the exact list of
28835supported MCUs.
28836
d77de738 28837@opindex mno-relax
ddf6fe37 28838@item -mno-relax
d77de738
ML
28839Make GCC pass the @option{--no-relax} command-line option to the linker
28840instead of the @option{--relax} option.
28841
d77de738 28842@opindex mloop
ddf6fe37 28843@item -mloop
d77de738
ML
28844Allow (or do not allow) GCC to use the LOOP instruction.
28845
d77de738 28846@opindex mabi
ddf6fe37 28847@item -mabi=@var{variant}
d77de738
ML
28848Specify the ABI variant to output code for. @option{-mabi=ti} selects the
28849unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
28850more naturally with certain GCC assumptions. These are the differences:
28851
28852@table @samp
28853@item Function Pointer Size
28854TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
28855supports only 32-bit data and code pointers.
28856
28857@item Optional Return Value Pointer
28858Function return values larger than 64 bits are passed by using a hidden
28859pointer as the first argument of the function. TI ABI, though, mandates that
28860the pointer can be NULL in case the caller is not using the returned value.
28861GNU always passes and expects a valid return value pointer.
28862
28863@end table
28864
28865The current @option{-mabi=ti} implementation simply raises a compile error
28866when any of the above code constructs is detected. As a consequence
28867the standard C library cannot be built and it is omitted when linking with
28868@option{-mabi=ti}.
28869
28870Relaxation is a GNU feature and for safety reasons is disabled when using
28871@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
28872instructions, so the GNU linker cannot adjust them when shortening adjacent
28873LDI32 pseudo instructions.
28874
28875@end table
28876
28877@node RISC-V Options
28878@subsection RISC-V Options
28879@cindex RISC-V Options
28880
28881These command-line options are defined for RISC-V targets:
28882
28883@table @gcctabopt
d77de738 28884@opindex mbranch-cost
ddf6fe37 28885@item -mbranch-cost=@var{n}
d77de738
ML
28886Set the cost of branches to roughly @var{n} instructions.
28887
ddf6fe37 28888@opindex plt
d77de738
ML
28889@item -mplt
28890@itemx -mno-plt
d77de738
ML
28891When generating PIC code, do or don't allow the use of PLTs. Ignored for
28892non-PIC. The default is @option{-mplt}.
28893
d77de738 28894@opindex mabi
ddf6fe37 28895@item -mabi=@var{ABI-string}
d77de738
ML
28896Specify integer and floating-point calling convention. @var{ABI-string}
28897contains two parts: the size of integer types and the registers used for
28898floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
28899@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2890032-bit), and that floating-point values up to 64 bits wide are passed in F
28901registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
28902allows the compiler to generate code that uses the F and D extensions but only
28903allows floating-point values up to 32 bits long to be passed in registers; or
28904@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
28905passed in registers.
28906
28907The default for this argument is system dependent, users who want a specific
28908calling convention should specify one explicitly. The valid calling
28909conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
28910@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
28911implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
28912invalid because the ABI requires 64-bit values be passed in F registers, but F
28913registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
28914only be used with the @samp{rv32e} architecture. This ABI is not well
28915specified at present, and is subject to change.
28916
ddf6fe37 28917@opindex mfdiv
d77de738
ML
28918@item -mfdiv
28919@itemx -mno-fdiv
d77de738
ML
28920Do or don't use hardware floating-point divide and square root instructions.
28921This requires the F or D extensions for floating-point registers. The default
28922is to use them if the specified architecture has these instructions.
28923
ddf6fe37 28924@opindex mdiv
d77de738
ML
28925@item -mdiv
28926@itemx -mno-div
d77de738
ML
28927Do or don't use hardware instructions for integer division. This requires the
28928M extension. The default is to use them if the specified architecture has
28929these instructions.
28930
d77de738 28931@opindex misa-spec
ddf6fe37 28932@item -misa-spec=@var{ISA-spec-string}
d77de738
ML
28933Specify the version of the RISC-V Unprivileged (formerly User-Level)
28934ISA specification to produce code conforming to. The possibilities
28935for @var{ISA-spec-string} are:
28936@table @code
28937@item 2.2
28938Produce code conforming to version 2.2.
28939@item 20190608
28940Produce code conforming to version 20190608.
28941@item 20191213
28942Produce code conforming to version 20191213.
28943@end table
28944The default is @option{-misa-spec=20191213} unless GCC has been configured
28945with @option{--with-isa-spec=} specifying a different default version.
28946
d77de738 28947@opindex march
ddf6fe37 28948@item -march=@var{ISA-string}
d77de738
ML
28949Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
28950lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
28951@samp{rv32imaf}.
28952
28953When @option{-march=} is not specified, use the setting from @option{-mcpu}.
28954
28955If both @option{-march} and @option{-mcpu=} are not specified, the default for
28956this argument is system dependent, users who want a specific architecture
28957extensions should specify one explicitly.
28958
d77de738 28959@opindex mcpu
ddf6fe37 28960@item -mcpu=@var{processor-string}
d77de738
ML
28961Use architecture of and optimize the output for the given processor, specified
28962by particular CPU name.
28963Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
28964@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
28965@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 28966@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738 28967
d77de738 28968@opindex mtune
ddf6fe37 28969@item -mtune=@var{processor-string}
d77de738
ML
28970Optimize the output for the given processor, specified by microarchitecture or
28971particular CPU name. Permissible values for this option are: @samp{rocket},
28972@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 28973@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
28974
28975When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
28976the default is @samp{rocket} if both are not specified.
28977
28978The @samp{size} choice is not intended for use by end-users. This is used
28979when @option{-Os} is specified. It overrides the instruction cost info
28980provided by @option{-mtune=}, but does not override the pipeline info. This
28981helps reduce code size while still giving good performance.
28982
d77de738 28983@opindex mpreferred-stack-boundary
ddf6fe37 28984@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
28985Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
28986byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
28987the default is 4 (16 bytes or 128-bits).
28988
28989@strong{Warning:} If you use this switch, then you must build all modules with
28990the same value, including any libraries. This includes the system libraries
28991and startup modules.
28992
d77de738 28993@opindex msmall-data-limit
ddf6fe37 28994@item -msmall-data-limit=@var{n}
d77de738
ML
28995Put global and static data smaller than @var{n} bytes into a special section
28996(on some targets).
28997
ddf6fe37 28998@opindex msave-restore
d77de738
ML
28999@item -msave-restore
29000@itemx -mno-save-restore
d77de738
ML
29001Do or don't use smaller but slower prologue and epilogue code that uses
29002library function calls. The default is to use fast inline prologues and
29003epilogues.
29004
ddf6fe37 29005@opindex mshorten-memrefs
d77de738
ML
29006@item -mshorten-memrefs
29007@itemx -mno-shorten-memrefs
d77de738
ML
29008Do or do not attempt to make more use of compressed load/store instructions by
29009replacing a load/store of 'base register + large offset' with a new load/store
29010of 'new base + small offset'. If the new base gets stored in a compressed
29011register, then the new load/store can be compressed. Currently targets 32-bit
29012integer load/stores only.
29013
ddf6fe37 29014@opindex mstrict-align
d77de738
ML
29015@item -mstrict-align
29016@itemx -mno-strict-align
d77de738
ML
29017Do not or do generate unaligned memory accesses. The default is set depending
29018on whether the processor we are optimizing for supports fast unaligned access
29019or not.
29020
d77de738 29021@opindex mcmodel=medlow
ddf6fe37 29022@item -mcmodel=medlow
d77de738
ML
29023Generate code for the medium-low code model. The program and its statically
29024defined symbols must lie within a single 2 GiB address range and must lie
29025between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
29026statically or dynamically linked. This is the default code model.
29027
d77de738 29028@opindex mcmodel=medany
ddf6fe37 29029@item -mcmodel=medany
d77de738
ML
29030Generate code for the medium-any code model. The program and its statically
29031defined symbols must be within any single 2 GiB address range. Programs can be
29032statically or dynamically linked.
29033
29034The code generated by the medium-any code model is position-independent, but is
29035not guaranteed to function correctly when linked into position-independent
29036executables or libraries.
29037
29038@item -mexplicit-relocs
29039@itemx -mno-exlicit-relocs
29040Use or do not use assembler relocation operators when dealing with symbolic
29041addresses. The alternative is to use assembler macros instead, which may
29042limit optimization.
29043
ddf6fe37 29044@opindex mrelax
d77de738
ML
29045@item -mrelax
29046@itemx -mno-relax
d77de738
ML
29047Take advantage of linker relaxations to reduce the number of instructions
29048required to materialize symbol addresses. The default is to take advantage of
29049linker relaxations.
29050
ddf6fe37 29051@opindex mriscv-attribute
d77de738
ML
29052@item -mriscv-attribute
29053@itemx -mno-riscv-attribute
d77de738
ML
29054Emit (do not emit) RISC-V attribute to record extra information into ELF
29055objects. This feature requires at least binutils 2.32.
29056
ddf6fe37 29057@opindex mcsr-check
d77de738
ML
29058@item -mcsr-check
29059@itemx -mno-csr-check
d77de738
ML
29060Enables or disables the CSR checking.
29061
d77de738 29062@opindex malign-data
ddf6fe37 29063@item -malign-data=@var{type}
d77de738
ML
29064Control how GCC aligns variables and constants of array, structure, or union
29065types. Supported values for @var{type} are @samp{xlen} which uses x register
29066width as the alignment value, and @samp{natural} which uses natural alignment.
29067@samp{xlen} is the default.
29068
d77de738 29069@opindex mbig-endian
ddf6fe37 29070@item -mbig-endian
d77de738
ML
29071Generate big-endian code. This is the default when GCC is configured for a
29072@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
29073
d77de738 29074@opindex mlittle-endian
ddf6fe37 29075@item -mlittle-endian
d77de738
ML
29076Generate little-endian code. This is the default when GCC is configured for a
29077@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
29078@samp{riscv32be-*-*} target.
29079
d77de738
ML
29080@opindex mstack-protector-guard
29081@opindex mstack-protector-guard-reg
29082@opindex mstack-protector-guard-offset
ddf6fe37
AA
29083@item -mstack-protector-guard=@var{guard}
29084@itemx -mstack-protector-guard-reg=@var{reg}
29085@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
29086Generate stack protection code using canary at @var{guard}. Supported
29087locations are @samp{global} for a global canary or @samp{tls} for per-thread
29088canary in the TLS block.
29089
29090With the latter choice the options
29091@option{-mstack-protector-guard-reg=@var{reg}} and
29092@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
29093which register to use as base register for reading the canary,
29094and from what offset from that base register. There is no default
29095register or offset as this is entirely for use within the Linux
29096kernel.
29097@end table
29098
29099@node RL78 Options
29100@subsection RL78 Options
29101@cindex RL78 Options
29102
29103@table @gcctabopt
29104
d77de738 29105@opindex msim
ddf6fe37 29106@item -msim
d77de738
ML
29107Links in additional target libraries to support operation within a
29108simulator.
29109
ddf6fe37 29110@opindex mmul
d77de738
ML
29111@item -mmul=none
29112@itemx -mmul=g10
29113@itemx -mmul=g13
29114@itemx -mmul=g14
29115@itemx -mmul=rl78
d77de738
ML
29116Specifies the type of hardware multiplication and division support to
29117be used. The simplest is @code{none}, which uses software for both
29118multiplication and division. This is the default. The @code{g13}
29119value is for the hardware multiply/divide peripheral found on the
29120RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
29121the multiplication and division instructions supported by the RL78/G14
29122(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
29123the value @code{mg10} is an alias for @code{none}.
29124
29125In addition a C preprocessor macro is defined, based upon the setting
29126of this option. Possible values are: @code{__RL78_MUL_NONE__},
29127@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
29128
ddf6fe37 29129@opindex mcpu
d77de738
ML
29130@item -mcpu=g10
29131@itemx -mcpu=g13
29132@itemx -mcpu=g14
29133@itemx -mcpu=rl78
d77de738
ML
29134Specifies the RL78 core to target. The default is the G14 core, also
29135known as an S3 core or just RL78. The G13 or S2 core does not have
29136multiply or divide instructions, instead it uses a hardware peripheral
29137for these operations. The G10 or S1 core does not have register
29138banks, so it uses a different calling convention.
29139
29140If this option is set it also selects the type of hardware multiply
29141support to use, unless this is overridden by an explicit
29142@option{-mmul=none} option on the command line. Thus specifying
29143@option{-mcpu=g13} enables the use of the G13 hardware multiply
29144peripheral and specifying @option{-mcpu=g10} disables the use of
29145hardware multiplications altogether.
29146
29147Note, although the RL78/G14 core is the default target, specifying
29148@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
29149change the behavior of the toolchain since it also enables G14
29150hardware multiply support. If these options are not specified on the
29151command line then software multiplication routines will be used even
29152though the code targets the RL78 core. This is for backwards
29153compatibility with older toolchains which did not have hardware
29154multiply and divide support.
29155
29156In addition a C preprocessor macro is defined, based upon the setting
29157of this option. Possible values are: @code{__RL78_G10__},
29158@code{__RL78_G13__} or @code{__RL78_G14__}.
29159
d77de738
ML
29160@opindex mg10
29161@opindex mg13
29162@opindex mg14
29163@opindex mrl78
ddf6fe37
AA
29164@item -mg10
29165@itemx -mg13
29166@itemx -mg14
29167@itemx -mrl78
d77de738
ML
29168These are aliases for the corresponding @option{-mcpu=} option. They
29169are provided for backwards compatibility.
29170
d77de738 29171@opindex mallregs
ddf6fe37 29172@item -mallregs
d77de738
ML
29173Allow the compiler to use all of the available registers. By default
29174registers @code{r24..r31} are reserved for use in interrupt handlers.
29175With this option enabled these registers can be used in ordinary
29176functions as well.
29177
d77de738
ML
29178@opindex m64bit-doubles
29179@opindex m32bit-doubles
ddf6fe37
AA
29180@item -m64bit-doubles
29181@itemx -m32bit-doubles
d77de738
ML
29182Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29183or 32 bits (@option{-m32bit-doubles}) in size. The default is
29184@option{-m32bit-doubles}.
29185
d77de738
ML
29186@opindex msave-mduc-in-interrupts
29187@opindex mno-save-mduc-in-interrupts
ddf6fe37
AA
29188@item -msave-mduc-in-interrupts
29189@itemx -mno-save-mduc-in-interrupts
d77de738
ML
29190Specifies that interrupt handler functions should preserve the
29191MDUC registers. This is only necessary if normal code might use
29192the MDUC registers, for example because it performs multiplication
29193and division operations. The default is to ignore the MDUC registers
29194as this makes the interrupt handlers faster. The target option -mg13
29195needs to be passed for this to work as this feature is only available
29196on the G13 target (S2 core). The MDUC registers will only be saved
29197if the interrupt handler performs a multiplication or division
29198operation or it calls another function.
29199
29200@end table
29201
29202@node RS/6000 and PowerPC Options
29203@subsection IBM RS/6000 and PowerPC Options
29204@cindex RS/6000 and PowerPC Options
29205@cindex IBM RS/6000 and PowerPC Options
29206
29207These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29208@table @gcctabopt
29209@item -mpowerpc-gpopt
29210@itemx -mno-powerpc-gpopt
29211@itemx -mpowerpc-gfxopt
29212@itemx -mno-powerpc-gfxopt
29213@need 800
29214@itemx -mpowerpc64
29215@itemx -mno-powerpc64
29216@itemx -mmfcrf
29217@itemx -mno-mfcrf
29218@itemx -mpopcntb
29219@itemx -mno-popcntb
29220@itemx -mpopcntd
29221@itemx -mno-popcntd
29222@itemx -mfprnd
29223@itemx -mno-fprnd
29224@need 800
d77de738
ML
29225@opindex mpowerpc-gpopt
29226@opindex mno-powerpc-gpopt
29227@opindex mpowerpc-gfxopt
29228@opindex mno-powerpc-gfxopt
29229@opindex mpowerpc64
29230@opindex mno-powerpc64
29231@opindex mmfcrf
29232@opindex mno-mfcrf
29233@opindex mpopcntb
29234@opindex mno-popcntb
29235@opindex mpopcntd
29236@opindex mno-popcntd
29237@opindex mfprnd
29238@opindex mno-fprnd
29239@opindex mcmpb
29240@opindex mno-cmpb
29241@opindex mhard-dfp
29242@opindex mno-hard-dfp
ddf6fe37
AA
29243@itemx -mcmpb
29244@itemx -mno-cmpb
29245@itemx -mhard-dfp
29246@itemx -mno-hard-dfp
d77de738
ML
29247You use these options to specify which instructions are available on the
29248processor you are using. The default value of these options is
29249determined when configuring GCC@. Specifying the
29250@option{-mcpu=@var{cpu_type}} overrides the specification of these
29251options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29252rather than the options listed above.
29253
29254Specifying @option{-mpowerpc-gpopt} allows
29255GCC to use the optional PowerPC architecture instructions in the
29256General Purpose group, including floating-point square root. Specifying
29257@option{-mpowerpc-gfxopt} allows GCC to
29258use the optional PowerPC architecture instructions in the Graphics
29259group, including floating-point select.
29260
29261The @option{-mmfcrf} option allows GCC to generate the move from
29262condition register field instruction implemented on the POWER4
29263processor and other processors that support the PowerPC V2.01
29264architecture.
29265The @option{-mpopcntb} option allows GCC to generate the popcount and
29266double-precision FP reciprocal estimate instruction implemented on the
29267POWER5 processor and other processors that support the PowerPC V2.02
29268architecture.
29269The @option{-mpopcntd} option allows GCC to generate the popcount
29270instruction implemented on the POWER7 processor and other processors
29271that support the PowerPC V2.06 architecture.
29272The @option{-mfprnd} option allows GCC to generate the FP round to
29273integer instructions implemented on the POWER5+ processor and other
29274processors that support the PowerPC V2.03 architecture.
29275The @option{-mcmpb} option allows GCC to generate the compare bytes
29276instruction implemented on the POWER6 processor and other processors
29277that support the PowerPC V2.05 architecture.
29278The @option{-mhard-dfp} option allows GCC to generate the decimal
29279floating-point instructions implemented on some POWER processors.
29280
29281The @option{-mpowerpc64} option allows GCC to generate the additional
2928264-bit instructions that are found in the full PowerPC64 architecture
29283and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29284@option{-mno-powerpc64}.
29285
d77de738 29286@opindex mcpu
ddf6fe37 29287@item -mcpu=@var{cpu_type}
d77de738
ML
29288Set architecture type, register usage, and
29289instruction scheduling parameters for machine type @var{cpu_type}.
29290Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29291@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29292@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29293@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29294@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29295@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29296@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29297@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29298@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29299@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29300@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29301@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29302
29303@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29304@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29305endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29306architecture machine types, with an appropriate, generic processor
29307model assumed for scheduling purposes.
29308
29309Specifying @samp{native} as cpu type detects and selects the
29310architecture option that corresponds to the host processor of the
29311system performing the compilation.
29312@option{-mcpu=native} has no effect if GCC does not recognize the
29313processor.
29314
29315The other options specify a specific processor. Code generated under
29316those options runs best on that processor, and may not run at all on
29317others.
29318
29319The @option{-mcpu} options automatically enable or disable the
29320following options:
29321
29322@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
29323-mpopcntb -mpopcntd -mpowerpc64 @gol
29324-mpowerpc-gpopt -mpowerpc-gfxopt @gol
29325-mmulhw -mdlmzb -mmfpgpr -mvsx @gol
29326-mcrypto -mhtm -mpower8-fusion -mpower8-vector @gol
29327-mquad-memory -mquad-memory-atomic -mfloat128 @gol
29328-mfloat128-hardware -mprefixed -mpcrel -mmma @gol
29329-mrop-protect}
29330
29331The particular options set for any particular CPU varies between
29332compiler versions, depending on what setting seems to produce optimal
29333code for that CPU; it doesn't necessarily reflect the actual hardware's
29334capabilities. If you wish to set an individual option to a particular
29335value, you may specify it after the @option{-mcpu} option, like
29336@option{-mcpu=970 -mno-altivec}.
29337
29338On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29339not enabled or disabled by the @option{-mcpu} option at present because
29340AIX does not have full support for these options. You may still
29341enable or disable them individually if you're sure it'll work in your
29342environment.
29343
d77de738 29344@opindex mtune
ddf6fe37 29345@item -mtune=@var{cpu_type}
d77de738
ML
29346Set the instruction scheduling parameters for machine type
29347@var{cpu_type}, but do not set the architecture type or register usage,
29348as @option{-mcpu=@var{cpu_type}} does. The same
29349values for @var{cpu_type} are used for @option{-mtune} as for
29350@option{-mcpu}. If both are specified, the code generated uses the
29351architecture and registers set by @option{-mcpu}, but the
29352scheduling parameters set by @option{-mtune}.
29353
d77de738 29354@opindex mcmodel=small
ddf6fe37 29355@item -mcmodel=small
d77de738
ML
29356Generate PowerPC64 code for the small model: The TOC is limited to
2935764k.
29358
d77de738 29359@opindex mcmodel=medium
ddf6fe37 29360@item -mcmodel=medium
d77de738
ML
29361Generate PowerPC64 code for the medium model: The TOC and other static
29362data may be up to a total of 4G in size. This is the default for 64-bit
29363Linux.
29364
d77de738 29365@opindex mcmodel=large
ddf6fe37 29366@item -mcmodel=large
d77de738
ML
29367Generate PowerPC64 code for the large model: The TOC may be up to 4G
29368in size. Other data and code is only limited by the 64-bit address
29369space.
29370
d77de738
ML
29371@opindex maltivec
29372@opindex mno-altivec
ddf6fe37
AA
29373@item -maltivec
29374@itemx -mno-altivec
d77de738
ML
29375Generate code that uses (does not use) AltiVec instructions, and also
29376enable the use of built-in functions that allow more direct access to
29377the AltiVec instruction set. You may also need to set
29378@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29379enhancements.
29380
29381When @option{-maltivec} is used, the element order for AltiVec intrinsics
29382such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29383match array element order corresponding to the endianness of the
29384target. That is, element zero identifies the leftmost element in a
29385vector register when targeting a big-endian platform, and identifies
29386the rightmost element in a vector register when targeting a
29387little-endian platform.
29388
d77de738
ML
29389@opindex mvrsave
29390@opindex mno-vrsave
ddf6fe37
AA
29391@item -mvrsave
29392@itemx -mno-vrsave
d77de738
ML
29393Generate VRSAVE instructions when generating AltiVec code.
29394
d77de738 29395@opindex msecure-plt
ddf6fe37 29396@item -msecure-plt
d77de738
ML
29397Generate code that allows @command{ld} and @command{ld.so}
29398to build executables and shared
29399libraries with non-executable @code{.plt} and @code{.got} sections.
29400This is a PowerPC
2940132-bit SYSV ABI option.
29402
d77de738 29403@opindex mbss-plt
ddf6fe37 29404@item -mbss-plt
d77de738
ML
29405Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29406fills in, and
29407requires @code{.plt} and @code{.got}
29408sections that are both writable and executable.
29409This is a PowerPC 32-bit SYSV ABI option.
29410
d77de738
ML
29411@opindex misel
29412@opindex mno-isel
ddf6fe37
AA
29413@item -misel
29414@itemx -mno-isel
d77de738
ML
29415This switch enables or disables the generation of ISEL instructions.
29416
d77de738
ML
29417@opindex mvsx
29418@opindex mno-vsx
ddf6fe37
AA
29419@item -mvsx
29420@itemx -mno-vsx
d77de738
ML
29421Generate code that uses (does not use) vector/scalar (VSX)
29422instructions, and also enable the use of built-in functions that allow
29423more direct access to the VSX instruction set.
29424
d77de738
ML
29425@opindex mcrypto
29426@opindex mno-crypto
ddf6fe37
AA
29427@item -mcrypto
29428@itemx -mno-crypto
d77de738
ML
29429Enable the use (disable) of the built-in functions that allow direct
29430access to the cryptographic instructions that were added in version
294312.07 of the PowerPC ISA.
29432
d77de738
ML
29433@opindex mhtm
29434@opindex mno-htm
ddf6fe37
AA
29435@item -mhtm
29436@itemx -mno-htm
d77de738
ML
29437Enable (disable) the use of the built-in functions that allow direct
29438access to the Hardware Transactional Memory (HTM) instructions that
29439were added in version 2.07 of the PowerPC ISA.
29440
d77de738
ML
29441@opindex mpower8-fusion
29442@opindex mno-power8-fusion
ddf6fe37
AA
29443@item -mpower8-fusion
29444@itemx -mno-power8-fusion
d77de738
ML
29445Generate code that keeps (does not keeps) some integer operations
29446adjacent so that the instructions can be fused together on power8 and
29447later processors.
29448
d77de738
ML
29449@opindex mpower8-vector
29450@opindex mno-power8-vector
ddf6fe37
AA
29451@item -mpower8-vector
29452@itemx -mno-power8-vector
d77de738
ML
29453Generate code that uses (does not use) the vector and scalar
29454instructions that were added in version 2.07 of the PowerPC ISA. Also
29455enable the use of built-in functions that allow more direct access to
29456the vector instructions.
29457
d77de738
ML
29458@opindex mquad-memory
29459@opindex mno-quad-memory
ddf6fe37
AA
29460@item -mquad-memory
29461@itemx -mno-quad-memory
d77de738
ML
29462Generate code that uses (does not use) the non-atomic quad word memory
29463instructions. The @option{-mquad-memory} option requires use of
2946464-bit mode.
29465
d77de738
ML
29466@opindex mquad-memory-atomic
29467@opindex mno-quad-memory-atomic
ddf6fe37
AA
29468@item -mquad-memory-atomic
29469@itemx -mno-quad-memory-atomic
d77de738
ML
29470Generate code that uses (does not use) the atomic quad word memory
29471instructions. The @option{-mquad-memory-atomic} option requires use of
2947264-bit mode.
29473
d77de738
ML
29474@opindex mfloat128
29475@opindex mno-float128
ddf6fe37
AA
29476@item -mfloat128
29477@itemx -mno-float128
d77de738
ML
29478Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29479and use either software emulation for IEEE 128-bit floating point or
29480hardware instructions.
29481
29482The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29483128-bit floating point support. The IEEE 128-bit floating point is only
29484supported on Linux.
29485
29486The default for @option{-mfloat128} is enabled on PowerPC Linux
29487systems using the VSX instruction set, and disabled on other systems.
29488
29489If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29490@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29491point support will also enable the generation of ISA 3.0 IEEE 128-bit
29492floating point instructions. Otherwise, if you do not specify to
29493generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29494system, IEEE 128-bit floating point will be done with software
29495emulation.
29496
d77de738
ML
29497@opindex mfloat128-hardware
29498@opindex mno-float128-hardware
ddf6fe37
AA
29499@item -mfloat128-hardware
29500@itemx -mno-float128-hardware
d77de738
ML
29501Enable/disable using ISA 3.0 hardware instructions to support the
29502@var{__float128} data type.
29503
29504The default for @option{-mfloat128-hardware} is enabled on PowerPC
29505Linux systems using the ISA 3.0 instruction set, and disabled on other
29506systems.
29507
d77de738
ML
29508@opindex m32
29509@opindex m64
ddf6fe37
AA
29510@item -m32
29511@itemx -m64
d77de738
ML
29512Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29513targets (including GNU/Linux). The 32-bit environment sets int, long
29514and pointer to 32 bits and generates code that runs on any PowerPC
29515variant. The 64-bit environment sets int to 32 bits and long and
29516pointer to 64 bits, and generates code for PowerPC64, as for
29517@option{-mpowerpc64}.
29518
d77de738
ML
29519@opindex mfull-toc
29520@opindex mno-fp-in-toc
29521@opindex mno-sum-in-toc
29522@opindex mminimal-toc
ddf6fe37
AA
29523@item -mfull-toc
29524@itemx -mno-fp-in-toc
29525@itemx -mno-sum-in-toc
29526@itemx -mminimal-toc
d77de738
ML
29527Modify generation of the TOC (Table Of Contents), which is created for
29528every executable file. The @option{-mfull-toc} option is selected by
29529default. In that case, GCC allocates at least one TOC entry for
29530each unique non-automatic variable reference in your program. GCC
29531also places floating-point constants in the TOC@. However, only
2953216,384 entries are available in the TOC@.
29533
29534If you receive a linker error message that saying you have overflowed
29535the available TOC space, you can reduce the amount of TOC space used
29536with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
29537@option{-mno-fp-in-toc} prevents GCC from putting floating-point
29538constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
29539generate code to calculate the sum of an address and a constant at
29540run time instead of putting that sum into the TOC@. You may specify one
29541or both of these options. Each causes GCC to produce very slightly
29542slower and larger code at the expense of conserving TOC space.
29543
29544If you still run out of space in the TOC even when you specify both of
29545these options, specify @option{-mminimal-toc} instead. This option causes
29546GCC to make only one TOC entry for every file. When you specify this
29547option, GCC produces code that is slower and larger but which
29548uses extremely little TOC space. You may wish to use this option
29549only on files that contain less frequently-executed code.
29550
d77de738
ML
29551@opindex maix64
29552@opindex maix32
ddf6fe37
AA
29553@item -maix64
29554@itemx -maix32
d77de738
ML
29555Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
29556@code{long} type, and the infrastructure needed to support them.
29557Specifying @option{-maix64} implies @option{-mpowerpc64},
29558while @option{-maix32} disables the 64-bit ABI and
29559implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
29560
d77de738
ML
29561@opindex mxl-compat
29562@opindex mno-xl-compat
ddf6fe37
AA
29563@item -mxl-compat
29564@itemx -mno-xl-compat
d77de738
ML
29565Produce code that conforms more closely to IBM XL compiler semantics
29566when using AIX-compatible ABI@. Pass floating-point arguments to
29567prototyped functions beyond the register save area (RSA) on the stack
29568in addition to argument FPRs. Do not assume that most significant
29569double in 128-bit long double value is properly rounded when comparing
29570values and converting to double. Use XL symbol names for long double
29571support routines.
29572
29573The AIX calling convention was extended but not initially documented to
29574handle an obscure K&R C case of calling a function that takes the
29575address of its arguments with fewer arguments than declared. IBM XL
29576compilers access floating-point arguments that do not fit in the
29577RSA from the stack when a subroutine is compiled without
29578optimization. Because always storing floating-point arguments on the
29579stack is inefficient and rarely needed, this option is not enabled by
29580default and only is necessary when calling subroutines compiled by IBM
29581XL compilers without optimization.
29582
d77de738 29583@opindex mpe
ddf6fe37 29584@item -mpe
d77de738
ML
29585Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
29586application written to use message passing with special startup code to
29587enable the application to run. The system must have PE installed in the
29588standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
29589must be overridden with the @option{-specs=} option to specify the
29590appropriate directory location. The Parallel Environment does not
29591support threads, so the @option{-mpe} option and the @option{-pthread}
29592option are incompatible.
29593
d77de738
ML
29594@opindex malign-natural
29595@opindex malign-power
ddf6fe37
AA
29596@item -malign-natural
29597@itemx -malign-power
d77de738
ML
29598On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
29599@option{-malign-natural} overrides the ABI-defined alignment of larger
29600types, such as floating-point doubles, on their natural size-based boundary.
29601The option @option{-malign-power} instructs GCC to follow the ABI-specified
29602alignment rules. GCC defaults to the standard alignment defined in the ABI@.
29603
29604On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
29605is not supported.
29606
d77de738
ML
29607@opindex msoft-float
29608@opindex mhard-float
ddf6fe37
AA
29609@item -msoft-float
29610@itemx -mhard-float
d77de738
ML
29611Generate code that does not use (uses) the floating-point register set.
29612Software floating-point emulation is provided if you use the
29613@option{-msoft-float} option, and pass the option to GCC when linking.
29614
d77de738
ML
29615@opindex mmultiple
29616@opindex mno-multiple
ddf6fe37
AA
29617@item -mmultiple
29618@itemx -mno-multiple
d77de738
ML
29619Generate code that uses (does not use) the load multiple word
29620instructions and the store multiple word instructions. These
29621instructions are generated by default on POWER systems, and not
29622generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
29623PowerPC systems, since those instructions do not work when the
29624processor is in little-endian mode. The exceptions are PPC740 and
29625PPC750 which permit these instructions in little-endian mode.
29626
d77de738
ML
29627@opindex mupdate
29628@opindex mno-update
ddf6fe37
AA
29629@item -mupdate
29630@itemx -mno-update
d77de738
ML
29631Generate code that uses (does not use) the load or store instructions
29632that update the base register to the address of the calculated memory
29633location. These instructions are generated by default. If you use
29634@option{-mno-update}, there is a small window between the time that the
29635stack pointer is updated and the address of the previous frame is
29636stored, which means code that walks the stack frame across interrupts or
29637signals may get corrupted data.
29638
d77de738
ML
29639@opindex mavoid-indexed-addresses
29640@opindex mno-avoid-indexed-addresses
ddf6fe37
AA
29641@item -mavoid-indexed-addresses
29642@itemx -mno-avoid-indexed-addresses
d77de738
ML
29643Generate code that tries to avoid (not avoid) the use of indexed load
29644or store instructions. These instructions can incur a performance
29645penalty on Power6 processors in certain situations, such as when
29646stepping through large arrays that cross a 16M boundary. This option
29647is enabled by default when targeting Power6 and disabled otherwise.
29648
d77de738
ML
29649@opindex mfused-madd
29650@opindex mno-fused-madd
ddf6fe37
AA
29651@item -mfused-madd
29652@itemx -mno-fused-madd
d77de738
ML
29653Generate code that uses (does not use) the floating-point multiply and
29654accumulate instructions. These instructions are generated by default
29655if hardware floating point is used. The machine-dependent
29656@option{-mfused-madd} option is now mapped to the machine-independent
29657@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29658mapped to @option{-ffp-contract=off}.
29659
d77de738
ML
29660@opindex mmulhw
29661@opindex mno-mulhw
ddf6fe37
AA
29662@item -mmulhw
29663@itemx -mno-mulhw
d77de738
ML
29664Generate code that uses (does not use) the half-word multiply and
29665multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
29666These instructions are generated by default when targeting those
29667processors.
29668
d77de738
ML
29669@opindex mdlmzb
29670@opindex mno-dlmzb
ddf6fe37
AA
29671@item -mdlmzb
29672@itemx -mno-dlmzb
d77de738
ML
29673Generate code that uses (does not use) the string-search @samp{dlmzb}
29674instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
29675generated by default when targeting those processors.
29676
d77de738
ML
29677@opindex mno-bit-align
29678@opindex mbit-align
ddf6fe37
AA
29679@item -mno-bit-align
29680@itemx -mbit-align
d77de738
ML
29681On System V.4 and embedded PowerPC systems do not (do) force structures
29682and unions that contain bit-fields to be aligned to the base type of the
29683bit-field.
29684
29685For example, by default a structure containing nothing but 8
29686@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
29687boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
29688the structure is aligned to a 1-byte boundary and is 1 byte in
29689size.
29690
d77de738
ML
29691@opindex mno-strict-align
29692@opindex mstrict-align
ddf6fe37
AA
29693@item -mno-strict-align
29694@itemx -mstrict-align
d77de738
ML
29695On System V.4 and embedded PowerPC systems do not (do) assume that
29696unaligned memory references are handled by the system.
29697
d77de738
ML
29698@opindex mrelocatable
29699@opindex mno-relocatable
ddf6fe37
AA
29700@item -mrelocatable
29701@itemx -mno-relocatable
d77de738
ML
29702Generate code that allows (does not allow) a static executable to be
29703relocated to a different address at run time. A simple embedded
29704PowerPC system loader should relocate the entire contents of
29705@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
29706a table of 32-bit addresses generated by this option. For this to
29707work, all objects linked together must be compiled with
29708@option{-mrelocatable} or @option{-mrelocatable-lib}.
29709@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
29710
d77de738
ML
29711@opindex mrelocatable-lib
29712@opindex mno-relocatable-lib
ddf6fe37
AA
29713@item -mrelocatable-lib
29714@itemx -mno-relocatable-lib
d77de738
ML
29715Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
29716@code{.fixup} section to allow static executables to be relocated at
29717run time, but @option{-mrelocatable-lib} does not use the smaller stack
29718alignment of @option{-mrelocatable}. Objects compiled with
29719@option{-mrelocatable-lib} may be linked with objects compiled with
29720any combination of the @option{-mrelocatable} options.
29721
d77de738
ML
29722@opindex mno-toc
29723@opindex mtoc
ddf6fe37
AA
29724@item -mno-toc
29725@itemx -mtoc
d77de738
ML
29726On System V.4 and embedded PowerPC systems do not (do) assume that
29727register 2 contains a pointer to a global area pointing to the addresses
29728used in the program.
29729
d77de738
ML
29730@opindex mlittle
29731@opindex mlittle-endian
ddf6fe37
AA
29732@item -mlittle
29733@itemx -mlittle-endian
d77de738
ML
29734On System V.4 and embedded PowerPC systems compile code for the
29735processor in little-endian mode. The @option{-mlittle-endian} option is
29736the same as @option{-mlittle}.
29737
d77de738
ML
29738@opindex mbig
29739@opindex mbig-endian
ddf6fe37
AA
29740@item -mbig
29741@itemx -mbig-endian
d77de738
ML
29742On System V.4 and embedded PowerPC systems compile code for the
29743processor in big-endian mode. The @option{-mbig-endian} option is
29744the same as @option{-mbig}.
29745
d77de738 29746@opindex mdynamic-no-pic
ddf6fe37 29747@item -mdynamic-no-pic
d77de738
ML
29748On Darwin and Mac OS X systems, compile code so that it is not
29749relocatable, but that its external references are relocatable. The
29750resulting code is suitable for applications, but not shared
29751libraries.
29752
d77de738 29753@opindex msingle-pic-base
ddf6fe37 29754@item -msingle-pic-base
d77de738
ML
29755Treat the register used for PIC addressing as read-only, rather than
29756loading it in the prologue for each function. The runtime system is
29757responsible for initializing this register with an appropriate value
29758before execution begins.
29759
d77de738 29760@opindex mprioritize-restricted-insns
ddf6fe37 29761@item -mprioritize-restricted-insns=@var{priority}
d77de738
ML
29762This option controls the priority that is assigned to
29763dispatch-slot restricted instructions during the second scheduling
29764pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
29765or @samp{2} to assign no, highest, or second-highest (respectively)
29766priority to dispatch-slot restricted
29767instructions.
29768
d77de738 29769@opindex msched-costly-dep
ddf6fe37 29770@item -msched-costly-dep=@var{dependence_type}
d77de738
ML
29771This option controls which dependences are considered costly
29772by the target during instruction scheduling. The argument
29773@var{dependence_type} takes one of the following values:
29774
29775@table @asis
29776@item @samp{no}
29777No dependence is costly.
29778
29779@item @samp{all}
29780All dependences are costly.
29781
29782@item @samp{true_store_to_load}
29783A true dependence from store to load is costly.
29784
29785@item @samp{store_to_load}
29786Any dependence from store to load is costly.
29787
29788@item @var{number}
29789Any dependence for which the latency is greater than or equal to
29790@var{number} is costly.
29791@end table
29792
d77de738 29793@opindex minsert-sched-nops
ddf6fe37 29794@item -minsert-sched-nops=@var{scheme}
d77de738
ML
29795This option controls which NOP insertion scheme is used during
29796the second scheduling pass. The argument @var{scheme} takes one of the
29797following values:
29798
29799@table @asis
29800@item @samp{no}
29801Don't insert NOPs.
29802
29803@item @samp{pad}
29804Pad with NOPs any dispatch group that has vacant issue slots,
29805according to the scheduler's grouping.
29806
29807@item @samp{regroup_exact}
29808Insert NOPs to force costly dependent insns into
29809separate groups. Insert exactly as many NOPs as needed to force an insn
29810to a new group, according to the estimated processor grouping.
29811
29812@item @var{number}
29813Insert NOPs to force costly dependent insns into
29814separate groups. Insert @var{number} NOPs to force an insn to a new group.
29815@end table
29816
d77de738 29817@opindex mcall-sysv
ddf6fe37 29818@item -mcall-sysv
d77de738
ML
29819On System V.4 and embedded PowerPC systems compile code using calling
29820conventions that adhere to the March 1995 draft of the System V
29821Application Binary Interface, PowerPC processor supplement. This is the
29822default unless you configured GCC using @samp{powerpc-*-eabiaix}.
29823
d77de738
ML
29824@opindex mcall-sysv-eabi
29825@opindex mcall-eabi
ddf6fe37
AA
29826@item -mcall-sysv-eabi
29827@itemx -mcall-eabi
d77de738
ML
29828Specify both @option{-mcall-sysv} and @option{-meabi} options.
29829
d77de738 29830@opindex mcall-sysv-noeabi
ddf6fe37 29831@item -mcall-sysv-noeabi
d77de738
ML
29832Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
29833
d7971cf7 29834@opindex mcall-aixdesc
ddf6fe37 29835@item -mcall-aixdesc
d77de738
ML
29836On System V.4 and embedded PowerPC systems compile code for the AIX
29837operating system.
29838
d77de738 29839@opindex mcall-linux
ddf6fe37 29840@item -mcall-linux
d77de738
ML
29841On System V.4 and embedded PowerPC systems compile code for the
29842Linux-based GNU system.
29843
d77de738 29844@opindex mcall-freebsd
ddf6fe37 29845@item -mcall-freebsd
d77de738
ML
29846On System V.4 and embedded PowerPC systems compile code for the
29847FreeBSD operating system.
29848
d77de738 29849@opindex mcall-netbsd
ddf6fe37 29850@item -mcall-netbsd
d77de738
ML
29851On System V.4 and embedded PowerPC systems compile code for the
29852NetBSD operating system.
29853
d7971cf7 29854@opindex mcall-openbsd
ddf6fe37 29855@item -mcall-openbsd
d77de738
ML
29856On System V.4 and embedded PowerPC systems compile code for the
29857OpenBSD operating system.
29858
d77de738 29859@opindex mtraceback
ddf6fe37 29860@item -mtraceback=@var{traceback_type}
d77de738
ML
29861Select the type of traceback table. Valid values for @var{traceback_type}
29862are @samp{full}, @samp{part}, and @samp{no}.
29863
d77de738 29864@opindex maix-struct-return
ddf6fe37 29865@item -maix-struct-return
d77de738
ML
29866Return all structures in memory (as specified by the AIX ABI)@.
29867
d77de738 29868@opindex msvr4-struct-return
ddf6fe37 29869@item -msvr4-struct-return
d77de738
ML
29870Return structures smaller than 8 bytes in registers (as specified by the
29871SVR4 ABI)@.
29872
d77de738 29873@opindex mabi
ddf6fe37 29874@item -mabi=@var{abi-type}
d77de738
ML
29875Extend the current ABI with a particular extension, or remove such extension.
29876Valid values are: @samp{altivec}, @samp{no-altivec},
29877@samp{ibmlongdouble}, @samp{ieeelongdouble},
29878@samp{elfv1}, @samp{elfv2},
29879and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
29880
d77de738 29881@opindex mabi=ibmlongdouble
ddf6fe37 29882@item -mabi=ibmlongdouble
d77de738
ML
29883Change the current ABI to use IBM extended-precision long double.
29884This is not likely to work if your system defaults to using IEEE
29885extended-precision long double. If you change the long double type
29886from IEEE extended-precision, the compiler will issue a warning unless
29887you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29888to be enabled.
29889
d77de738 29890@opindex mabi=ieeelongdouble
ddf6fe37 29891@item -mabi=ieeelongdouble
d77de738
ML
29892Change the current ABI to use IEEE extended-precision long double.
29893This is not likely to work if your system defaults to using IBM
29894extended-precision long double. If you change the long double type
29895from IBM extended-precision, the compiler will issue a warning unless
29896you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29897to be enabled.
29898
d77de738 29899@opindex mabi=elfv1
ddf6fe37 29900@item -mabi=elfv1
d77de738
ML
29901Change the current ABI to use the ELFv1 ABI.
29902This is the default ABI for big-endian PowerPC 64-bit Linux.
29903Overriding the default ABI requires special system support and is
29904likely to fail in spectacular ways.
29905
d77de738 29906@opindex mabi=elfv2
ddf6fe37 29907@item -mabi=elfv2
d77de738
ML
29908Change the current ABI to use the ELFv2 ABI.
29909This is the default ABI for little-endian PowerPC 64-bit Linux.
29910Overriding the default ABI requires special system support and is
29911likely to fail in spectacular ways.
29912
d77de738
ML
29913@opindex mgnu-attribute
29914@opindex mno-gnu-attribute
ddf6fe37
AA
29915@item -mgnu-attribute
29916@itemx -mno-gnu-attribute
d77de738
ML
29917Emit .gnu_attribute assembly directives to set tag/value pairs in a
29918.gnu.attributes section that specify ABI variations in function
29919parameters or return values.
29920
d77de738
ML
29921@opindex mprototype
29922@opindex mno-prototype
ddf6fe37
AA
29923@item -mprototype
29924@itemx -mno-prototype
d77de738
ML
29925On System V.4 and embedded PowerPC systems assume that all calls to
29926variable argument functions are properly prototyped. Otherwise, the
29927compiler must insert an instruction before every non-prototyped call to
29928set or clear bit 6 of the condition code register (@code{CR}) to
29929indicate whether floating-point values are passed in the floating-point
29930registers in case the function takes variable arguments. With
29931@option{-mprototype}, only calls to prototyped variable argument functions
29932set or clear the bit.
29933
d77de738 29934@opindex msim
ddf6fe37 29935@item -msim
d77de738
ML
29936On embedded PowerPC systems, assume that the startup module is called
29937@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
29938@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
29939configurations.
29940
d77de738 29941@opindex mmvme
ddf6fe37 29942@item -mmvme
d77de738
ML
29943On embedded PowerPC systems, assume that the startup module is called
29944@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
29945@file{libc.a}.
29946
d77de738 29947@opindex mads
ddf6fe37 29948@item -mads
d77de738
ML
29949On embedded PowerPC systems, assume that the startup module is called
29950@file{crt0.o} and the standard C libraries are @file{libads.a} and
29951@file{libc.a}.
29952
d77de738 29953@opindex myellowknife
ddf6fe37 29954@item -myellowknife
d77de738
ML
29955On embedded PowerPC systems, assume that the startup module is called
29956@file{crt0.o} and the standard C libraries are @file{libyk.a} and
29957@file{libc.a}.
29958
d77de738 29959@opindex mvxworks
ddf6fe37 29960@item -mvxworks
d77de738
ML
29961On System V.4 and embedded PowerPC systems, specify that you are
29962compiling for a VxWorks system.
29963
d77de738 29964@opindex memb
ddf6fe37 29965@item -memb
d77de738
ML
29966On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
29967header to indicate that @samp{eabi} extended relocations are used.
29968
d77de738
ML
29969@opindex meabi
29970@opindex mno-eabi
ddf6fe37
AA
29971@item -meabi
29972@itemx -mno-eabi
d77de738
ML
29973On System V.4 and embedded PowerPC systems do (do not) adhere to the
29974Embedded Applications Binary Interface (EABI), which is a set of
29975modifications to the System V.4 specifications. Selecting @option{-meabi}
29976means that the stack is aligned to an 8-byte boundary, a function
29977@code{__eabi} is called from @code{main} to set up the EABI
29978environment, and the @option{-msdata} option can use both @code{r2} and
29979@code{r13} to point to two separate small data areas. Selecting
29980@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
29981no EABI initialization function is called from @code{main}, and the
29982@option{-msdata} option only uses @code{r13} to point to a single
29983small data area. The @option{-meabi} option is on by default if you
29984configured GCC using one of the @samp{powerpc*-*-eabi*} options.
29985
d77de738 29986@opindex msdata=eabi
ddf6fe37 29987@item -msdata=eabi
d77de738
ML
29988On System V.4 and embedded PowerPC systems, put small initialized
29989@code{const} global and static data in the @code{.sdata2} section, which
29990is pointed to by register @code{r2}. Put small initialized
29991non-@code{const} global and static data in the @code{.sdata} section,
29992which is pointed to by register @code{r13}. Put small uninitialized
29993global and static data in the @code{.sbss} section, which is adjacent to
29994the @code{.sdata} section. The @option{-msdata=eabi} option is
29995incompatible with the @option{-mrelocatable} option. The
29996@option{-msdata=eabi} option also sets the @option{-memb} option.
29997
d77de738 29998@opindex msdata=sysv
ddf6fe37 29999@item -msdata=sysv
d77de738
ML
30000On System V.4 and embedded PowerPC systems, put small global and static
30001data in the @code{.sdata} section, which is pointed to by register
30002@code{r13}. Put small uninitialized global and static data in the
30003@code{.sbss} section, which is adjacent to the @code{.sdata} section.
30004The @option{-msdata=sysv} option is incompatible with the
30005@option{-mrelocatable} option.
30006
d77de738
ML
30007@opindex msdata=default
30008@opindex msdata
ddf6fe37
AA
30009@item -msdata=default
30010@itemx -msdata
d77de738
ML
30011On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
30012compile code the same as @option{-msdata=eabi}, otherwise compile code the
30013same as @option{-msdata=sysv}.
30014
d77de738 30015@opindex msdata=data
ddf6fe37 30016@item -msdata=data
d77de738
ML
30017On System V.4 and embedded PowerPC systems, put small global
30018data in the @code{.sdata} section. Put small uninitialized global
30019data in the @code{.sbss} section. Do not use register @code{r13}
30020to address small data however. This is the default behavior unless
30021other @option{-msdata} options are used.
30022
d77de738
ML
30023@opindex msdata=none
30024@opindex mno-sdata
ddf6fe37
AA
30025@item -msdata=none
30026@itemx -mno-sdata
d77de738
ML
30027On embedded PowerPC systems, put all initialized global and static data
30028in the @code{.data} section, and all uninitialized data in the
30029@code{.bss} section.
30030
d77de738
ML
30031@opindex mreadonly-in-sdata
30032@opindex mno-readonly-in-sdata
ddf6fe37 30033@item -mreadonly-in-sdata
d77de738
ML
30034Put read-only objects in the @code{.sdata} section as well. This is the
30035default.
30036
d77de738 30037@opindex mblock-move-inline-limit
ddf6fe37 30038@item -mblock-move-inline-limit=@var{num}
d77de738
ML
30039Inline all block moves (such as calls to @code{memcpy} or structure
30040copies) less than or equal to @var{num} bytes. The minimum value for
30041@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
30042targets. The default value is target-specific.
30043
d77de738 30044@opindex mblock-compare-inline-limit
ddf6fe37 30045@item -mblock-compare-inline-limit=@var{num}
d77de738
ML
30046Generate non-looping inline code for all block compares (such as calls
30047to @code{memcmp} or structure compares) less than or equal to @var{num}
30048bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
30049block compare is disabled. The default value is target-specific.
30050
d77de738 30051@opindex mblock-compare-inline-loop-limit
ddf6fe37 30052@item -mblock-compare-inline-loop-limit=@var{num}
d77de738
ML
30053Generate an inline expansion using loop code for all block compares that
30054are less than or equal to @var{num} bytes, but greater than the limit
30055for non-loop inline block compare expansion. If the block length is not
30056constant, at most @var{num} bytes will be compared before @code{memcmp}
30057is called to compare the remainder of the block. The default value is
30058target-specific.
30059
d77de738 30060@opindex mstring-compare-inline-limit
ddf6fe37 30061@item -mstring-compare-inline-limit=@var{num}
d77de738
ML
30062Compare at most @var{num} string bytes with inline code.
30063If the difference or end of string is not found at the
30064end of the inline compare a call to @code{strcmp} or @code{strncmp} will
30065take care of the rest of the comparison. The default is 64 bytes.
30066
d77de738
ML
30067@opindex G
30068@cindex smaller data references (PowerPC)
30069@cindex .sdata/.sdata2 references (PowerPC)
f33d7a88 30070@item -G @var{num}
d77de738
ML
30071On embedded PowerPC systems, put global and static items less than or
30072equal to @var{num} bytes into the small data or BSS sections instead of
30073the normal data or BSS section. By default, @var{num} is 8. The
30074@option{-G @var{num}} switch is also passed to the linker.
30075All modules should be compiled with the same @option{-G @var{num}} value.
30076
d77de738
ML
30077@opindex mregnames
30078@opindex mno-regnames
ddf6fe37
AA
30079@item -mregnames
30080@itemx -mno-regnames
d77de738
ML
30081On System V.4 and embedded PowerPC systems do (do not) emit register
30082names in the assembly language output using symbolic forms.
30083
d77de738
ML
30084@opindex mlongcall
30085@opindex mno-longcall
ddf6fe37
AA
30086@item -mlongcall
30087@itemx -mno-longcall
d77de738
ML
30088By default assume that all calls are far away so that a longer and more
30089expensive calling sequence is required. This is required for calls
30090farther than 32 megabytes (33,554,432 bytes) from the current location.
30091A short call is generated if the compiler knows
30092the call cannot be that far away. This setting can be overridden by
30093the @code{shortcall} function attribute, or by @code{#pragma
30094longcall(0)}.
30095
30096Some linkers are capable of detecting out-of-range calls and generating
30097glue code on the fly. On these systems, long calls are unnecessary and
30098generate slower code. As of this writing, the AIX linker can do this,
30099as can the GNU linker for PowerPC/64. It is planned to add this feature
30100to the GNU linker for 32-bit PowerPC systems as well.
30101
30102On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
30103GCC can generate long calls using an inline PLT call sequence (see
30104@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
30105ELFv1 (big-endian) do not support inline PLT calls.
30106
30107On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
30108callee, L42}, plus a @dfn{branch island} (glue code). The two target
30109addresses represent the callee and the branch island. The
30110Darwin/PPC linker prefers the first address and generates a @code{bl
30111callee} if the PPC @code{bl} instruction reaches the callee directly;
30112otherwise, the linker generates @code{bl L42} to call the branch
30113island. The branch island is appended to the body of the
30114calling function; it computes the full 32-bit address of the callee
30115and jumps to it.
30116
30117On Mach-O (Darwin) systems, this option directs the compiler emit to
30118the glue for every direct call, and the Darwin linker decides whether
30119to use or discard it.
30120
30121In the future, GCC may ignore all longcall specifications
30122when the linker is known to generate glue.
30123
d77de738
ML
30124@opindex mpltseq
30125@opindex mno-pltseq
ddf6fe37
AA
30126@item -mpltseq
30127@itemx -mno-pltseq
d77de738
ML
30128Implement (do not implement) -fno-plt and long calls using an inline
30129PLT call sequence that supports lazy linking and long calls to
30130functions in dlopen'd shared libraries. Inline PLT calls are only
30131supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
30132linkers, and are enabled by default if the support is detected when
30133configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
30134configured with @option{--enable-secureplt}. @option{-mpltseq} code
30135and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
30136linked together.
30137
d77de738
ML
30138@opindex mtls-markers
30139@opindex mno-tls-markers
ddf6fe37
AA
30140@item -mtls-markers
30141@itemx -mno-tls-markers
d77de738
ML
30142Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
30143specifying the function argument. The relocation allows the linker to
30144reliably associate function call with argument setup instructions for
30145TLS optimization, which in turn allows GCC to better schedule the
30146sequence.
30147
ddf6fe37 30148@opindex mrecip
d77de738
ML
30149@item -mrecip
30150@itemx -mno-recip
d77de738
ML
30151This option enables use of the reciprocal estimate and
30152reciprocal square root estimate instructions with additional
30153Newton-Raphson steps to increase precision instead of doing a divide or
30154square root and divide for floating-point arguments. You should use
30155the @option{-ffast-math} option when using @option{-mrecip} (or at
30156least @option{-funsafe-math-optimizations},
30157@option{-ffinite-math-only}, @option{-freciprocal-math} and
30158@option{-fno-trapping-math}). Note that while the throughput of the
30159sequence is generally higher than the throughput of the non-reciprocal
30160instruction, the precision of the sequence can be decreased by up to 2
30161ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30162roots.
30163
d77de738 30164@opindex mrecip=opt
ddf6fe37 30165@item -mrecip=@var{opt}
d77de738
ML
30166This option controls which reciprocal estimate instructions
30167may be used. @var{opt} is a comma-separated list of options, which may
30168be preceded by a @code{!} to invert the option:
30169
30170@table @samp
30171
30172@item all
30173Enable all estimate instructions.
30174
30175@item default
30176Enable the default instructions, equivalent to @option{-mrecip}.
30177
30178@item none
30179Disable all estimate instructions, equivalent to @option{-mno-recip}.
30180
30181@item div
30182Enable the reciprocal approximation instructions for both
30183single and double precision.
30184
30185@item divf
30186Enable the single-precision reciprocal approximation instructions.
30187
30188@item divd
30189Enable the double-precision reciprocal approximation instructions.
30190
30191@item rsqrt
30192Enable the reciprocal square root approximation instructions for both
30193single and double precision.
30194
30195@item rsqrtf
30196Enable the single-precision reciprocal square root approximation instructions.
30197
30198@item rsqrtd
30199Enable the double-precision reciprocal square root approximation instructions.
30200
30201@end table
30202
30203So, for example, @option{-mrecip=all,!rsqrtd} enables
30204all of the reciprocal estimate instructions, except for the
30205@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30206which handle the double-precision reciprocal square root calculations.
30207
ddf6fe37 30208@opindex mrecip-precision
d77de738
ML
30209@item -mrecip-precision
30210@itemx -mno-recip-precision
d77de738
ML
30211Assume (do not assume) that the reciprocal estimate instructions
30212provide higher-precision estimates than is mandated by the PowerPC
30213ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30214@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30215The double-precision square root estimate instructions are not generated by
30216default on low-precision machines, since they do not provide an
30217estimate that converges after three steps.
30218
d77de738 30219@opindex mveclibabi
ddf6fe37 30220@item -mveclibabi=@var{type}
d77de738
ML
30221Specifies the ABI type to use for vectorizing intrinsics using an
30222external library. The only type supported at present is @samp{mass},
30223which specifies to use IBM's Mathematical Acceleration Subsystem
30224(MASS) libraries for vectorizing intrinsics using external libraries.
30225GCC currently emits calls to @code{acosd2}, @code{acosf4},
30226@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30227@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30228@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30229@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30230@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30231@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30232@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30233@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30234@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30235@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30236@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30237@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30238@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30239for power7. Both @option{-ftree-vectorize} and
30240@option{-funsafe-math-optimizations} must also be enabled. The MASS
30241libraries must be specified at link time.
30242
ddf6fe37 30243@opindex mfriz
d77de738
ML
30244@item -mfriz
30245@itemx -mno-friz
d77de738
ML
30246Generate (do not generate) the @code{friz} instruction when the
30247@option{-funsafe-math-optimizations} option is used to optimize
30248rounding of floating-point values to 64-bit integer and back to floating
30249point. The @code{friz} instruction does not return the same value if
30250the floating-point number is too large to fit in an integer.
30251
ddf6fe37 30252@opindex mpointers-to-nested-functions
d77de738
ML
30253@item -mpointers-to-nested-functions
30254@itemx -mno-pointers-to-nested-functions
d77de738
ML
30255Generate (do not generate) code to load up the static chain register
30256(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30257systems where a function pointer points to a 3-word descriptor giving
30258the function address, TOC value to be loaded in register @code{r2}, and
30259static chain value to be loaded in register @code{r11}. The
30260@option{-mpointers-to-nested-functions} is on by default. You cannot
30261call through pointers to nested functions or pointers
30262to functions compiled in other languages that use the static chain if
30263you use @option{-mno-pointers-to-nested-functions}.
30264
ddf6fe37 30265@opindex msave-toc-indirect
d77de738
ML
30266@item -msave-toc-indirect
30267@itemx -mno-save-toc-indirect
d77de738
ML
30268Generate (do not generate) code to save the TOC value in the reserved
30269stack location in the function prologue if the function calls through
30270a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30271saved in the prologue, it is saved just before the call through the
30272pointer. The @option{-mno-save-toc-indirect} option is the default.
30273
ddf6fe37 30274@opindex mcompat-align-parm
d77de738
ML
30275@item -mcompat-align-parm
30276@itemx -mno-compat-align-parm
d77de738
ML
30277Generate (do not generate) code to pass structure parameters with a
30278maximum alignment of 64 bits, for compatibility with older versions
30279of GCC.
30280
30281Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30282structure parameter on a 128-bit boundary when that structure contained
30283a member requiring 128-bit alignment. This is corrected in more
30284recent versions of GCC. This option may be used to generate code
30285that is compatible with functions compiled with older versions of
30286GCC.
30287
30288The @option{-mno-compat-align-parm} option is the default.
30289
d77de738
ML
30290@opindex mstack-protector-guard
30291@opindex mstack-protector-guard-reg
30292@opindex mstack-protector-guard-offset
30293@opindex mstack-protector-guard-symbol
ddf6fe37
AA
30294@item -mstack-protector-guard=@var{guard}
30295@itemx -mstack-protector-guard-reg=@var{reg}
30296@itemx -mstack-protector-guard-offset=@var{offset}
30297@itemx -mstack-protector-guard-symbol=@var{symbol}
d77de738
ML
30298Generate stack protection code using canary at @var{guard}. Supported
30299locations are @samp{global} for global canary or @samp{tls} for per-thread
30300canary in the TLS block (the default with GNU libc version 2.4 or later).
30301
30302With the latter choice the options
30303@option{-mstack-protector-guard-reg=@var{reg}} and
30304@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30305which register to use as base register for reading the canary, and from what
30306offset from that base register. The default for those is as specified in the
30307relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30308the offset with a symbol reference to a canary in the TLS block.
30309
d77de738
ML
30310@opindex mpcrel
30311@opindex mno-pcrel
ddf6fe37
AA
30312@item -mpcrel
30313@itemx -mno-pcrel
d77de738
ML
30314Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30315option requires that the medium code model (@option{-mcmodel=medium})
30316and prefixed addressing (@option{-mprefixed}) options are enabled.
30317
d77de738
ML
30318@opindex mprefixed
30319@opindex mno-prefixed
ddf6fe37
AA
30320@item -mprefixed
30321@itemx -mno-prefixed
d77de738
ML
30322Generate (do not generate) addressing modes using prefixed load and
30323store instructions. The @option{-mprefixed} option requires that
30324the option @option{-mcpu=power10} (or later) is enabled.
30325
d77de738
ML
30326@opindex mmma
30327@opindex mno-mma
ddf6fe37
AA
30328@item -mmma
30329@itemx -mno-mma
d77de738
ML
30330Generate (do not generate) the MMA instructions. The @option{-mma}
30331option requires that the option @option{-mcpu=power10} (or later)
30332is enabled.
30333
d77de738
ML
30334@opindex mrop-protect
30335@opindex mno-rop-protect
ddf6fe37
AA
30336@item -mrop-protect
30337@itemx -mno-rop-protect
d77de738
ML
30338Generate (do not generate) ROP protection instructions when the target
30339processor supports them. Currently this option disables the shrink-wrap
30340optimization (@option{-fshrink-wrap}).
30341
d77de738
ML
30342@opindex mprivileged
30343@opindex mno-privileged
ddf6fe37
AA
30344@item -mprivileged
30345@itemx -mno-privileged
d77de738
ML
30346Generate (do not generate) code that will run in privileged state.
30347
d77de738
ML
30348@opindex block-ops-unaligned-vsx
30349@opindex no-block-ops-unaligned-vsx
ddf6fe37
AA
30350@item -mblock-ops-unaligned-vsx
30351@itemx -mno-block-ops-unaligned-vsx
d77de738
ML
30352Generate (do not generate) unaligned vsx loads and stores for
30353inline expansion of @code{memcpy} and @code{memmove}.
30354
30355@item --param rs6000-vect-unroll-limit=
30356The vectorizer will check with target information to determine whether it
30357would be beneficial to unroll the main vectorized loop and by how much. This
30358parameter sets the upper bound of how much the vectorizer will unroll the main
30359loop. The default value is four.
30360
30361@end table
30362
30363@node RX Options
30364@subsection RX Options
30365@cindex RX Options
30366
30367These command-line options are defined for RX targets:
30368
30369@table @gcctabopt
d77de738
ML
30370@opindex m64bit-doubles
30371@opindex m32bit-doubles
ddf6fe37
AA
30372@item -m64bit-doubles
30373@itemx -m32bit-doubles
d77de738
ML
30374Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30375or 32 bits (@option{-m32bit-doubles}) in size. The default is
30376@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30377works on 32-bit values, which is why the default is
30378@option{-m32bit-doubles}.
30379
d77de738
ML
30380@opindex fpu
30381@opindex nofpu
ddf6fe37
AA
30382@item -fpu
30383@itemx -nofpu
d77de738
ML
30384Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30385floating-point hardware. The default is enabled for the RX600
30386series and disabled for the RX200 series.
30387
30388Floating-point instructions are only generated for 32-bit floating-point
30389values, however, so the FPU hardware is not used for doubles if the
30390@option{-m64bit-doubles} option is used.
30391
30392@emph{Note} If the @option{-fpu} option is enabled then
30393@option{-funsafe-math-optimizations} is also enabled automatically.
30394This is because the RX FPU instructions are themselves unsafe.
30395
d77de738 30396@opindex mcpu
ddf6fe37 30397@item -mcpu=@var{name}
d77de738
ML
30398Selects the type of RX CPU to be targeted. Currently three types are
30399supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30400the specific @samp{RX610} CPU. The default is @samp{RX600}.
30401
30402The only difference between @samp{RX600} and @samp{RX610} is that the
30403@samp{RX610} does not support the @code{MVTIPL} instruction.
30404
30405The @samp{RX200} series does not have a hardware floating-point unit
30406and so @option{-nofpu} is enabled by default when this type is
30407selected.
30408
d77de738
ML
30409@opindex mbig-endian-data
30410@opindex mlittle-endian-data
ddf6fe37
AA
30411@item -mbig-endian-data
30412@itemx -mlittle-endian-data
d77de738
ML
30413Store data (but not code) in the big-endian format. The default is
30414@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30415format.
30416
d77de738 30417@opindex msmall-data-limit
ddf6fe37 30418@item -msmall-data-limit=@var{N}
d77de738
ML
30419Specifies the maximum size in bytes of global and static variables
30420which can be placed into the small data area. Using the small data
30421area can lead to smaller and faster code, but the size of area is
30422limited and it is up to the programmer to ensure that the area does
30423not overflow. Also when the small data area is used one of the RX's
30424registers (usually @code{r13}) is reserved for use pointing to this
30425area, so it is no longer available for use by the compiler. This
30426could result in slower and/or larger code if variables are pushed onto
30427the stack instead of being held in this register.
30428
30429Note, common variables (variables that have not been initialized) and
30430constants are not placed into the small data area as they are assigned
30431to other sections in the output executable.
30432
30433The default value is zero, which disables this feature. Note, this
30434feature is not enabled by default with higher optimization levels
30435(@option{-O2} etc) because of the potentially detrimental effects of
30436reserving a register. It is up to the programmer to experiment and
30437discover whether this feature is of benefit to their program. See the
30438description of the @option{-mpid} option for a description of how the
30439actual register to hold the small data area pointer is chosen.
30440
d77de738
ML
30441@opindex msim
30442@opindex mno-sim
ddf6fe37
AA
30443@item -msim
30444@itemx -mno-sim
d77de738
ML
30445Use the simulator runtime. The default is to use the libgloss
30446board-specific runtime.
30447
d77de738
ML
30448@opindex mas100-syntax
30449@opindex mno-as100-syntax
ddf6fe37
AA
30450@item -mas100-syntax
30451@itemx -mno-as100-syntax
d77de738
ML
30452When generating assembler output use a syntax that is compatible with
30453Renesas's AS100 assembler. This syntax can also be handled by the GAS
30454assembler, but it has some restrictions so it is not generated by default.
30455
d77de738 30456@opindex mmax-constant-size
ddf6fe37 30457@item -mmax-constant-size=@var{N}
d77de738
ML
30458Specifies the maximum size, in bytes, of a constant that can be used as
30459an operand in a RX instruction. Although the RX instruction set does
30460allow constants of up to 4 bytes in length to be used in instructions,
30461a longer value equates to a longer instruction. Thus in some
30462circumstances it can be beneficial to restrict the size of constants
30463that are used in instructions. Constants that are too big are instead
30464placed into a constant pool and referenced via register indirection.
30465
30466The value @var{N} can be between 0 and 4. A value of 0 (the default)
30467or 4 means that constants of any size are allowed.
30468
d77de738 30469@opindex mrelax
ddf6fe37 30470@item -mrelax
d77de738
ML
30471Enable linker relaxation. Linker relaxation is a process whereby the
30472linker attempts to reduce the size of a program by finding shorter
30473versions of various instructions. Disabled by default.
30474
d77de738 30475@opindex mint-register
ddf6fe37 30476@item -mint-register=@var{N}
d77de738
ML
30477Specify the number of registers to reserve for fast interrupt handler
30478functions. The value @var{N} can be between 0 and 4. A value of 1
30479means that register @code{r13} is reserved for the exclusive use
30480of fast interrupt handlers. A value of 2 reserves @code{r13} and
30481@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30482@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30483A value of 0, the default, does not reserve any registers.
30484
d77de738 30485@opindex msave-acc-in-interrupts
ddf6fe37 30486@item -msave-acc-in-interrupts
d77de738
ML
30487Specifies that interrupt handler functions should preserve the
30488accumulator register. This is only necessary if normal code might use
30489the accumulator register, for example because it performs 64-bit
30490multiplications. The default is to ignore the accumulator as this
30491makes the interrupt handlers faster.
30492
d77de738
ML
30493@opindex mpid
30494@opindex mno-pid
ddf6fe37
AA
30495@item -mpid
30496@itemx -mno-pid
d77de738
ML
30497Enables the generation of position independent data. When enabled any
30498access to constant data is done via an offset from a base address
30499held in a register. This allows the location of constant data to be
30500determined at run time without requiring the executable to be
30501relocated, which is a benefit to embedded applications with tight
30502memory constraints. Data that can be modified is not affected by this
30503option.
30504
30505Note, using this feature reserves a register, usually @code{r13}, for
30506the constant data base address. This can result in slower and/or
30507larger code, especially in complicated functions.
30508
30509The actual register chosen to hold the constant data base address
30510depends upon whether the @option{-msmall-data-limit} and/or the
30511@option{-mint-register} command-line options are enabled. Starting
30512with register @code{r13} and proceeding downwards, registers are
30513allocated first to satisfy the requirements of @option{-mint-register},
30514then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30515is possible for the small data area register to be @code{r8} if both
30516@option{-mint-register=4} and @option{-mpid} are specified on the
30517command line.
30518
30519By default this feature is not enabled. The default can be restored
30520via the @option{-mno-pid} command-line option.
30521
d77de738
ML
30522@opindex mno-warn-multiple-fast-interrupts
30523@opindex mwarn-multiple-fast-interrupts
ddf6fe37
AA
30524@item -mno-warn-multiple-fast-interrupts
30525@itemx -mwarn-multiple-fast-interrupts
d77de738
ML
30526Prevents GCC from issuing a warning message if it finds more than one
30527fast interrupt handler when it is compiling a file. The default is to
30528issue a warning for each extra fast interrupt handler found, as the RX
30529only supports one such interrupt.
30530
d77de738
ML
30531@opindex mallow-string-insns
30532@opindex mno-allow-string-insns
ddf6fe37
AA
30533@item -mallow-string-insns
30534@itemx -mno-allow-string-insns
d77de738
ML
30535Enables or disables the use of the string manipulation instructions
30536@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
30537@code{SWHILE} and also the @code{RMPA} instruction. These
30538instructions may prefetch data, which is not safe to do if accessing
30539an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
30540for more information).
30541
30542The default is to allow these instructions, but it is not possible for
30543GCC to reliably detect all circumstances where a string instruction
30544might be used to access an I/O register, so their use cannot be
30545disabled automatically. Instead it is reliant upon the programmer to
30546use the @option{-mno-allow-string-insns} option if their program
30547accesses I/O space.
30548
30549When the instructions are enabled GCC defines the C preprocessor
30550symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
30551symbol @code{__RX_DISALLOW_STRING_INSNS__}.
30552
d77de738
ML
30553@opindex mjsr
30554@opindex mno-jsr
ddf6fe37
AA
30555@item -mjsr
30556@itemx -mno-jsr
d77de738
ML
30557Use only (or not only) @code{JSR} instructions to access functions.
30558This option can be used when code size exceeds the range of @code{BSR}
30559instructions. Note that @option{-mno-jsr} does not mean to not use
30560@code{JSR} but instead means that any type of branch may be used.
30561@end table
30562
30563@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
30564has special significance to the RX port when used with the
30565@code{interrupt} function attribute. This attribute indicates a
30566function intended to process fast interrupts. GCC ensures
30567that it only uses the registers @code{r10}, @code{r11}, @code{r12}
30568and/or @code{r13} and only provided that the normal use of the
30569corresponding registers have been restricted via the
30570@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
30571options.
30572
30573@node S/390 and zSeries Options
30574@subsection S/390 and zSeries Options
30575@cindex S/390 and zSeries Options
30576
30577These are the @samp{-m} options defined for the S/390 and zSeries architecture.
30578
30579@table @gcctabopt
d77de738
ML
30580@opindex mhard-float
30581@opindex msoft-float
ddf6fe37
AA
30582@item -mhard-float
30583@itemx -msoft-float
d77de738
ML
30584Use (do not use) the hardware floating-point instructions and registers
30585for floating-point operations. When @option{-msoft-float} is specified,
30586functions in @file{libgcc.a} are used to perform floating-point
30587operations. When @option{-mhard-float} is specified, the compiler
30588generates IEEE floating-point instructions. This is the default.
30589
d77de738
ML
30590@opindex mhard-dfp
30591@opindex mno-hard-dfp
ddf6fe37
AA
30592@item -mhard-dfp
30593@itemx -mno-hard-dfp
d77de738
ML
30594Use (do not use) the hardware decimal-floating-point instructions for
30595decimal-floating-point operations. When @option{-mno-hard-dfp} is
30596specified, functions in @file{libgcc.a} are used to perform
30597decimal-floating-point operations. When @option{-mhard-dfp} is
30598specified, the compiler generates decimal-floating-point hardware
30599instructions. This is the default for @option{-march=z9-ec} or higher.
30600
d77de738
ML
30601@opindex mlong-double-64
30602@opindex mlong-double-128
ddf6fe37
AA
30603@item -mlong-double-64
30604@itemx -mlong-double-128
d77de738
ML
30605These switches control the size of @code{long double} type. A size
30606of 64 bits makes the @code{long double} type equivalent to the @code{double}
30607type. This is the default.
30608
d77de738
ML
30609@opindex mbackchain
30610@opindex mno-backchain
ddf6fe37
AA
30611@item -mbackchain
30612@itemx -mno-backchain
d77de738
ML
30613Store (do not store) the address of the caller's frame as backchain pointer
30614into the callee's stack frame.
30615A backchain may be needed to allow debugging using tools that do not understand
30616DWARF call frame information.
30617When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
30618at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
30619the backchain is placed into the topmost word of the 96/160 byte register
30620save area.
30621
30622In general, code compiled with @option{-mbackchain} is call-compatible with
30623code compiled with @option{-mno-backchain}; however, use of the backchain
30624for debugging purposes usually requires that the whole binary is built with
30625@option{-mbackchain}. Note that the combination of @option{-mbackchain},
30626@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30627to build a linux kernel use @option{-msoft-float}.
30628
30629The default is to not maintain the backchain.
30630
d77de738
ML
30631@opindex mpacked-stack
30632@opindex mno-packed-stack
ddf6fe37
AA
30633@item -mpacked-stack
30634@itemx -mno-packed-stack
d77de738
ML
30635Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
30636specified, the compiler uses the all fields of the 96/160 byte register save
30637area only for their default purpose; unused fields still take up stack space.
30638When @option{-mpacked-stack} is specified, register save slots are densely
30639packed at the top of the register save area; unused space is reused for other
30640purposes, allowing for more efficient use of the available stack space.
30641However, when @option{-mbackchain} is also in effect, the topmost word of
30642the save area is always used to store the backchain, and the return address
30643register is always saved two words below the backchain.
30644
30645As long as the stack frame backchain is not used, code generated with
30646@option{-mpacked-stack} is call-compatible with code generated with
30647@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
30648S/390 or zSeries generated code that uses the stack frame backchain at run
30649time, not just for debugging purposes. Such code is not call-compatible
30650with code compiled with @option{-mpacked-stack}. Also, note that the
30651combination of @option{-mbackchain},
30652@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30653to build a linux kernel use @option{-msoft-float}.
30654
30655The default is to not use the packed stack layout.
30656
d77de738
ML
30657@opindex msmall-exec
30658@opindex mno-small-exec
ddf6fe37
AA
30659@item -msmall-exec
30660@itemx -mno-small-exec
d77de738
ML
30661Generate (or do not generate) code using the @code{bras} instruction
30662to do subroutine calls.
30663This only works reliably if the total executable size does not
30664exceed 64k. The default is to use the @code{basr} instruction instead,
30665which does not have this limitation.
30666
d77de738
ML
30667@opindex m64
30668@opindex m31
ddf6fe37
AA
30669@item -m64
30670@itemx -m31
d77de738
ML
30671When @option{-m31} is specified, generate code compliant to the
30672GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
30673code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
30674particular to generate 64-bit instructions. For the @samp{s390}
30675targets, the default is @option{-m31}, while the @samp{s390x}
30676targets default to @option{-m64}.
30677
d77de738
ML
30678@opindex mzarch
30679@opindex mesa
ddf6fe37
AA
30680@item -mzarch
30681@itemx -mesa
d77de738
ML
30682When @option{-mzarch} is specified, generate code using the
30683instructions available on z/Architecture.
30684When @option{-mesa} is specified, generate code using the
30685instructions available on ESA/390. Note that @option{-mesa} is
30686not possible with @option{-m64}.
30687When generating code compliant to the GNU/Linux for S/390 ABI,
30688the default is @option{-mesa}. When generating code compliant
30689to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
30690
d77de738
ML
30691@opindex mhtm
30692@opindex mno-htm
ddf6fe37
AA
30693@item -mhtm
30694@itemx -mno-htm
d77de738
ML
30695The @option{-mhtm} option enables a set of builtins making use of
30696instructions available with the transactional execution facility
30697introduced with the IBM zEnterprise EC12 machine generation
30698@ref{S/390 System z Built-in Functions}.
30699@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
30700
d77de738
ML
30701@opindex mvx
30702@opindex mno-vx
ddf6fe37
AA
30703@item -mvx
30704@itemx -mno-vx
d77de738
ML
30705When @option{-mvx} is specified, generate code using the instructions
30706available with the vector extension facility introduced with the IBM
30707z13 machine generation.
30708This option changes the ABI for some vector type values with regard to
30709alignment and calling conventions. In case vector type values are
30710being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
30711command will be added to mark the resulting binary with the ABI used.
30712@option{-mvx} is enabled by default when using @option{-march=z13}.
30713
d77de738
ML
30714@opindex mzvector
30715@opindex mno-zvector
ddf6fe37
AA
30716@item -mzvector
30717@itemx -mno-zvector
d77de738
ML
30718The @option{-mzvector} option enables vector language extensions and
30719builtins using instructions available with the vector extension
30720facility introduced with the IBM z13 machine generation.
30721This option adds support for @samp{vector} to be used as a keyword to
30722define vector type variables and arguments. @samp{vector} is only
30723available when GNU extensions are enabled. It will not be expanded
30724when requesting strict standard compliance e.g.@: with @option{-std=c99}.
30725In addition to the GCC low-level builtins @option{-mzvector} enables
30726a set of builtins added for compatibility with AltiVec-style
30727implementations like Power and Cell. In order to make use of these
30728builtins the header file @file{vecintrin.h} needs to be included.
30729@option{-mzvector} is disabled by default.
30730
d77de738
ML
30731@opindex mmvcle
30732@opindex mno-mvcle
ddf6fe37
AA
30733@item -mmvcle
30734@itemx -mno-mvcle
d77de738
ML
30735Generate (or do not generate) code using the @code{mvcle} instruction
30736to perform block moves. When @option{-mno-mvcle} is specified,
30737use a @code{mvc} loop instead. This is the default unless optimizing for
30738size.
30739
d77de738
ML
30740@opindex mdebug
30741@opindex mno-debug
ddf6fe37
AA
30742@item -mdebug
30743@itemx -mno-debug
d77de738
ML
30744Print (or do not print) additional debug information when compiling.
30745The default is to not print debug information.
30746
d77de738 30747@opindex march
ddf6fe37 30748@item -march=@var{cpu-type}
d77de738
ML
30749Generate code that runs on @var{cpu-type}, which is the name of a
30750system representing a certain processor type. Possible values for
30751@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
30752@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
30753@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
30754@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
30755@samp{z16}/@samp{arch14}, and @samp{native}.
30756
30757The default is @option{-march=z900}.
30758
30759Specifying @samp{native} as cpu type can be used to select the best
30760architecture option for the host processor.
30761@option{-march=native} has no effect if GCC does not recognize the
30762processor.
30763
d77de738 30764@opindex mtune
ddf6fe37 30765@item -mtune=@var{cpu-type}
d77de738
ML
30766Tune to @var{cpu-type} everything applicable about the generated code,
30767except for the ABI and the set of available instructions.
30768The list of @var{cpu-type} values is the same as for @option{-march}.
30769The default is the value used for @option{-march}.
30770
d77de738
ML
30771@opindex mtpf-trace
30772@opindex mno-tpf-trace
ddf6fe37
AA
30773@item -mtpf-trace
30774@itemx -mno-tpf-trace
d77de738
ML
30775Generate code that adds (does not add) in TPF OS specific branches to trace
30776routines in the operating system. This option is off by default, even
30777when compiling for the TPF OS@.
30778
d77de738
ML
30779@opindex mtpf-trace-skip
30780@opindex mno-tpf-trace-skip
ddf6fe37
AA
30781@item -mtpf-trace-skip
30782@itemx -mno-tpf-trace-skip
d77de738
ML
30783Generate code that changes (does not change) the default branch
30784targets enabled by @option{-mtpf-trace} to point to specialized trace
30785routines providing the ability of selectively skipping function trace
30786entries for the TPF OS. This option is off by default, even when
30787compiling for the TPF OS and specifying @option{-mtpf-trace}.
30788
d77de738
ML
30789@opindex mfused-madd
30790@opindex mno-fused-madd
ddf6fe37
AA
30791@item -mfused-madd
30792@itemx -mno-fused-madd
d77de738
ML
30793Generate code that uses (does not use) the floating-point multiply and
30794accumulate instructions. These instructions are generated by default if
30795hardware floating point is used.
30796
d77de738 30797@opindex mwarn-framesize
ddf6fe37 30798@item -mwarn-framesize=@var{framesize}
d77de738
ML
30799Emit a warning if the current function exceeds the given frame size. Because
30800this is a compile-time check it doesn't need to be a real problem when the program
30801runs. It is intended to identify functions that most probably cause
30802a stack overflow. It is useful to be used in an environment with limited stack
30803size e.g.@: the linux kernel.
30804
d77de738 30805@opindex mwarn-dynamicstack
ddf6fe37 30806@item -mwarn-dynamicstack
d77de738
ML
30807Emit a warning if the function calls @code{alloca} or uses dynamically-sized
30808arrays. This is generally a bad idea with a limited stack size.
30809
d77de738
ML
30810@opindex mstack-guard
30811@opindex mstack-size
ddf6fe37
AA
30812@item -mstack-guard=@var{stack-guard}
30813@itemx -mstack-size=@var{stack-size}
d77de738
ML
30814If these options are provided the S/390 back end emits additional instructions in
30815the function prologue that trigger a trap if the stack size is @var{stack-guard}
30816bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
30817If the @var{stack-guard} option is omitted the smallest power of 2 larger than
30818the frame size of the compiled function is chosen.
30819These options are intended to be used to help debugging stack overflow problems.
30820The additionally emitted code causes only little overhead and hence can also be
30821used in production-like systems without greater performance degradation. The given
30822values have to be exact powers of 2 and @var{stack-size} has to be greater than
30823@var{stack-guard} without exceeding 64k.
30824In order to be efficient the extra code makes the assumption that the stack starts
30825at an address aligned to the value given by @var{stack-size}.
30826The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
30827
d77de738 30828@opindex mhotpatch
ddf6fe37 30829@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
d77de738
ML
30830If the hotpatch option is enabled, a ``hot-patching'' function
30831prologue is generated for all functions in the compilation unit.
30832The funtion label is prepended with the given number of two-byte
30833NOP instructions (@var{pre-halfwords}, maximum 1000000). After
30834the label, 2 * @var{post-halfwords} bytes are appended, using the
30835largest NOP like instructions the architecture allows (maximum
308361000000).
30837
30838If both arguments are zero, hotpatching is disabled.
30839
30840This option can be overridden for individual functions with the
30841@code{hotpatch} attribute.
30842@end table
30843
d77de738
ML
30844@node SH Options
30845@subsection SH Options
30846
30847These @samp{-m} options are defined for the SH implementations:
30848
30849@table @gcctabopt
d77de738 30850@opindex m1
ddf6fe37 30851@item -m1
d77de738
ML
30852Generate code for the SH1.
30853
d77de738 30854@opindex m2
ddf6fe37 30855@item -m2
d77de738
ML
30856Generate code for the SH2.
30857
30858@item -m2e
30859Generate code for the SH2e.
30860
d77de738 30861@opindex m2a-nofpu
ddf6fe37 30862@item -m2a-nofpu
d77de738
ML
30863Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
30864that the floating-point unit is not used.
30865
d77de738 30866@opindex m2a-single-only
ddf6fe37 30867@item -m2a-single-only
d77de738
ML
30868Generate code for the SH2a-FPU, in such a way that no double-precision
30869floating-point operations are used.
30870
d77de738 30871@opindex m2a-single
ddf6fe37 30872@item -m2a-single
d77de738
ML
30873Generate code for the SH2a-FPU assuming the floating-point unit is in
30874single-precision mode by default.
30875
d77de738 30876@opindex m2a
ddf6fe37 30877@item -m2a
d77de738
ML
30878Generate code for the SH2a-FPU assuming the floating-point unit is in
30879double-precision mode by default.
30880
d77de738 30881@opindex m3
ddf6fe37 30882@item -m3
d77de738
ML
30883Generate code for the SH3.
30884
d77de738 30885@opindex m3e
ddf6fe37 30886@item -m3e
d77de738
ML
30887Generate code for the SH3e.
30888
d77de738 30889@opindex m4-nofpu
ddf6fe37 30890@item -m4-nofpu
d77de738
ML
30891Generate code for the SH4 without a floating-point unit.
30892
d77de738 30893@opindex m4-single-only
ddf6fe37 30894@item -m4-single-only
d77de738
ML
30895Generate code for the SH4 with a floating-point unit that only
30896supports single-precision arithmetic.
30897
d77de738 30898@opindex m4-single
ddf6fe37 30899@item -m4-single
d77de738
ML
30900Generate code for the SH4 assuming the floating-point unit is in
30901single-precision mode by default.
30902
d77de738 30903@opindex m4
ddf6fe37 30904@item -m4
d77de738
ML
30905Generate code for the SH4.
30906
d77de738 30907@opindex m4-100
ddf6fe37 30908@item -m4-100
d77de738
ML
30909Generate code for SH4-100.
30910
d77de738 30911@opindex m4-100-nofpu
ddf6fe37 30912@item -m4-100-nofpu
d77de738
ML
30913Generate code for SH4-100 in such a way that the
30914floating-point unit is not used.
30915
d77de738 30916@opindex m4-100-single
ddf6fe37 30917@item -m4-100-single
d77de738
ML
30918Generate code for SH4-100 assuming the floating-point unit is in
30919single-precision mode by default.
30920
d77de738 30921@opindex m4-100-single-only
ddf6fe37 30922@item -m4-100-single-only
d77de738
ML
30923Generate code for SH4-100 in such a way that no double-precision
30924floating-point operations are used.
30925
d77de738 30926@opindex m4-200
ddf6fe37 30927@item -m4-200
d77de738
ML
30928Generate code for SH4-200.
30929
d77de738 30930@opindex m4-200-nofpu
ddf6fe37 30931@item -m4-200-nofpu
d77de738
ML
30932Generate code for SH4-200 without in such a way that the
30933floating-point unit is not used.
30934
d77de738 30935@opindex m4-200-single
ddf6fe37 30936@item -m4-200-single
d77de738
ML
30937Generate code for SH4-200 assuming the floating-point unit is in
30938single-precision mode by default.
30939
d77de738 30940@opindex m4-200-single-only
ddf6fe37 30941@item -m4-200-single-only
d77de738
ML
30942Generate code for SH4-200 in such a way that no double-precision
30943floating-point operations are used.
30944
d77de738 30945@opindex m4-300
ddf6fe37 30946@item -m4-300
d77de738
ML
30947Generate code for SH4-300.
30948
d77de738 30949@opindex m4-300-nofpu
ddf6fe37 30950@item -m4-300-nofpu
d77de738
ML
30951Generate code for SH4-300 without in such a way that the
30952floating-point unit is not used.
30953
d77de738 30954@opindex m4-300-single
ddf6fe37 30955@item -m4-300-single
d77de738
ML
30956Generate code for SH4-300 in such a way that no double-precision
30957floating-point operations are used.
30958
d77de738 30959@opindex m4-300-single-only
ddf6fe37 30960@item -m4-300-single-only
d77de738
ML
30961Generate code for SH4-300 in such a way that no double-precision
30962floating-point operations are used.
30963
d77de738 30964@opindex m4-340
ddf6fe37 30965@item -m4-340
d77de738
ML
30966Generate code for SH4-340 (no MMU, no FPU).
30967
d77de738 30968@opindex m4-500
ddf6fe37 30969@item -m4-500
d77de738
ML
30970Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
30971assembler.
30972
d77de738 30973@opindex m4a-nofpu
ddf6fe37 30974@item -m4a-nofpu
d77de738
ML
30975Generate code for the SH4al-dsp, or for a SH4a in such a way that the
30976floating-point unit is not used.
30977
d77de738 30978@opindex m4a-single-only
ddf6fe37 30979@item -m4a-single-only
d77de738
ML
30980Generate code for the SH4a, in such a way that no double-precision
30981floating-point operations are used.
30982
d77de738 30983@opindex m4a-single
ddf6fe37 30984@item -m4a-single
d77de738
ML
30985Generate code for the SH4a assuming the floating-point unit is in
30986single-precision mode by default.
30987
d77de738 30988@opindex m4a
ddf6fe37 30989@item -m4a
d77de738
ML
30990Generate code for the SH4a.
30991
d77de738 30992@opindex m4al
ddf6fe37 30993@item -m4al
d77de738
ML
30994Same as @option{-m4a-nofpu}, except that it implicitly passes
30995@option{-dsp} to the assembler. GCC doesn't generate any DSP
30996instructions at the moment.
30997
d77de738 30998@opindex mb
ddf6fe37 30999@item -mb
d77de738
ML
31000Compile code for the processor in big-endian mode.
31001
d77de738 31002@opindex ml
ddf6fe37 31003@item -ml
d77de738
ML
31004Compile code for the processor in little-endian mode.
31005
d77de738 31006@opindex mdalign
ddf6fe37 31007@item -mdalign
d77de738
ML
31008Align doubles at 64-bit boundaries. Note that this changes the calling
31009conventions, and thus some functions from the standard C library do
31010not work unless you recompile it first with @option{-mdalign}.
31011
d77de738 31012@opindex mrelax
ddf6fe37 31013@item -mrelax
d77de738
ML
31014Shorten some address references at link time, when possible; uses the
31015linker option @option{-relax}.
31016
d77de738 31017@opindex mbigtable
ddf6fe37 31018@item -mbigtable
d77de738
ML
31019Use 32-bit offsets in @code{switch} tables. The default is to use
3102016-bit offsets.
31021
d77de738 31022@opindex mbitops
ddf6fe37 31023@item -mbitops
d77de738
ML
31024Enable the use of bit manipulation instructions on SH2A.
31025
d77de738 31026@opindex mfmovd
ddf6fe37 31027@item -mfmovd
d77de738
ML
31028Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
31029alignment constraints.
31030
d77de738 31031@opindex mrenesas
ddf6fe37 31032@item -mrenesas
d77de738
ML
31033Comply with the calling conventions defined by Renesas.
31034
d77de738 31035@opindex mno-renesas
ddf6fe37 31036@item -mno-renesas
d77de738
ML
31037Comply with the calling conventions defined for GCC before the Renesas
31038conventions were available. This option is the default for all
31039targets of the SH toolchain.
31040
d77de738 31041@opindex mnomacsave
ddf6fe37 31042@item -mnomacsave
d77de738
ML
31043Mark the @code{MAC} register as call-clobbered, even if
31044@option{-mrenesas} is given.
31045
d77de738
ML
31046@opindex mieee
31047@opindex mno-ieee
ddf6fe37
AA
31048@item -mieee
31049@itemx -mno-ieee
d77de738
ML
31050Control the IEEE compliance of floating-point comparisons, which affects the
31051handling of cases where the result of a comparison is unordered. By default
31052@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
31053enabled @option{-mno-ieee} is implicitly set, which results in faster
31054floating-point greater-equal and less-equal comparisons. The implicit settings
31055can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
31056
d77de738 31057@opindex minline-ic_invalidate
ddf6fe37 31058@item -minline-ic_invalidate
d77de738
ML
31059Inline code to invalidate instruction cache entries after setting up
31060nested function trampolines.
31061This option has no effect if @option{-musermode} is in effect and the selected
31062code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
31063instruction.
31064If the selected code generation option does not allow the use of the @code{icbi}
31065instruction, and @option{-musermode} is not in effect, the inlined code
31066manipulates the instruction cache address array directly with an associative
31067write. This not only requires privileged mode at run time, but it also
31068fails if the cache line had been mapped via the TLB and has become unmapped.
31069
d77de738 31070@opindex misize
ddf6fe37 31071@item -misize
d77de738
ML
31072Dump instruction size and location in the assembly code.
31073
d77de738 31074@opindex mpadstruct
ddf6fe37 31075@item -mpadstruct
d77de738
ML
31076This option is deprecated. It pads structures to multiple of 4 bytes,
31077which is incompatible with the SH ABI@.
31078
d77de738 31079@opindex matomic-model=@var{model}
ddf6fe37 31080@item -matomic-model=@var{model}
d77de738
ML
31081Sets the model of atomic operations and additional parameters as a comma
31082separated list. For details on the atomic built-in functions see
31083@ref{__atomic Builtins}. The following models and parameters are supported:
31084
31085@table @samp
31086
31087@item none
31088Disable compiler generated atomic sequences and emit library calls for atomic
31089operations. This is the default if the target is not @code{sh*-*-linux*}.
31090
31091@item soft-gusa
31092Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
31093built-in functions. The generated atomic sequences require additional support
31094from the interrupt/exception handling code of the system and are only suitable
31095for SH3* and SH4* single-core systems. This option is enabled by default when
31096the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
31097this option also partially utilizes the hardware atomic instructions
31098@code{movli.l} and @code{movco.l} to create more efficient code, unless
31099@samp{strict} is specified.
31100
31101@item soft-tcb
31102Generate software atomic sequences that use a variable in the thread control
31103block. This is a variation of the gUSA sequences which can also be used on
31104SH1* and SH2* targets. The generated atomic sequences require additional
31105support from the interrupt/exception handling code of the system and are only
31106suitable for single-core systems. When using this model, the @samp{gbr-offset=}
31107parameter has to be specified as well.
31108
31109@item soft-imask
31110Generate software atomic sequences that temporarily disable interrupts by
31111setting @code{SR.IMASK = 1111}. This model works only when the program runs
31112in privileged mode and is only suitable for single-core systems. Additional
31113support from the interrupt/exception handling code of the system is not
31114required. This model is enabled by default when the target is
31115@code{sh*-*-linux*} and SH1* or SH2*.
31116
31117@item hard-llcs
31118Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
31119instructions only. This is only available on SH4A and is suitable for
31120multi-core systems. Since the hardware instructions support only 32 bit atomic
31121variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
31122Code compiled with this option is also compatible with other software
31123atomic model interrupt/exception handling systems if executed on an SH4A
31124system. Additional support from the interrupt/exception handling code of the
31125system is not required for this model.
31126
31127@item gbr-offset=
31128This parameter specifies the offset in bytes of the variable in the thread
31129control block structure that should be used by the generated atomic sequences
31130when the @samp{soft-tcb} model has been selected. For other models this
31131parameter is ignored. The specified value must be an integer multiple of four
31132and in the range 0-1020.
31133
31134@item strict
31135This parameter prevents mixed usage of multiple atomic models, even if they
31136are compatible, and makes the compiler generate atomic sequences of the
31137specified model only.
31138
31139@end table
31140
d77de738 31141@opindex mtas
ddf6fe37 31142@item -mtas
d77de738
ML
31143Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
31144Notice that depending on the particular hardware and software configuration
31145this can degrade overall performance due to the operand cache line flushes
31146that are implied by the @code{tas.b} instruction. On multi-core SH4A
31147processors the @code{tas.b} instruction must be used with caution since it
31148can result in data corruption for certain cache configurations.
31149
d77de738 31150@opindex mprefergot
ddf6fe37 31151@item -mprefergot
d77de738
ML
31152When generating position-independent code, emit function calls using
31153the Global Offset Table instead of the Procedure Linkage Table.
31154
d77de738
ML
31155@opindex musermode
31156@opindex mno-usermode
ddf6fe37
AA
31157@item -musermode
31158@itemx -mno-usermode
d77de738
ML
31159Don't allow (allow) the compiler generating privileged mode code. Specifying
31160@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31161inlined code would not work in user mode. @option{-musermode} is the default
31162when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31163@option{-musermode} has no effect, since there is no user mode.
31164
d77de738 31165@opindex multcost=@var{number}
ddf6fe37 31166@item -multcost=@var{number}
d77de738
ML
31167Set the cost to assume for a multiply insn.
31168
d77de738 31169@opindex mdiv=@var{strategy}
ddf6fe37 31170@item -mdiv=@var{strategy}
d77de738
ML
31171Set the division strategy to be used for integer division operations.
31172@var{strategy} can be one of:
31173
31174@table @samp
31175
31176@item call-div1
31177Calls a library function that uses the single-step division instruction
31178@code{div1} to perform the operation. Division by zero calculates an
31179unspecified result and does not trap. This is the default except for SH4,
31180SH2A and SHcompact.
31181
31182@item call-fp
31183Calls a library function that performs the operation in double precision
31184floating point. Division by zero causes a floating-point exception. This is
31185the default for SHcompact with FPU. Specifying this for targets that do not
31186have a double precision FPU defaults to @code{call-div1}.
31187
31188@item call-table
31189Calls a library function that uses a lookup table for small divisors and
31190the @code{div1} instruction with case distinction for larger divisors. Division
31191by zero calculates an unspecified result and does not trap. This is the default
31192for SH4. Specifying this for targets that do not have dynamic shift
31193instructions defaults to @code{call-div1}.
31194
31195@end table
31196
31197When a division strategy has not been specified the default strategy is
31198selected based on the current target. For SH2A the default strategy is to
31199use the @code{divs} and @code{divu} instructions instead of library function
31200calls.
31201
d77de738 31202@opindex maccumulate-outgoing-args
ddf6fe37 31203@item -maccumulate-outgoing-args
d77de738
ML
31204Reserve space once for outgoing arguments in the function prologue rather
31205than around each call. Generally beneficial for performance and size. Also
31206needed for unwinding to avoid changing the stack frame around conditional code.
31207
d77de738 31208@opindex mdivsi3_libfunc=@var{name}
ddf6fe37 31209@item -mdivsi3_libfunc=@var{name}
d77de738
ML
31210Set the name of the library function used for 32-bit signed division to
31211@var{name}.
31212This only affects the name used in the @samp{call} division strategies, and
31213the compiler still expects the same sets of input/output/clobbered registers as
31214if this option were not present.
31215
d77de738 31216@opindex mfixed-range
ddf6fe37 31217@item -mfixed-range=@var{register-range}
d77de738
ML
31218Generate code treating the given register range as fixed registers.
31219A fixed register is one that the register allocator cannot use. This is
31220useful when compiling kernel code. A register range is specified as
31221two registers separated by a dash. Multiple register ranges can be
31222specified separated by a comma.
31223
d77de738 31224@opindex mbranch-cost=@var{num}
ddf6fe37 31225@item -mbranch-cost=@var{num}
d77de738
ML
31226Assume @var{num} to be the cost for a branch instruction. Higher numbers
31227make the compiler try to generate more branch-free code if possible.
31228If not specified the value is selected depending on the processor type that
31229is being compiled for.
31230
d77de738
ML
31231@opindex mzdcbranch
31232@opindex mno-zdcbranch
ddf6fe37
AA
31233@item -mzdcbranch
31234@itemx -mno-zdcbranch
d77de738
ML
31235Assume (do not assume) that zero displacement conditional branch instructions
31236@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31237compiler prefers zero displacement branch code sequences. This is
31238enabled by default when generating code for SH4 and SH4A. It can be explicitly
31239disabled by specifying @option{-mno-zdcbranch}.
31240
d77de738 31241@opindex mcbranch-force-delay-slot
ddf6fe37 31242@item -mcbranch-force-delay-slot
d77de738
ML
31243Force the usage of delay slots for conditional branches, which stuffs the delay
31244slot with a @code{nop} if a suitable instruction cannot be found. By default
31245this option is disabled. It can be enabled to work around hardware bugs as
31246found in the original SH7055.
31247
d77de738
ML
31248@opindex mfused-madd
31249@opindex mno-fused-madd
ddf6fe37
AA
31250@item -mfused-madd
31251@itemx -mno-fused-madd
d77de738
ML
31252Generate code that uses (does not use) the floating-point multiply and
31253accumulate instructions. These instructions are generated by default
31254if hardware floating point is used. The machine-dependent
31255@option{-mfused-madd} option is now mapped to the machine-independent
31256@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31257mapped to @option{-ffp-contract=off}.
31258
d77de738
ML
31259@opindex mfsca
31260@opindex mno-fsca
ddf6fe37
AA
31261@item -mfsca
31262@itemx -mno-fsca
d77de738
ML
31263Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31264and cosine approximations. The option @option{-mfsca} must be used in
31265combination with @option{-funsafe-math-optimizations}. It is enabled by default
31266when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31267approximations even if @option{-funsafe-math-optimizations} is in effect.
31268
d77de738
ML
31269@opindex mfsrra
31270@opindex mno-fsrra
ddf6fe37
AA
31271@item -mfsrra
31272@itemx -mno-fsrra
d77de738
ML
31273Allow or disallow the compiler to emit the @code{fsrra} instruction for
31274reciprocal square root approximations. The option @option{-mfsrra} must be used
31275in combination with @option{-funsafe-math-optimizations} and
31276@option{-ffinite-math-only}. It is enabled by default when generating code for
31277SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31278even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31279in effect.
31280
d77de738 31281@opindex mpretend-cmove
ddf6fe37 31282@item -mpretend-cmove
d77de738
ML
31283Prefer zero-displacement conditional branches for conditional move instruction
31284patterns. This can result in faster code on the SH4 processor.
31285
d77de738 31286@opindex fdpic
ddf6fe37 31287@item -mfdpic
d77de738
ML
31288Generate code using the FDPIC ABI.
31289
31290@end table
31291
31292@node Solaris 2 Options
31293@subsection Solaris 2 Options
31294@cindex Solaris 2 options
31295
31296These @samp{-m} options are supported on Solaris 2:
31297
31298@table @gcctabopt
d77de738 31299@opindex mclear-hwcap
ddf6fe37 31300@item -mclear-hwcap
d77de738
ML
31301@option{-mclear-hwcap} tells the compiler to remove the hardware
31302capabilities generated by the Solaris assembler. This is only necessary
31303when object files use ISA extensions not supported by the current
31304machine, but check at runtime whether or not to use them.
31305
d77de738 31306@opindex mimpure-text
ddf6fe37 31307@item -mimpure-text
d77de738
ML
31308@option{-mimpure-text}, used in addition to @option{-shared}, tells
31309the compiler to not pass @option{-z text} to the linker when linking a
31310shared object. Using this option, you can link position-dependent
31311code into a shared object.
31312
31313@option{-mimpure-text} suppresses the ``relocations remain against
31314allocatable but non-writable sections'' linker error message.
31315However, the necessary relocations trigger copy-on-write, and the
31316shared object is not actually shared across processes. Instead of
31317using @option{-mimpure-text}, you should compile all source code with
31318@option{-fpic} or @option{-fPIC}.
31319
31320@end table
31321
31322These switches are supported in addition to the above on Solaris 2:
31323
31324@table @gcctabopt
d77de738 31325@opindex pthreads
ddf6fe37 31326@item -pthreads
d77de738
ML
31327This is a synonym for @option{-pthread}.
31328@end table
31329
31330@node SPARC Options
31331@subsection SPARC Options
31332@cindex SPARC options
31333
31334These @samp{-m} options are supported on the SPARC:
31335
31336@table @gcctabopt
d77de738
ML
31337@opindex mno-app-regs
31338@opindex mapp-regs
ddf6fe37
AA
31339@item -mno-app-regs
31340@itemx -mapp-regs
d77de738
ML
31341Specify @option{-mapp-regs} to generate output using the global registers
313422 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31343global register 1, each global register 2 through 4 is then treated as an
31344allocable register that is clobbered by function calls. This is the default.
31345
31346To be fully SVR4 ABI-compliant at the cost of some performance loss,
31347specify @option{-mno-app-regs}. You should compile libraries and system
31348software with this option.
31349
d77de738
ML
31350@opindex mflat
31351@opindex mno-flat
ddf6fe37
AA
31352@item -mflat
31353@itemx -mno-flat
d77de738
ML
31354With @option{-mflat}, the compiler does not generate save/restore instructions
31355and uses a ``flat'' or single register window model. This model is compatible
31356with the regular register window model. The local registers and the input
31357registers (0--5) are still treated as ``call-saved'' registers and are
31358saved on the stack as needed.
31359
31360With @option{-mno-flat} (the default), the compiler generates save/restore
31361instructions (except for leaf functions). This is the normal operating mode.
31362
d77de738
ML
31363@opindex mfpu
31364@opindex mhard-float
ddf6fe37
AA
31365@item -mfpu
31366@itemx -mhard-float
d77de738
ML
31367Generate output containing floating-point instructions. This is the
31368default.
31369
d77de738
ML
31370@opindex mno-fpu
31371@opindex msoft-float
ddf6fe37
AA
31372@item -mno-fpu
31373@itemx -msoft-float
d77de738
ML
31374Generate output containing library calls for floating point.
31375@strong{Warning:} the requisite libraries are not available for all SPARC
31376targets. Normally the facilities of the machine's usual C compiler are
31377used, but this cannot be done directly in cross-compilation. You must make
31378your own arrangements to provide suitable library functions for
31379cross-compilation. The embedded targets @samp{sparc-*-aout} and
31380@samp{sparclite-*-*} do provide software floating-point support.
31381
31382@option{-msoft-float} changes the calling convention in the output file;
31383therefore, it is only useful if you compile @emph{all} of a program with
31384this option. In particular, you need to compile @file{libgcc.a}, the
31385library that comes with GCC, with @option{-msoft-float} in order for
31386this to work.
31387
d77de738 31388@opindex mhard-quad-float
ddf6fe37 31389@item -mhard-quad-float
d77de738
ML
31390Generate output containing quad-word (long double) floating-point
31391instructions.
31392
d77de738 31393@opindex msoft-quad-float
ddf6fe37 31394@item -msoft-quad-float
d77de738
ML
31395Generate output containing library calls for quad-word (long double)
31396floating-point instructions. The functions called are those specified
31397in the SPARC ABI@. This is the default.
31398
31399As of this writing, there are no SPARC implementations that have hardware
31400support for the quad-word floating-point instructions. They all invoke
31401a trap handler for one of these instructions, and then the trap handler
31402emulates the effect of the instruction. Because of the trap handler overhead,
31403this is much slower than calling the ABI library routines. Thus the
31404@option{-msoft-quad-float} option is the default.
31405
d77de738
ML
31406@opindex mno-unaligned-doubles
31407@opindex munaligned-doubles
ddf6fe37
AA
31408@item -mno-unaligned-doubles
31409@itemx -munaligned-doubles
d77de738
ML
31410Assume that doubles have 8-byte alignment. This is the default.
31411
31412With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31413alignment only if they are contained in another type, or if they have an
31414absolute address. Otherwise, it assumes they have 4-byte alignment.
31415Specifying this option avoids some rare compatibility problems with code
31416generated by other compilers. It is not the default because it results
31417in a performance loss, especially for floating-point code.
31418
d77de738
ML
31419@opindex muser-mode
31420@opindex mno-user-mode
ddf6fe37
AA
31421@item -muser-mode
31422@itemx -mno-user-mode
d77de738
ML
31423Do not generate code that can only run in supervisor mode. This is relevant
31424only for the @code{casa} instruction emitted for the LEON3 processor. This
31425is the default.
31426
d77de738
ML
31427@opindex mfaster-structs
31428@opindex mno-faster-structs
ddf6fe37
AA
31429@item -mfaster-structs
31430@itemx -mno-faster-structs
d77de738
ML
31431With @option{-mfaster-structs}, the compiler assumes that structures
31432should have 8-byte alignment. This enables the use of pairs of
31433@code{ldd} and @code{std} instructions for copies in structure
31434assignment, in place of twice as many @code{ld} and @code{st} pairs.
31435However, the use of this changed alignment directly violates the SPARC
31436ABI@. Thus, it's intended only for use on targets where the developer
31437acknowledges that their resulting code is not directly in line with
31438the rules of the ABI@.
31439
d77de738
ML
31440@opindex mstd-struct-return
31441@opindex mno-std-struct-return
ddf6fe37
AA
31442@item -mstd-struct-return
31443@itemx -mno-std-struct-return
d77de738
ML
31444With @option{-mstd-struct-return}, the compiler generates checking code
31445in functions returning structures or unions to detect size mismatches
31446between the two sides of function calls, as per the 32-bit ABI@.
31447
31448The default is @option{-mno-std-struct-return}. This option has no effect
31449in 64-bit mode.
31450
d77de738
ML
31451@opindex mlra
31452@opindex mno-lra
ddf6fe37
AA
31453@item -mlra
31454@itemx -mno-lra
d77de738
ML
31455Enable Local Register Allocation. This is the default for SPARC since GCC 7
31456so @option{-mno-lra} needs to be passed to get old Reload.
31457
d77de738 31458@opindex mcpu
ddf6fe37 31459@item -mcpu=@var{cpu_type}
d77de738
ML
31460Set the instruction set, register set, and instruction scheduling parameters
31461for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31462@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31463@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31464@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31465@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31466@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31467@samp{m8}.
31468
31469Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31470which selects the best architecture option for the host processor.
31471@option{-mcpu=native} has no effect if GCC does not recognize
31472the processor.
31473
31474Default instruction scheduling parameters are used for values that select
31475an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31476@samp{sparclite}, @samp{sparclet}, @samp{v9}.
31477
31478Here is a list of each supported architecture and their supported
31479implementations.
31480
31481@table @asis
31482@item v7
31483cypress, leon3v7
31484
31485@item v8
31486supersparc, hypersparc, leon, leon3, leon5
31487
31488@item sparclite
31489f930, f934, sparclite86x
31490
31491@item sparclet
31492tsc701
31493
31494@item v9
31495ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31496niagara7, m8
31497@end table
31498
31499By default (unless configured otherwise), GCC generates code for the V7
31500variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31501additionally optimizes it for the Cypress CY7C602 chip, as used in the
31502SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31503SPARCStation 1, 2, IPX etc.
31504
31505With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31506architecture. The only difference from V7 code is that the compiler emits
31507the integer multiply and integer divide instructions which exist in SPARC-V8
31508but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31509optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
315102000 series.
31511
31512With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31513the SPARC architecture. This adds the integer multiply, integer divide step
31514and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31515With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31516Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31517@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31518MB86934 chip, which is the more recent SPARClite with FPU@.
31519
31520With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31521the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31522integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31523but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31524optimizes it for the TEMIC SPARClet chip.
31525
31526With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31527architecture. This adds 64-bit integer and floating-point move instructions,
315283 additional floating-point condition code registers and conditional move
31529instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31530optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31531@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31532Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31533@option{-mcpu=niagara}, the compiler additionally optimizes it for
31534Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31535additionally optimizes it for Sun UltraSPARC T2 chips. With
31536@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
31537UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
31538additionally optimizes it for Sun UltraSPARC T4 chips. With
31539@option{-mcpu=niagara7}, the compiler additionally optimizes it for
31540Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
31541additionally optimizes it for Oracle M8 chips.
31542
d77de738 31543@opindex mtune
ddf6fe37 31544@item -mtune=@var{cpu_type}
d77de738
ML
31545Set the instruction scheduling parameters for machine type
31546@var{cpu_type}, but do not set the instruction set or register set that the
31547option @option{-mcpu=@var{cpu_type}} does.
31548
31549The same values for @option{-mcpu=@var{cpu_type}} can be used for
31550@option{-mtune=@var{cpu_type}}, but the only useful values are those
31551that select a particular CPU implementation. Those are
31552@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
31553@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
31554@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
31555@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
31556@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
31557and GNU/Linux toolchains, @samp{native} can also be used.
31558
d77de738
ML
31559@opindex mv8plus
31560@opindex mno-v8plus
ddf6fe37
AA
31561@item -mv8plus
31562@itemx -mno-v8plus
d77de738
ML
31563With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
31564difference from the V8 ABI is that the global and out registers are
31565considered 64 bits wide. This is enabled by default on Solaris in 32-bit
31566mode for all SPARC-V9 processors.
31567
d77de738
ML
31568@opindex mvis
31569@opindex mno-vis
ddf6fe37
AA
31570@item -mvis
31571@itemx -mno-vis
d77de738
ML
31572With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
31573Visual Instruction Set extensions. The default is @option{-mno-vis}.
31574
d77de738
ML
31575@opindex mvis2
31576@opindex mno-vis2
ddf6fe37
AA
31577@item -mvis2
31578@itemx -mno-vis2
d77de738
ML
31579With @option{-mvis2}, GCC generates code that takes advantage of
31580version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
31581default is @option{-mvis2} when targeting a cpu that supports such
31582instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
31583also sets @option{-mvis}.
31584
d77de738
ML
31585@opindex mvis3
31586@opindex mno-vis3
ddf6fe37
AA
31587@item -mvis3
31588@itemx -mno-vis3
d77de738
ML
31589With @option{-mvis3}, GCC generates code that takes advantage of
31590version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
31591default is @option{-mvis3} when targeting a cpu that supports such
31592instructions, such as niagara-3 and later. Setting @option{-mvis3}
31593also sets @option{-mvis2} and @option{-mvis}.
31594
d77de738
ML
31595@opindex mvis4
31596@opindex mno-vis4
ddf6fe37
AA
31597@item -mvis4
31598@itemx -mno-vis4
d77de738
ML
31599With @option{-mvis4}, GCC generates code that takes advantage of
31600version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
31601default is @option{-mvis4} when targeting a cpu that supports such
31602instructions, such as niagara-7 and later. Setting @option{-mvis4}
31603also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
31604
d77de738
ML
31605@opindex mvis4b
31606@opindex mno-vis4b
ddf6fe37
AA
31607@item -mvis4b
31608@itemx -mno-vis4b
d77de738
ML
31609With @option{-mvis4b}, GCC generates code that takes advantage of
31610version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
31611the additional VIS instructions introduced in the Oracle SPARC
31612Architecture 2017. The default is @option{-mvis4b} when targeting a
31613cpu that supports such instructions, such as m8 and later. Setting
31614@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
31615@option{-mvis2} and @option{-mvis}.
31616
d77de738
ML
31617@opindex mcbcond
31618@opindex mno-cbcond
ddf6fe37
AA
31619@item -mcbcond
31620@itemx -mno-cbcond
d77de738
ML
31621With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
31622Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
31623when targeting a CPU that supports such instructions, such as Niagara-4 and
31624later.
31625
d77de738
ML
31626@opindex mfmaf
31627@opindex mno-fmaf
ddf6fe37
AA
31628@item -mfmaf
31629@itemx -mno-fmaf
d77de738
ML
31630With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
31631Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
31632when targeting a CPU that supports such instructions, such as Niagara-3 and
31633later.
31634
d77de738
ML
31635@opindex mfsmuld
31636@opindex mno-fsmuld
ddf6fe37
AA
31637@item -mfsmuld
31638@itemx -mno-fsmuld
d77de738
ML
31639With @option{-mfsmuld}, GCC generates code that takes advantage of the
31640Floating-point Multiply Single to Double (FsMULd) instruction. The default is
31641@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
31642or V9 with FPU except @option{-mcpu=leon}.
31643
d77de738
ML
31644@opindex mpopc
31645@opindex mno-popc
ddf6fe37
AA
31646@item -mpopc
31647@itemx -mno-popc
d77de738
ML
31648With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
31649Population Count instruction. The default is @option{-mpopc}
31650when targeting a CPU that supports such an instruction, such as Niagara-2 and
31651later.
31652
d77de738
ML
31653@opindex msubxc
31654@opindex mno-subxc
ddf6fe37
AA
31655@item -msubxc
31656@itemx -mno-subxc
d77de738
ML
31657With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
31658Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
31659when targeting a CPU that supports such an instruction, such as Niagara-7 and
31660later.
31661
d77de738 31662@opindex mfix-at697f
ddf6fe37 31663@item -mfix-at697f
d77de738
ML
31664Enable the documented workaround for the single erratum of the Atmel AT697F
31665processor (which corresponds to erratum #13 of the AT697E processor).
31666
d77de738 31667@opindex mfix-ut699
ddf6fe37 31668@item -mfix-ut699
d77de738
ML
31669Enable the documented workarounds for the floating-point errata and the data
31670cache nullify errata of the UT699 processor.
31671
d77de738 31672@opindex mfix-ut700
ddf6fe37 31673@item -mfix-ut700
d77de738
ML
31674Enable the documented workaround for the back-to-back store errata of
31675the UT699E/UT700 processor.
31676
d77de738 31677@opindex mfix-gr712rc
ddf6fe37 31678@item -mfix-gr712rc
d77de738
ML
31679Enable the documented workaround for the back-to-back store errata of
31680the GR712RC processor.
31681@end table
31682
31683These @samp{-m} options are supported in addition to the above
31684on SPARC-V9 processors in 64-bit environments:
31685
31686@table @gcctabopt
d77de738
ML
31687@opindex m32
31688@opindex m64
ddf6fe37
AA
31689@item -m32
31690@itemx -m64
d77de738
ML
31691Generate code for a 32-bit or 64-bit environment.
31692The 32-bit environment sets int, long and pointer to 32 bits.
31693The 64-bit environment sets int to 32 bits and long and pointer
31694to 64 bits.
31695
d77de738 31696@opindex mcmodel
ddf6fe37 31697@item -mcmodel=@var{which}
d77de738
ML
31698Set the code model to one of
31699
31700@table @samp
31701@item medlow
31702The Medium/Low code model: 64-bit addresses, programs
31703must be linked in the low 32 bits of memory. Programs can be statically
31704or dynamically linked.
31705
31706@item medmid
31707The Medium/Middle code model: 64-bit addresses, programs
31708must be linked in the low 44 bits of memory, the text and data segments must
31709be less than 2GB in size and the data segment must be located within 2GB of
31710the text segment.
31711
31712@item medany
31713The Medium/Anywhere code model: 64-bit addresses, programs
31714may be linked anywhere in memory, the text and data segments must be less
31715than 2GB in size and the data segment must be located within 2GB of the
31716text segment.
31717
31718@item embmedany
31719The Medium/Anywhere code model for embedded systems:
3172064-bit addresses, the text and data segments must be less than 2GB in
31721size, both starting anywhere in memory (determined at link time). The
31722global register %g4 points to the base of the data segment. Programs
31723are statically linked and PIC is not supported.
31724@end table
31725
d77de738 31726@opindex mmemory-model
ddf6fe37 31727@item -mmemory-model=@var{mem-model}
d77de738
ML
31728Set the memory model in force on the processor to one of
31729
31730@table @samp
31731@item default
31732The default memory model for the processor and operating system.
31733
31734@item rmo
31735Relaxed Memory Order
31736
31737@item pso
31738Partial Store Order
31739
31740@item tso
31741Total Store Order
31742
31743@item sc
31744Sequential Consistency
31745@end table
31746
31747These memory models are formally defined in Appendix D of the SPARC-V9
31748architecture manual, as set in the processor's @code{PSTATE.MM} field.
31749
d77de738
ML
31750@opindex mstack-bias
31751@opindex mno-stack-bias
ddf6fe37
AA
31752@item -mstack-bias
31753@itemx -mno-stack-bias
d77de738
ML
31754With @option{-mstack-bias}, GCC assumes that the stack pointer, and
31755frame pointer if present, are offset by @minus{}2047 which must be added back
31756when making stack frame references. This is the default in 64-bit mode.
31757Otherwise, assume no such offset is present.
31758@end table
31759
31760@node System V Options
31761@subsection Options for System V
31762
31763These additional options are available on System V Release 4 for
31764compatibility with other compilers on those systems:
31765
31766@table @gcctabopt
d77de738 31767@opindex G
ddf6fe37 31768@item -G
d77de738
ML
31769Create a shared object.
31770It is recommended that @option{-symbolic} or @option{-shared} be used instead.
31771
d77de738 31772@opindex Qy
ddf6fe37 31773@item -Qy
d77de738
ML
31774Identify the versions of each tool used by the compiler, in a
31775@code{.ident} assembler directive in the output.
31776
d77de738 31777@opindex Qn
ddf6fe37 31778@item -Qn
d77de738
ML
31779Refrain from adding @code{.ident} directives to the output file (this is
31780the default).
31781
d77de738 31782@opindex YP
ddf6fe37 31783@item -YP,@var{dirs}
d77de738
ML
31784Search the directories @var{dirs}, and no others, for libraries
31785specified with @option{-l}.
31786
d77de738 31787@opindex Ym
ddf6fe37 31788@item -Ym,@var{dir}
d77de738
ML
31789Look in the directory @var{dir} to find the M4 preprocessor.
31790The assembler uses this option.
31791@c This is supposed to go with a -Yd for predefined M4 macro files, but
31792@c the generic assembler that comes with Solaris takes just -Ym.
31793@end table
31794
31795@node V850 Options
31796@subsection V850 Options
31797@cindex V850 Options
31798
31799These @samp{-m} options are defined for V850 implementations:
31800
31801@table @gcctabopt
d77de738
ML
31802@opindex mlong-calls
31803@opindex mno-long-calls
ddf6fe37
AA
31804@item -mlong-calls
31805@itemx -mno-long-calls
d77de738
ML
31806Treat all calls as being far away (near). If calls are assumed to be
31807far away, the compiler always loads the function's address into a
31808register, and calls indirect through the pointer.
31809
d77de738
ML
31810@opindex mno-ep
31811@opindex mep
ddf6fe37
AA
31812@item -mno-ep
31813@itemx -mep
d77de738
ML
31814Do not optimize (do optimize) basic blocks that use the same index
31815pointer 4 or more times to copy pointer into the @code{ep} register, and
31816use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
31817option is on by default if you optimize.
31818
d77de738
ML
31819@opindex mno-prolog-function
31820@opindex mprolog-function
ddf6fe37
AA
31821@item -mno-prolog-function
31822@itemx -mprolog-function
d77de738
ML
31823Do not use (do use) external functions to save and restore registers
31824at the prologue and epilogue of a function. The external functions
31825are slower, but use less code space if more than one function saves
31826the same number of registers. The @option{-mprolog-function} option
31827is on by default if you optimize.
31828
d77de738 31829@opindex mspace
ddf6fe37 31830@item -mspace
d77de738
ML
31831Try to make the code as small as possible. At present, this just turns
31832on the @option{-mep} and @option{-mprolog-function} options.
31833
d77de738 31834@opindex mtda
ddf6fe37 31835@item -mtda=@var{n}
d77de738
ML
31836Put static or global variables whose size is @var{n} bytes or less into
31837the tiny data area that register @code{ep} points to. The tiny data
31838area can hold up to 256 bytes in total (128 bytes for byte references).
31839
d77de738 31840@opindex msda
ddf6fe37 31841@item -msda=@var{n}
d77de738
ML
31842Put static or global variables whose size is @var{n} bytes or less into
31843the small data area that register @code{gp} points to. The small data
31844area can hold up to 64 kilobytes.
31845
d77de738 31846@opindex mzda
ddf6fe37 31847@item -mzda=@var{n}
d77de738
ML
31848Put static or global variables whose size is @var{n} bytes or less into
31849the first 32 kilobytes of memory.
31850
d77de738 31851@opindex mv850
ddf6fe37 31852@item -mv850
d77de738
ML
31853Specify that the target processor is the V850.
31854
d77de738 31855@opindex mv850e3v5
ddf6fe37 31856@item -mv850e3v5
d77de738
ML
31857Specify that the target processor is the V850E3V5. The preprocessor
31858constant @code{__v850e3v5__} is defined if this option is used.
31859
d77de738 31860@opindex mv850e2v4
ddf6fe37 31861@item -mv850e2v4
d77de738
ML
31862Specify that the target processor is the V850E3V5. This is an alias for
31863the @option{-mv850e3v5} option.
31864
d77de738 31865@opindex mv850e2v3
ddf6fe37 31866@item -mv850e2v3
d77de738
ML
31867Specify that the target processor is the V850E2V3. The preprocessor
31868constant @code{__v850e2v3__} is defined if this option is used.
31869
d77de738 31870@opindex mv850e2
ddf6fe37 31871@item -mv850e2
d77de738
ML
31872Specify that the target processor is the V850E2. The preprocessor
31873constant @code{__v850e2__} is defined if this option is used.
31874
d77de738 31875@opindex mv850e1
ddf6fe37 31876@item -mv850e1
d77de738
ML
31877Specify that the target processor is the V850E1. The preprocessor
31878constants @code{__v850e1__} and @code{__v850e__} are defined if
31879this option is used.
31880
d77de738 31881@opindex mv850es
ddf6fe37 31882@item -mv850es
d77de738
ML
31883Specify that the target processor is the V850ES. This is an alias for
31884the @option{-mv850e1} option.
31885
d77de738 31886@opindex mv850e
ddf6fe37 31887@item -mv850e
d77de738
ML
31888Specify that the target processor is the V850E@. The preprocessor
31889constant @code{__v850e__} is defined if this option is used.
31890
31891If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
31892nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
31893are defined then a default target processor is chosen and the
31894relevant @samp{__v850*__} preprocessor constant is defined.
31895
31896The preprocessor constants @code{__v850} and @code{__v851__} are always
31897defined, regardless of which processor variant is the target.
31898
d77de738
ML
31899@opindex mdisable-callt
31900@opindex mno-disable-callt
ddf6fe37
AA
31901@item -mdisable-callt
31902@itemx -mno-disable-callt
d77de738
ML
31903This option suppresses generation of the @code{CALLT} instruction for the
31904v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
31905architecture.
31906
31907This option is enabled by default when the RH850 ABI is
31908in use (see @option{-mrh850-abi}), and disabled by default when the
31909GCC ABI is in use. If @code{CALLT} instructions are being generated
31910then the C preprocessor symbol @code{__V850_CALLT__} is defined.
31911
d77de738
ML
31912@opindex mrelax
31913@opindex mno-relax
ddf6fe37
AA
31914@item -mrelax
31915@itemx -mno-relax
d77de738
ML
31916Pass on (or do not pass on) the @option{-mrelax} command-line option
31917to the assembler.
31918
d77de738
ML
31919@opindex mlong-jumps
31920@opindex mno-long-jumps
ddf6fe37
AA
31921@item -mlong-jumps
31922@itemx -mno-long-jumps
d77de738
ML
31923Disable (or re-enable) the generation of PC-relative jump instructions.
31924
d77de738
ML
31925@opindex msoft-float
31926@opindex mhard-float
ddf6fe37
AA
31927@item -msoft-float
31928@itemx -mhard-float
d77de738
ML
31929Disable (or re-enable) the generation of hardware floating point
31930instructions. This option is only significant when the target
31931architecture is @samp{V850E2V3} or higher. If hardware floating point
31932instructions are being generated then the C preprocessor symbol
31933@code{__FPU_OK__} is defined, otherwise the symbol
31934@code{__NO_FPU__} is defined.
31935
d77de738 31936@opindex mloop
ddf6fe37 31937@item -mloop
d77de738
ML
31938Enables the use of the e3v5 LOOP instruction. The use of this
31939instruction is not enabled by default when the e3v5 architecture is
31940selected because its use is still experimental.
31941
d77de738
ML
31942@opindex mrh850-abi
31943@opindex mghs
ddf6fe37
AA
31944@item -mrh850-abi
31945@itemx -mghs
d77de738
ML
31946Enables support for the RH850 version of the V850 ABI. This is the
31947default. With this version of the ABI the following rules apply:
31948
31949@itemize
31950@item
31951Integer sized structures and unions are returned via a memory pointer
31952rather than a register.
31953
31954@item
31955Large structures and unions (more than 8 bytes in size) are passed by
31956value.
31957
31958@item
31959Functions are aligned to 16-bit boundaries.
31960
31961@item
31962The @option{-m8byte-align} command-line option is supported.
31963
31964@item
31965The @option{-mdisable-callt} command-line option is enabled by
31966default. The @option{-mno-disable-callt} command-line option is not
31967supported.
31968@end itemize
31969
31970When this version of the ABI is enabled the C preprocessor symbol
31971@code{__V850_RH850_ABI__} is defined.
31972
d77de738 31973@opindex mgcc-abi
ddf6fe37 31974@item -mgcc-abi
d77de738
ML
31975Enables support for the old GCC version of the V850 ABI. With this
31976version of the ABI the following rules apply:
31977
31978@itemize
31979@item
31980Integer sized structures and unions are returned in register @code{r10}.
31981
31982@item
31983Large structures and unions (more than 8 bytes in size) are passed by
31984reference.
31985
31986@item
31987Functions are aligned to 32-bit boundaries, unless optimizing for
31988size.
31989
31990@item
31991The @option{-m8byte-align} command-line option is not supported.
31992
31993@item
31994The @option{-mdisable-callt} command-line option is supported but not
31995enabled by default.
31996@end itemize
31997
31998When this version of the ABI is enabled the C preprocessor symbol
31999@code{__V850_GCC_ABI__} is defined.
32000
d77de738
ML
32001@opindex m8byte-align
32002@opindex mno-8byte-align
ddf6fe37
AA
32003@item -m8byte-align
32004@itemx -mno-8byte-align
d77de738
ML
32005Enables support for @code{double} and @code{long long} types to be
32006aligned on 8-byte boundaries. The default is to restrict the
32007alignment of all objects to at most 4-bytes. When
32008@option{-m8byte-align} is in effect the C preprocessor symbol
32009@code{__V850_8BYTE_ALIGN__} is defined.
32010
d77de738 32011@opindex mbig-switch
ddf6fe37 32012@item -mbig-switch
d77de738
ML
32013Generate code suitable for big switch tables. Use this option only if
32014the assembler/linker complain about out of range branches within a switch
32015table.
32016
d77de738 32017@opindex mapp-regs
ddf6fe37 32018@item -mapp-regs
d77de738
ML
32019This option causes r2 and r5 to be used in the code generated by
32020the compiler. This setting is the default.
32021
d77de738 32022@opindex mno-app-regs
ddf6fe37 32023@item -mno-app-regs
d77de738
ML
32024This option causes r2 and r5 to be treated as fixed registers.
32025
32026@end table
32027
32028@node VAX Options
32029@subsection VAX Options
32030@cindex VAX options
32031
32032These @samp{-m} options are defined for the VAX:
32033
32034@table @gcctabopt
d77de738 32035@opindex munix
ddf6fe37 32036@item -munix
d77de738
ML
32037Do not output certain jump instructions (@code{aobleq} and so on)
32038that the Unix assembler for the VAX cannot handle across long
32039ranges.
32040
d77de738 32041@opindex mgnu
ddf6fe37 32042@item -mgnu
d77de738
ML
32043Do output those jump instructions, on the assumption that the
32044GNU assembler is being used.
32045
d77de738 32046@opindex mg
ddf6fe37 32047@item -mg
d77de738
ML
32048Output code for G-format floating-point numbers instead of D-format.
32049
d77de738
ML
32050@opindex mlra
32051@opindex mno-lra
ddf6fe37
AA
32052@item -mlra
32053@itemx -mno-lra
d77de738
ML
32054Enable Local Register Allocation. This is still experimental for the VAX,
32055so by default the compiler uses standard reload.
32056@end table
32057
32058@node Visium Options
32059@subsection Visium Options
32060@cindex Visium options
32061
32062@table @gcctabopt
32063
d77de738 32064@opindex mdebug
ddf6fe37 32065@item -mdebug
d77de738
ML
32066A program which performs file I/O and is destined to run on an MCM target
32067should be linked with this option. It causes the libraries libc.a and
32068libdebug.a to be linked. The program should be run on the target under
32069the control of the GDB remote debugging stub.
32070
d77de738 32071@opindex msim
ddf6fe37 32072@item -msim
d77de738
ML
32073A program which performs file I/O and is destined to run on the simulator
32074should be linked with option. This causes libraries libc.a and libsim.a to
32075be linked.
32076
d77de738
ML
32077@opindex mfpu
32078@opindex mhard-float
ddf6fe37
AA
32079@item -mfpu
32080@itemx -mhard-float
d77de738
ML
32081Generate code containing floating-point instructions. This is the
32082default.
32083
d77de738
ML
32084@opindex mno-fpu
32085@opindex msoft-float
ddf6fe37
AA
32086@item -mno-fpu
32087@itemx -msoft-float
d77de738
ML
32088Generate code containing library calls for floating-point.
32089
32090@option{-msoft-float} changes the calling convention in the output file;
32091therefore, it is only useful if you compile @emph{all} of a program with
32092this option. In particular, you need to compile @file{libgcc.a}, the
32093library that comes with GCC, with @option{-msoft-float} in order for
32094this to work.
32095
d77de738 32096@opindex mcpu
ddf6fe37 32097@item -mcpu=@var{cpu_type}
d77de738
ML
32098Set the instruction set, register set, and instruction scheduling parameters
32099for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
32100@samp{mcm}, @samp{gr5} and @samp{gr6}.
32101
32102@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
32103
32104By default (unless configured otherwise), GCC generates code for the GR5
32105variant of the Visium architecture.
32106
32107With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
32108architecture. The only difference from GR5 code is that the compiler will
32109generate block move instructions.
32110
d77de738 32111@opindex mtune
ddf6fe37 32112@item -mtune=@var{cpu_type}
d77de738
ML
32113Set the instruction scheduling parameters for machine type @var{cpu_type},
32114but do not set the instruction set or register set that the option
32115@option{-mcpu=@var{cpu_type}} would.
32116
d77de738 32117@opindex msv-mode
ddf6fe37 32118@item -msv-mode
d77de738
ML
32119Generate code for the supervisor mode, where there are no restrictions on
32120the access to general registers. This is the default.
32121
d77de738 32122@opindex muser-mode
ddf6fe37 32123@item -muser-mode
d77de738
ML
32124Generate code for the user mode, where the access to some general registers
32125is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
32126mode; on the GR6, only registers r29 to r31 are affected.
32127@end table
32128
32129@node VMS Options
32130@subsection VMS Options
32131
32132These @samp{-m} options are defined for the VMS implementations:
32133
32134@table @gcctabopt
d77de738 32135@opindex mvms-return-codes
ddf6fe37 32136@item -mvms-return-codes
d77de738
ML
32137Return VMS condition codes from @code{main}. The default is to return POSIX-style
32138condition (e.g.@: error) codes.
32139
d77de738 32140@opindex mdebug-main=@var{prefix}
ddf6fe37 32141@item -mdebug-main=@var{prefix}
d77de738
ML
32142Flag the first routine whose name starts with @var{prefix} as the main
32143routine for the debugger.
32144
d77de738 32145@opindex mmalloc64
ddf6fe37 32146@item -mmalloc64
d77de738
ML
32147Default to 64-bit memory allocation routines.
32148
d77de738 32149@opindex mpointer-size=@var{size}
ddf6fe37 32150@item -mpointer-size=@var{size}
d77de738
ML
32151Set the default size of pointers. Possible options for @var{size} are
32152@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
32153for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
32154The later option disables @code{pragma pointer_size}.
32155@end table
32156
32157@node VxWorks Options
32158@subsection VxWorks Options
32159@cindex VxWorks Options
32160
32161The options in this section are defined for all VxWorks targets.
32162Options specific to the target hardware are listed with the other
32163options for that target.
32164
32165@table @gcctabopt
d77de738 32166@opindex mrtp
ddf6fe37 32167@item -mrtp
d77de738
ML
32168GCC can generate code for both VxWorks kernels and real time processes
32169(RTPs). This option switches from the former to the latter. It also
32170defines the preprocessor macro @code{__RTP__}.
32171
d77de738 32172@opindex non-static
ddf6fe37 32173@item -non-static
d77de738
ML
32174Link an RTP executable against shared libraries rather than static
32175libraries. The options @option{-static} and @option{-shared} can
32176also be used for RTPs (@pxref{Link Options}); @option{-static}
32177is the default.
32178
d77de738
ML
32179@opindex Bstatic
32180@opindex Bdynamic
ddf6fe37
AA
32181@item -Bstatic
32182@itemx -Bdynamic
d77de738
ML
32183These options are passed down to the linker. They are defined for
32184compatibility with Diab.
32185
d77de738 32186@opindex Xbind-lazy
ddf6fe37 32187@item -Xbind-lazy
d77de738
ML
32188Enable lazy binding of function calls. This option is equivalent to
32189@option{-Wl,-z,now} and is defined for compatibility with Diab.
32190
d77de738 32191@opindex Xbind-now
ddf6fe37 32192@item -Xbind-now
d77de738
ML
32193Disable lazy binding of function calls. This option is the default and
32194is defined for compatibility with Diab.
32195@end table
32196
32197@node x86 Options
32198@subsection x86 Options
32199@cindex x86 Options
32200
32201These @samp{-m} options are defined for the x86 family of computers.
32202
32203@table @gcctabopt
32204
d77de738 32205@opindex march
ddf6fe37 32206@item -march=@var{cpu-type}
d77de738
ML
32207Generate instructions for the machine type @var{cpu-type}. In contrast to
32208@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32209for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32210to generate code that may not run at all on processors other than the one
32211indicated. Specifying @option{-march=@var{cpu-type}} implies
32212@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32213
32214The choices for @var{cpu-type} are:
32215
32216@table @samp
32217@item native
32218This selects the CPU to generate code for at compilation time by determining
32219the processor type of the compiling machine. Using @option{-march=native}
32220enables all instruction subsets supported by the local machine (hence
32221the result might not run on different machines). Using @option{-mtune=native}
32222produces code optimized for the local machine under the constraints
32223of the selected instruction set.
32224
32225@item x86-64
32226A generic CPU with 64-bit extensions.
32227
32228@item x86-64-v2
32229@itemx x86-64-v3
32230@itemx x86-64-v4
32231These choices for @var{cpu-type} select the corresponding
32232micro-architecture level from the x86-64 psABI. On ABIs other than
32233the x86-64 psABI they select the same CPU features as the x86-64 psABI
32234documents for the particular micro-architecture level.
32235
32236Since these @var{cpu-type} values do not have a corresponding
32237@option{-mtune} setting, using @option{-march} with these values enables
32238generic tuning. Specific tuning can be enabled using the
32239@option{-mtune=@var{other-cpu-type}} option with an appropriate
32240@var{other-cpu-type} value.
32241
32242@item i386
32243Original Intel i386 CPU@.
32244
32245@item i486
32246Intel i486 CPU@. (No scheduling is implemented for this chip.)
32247
32248@item i586
32249@itemx pentium
32250Intel Pentium CPU with no MMX support.
32251
32252@item lakemont
32253Intel Lakemont MCU, based on Intel Pentium CPU.
32254
32255@item pentium-mmx
32256Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32257
32258@item pentiumpro
32259Intel Pentium Pro CPU@.
32260
32261@item i686
32262When used with @option{-march}, the Pentium Pro
32263instruction set is used, so the code runs on all i686 family chips.
32264When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32265
32266@item pentium2
32267Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32268set support.
32269
32270@item pentium3
32271@itemx pentium3m
32272Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32273instruction set support.
32274
32275@item pentium-m
32276Intel Pentium M; low-power version of Intel Pentium III CPU
32277with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32278notebooks.
32279
32280@item pentium4
32281@itemx pentium4m
32282Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32283
32284@item prescott
32285Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32286instruction set support.
32287
32288@item nocona
32289Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32290SSE2, SSE3 and FXSR instruction set support.
32291
32292@item core2
32293Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32294SAHF and FXSR instruction set support.
32295
32296@item nehalem
32297Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32298SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32299
32300@item westmere
32301Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32302SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32303
32304@item sandybridge
32305Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32306SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32307support.
32308
32309@item ivybridge
32310Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32311SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32312and F16C instruction set support.
32313
32314@item haswell
32315Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32316SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32317F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32318
32319@item broadwell
32320Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32321SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32322F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32323instruction set support.
32324
32325@item skylake
32326Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32327SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32328F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32329CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32330
32331@item bonnell
32332Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32333instruction set support.
32334
32335@item silvermont
32336Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32337SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32338instruction set support.
32339
32340@item goldmont
32341Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32342SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32343RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32344set support.
32345
32346@item goldmont-plus
32347Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32348SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32349SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32350RDPID and SGX instruction set support.
32351
32352@item tremont
32353Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32354SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32355RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32356SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32357support.
32358
32359@item sierraforest
32360Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32361SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32362XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32363MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32364PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32365AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32366
32367@item grandridge
32368Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32369SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32370XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32371MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32372PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32373AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set
32374support.
32375
32376@item knl
32377Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32378SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32379RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32380AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32381
32382@item knm
32383Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32384SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32385RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32386AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32387AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32388
32389@item skylake-avx512
32390Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32391SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32392RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32393AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32394AVX512DQ and AVX512CD instruction set support.
32395
32396@item cannonlake
32397Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32398SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32399FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32400PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32401AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32402support.
32403
32404@item icelake-client
32405Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32406SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32407RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32408AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32409AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32410, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32411
32412@item icelake-server
32413Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32414SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32415RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32416AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32417AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32418, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32419instruction set support.
32420
32421@item cascadelake
32422Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32423SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32424F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32425CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32426AVX512CD and AVX512VNNI instruction set support.
32427
32428@item cooperlake
32429Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32430SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32431F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32432CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32433AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32434
32435@item tigerlake
32436Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32437SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32438F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32439CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32440PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32441VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32442AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32443
32444@item sapphirerapids
32445Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32446SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32447RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32448AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32449AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32450VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32451MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
29ecb952 32452UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16
d77de738
ML
32453instruction set support.
32454
32455@item alderlake
32456Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32457SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32458XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32459CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32460VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32461support.
32462
32463@item rocketlake
32464Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32465, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32466F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32467CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32468PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32469VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32470
32471@item graniterapids
32472Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32473SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32474RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32475AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32476AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32477VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32478MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
29ecb952 32479SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16,
d77de738
ML
32480AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
32481
32482@item k6
32483AMD K6 CPU with MMX instruction set support.
32484
32485@item k6-2
32486@itemx k6-3
32487Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
32488
32489@item athlon
32490@itemx athlon-tbird
32491AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
32492support.
32493
32494@item athlon-4
32495@itemx athlon-xp
32496@itemx athlon-mp
32497Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
32498instruction set support.
32499
32500@item k8
32501@itemx opteron
32502@itemx athlon64
32503@itemx athlon-fx
32504Processors based on the AMD K8 core with x86-64 instruction set support,
32505including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
32506(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
32507instruction set extensions.)
32508
32509@item k8-sse3
32510@itemx opteron-sse3
32511@itemx athlon64-sse3
32512Improved versions of AMD K8 cores with SSE3 instruction set support.
32513
32514@item amdfam10
32515@itemx barcelona
32516CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
32517supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
32518instruction set extensions.)
32519
32520@item bdver1
32521CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
32522supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
32523SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
32524
32525@item bdver2
32526AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32527supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
32528SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
32529extensions.)
32530
32531@item bdver3
32532AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32533supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
32534PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3253564-bit instruction set extensions.)
32536
32537@item bdver4
32538AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32539supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
32540AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
32541SSE4.2, ABM and 64-bit instruction set extensions.)
32542
32543@item znver1
32544AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32545supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
32546SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
32547SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
32548instruction set extensions.)
32549
32550@item znver2
32551AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32552supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32553MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32554SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32555WBNOINVD, and 64-bit instruction set extensions.)
32556
32557@item znver3
32558AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32559supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32560MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32561SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32562WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
32563
32564@item znver4
32565AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32566supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32567MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32568SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32569WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
32570AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
32571AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
32572
32573@item btver1
32574CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
32575supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
32576instruction set extensions.)
32577
32578@item btver2
32579CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
32580includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
32581SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
32582
32583@item winchip-c6
32584IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
32585set support.
32586
32587@item winchip2
32588IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
32589instruction set support.
32590
32591@item c3
32592VIA C3 CPU with MMX and 3DNow!@: instruction set support.
32593(No scheduling is implemented for this chip.)
32594
32595@item c3-2
32596VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
32597(No scheduling is implemented for this chip.)
32598
32599@item c7
32600VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32601(No scheduling is implemented for this chip.)
32602
32603@item samuel-2
32604VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
32605(No scheduling is implemented for this chip.)
32606
32607@item nehemiah
32608VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
32609(No scheduling is implemented for this chip.)
32610
32611@item esther
32612VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32613(No scheduling is implemented for this chip.)
32614
32615@item eden-x2
32616VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
32617(No scheduling is implemented for this chip.)
32618
32619@item eden-x4
32620VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
32621AVX and AVX2 instruction set support.
32622(No scheduling is implemented for this chip.)
32623
32624@item nano
32625Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32626instruction set support.
32627(No scheduling is implemented for this chip.)
32628
32629@item nano-1000
32630VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32631instruction set support.
32632(No scheduling is implemented for this chip.)
32633
32634@item nano-2000
32635VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32636instruction set support.
32637(No scheduling is implemented for this chip.)
32638
32639@item nano-3000
32640VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32641instruction set support.
32642(No scheduling is implemented for this chip.)
32643
32644@item nano-x2
32645VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32646instruction set support.
32647(No scheduling is implemented for this chip.)
32648
32649@item nano-x4
32650VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32651instruction set support.
32652(No scheduling is implemented for this chip.)
32653
32654@item lujiazui
32655ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
32656SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
32657ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
32658
32659@item geode
32660AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
32661@end table
32662
d77de738 32663@opindex mtune
ddf6fe37 32664@item -mtune=@var{cpu-type}
d77de738
ML
32665Tune to @var{cpu-type} everything applicable about the generated code, except
32666for the ABI and the set of available instructions.
32667While picking a specific @var{cpu-type} schedules things appropriately
32668for that particular chip, the compiler does not generate any code that
32669cannot run on the default machine type unless you use a
32670@option{-march=@var{cpu-type}} option.
32671For example, if GCC is configured for i686-pc-linux-gnu
32672then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
32673but still runs on i686 machines.
32674
32675The choices for @var{cpu-type} are the same as for @option{-march}.
32676In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
32677
32678@table @samp
32679@item generic
32680Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
32681If you know the CPU on which your code will run, then you should use
32682the corresponding @option{-mtune} or @option{-march} option instead of
32683@option{-mtune=generic}. But, if you do not know exactly what CPU users
32684of your application will have, then you should use this option.
32685
32686As new processors are deployed in the marketplace, the behavior of this
32687option will change. Therefore, if you upgrade to a newer version of
32688GCC, code generation controlled by this option will change to reflect
32689the processors
32690that are most common at the time that version of GCC is released.
32691
32692There is no @option{-march=generic} option because @option{-march}
32693indicates the instruction set the compiler can use, and there is no
32694generic instruction set applicable to all processors. In contrast,
32695@option{-mtune} indicates the processor (or, in this case, collection of
32696processors) for which the code is optimized.
32697
32698@item intel
32699Produce code optimized for the most current Intel processors, which are
32700Haswell and Silvermont for this version of GCC. If you know the CPU
32701on which your code will run, then you should use the corresponding
32702@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
32703But, if you want your application performs better on both Haswell and
32704Silvermont, then you should use this option.
32705
32706As new Intel processors are deployed in the marketplace, the behavior of
32707this option will change. Therefore, if you upgrade to a newer version of
32708GCC, code generation controlled by this option will change to reflect
32709the most current Intel processors at the time that version of GCC is
32710released.
32711
32712There is no @option{-march=intel} option because @option{-march} indicates
32713the instruction set the compiler can use, and there is no common
32714instruction set applicable to all processors. In contrast,
32715@option{-mtune} indicates the processor (or, in this case, collection of
32716processors) for which the code is optimized.
32717@end table
32718
d77de738 32719@opindex mcpu
ddf6fe37 32720@item -mcpu=@var{cpu-type}
d77de738
ML
32721A deprecated synonym for @option{-mtune}.
32722
d77de738 32723@opindex mfpmath
ddf6fe37 32724@item -mfpmath=@var{unit}
d77de738
ML
32725Generate floating-point arithmetic for selected unit @var{unit}. The choices
32726for @var{unit} are:
32727
32728@table @samp
32729@item 387
32730Use the standard 387 floating-point coprocessor present on the majority of chips and
32731emulated otherwise. Code compiled with this option runs almost everywhere.
32732The temporary results are computed in 80-bit precision instead of the precision
32733specified by the type, resulting in slightly different results compared to most
32734of other chips. See @option{-ffloat-store} for more detailed description.
32735
32736This is the default choice for non-Darwin x86-32 targets.
32737
32738@item sse
32739Use scalar floating-point instructions present in the SSE instruction set.
32740This instruction set is supported by Pentium III and newer chips,
32741and in the AMD line
32742by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
32743instruction set supports only single-precision arithmetic, thus the double and
32744extended-precision arithmetic are still done using 387. A later version, present
32745only in Pentium 4 and AMD x86-64 chips, supports double-precision
32746arithmetic too.
32747
32748For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
32749or @option{-msse2} switches to enable SSE extensions and make this option
32750effective. For the x86-64 compiler, these extensions are enabled by default.
32751
32752The resulting code should be considerably faster in the majority of cases and avoid
32753the numerical instability problems of 387 code, but may break some existing
32754code that expects temporaries to be 80 bits.
32755
32756This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
32757and the default choice for x86-32 targets with the SSE2 instruction set
32758when @option{-ffast-math} is enabled.
32759
32760@item sse,387
32761@itemx sse+387
32762@itemx both
32763Attempt to utilize both instruction sets at once. This effectively doubles the
32764amount of available registers, and on chips with separate execution units for
32765387 and SSE the execution resources too. Use this option with care, as it is
32766still experimental, because the GCC register allocator does not model separate
32767functional units well, resulting in unstable performance.
32768@end table
32769
d77de738 32770@opindex masm=@var{dialect}
ddf6fe37 32771@item -masm=@var{dialect}
d77de738
ML
32772Output assembly instructions using selected @var{dialect}. Also affects
32773which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
32774extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
32775order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
32776not support @samp{intel}.
32777
d77de738
ML
32778@opindex mieee-fp
32779@opindex mno-ieee-fp
ddf6fe37
AA
32780@item -mieee-fp
32781@itemx -mno-ieee-fp
d77de738
ML
32782Control whether or not the compiler uses IEEE floating-point
32783comparisons. These correctly handle the case where the result of a
32784comparison is unordered.
32785
30348d30 32786@opindex m80387
d77de738 32787@opindex mhard-float
ddf6fe37
AA
32788@item -m80387
32789@itemx -mhard-float
d77de738
ML
32790Generate output containing 80387 instructions for floating point.
32791
d77de738
ML
32792@opindex no-80387
32793@opindex msoft-float
ddf6fe37
AA
32794@item -mno-80387
32795@itemx -msoft-float
d77de738
ML
32796Generate output containing library calls for floating point.
32797
32798@strong{Warning:} the requisite libraries are not part of GCC@.
32799Normally the facilities of the machine's usual C compiler are used, but
32800this cannot be done directly in cross-compilation. You must make your
32801own arrangements to provide suitable library functions for
32802cross-compilation.
32803
32804On machines where a function returns floating-point results in the 80387
32805register stack, some floating-point opcodes may be emitted even if
32806@option{-msoft-float} is used.
32807
d77de738
ML
32808@opindex mno-fp-ret-in-387
32809@opindex mfp-ret-in-387
ddf6fe37 32810@item -mno-fp-ret-in-387
d77de738
ML
32811Do not use the FPU registers for return values of functions.
32812
32813The usual calling convention has functions return values of types
32814@code{float} and @code{double} in an FPU register, even if there
32815is no FPU@. The idea is that the operating system should emulate
32816an FPU@.
32817
32818The option @option{-mno-fp-ret-in-387} causes such values to be returned
32819in ordinary CPU registers instead.
32820
d77de738
ML
32821@opindex mno-fancy-math-387
32822@opindex mfancy-math-387
ddf6fe37 32823@item -mno-fancy-math-387
d77de738
ML
32824Some 387 emulators do not support the @code{sin}, @code{cos} and
32825@code{sqrt} instructions for the 387. Specify this option to avoid
32826generating those instructions.
32827This option is overridden when @option{-march}
32828indicates that the target CPU always has an FPU and so the
32829instruction does not need emulation. These
32830instructions are not generated unless you also use the
32831@option{-funsafe-math-optimizations} switch.
32832
d77de738
ML
32833@opindex malign-double
32834@opindex mno-align-double
ddf6fe37
AA
32835@item -malign-double
32836@itemx -mno-align-double
d77de738
ML
32837Control whether GCC aligns @code{double}, @code{long double}, and
32838@code{long long} variables on a two-word boundary or a one-word
32839boundary. Aligning @code{double} variables on a two-word boundary
32840produces code that runs somewhat faster on a Pentium at the
32841expense of more memory.
32842
32843On x86-64, @option{-malign-double} is enabled by default.
32844
32845@strong{Warning:} if you use the @option{-malign-double} switch,
32846structures containing the above types are aligned differently than
32847the published application binary interface specifications for the x86-32
32848and are not binary compatible with structures in code compiled
32849without that switch.
32850
d77de738
ML
32851@opindex m96bit-long-double
32852@opindex m128bit-long-double
ddf6fe37
AA
32853@item -m96bit-long-double
32854@itemx -m128bit-long-double
d77de738
ML
32855These switches control the size of @code{long double} type. The x86-32
32856application binary interface specifies the size to be 96 bits,
32857so @option{-m96bit-long-double} is the default in 32-bit mode.
32858
32859Modern architectures (Pentium and newer) prefer @code{long double}
32860to be aligned to an 8- or 16-byte boundary. In arrays or structures
32861conforming to the ABI, this is not possible. So specifying
32862@option{-m128bit-long-double} aligns @code{long double}
32863to a 16-byte boundary by padding the @code{long double} with an additional
3286432-bit zero.
32865
32866In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
32867its ABI specifies that @code{long double} is aligned on 16-byte boundary.
32868
32869Notice that neither of these options enable any extra precision over the x87
32870standard of 80 bits for a @code{long double}.
32871
32872@strong{Warning:} if you override the default value for your target ABI, this
32873changes the size of
32874structures and arrays containing @code{long double} variables,
32875as well as modifying the function calling convention for functions taking
32876@code{long double}. Hence they are not binary-compatible
32877with code compiled without that switch.
32878
d77de738
ML
32879@opindex mlong-double-64
32880@opindex mlong-double-80
32881@opindex mlong-double-128
ddf6fe37
AA
32882@item -mlong-double-64
32883@itemx -mlong-double-80
32884@itemx -mlong-double-128
d77de738
ML
32885These switches control the size of @code{long double} type. A size
32886of 64 bits makes the @code{long double} type equivalent to the @code{double}
32887type. This is the default for 32-bit Bionic C library. A size
32888of 128 bits makes the @code{long double} type equivalent to the
32889@code{__float128} type. This is the default for 64-bit Bionic C library.
32890
32891@strong{Warning:} if you override the default value for your target ABI, this
32892changes the size of
32893structures and arrays containing @code{long double} variables,
32894as well as modifying the function calling convention for functions taking
32895@code{long double}. Hence they are not binary-compatible
32896with code compiled without that switch.
32897
d77de738 32898@opindex malign-data
ddf6fe37 32899@item -malign-data=@var{type}
d77de738
ML
32900Control how GCC aligns variables. Supported values for @var{type} are
32901@samp{compat} uses increased alignment value compatible uses GCC 4.8
32902and earlier, @samp{abi} uses alignment value as specified by the
32903psABI, and @samp{cacheline} uses increased alignment value to match
32904the cache line size. @samp{compat} is the default.
32905
d77de738 32906@opindex mlarge-data-threshold
ddf6fe37 32907@item -mlarge-data-threshold=@var{threshold}
d77de738
ML
32908When @option{-mcmodel=medium} is specified, data objects larger than
32909@var{threshold} are placed in the large data section. This value must be the
32910same across all objects linked into the binary, and defaults to 65535.
32911
d77de738 32912@opindex mrtd
ddf6fe37 32913@item -mrtd
d77de738
ML
32914Use a different function-calling convention, in which functions that
32915take a fixed number of arguments return with the @code{ret @var{num}}
32916instruction, which pops their arguments while returning. This saves one
32917instruction in the caller since there is no need to pop the arguments
32918there.
32919
32920You can specify that an individual function is called with this calling
32921sequence with the function attribute @code{stdcall}. You can also
32922override the @option{-mrtd} option by using the function attribute
32923@code{cdecl}. @xref{Function Attributes}.
32924
32925@strong{Warning:} this calling convention is incompatible with the one
32926normally used on Unix, so you cannot use it if you need to call
32927libraries compiled with the Unix compiler.
32928
32929Also, you must provide function prototypes for all functions that
32930take variable numbers of arguments (including @code{printf});
32931otherwise incorrect code is generated for calls to those
32932functions.
32933
32934In addition, seriously incorrect code results if you call a
32935function with too many arguments. (Normally, extra arguments are
32936harmlessly ignored.)
32937
d77de738 32938@opindex mregparm
ddf6fe37 32939@item -mregparm=@var{num}
d77de738
ML
32940Control how many registers are used to pass integer arguments. By
32941default, no registers are used to pass arguments, and at most 3
32942registers can be used. You can control this behavior for a specific
32943function by using the function attribute @code{regparm}.
32944@xref{Function Attributes}.
32945
32946@strong{Warning:} if you use this switch, and
32947@var{num} is nonzero, then you must build all modules with the same
32948value, including any libraries. This includes the system libraries and
32949startup modules.
32950
d77de738 32951@opindex msseregparm
ddf6fe37 32952@item -msseregparm
d77de738
ML
32953Use SSE register passing conventions for float and double arguments
32954and return values. You can control this behavior for a specific
32955function by using the function attribute @code{sseregparm}.
32956@xref{Function Attributes}.
32957
32958@strong{Warning:} if you use this switch then you must build all
32959modules with the same value, including any libraries. This includes
32960the system libraries and startup modules.
32961
d77de738 32962@opindex mvect8-ret-in-mem
ddf6fe37 32963@item -mvect8-ret-in-mem
d77de738
ML
32964Return 8-byte vectors in memory instead of MMX registers. This is the
32965default on VxWorks to match the ABI of the Sun Studio compilers until
32966version 12. @emph{Only} use this option if you need to remain
32967compatible with existing code produced by those previous compiler
32968versions or older versions of GCC@.
32969
d77de738
ML
32970@opindex mpc32
32971@opindex mpc64
32972@opindex mpc80
ddf6fe37
AA
32973@item -mpc32
32974@itemx -mpc64
32975@itemx -mpc80
d77de738
ML
32976
32977Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
32978is specified, the significands of results of floating-point operations are
32979rounded to 24 bits (single precision); @option{-mpc64} rounds the
32980significands of results of floating-point operations to 53 bits (double
32981precision) and @option{-mpc80} rounds the significands of results of
32982floating-point operations to 64 bits (extended double precision), which is
32983the default. When this option is used, floating-point operations in higher
32984precisions are not available to the programmer without setting the FPU
32985control word explicitly.
32986
32987Setting the rounding of floating-point operations to less than the default
3298880 bits can speed some programs by 2% or more. Note that some mathematical
32989libraries assume that extended-precision (80-bit) floating-point operations
32990are enabled by default; routines in such libraries could suffer significant
32991loss of accuracy, typically through so-called ``catastrophic cancellation'',
32992when this option is used to set the precision to less than extended precision.
32993
e54375d8 32994@opindex mdaz-ftz
ddf6fe37 32995@item -mdaz-ftz
e54375d8 32996
32997The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
32998are used to control floating-point calculations.SSE and AVX instructions
32999including scalar and vector instructions could benefit from enabling the FTZ
33000and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
33001when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
33002will set FTZ/DAZ flags even with @option{-shared}.
33003
d77de738 33004@opindex mstackrealign
ddf6fe37 33005@item -mstackrealign
d77de738
ML
33006Realign the stack at entry. On the x86, the @option{-mstackrealign}
33007option generates an alternate prologue and epilogue that realigns the
33008run-time stack if necessary. This supports mixing legacy codes that keep
330094-byte stack alignment with modern codes that keep 16-byte stack alignment for
33010SSE compatibility. See also the attribute @code{force_align_arg_pointer},
33011applicable to individual functions.
33012
d77de738 33013@opindex mpreferred-stack-boundary
ddf6fe37 33014@item -mpreferred-stack-boundary=@var{num}
d77de738
ML
33015Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
33016byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
33017the default is 4 (16 bytes or 128 bits).
33018
33019@strong{Warning:} When generating code for the x86-64 architecture with
33020SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
33021used to keep the stack boundary aligned to 8 byte boundary. Since
33022x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
33023intended to be used in controlled environment where stack space is
33024important limitation. This option leads to wrong code when functions
33025compiled with 16 byte stack alignment (such as functions from a standard
33026library) are called with misaligned stack. In this case, SSE
33027instructions may lead to misaligned memory access traps. In addition,
33028variable arguments are handled incorrectly for 16 byte aligned
33029objects (including x87 long double and __int128), leading to wrong
33030results. You must build all modules with
33031@option{-mpreferred-stack-boundary=3}, including any libraries. This
33032includes the system libraries and startup modules.
33033
d77de738 33034@opindex mincoming-stack-boundary
ddf6fe37 33035@item -mincoming-stack-boundary=@var{num}
d77de738
ML
33036Assume the incoming stack is aligned to a 2 raised to @var{num} byte
33037boundary. If @option{-mincoming-stack-boundary} is not specified,
33038the one specified by @option{-mpreferred-stack-boundary} is used.
33039
33040On Pentium and Pentium Pro, @code{double} and @code{long double} values
33041should be aligned to an 8-byte boundary (see @option{-malign-double}) or
33042suffer significant run time performance penalties. On Pentium III, the
33043Streaming SIMD Extension (SSE) data type @code{__m128} may not work
33044properly if it is not 16-byte aligned.
33045
33046To ensure proper alignment of this values on the stack, the stack boundary
33047must be as aligned as that required by any value stored on the stack.
33048Further, every function must be generated such that it keeps the stack
33049aligned. Thus calling a function compiled with a higher preferred
33050stack boundary from a function compiled with a lower preferred stack
33051boundary most likely misaligns the stack. It is recommended that
33052libraries that use callbacks always use the default setting.
33053
33054This extra alignment does consume extra stack space, and generally
33055increases code size. Code that is sensitive to stack space usage, such
33056as embedded systems and operating system kernels, may want to reduce the
33057preferred alignment to @option{-mpreferred-stack-boundary=2}.
33058
33059@need 200
d77de738 33060@opindex mmmx
ddf6fe37 33061@item -mmmx
d77de738 33062@need 200
d77de738 33063@opindex msse
ddf6fe37 33064@itemx -msse
d77de738 33065@need 200
d77de738 33066@opindex msse2
ddf6fe37 33067@itemx -msse2
d77de738 33068@need 200
d77de738 33069@opindex msse3
ddf6fe37 33070@itemx -msse3
d77de738 33071@need 200
d77de738 33072@opindex mssse3
ddf6fe37 33073@itemx -mssse3
d77de738 33074@need 200
d77de738 33075@opindex msse4
ddf6fe37 33076@itemx -msse4
d77de738 33077@need 200
d77de738 33078@opindex msse4a
ddf6fe37 33079@itemx -msse4a
d77de738 33080@need 200
d77de738 33081@opindex msse4.1
ddf6fe37 33082@itemx -msse4.1
d77de738 33083@need 200
d77de738 33084@opindex msse4.2
ddf6fe37 33085@itemx -msse4.2
d77de738 33086@need 200
d77de738 33087@opindex mavx
ddf6fe37 33088@itemx -mavx
d77de738 33089@need 200
d77de738 33090@opindex mavx2
ddf6fe37 33091@itemx -mavx2
d77de738 33092@need 200
d77de738 33093@opindex mavx512f
ddf6fe37 33094@itemx -mavx512f
d77de738 33095@need 200
d77de738 33096@opindex mavx512pf
ddf6fe37 33097@itemx -mavx512pf
d77de738 33098@need 200
d77de738 33099@opindex mavx512er
ddf6fe37 33100@itemx -mavx512er
d77de738 33101@need 200
d77de738 33102@opindex mavx512cd
ddf6fe37 33103@itemx -mavx512cd
d77de738 33104@need 200
d77de738 33105@opindex mavx512vl
ddf6fe37 33106@itemx -mavx512vl
d77de738 33107@need 200
d77de738 33108@opindex mavx512bw
ddf6fe37 33109@itemx -mavx512bw
d77de738 33110@need 200
d77de738 33111@opindex mavx512dq
ddf6fe37 33112@itemx -mavx512dq
d77de738 33113@need 200
d77de738 33114@opindex mavx512ifma
ddf6fe37 33115@itemx -mavx512ifma
d77de738 33116@need 200
d77de738 33117@opindex mavx512vbmi
ddf6fe37 33118@itemx -mavx512vbmi
d77de738 33119@need 200
d77de738 33120@opindex msha
ddf6fe37 33121@itemx -msha
d77de738 33122@need 200
d77de738 33123@opindex maes
ddf6fe37 33124@itemx -maes
d77de738 33125@need 200
d77de738 33126@opindex mpclmul
ddf6fe37 33127@itemx -mpclmul
d77de738 33128@need 200
d77de738 33129@opindex mclflushopt
ddf6fe37 33130@itemx -mclflushopt
d77de738 33131@need 200
d77de738 33132@opindex mclwb
ddf6fe37 33133@itemx -mclwb
d77de738 33134@need 200
d77de738 33135@opindex mfsgsbase
ddf6fe37 33136@itemx -mfsgsbase
d77de738 33137@need 200
d77de738 33138@opindex mptwrite
ddf6fe37 33139@itemx -mptwrite
d77de738 33140@need 200
d77de738 33141@opindex mrdrnd
ddf6fe37 33142@itemx -mrdrnd
d77de738 33143@need 200
d77de738 33144@opindex mf16c
ddf6fe37 33145@itemx -mf16c
d77de738 33146@need 200
d77de738 33147@opindex mfma
ddf6fe37 33148@itemx -mfma
d77de738 33149@need 200
d77de738 33150@opindex mpconfig
ddf6fe37 33151@itemx -mpconfig
d77de738 33152@need 200
d77de738 33153@opindex mwbnoinvd
ddf6fe37 33154@itemx -mwbnoinvd
d77de738 33155@need 200
d77de738 33156@opindex mfma4
ddf6fe37 33157@itemx -mfma4
d77de738 33158@need 200
d77de738 33159@opindex mprfchw
ddf6fe37 33160@itemx -mprfchw
d77de738 33161@need 200
d77de738 33162@opindex mrdpid
ddf6fe37 33163@itemx -mrdpid
d77de738 33164@need 200
d77de738 33165@opindex mprefetchwt1
ddf6fe37 33166@itemx -mprefetchwt1
d77de738 33167@need 200
d77de738 33168@opindex mrdseed
ddf6fe37 33169@itemx -mrdseed
d77de738 33170@need 200
d77de738 33171@opindex msgx
ddf6fe37 33172@itemx -msgx
d77de738 33173@need 200
d77de738 33174@opindex mxop
ddf6fe37 33175@itemx -mxop
d77de738 33176@need 200
d77de738 33177@opindex mlwp
ddf6fe37 33178@itemx -mlwp
d77de738 33179@need 200
d77de738 33180@opindex m3dnow
ddf6fe37 33181@itemx -m3dnow
d77de738 33182@need 200
d77de738 33183@opindex m3dnowa
ddf6fe37 33184@itemx -m3dnowa
d77de738 33185@need 200
d77de738 33186@opindex mpopcnt
ddf6fe37 33187@itemx -mpopcnt
d77de738 33188@need 200
d77de738 33189@opindex mabm
ddf6fe37 33190@itemx -mabm
d77de738 33191@need 200
d77de738 33192@opindex madx
ddf6fe37 33193@itemx -madx
d77de738 33194@need 200
d77de738 33195@opindex mbmi
ddf6fe37 33196@itemx -mbmi
d77de738 33197@need 200
d77de738 33198@opindex mbmi2
ddf6fe37 33199@itemx -mbmi2
d77de738 33200@need 200
d77de738 33201@opindex mlzcnt
ddf6fe37 33202@itemx -mlzcnt
d77de738 33203@need 200
d77de738 33204@opindex mfxsr
ddf6fe37 33205@itemx -mfxsr
d77de738 33206@need 200
d77de738 33207@opindex mxsave
ddf6fe37 33208@itemx -mxsave
d77de738 33209@need 200
d77de738 33210@opindex mxsaveopt
ddf6fe37 33211@itemx -mxsaveopt
d77de738 33212@need 200
d77de738 33213@opindex mxsavec
ddf6fe37 33214@itemx -mxsavec
d77de738 33215@need 200
d77de738 33216@opindex mxsaves
ddf6fe37 33217@itemx -mxsaves
d77de738 33218@need 200
d77de738 33219@opindex mrtm
ddf6fe37 33220@itemx -mrtm
d77de738 33221@need 200
d77de738 33222@opindex mhle
ddf6fe37 33223@itemx -mhle
d77de738 33224@need 200
d77de738 33225@opindex mtbm
ddf6fe37 33226@itemx -mtbm
d77de738 33227@need 200
d77de738 33228@opindex mmwaitx
ddf6fe37 33229@itemx -mmwaitx
d77de738 33230@need 200
d77de738 33231@opindex mclzero
ddf6fe37 33232@itemx -mclzero
d77de738 33233@need 200
d77de738 33234@opindex mpku
ddf6fe37 33235@itemx -mpku
d77de738 33236@need 200
d77de738 33237@opindex mavx512vbmi2
ddf6fe37 33238@itemx -mavx512vbmi2
d77de738 33239@need 200
d77de738 33240@opindex mavx512bf16
ddf6fe37 33241@itemx -mavx512bf16
d77de738 33242@need 200
d77de738 33243@opindex mavx512fp16
ddf6fe37 33244@itemx -mavx512fp16
d77de738 33245@need 200
d77de738 33246@opindex mgfni
ddf6fe37 33247@itemx -mgfni
d77de738 33248@need 200
d77de738 33249@opindex mvaes
ddf6fe37 33250@itemx -mvaes
d77de738 33251@need 200
d77de738 33252@opindex mwaitpkg
ddf6fe37 33253@itemx -mwaitpkg
d77de738 33254@need 200
d77de738 33255@opindex mvpclmulqdq
ddf6fe37 33256@itemx -mvpclmulqdq
d77de738 33257@need 200
d77de738 33258@opindex mavx512bitalg
ddf6fe37 33259@itemx -mavx512bitalg
d77de738 33260@need 200
d77de738 33261@opindex mmovdiri
ddf6fe37 33262@itemx -mmovdiri
d77de738 33263@need 200
d77de738 33264@opindex mmovdir64b
ddf6fe37 33265@itemx -mmovdir64b
d77de738 33266@need 200
d77de738 33267@opindex menqcmd
d77de738 33268@opindex muintr
ddf6fe37
AA
33269@itemx -menqcmd
33270@itemx -muintr
d77de738 33271@need 200
d77de738 33272@opindex mtsxldtrk
ddf6fe37 33273@itemx -mtsxldtrk
d77de738 33274@need 200
d77de738 33275@opindex mavx512vpopcntdq
ddf6fe37 33276@itemx -mavx512vpopcntdq
d77de738 33277@need 200
d77de738 33278@opindex mavx512vp2intersect
ddf6fe37 33279@itemx -mavx512vp2intersect
d77de738 33280@need 200
d77de738 33281@opindex mavx5124fmaps
ddf6fe37 33282@itemx -mavx5124fmaps
d77de738 33283@need 200
d77de738 33284@opindex mavx512vnni
ddf6fe37 33285@itemx -mavx512vnni
d77de738 33286@need 200
d77de738 33287@opindex mavxvnni
ddf6fe37 33288@itemx -mavxvnni
d77de738 33289@need 200
d77de738 33290@opindex mavx5124vnniw
ddf6fe37 33291@itemx -mavx5124vnniw
d77de738 33292@need 200
d77de738 33293@opindex mcldemote
ddf6fe37 33294@itemx -mcldemote
d77de738 33295@need 200
d77de738 33296@opindex mserialize
ddf6fe37 33297@itemx -mserialize
d77de738 33298@need 200
d77de738 33299@opindex mamx-tile
ddf6fe37 33300@itemx -mamx-tile
d77de738 33301@need 200
d77de738 33302@opindex mamx-int8
ddf6fe37 33303@itemx -mamx-int8
d77de738 33304@need 200
d77de738 33305@opindex mamx-bf16
ddf6fe37 33306@itemx -mamx-bf16
d77de738 33307@need 200
d77de738 33308@opindex mhreset
d77de738 33309@opindex mkl
ddf6fe37
AA
33310@itemx -mhreset
33311@itemx -mkl
d77de738 33312@need 200
d77de738 33313@opindex mwidekl
ddf6fe37 33314@itemx -mwidekl
d77de738 33315@need 200
d77de738 33316@opindex mavxifma
ddf6fe37 33317@itemx -mavxifma
d77de738 33318@need 200
d77de738 33319@opindex mavxvnniint8
ddf6fe37 33320@itemx -mavxvnniint8
d77de738 33321@need 200
d77de738 33322@opindex mavxneconvert
ddf6fe37 33323@itemx -mavxneconvert
d77de738 33324@need 200
d77de738 33325@opindex mcmpccxadd
ddf6fe37 33326@itemx -mcmpccxadd
d77de738 33327@need 200
d77de738 33328@opindex mamx-fp16
ddf6fe37 33329@itemx -mamx-fp16
d77de738 33330@need 200
d77de738 33331@opindex mprefetchi
ddf6fe37 33332@itemx -mprefetchi
d77de738 33333@need 200
d77de738 33334@opindex mraoint
ddf6fe37 33335@itemx -mraoint
d77de738
ML
33336These switches enable the use of instructions in the MMX, SSE,
33337SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
33338AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33339AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33340WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
333413DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33342XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33343GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33344ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
29ecb952 33345UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16,
d77de738
ML
33346AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT or
33347CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
33348option to disable use of these instructions.
33349
33350These extensions are also available as built-in functions: see
33351@ref{x86 Built-in Functions}, for details of the functions enabled and
33352disabled by these switches.
33353
33354To generate SSE/SSE2 instructions automatically from floating-point
33355code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33356
33357GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33358generates new AVX instructions or AVX equivalence for all SSEx instructions
33359when needed.
33360
33361These options enable GCC to use these extended instructions in
33362generated code, even without @option{-mfpmath=sse}. Applications that
33363perform run-time CPU detection must compile separate files for each
33364supported architecture, using the appropriate flags. In particular,
33365the file containing the CPU detection code should be compiled without
33366these options.
33367
d77de738 33368@opindex mdump-tune-features
ddf6fe37 33369@item -mdump-tune-features
d77de738
ML
33370This option instructs GCC to dump the names of the x86 performance
33371tuning features and default settings. The names can be used in
33372@option{-mtune-ctrl=@var{feature-list}}.
33373
d77de738 33374@opindex mtune-ctrl=@var{feature-list}
ddf6fe37 33375@item -mtune-ctrl=@var{feature-list}
d77de738
ML
33376This option is used to do fine grain control of x86 code generation features.
33377@var{feature-list} is a comma separated list of @var{feature} names. See also
33378@option{-mdump-tune-features}. When specified, the @var{feature} is turned
33379on if it is not preceded with @samp{^}, otherwise, it is turned off.
33380@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33381developers. Using it may lead to code paths not covered by testing and can
33382potentially result in compiler ICEs or runtime errors.
33383
d77de738 33384@opindex mno-default
ddf6fe37 33385@item -mno-default
d77de738
ML
33386This option instructs GCC to turn off all tunable features. See also
33387@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33388
d77de738 33389@opindex mcld
ddf6fe37 33390@item -mcld
d77de738
ML
33391This option instructs GCC to emit a @code{cld} instruction in the prologue
33392of functions that use string instructions. String instructions depend on
33393the DF flag to select between autoincrement or autodecrement mode. While the
33394ABI specifies the DF flag to be cleared on function entry, some operating
33395systems violate this specification by not clearing the DF flag in their
33396exception dispatchers. The exception handler can be invoked with the DF flag
33397set, which leads to wrong direction mode when string instructions are used.
33398This option can be enabled by default on 32-bit x86 targets by configuring
33399GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33400instructions can be suppressed with the @option{-mno-cld} compiler option
33401in this case.
33402
d77de738 33403@opindex mvzeroupper
ddf6fe37 33404@item -mvzeroupper
d77de738
ML
33405This option instructs GCC to emit a @code{vzeroupper} instruction
33406before a transfer of control flow out of the function to minimize
33407the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33408intrinsics.
33409
d77de738 33410@opindex mprefer-avx128
ddf6fe37 33411@item -mprefer-avx128
d77de738
ML
33412This option instructs GCC to use 128-bit AVX instructions instead of
33413256-bit AVX instructions in the auto-vectorizer.
33414
d77de738 33415@opindex mprefer-vector-width
ddf6fe37 33416@item -mprefer-vector-width=@var{opt}
d77de738
ML
33417This option instructs GCC to use @var{opt}-bit vector width in instructions
33418instead of default on the selected platform.
33419
d77de738 33420@opindex mmove-max
ddf6fe37 33421@item -mmove-max=@var{bits}
d77de738
ML
33422This option instructs GCC to set the maximum number of bits can be
33423moved from memory to memory efficiently to @var{bits}. The valid
33424@var{bits} are 128, 256 and 512.
33425
d77de738 33426@opindex mstore-max
ddf6fe37 33427@item -mstore-max=@var{bits}
d77de738
ML
33428This option instructs GCC to set the maximum number of bits can be
33429stored to memory efficiently to @var{bits}. The valid @var{bits} are
33430128, 256 and 512.
33431
33432@table @samp
33433@item none
33434No extra limitations applied to GCC other than defined by the selected platform.
33435
33436@item 128
33437Prefer 128-bit vector width for instructions.
33438
33439@item 256
33440Prefer 256-bit vector width for instructions.
33441
33442@item 512
33443Prefer 512-bit vector width for instructions.
33444@end table
33445
d77de738 33446@opindex mcx16
ddf6fe37 33447@item -mcx16
d77de738
ML
33448This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
33449code to implement compare-and-exchange operations on 16-byte aligned 128-bit
33450objects. This is useful for atomic updates of data structures exceeding one
33451machine word in size. The compiler uses this instruction to implement
33452@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
33453128-bit integers, a library call is always used.
33454
d77de738 33455@opindex msahf
ddf6fe37 33456@item -msahf
d77de738
ML
33457This option enables generation of @code{SAHF} instructions in 64-bit code.
33458Early Intel Pentium 4 CPUs with Intel 64 support,
33459prior to the introduction of Pentium 4 G1 step in December 2005,
33460lacked the @code{LAHF} and @code{SAHF} instructions
33461which are supported by AMD64.
33462These are load and store instructions, respectively, for certain status flags.
33463In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
33464@code{drem}, and @code{remainder} built-in functions;
33465see @ref{Other Builtins} for details.
33466
d77de738 33467@opindex mmovbe
ddf6fe37 33468@item -mmovbe
d77de738
ML
33469This option enables use of the @code{movbe} instruction to implement
33470@code{__builtin_bswap32} and @code{__builtin_bswap64}.
33471
d77de738 33472@opindex mshstk
ddf6fe37 33473@item -mshstk
d77de738
ML
33474The @option{-mshstk} option enables shadow stack built-in functions
33475from x86 Control-flow Enforcement Technology (CET).
33476
d77de738 33477@opindex mcrc32
ddf6fe37 33478@item -mcrc32
d77de738
ML
33479This option enables built-in functions @code{__builtin_ia32_crc32qi},
33480@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
33481@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
33482
d77de738 33483@opindex mmwait
ddf6fe37 33484@item -mmwait
d77de738
ML
33485This option enables built-in functions @code{__builtin_ia32_monitor},
33486and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
33487@code{mwait} machine instructions.
33488
d77de738 33489@opindex mrecip
ddf6fe37 33490@item -mrecip
d77de738
ML
33491This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
33492(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
33493with an additional Newton-Raphson step
33494to increase precision instead of @code{DIVSS} and @code{SQRTSS}
33495(and their vectorized
33496variants) for single-precision floating-point arguments. These instructions
33497are generated only when @option{-funsafe-math-optimizations} is enabled
33498together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
33499Note that while the throughput of the sequence is higher than the throughput
33500of the non-reciprocal instruction, the precision of the sequence can be
33501decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
33502
33503Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
33504(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
33505combination), and doesn't need @option{-mrecip}.
33506
33507Also note that GCC emits the above sequence with additional Newton-Raphson step
33508for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
33509already with @option{-ffast-math} (or the above option combination), and
33510doesn't need @option{-mrecip}.
33511
d77de738 33512@opindex mrecip=opt
ddf6fe37 33513@item -mrecip=@var{opt}
d77de738
ML
33514This option controls which reciprocal estimate instructions
33515may be used. @var{opt} is a comma-separated list of options, which may
33516be preceded by a @samp{!} to invert the option:
33517
33518@table @samp
33519@item all
33520Enable all estimate instructions.
33521
33522@item default
33523Enable the default instructions, equivalent to @option{-mrecip}.
33524
33525@item none
33526Disable all estimate instructions, equivalent to @option{-mno-recip}.
33527
33528@item div
33529Enable the approximation for scalar division.
33530
33531@item vec-div
33532Enable the approximation for vectorized division.
33533
33534@item sqrt
33535Enable the approximation for scalar square root.
33536
33537@item vec-sqrt
33538Enable the approximation for vectorized square root.
33539@end table
33540
33541So, for example, @option{-mrecip=all,!sqrt} enables
33542all of the reciprocal approximations, except for square root.
33543
d77de738 33544@opindex mveclibabi
ddf6fe37 33545@item -mveclibabi=@var{type}
d77de738
ML
33546Specifies the ABI type to use for vectorizing intrinsics using an
33547external library. Supported values for @var{type} are @samp{svml}
33548for the Intel short
33549vector math library and @samp{acml} for the AMD math core library.
33550To use this option, both @option{-ftree-vectorize} and
33551@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
33552ABI-compatible library must be specified at link time.
33553
33554GCC currently emits calls to @code{vmldExp2},
33555@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
33556@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
33557@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
33558@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
33559@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
33560@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
33561@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
33562@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
33563@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
33564function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
33565@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
33566@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
33567@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
33568@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
33569when @option{-mveclibabi=acml} is used.
33570
d77de738 33571@opindex mabi
ddf6fe37 33572@item -mabi=@var{name}
d77de738
ML
33573Generate code for the specified calling convention. Permissible values
33574are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
33575@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
33576ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
33577You can control this behavior for specific functions by
33578using the function attributes @code{ms_abi} and @code{sysv_abi}.
33579@xref{Function Attributes}.
33580
d77de738 33581@opindex mforce-indirect-call
ddf6fe37 33582@item -mforce-indirect-call
d77de738
ML
33583Force all calls to functions to be indirect. This is useful
33584when using Intel Processor Trace where it generates more precise timing
33585information for function calls.
33586
d77de738 33587@opindex mmanual-endbr
ddf6fe37 33588@item -mmanual-endbr
d77de738
ML
33589Insert ENDBR instruction at function entry only via the @code{cf_check}
33590function attribute. This is useful when used with the option
33591@option{-fcf-protection=branch} to control ENDBR insertion at the
33592function entry.
33593
d77de738 33594@opindex mcet-switch
ddf6fe37 33595@item -mcet-switch
d77de738
ML
33596By default, CET instrumentation is turned off on switch statements that
33597use a jump table and indirect branch track is disabled. Since jump
33598tables are stored in read-only memory, this does not result in a direct
33599loss of hardening. But if the jump table index is attacker-controlled,
33600the indirect jump may not be constrained by CET. This option turns on
33601CET instrumentation to enable indirect branch track for switch statements
33602with jump tables which leads to the jump targets reachable via any indirect
33603jumps.
33604
d77de738
ML
33605@opindex mcall-ms2sysv-xlogues
33606@opindex mno-call-ms2sysv-xlogues
ddf6fe37 33607@item -mcall-ms2sysv-xlogues
d77de738
ML
33608Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
33609System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
33610default, the code for saving and restoring these registers is emitted inline,
33611resulting in fairly lengthy prologues and epilogues. Using
33612@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
33613use stubs in the static portion of libgcc to perform these saves and restores,
33614thus reducing function size at the cost of a few extra instructions.
33615
d77de738 33616@opindex mtls-dialect
ddf6fe37 33617@item -mtls-dialect=@var{type}
d77de738
ML
33618Generate code to access thread-local storage using the @samp{gnu} or
33619@samp{gnu2} conventions. @samp{gnu} is the conservative default;
33620@samp{gnu2} is more efficient, but it may add compile- and run-time
33621requirements that cannot be satisfied on all systems.
33622
d77de738
ML
33623@opindex mpush-args
33624@opindex mno-push-args
ddf6fe37
AA
33625@item -mpush-args
33626@itemx -mno-push-args
d77de738
ML
33627Use PUSH operations to store outgoing parameters. This method is shorter
33628and usually equally fast as method using SUB/MOV operations and is enabled
33629by default. In some cases disabling it may improve performance because of
33630improved scheduling and reduced dependencies.
33631
d77de738 33632@opindex maccumulate-outgoing-args
ddf6fe37 33633@item -maccumulate-outgoing-args
d77de738
ML
33634If enabled, the maximum amount of space required for outgoing arguments is
33635computed in the function prologue. This is faster on most modern CPUs
33636because of reduced dependencies, improved scheduling and reduced stack usage
33637when the preferred stack boundary is not equal to 2. The drawback is a notable
33638increase in code size. This switch implies @option{-mno-push-args}.
33639
d77de738 33640@opindex mthreads
ddf6fe37 33641@item -mthreads
d77de738
ML
33642Support thread-safe exception handling on MinGW. Programs that rely
33643on thread-safe exception handling must compile and link all code with the
33644@option{-mthreads} option. When compiling, @option{-mthreads} defines
33645@option{-D_MT}; when linking, it links in a special thread helper library
33646@option{-lmingwthrd} which cleans up per-thread exception-handling data.
33647
d77de738
ML
33648@opindex mms-bitfields
33649@opindex mno-ms-bitfields
ddf6fe37
AA
33650@item -mms-bitfields
33651@itemx -mno-ms-bitfields
d77de738
ML
33652
33653Enable/disable bit-field layout compatible with the native Microsoft
33654Windows compiler.
33655
33656If @code{packed} is used on a structure, or if bit-fields are used,
33657it may be that the Microsoft ABI lays out the structure differently
33658than the way GCC normally does. Particularly when moving packed
33659data between functions compiled with GCC and the native Microsoft compiler
33660(either via function call or as data in a file), it may be necessary to access
33661either format.
33662
33663This option is enabled by default for Microsoft Windows
33664targets. This behavior can also be controlled locally by use of variable
33665or type attributes. For more information, see @ref{x86 Variable Attributes}
33666and @ref{x86 Type Attributes}.
33667
33668The Microsoft structure layout algorithm is fairly simple with the exception
33669of the bit-field packing.
33670The padding and alignment of members of structures and whether a bit-field
33671can straddle a storage-unit boundary are determine by these rules:
33672
33673@enumerate
33674@item Structure members are stored sequentially in the order in which they are
33675declared: the first member has the lowest memory address and the last member
33676the highest.
33677
33678@item Every data object has an alignment requirement. The alignment requirement
33679for all data except structures, unions, and arrays is either the size of the
33680object or the current packing size (specified with either the
33681@code{aligned} attribute or the @code{pack} pragma),
33682whichever is less. For structures, unions, and arrays,
33683the alignment requirement is the largest alignment requirement of its members.
33684Every object is allocated an offset so that:
33685
33686@smallexample
33687offset % alignment_requirement == 0
33688@end smallexample
33689
33690@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
33691unit if the integral types are the same size and if the next bit-field fits
33692into the current allocation unit without crossing the boundary imposed by the
33693common alignment requirements of the bit-fields.
33694@end enumerate
33695
33696MSVC interprets zero-length bit-fields in the following ways:
33697
33698@enumerate
33699@item If a zero-length bit-field is inserted between two bit-fields that
33700are normally coalesced, the bit-fields are not coalesced.
33701
33702For example:
33703
33704@smallexample
33705struct
33706 @{
33707 unsigned long bf_1 : 12;
33708 unsigned long : 0;
33709 unsigned long bf_2 : 12;
33710 @} t1;
33711@end smallexample
33712
33713@noindent
33714The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
33715zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
33716
33717@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
33718alignment of the zero-length bit-field is greater than the member that follows it,
33719@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
33720
33721For example:
33722
33723@smallexample
33724struct
33725 @{
33726 char foo : 4;
33727 short : 0;
33728 char bar;
33729 @} t2;
33730
33731struct
33732 @{
33733 char foo : 4;
33734 short : 0;
33735 double bar;
33736 @} t3;
33737@end smallexample
33738
33739@noindent
33740For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
33741Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
33742bit-field does not affect the alignment of @code{bar} or, as a result, the size
33743of the structure.
33744
33745Taking this into account, it is important to note the following:
33746
33747@enumerate
33748@item If a zero-length bit-field follows a normal bit-field, the type of the
33749zero-length bit-field may affect the alignment of the structure as whole. For
33750example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
33751normal bit-field, and is of type short.
33752
33753@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
33754still affect the alignment of the structure:
33755
33756@smallexample
33757struct
33758 @{
33759 char foo : 6;
33760 long : 0;
33761 @} t4;
33762@end smallexample
33763
33764@noindent
33765Here, @code{t4} takes up 4 bytes.
33766@end enumerate
33767
33768@item Zero-length bit-fields following non-bit-field members are ignored:
33769
33770@smallexample
33771struct
33772 @{
33773 char foo;
33774 long : 0;
33775 char bar;
33776 @} t5;
33777@end smallexample
33778
33779@noindent
33780Here, @code{t5} takes up 2 bytes.
33781@end enumerate
33782
33783
d77de738
ML
33784@opindex mno-align-stringops
33785@opindex malign-stringops
ddf6fe37 33786@item -mno-align-stringops
d77de738
ML
33787Do not align the destination of inlined string operations. This switch reduces
33788code size and improves performance in case the destination is already aligned,
33789but GCC doesn't know about it.
33790
d77de738 33791@opindex minline-all-stringops
ddf6fe37 33792@item -minline-all-stringops
d77de738
ML
33793By default GCC inlines string operations only when the destination is
33794known to be aligned to least a 4-byte boundary.
33795This enables more inlining and increases code
33796size, but may improve performance of code that depends on fast
33797@code{memcpy} and @code{memset} for short lengths.
33798The option enables inline expansion of @code{strlen} for all
33799pointer alignments.
33800
d77de738 33801@opindex minline-stringops-dynamically
ddf6fe37 33802@item -minline-stringops-dynamically
d77de738
ML
33803For string operations of unknown size, use run-time checks with
33804inline code for small blocks and a library call for large blocks.
33805
d77de738 33806@opindex mstringop-strategy=@var{alg}
ddf6fe37 33807@item -mstringop-strategy=@var{alg}
d77de738
ML
33808Override the internal decision heuristic for the particular algorithm to use
33809for inlining string operations. The allowed values for @var{alg} are:
33810
33811@table @samp
33812@item rep_byte
33813@itemx rep_4byte
33814@itemx rep_8byte
33815Expand using i386 @code{rep} prefix of the specified size.
33816
33817@item byte_loop
33818@itemx loop
33819@itemx unrolled_loop
33820Expand into an inline loop.
33821
33822@item libcall
33823Always use a library call.
33824@end table
33825
d77de738 33826@opindex mmemcpy-strategy=@var{strategy}
ddf6fe37 33827@item -mmemcpy-strategy=@var{strategy}
d77de738
ML
33828Override the internal decision heuristic to decide if @code{__builtin_memcpy}
33829should be inlined and what inline algorithm to use when the expected size
33830of the copy operation is known. @var{strategy}
33831is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
33832@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
33833the max byte size with which inline algorithm @var{alg} is allowed. For the last
33834triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
33835in the list must be specified in increasing order. The minimal byte size for
33836@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
33837preceding range.
33838
d77de738 33839@opindex mmemset-strategy=@var{strategy}
ddf6fe37 33840@item -mmemset-strategy=@var{strategy}
d77de738
ML
33841The option is similar to @option{-mmemcpy-strategy=} except that it is to control
33842@code{__builtin_memset} expansion.
33843
d77de738 33844@opindex momit-leaf-frame-pointer
ddf6fe37 33845@item -momit-leaf-frame-pointer
d77de738
ML
33846Don't keep the frame pointer in a register for leaf functions. This
33847avoids the instructions to save, set up, and restore frame pointers and
33848makes an extra register available in leaf functions. The option
33849@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
33850which might make debugging harder.
33851
ddf6fe37 33852@opindex mtls-direct-seg-refs
d77de738
ML
33853@item -mtls-direct-seg-refs
33854@itemx -mno-tls-direct-seg-refs
d77de738
ML
33855Controls whether TLS variables may be accessed with offsets from the
33856TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
33857or whether the thread base pointer must be added. Whether or not this
33858is valid depends on the operating system, and whether it maps the
33859segment to cover the entire TLS area.
33860
33861For systems that use the GNU C Library, the default is on.
33862
ddf6fe37 33863@opindex msse2avx
d77de738
ML
33864@item -msse2avx
33865@itemx -mno-sse2avx
d77de738
ML
33866Specify that the assembler should encode SSE instructions with VEX
33867prefix. The option @option{-mavx} turns this on by default.
33868
ddf6fe37 33869@opindex mfentry
d77de738
ML
33870@item -mfentry
33871@itemx -mno-fentry
d77de738
ML
33872If profiling is active (@option{-pg}), put the profiling
33873counter call before the prologue.
33874Note: On x86 architectures the attribute @code{ms_hook_prologue}
33875isn't possible at the moment for @option{-mfentry} and @option{-pg}.
33876
ddf6fe37 33877@opindex mrecord-mcount
d77de738
ML
33878@item -mrecord-mcount
33879@itemx -mno-record-mcount
d77de738
ML
33880If profiling is active (@option{-pg}), generate a __mcount_loc section
33881that contains pointers to each profiling call. This is useful for
33882automatically patching and out calls.
33883
ddf6fe37 33884@opindex mnop-mcount
d77de738
ML
33885@item -mnop-mcount
33886@itemx -mno-nop-mcount
d77de738
ML
33887If profiling is active (@option{-pg}), generate the calls to
33888the profiling functions as NOPs. This is useful when they
33889should be patched in later dynamically. This is likely only
33890useful together with @option{-mrecord-mcount}.
33891
d77de738 33892@opindex minstrument-return
ddf6fe37 33893@item -minstrument-return=@var{type}
d77de738
ML
33894Instrument function exit in -pg -mfentry instrumented functions with
33895call to specified function. This only instruments true returns ending
33896with ret, but not sibling calls ending with jump. Valid types
33897are @var{none} to not instrument, @var{call} to generate a call to __return__,
33898or @var{nop5} to generate a 5 byte nop.
33899
ddf6fe37 33900@opindex mrecord-return
d77de738
ML
33901@item -mrecord-return
33902@itemx -mno-record-return
d77de738
ML
33903Generate a __return_loc section pointing to all return instrumentation code.
33904
d77de738 33905@opindex mfentry-name
ddf6fe37 33906@item -mfentry-name=@var{name}
d77de738
ML
33907Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
33908
d77de738 33909@opindex mfentry-section
ddf6fe37 33910@item -mfentry-section=@var{name}
d77de738
ML
33911Set name of section to record -mrecord-mcount calls (default __mcount_loc).
33912
ddf6fe37 33913@opindex mskip-rax-setup
d77de738
ML
33914@item -mskip-rax-setup
33915@itemx -mno-skip-rax-setup
d77de738
ML
33916When generating code for the x86-64 architecture with SSE extensions
33917disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
33918register when there are no variable arguments passed in vector registers.
33919
33920@strong{Warning:} Since RAX register is used to avoid unnecessarily
33921saving vector registers on stack when passing variable arguments, the
33922impacts of this option are callees may waste some stack space,
33923misbehave or jump to a random location. GCC 4.4 or newer don't have
33924those issues, regardless the RAX register value.
33925
ddf6fe37 33926@opindex m8bit-idiv
d77de738
ML
33927@item -m8bit-idiv
33928@itemx -mno-8bit-idiv
d77de738
ML
33929On some processors, like Intel Atom, 8-bit unsigned integer divide is
33930much faster than 32-bit/64-bit integer divide. This option generates a
33931run-time check. If both dividend and divisor are within range of 0
33932to 255, 8-bit unsigned integer divide is used instead of
3393332-bit/64-bit integer divide.
33934
d77de738
ML
33935@opindex mavx256-split-unaligned-load
33936@opindex mavx256-split-unaligned-store
ddf6fe37
AA
33937@item -mavx256-split-unaligned-load
33938@itemx -mavx256-split-unaligned-store
d77de738
ML
33939Split 32-byte AVX unaligned load and store.
33940
d77de738
ML
33941@opindex mstack-protector-guard
33942@opindex mstack-protector-guard-reg
33943@opindex mstack-protector-guard-offset
ddf6fe37
AA
33944@item -mstack-protector-guard=@var{guard}
33945@itemx -mstack-protector-guard-reg=@var{reg}
33946@itemx -mstack-protector-guard-offset=@var{offset}
d77de738
ML
33947Generate stack protection code using canary at @var{guard}. Supported
33948locations are @samp{global} for global canary or @samp{tls} for per-thread
33949canary in the TLS block (the default). This option has effect only when
33950@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
33951
33952With the latter choice the options
33953@option{-mstack-protector-guard-reg=@var{reg}} and
33954@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
33955which segment register (@code{%fs} or @code{%gs}) to use as base register
33956for reading the canary, and from what offset from that base register.
33957The default for those is as specified in the relevant ABI.
33958
d77de738 33959@opindex mgeneral-regs-only
ddf6fe37 33960@item -mgeneral-regs-only
d77de738
ML
33961Generate code that uses only the general-purpose registers. This
33962prevents the compiler from using floating-point, vector, mask and bound
33963registers.
33964
d77de738 33965@opindex mrelax-cmpxchg-loop
ddf6fe37 33966@item -mrelax-cmpxchg-loop
85966f0d
AM
33967When emitting a compare-and-swap loop for @ref{__sync Builtins}
33968and @ref{__atomic Builtins} lacking a native instruction, optimize
33969for the highly contended case by issuing an atomic load before the
33970@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
33971to save CPU power when restarting the loop.
d77de738 33972
d77de738 33973@opindex mindirect-branch
ddf6fe37 33974@item -mindirect-branch=@var{choice}
d77de738
ML
33975Convert indirect call and jump with @var{choice}. The default is
33976@samp{keep}, which keeps indirect call and jump unmodified.
33977@samp{thunk} converts indirect call and jump to call and return thunk.
33978@samp{thunk-inline} converts indirect call and jump to inlined call
33979and return thunk. @samp{thunk-extern} converts indirect call and jump
33980to external call and return thunk provided in a separate object file.
33981You can control this behavior for a specific function by using the
33982function attribute @code{indirect_branch}. @xref{Function Attributes}.
33983
33984Note that @option{-mcmodel=large} is incompatible with
33985@option{-mindirect-branch=thunk} and
33986@option{-mindirect-branch=thunk-extern} since the thunk function may
33987not be reachable in the large code model.
33988
33989Note that @option{-mindirect-branch=thunk-extern} is compatible with
33990@option{-fcf-protection=branch} since the external thunk can be made
33991to enable control-flow check.
33992
d77de738 33993@opindex mfunction-return
ddf6fe37 33994@item -mfunction-return=@var{choice}
d77de738
ML
33995Convert function return with @var{choice}. The default is @samp{keep},
33996which keeps function return unmodified. @samp{thunk} converts function
33997return to call and return thunk. @samp{thunk-inline} converts function
33998return to inlined call and return thunk. @samp{thunk-extern} converts
33999function return to external call and return thunk provided in a separate
34000object file. You can control this behavior for a specific function by
34001using the function attribute @code{function_return}.
34002@xref{Function Attributes}.
34003
34004Note that @option{-mindirect-return=thunk-extern} is compatible with
34005@option{-fcf-protection=branch} since the external thunk can be made
34006to enable control-flow check.
34007
34008Note that @option{-mcmodel=large} is incompatible with
34009@option{-mfunction-return=thunk} and
34010@option{-mfunction-return=thunk-extern} since the thunk function may
34011not be reachable in the large code model.
34012
34013
d77de738 34014@opindex mindirect-branch-register
ddf6fe37 34015@item -mindirect-branch-register
d77de738
ML
34016Force indirect call and jump via register.
34017
d77de738 34018@opindex mharden-sls
ddf6fe37 34019@item -mharden-sls=@var{choice}
d77de738
ML
34020Generate code to mitigate against straight line speculation (SLS) with
34021@var{choice}. The default is @samp{none} which disables all SLS
34022hardening. @samp{return} enables SLS hardening for function returns.
34023@samp{indirect-jmp} enables SLS hardening for indirect jumps.
34024@samp{all} enables all SLS hardening.
34025
d77de738 34026@opindex mindirect-branch-cs-prefix
ddf6fe37 34027@item -mindirect-branch-cs-prefix
d77de738
ML
34028Add CS prefix to call and jmp to indirect thunk with branch target in
34029r8-r15 registers so that the call and jmp instruction length is 6 bytes
34030to allow them to be replaced with @samp{lfence; call *%r8-r15} or
34031@samp{lfence; jmp *%r8-r15} at run-time.
34032
34033@end table
34034
34035These @samp{-m} switches are supported in addition to the above
34036on x86-64 processors in 64-bit environments.
34037
34038@table @gcctabopt
d77de738
ML
34039@opindex m32
34040@opindex m64
34041@opindex mx32
34042@opindex m16
34043@opindex miamcu
ddf6fe37
AA
34044@item -m32
34045@itemx -m64
34046@itemx -mx32
34047@itemx -m16
34048@itemx -miamcu
d77de738
ML
34049Generate code for a 16-bit, 32-bit or 64-bit environment.
34050The @option{-m32} option sets @code{int}, @code{long}, and pointer types
34051to 32 bits, and
34052generates code that runs on any i386 system.
34053
34054The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
34055types to 64 bits, and generates code for the x86-64 architecture.
34056For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
34057and @option{-mdynamic-no-pic} options.
34058
34059The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
34060to 32 bits, and
34061generates code for the x86-64 architecture.
34062
34063The @option{-m16} option is the same as @option{-m32}, except for that
34064it outputs the @code{.code16gcc} assembly directive at the beginning of
34065the assembly output so that the binary can run in 16-bit mode.
34066
34067The @option{-miamcu} option generates code which conforms to Intel MCU
34068psABI. It requires the @option{-m32} option to be turned on.
34069
d77de738
ML
34070@opindex mno-red-zone
34071@opindex mred-zone
ddf6fe37 34072@item -mno-red-zone
d77de738
ML
34073Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
34074by the x86-64 ABI; it is a 128-byte area beyond the location of the
34075stack pointer that is not modified by signal or interrupt handlers
34076and therefore can be used for temporary data without adjusting the stack
34077pointer. The flag @option{-mno-red-zone} disables this red zone.
34078
d77de738 34079@opindex mcmodel=small
ddf6fe37 34080@item -mcmodel=small
d77de738
ML
34081Generate code for the small code model: the program and its symbols must
34082be linked in the lower 2 GB of the address space. Pointers are 64 bits.
34083Programs can be statically or dynamically linked. This is the default
34084code model.
34085
d77de738 34086@opindex mcmodel=kernel
ddf6fe37 34087@item -mcmodel=kernel
d77de738
ML
34088Generate code for the kernel code model. The kernel runs in the
34089negative 2 GB of the address space.
34090This model has to be used for Linux kernel code.
34091
d77de738 34092@opindex mcmodel=medium
ddf6fe37 34093@item -mcmodel=medium
d77de738
ML
34094Generate code for the medium model: the program is linked in the lower 2
34095GB of the address space. Small symbols are also placed there. Symbols
34096with sizes larger than @option{-mlarge-data-threshold} are put into
34097large data or BSS sections and can be located above 2GB. Programs can
34098be statically or dynamically linked.
34099
d77de738 34100@opindex mcmodel=large
ddf6fe37 34101@item -mcmodel=large
d77de738
ML
34102Generate code for the large model. This model makes no assumptions
34103about addresses and sizes of sections.
34104
d77de738 34105@opindex maddress-mode=long
ddf6fe37 34106@item -maddress-mode=long
d77de738
ML
34107Generate code for long address mode. This is only supported for 64-bit
34108and x32 environments. It is the default address mode for 64-bit
34109environments.
34110
d77de738 34111@opindex maddress-mode=short
ddf6fe37 34112@item -maddress-mode=short
d77de738
ML
34113Generate code for short address mode. This is only supported for 32-bit
34114and x32 environments. It is the default address mode for 32-bit and
34115x32 environments.
34116
ddf6fe37 34117@opindex mneeded
d77de738
ML
34118@item -mneeded
34119@itemx -mno-needed
d77de738
ML
34120Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
34121indicate the micro-architecture ISA level required to execute the binary.
34122
d77de738
ML
34123@opindex mno-direct-extern-access
34124@opindex mdirect-extern-access
ddf6fe37 34125@item -mno-direct-extern-access
d77de738
ML
34126Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
34127to access external symbols. With @option{-fpic} or @option{-fPIC},
34128treat access to protected symbols as local symbols. The default is
34129@option{-mdirect-extern-access}.
34130
34131@strong{Warning:} shared libraries compiled with
34132@option{-mno-direct-extern-access} and executable compiled with
34133@option{-mdirect-extern-access} may not be binary compatible if
34134protected symbols are used in shared libraries and executable.
ce51e843 34135
ce51e843
ML
34136@opindex munroll-only-small-loops
34137@opindex mno-unroll-only-small-loops
ddf6fe37 34138@item -munroll-only-small-loops
ce51e843
ML
34139Controls conservative small loop unrolling. It is default enabled by
34140O2, and unrolls loop with less than 4 insns by 1 time. Explicit
34141-f[no-]unroll-[all-]loops would disable this flag to avoid any
34142unintended unrolling behavior that user does not want.
bb576017 34143
bb576017 34144@opindex mlam
ddf6fe37 34145@item -mlam=@var{choice}
bb576017 34146LAM(linear-address masking) allows special bits in the pointer to be used
34147for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
34148positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
34149positions 62:57 can be used for metadata.
d77de738
ML
34150@end table
34151
34152@node x86 Windows Options
34153@subsection x86 Windows Options
34154@cindex x86 Windows Options
34155@cindex Windows Options for x86
34156
34157These additional options are available for Microsoft Windows targets:
34158
34159@table @gcctabopt
d77de738 34160@opindex mconsole
ddf6fe37 34161@item -mconsole
d77de738
ML
34162This option
34163specifies that a console application is to be generated, by
34164instructing the linker to set the PE header subsystem type
34165required for console applications.
34166This option is available for Cygwin and MinGW targets and is
34167enabled by default on those targets.
34168
d77de738 34169@opindex mdll
ddf6fe37 34170@item -mdll
d77de738
ML
34171This option is available for Cygwin and MinGW targets. It
34172specifies that a DLL---a dynamic link library---is to be
34173generated, enabling the selection of the required runtime
34174startup object and entry point.
34175
d77de738 34176@opindex mnop-fun-dllimport
ddf6fe37 34177@item -mnop-fun-dllimport
d77de738
ML
34178This option is available for Cygwin and MinGW targets. It
34179specifies that the @code{dllimport} attribute should be ignored.
34180
d77de738 34181@opindex mthreads
ddf6fe37 34182@item -mthreads
d77de738
ML
34183This option is available for MinGW targets. It specifies
34184that MinGW-specific thread support is to be used.
34185
d77de738 34186@opindex municode
ddf6fe37 34187@item -municode
d77de738
ML
34188This option is available for MinGW-w64 targets. It causes
34189the @code{UNICODE} preprocessor macro to be predefined, and
34190chooses Unicode-capable runtime startup code.
34191
d77de738 34192@opindex mwin32
ddf6fe37 34193@item -mwin32
d77de738
ML
34194This option is available for Cygwin and MinGW targets. It
34195specifies that the typical Microsoft Windows predefined macros are to
34196be set in the pre-processor, but does not influence the choice
34197of runtime library/startup code.
34198
d77de738 34199@opindex mwindows
ddf6fe37 34200@item -mwindows
d77de738
ML
34201This option is available for Cygwin and MinGW targets. It
34202specifies that a GUI application is to be generated by
34203instructing the linker to set the PE header subsystem type
34204appropriately.
34205
d77de738
ML
34206@opindex fno-set-stack-executable
34207@opindex fset-stack-executable
ddf6fe37 34208@item -fno-set-stack-executable
d77de738
ML
34209This option is available for MinGW targets. It specifies that
34210the executable flag for the stack used by nested functions isn't
34211set. This is necessary for binaries running in kernel mode of
34212Microsoft Windows, as there the User32 API, which is used to set executable
34213privileges, isn't available.
34214
d77de738
ML
34215@opindex fno-writable-relocated-rdata
34216@opindex fwritable-relocated-rdata
ddf6fe37 34217@item -fwritable-relocated-rdata
d77de738
ML
34218This option is available for MinGW and Cygwin targets. It specifies
34219that relocated-data in read-only section is put into the @code{.data}
34220section. This is a necessary for older runtimes not supporting
34221modification of @code{.rdata} sections for pseudo-relocation.
34222
d77de738 34223@opindex mpe-aligned-commons
ddf6fe37 34224@item -mpe-aligned-commons
d77de738
ML
34225This option is available for Cygwin and MinGW targets. It
34226specifies that the GNU extension to the PE file format that
34227permits the correct alignment of COMMON variables should be
34228used when generating code. It is enabled by default if
34229GCC detects that the target assembler found during configuration
34230supports the feature.
34231@end table
34232
34233See also under @ref{x86 Options} for standard options.
34234
34235@node Xstormy16 Options
34236@subsection Xstormy16 Options
34237@cindex Xstormy16 Options
34238
34239These options are defined for Xstormy16:
34240
34241@table @gcctabopt
d77de738 34242@opindex msim
ddf6fe37 34243@item -msim
d77de738
ML
34244Choose startup files and linker script suitable for the simulator.
34245@end table
34246
34247@node Xtensa Options
34248@subsection Xtensa Options
34249@cindex Xtensa Options
34250
34251These options are supported for Xtensa targets:
34252
34253@table @gcctabopt
d77de738
ML
34254@opindex mconst16
34255@opindex mno-const16
ddf6fe37
AA
34256@item -mconst16
34257@itemx -mno-const16
d77de738
ML
34258Enable or disable use of @code{CONST16} instructions for loading
34259constant values. The @code{CONST16} instruction is currently not a
34260standard option from Tensilica. When enabled, @code{CONST16}
34261instructions are always used in place of the standard @code{L32R}
34262instructions. The use of @code{CONST16} is enabled by default only if
34263the @code{L32R} instruction is not available.
34264
d77de738
ML
34265@opindex mfused-madd
34266@opindex mno-fused-madd
ddf6fe37
AA
34267@item -mfused-madd
34268@itemx -mno-fused-madd
d77de738
ML
34269Enable or disable use of fused multiply/add and multiply/subtract
34270instructions in the floating-point option. This has no effect if the
34271floating-point option is not also enabled. Disabling fused multiply/add
34272and multiply/subtract instructions forces the compiler to use separate
34273instructions for the multiply and add/subtract operations. This may be
34274desirable in some cases where strict IEEE 754-compliant results are
34275required: the fused multiply add/subtract instructions do not round the
34276intermediate result, thereby producing results with @emph{more} bits of
34277precision than specified by the IEEE standard. Disabling fused multiply
34278add/subtract instructions also ensures that the program output is not
34279sensitive to the compiler's ability to combine multiply and add/subtract
34280operations.
34281
d77de738
ML
34282@opindex mserialize-volatile
34283@opindex mno-serialize-volatile
ddf6fe37
AA
34284@item -mserialize-volatile
34285@itemx -mno-serialize-volatile
d77de738
ML
34286When this option is enabled, GCC inserts @code{MEMW} instructions before
34287@code{volatile} memory references to guarantee sequential consistency.
34288The default is @option{-mserialize-volatile}. Use
34289@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
34290
d77de738 34291@opindex mforce-no-pic
ddf6fe37 34292@item -mforce-no-pic
d77de738
ML
34293For targets, like GNU/Linux, where all user-mode Xtensa code must be
34294position-independent code (PIC), this option disables PIC for compiling
34295kernel code.
34296
d77de738
ML
34297@opindex mtext-section-literals
34298@opindex mno-text-section-literals
ddf6fe37
AA
34299@item -mtext-section-literals
34300@itemx -mno-text-section-literals
d77de738
ML
34301These options control the treatment of literal pools. The default is
34302@option{-mno-text-section-literals}, which places literals in a separate
34303section in the output file. This allows the literal pool to be placed
34304in a data RAM/ROM, and it also allows the linker to combine literal
34305pools from separate object files to remove redundant literals and
34306improve code size. With @option{-mtext-section-literals}, the literals
34307are interspersed in the text section in order to keep them as close as
34308possible to their references. This may be necessary for large assembly
34309files. Literals for each function are placed right before that function.
34310
d77de738
ML
34311@opindex mauto-litpools
34312@opindex mno-auto-litpools
ddf6fe37
AA
34313@item -mauto-litpools
34314@itemx -mno-auto-litpools
d77de738
ML
34315These options control the treatment of literal pools. The default is
34316@option{-mno-auto-litpools}, which places literals in a separate
34317section in the output file unless @option{-mtext-section-literals} is
34318used. With @option{-mauto-litpools} the literals are interspersed in
34319the text section by the assembler. Compiler does not produce explicit
34320@code{.literal} directives and loads literals into registers with
34321@code{MOVI} instructions instead of @code{L32R} to let the assembler
34322do relaxation and place literals as necessary. This option allows
34323assembler to create several literal pools per function and assemble
34324very big functions, which may not be possible with
34325@option{-mtext-section-literals}.
34326
d77de738
ML
34327@opindex mtarget-align
34328@opindex mno-target-align
ddf6fe37
AA
34329@item -mtarget-align
34330@itemx -mno-target-align
d77de738
ML
34331When this option is enabled, GCC instructs the assembler to
34332automatically align instructions to reduce branch penalties at the
34333expense of some code density. The assembler attempts to widen density
34334instructions to align branch targets and the instructions following call
34335instructions. If there are not enough preceding safe density
34336instructions to align a target, no widening is performed. The
34337default is @option{-mtarget-align}. These options do not affect the
34338treatment of auto-aligned instructions like @code{LOOP}, which the
34339assembler always aligns, either by widening density instructions or
34340by inserting NOP instructions.
34341
d77de738
ML
34342@opindex mlongcalls
34343@opindex mno-longcalls
ddf6fe37
AA
34344@item -mlongcalls
34345@itemx -mno-longcalls
d77de738
ML
34346When this option is enabled, GCC instructs the assembler to translate
34347direct calls to indirect calls unless it can determine that the target
34348of a direct call is in the range allowed by the call instruction. This
34349translation typically occurs for calls to functions in other source
34350files. Specifically, the assembler translates a direct @code{CALL}
34351instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34352The default is @option{-mno-longcalls}. This option should be used in
34353programs where the call target can potentially be out of range. This
34354option is implemented in the assembler, not the compiler, so the
34355assembly code generated by GCC still shows direct call
34356instructions---look at the disassembled object code to see the actual
34357instructions. Note that the assembler uses an indirect call for
34358every cross-file call, not just those that really are out of range.
34359
d77de738 34360@opindex mabi
ddf6fe37 34361@item -mabi=@var{name}
d77de738
ML
34362Generate code for the specified ABI@. Permissible values are: @samp{call0},
34363@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34364
d77de738 34365@opindex mabi=call0
ddf6fe37 34366@item -mabi=call0
d77de738
ML
34367When this option is enabled function parameters are passed in registers
34368@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34369caller-saved, and register @code{a15} may be used as a frame pointer.
34370When this version of the ABI is enabled the C preprocessor symbol
34371@code{__XTENSA_CALL0_ABI__} is defined.
34372
d77de738 34373@opindex mabi=windowed
ddf6fe37 34374@item -mabi=windowed
d77de738
ML
34375When this option is enabled function parameters are passed in registers
34376@code{a10} through @code{a15}, and called function rotates register window
34377by 8 registers on entry so that its arguments are found in registers
34378@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34379pointer. Register window is rotated 8 registers back upon return.
34380When this version of the ABI is enabled the C preprocessor symbol
34381@code{__XTENSA_WINDOWED_ABI__} is defined.
34382
d77de738 34383@opindex mextra-l32r-costs
ddf6fe37 34384@item -mextra-l32r-costs=@var{n}
d77de738
ML
34385Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34386instructions, in clock cycles. This affects, when optimizing for speed,
34387whether loading a constant from literal pool using @code{L32R} or
34388synthesizing the constant from a small one with a couple of arithmetic
34389instructions. The default value is 0.
34390@end table
34391
34392@node zSeries Options
34393@subsection zSeries Options
34394@cindex zSeries options
34395
34396These are listed under @xref{S/390 and zSeries Options}.
34397
34398
34399@c man end
34400
34401@node Spec Files
34402@section Specifying Subprocesses and the Switches to Pass to Them
34403@cindex Spec Files
34404
34405@command{gcc} is a driver program. It performs its job by invoking a
34406sequence of other programs to do the work of compiling, assembling and
34407linking. GCC interprets its command-line parameters and uses these to
34408deduce which programs it should invoke, and which command-line options
34409it ought to place on their command lines. This behavior is controlled
34410by @dfn{spec strings}. In most cases there is one spec string for each
34411program that GCC can invoke, but a few programs have multiple spec
34412strings to control their behavior. The spec strings built into GCC can
34413be overridden by using the @option{-specs=} command-line switch to specify
34414a spec file.
34415
34416@dfn{Spec files} are plain-text files that are used to construct spec
34417strings. They consist of a sequence of directives separated by blank
34418lines. The type of directive is determined by the first non-whitespace
34419character on the line, which can be one of the following:
34420
34421@table @code
34422@item %@var{command}
34423Issues a @var{command} to the spec file processor. The commands that can
34424appear here are:
34425
34426@table @code
d77de738 34427@cindex @code{%include}
f33d7a88 34428@item %include <@var{file}>
d77de738
ML
34429Search for @var{file} and insert its text at the current point in the
34430specs file.
34431
d77de738 34432@cindex @code{%include_noerr}
f33d7a88 34433@item %include_noerr <@var{file}>
d77de738
ML
34434Just like @samp{%include}, but do not generate an error message if the include
34435file cannot be found.
34436
d77de738 34437@cindex @code{%rename}
f33d7a88 34438@item %rename @var{old_name} @var{new_name}
d77de738
ML
34439Rename the spec string @var{old_name} to @var{new_name}.
34440
34441@end table
34442
34443@item *[@var{spec_name}]:
34444This tells the compiler to create, override or delete the named spec
34445string. All lines after this directive up to the next directive or
34446blank line are considered to be the text for the spec string. If this
34447results in an empty string then the spec is deleted. (Or, if the
34448spec did not exist, then nothing happens.) Otherwise, if the spec
34449does not currently exist a new spec is created. If the spec does
34450exist then its contents are overridden by the text of this
34451directive, unless the first character of that text is the @samp{+}
34452character, in which case the text is appended to the spec.
34453
34454@item [@var{suffix}]:
34455Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
34456and up to the next directive or blank line are considered to make up the
34457spec string for the indicated suffix. When the compiler encounters an
34458input file with the named suffix, it processes the spec string in
34459order to work out how to compile that file. For example:
34460
34461@smallexample
34462.ZZ:
34463z-compile -input %i
34464@end smallexample
34465
34466This says that any input file whose name ends in @samp{.ZZ} should be
34467passed to the program @samp{z-compile}, which should be invoked with the
34468command-line switch @option{-input} and with the result of performing the
34469@samp{%i} substitution. (See below.)
34470
34471As an alternative to providing a spec string, the text following a
34472suffix directive can be one of the following:
34473
34474@table @code
34475@item @@@var{language}
34476This says that the suffix is an alias for a known @var{language}. This is
34477similar to using the @option{-x} command-line switch to GCC to specify a
34478language explicitly. For example:
34479
34480@smallexample
34481.ZZ:
34482@@c++
34483@end smallexample
34484
34485Says that .ZZ files are, in fact, C++ source files.
34486
34487@item #@var{name}
34488This causes an error messages saying:
34489
34490@smallexample
34491@var{name} compiler not installed on this system.
34492@end smallexample
34493@end table
34494
34495GCC already has an extensive list of suffixes built into it.
34496This directive adds an entry to the end of the list of suffixes, but
34497since the list is searched from the end backwards, it is effectively
34498possible to override earlier entries using this technique.
34499
34500@end table
34501
34502GCC has the following spec strings built into it. Spec files can
34503override these strings or create their own. Note that individual
34504targets can also add their own spec strings to this list.
34505
34506@smallexample
34507asm Options to pass to the assembler
34508asm_final Options to pass to the assembler post-processor
34509cpp Options to pass to the C preprocessor
34510cc1 Options to pass to the C compiler
34511cc1plus Options to pass to the C++ compiler
34512endfile Object files to include at the end of the link
34513link Options to pass to the linker
34514lib Libraries to include on the command line to the linker
34515libgcc Decides which GCC support library to pass to the linker
34516linker Sets the name of the linker
34517predefines Defines to be passed to the C preprocessor
34518signed_char Defines to pass to CPP to say whether @code{char} is signed
34519 by default
34520startfile Object files to include at the start of the link
34521@end smallexample
34522
34523Here is a small example of a spec file:
34524
34525@smallexample
34526%rename lib old_lib
34527
34528*lib:
34529--start-group -lgcc -lc -leval1 --end-group %(old_lib)
34530@end smallexample
34531
34532This example renames the spec called @samp{lib} to @samp{old_lib} and
34533then overrides the previous definition of @samp{lib} with a new one.
34534The new definition adds in some extra command-line options before
34535including the text of the old definition.
34536
34537@dfn{Spec strings} are a list of command-line options to be passed to their
34538corresponding program. In addition, the spec strings can contain
34539@samp{%}-prefixed sequences to substitute variable text or to
34540conditionally insert text into the command line. Using these constructs
34541it is possible to generate quite complex command lines.
34542
34543Here is a table of all defined @samp{%}-sequences for spec
34544strings. Note that spaces are not generated automatically around the
34545results of expanding these sequences. Therefore you can concatenate them
34546together or combine them with constant text in a single argument.
34547
34548@table @code
34549@item %%
34550Substitute one @samp{%} into the program name or argument.
34551
34552@item %"
34553Substitute an empty argument.
34554
34555@item %i
34556Substitute the name of the input file being processed.
34557
34558@item %b
34559Substitute the basename for outputs related with the input file being
34560processed. This is often the substring up to (and not including) the
34561last period and not including the directory but, unless %w is active, it
34562expands to the basename for auxiliary outputs, which may be influenced
34563by an explicit output name, and by various other options that control
34564how auxiliary outputs are named.
34565
34566@item %B
34567This is the same as @samp{%b}, but include the file suffix (text after
34568the last period). Without %w, it expands to the basename for dump
34569outputs.
34570
34571@item %d
34572Marks the argument containing or following the @samp{%d} as a
34573temporary file name, so that that file is deleted if GCC exits
34574successfully. Unlike @samp{%g}, this contributes no text to the
34575argument.
34576
34577@item %g@var{suffix}
34578Substitute a file name that has suffix @var{suffix} and is chosen
34579once per compilation, and mark the argument in the same way as
34580@samp{%d}. To reduce exposure to denial-of-service attacks, the file
34581name is now chosen in a way that is hard to predict even when previously
34582chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
34583might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
34584the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
34585treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
34586was simply substituted with a file name chosen once per compilation,
34587without regard to any appended suffix (which was therefore treated
34588just like ordinary text), making such attacks more likely to succeed.
34589
34590@item %u@var{suffix}
34591Like @samp{%g}, but generates a new temporary file name
34592each time it appears instead of once per compilation.
34593
34594@item %U@var{suffix}
34595Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
34596new one if there is no such last file name. In the absence of any
34597@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
34598the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
34599involves the generation of two distinct file names, one
34600for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
34601simply substituted with a file name chosen for the previous @samp{%u},
34602without regard to any appended suffix.
34603
34604@item %j@var{suffix}
34605Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
34606writable, and if @option{-save-temps} is not used;
34607otherwise, substitute the name
34608of a temporary file, just like @samp{%u}. This temporary file is not
34609meant for communication between processes, but rather as a junk
34610disposal mechanism.
34611
34612@item %|@var{suffix}
34613@itemx %m@var{suffix}
34614Like @samp{%g}, except if @option{-pipe} is in effect. In that case
34615@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
34616all. These are the two most common ways to instruct a program that it
34617should read from standard input or write to standard output. If you
34618need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
34619construct: see for example @file{gcc/fortran/lang-specs.h}.
34620
34621@item %.@var{SUFFIX}
34622Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
34623when it is subsequently output with @samp{%*}. @var{SUFFIX} is
34624terminated by the next space or %.
34625
34626@item %w
34627Marks the argument containing or following the @samp{%w} as the
34628designated output file of this compilation. This puts the argument
34629into the sequence of arguments that @samp{%o} substitutes.
34630
34631@item %V
34632Indicates that this compilation produces no output file.
34633
34634@item %o
34635Substitutes the names of all the output files, with spaces
34636automatically placed around them. You should write spaces
34637around the @samp{%o} as well or the results are undefined.
34638@samp{%o} is for use in the specs for running the linker.
34639Input files whose names have no recognized suffix are not compiled
34640at all, but they are included among the output files, so they are
34641linked.
34642
34643@item %O
34644Substitutes the suffix for object files. Note that this is
34645handled specially when it immediately follows @samp{%g, %u, or %U},
34646because of the need for those to form complete file names. The
34647handling is such that @samp{%O} is treated exactly as if it had already
34648been substituted, except that @samp{%g, %u, and %U} do not currently
34649support additional @var{suffix} characters following @samp{%O} as they do
34650following, for example, @samp{.o}.
34651
34652@item %I
34653Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
34654@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
34655@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
34656and @option{-imultilib} as necessary.
34657
34658@item %s
34659Current argument is the name of a library or startup file of some sort.
34660Search for that file in a standard list of directories and substitute
34661the full name found. The current working directory is included in the
34662list of directories scanned.
34663
34664@item %T
34665Current argument is the name of a linker script. Search for that file
34666in the current list of directories to scan for libraries. If the file
34667is located insert a @option{--script} option into the command line
34668followed by the full path name found. If the file is not found then
34669generate an error message. Note: the current working directory is not
34670searched.
34671
34672@item %e@var{str}
34673Print @var{str} as an error message. @var{str} is terminated by a newline.
34674Use this when inconsistent options are detected.
34675
34676@item %n@var{str}
34677Print @var{str} as a notice. @var{str} is terminated by a newline.
34678
34679@item %(@var{name})
34680Substitute the contents of spec string @var{name} at this point.
34681
34682@item %x@{@var{option}@}
34683Accumulate an option for @samp{%X}.
34684
34685@item %X
34686Output the accumulated linker options specified by a @samp{%x} spec string.
34687
34688@item %Y
34689Output the accumulated assembler options specified by @option{-Wa}.
34690
34691@item %Z
34692Output the accumulated preprocessor options specified by @option{-Wp}.
34693
34694@item %M
34695Output @code{multilib_os_dir}.
34696
34697@item %R
34698Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
34699
34700@item %a
34701Process the @code{asm} spec. This is used to compute the
34702switches to be passed to the assembler.
34703
34704@item %A
34705Process the @code{asm_final} spec. This is a spec string for
34706passing switches to an assembler post-processor, if such a program is
34707needed.
34708
34709@item %l
34710Process the @code{link} spec. This is the spec for computing the
34711command line passed to the linker. Typically it makes use of the
34712@samp{%L %G %S %D and %E} sequences.
34713
34714@item %D
34715Dump out a @option{-L} option for each directory that GCC believes might
34716contain startup files. If the target supports multilibs then the
34717current multilib directory is prepended to each of these paths.
34718
34719@item %L
34720Process the @code{lib} spec. This is a spec string for deciding which
34721libraries are included on the command line to the linker.
34722
34723@item %G
34724Process the @code{libgcc} spec. This is a spec string for deciding
34725which GCC support library is included on the command line to the linker.
34726
34727@item %S
34728Process the @code{startfile} spec. This is a spec for deciding which
34729object files are the first ones passed to the linker. Typically
34730this might be a file named @file{crt0.o}.
34731
34732@item %E
34733Process the @code{endfile} spec. This is a spec string that specifies
34734the last object files that are passed to the linker.
34735
34736@item %C
34737Process the @code{cpp} spec. This is used to construct the arguments
34738to be passed to the C preprocessor.
34739
34740@item %1
34741Process the @code{cc1} spec. This is used to construct the options to be
34742passed to the actual C compiler (@command{cc1}).
34743
34744@item %2
34745Process the @code{cc1plus} spec. This is used to construct the options to be
34746passed to the actual C++ compiler (@command{cc1plus}).
34747
34748@item %*
34749Substitute the variable part of a matched option. See below.
34750Note that each comma in the substituted string is replaced by
34751a single space.
34752
34753@item %<S
34754Remove all occurrences of @code{-S} from the command line. Note---this
34755command is position dependent. @samp{%} commands in the spec string
34756before this one see @code{-S}, @samp{%} commands in the spec string
34757after this one do not.
34758
34759@item %<S*
34760Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
34761
34762@item %>S
34763Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
34764
34765@item %:@var{function}(@var{args})
34766Call the named function @var{function}, passing it @var{args}.
34767@var{args} is first processed as a nested spec string, then split
34768into an argument vector in the usual fashion. The function returns
34769a string which is processed as if it had appeared literally as part
34770of the current spec.
34771
34772The following built-in spec functions are provided:
34773
34774@table @code
34775@item @code{getenv}
34776The @code{getenv} spec function takes two arguments: an environment
34777variable name and a string. If the environment variable is not
34778defined, a fatal error is issued. Otherwise, the return value is the
34779value of the environment variable concatenated with the string. For
34780example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
34781
34782@smallexample
34783%:getenv(TOPDIR /include)
34784@end smallexample
34785
34786expands to @file{/path/to/top/include}.
34787
34788@item @code{if-exists}
34789The @code{if-exists} spec function takes one argument, an absolute
34790pathname to a file. If the file exists, @code{if-exists} returns the
34791pathname. Here is a small example of its usage:
34792
34793@smallexample
34794*startfile:
34795crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
34796@end smallexample
34797
34798@item @code{if-exists-else}
34799The @code{if-exists-else} spec function is similar to the @code{if-exists}
34800spec function, except that it takes two arguments. The first argument is
34801an absolute pathname to a file. If the file exists, @code{if-exists-else}
34802returns the pathname. If it does not exist, it returns the second argument.
34803This way, @code{if-exists-else} can be used to select one file or another,
34804based on the existence of the first. Here is a small example of its usage:
34805
34806@smallexample
34807*startfile:
34808crt0%O%s %:if-exists(crti%O%s) \
34809%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
34810@end smallexample
34811
34812@item @code{if-exists-then-else}
34813The @code{if-exists-then-else} spec function takes at least two arguments
34814and an optional third one. The first argument is an absolute pathname to a
34815file. If the file exists, the function returns the second argument.
34816If the file does not exist, the function returns the third argument if there
34817is one, or NULL otherwise. This can be used to expand one text, or optionally
34818another, based on the existence of a file. Here is a small example of its
34819usage:
34820
34821@smallexample
34822-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
34823@end smallexample
34824
34825@item @code{sanitize}
34826The @code{sanitize} spec function takes no arguments. It returns non-NULL if
34827any address, thread or undefined behavior sanitizers are active.
34828
34829@smallexample
34830%@{%:sanitize(address):-funwind-tables@}
34831@end smallexample
34832
34833@item @code{replace-outfile}
34834The @code{replace-outfile} spec function takes two arguments. It looks for the
34835first argument in the outfiles array and replaces it with the second argument. Here
34836is a small example of its usage:
34837
34838@smallexample
34839%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
34840@end smallexample
34841
34842@item @code{remove-outfile}
34843The @code{remove-outfile} spec function takes one argument. It looks for the
34844first argument in the outfiles array and removes it. Here is a small example
34845its usage:
34846
34847@smallexample
34848%:remove-outfile(-lm)
34849@end smallexample
34850
34851@item @code{version-compare}
34852The @code{version-compare} spec function takes four or five arguments of the following
34853form:
34854
34855@smallexample
34856<comparison-op> <arg1> [<arg2>] <switch> <result>
34857@end smallexample
34858
34859It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
34860The supported @code{comparison-op} values are:
34861
34862@table @code
34863@item >=
34864True if @code{switch} is a later (or same) version than @code{arg1}
34865
34866@item !>
34867Opposite of @code{>=}
34868
34869@item <
34870True if @code{switch} is an earlier version than @code{arg1}
34871
34872@item !<
34873Opposite of @code{<}
34874
34875@item ><
34876True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
34877
34878@item <>
34879True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
34880@end table
34881
34882If the @code{switch} is not present at all, the condition is false unless the first character
34883of the @code{comparison-op} is @code{!}.
34884
34885@smallexample
34886%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
34887@end smallexample
34888
34889The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
34890passed.
34891
34892@item @code{include}
34893The @code{include} spec function behaves much like @code{%include}, with the advantage
34894that it can be nested inside a spec and thus be conditionalized. It takes one argument,
34895the filename, and looks for it in the startfile path. It always returns NULL.
34896
34897@smallexample
34898%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
34899@end smallexample
34900
34901@item @code{pass-through-libs}
34902The @code{pass-through-libs} spec function takes any number of arguments. It
34903finds any @option{-l} options and any non-options ending in @file{.a} (which it
34904assumes are the names of linker input library archive files) and returns a
34905result containing all the found arguments each prepended by
34906@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
34907intended to be passed to the LTO linker plugin.
34908
34909@smallexample
34910%:pass-through-libs(%G %L %G)
34911@end smallexample
34912
34913@item @code{print-asm-header}
34914The @code{print-asm-header} function takes no arguments and simply
34915prints a banner like:
34916
34917@smallexample
34918Assembler options
34919=================
34920
34921Use "-Wa,OPTION" to pass "OPTION" to the assembler.
34922@end smallexample
34923
34924It is used to separate compiler options from assembler options
34925in the @option{--target-help} output.
34926
34927@item @code{gt}
34928The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
34929empty string) if the second-to-last argument is greater than the last argument, and NULL
34930otherwise. The following example inserts the @code{link_gomp} spec if the last
34931@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
34932
34933@smallexample
34934%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
34935@end smallexample
34936
34937@item @code{debug-level-gt}
34938The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
34939empty string) if @code{debug_info_level} is greater than the specified number, and NULL
34940otherwise.
34941
34942@smallexample
34943%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
34944@end smallexample
34945@end table
34946
34947@item %@{S@}
34948Substitutes the @code{-S} switch, if that switch is given to GCC@.
34949If that switch is not specified, this substitutes nothing. Note that
34950the leading dash is omitted when specifying this option, and it is
34951automatically inserted if the substitution is performed. Thus the spec
34952string @samp{%@{foo@}} matches the command-line option @option{-foo}
34953and outputs the command-line option @option{-foo}.
34954
34955@item %W@{S@}
34956Like %@{@code{S}@} but mark last argument supplied within as a file to be
34957deleted on failure.
34958
34959@item %@@@{S@}
34960Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
34961@code{@@FILE} if an @code{@@file} argument has been supplied.
34962
34963@item %@{S*@}
34964Substitutes all the switches specified to GCC whose names start
34965with @code{-S}, but which also take an argument. This is used for
34966switches like @option{-o}, @option{-D}, @option{-I}, etc.
34967GCC considers @option{-o foo} as being
34968one switch whose name starts with @samp{o}. %@{o*@} substitutes this
34969text, including the space. Thus two arguments are generated.
34970
34971@item %@{S*&T*@}
34972Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
34973(the order of @code{S} and @code{T} in the spec is not significant).
34974There can be any number of ampersand-separated variables; for each the
34975wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
34976
34977@item %@{S:X@}
34978Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
34979
34980@item %@{!S:X@}
34981Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
34982
34983@item %@{S*:X@}
34984Substitutes @code{X} if one or more switches whose names start with
34985@code{-S} are specified to GCC@. Normally @code{X} is substituted only
34986once, no matter how many such switches appeared. However, if @code{%*}
34987appears somewhere in @code{X}, then @code{X} is substituted once
34988for each matching switch, with the @code{%*} replaced by the part of
34989that switch matching the @code{*}.
34990
34991If @code{%*} appears as the last part of a spec sequence then a space
34992is added after the end of the last substitution. If there is more
34993text in the sequence, however, then a space is not generated. This
34994allows the @code{%*} substitution to be used as part of a larger
34995string. For example, a spec string like this:
34996
34997@smallexample
34998%@{mcu=*:--script=%*/memory.ld@}
34999@end smallexample
35000
35001@noindent
35002when matching an option like @option{-mcu=newchip} produces:
35003
35004@smallexample
35005--script=newchip/memory.ld
35006@end smallexample
35007
35008@item %@{.S:X@}
35009Substitutes @code{X}, if processing a file with suffix @code{S}.
35010
35011@item %@{!.S:X@}
35012Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
35013
35014@item %@{,S:X@}
35015Substitutes @code{X}, if processing a file for language @code{S}.
35016
35017@item %@{!,S:X@}
35018Substitutes @code{X}, if not processing a file for language @code{S}.
35019
35020@item %@{S|P:X@}
35021Substitutes @code{X} if either @code{-S} or @code{-P} is given to
35022GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
35023@code{*} sequences as well, although they have a stronger binding than
35024the @samp{|}. If @code{%*} appears in @code{X}, all of the
35025alternatives must be starred, and only the first matching alternative
35026is substituted.
35027
35028For example, a spec string like this:
35029
35030@smallexample
35031%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
35032@end smallexample
35033
35034@noindent
35035outputs the following command-line options from the following input
35036command-line options:
35037
35038@smallexample
35039fred.c -foo -baz
35040jim.d -bar -boggle
35041-d fred.c -foo -baz -boggle
35042-d jim.d -bar -baz -boggle
35043@end smallexample
35044
35045@item %@{%:@var{function}(@var{args}):X@}
35046
35047Call function named @var{function} with args @var{args}. If the
35048function returns non-NULL, then @code{X} is substituted, if it returns
35049NULL, it isn't substituted.
35050
35051@item %@{S:X; T:Y; :D@}
35052
35053If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
35054given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
35055be as many clauses as you need. This may be combined with @code{.},
35056@code{,}, @code{!}, @code{|}, and @code{*} as needed.
35057
35058
35059@end table
35060
35061The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
35062or similar construct can use a backslash to ignore the special meaning
35063of the character following it, thus allowing literal matching of a
35064character that is otherwise specially treated. For example,
35065@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
35066@option{-std=iso9899:1999} option is given.
35067
35068The conditional text @code{X} in a @samp{%@{S:X@}} or similar
35069construct may contain other nested @samp{%} constructs or spaces, or
35070even newlines. They are processed as usual, as described above.
35071Trailing white space in @code{X} is ignored. White space may also
35072appear anywhere on the left side of the colon in these constructs,
35073except between @code{.} or @code{*} and the corresponding word.
35074
35075The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
35076handled specifically in these constructs. If another value of
35077@option{-O} or the negated form of a @option{-f}, @option{-m}, or
35078@option{-W} switch is found later in the command line, the earlier
35079switch value is ignored, except with @{@code{S}*@} where @code{S} is
35080just one letter, which passes all matching options.
35081
35082The character @samp{|} at the beginning of the predicate text is used to
35083indicate that a command should be piped to the following command, but
35084only if @option{-pipe} is specified.
35085
35086It is built into GCC which switches take arguments and which do not.
35087(You might think it would be useful to generalize this to allow each
35088compiler's spec to say which switches take arguments. But this cannot
35089be done in a consistent fashion. GCC cannot even decide which input
35090files have been specified without knowing which switches take arguments,
35091and it must know which input files to compile in order to tell which
35092compilers to run).
35093
35094GCC also knows implicitly that arguments starting in @option{-l} are to be
35095treated as compiler output files, and passed to the linker in their
35096proper position among the other output files.
35097
35098@node Environment Variables
35099@section Environment Variables Affecting GCC
35100@cindex environment variables
35101
35102@c man begin ENVIRONMENT
35103This section describes several environment variables that affect how GCC
35104operates. Some of them work by specifying directories or prefixes to use
35105when searching for various kinds of files. Some are used to specify other
35106aspects of the compilation environment.
35107
35108Note that you can also specify places to search using options such as
35109@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
35110take precedence over places specified using environment variables, which
35111in turn take precedence over those specified by the configuration of GCC@.
35112@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
35113GNU Compiler Collection (GCC) Internals}.
35114
35115@table @env
f33d7a88
AA
35116@vindex LANG
35117@vindex LC_CTYPE
35118@c @vindex LC_COLLATE
35119@vindex LC_MESSAGES
35120@c @vindex LC_MONETARY
35121@c @vindex LC_NUMERIC
35122@c @vindex LC_TIME
35123@vindex LC_ALL
35124@cindex locale
d77de738
ML
35125@item LANG
35126@itemx LC_CTYPE
35127@c @itemx LC_COLLATE
35128@itemx LC_MESSAGES
35129@c @itemx LC_MONETARY
35130@c @itemx LC_NUMERIC
35131@c @itemx LC_TIME
35132@itemx LC_ALL
d77de738
ML
35133These environment variables control the way that GCC uses
35134localization information which allows GCC to work with different
35135national conventions. GCC inspects the locale categories
35136@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
35137so. These locale categories can be set to any value supported by your
35138installation. A typical value is @samp{en_GB.UTF-8} for English in the United
35139Kingdom encoded in UTF-8.
35140
35141The @env{LC_CTYPE} environment variable specifies character
35142classification. GCC uses it to determine the character boundaries in
35143a string; this is needed for some multibyte encodings that contain quote
35144and escape characters that are otherwise interpreted as a string
35145end or escape.
35146
35147The @env{LC_MESSAGES} environment variable specifies the language to
35148use in diagnostic messages.
35149
35150If the @env{LC_ALL} environment variable is set, it overrides the value
35151of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
35152and @env{LC_MESSAGES} default to the value of the @env{LANG}
35153environment variable. If none of these variables are set, GCC
35154defaults to traditional C English behavior.
35155
f33d7a88 35156@vindex TMPDIR
d77de738 35157@item TMPDIR
d77de738
ML
35158If @env{TMPDIR} is set, it specifies the directory to use for temporary
35159files. GCC uses temporary files to hold the output of one stage of
35160compilation which is to be used as input to the next stage: for example,
35161the output of the preprocessor, which is the input to the compiler
35162proper.
35163
f33d7a88 35164@vindex GCC_COMPARE_DEBUG
d77de738 35165@item GCC_COMPARE_DEBUG
d77de738
ML
35166Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
35167@option{-fcompare-debug} to the compiler driver. See the documentation
35168of this option for more details.
35169
f33d7a88 35170@vindex GCC_EXEC_PREFIX
d77de738 35171@item GCC_EXEC_PREFIX
d77de738
ML
35172If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
35173names of the subprograms executed by the compiler. No slash is added
35174when this prefix is combined with the name of a subprogram, but you can
35175specify a prefix that ends with a slash if you wish.
35176
35177If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
35178an appropriate prefix to use based on the pathname it is invoked with.
35179
35180If GCC cannot find the subprogram using the specified prefix, it
35181tries looking in the usual places for the subprogram.
35182
35183The default value of @env{GCC_EXEC_PREFIX} is
35184@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
35185the installed compiler. In many cases @var{prefix} is the value
35186of @code{prefix} when you ran the @file{configure} script.
35187
35188Other prefixes specified with @option{-B} take precedence over this prefix.
35189
35190This prefix is also used for finding files such as @file{crt0.o} that are
35191used for linking.
35192
35193In addition, the prefix is used in an unusual way in finding the
35194directories to search for header files. For each of the standard
35195directories whose name normally begins with @samp{/usr/local/lib/gcc}
35196(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
35197replacing that beginning with the specified prefix to produce an
35198alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
35199@file{foo/bar} just before it searches the standard directory
35200@file{/usr/local/lib/bar}.
35201If a standard directory begins with the configured
35202@var{prefix} then the value of @var{prefix} is replaced by
35203@env{GCC_EXEC_PREFIX} when looking for header files.
35204
f33d7a88 35205@vindex COMPILER_PATH
d77de738 35206@item COMPILER_PATH
d77de738
ML
35207The value of @env{COMPILER_PATH} is a colon-separated list of
35208directories, much like @env{PATH}. GCC tries the directories thus
35209specified when searching for subprograms, if it cannot find the
35210subprograms using @env{GCC_EXEC_PREFIX}.
35211
f33d7a88 35212@vindex LIBRARY_PATH
d77de738 35213@item LIBRARY_PATH
d77de738
ML
35214The value of @env{LIBRARY_PATH} is a colon-separated list of
35215directories, much like @env{PATH}. When configured as a native compiler,
35216GCC tries the directories thus specified when searching for special
35217linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35218using GCC also uses these directories when searching for ordinary
35219libraries for the @option{-l} option (but directories specified with
35220@option{-L} come first).
35221
f33d7a88 35222@vindex LANG
d77de738 35223@cindex locale definition
f33d7a88 35224@item LANG
d77de738
ML
35225This variable is used to pass locale information to the compiler. One way in
35226which this information is used is to determine the character set to be used
35227when character literals, string literals and comments are parsed in C and C++.
35228When the compiler is configured to allow multibyte characters,
35229the following values for @env{LANG} are recognized:
35230
35231@table @samp
35232@item C-JIS
35233Recognize JIS characters.
35234@item C-SJIS
35235Recognize SJIS characters.
35236@item C-EUCJP
35237Recognize EUCJP characters.
35238@end table
35239
35240If @env{LANG} is not defined, or if it has some other value, then the
35241compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35242recognize and translate multibyte characters.
35243
f33d7a88 35244@vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738 35245@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
d77de738
ML
35246If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
35247then additional text will be emitted to stderr when fix-it hints are
35248emitted. @option{-fdiagnostics-parseable-fixits} and
35249@option{-fno-diagnostics-parseable-fixits} take precedence over this
35250environment variable.
35251
35252@table @samp
35253@item fixits-v1
35254Emit parseable fix-it hints, equivalent to
35255@option{-fdiagnostics-parseable-fixits}. In particular, columns are
35256expressed as a count of bytes, starting at byte 1 for the initial column.
35257
35258@item fixits-v2
35259As @code{fixits-v1}, but columns are expressed as display columns,
35260as per @option{-fdiagnostics-column-unit=display}.
35261@end table
35262
35263@end table
35264
35265@noindent
35266Some additional environment variables affect the behavior of the
35267preprocessor.
35268
35269@include cppenv.texi
35270
35271@c man end
35272
35273@node Precompiled Headers
35274@section Using Precompiled Headers
35275@cindex precompiled headers
35276@cindex speed of compilation
35277
35278Often large projects have many header files that are included in every
35279source file. The time the compiler takes to process these header files
35280over and over again can account for nearly all of the time required to
35281build the project. To make builds faster, GCC allows you to
35282@dfn{precompile} a header file.
35283
35284To create a precompiled header file, simply compile it as you would any
35285other file, if necessary using the @option{-x} option to make the driver
35286treat it as a C or C++ header file. You may want to use a
35287tool like @command{make} to keep the precompiled header up-to-date when
35288the headers it contains change.
35289
35290A precompiled header file is searched for when @code{#include} is
35291seen in the compilation. As it searches for the included file
35292(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
35293compiler looks for a precompiled header in each directory just before it
35294looks for the include file in that directory. The name searched for is
35295the name specified in the @code{#include} with @samp{.gch} appended. If
35296the precompiled header file cannot be used, it is ignored.
35297
35298For instance, if you have @code{#include "all.h"}, and you have
35299@file{all.h.gch} in the same directory as @file{all.h}, then the
35300precompiled header file is used if possible, and the original
35301header is used otherwise.
35302
35303Alternatively, you might decide to put the precompiled header file in a
35304directory and use @option{-I} to ensure that directory is searched
35305before (or instead of) the directory containing the original header.
35306Then, if you want to check that the precompiled header file is always
35307used, you can put a file of the same name as the original header in this
35308directory containing an @code{#error} command.
35309
35310This also works with @option{-include}. So yet another way to use
35311precompiled headers, good for projects not designed with precompiled
35312header files in mind, is to simply take most of the header files used by
35313a project, include them from another header file, precompile that header
35314file, and @option{-include} the precompiled header. If the header files
35315have guards against multiple inclusion, they are skipped because
35316they've already been included (in the precompiled header).
35317
35318If you need to precompile the same header file for different
35319languages, targets, or compiler options, you can instead make a
35320@emph{directory} named like @file{all.h.gch}, and put each precompiled
35321header in the directory, perhaps using @option{-o}. It doesn't matter
35322what you call the files in the directory; every precompiled header in
35323the directory is considered. The first precompiled header
35324encountered in the directory that is valid for this compilation is
35325used; they're searched in no particular order.
35326
35327There are many other possibilities, limited only by your imagination,
35328good sense, and the constraints of your build system.
35329
35330A precompiled header file can be used only when these conditions apply:
35331
35332@itemize
35333@item
35334Only one precompiled header can be used in a particular compilation.
35335
35336@item
35337A precompiled header cannot be used once the first C token is seen. You
35338can have preprocessor directives before a precompiled header; you cannot
35339include a precompiled header from inside another header.
35340
35341@item
35342The precompiled header file must be produced for the same language as
35343the current compilation. You cannot use a C precompiled header for a C++
35344compilation.
35345
35346@item
35347The precompiled header file must have been produced by the same compiler
35348binary as the current compilation is using.
35349
35350@item
35351Any macros defined before the precompiled header is included must
35352either be defined in the same way as when the precompiled header was
35353generated, or must not affect the precompiled header, which usually
35354means that they don't appear in the precompiled header at all.
35355
35356The @option{-D} option is one way to define a macro before a
35357precompiled header is included; using a @code{#define} can also do it.
35358There are also some options that define macros implicitly, like
35359@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35360defined this way.
35361
35362@item If debugging information is output when using the precompiled
35363header, using @option{-g} or similar, the same kind of debugging information
35364must have been output when building the precompiled header. However,
35365a precompiled header built using @option{-g} can be used in a compilation
35366when no debugging information is being output.
35367
35368@item The same @option{-m} options must generally be used when building
35369and using the precompiled header. @xref{Submodel Options},
35370for any cases where this rule is relaxed.
35371
35372@item Each of the following options must be the same when building and using
35373the precompiled header:
35374
35375@gccoptlist{-fexceptions}
35376
35377@item
35378Some other command-line options starting with @option{-f},
35379@option{-p}, or @option{-O} must be defined in the same way as when
35380the precompiled header was generated. At present, it's not clear
35381which options are safe to change and which are not; the safest choice
35382is to use exactly the same options when generating and using the
35383precompiled header. The following are known to be safe:
35384
35385@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock @gol
35386-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous @gol
35387-fsched-verbose=@var{number} -fschedule-insns -fvisibility= @gol
35388-pedantic-errors}
35389
35390@item Address space layout randomization (ASLR) can lead to not binary identical
35391PCH files. If you rely on stable PCH file contents disable ASLR when generating
35392PCH files.
35393
35394@end itemize
35395
35396For all of these except the last, the compiler automatically
35397ignores the precompiled header if the conditions aren't met. If you
35398find an option combination that doesn't work and doesn't cause the
35399precompiled header to be ignored, please consider filing a bug report,
35400see @ref{Bugs}.
35401
35402If you do use differing options when generating and using the
35403precompiled header, the actual behavior is a mixture of the
35404behavior for the options. For instance, if you use @option{-g} to
35405generate the precompiled header but not when using it, you may or may
35406not get debugging information for routines in the precompiled header.
35407
35408@node C++ Modules
35409@section C++ Modules
35410@cindex speed of compilation
35411
35412Modules are a C++20 language feature. As the name suggests, they
35413provides a modular compilation system, intending to provide both
35414faster builds and better library isolation. The ``Merging Modules''
35415paper @uref{https://wg21.link/p1103}, provides the easiest to read set
35416of changes to the standard, although it does not capture later
35417changes.
35418
35419@emph{G++'s modules support is not complete.} Other than bugs, the
35420known missing pieces are:
35421
35422@table @emph
35423
35424@item Private Module Fragment
35425The Private Module Fragment is recognized, but an error is emitted.
35426
35427@item Partition definition visibility rules
35428Entities may be defined in implementation partitions, and those
35429definitions are not available outside of the module. This is not
35430implemented, and the definitions are available to extra-module use.
35431
35432@item Textual merging of reachable GM entities
35433Entities may be multiply defined across different header-units.
35434These must be de-duplicated, and this is implemented across imports,
35435or when an import redefines a textually-defined entity. However the
35436reverse is not implemented---textually redefining an entity that has
35437been defined in an imported header-unit. A redefinition error is
35438emitted.
35439
35440@item Translation-Unit local referencing rules
35441Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
35442(@uref{https://wg21.link/p2003}) add limitations on which entities an
35443exported region may reference (for instance, the entities an exported
35444template definition may reference). These are not fully implemented.
35445
35446@item Standard Library Header Units
35447The Standard Library is not provided as importable header units. If
35448you want to import such units, you must explicitly build them first.
35449If you do not do this with care, you may have multiple declarations,
35450which the module machinery must merge---compiler resource usage can be
35451affected by how you partition header files into header units.
35452
35453@end table
35454
35455Modular compilation is @emph{not} enabled with just the
35456@option{-std=c++20} option. You must explicitly enable it with the
35457@option{-fmodules-ts} option. It is independent of the language
35458version selected, although in pre-C++20 versions, it is of course an
35459extension.
35460
35461No new source file suffixes are required or supported. If you wish to
35462use a non-standard suffix (@pxref{Overall Options}), you also need
35463to provide a @option{-x c++} option too.@footnote{Some users like to
35464distinguish module interface files with a new suffix, such as naming
35465the source @code{module.cppm}, which involves
35466teaching all tools about the new suffix. A different scheme, such as
35467naming @code{module-m.cpp} would be less invasive.}
35468
35469Compiling a module interface unit produces an additional output (to
35470the assembly or object file), called a Compiled Module Interface
35471(CMI). This encodes the exported declarations of the module.
35472Importing a module reads in the CMI. The import graph is a Directed
35473Acyclic Graph (DAG). You must build imports before the importer.
35474
35475Header files may themselves be compiled to header units, which are a
35476transitional ability aiming at faster compilation. The
35477@option{-fmodule-header} option is used to enable this, and implies
35478the @option{-fmodules-ts} option. These CMIs are named by the fully
35479resolved underlying header file, and thus may be a complete pathname
35480containing subdirectories. If the header file is found at an absolute
35481pathname, the CMI location is still relative to a CMI root directory.
35482
35483As header files often have no suffix, you commonly have to specify a
35484@option{-x} option to tell the compiler the source is a header file.
35485You may use @option{-x c++-header}, @option{-x c++-user-header} or
35486@option{-x c++-system-header}. When used in conjunction with
35487@option{-fmodules-ts}, these all imply an appropriate
35488@option{-fmodule-header} option. The latter two variants use the
35489user or system include path to search for the file specified. This
35490allows you to, for instance, compile standard library header files as
35491header units, without needing to know exactly where they are
35492installed. Specifying the language as one of these variants also
35493inhibits output of the object file, as header files have no associated
35494object file.
35495
35496The @option{-fmodule-only} option disables generation of the
35497associated object file for compiling a module interface. Only the CMI
35498is generated. This option is implied when using the
35499@option{-fmodule-header} option.
35500
35501The @option{-flang-info-include-translate} and
35502@option{-flang-info-include-translate-not} options notes whether
35503include translation occurs or not. With no argument, the first will
35504note all include translation. The second will note all
35505non-translations of include files not known to intentionally be
35506textual. With an argument, queries about include translation of a
35507header files with that particular trailing pathname are noted. You
35508may repeat this form to cover several different header files. This
35509option may be helpful in determining whether include translation is
35510happening---if it is working correctly, it behaves as if it isn't
35511there at all.
35512
35513The @option{-flang-info-module-cmi} option can be used to determine
35514where the compiler is reading a CMI from. Without the option, the
35515compiler is silent when such a read is successful. This option has an
35516optional argument, which will restrict the notification to just the
35517set of named modules or header units specified.
35518
35519The @option{-Winvalid-imported-macros} option causes all imported macros
35520to be resolved at the end of compilation. Without this, imported
35521macros are only resolved when expanded or (re)defined. This option
35522detects conflicting import definitions for all macros.
35523
35524For details of the @option{-fmodule-mapper} family of options,
35525@pxref{C++ Module Mapper}.
35526
35527@menu
35528* C++ Module Mapper:: Module Mapper
35529* C++ Module Preprocessing:: Module Preprocessing
35530* C++ Compiled Module Interface:: Compiled Module Interface
35531@end menu
35532
35533@node C++ Module Mapper
35534@subsection Module Mapper
35535@cindex C++ Module Mapper
35536
35537A module mapper provides a server or file that the compiler queries to
35538determine the mapping between module names and CMI files. It is also
35539used to build CMIs on demand. @emph{Mapper functionality is in its
35540infancy and is intended for experimentation with build system
35541interactions.}
35542
35543You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
35544option or @env{CXX_MODULE_MAPPER} environment variable. The value may
35545have one of the following forms:
35546
35547@table @gcctabopt
35548
35549@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
35550An optional hostname and a numeric port number to connect to. If the
35551hostname is omitted, the loopback address is used. If the hostname
35552corresponds to multiple IPV6 addresses, these are tried in turn, until
35553one is successful. If your host lacks IPv6, this form is
35554non-functional. If you must use IPv4 use
35555@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
35556
35557@item =@var{socket}@r{[}?@var{ident}@r{]}
35558A local domain socket. If your host lacks local domain sockets, this
35559form is non-functional.
35560
35561@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
35562A program to spawn, and communicate with on its stdin/stdout streams.
35563Your @var{PATH} environment variable is searched for the program.
35564Arguments are separated by space characters, (it is not possible for
35565one of the arguments delivered to the program to contain a space). An
35566exception is if @var{program} begins with @@. In that case
35567@var{program} (sans @@) is looked for in the compiler's internal
35568binary directory. Thus the sample mapper-server can be specified
35569with @code{@@g++-mapper-server}.
35570
35571@item <>@r{[}?@var{ident}@r{]}
35572@item <>@var{inout}@r{[}?@var{ident}@r{]}
35573@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
35574Named pipes or file descriptors to communicate over. The first form,
35575@option{<>}, communicates over stdin and stdout. The other forms
35576allow you to specify a file descriptor or name a pipe. A numeric value
35577is interpreted as a file descriptor, otherwise named pipe is opened.
35578The second form specifies a bidirectional pipe and the last form
35579allows specifying two independent pipes. Using file descriptors
35580directly in this manner is fragile in general, as it can require the
35581cooperation of intermediate processes. In particular using stdin &
35582stdout is fraught with danger as other compiler options might also
35583cause the compiler to read stdin or write stdout, and it can have
35584unfortunate interactions with signal delivery from the terminal.
35585
35586@item @var{file}@r{[}?@var{ident}@r{]}
35587A mapping file consisting of space-separated module-name, filename
35588pairs, one per line. Only the mappings for the direct imports and any
35589module export name need be provided. If other mappings are provided,
35590they override those stored in any imported CMI files. A repository
35591root may be specified in the mapping file by using @samp{$root} as the
35592module name in the first active line. Use of this option will disable
35593any default module->CMI name mapping.
35594
35595@end table
35596
35597As shown, an optional @var{ident} may suffix the first word of the
35598option, indicated by a @samp{?} prefix. The value is used in the
35599initial handshake with the module server, or to specify a prefix on
35600mapping file lines. In the server case, the main source file name is
35601used if no @var{ident} is specified. In the file case, all non-blank
35602lines are significant, unless a value is specified, in which case only
35603lines beginning with @var{ident} are significant. The @var{ident}
35604must be separated by whitespace from the module name. Be aware that
35605@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
35606significant to the shell, and therefore may need quoting.
35607
35608The mapper is connected to or loaded lazily, when the first module
35609mapping is required. The networking protocols are only supported on
35610hosts that provide networking. If no mapper is specified a default is
35611provided.
35612
35613A project-specific mapper is expected to be provided by the build
35614system that invokes the compiler. It is not expected that a
35615general-purpose server is provided for all compilations. As such, the
35616server will know the build configuration, the compiler it invoked, and
35617the environment (such as working directory) in which that is
35618operating. As it may parallelize builds, several compilations may
35619connect to the same socket.
35620
35621The default mapper generates CMI files in a @samp{gcm.cache}
35622directory. CMI files have a @samp{.gcm} suffix. The module unit name
35623is used directly to provide the basename. Header units construct a
35624relative path using the underlying header file name. If the path is
35625already relative, a @samp{,} directory is prepended. Internal
35626@samp{..} components are translated to @samp{,,}. No attempt is made
35627to canonicalize these filenames beyond that done by the preprocessor's
35628include search algorithm, as in general it is ambiguous when symbolic
35629links are present.
35630
35631The mapper protocol was published as ``A Module Mapper''
35632@uref{https://wg21.link/p1184}. The implementation is provided by
35633@command{libcody}, @uref{https://github.com/urnathan/libcody},
35634which specifies the canonical protocol definition. A proof of concept
35635server implementation embedded in @command{make} was described in
35636''Make Me A Module'', @uref{https://wg21.link/p1602}.
35637
35638@node C++ Module Preprocessing
35639@subsection Module Preprocessing
35640@cindex C++ Module Preprocessing
35641
35642Modules affect preprocessing because of header units and include
35643translation. Some uses of the preprocessor as a separate step either
35644do not produce a correct output, or require CMIs to be available.
35645
35646Header units import macros. These macros can affect later conditional
35647inclusion, which therefore can cascade to differing import sets. When
35648preprocessing, it is necessary to load the CMI. If a header unit is
35649unavailable, the preprocessor issues a warning and continue (when
35650not just preprocessing, an error is emitted). Detecting such imports
35651requires preprocessor tokenization of the input stream to phase 4
35652(macro expansion).
35653
35654Include translation converts @code{#include}, @code{#include_next} and
35655@code{#import} directives to internal @code{import} declarations.
35656Whether a particular directive is translated is controlled by the
35657module mapper. Header unit names are canonicalized during
35658preprocessing.
35659
35660Dependency information can be emitted for macro import, extending the
35661functionality of @option{-MD} and @option{-MMD} options. Detection of
35662import declarations also requires phase 4 preprocessing, and thus
35663requires full preprocessing (or compilation).
35664
35665The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
35666preprocessing before phase 4.
35667
35668The @option{-save-temps} option uses @option{-fdirectives-only} for
35669preprocessing, and preserve the macro definitions in the preprocessed
35670output. Usually you also want to use this option when explicitly
35671preprocessing a header-unit, or consuming such preprocessed output:
35672
35673@smallexample
35674g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
35675g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
35676@end smallexample
35677
35678@node C++ Compiled Module Interface
35679@subsection Compiled Module Interface
35680@cindex C++ Compiled Module Interface
35681
35682CMIs are an additional artifact when compiling named module
35683interfaces, partitions or header units. These are read when
35684importing. CMI contents are implementation-specific, and in GCC's
35685case tied to the compiler version. Consider them a rebuildable cache
35686artifact, not a distributable object.
35687
35688When creating an output CMI, any missing directory components are
35689created in a manner that is safe for concurrent builds creating
35690multiple, different, CMIs within a common subdirectory tree.
35691
35692CMI contents are written to a temporary file, which is then atomically
35693renamed. Observers either see old contents (if there is an
35694existing file), or complete new contents. They do not observe the
35695CMI during its creation. This is unlike object file writing, which
35696may be observed by an external process.
35697
35698CMIs are read in lazily, if the host OS provides @code{mmap}
35699functionality. Generally blocks are read when name lookup or template
35700instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
35701option may be used.
35702
35703The @option{--param lazy-modules=@var{n}} parameter controls the limit
35704on the number of concurrently open module files during lazy loading.
35705Should more modules be imported, an LRU algorithm is used to determine
35706which files to close---until that file is needed again. This limit
35707may be exceeded with deep module dependency hierarchies. With large
35708code bases there may be more imports than the process limit of file
35709descriptors. By default, the limit is a few less than the per-process
35710file descriptor hard limit, if that is determinable.@footnote{Where
35711applicable the soft limit is incremented as needed towards the hard limit.}
35712
35713GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
35714You may use @command{readelf} to inspect them, although section
35715contents are largely undecipherable. There is a section named
35716@code{.gnu.c++.README}, which contains human-readable text. Other
35717than the first line, each line consists of @code{@var{tag}: @code{value}}
35718tuples.
35719
35720@smallexample
35721> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
35722
35723String dump of section '.gnu.c++.README':
35724 [ 0] GNU C++ primary module interface
35725 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
35726 [ 6f] version: 2020/11/16-04:54
35727 [ 89] module: foo
35728 [ 95] source: c_b.ii
35729 [ a4] dialect: C++20/coroutines
35730 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
35731 [ ee] repository: gcm.cache
35732 [ 104] buildtime: 2020/11/16 15:03:21 UTC
35733 [ 127] localtime: 2020/11/16 07:03:21 PST
35734 [ 14a] export: foo:part1 foo-part1.gcm
35735@end smallexample
35736
35737Amongst other things, this lists the source that was built, C++
35738dialect used and imports of the module.@footnote{The precise contents
35739of this output may change.} The timestamp is the same value as that
35740provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
35741explicitly specified with the environment variable
35742@code{SOURCE_DATE_EPOCH}. For further details
35743@pxref{Environment Variables}.
35744
35745A set of related CMIs may be copied, provided the relative pathnames
35746are preserved.
35747
35748The @code{.gnu.c++.README} contents do not affect CMI integrity, and
35749it may be removed or altered. The section numbering of the sections
35750whose names do not begin with @code{.gnu.c++.}, or are not the string
35751section is significant and must not be altered.