]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
Daily bump.
[thirdparty/gcc.git] / gcc / doc / invoke.texi
CommitLineData
d77de738
ML
1@c Copyright (C) 1988-2022 Free Software Foundation, Inc.
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
11Copyright @copyright{} 1988-2022 Free Software Foundation, Inc.
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
194@@@var{file} -ffile-prefix-map=@var{old}=@var{new} @gol
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
346-Wconversion -Wno-coverage-mismatch -Wno-cpp @gol
347-Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} @gol
348-Wdate-time @gol
349-Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init @gol
350-Wdisabled-optimization @gol
351-Wno-discarded-array-qualifiers -Wno-discarded-qualifiers @gol
352-Wno-div-by-zero -Wdouble-promotion @gol
353-Wduplicated-branches -Wduplicated-cond @gol
354-Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion @gol
355-Wenum-int-mismatch @gol
356-Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors @gol
357-Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 @gol
358-Wno-format-contains-nul -Wno-format-extra-args @gol
359-Wformat-nonliteral -Wformat-overflow=@var{n} @gol
360-Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} @gol
361-Wformat-y2k -Wframe-address @gol
362-Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object @gol
363-Wno-if-not-aligned -Wno-ignored-attributes @gol
364-Wignored-qualifiers -Wno-incompatible-pointer-types @gol
365-Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} @gol
366-Wno-implicit-function-declaration -Wno-implicit-int @gol
367-Winfinite-recursion @gol
368-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context @gol
369-Wno-int-to-pointer-cast -Wno-invalid-memory-model @gol
370-Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init @gol
371-Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op @gol
372-Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized @gol
373-Wmemset-elt-size -Wmemset-transposed-args @gol
374-Wmisleading-indentation -Wmissing-attributes -Wmissing-braces @gol
375-Wmissing-field-initializers -Wmissing-format-attribute @gol
376-Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile @gol
377-Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare @gol
378-Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} @gol
379-Wnull-dereference -Wno-odr @gol
380-Wopenacc-parallelism @gol
381-Wopenmp-simd @gol
382-Wno-overflow -Woverlength-strings -Wno-override-init-side-effects @gol
383-Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol
384-Wparentheses -Wno-pedantic-ms-format @gol
385-Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol
386-Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
387-Wrestrict -Wno-return-local-addr -Wreturn-type @gol
388-Wno-scalar-storage-order -Wsequence-point @gol
389-Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local @gol
390-Wno-shadow-ivar @gol
391-Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value @gol
392-Wno-shift-overflow -Wshift-overflow=@var{n} @gol
393-Wsign-compare -Wsign-conversion @gol
394-Wno-sizeof-array-argument @gol
395-Wsizeof-array-div @gol
396-Wsizeof-pointer-div -Wsizeof-pointer-memaccess @gol
397-Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing @gol
398-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} @gol
399-Wstring-compare @gol
400-Wno-stringop-overflow -Wno-stringop-overread @gol
2a27ae32 401-Wno-stringop-truncation -Wstrict-flex-arrays @gol
d77de738
ML
402-Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} @gol
403-Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum @gol
404-Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand @gol
405-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol
406-Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef @gol
407-Wuninitialized -Wunknown-pragmas @gol
408-Wunsuffixed-float-constants -Wunused @gol
409-Wunused-but-set-parameter -Wunused-but-set-variable @gol
410-Wunused-const-variable -Wunused-const-variable=@var{n} @gol
411-Wunused-function -Wunused-label -Wunused-local-typedefs @gol
412-Wunused-macros @gol
413-Wunused-parameter -Wno-unused-result @gol
414-Wunused-value -Wunused-variable @gol
415-Wno-varargs -Wvariadic-macros @gol
416-Wvector-operation-performance @gol
417-Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than @gol
418-Wvolatile-register-var -Wwrite-strings @gol
419-Wxor-used-as-pow @gol
420-Wzero-length-bounds}
421
422@item Static Analyzer Options
423@gccoptlist{
424-fanalyzer @gol
425-fanalyzer-call-summaries @gol
426-fanalyzer-checker=@var{name} @gol
427-fno-analyzer-feasibility @gol
428-fanalyzer-fine-grained @gol
429-fno-analyzer-state-merge @gol
430-fno-analyzer-state-purge @gol
431-fanalyzer-transitivity @gol
432-fno-analyzer-undo-inlining @gol
433-fanalyzer-verbose-edges @gol
434-fanalyzer-verbose-state-changes @gol
435-fanalyzer-verbosity=@var{level} @gol
436-fdump-analyzer @gol
437-fdump-analyzer-callgraph @gol
438-fdump-analyzer-exploded-graph @gol
439-fdump-analyzer-exploded-nodes @gol
440-fdump-analyzer-exploded-nodes-2 @gol
441-fdump-analyzer-exploded-nodes-3 @gol
442-fdump-analyzer-exploded-paths @gol
443-fdump-analyzer-feasibility @gol
444-fdump-analyzer-json @gol
445-fdump-analyzer-state-purge @gol
446-fdump-analyzer-stderr @gol
447-fdump-analyzer-supergraph @gol
448-fdump-analyzer-untracked @gol
449-Wno-analyzer-double-fclose @gol
450-Wno-analyzer-double-free @gol
451-Wno-analyzer-exposure-through-output-file @gol
452-Wno-analyzer-exposure-through-uninit-copy @gol
453-Wno-analyzer-fd-access-mode-mismatch @gol
454-Wno-analyzer-fd-double-close @gol
455-Wno-analyzer-fd-leak @gol
86a90006
DM
456-Wno-analyzer-fd-phase-mismatch @gol
457-Wno-analyzer-fd-type-mismatch @gol
d77de738
ML
458-Wno-analyzer-fd-use-after-close @gol
459-Wno-analyzer-fd-use-without-check @gol
460-Wno-analyzer-file-leak @gol
461-Wno-analyzer-free-of-non-heap @gol
462-Wno-analyzer-imprecise-fp-arithmetic @gol
ce51e843 463-Wno-analyzer-infinite-recursion @gol
d77de738
ML
464-Wno-analyzer-jump-through-null @gol
465-Wno-analyzer-malloc-leak @gol
466-Wno-analyzer-mismatching-deallocation @gol
467-Wno-analyzer-null-argument @gol
468-Wno-analyzer-null-dereference @gol
469-Wno-analyzer-out-of-bounds @gol
470-Wno-analyzer-possible-null-argument @gol
471-Wno-analyzer-possible-null-dereference @gol
472-Wno-analyzer-putenv-of-auto-var @gol
473-Wno-analyzer-shift-count-negative @gol
474-Wno-analyzer-shift-count-overflow @gol
475-Wno-analyzer-stale-setjmp-buffer @gol
476-Wno-analyzer-tainted-allocation-size @gol
ce51e843 477-Wno-analyzer-tainted-assertion @gol
d77de738
ML
478-Wno-analyzer-tainted-array-index @gol
479-Wno-analyzer-tainted-divisor @gol
480-Wno-analyzer-tainted-offset @gol
481-Wno-analyzer-tainted-size @gol
482-Wanalyzer-too-complex @gol
483-Wno-analyzer-unsafe-call-within-signal-handler @gol
484-Wno-analyzer-use-after-free @gol
485-Wno-analyzer-use-of-pointer-in-stale-stack-frame @gol
486-Wno-analyzer-use-of-uninitialized-value @gol
487-Wno-analyzer-va-arg-type-mismatch @gol
488-Wno-analyzer-va-list-exhausted @gol
489-Wno-analyzer-va-list-leak @gol
490-Wno-analyzer-va-list-use-after-va-end @gol
491-Wno-analyzer-write-to-const @gol
492-Wno-analyzer-write-to-string-literal @gol
493}
494
495@item C and Objective-C-only Warning Options
496@gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
497-Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs @gol
498-Wold-style-declaration -Wold-style-definition @gol
499-Wstrict-prototypes -Wtraditional -Wtraditional-conversion @gol
500-Wdeclaration-after-statement -Wpointer-sign}
501
502@item Debugging Options
503@xref{Debugging Options,,Options for Debugging Your Program}.
504@gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} @gol
505-gbtf -gctf -gctf@var{level} @gol
506-ggdb -grecord-gcc-switches -gno-record-gcc-switches @gol
507-gstrict-dwarf -gno-strict-dwarf @gol
508-gas-loc-support -gno-as-loc-support @gol
509-gas-locview-support -gno-as-locview-support @gol
510-gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 @gol
511-gstatement-frontiers -gno-statement-frontiers @gol
512-gvariable-location-views -gno-variable-location-views @gol
513-ginternal-reset-location-views -gno-internal-reset-location-views @gol
514-ginline-points -gno-inline-points @gol
515-gvms -gz@r{[}=@var{type}@r{]} @gol
516-gsplit-dwarf -gdescribe-dies -gno-describe-dies @gol
517-fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section @gol
518-fno-eliminate-unused-debug-types @gol
519-femit-struct-debug-baseonly -femit-struct-debug-reduced @gol
520-femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} @gol
521-fno-eliminate-unused-debug-symbols -femit-class-debug-always @gol
522-fno-merge-debug-strings -fno-dwarf2-cfi-asm @gol
523-fvar-tracking -fvar-tracking-assignments}
524
525@item Optimization Options
526@xref{Optimize Options,,Options that Control Optimization}.
527@gccoptlist{-faggressive-loop-optimizations @gol
528-falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
529-falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
530-falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
531-falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] @gol
532-fno-allocation-dce -fallow-store-data-races @gol
533-fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol
534-fauto-inc-dec -fbranch-probabilities @gol
535-fcaller-saves @gol
536-fcombine-stack-adjustments -fconserve-stack @gol
537-fcompare-elim -fcprop-registers -fcrossjumping @gol
538-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules @gol
539-fcx-limited-range @gol
540-fdata-sections -fdce -fdelayed-branch @gol
541-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively @gol
542-fdevirtualize-at-ltrans -fdse @gol
543-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects @gol
544-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} @gol
545-ffinite-loops @gol
546-fforward-propagate -ffp-contract=@var{style} -ffunction-sections @gol
547-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity @gol
548-fgcse-sm -fhoist-adjacent-loads -fif-conversion @gol
549-fif-conversion2 -findirect-inlining @gol
550-finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol
551-finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone @gol
552-fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const @gol
553-fipa-reference -fipa-reference-addressable @gol
554-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} @gol
555-flive-patching=@var{level} @gol
556-fira-region=@var{region} -fira-hoist-pressure @gol
557-fira-loop-pressure -fno-ira-share-save-slots @gol
558-fno-ira-share-spill-slots @gol
559-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute @gol
560-fivopts -fkeep-inline-functions -fkeep-static-functions @gol
561-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage @gol
562-floop-block -floop-interchange -floop-strip-mine @gol
563-floop-unroll-and-jam -floop-nest-optimize @gol
564-floop-parallelize-all -flra-remat -flto -flto-compression-level @gol
565-flto-partition=@var{alg} -fmerge-all-constants @gol
566-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves @gol
567-fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg @gol
568-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse @gol
569-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole @gol
570-fno-peephole2 -fno-printf-return-value -fno-sched-interblock @gol
571-fno-sched-spec -fno-signed-zeros @gol
572-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol
573-fomit-frame-pointer -foptimize-sibling-calls @gol
574-fpartial-inlining -fpeel-loops -fpredictive-commoning @gol
575-fprefetch-loop-arrays @gol
576-fprofile-correction @gol
577-fprofile-use -fprofile-use=@var{path} -fprofile-partial-training @gol
578-fprofile-values -fprofile-reorder-functions @gol
579-freciprocal-math -free -frename-registers -freorder-blocks @gol
580-freorder-blocks-algorithm=@var{algorithm} @gol
581-freorder-blocks-and-partition -freorder-functions @gol
582-frerun-cse-after-loop -freschedule-modulo-scheduled-loops @gol
583-frounding-math -fsave-optimization-record @gol
584-fsched2-use-superblocks -fsched-pressure @gol
585-fsched-spec-load -fsched-spec-load-dangerous @gol
586-fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] @gol
587-fsched-group-heuristic -fsched-critical-path-heuristic @gol
588-fsched-spec-insn-heuristic -fsched-rank-heuristic @gol
589-fsched-last-insn-heuristic -fsched-dep-count-heuristic @gol
590-fschedule-fusion @gol
591-fschedule-insns -fschedule-insns2 -fsection-anchors @gol
592-fselective-scheduling -fselective-scheduling2 @gol
593-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops @gol
594-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate @gol
595-fsignaling-nans @gol
596-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops@gol
597-fsplit-paths @gol
598-fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt @gol
599-fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing @gol
600-fthread-jumps -ftracer -ftree-bit-ccp @gol
601-ftree-builtin-call-dce -ftree-ccp -ftree-ch @gol
602-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts @gol
603-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting @gol
604-ftree-loop-if-convert -ftree-loop-im @gol
605-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns @gol
606-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize @gol
607-ftree-loop-vectorize @gol
608-ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta @gol
609-ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra @gol
610-ftree-switch-conversion -ftree-tail-merge @gol
611-ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init @gol
612-funconstrained-commons -funit-at-a-time -funroll-all-loops @gol
613-funroll-loops -funsafe-math-optimizations -funswitch-loops @gol
614-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt @gol
615-fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs @gol
616--param @var{name}=@var{value}
617-O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz}
618
619@item Program Instrumentation Options
620@xref{Instrumentation Options,,Program Instrumentation Options}.
621@gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage @gol
622-fprofile-abs-path @gol
623-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} @gol
624-fprofile-info-section -fprofile-info-section=@var{name} @gol
625-fprofile-note=@var{path} -fprofile-prefix-path=@var{path} @gol
626-fprofile-update=@var{method} -fprofile-filter-files=@var{regex} @gol
627-fprofile-exclude-files=@var{regex} @gol
628-fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} @gol
629-fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol
630-fsanitize-trap -fsanitize-trap=@var{style} @gol
631-fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol
632-fsanitize-undefined-trap-on-error -fbounds-check @gol
633-fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} @gol
634-fharden-compares -fharden-conditional-branches @gol
635-fstack-protector -fstack-protector-all -fstack-protector-strong @gol
636-fstack-protector-explicit -fstack-check @gol
637-fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
638-fno-stack-limit -fsplit-stack @gol
639-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
640-fvtv-counts -fvtv-debug @gol
641-finstrument-functions -finstrument-functions-once @gol
642-finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} @gol
643-finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}} @gol
644-fprofile-prefix-map=@var{old}=@var{new}
645
646@item Preprocessor Options
647@xref{Preprocessor Options,,Options Controlling the Preprocessor}.
648@gccoptlist{-A@var{question}=@var{answer} @gol
649-A-@var{question}@r{[}=@var{answer}@r{]} @gol
650-C -CC -D@var{macro}@r{[}=@var{defn}@r{]} @gol
651-dD -dI -dM -dN -dU @gol
652-fdebug-cpp -fdirectives-only -fdollars-in-identifiers @gol
653-fexec-charset=@var{charset} -fextended-identifiers @gol
654-finput-charset=@var{charset} -flarge-source-files @gol
655-fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} @gol
656-fno-canonical-system-headers -fpch-deps -fpch-preprocess @gol
657-fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion @gol
658-fwide-exec-charset=@var{charset} -fworking-directory @gol
659-H -imacros @var{file} -include @var{file} @gol
660-M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules @gol
661-no-integrated-cpp -P -pthread -remap @gol
662-traditional -traditional-cpp -trigraphs @gol
663-U@var{macro} -undef @gol
664-Wp,@var{option} -Xpreprocessor @var{option}}
665
666@item Assembler Options
667@xref{Assembler Options,,Passing Options to the Assembler}.
668@gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
669
670@item Linker Options
671@xref{Link Options,,Options for Linking}.
672@gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} @gol
673-nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ @gol
674-e @var{entry} --entry=@var{entry} @gol
675-pie -pthread -r -rdynamic @gol
676-s -static -static-pie -static-libgcc -static-libstdc++ @gol
677-static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
678-shared -shared-libgcc -symbolic @gol
679-T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
680-u @var{symbol} -z @var{keyword}}
681
682@item Directory Options
683@xref{Directory Options,,Options for Directory Search}.
684@gccoptlist{-B@var{prefix} -I@var{dir} -I- @gol
685-idirafter @var{dir} @gol
686-imacros @var{file} -imultilib @var{dir} @gol
687-iplugindir=@var{dir} -iprefix @var{file} @gol
688-iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} @gol
689-iwithprefix @var{dir} -iwithprefixbefore @var{dir} @gol
690-L@var{dir} -no-canonical-prefixes --no-sysroot-suffix @gol
691-nostdinc -nostdinc++ --sysroot=@var{dir}}
692
693@item Code Generation Options
694@xref{Code Gen Options,,Options for Code Generation Conventions}.
695@gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
696-ffixed-@var{reg} -fexceptions @gol
697-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables @gol
698-fasynchronous-unwind-tables @gol
699-fno-gnu-unique @gol
700-finhibit-size-directive -fcommon -fno-ident @gol
701-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt @gol
702-fno-jump-tables -fno-bit-tests @gol
703-frecord-gcc-switches @gol
704-freg-struct-return -fshort-enums -fshort-wchar @gol
705-fverbose-asm -fpack-struct[=@var{n}] @gol
706-fleading-underscore -ftls-model=@var{model} @gol
707-fstack-reuse=@var{reuse_level} @gol
708-ftrampolines -ftrapv -fwrapv @gol
709-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} @gol
710-fstrict-volatile-bitfields -fsync-libcalls}
711
712@item Developer Options
713@xref{Developer Options,,GCC Developer Options}.
714@gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
715-dumpfullversion -fcallgraph-info@r{[}=su,da@r{]}
716-fchecking -fchecking=@var{n}
717-fdbg-cnt-list @gol -fdbg-cnt=@var{counter-value-list} @gol
718-fdisable-ipa-@var{pass_name} @gol
719-fdisable-rtl-@var{pass_name} @gol
720-fdisable-rtl-@var{pass-name}=@var{range-list} @gol
721-fdisable-tree-@var{pass_name} @gol
722-fdisable-tree-@var{pass-name}=@var{range-list} @gol
723-fdump-debug -fdump-earlydebug @gol
724-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links @gol
725-fdump-final-insns@r{[}=@var{file}@r{]} @gol
726-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol
727-fdump-lang-all @gol
728-fdump-lang-@var{switch} @gol
729-fdump-lang-@var{switch}-@var{options} @gol
730-fdump-lang-@var{switch}-@var{options}=@var{filename} @gol
731-fdump-passes @gol
732-fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol
733-fdump-statistics @gol
734-fdump-tree-all @gol
735-fdump-tree-@var{switch} @gol
736-fdump-tree-@var{switch}-@var{options} @gol
737-fdump-tree-@var{switch}-@var{options}=@var{filename} @gol
738-fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second @gol
739-fenable-@var{kind}-@var{pass} @gol
740-fenable-@var{kind}-@var{pass}=@var{range-list} @gol
741-fira-verbose=@var{n} @gol
742-flto-report -flto-report-wpa -fmem-report-wpa @gol
743-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report @gol
744-fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} @gol
745-fmultiflags -fprofile-report @gol
746-frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
747-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
748-fstats -fstack-usage -ftime-report -ftime-report-details @gol
749-fvar-tracking-assignments-toggle -gtoggle @gol
750-print-file-name=@var{library} -print-libgcc-file-name @gol
751-print-multi-directory -print-multi-lib -print-multi-os-directory @gol
752-print-prog-name=@var{program} -print-search-dirs -Q @gol
753-print-sysroot -print-sysroot-headers-suffix @gol
754-save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}}
755
756@item Machine-Dependent Options
757@xref{Submodel Options,,Machine-Dependent Options}.
758@c This list is ordered alphanumerically by subsection name.
759@c Try and put the significant identifier (CPU or system) first,
760@c so users have a clue at guessing where the ones they want will be.
761
762@emph{AArch64 Options}
763@gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian @gol
764-mgeneral-regs-only @gol
765-mcmodel=tiny -mcmodel=small -mcmodel=large @gol
766-mstrict-align -mno-strict-align @gol
767-momit-leaf-frame-pointer @gol
768-mtls-dialect=desc -mtls-dialect=traditional @gol
769-mtls-size=@var{size} @gol
770-mfix-cortex-a53-835769 -mfix-cortex-a53-843419 @gol
771-mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div @gol
772-mpc-relative-literal-loads @gol
773-msign-return-address=@var{scope} @gol
774-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
775+@var{b-key}]|@var{bti} @gol
776-mharden-sls=@var{opts} @gol
777-march=@var{name} -mcpu=@var{name} -mtune=@var{name} @gol
778-moverride=@var{string} -mverbose-cost-dump @gol
779-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} @gol
780-mstack-protector-guard-offset=@var{offset} -mtrack-speculation @gol
781-moutline-atomics }
782
783@emph{Adapteva Epiphany Options}
784@gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs @gol
785-mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf @gol
786-msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} @gol
787-mround-nearest -mlong-calls -mshort-calls -msmall16 @gol
788-mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} @gol
789-msplit-vecmove-early -m1reg-@var{reg}}
790
791@emph{AMD GCN Options}
792@gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}}
793
794@emph{ARC Options}
795@gccoptlist{-mbarrel-shifter -mjli-always @gol
796-mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 @gol
797-mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr @gol
798-mea -mno-mpy -mmul32x16 -mmul64 -matomic @gol
799-mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap @gol
800-mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape @gol
801-mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof @gol
802-mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved @gol
803-mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} @gol
804-mvolatile-cache -mtp-regno=@var{regno} @gol
805-malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc @gol
806-mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi @gol
807-mexpand-adddi -mindexed-loads -mlra -mlra-priority-none @gol
808-mlra-priority-compact -mlra-priority-noncompact -mmillicode @gol
809-mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} @gol
810-mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame @gol
811-munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} @gol
812-mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index}
813
814@emph{ARM Options}
815@gccoptlist{-mapcs-frame -mno-apcs-frame @gol
816-mabi=@var{name} @gol
817-mapcs-stack-check -mno-apcs-stack-check @gol
818-mapcs-reentrant -mno-apcs-reentrant @gol
819-mgeneral-regs-only @gol
820-msched-prolog -mno-sched-prolog @gol
821-mlittle-endian -mbig-endian @gol
822-mbe8 -mbe32 @gol
823-mfloat-abi=@var{name} @gol
824-mfp16-format=@var{name}
825-mthumb-interwork -mno-thumb-interwork @gol
826-mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
827-mtune=@var{name} -mprint-tune-info @gol
828-mstructure-size-boundary=@var{n} @gol
829-mabort-on-noreturn @gol
830-mlong-calls -mno-long-calls @gol
831-msingle-pic-base -mno-single-pic-base @gol
832-mpic-register=@var{reg} @gol
833-mnop-fun-dllimport @gol
834-mpoke-function-name @gol
835-mthumb -marm -mflip-thumb @gol
836-mtpcs-frame -mtpcs-leaf-frame @gol
837-mcaller-super-interworking -mcallee-super-interworking @gol
838-mtp=@var{name} -mtls-dialect=@var{dialect} @gol
839-mword-relocations @gol
840-mfix-cortex-m3-ldrd @gol
841-mfix-cortex-a57-aes-1742098 @gol
842-mfix-cortex-a72-aes-1655431 @gol
843-munaligned-access @gol
844-mneon-for-64bits @gol
845-mslow-flash-data @gol
846-masm-syntax-unified @gol
847-mrestrict-it @gol
848-mverbose-cost-dump @gol
849-mpure-code @gol
850-mcmse @gol
851-mfix-cmse-cve-2021-35465 @gol
852-mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} @gol
853-mfdpic}
854
855@emph{AVR Options}
856@gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol
857-mbranch-cost=@var{cost} @gol
858-mcall-prologues -mgas-isr-prologues -mint8 @gol
859-mdouble=@var{bits} -mlong-double=@var{bits} @gol
860-mn_flash=@var{size} -mno-interrupts @gol
861-mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack @gol
862-mfract-convert-truncate @gol
863-mshort-calls -nodevicelib -nodevicespecs @gol
864-Waddr-space-convert -Wmisspelled-isr}
865
866@emph{Blackfin Options}
867@gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol
868-msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer @gol
869-mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly @gol
870-mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library @gol
871-mno-id-shared-library -mshared-library-id=@var{n} @gol
872-mleaf-id-shared-library -mno-leaf-id-shared-library @gol
873-msep-data -mno-sep-data -mlong-calls -mno-long-calls @gol
874-mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram @gol
875-micplb}
876
877@emph{C6X Options}
878@gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} @gol
879-msim -msdata=@var{sdata-type}}
880
881@emph{CRIS Options}
882@gccoptlist{-mcpu=@var{cpu} -march=@var{cpu}
883-mtune=@var{cpu} -mmax-stack-frame=@var{n} @gol
884-metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
885-mstack-align -mdata-align -mconst-align @gol
886-m32-bit -m16-bit -m8-bit -mno-prologue-epilogue @gol
887-melf -maout -sim -sim2 @gol
888-mmul-bug-workaround -mno-mul-bug-workaround}
889
890@emph{C-SKY Options}
891@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} @gol
892-mbig-endian -EB -mlittle-endian -EL @gol
893-mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu @gol
894-mfloat-abi=@var{name} @gol
895-melrw -mistack -mmp -mcp -mcache -msecurity -mtrust @gol
896-mdsp -medsp -mvdsp @gol
897-mdiv -msmart -mhigh-registers -manchor @gol
898-mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt @gol
899-mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim}
900
901@emph{Darwin Options}
902@gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
903-arch_only -bind_at_load -bundle -bundle_loader @gol
904-client_name -compatibility_version -current_version @gol
905-dead_strip @gol
906-dependency-file -dylib_file -dylinker_install_name @gol
907-dynamic -dynamiclib -exported_symbols_list @gol
908-filelist -flat_namespace -force_cpusubtype_ALL @gol
909-force_flat_namespace -headerpad_max_install_names @gol
910-iframework @gol
911-image_base -init -install_name -keep_private_externs @gol
912-multi_module -multiply_defined -multiply_defined_unused @gol
913-noall_load -no_dead_strip_inits_and_terms @gol
914-nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
915-pagezero_size -prebind -prebind_all_twolevel_modules @gol
916-private_bundle -read_only_relocs -sectalign @gol
917-sectobjectsymbols -whyload -seg1addr @gol
918-sectcreate -sectobjectsymbols -sectorder @gol
919-segaddr -segs_read_only_addr -segs_read_write_addr @gol
920-seg_addr_table -seg_addr_table_filename -seglinkedit @gol
921-segprot -segs_read_only_addr -segs_read_write_addr @gol
922-single_module -static -sub_library -sub_umbrella @gol
923-twolevel_namespace -umbrella -undefined @gol
924-unexported_symbols_list -weak_reference_mismatches @gol
925-whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} @gol
926-mkernel -mone-byte-bool}
927
928@emph{DEC Alpha Options}
929@gccoptlist{-mno-fp-regs -msoft-float @gol
930-mieee -mieee-with-inexact -mieee-conformant @gol
931-mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
932-mtrap-precision=@var{mode} -mbuild-constants @gol
933-mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
934-mbwx -mmax -mfix -mcix @gol
935-mfloat-vax -mfloat-ieee @gol
936-mexplicit-relocs -msmall-data -mlarge-data @gol
937-msmall-text -mlarge-text @gol
938-mmemory-latency=@var{time}}
939
940@emph{eBPF Options}
941@gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version}
942-mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re
943-mjmpext -mjmp32 -malu32 -mcpu=@var{version}}
944
945@emph{FR30 Options}
946@gccoptlist{-msmall-model -mno-lsim}
947
948@emph{FT32 Options}
949@gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm}
950
951@emph{FRV Options}
952@gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
953-mhard-float -msoft-float @gol
954-malloc-cc -mfixed-cc -mdword -mno-dword @gol
955-mdouble -mno-double @gol
956-mmedia -mno-media -mmuladd -mno-muladd @gol
957-mfdpic -minline-plt -mgprel-ro -multilib-library-pic @gol
958-mlinked-fp -mlong-calls -malign-labels @gol
959-mlibrary-pic -macc-4 -macc-8 @gol
960-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
961-moptimize-membar -mno-optimize-membar @gol
962-mscc -mno-scc -mcond-exec -mno-cond-exec @gol
963-mvliw-branch -mno-vliw-branch @gol
964-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
965-mno-nested-cond-exec -mtomcat-stats @gol
966-mTLS -mtls @gol
967-mcpu=@var{cpu}}
968
969@emph{GNU/Linux Options}
970@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
971-tno-android-cc -tno-android-ld}
972
973@emph{H8/300 Options}
974@gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300}
975
976@emph{HPPA Options}
977@gccoptlist{-march=@var{architecture-type} @gol
978-mcaller-copies -mdisable-fpregs -mdisable-indexing @gol
979-mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
980-mfixed-range=@var{register-range} @gol
981-mjump-in-delay -mlinker-opt -mlong-calls @gol
982-mlong-load-store -mno-disable-fpregs @gol
983-mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
984-mno-jump-in-delay -mno-long-load-store @gol
985-mno-portable-runtime -mno-soft-float @gol
986-mno-space-regs -msoft-float -mpa-risc-1-0 @gol
987-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
988-mschedule=@var{cpu-type} -mspace-regs -msio -mwsio @gol
989-munix=@var{unix-std} -nolibdld -static -threads}
990
991@emph{IA-64 Options}
992@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
993-mvolatile-asm-stop -mregister-names -msdata -mno-sdata @gol
994-mconstant-gp -mauto-pic -mfused-madd @gol
995-minline-float-divide-min-latency @gol
996-minline-float-divide-max-throughput @gol
997-mno-inline-float-divide @gol
998-minline-int-divide-min-latency @gol
999-minline-int-divide-max-throughput @gol
1000-mno-inline-int-divide @gol
1001-minline-sqrt-min-latency -minline-sqrt-max-throughput @gol
1002-mno-inline-sqrt @gol
1003-mdwarf2-asm -mearly-stop-bits @gol
1004-mfixed-range=@var{register-range} -mtls-size=@var{tls-size} @gol
1005-mtune=@var{cpu-type} -milp32 -mlp64 @gol
1006-msched-br-data-spec -msched-ar-data-spec -msched-control-spec @gol
1007-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec @gol
1008-msched-spec-ldc -msched-spec-control-ldc @gol
1009-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns @gol
1010-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path @gol
1011-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost @gol
1012-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1013
1014@emph{LM32 Options}
1015@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled @gol
1016-msign-extend-enabled -muser-enabled}
1017
1018@emph{LoongArch Options}
1019@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} @gol
1020-mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float @gol
1021-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division @gol
1022-mcond-move-int -mno-cond-move-int @gol
1023-mcond-move-float -mno-cond-move-float @gol
1024-memcpy -mno-memcpy -mstrict-align -mno-strict-align @gol
1025-mmax-inline-memcpy-size=@var{n} @gol
1026-mexplicit-relocs -mno-explicit-relocs @gol
1027-mdirect-extern-access -mno-direct-extern-access @gol
1028-mcmodel=@var{code-model}}
1029
1030@emph{M32R/D Options}
1031@gccoptlist{-m32r2 -m32rx -m32r @gol
1032-mdebug @gol
1033-malign-loops -mno-align-loops @gol
1034-missue-rate=@var{number} @gol
1035-mbranch-cost=@var{number} @gol
1036-mmodel=@var{code-size-model-type} @gol
1037-msdata=@var{sdata-type} @gol
1038-mno-flush-func -mflush-func=@var{name} @gol
1039-mno-flush-trap -mflush-trap=@var{number} @gol
1040-G @var{num}}
1041
1042@emph{M32C Options}
1043@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1044
1045@emph{M680x0 Options}
1046@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} @gol
1047-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
1048-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 @gol
1049-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 @gol
1050-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort @gol
1051-mno-short -mhard-float -m68881 -msoft-float -mpcrel @gol
1052-malign-int -mstrict-align -msep-data -mno-sep-data @gol
1053-mshared-library-id=n -mid-shared-library -mno-id-shared-library @gol
1054-mxgot -mno-xgot -mlong-jump-table-offsets}
1055
1056@emph{MCore Options}
1057@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
1058-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
1059-m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
1060-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
1061-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1062
d77de738
ML
1063@emph{MicroBlaze Options}
1064@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} @gol
1065-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift @gol
1066-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss @gol
1067-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt @gol
1068-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} @gol
1069-mpic-data-is-text-relative}
1070
1071@emph{MIPS Options}
1072@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
1073-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 @gol
1074-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 @gol
1075-mips16 -mno-mips16 -mflip-mips16 @gol
1076-minterlink-compressed -mno-interlink-compressed @gol
1077-minterlink-mips16 -mno-interlink-mips16 @gol
1078-mabi=@var{abi} -mabicalls -mno-abicalls @gol
1079-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol
1080-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float @gol
1081-mno-float -msingle-float -mdouble-float @gol
1082-modd-spreg -mno-odd-spreg @gol
1083-mabs=@var{mode} -mnan=@var{encoding} @gol
1084-mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
1085-mmcu -mmno-mcu @gol
1086-meva -mno-eva @gol
1087-mvirt -mno-virt @gol
1088-mxpa -mno-xpa @gol
1089-mcrc -mno-crc @gol
1090-mginv -mno-ginv @gol
1091-mmicromips -mno-micromips @gol
1092-mmsa -mno-msa @gol
1093-mloongson-mmi -mno-loongson-mmi @gol
1094-mloongson-ext -mno-loongson-ext @gol
1095-mloongson-ext2 -mno-loongson-ext2 @gol
1096-mfpu=@var{fpu-type} @gol
1097-msmartmips -mno-smartmips @gol
1098-mpaired-single -mno-paired-single -mdmx -mno-mdmx @gol
1099-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc @gol
1100-mlong64 -mlong32 -msym32 -mno-sym32 @gol
1101-G@var{num} -mlocal-sdata -mno-local-sdata @gol
1102-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt @gol
1103-membedded-data -mno-embedded-data @gol
1104-muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
1105-mcode-readable=@var{setting} @gol
1106-msplit-addresses -mno-split-addresses @gol
1107-mexplicit-relocs -mno-explicit-relocs @gol
1108-mcheck-zero-division -mno-check-zero-division @gol
1109-mdivide-traps -mdivide-breaks @gol
1110-mload-store-pairs -mno-load-store-pairs @gol
1111-munaligned-access -mno-unaligned-access @gol
1112-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
1113-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp @gol
1114-mfix-24k -mno-fix-24k @gol
1115-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
1116-mfix-r5900 -mno-fix-r5900 @gol
1117-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 @gol
1118-mfix-vr4120 -mno-fix-vr4120 @gol
1119-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 @gol
1120-mflush-func=@var{func} -mno-flush-func @gol
1121-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely @gol
1122-mcompact-branches=@var{policy} @gol
1123-mfp-exceptions -mno-fp-exceptions @gol
1124-mvr4130-align -mno-vr4130-align -msynci -mno-synci @gol
1125-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 @gol
1126-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address @gol
1127-mframe-header-opt -mno-frame-header-opt}
1128
1129@emph{MMIX Options}
1130@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
1131-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
1132-melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
1133-mno-base-addresses -msingle-exit -mno-single-exit}
1134
1135@emph{MN10300 Options}
1136@gccoptlist{-mmult-bug -mno-mult-bug @gol
1137-mno-am33 -mam33 -mam33-2 -mam34 @gol
1138-mtune=@var{cpu-type} @gol
1139-mreturn-pointer-on-d0 @gol
1140-mno-crt0 -mrelax -mliw -msetlb}
1141
1142@emph{Moxie Options}
1143@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1144
1145@emph{MSP430 Options}
1146@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax @gol
1147-mwarn-mcu @gol
1148-mcode-region= -mdata-region= @gol
1149-msilicon-errata= -msilicon-errata-warn= @gol
1150-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1151
1152@emph{NDS32 Options}
1153@gccoptlist{-mbig-endian -mlittle-endian @gol
1154-mreduced-regs -mfull-regs @gol
1155-mcmov -mno-cmov @gol
1156-mext-perf -mno-ext-perf @gol
1157-mext-perf2 -mno-ext-perf2 @gol
1158-mext-string -mno-ext-string @gol
1159-mv3push -mno-v3push @gol
1160-m16bit -mno-16bit @gol
1161-misr-vector-size=@var{num} @gol
1162-mcache-block-size=@var{num} @gol
1163-march=@var{arch} @gol
1164-mcmodel=@var{code-model} @gol
1165-mctor-dtor -mrelax}
1166
1167@emph{Nios II Options}
1168@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt @gol
1169-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} @gol
1170-mel -meb @gol
1171-mno-bypass-cache -mbypass-cache @gol
1172-mno-cache-volatile -mcache-volatile @gol
1173-mno-fast-sw-div -mfast-sw-div @gol
1174-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div @gol
1175-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} @gol
1176-mcustom-fpu-cfg=@var{name} @gol
1177-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} @gol
1178-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1179
1180@emph{Nvidia PTX Options}
1181@gccoptlist{-m64 -mmainkernel -moptimize}
1182
1183@emph{OpenRISC Options}
1184@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div @gol
1185-msoft-mul -msoft-div @gol
1186-msoft-float -mhard-float -mdouble-float -munordered-float @gol
1187-mcmov -mror -mrori -msext -msfimm -mshftimm @gol
1188-mcmodel=@var{code-model}}
1189
1190@emph{PDP-11 Options}
1191@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
1192-mint32 -mno-int16 -mint16 -mno-int32 @gol
1193-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1194
d77de738
ML
1195@emph{PowerPC Options}
1196See RS/6000 and PowerPC Options.
1197
1198@emph{PRU Options}
1199@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop @gol
f58e6d42 1200-mabi=@var{variant}}
d77de738
ML
1201
1202@emph{RISC-V Options}
1203@gccoptlist{-mbranch-cost=@var{N-instruction} @gol
1204-mplt -mno-plt @gol
1205-mabi=@var{ABI-string} @gol
1206-mfdiv -mno-fdiv @gol
1207-mdiv -mno-div @gol
1208-misa-spec=@var{ISA-spec-string} @gol
1209-march=@var{ISA-string} @gol
1210-mtune=@var{processor-string} @gol
1211-mpreferred-stack-boundary=@var{num} @gol
1212-msmall-data-limit=@var{N-bytes} @gol
1213-msave-restore -mno-save-restore @gol
1214-mshorten-memrefs -mno-shorten-memrefs @gol
1215-mstrict-align -mno-strict-align @gol
1216-mcmodel=medlow -mcmodel=medany @gol
1217-mexplicit-relocs -mno-explicit-relocs @gol
1218-mrelax -mno-relax @gol
1219-mriscv-attribute -mno-riscv-attribute @gol
1220-malign-data=@var{type} @gol
1221-mbig-endian -mlittle-endian @gol
1222-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
f58e6d42
CM
1223-mstack-protector-guard-offset=@var{offset} @gol
1224-mcsr-check -mno-csr-check}
d77de738
ML
1225
1226@emph{RL78 Options}
1227@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol
1228-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 @gol
1229-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1230
1231@emph{RS/6000 and PowerPC Options}
1232@gccoptlist{-mcpu=@var{cpu-type} @gol
1233-mtune=@var{cpu-type} @gol
1234-mcmodel=@var{code-model} @gol
1235-mpowerpc64 @gol
1236-maltivec -mno-altivec @gol
1237-mpowerpc-gpopt -mno-powerpc-gpopt @gol
1238-mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
1239-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd @gol
1240-mfprnd -mno-fprnd @gol
1241-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp @gol
1242-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
1243-m64 -m32 -mxl-compat -mno-xl-compat -mpe @gol
1244-malign-power -malign-natural @gol
1245-msoft-float -mhard-float -mmultiple -mno-multiple @gol
1246-mupdate -mno-update @gol
1247-mavoid-indexed-addresses -mno-avoid-indexed-addresses @gol
1248-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
1249-mstrict-align -mno-strict-align -mrelocatable @gol
1250-mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
1251-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
1252-mdynamic-no-pic -mswdiv -msingle-pic-base @gol
1253-mprioritize-restricted-insns=@var{priority} @gol
1254-msched-costly-dep=@var{dependence_type} @gol
1255-minsert-sched-nops=@var{scheme} @gol
1256-mcall-aixdesc -mcall-eabi -mcall-freebsd @gol
1257-mcall-linux -mcall-netbsd -mcall-openbsd @gol
1258-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi @gol
1259-mtraceback=@var{traceback_type} @gol
1260-maix-struct-return -msvr4-struct-return @gol
1261-mabi=@var{abi-type} -msecure-plt -mbss-plt @gol
1262-mlongcall -mno-longcall -mpltseq -mno-pltseq @gol
1263-mblock-move-inline-limit=@var{num} @gol
1264-mblock-compare-inline-limit=@var{num} @gol
1265-mblock-compare-inline-loop-limit=@var{num} @gol
1266-mno-block-ops-unaligned-vsx @gol
1267-mstring-compare-inline-limit=@var{num} @gol
1268-misel -mno-isel @gol
1269-mvrsave -mno-vrsave @gol
1270-mmulhw -mno-mulhw @gol
1271-mdlmzb -mno-dlmzb @gol
1272-mprototype -mno-prototype @gol
1273-msim -mmvme -mads -myellowknife -memb -msdata @gol
1274-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol
1275-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol
1276-mno-recip-precision @gol
1277-mveclibabi=@var{type} -mfriz -mno-friz @gol
1278-mpointers-to-nested-functions -mno-pointers-to-nested-functions @gol
1279-msave-toc-indirect -mno-save-toc-indirect @gol
1280-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
1281-mcrypto -mno-crypto -mhtm -mno-htm @gol
1282-mquad-memory -mno-quad-memory @gol
1283-mquad-memory-atomic -mno-quad-memory-atomic @gol
1284-mcompat-align-parm -mno-compat-align-parm @gol
1285-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware @gol
1286-mgnu-attribute -mno-gnu-attribute @gol
1287-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1288-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed @gol
1289-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect @gol
1290-mprivileged -mno-privileged}
1291
1292@emph{RX Options}
1293@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu@gol
1294-mcpu=@gol
1295-mbig-endian-data -mlittle-endian-data @gol
1296-msmall-data @gol
1297-msim -mno-sim@gol
1298-mas100-syntax -mno-as100-syntax@gol
1299-mrelax@gol
1300-mmax-constant-size=@gol
1301-mint-register=@gol
1302-mpid@gol
1303-mallow-string-insns -mno-allow-string-insns@gol
1304-mjsr@gol
1305-mno-warn-multiple-fast-interrupts@gol
1306-msave-acc-in-interrupts}
1307
1308@emph{S/390 and zSeries Options}
1309@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1310-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp @gol
1311-mlong-double-64 -mlong-double-128 @gol
1312-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack @gol
1313-msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
1314-m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
1315-mhtm -mvx -mzvector @gol
1316-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip @gol
1317-mfused-madd -mno-fused-madd @gol
1318-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard @gol
1319-mhotpatch=@var{halfwords},@var{halfwords}}
1320
d77de738
ML
1321@emph{SH Options}
1322@gccoptlist{-m1 -m2 -m2e @gol
1323-m2a-nofpu -m2a-single-only -m2a-single -m2a @gol
1324-m3 -m3e @gol
1325-m4-nofpu -m4-single-only -m4-single -m4 @gol
1326-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol
1327-mb -ml -mdalign -mrelax @gol
1328-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave @gol
1329-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct @gol
1330-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
1331-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol
1332-maccumulate-outgoing-args @gol
1333-matomic-model=@var{atomic-model} @gol
1334-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch @gol
1335-mcbranch-force-delay-slot @gol
1336-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra @gol
1337-mpretend-cmove -mtas}
1338
1339@emph{Solaris 2 Options}
1340@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text @gol
1341-pthreads}
1342
1343@emph{SPARC Options}
1344@gccoptlist{-mcpu=@var{cpu-type} @gol
1345-mtune=@var{cpu-type} @gol
1346-mcmodel=@var{code-model} @gol
1347-mmemory-model=@var{mem-model} @gol
1348-m32 -m64 -mapp-regs -mno-app-regs @gol
1349-mfaster-structs -mno-faster-structs -mflat -mno-flat @gol
1350-mfpu -mno-fpu -mhard-float -msoft-float @gol
1351-mhard-quad-float -msoft-quad-float @gol
1352-mstack-bias -mno-stack-bias @gol
1353-mstd-struct-return -mno-std-struct-return @gol
1354-munaligned-doubles -mno-unaligned-doubles @gol
1355-muser-mode -mno-user-mode @gol
1356-mv8plus -mno-v8plus -mvis -mno-vis @gol
1357-mvis2 -mno-vis2 -mvis3 -mno-vis3 @gol
1358-mvis4 -mno-vis4 -mvis4b -mno-vis4b @gol
1359-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld @gol
1360-mpopc -mno-popc -msubxc -mno-subxc @gol
1361-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc @gol
1362-mlra -mno-lra}
1363
1364@emph{System V Options}
1365@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1366
1367@emph{V850 Options}
1368@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
1369-mprolog-function -mno-prolog-function -mspace @gol
1370-mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
1371-mapp-regs -mno-app-regs @gol
1372-mdisable-callt -mno-disable-callt @gol
1373-mv850e2v3 -mv850e2 -mv850e1 -mv850es @gol
1374-mv850e -mv850 -mv850e3v5 @gol
1375-mloop @gol
1376-mrelax @gol
1377-mlong-jumps @gol
1378-msoft-float @gol
1379-mhard-float @gol
1380-mgcc-abi @gol
1381-mrh850-abi @gol
1382-mbig-switch}
1383
1384@emph{VAX Options}
1385@gccoptlist{-mg -mgnu -munix -mlra}
1386
1387@emph{Visium Options}
1388@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float @gol
1389-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1390
1391@emph{VMS Options}
1392@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 @gol
1393-mpointer-size=@var{size}}
1394
1395@emph{VxWorks Options}
1396@gccoptlist{-mrtp -non-static -Bstatic -Bdynamic @gol
1397-Xbind-lazy -Xbind-now}
1398
1399@emph{x86 Options}
1400@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1401-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default @gol
1402-mfpmath=@var{unit} @gol
1403-masm=@var{dialect} -mno-fancy-math-387 @gol
1404-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float @gol
1405-mno-wide-multiply -mrtd -malign-double @gol
1406-mpreferred-stack-boundary=@var{num} @gol
1407-mincoming-stack-boundary=@var{num} @gol
1408-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait @gol
1409-mrecip -mrecip=@var{opt} @gol
1410-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} @gol
1411-mmove-max=@var{bits} -mstore-max=@var{bits} @gol
1412-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
1413-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl @gol
1414-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes @gol
1415-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd @gol
1416-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves @gol
1417-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol
1418-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp @gol
1419-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol
1420-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call @gol
1421-mavx512vbmi2 -mavx512bf16 -menqcmd @gol
1422-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol
1423-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid @gol
1424-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk@gol
1425-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni@gol
1426-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 @gol
1427-mprefetchi -mraoint @gol
1428-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops @gol
1429-minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
1430-mkl -mwidekl @gol
1431-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} @gol
1432-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
1433-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 @gol
1434-mregparm=@var{num} -msseregparm @gol
1435-mveclibabi=@var{type} -mvect8-ret-in-mem @gol
1436-mpc32 -mpc64 -mpc80 -mstackrealign @gol
1437-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
1438-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
1439-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol
1440-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
1441-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} @gol
1442-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
1443-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
1444-mstack-protector-guard-reg=@var{reg} @gol
1445-mstack-protector-guard-offset=@var{offset} @gol
1446-mstack-protector-guard-symbol=@var{symbol} @gol
1447-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop @gol
1448-mindirect-branch=@var{choice} -mfunction-return=@var{choice} @gol
1449-mindirect-branch-register -mharden-sls=@var{choice} @gol
ce51e843 1450-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access @gol
bb576017 1451-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1452
1453@emph{x86 Windows Options}
1454@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
1455-mnop-fun-dllimport -mthread @gol
1456-municode -mwin32 -mwindows -fno-set-stack-executable}
1457
1458@emph{Xstormy16 Options}
1459@gccoptlist{-msim}
1460
1461@emph{Xtensa Options}
1462@gccoptlist{-mconst16 -mno-const16 @gol
1463-mfused-madd -mno-fused-madd @gol
1464-mforce-no-pic @gol
1465-mserialize-volatile -mno-serialize-volatile @gol
1466-mtext-section-literals -mno-text-section-literals @gol
1467-mauto-litpools -mno-auto-litpools @gol
1468-mtarget-align -mno-target-align @gol
1469-mlongcalls -mno-longcalls @gol
1470-mabi=@var{abi-type} @gol
1471-mextra-l32r-costs=@var{cycles}}
1472
1473@emph{zSeries Options}
1474See S/390 and zSeries Options.
1475@end table
1476
1477
1478@node Overall Options
1479@section Options Controlling the Kind of Output
1480
1481Compilation can involve up to four stages: preprocessing, compilation
1482proper, assembly and linking, always in that order. GCC is capable of
1483preprocessing and compiling several files either into several
1484assembler input files, or into one assembler input file; then each
1485assembler input file produces an object file, and linking combines all
1486the object files (those newly compiled, and those specified as input)
1487into an executable file.
1488
1489@cindex file name suffix
1490For any given input file, the file name suffix determines what kind of
1491compilation is done:
1492
1493@table @gcctabopt
1494@item @var{file}.c
1495C source code that must be preprocessed.
1496
1497@item @var{file}.i
1498C source code that should not be preprocessed.
1499
1500@item @var{file}.ii
1501C++ source code that should not be preprocessed.
1502
1503@item @var{file}.m
1504Objective-C source code. Note that you must link with the @file{libobjc}
1505library to make an Objective-C program work.
1506
1507@item @var{file}.mi
1508Objective-C source code that should not be preprocessed.
1509
1510@item @var{file}.mm
1511@itemx @var{file}.M
1512Objective-C++ source code. Note that you must link with the @file{libobjc}
1513library to make an Objective-C++ program work. Note that @samp{.M} refers
1514to a literal capital M@.
1515
1516@item @var{file}.mii
1517Objective-C++ source code that should not be preprocessed.
1518
1519@item @var{file}.h
1520C, C++, Objective-C or Objective-C++ header file to be turned into a
1521precompiled header (default), or C, C++ header file to be turned into an
1522Ada spec (via the @option{-fdump-ada-spec} switch).
1523
1524@item @var{file}.cc
1525@itemx @var{file}.cp
1526@itemx @var{file}.cxx
1527@itemx @var{file}.cpp
1528@itemx @var{file}.CPP
1529@itemx @var{file}.c++
1530@itemx @var{file}.C
1531C++ source code that must be preprocessed. Note that in @samp{.cxx},
1532the last two letters must both be literally @samp{x}. Likewise,
1533@samp{.C} refers to a literal capital C@.
1534
1535@item @var{file}.mm
1536@itemx @var{file}.M
1537Objective-C++ source code that must be preprocessed.
1538
1539@item @var{file}.mii
1540Objective-C++ source code that should not be preprocessed.
1541
1542@item @var{file}.hh
1543@itemx @var{file}.H
1544@itemx @var{file}.hp
1545@itemx @var{file}.hxx
1546@itemx @var{file}.hpp
1547@itemx @var{file}.HPP
1548@itemx @var{file}.h++
1549@itemx @var{file}.tcc
1550C++ header file to be turned into a precompiled header or Ada spec.
1551
1552@item @var{file}.f
1553@itemx @var{file}.for
1554@itemx @var{file}.ftn
1555Fixed form Fortran source code that should not be preprocessed.
1556
1557@item @var{file}.F
1558@itemx @var{file}.FOR
1559@itemx @var{file}.fpp
1560@itemx @var{file}.FPP
1561@itemx @var{file}.FTN
1562Fixed form Fortran source code that must be preprocessed (with the traditional
1563preprocessor).
1564
1565@item @var{file}.f90
1566@itemx @var{file}.f95
1567@itemx @var{file}.f03
1568@itemx @var{file}.f08
1569Free form Fortran source code that should not be preprocessed.
1570
1571@item @var{file}.F90
1572@itemx @var{file}.F95
1573@itemx @var{file}.F03
1574@itemx @var{file}.F08
1575Free form Fortran source code that must be preprocessed (with the
1576traditional preprocessor).
1577
1578@item @var{file}.go
1579Go source code.
1580
1581@item @var{file}.d
1582D source code.
1583
1584@item @var{file}.di
1585D interface file.
1586
1587@item @var{file}.dd
1588D documentation code (Ddoc).
1589
1590@item @var{file}.ads
1591Ada source code file that contains a library unit declaration (a
1592declaration of a package, subprogram, or generic, or a generic
1593instantiation), or a library unit renaming declaration (a package,
1594generic, or subprogram renaming declaration). Such files are also
1595called @dfn{specs}.
1596
1597@item @var{file}.adb
1598Ada source code file containing a library unit body (a subprogram or
1599package body). Such files are also called @dfn{bodies}.
1600
1601@c GCC also knows about some suffixes for languages not yet included:
1602@c Ratfor:
1603@c @var{file}.r
1604
1605@item @var{file}.s
1606Assembler code.
1607
1608@item @var{file}.S
1609@itemx @var{file}.sx
1610Assembler code that must be preprocessed.
1611
1612@item @var{other}
1613An object file to be fed straight into linking.
1614Any file name with no recognized suffix is treated this way.
1615@end table
1616
1617@opindex x
1618You can specify the input language explicitly with the @option{-x} option:
1619
1620@table @gcctabopt
1621@item -x @var{language}
1622Specify explicitly the @var{language} for the following input files
1623(rather than letting the compiler choose a default based on the file
1624name suffix). This option applies to all following input files until
1625the next @option{-x} option. Possible values for @var{language} are:
1626@smallexample
1627c c-header cpp-output
1628c++ c++-header c++-system-header c++-user-header c++-cpp-output
1629objective-c objective-c-header objective-c-cpp-output
1630objective-c++ objective-c++-header objective-c++-cpp-output
1631assembler assembler-with-cpp
1632ada
1633d
1634f77 f77-cpp-input f95 f95-cpp-input
1635go
1636@end smallexample
1637
1638@item -x none
1639Turn off any specification of a language, so that subsequent files are
1640handled according to their file name suffixes (as they are if @option{-x}
1641has not been used at all).
1642@end table
1643
1644If you only want some of the stages of compilation, you can use
1645@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1646one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1647@command{gcc} is to stop. Note that some combinations (for example,
1648@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1649
1650@table @gcctabopt
1651@item -c
1652@opindex c
1653Compile or assemble the source files, but do not link. The linking
1654stage simply is not done. The ultimate output is in the form of an
1655object file for each source file.
1656
1657By default, the object file name for a source file is made by replacing
1658the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1659
1660Unrecognized input files, not requiring compilation or assembly, are
1661ignored.
1662
1663@item -S
1664@opindex S
1665Stop after the stage of compilation proper; do not assemble. The output
1666is in the form of an assembler code file for each non-assembler input
1667file specified.
1668
1669By default, the assembler file name for a source file is made by
1670replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1671
1672Input files that don't require compilation are ignored.
1673
1674@item -E
1675@opindex E
1676Stop after the preprocessing stage; do not run the compiler proper. The
1677output is in the form of preprocessed source code, which is sent to the
1678standard output.
1679
1680Input files that don't require preprocessing are ignored.
1681
1682@cindex output file option
1683@item -o @var{file}
1684@opindex o
1685Place the primary output in file @var{file}. This applies to whatever
1686sort of output is being produced, whether it be an executable file, an
1687object file, an assembler file or preprocessed C code.
1688
1689If @option{-o} is not specified, the default is to put an executable
1690file in @file{a.out}, the object file for
1691@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1692assembler file in @file{@var{source}.s}, a precompiled header file in
1693@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1694standard output.
1695
1696Though @option{-o} names only the primary output, it also affects the
1697naming of auxiliary and dump outputs. See the examples below. Unless
1698overridden, both auxiliary outputs and dump outputs are placed in the
1699same directory as the primary output. In auxiliary outputs, the suffix
1700of the input file is replaced with that of the auxiliary output file
1701type; in dump outputs, the suffix of the dump file is appended to the
1702input file suffix. In compilation commands, the base name of both
1703auxiliary and dump outputs is that of the primary output; in compile and
1704link commands, the primary output name, minus the executable suffix, is
1705combined with the input file name. If both share the same base name,
1706disregarding the suffix, the result of the combination is that base
1707name, otherwise, they are concatenated, separated by a dash.
1708
1709@smallexample
1710gcc -c foo.c ...
1711@end smallexample
1712
1713will use @file{foo.o} as the primary output, and place aux outputs and
1714dumps next to it, e.g., aux file @file{foo.dwo} for
1715@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1716@option{-fdump-rtl-final}.
1717
1718If a non-linker output file is explicitly specified, aux and dump files
1719by default take the same base name:
1720
1721@smallexample
1722gcc -c foo.c -o dir/foobar.o ...
1723@end smallexample
1724
1725will name aux outputs @file{dir/foobar.*} and dump outputs
1726@file{dir/foobar.c.*}.
1727
1728A linker output will instead prefix aux and dump outputs:
1729
1730@smallexample
1731gcc foo.c bar.c -o dir/foobar ...
1732@end smallexample
1733
1734will generally name aux outputs @file{dir/foobar-foo.*} and
1735@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1736@file{dir/foobar-bar.c.*}.
1737
1738The one exception to the above is when the executable shares the base
1739name with the single input:
1740
1741@smallexample
1742gcc foo.c -o dir/foo ...
1743@end smallexample
1744
1745in which case aux outputs are named @file{dir/foo.*} and dump outputs
1746named @file{dir/foo.c.*}.
1747
1748The location and the names of auxiliary and dump outputs can be adjusted
1749by the options @option{-dumpbase}, @option{-dumpbase-ext},
1750@option{-dumpdir}, @option{-save-temps=cwd}, and
1751@option{-save-temps=obj}.
1752
1753
1754@item -dumpbase @var{dumpbase}
1755@opindex dumpbase
1756This option sets the base name for auxiliary and dump output files. It
1757does not affect the name of the primary output file. Intermediate
1758outputs, when preserved, are not regarded as primary outputs, but as
1759auxiliary outputs:
1760
1761@smallexample
1762gcc -save-temps -S foo.c
1763@end smallexample
1764
1765saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1766then compiles to the (implied) output file @file{foo.s}, whereas:
1767
1768@smallexample
1769gcc -save-temps -dumpbase save-foo -c foo.c
1770@end smallexample
1771
1772preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1773an intermediate, thus auxiliary output), and then assembles to the
1774(implied) output file @file{foo.o}.
1775
1776Absent this option, dump and aux files take their names from the input
1777file, or from the (non-linker) output file, if one is explicitly
1778specified: dump output files (e.g. those requested by @option{-fdump-*}
1779options) with the input name suffix, and aux output files (those
1780requested by other non-dump options, e.g. @code{-save-temps},
1781@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1782
1783Similar suffix differentiation of dump and aux outputs can be attained
1784for explicitly-given @option{-dumpbase basename.suf} by also specifying
1785@option{-dumpbase-ext .suf}.
1786
1787If @var{dumpbase} is explicitly specified with any directory component,
1788any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1789@option{-save-temps=*}) is ignored, and instead of appending to it,
1790@var{dumpbase} fully overrides it:
1791
1792@smallexample
1793gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1794 -dumpdir pfx- -save-temps=cwd ...
1795@end smallexample
1796
1797creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1798@file{dir/} in @option{-o}, the @file{./} prefix implied by
1799@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1800
1801When @option{-dumpbase} is specified in a command that compiles multiple
1802inputs, or that compiles and then links, it may be combined with
1803@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1804file is compiled using the combined @var{dumppfx}, and default values
1805for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1806file:
1807
1808@smallexample
1809gcc foo.c bar.c -c -dumpbase main ...
1810@end smallexample
1811
1812creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1813overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1814as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1815and @file{main-bar.*}.
1816
1817An empty string specified as @var{dumpbase} avoids the influence of the
1818output basename in the naming of auxiliary and dump outputs during
1819compilation, computing default values :
1820
1821@smallexample
1822gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1823@end smallexample
1824
1825will name aux outputs @file{dir/foo.*} and dump outputs
1826@file{dir/foo.c.*}. Note how their basenames are taken from the input
1827name, but the directory still defaults to that of the output.
1828
1829The empty-string dumpbase does not prevent the use of the output
1830basename for outputs during linking:
1831
1832@smallexample
1833gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1834@end smallexample
1835
1836The compilation of the source files will name auxiliary outputs
1837@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1838@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1839linking will use @file{dir/foobar.} as the prefix for dumps and
1840auxiliary files.
1841
1842
1843@item -dumpbase-ext @var{auxdropsuf}
1844@opindex dumpbase-ext
1845When forming the name of an auxiliary (but not a dump) output file, drop
1846trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1847suffixes. If not specified, this option defaults to the suffix of a
1848default @var{dumpbase}, i.e., the suffix of the input file when
1849@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1850is combined with @var{dumppfx}.
1851
1852@smallexample
1853gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1854@end smallexample
1855
1856creates @file{dir/foo.o} as the main output, and generates auxiliary
1857outputs in @file{dir/x-foo.*}, taking the location of the primary
1858output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1859outputs retain the suffix: @file{dir/x-foo.c.*}.
1860
1861This option is disregarded if it does not match the suffix of a
1862specified @var{dumpbase}, except as an alternative to the executable
1863suffix when appending the linker output base name to @var{dumppfx}, as
1864specified below:
1865
1866@smallexample
1867gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1868@end smallexample
1869
1870creates @file{main.out} as the primary output, and avoids overwriting
1871the auxiliary and dump outputs by using the executable name minus
1872@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1873@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1874@file{main-foo.c.*} and @file{main-bar.c.*}.
1875
1876
1877@item -dumpdir @var{dumppfx}
1878@opindex dumpdir
1879When forming the name of an auxiliary or dump output file, use
1880@var{dumppfx} as a prefix:
1881
1882@smallexample
1883gcc -dumpdir pfx- -c foo.c ...
1884@end smallexample
1885
1886creates @file{foo.o} as the primary output, and auxiliary outputs named
1887@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1888@var{dumpbase} derived from the default primary output, derived in turn
1889from the input name. Dump outputs also take the input name suffix:
1890@file{pfx-foo.c.*}.
1891
1892If @var{dumppfx} is to be used as a directory name, it must end with a
1893directory separator:
1894
1895@smallexample
1896gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1897@end smallexample
1898
1899creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1900named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1901default @var{dumpbase} derived from the primary output name. Dump
1902outputs also take the input name suffix: @file{dir/bar.c.*}.
1903
1904It defaults to the location of the output file, unless the output
1905file is a special file like @code{/dev/null}. Options
1906@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1907default, just like an explicit @option{-dumpdir} option. In case
1908multiple such options are given, the last one prevails:
1909
1910@smallexample
1911gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1912@end smallexample
1913
1914outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1915@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1916@option{-dumpdir} option. It does not matter that @option{=obj} is the
1917default for @option{-save-temps}, nor that the output directory is
1918implicitly the current directory. Dump outputs are named
1919@file{foo.c.*}.
1920
1921When compiling from multiple input files, if @option{-dumpbase} is
1922specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1923are appended to (or override, if containing any directory components) an
1924explicit or defaulted @var{dumppfx}, so that each of the multiple
1925compilations gets differently-named aux and dump outputs.
1926
1927@smallexample
1928gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1929@end smallexample
1930
1931outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1932@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1933Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1934and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1935single-input compilation:
1936
1937@smallexample
1938gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1939@end smallexample
1940
1941that, applying @option{-dumpbase} to a single source, does not compute
1942and append a separate @var{dumpbase} per input file. Its auxiliary and
1943dump outputs go in @file{dir/pfx-main.*}.
1944
1945When compiling and then linking from multiple input files, a defaulted
1946or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1947transformation above (e.g. the compilation of @file{foo.c} and
1948@file{bar.c} above, but without @option{-c}). If neither
1949@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1950base name, minus @var{auxdropsuf}, if specified, or the executable
1951suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1952instead. Note, however, that unlike earlier cases of linking:
1953
1954@smallexample
1955gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1956@end smallexample
1957
1958does not append the output name @file{main} to @var{dumppfx}, because
1959@option{-dumpdir} is explicitly specified. The goal is that the
1960explicitly-specified @var{dumppfx} may contain the specified output name
1961as part of the prefix, if desired; only an explicitly-specified
1962@option{-dumpbase} would be combined with it, in order to avoid simply
1963discarding a meaningful option.
1964
1965When compiling and then linking from a single input file, the linker
1966output base name will only be appended to the default @var{dumppfx} as
1967above if it does not share the base name with the single input file
1968name. This has been covered in single-input linking cases above, but
1969not with an explicit @option{-dumpdir} that inhibits the combination,
1970even if overridden by @option{-save-temps=*}:
1971
1972@smallexample
1973gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1974@end smallexample
1975
1976Auxiliary outputs are named @file{foo.*}, and dump outputs
1977@file{foo.c.*}, in the current working directory as ultimately requested
1978by @option{-save-temps=cwd}.
1979
1980Summing it all up for an intuitive though slightly imprecise data flow:
1981the primary output name is broken into a directory part and a basename
1982part; @var{dumppfx} is set to the former, unless overridden by
1983@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
1984to the latter, unless overriden by @option{-dumpbase}. If there are
1985multiple inputs or linking, this @var{dumpbase} may be combined with
1986@var{dumppfx} and taken from each input file. Auxiliary output names
1987for each input are formed by combining @var{dumppfx}, @var{dumpbase}
1988minus suffix, and the auxiliary output suffix; dump output names are
1989only different in that the suffix from @var{dumpbase} is retained.
1990
1991When it comes to auxiliary and dump outputs created during LTO
1992recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
1993given or as derived from the linker output name but not from inputs,
1994even in cases in which this combination would not otherwise be used as
1995such, is passed down with a trailing period replacing the compiler-added
1996dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
1997being involved in linking, this program does not normally get any
1998@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
1999
2000When running sub-compilers, @command{lto-wrapper} appends LTO stage
2001names to the received @var{dumppfx}, ensures it contains a directory
2002component so that it overrides any @option{-dumpdir}, and passes that as
2003@option{-dumpbase} to sub-compilers.
2004
2005@item -v
2006@opindex v
2007Print (on standard error output) the commands executed to run the stages
2008of compilation. Also print the version number of the compiler driver
2009program and of the preprocessor and the compiler proper.
2010
2011@item -###
2012@opindex ###
2013Like @option{-v} except the commands are not executed and arguments
2014are quoted unless they contain only alphanumeric characters or @code{./-_}.
2015This is useful for shell scripts to capture the driver-generated command lines.
2016
2017@item --help
2018@opindex help
2019Print (on the standard output) a description of the command-line options
2020understood by @command{gcc}. If the @option{-v} option is also specified
2021then @option{--help} is also passed on to the various processes
2022invoked by @command{gcc}, so that they can display the command-line options
2023they accept. If the @option{-Wextra} option has also been specified
2024(prior to the @option{--help} option), then command-line options that
2025have no documentation associated with them are also displayed.
2026
2027@item --target-help
2028@opindex target-help
2029Print (on the standard output) a description of target-specific command-line
2030options for each tool. For some targets extra target-specific
2031information may also be printed.
2032
2033@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2034Print (on the standard output) a description of the command-line
2035options understood by the compiler that fit into all specified classes
2036and qualifiers. These are the supported classes:
2037
2038@table @asis
2039@item @samp{optimizers}
2040Display all of the optimization options supported by the
2041compiler.
2042
2043@item @samp{warnings}
2044Display all of the options controlling warning messages
2045produced by the compiler.
2046
2047@item @samp{target}
2048Display target-specific options. Unlike the
2049@option{--target-help} option however, target-specific options of the
2050linker and assembler are not displayed. This is because those
2051tools do not currently support the extended @option{--help=} syntax.
2052
2053@item @samp{params}
2054Display the values recognized by the @option{--param}
2055option.
2056
2057@item @var{language}
2058Display the options supported for @var{language}, where
2059@var{language} is the name of one of the languages supported in this
2060version of GCC@. If an option is supported by all languages, one needs
2061to select @samp{common} class.
2062
2063@item @samp{common}
2064Display the options that are common to all languages.
2065@end table
2066
2067These are the supported qualifiers:
2068
2069@table @asis
2070@item @samp{undocumented}
2071Display only those options that are undocumented.
2072
2073@item @samp{joined}
2074Display options taking an argument that appears after an equal
2075sign in the same continuous piece of text, such as:
2076@samp{--help=target}.
2077
2078@item @samp{separate}
2079Display options taking an argument that appears as a separate word
2080following the original option, such as: @samp{-o output-file}.
2081@end table
2082
2083Thus for example to display all the undocumented target-specific
2084switches supported by the compiler, use:
2085
2086@smallexample
2087--help=target,undocumented
2088@end smallexample
2089
2090The sense of a qualifier can be inverted by prefixing it with the
2091@samp{^} character, so for example to display all binary warning
2092options (i.e., ones that are either on or off and that do not take an
2093argument) that have a description, use:
2094
2095@smallexample
2096--help=warnings,^joined,^undocumented
2097@end smallexample
2098
2099The argument to @option{--help=} should not consist solely of inverted
2100qualifiers.
2101
2102Combining several classes is possible, although this usually
2103restricts the output so much that there is nothing to display. One
2104case where it does work, however, is when one of the classes is
2105@var{target}. For example, to display all the target-specific
2106optimization options, use:
2107
2108@smallexample
2109--help=target,optimizers
2110@end smallexample
2111
2112The @option{--help=} option can be repeated on the command line. Each
2113successive use displays its requested class of options, skipping
2114those that have already been displayed. If @option{--help} is also
2115specified anywhere on the command line then this takes precedence
2116over any @option{--help=} option.
2117
2118If the @option{-Q} option appears on the command line before the
2119@option{--help=} option, then the descriptive text displayed by
2120@option{--help=} is changed. Instead of describing the displayed
2121options, an indication is given as to whether the option is enabled,
2122disabled or set to a specific value (assuming that the compiler
2123knows this at the point where the @option{--help=} option is used).
2124
2125Here is a truncated example from the ARM port of @command{gcc}:
2126
2127@smallexample
2128 % gcc -Q -mabi=2 --help=target -c
2129 The following options are target specific:
2130 -mabi= 2
2131 -mabort-on-noreturn [disabled]
2132 -mapcs [disabled]
2133@end smallexample
2134
2135The output is sensitive to the effects of previous command-line
2136options, so for example it is possible to find out which optimizations
2137are enabled at @option{-O2} by using:
2138
2139@smallexample
2140-Q -O2 --help=optimizers
2141@end smallexample
2142
2143Alternatively you can discover which binary optimizations are enabled
2144by @option{-O3} by using:
2145
2146@smallexample
2147gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2148gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2149diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2150@end smallexample
2151
2152@item --version
2153@opindex version
2154Display the version number and copyrights of the invoked GCC@.
2155
2156@item -pass-exit-codes
2157@opindex pass-exit-codes
2158Normally the @command{gcc} program exits with the code of 1 if any
2159phase of the compiler returns a non-success return code. If you specify
2160@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2161the numerically highest error produced by any phase returning an error
2162indication. The C, C++, and Fortran front ends return 4 if an internal
2163compiler error is encountered.
2164
2165@item -pipe
2166@opindex pipe
2167Use pipes rather than temporary files for communication between the
2168various stages of compilation. This fails to work on some systems where
2169the assembler is unable to read from a pipe; but the GNU assembler has
2170no trouble.
2171
2172@item -specs=@var{file}
2173@opindex specs
2174Process @var{file} after the compiler reads in the standard @file{specs}
2175file, in order to override the defaults which the @command{gcc} driver
2176program uses when determining what switches to pass to @command{cc1},
2177@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2178@option{-specs=@var{file}} can be specified on the command line, and they
2179are processed in order, from left to right. @xref{Spec Files}, for
2180information about the format of the @var{file}.
2181
2182@item -wrapper
2183@opindex wrapper
2184Invoke all subcommands under a wrapper program. The name of the
2185wrapper program and its parameters are passed as a comma separated
2186list.
2187
2188@smallexample
2189gcc -c t.c -wrapper gdb,--args
2190@end smallexample
2191
2192@noindent
2193This invokes all subprograms of @command{gcc} under
2194@samp{gdb --args}, thus the invocation of @command{cc1} is
2195@samp{gdb --args cc1 @dots{}}.
2196
2197@item -ffile-prefix-map=@var{old}=@var{new}
2198@opindex ffile-prefix-map
2199When compiling files residing in directory @file{@var{old}}, record
2200any references to them in the result of the compilation as if the
2201files resided in directory @file{@var{new}} instead. Specifying this
2202option is equivalent to specifying all the individual
2203@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27
RP
2204builds that are location independent. Directories referenced by
2205directives are not affected by these options. See also
d77de738
ML
2206@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map} and
2207@option{-fprofile-prefix-map}.
2208
2209@item -fplugin=@var{name}.so
2210@opindex fplugin
2211Load the plugin code in file @var{name}.so, assumed to be a
2212shared object to be dlopen'd by the compiler. The base name of
2213the shared object file is used to identify the plugin for the
2214purposes of argument parsing (See
2215@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2216Each plugin should define the callback functions specified in the
2217Plugins API.
2218
2219@item -fplugin-arg-@var{name}-@var{key}=@var{value}
2220@opindex fplugin-arg
2221Define an argument called @var{key} with a value of @var{value}
2222for the plugin called @var{name}.
2223
2224@item -fdump-ada-spec@r{[}-slim@r{]}
2225@opindex fdump-ada-spec
2226For C and C++ source and include files, generate corresponding Ada specs.
2227@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2228GNAT User's Guide}, which provides detailed documentation on this feature.
2229
2230@item -fada-spec-parent=@var{unit}
2231@opindex fada-spec-parent
2232In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2233Ada specs as child units of parent @var{unit}.
2234
2235@item -fdump-go-spec=@var{file}
2236@opindex fdump-go-spec
2237For input files in any language, generate corresponding Go
2238declarations in @var{file}. This generates Go @code{const},
2239@code{type}, @code{var}, and @code{func} declarations which may be a
2240useful way to start writing a Go interface to code written in some
2241other language.
2242
2243@include @value{srcdir}/../libiberty/at-file.texi
2244@end table
2245
2246@node Invoking G++
2247@section Compiling C++ Programs
2248
2249@cindex suffixes for C++ source
2250@cindex C++ source file suffixes
2251C++ source files conventionally use one of the suffixes @samp{.C},
2252@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2253@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2254@samp{.H}, or (for shared template code) @samp{.tcc}; and
2255preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2256files with these names and compiles them as C++ programs even if you
2257call the compiler the same way as for compiling C programs (usually
2258with the name @command{gcc}).
2259
2260@findex g++
2261@findex c++
2262However, the use of @command{gcc} does not add the C++ library.
2263@command{g++} is a program that calls GCC and automatically specifies linking
2264against the C++ library. It treats @samp{.c},
2265@samp{.h} and @samp{.i} files as C++ source files instead of C source
2266files unless @option{-x} is used. This program is also useful when
2267precompiling a C header file with a @samp{.h} extension for use in C++
2268compilations. On many systems, @command{g++} is also installed with
2269the name @command{c++}.
2270
2271@cindex invoking @command{g++}
2272When you compile C++ programs, you may specify many of the same
2273command-line options that you use for compiling programs in any
2274language; or command-line options meaningful for C and related
2275languages; or options that are meaningful only for C++ programs.
2276@xref{C Dialect Options,,Options Controlling C Dialect}, for
2277explanations of options for languages related to C@.
2278@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2279explanations of options that are meaningful only for C++ programs.
2280
2281@node C Dialect Options
2282@section Options Controlling C Dialect
2283@cindex dialect options
2284@cindex language dialect options
2285@cindex options, dialect
2286
2287The following options control the dialect of C (or languages derived
2288from C, such as C++, Objective-C and Objective-C++) that the compiler
2289accepts:
2290
2291@table @gcctabopt
2292@cindex ANSI support
2293@cindex ISO support
2294@item -ansi
2295@opindex ansi
2296In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2297equivalent to @option{-std=c++98}.
2298
2299This turns off certain features of GCC that are incompatible with ISO
2300C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2301such as the @code{asm} and @code{typeof} keywords, and
2302predefined macros such as @code{unix} and @code{vax} that identify the
2303type of system you are using. It also enables the undesirable and
2304rarely used ISO trigraph feature. For the C compiler,
2305it disables recognition of C++ style @samp{//} comments as well as
2306the @code{inline} keyword.
2307
2308The alternate keywords @code{__asm__}, @code{__extension__},
2309@code{__inline__} and @code{__typeof__} continue to work despite
2310@option{-ansi}. You would not want to use them in an ISO C program, of
2311course, but it is useful to put them in header files that might be included
2312in compilations done with @option{-ansi}. Alternate predefined macros
2313such as @code{__unix__} and @code{__vax__} are also available, with or
2314without @option{-ansi}.
2315
2316The @option{-ansi} option does not cause non-ISO programs to be
2317rejected gratuitously. For that, @option{-Wpedantic} is required in
2318addition to @option{-ansi}. @xref{Warning Options}.
2319
2320The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2321option is used. Some header files may notice this macro and refrain
2322from declaring certain functions or defining certain macros that the
2323ISO standard doesn't call for; this is to avoid interfering with any
2324programs that might use these names for other things.
2325
2326Functions that are normally built in but do not have semantics
2327defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2328functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2329built-in functions provided by GCC}, for details of the functions
2330affected.
2331
2332@item -std=
2333@opindex std
2334Determine the language standard. @xref{Standards,,Language Standards
2335Supported by GCC}, for details of these standard versions. This option
2336is currently only supported when compiling C or C++.
2337
2338The compiler can accept several base standards, such as @samp{c90} or
2339@samp{c++98}, and GNU dialects of those standards, such as
2340@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2341compiler accepts all programs following that standard plus those
2342using GNU extensions that do not contradict it. For example,
2343@option{-std=c90} turns off certain features of GCC that are
2344incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2345keywords, but not other GNU extensions that do not have a meaning in
2346ISO C90, such as omitting the middle term of a @code{?:}
2347expression. On the other hand, when a GNU dialect of a standard is
2348specified, all features supported by the compiler are enabled, even when
2349those features change the meaning of the base standard. As a result, some
2350strict-conforming programs may be rejected. The particular standard
2351is used by @option{-Wpedantic} to identify which features are GNU
2352extensions given that version of the standard. For example
2353@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2354comments, while @option{-std=gnu99 -Wpedantic} does not.
2355
2356A value for this option must be provided; possible values are
2357
2358@table @samp
2359@item c90
2360@itemx c89
2361@itemx iso9899:1990
2362Support all ISO C90 programs (certain GNU extensions that conflict
2363with ISO C90 are disabled). Same as @option{-ansi} for C code.
2364
2365@item iso9899:199409
2366ISO C90 as modified in amendment 1.
2367
2368@item c99
2369@itemx c9x
2370@itemx iso9899:1999
2371@itemx iso9899:199x
2372ISO C99. This standard is substantially completely supported, modulo
2373bugs and floating-point issues
2374(mainly but not entirely relating to optional C99 features from
2375Annexes F and G). See
2376@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2377names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2378
2379@item c11
2380@itemx c1x
2381@itemx iso9899:2011
2382ISO C11, the 2011 revision of the ISO C standard. This standard is
2383substantially completely supported, modulo bugs, floating-point issues
2384(mainly but not entirely relating to optional C11 features from
2385Annexes F and G) and the optional Annexes K (Bounds-checking
2386interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2387
2388@item c17
2389@itemx c18
2390@itemx iso9899:2017
2391@itemx iso9899:2018
2392ISO C17, the 2017 revision of the ISO C standard
2393(published in 2018). This standard is
2394same as C11 except for corrections of defects (all of which are also
2395applied with @option{-std=c11}) and a new value of
2396@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2397
2398@item c2x
2399The next version of the ISO C standard, still under development. The
2400support for this version is experimental and incomplete.
2401
2402@item gnu90
2403@itemx gnu89
2404GNU dialect of ISO C90 (including some C99 features).
2405
2406@item gnu99
2407@itemx gnu9x
2408GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2409
2410@item gnu11
2411@itemx gnu1x
2412GNU dialect of ISO C11.
2413The name @samp{gnu1x} is deprecated.
2414
2415@item gnu17
2416@itemx gnu18
2417GNU dialect of ISO C17. This is the default for C code.
2418
2419@item gnu2x
2420The next version of the ISO C standard, still under development, plus
2421GNU extensions. The support for this version is experimental and
2422incomplete.
2423
2424@item c++98
2425@itemx c++03
2426The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2427additional defect reports. Same as @option{-ansi} for C++ code.
2428
2429@item gnu++98
2430@itemx gnu++03
2431GNU dialect of @option{-std=c++98}.
2432
2433@item c++11
2434@itemx c++0x
2435The 2011 ISO C++ standard plus amendments.
2436The name @samp{c++0x} is deprecated.
2437
2438@item gnu++11
2439@itemx gnu++0x
2440GNU dialect of @option{-std=c++11}.
2441The name @samp{gnu++0x} is deprecated.
2442
2443@item c++14
2444@itemx c++1y
2445The 2014 ISO C++ standard plus amendments.
2446The name @samp{c++1y} is deprecated.
2447
2448@item gnu++14
2449@itemx gnu++1y
2450GNU dialect of @option{-std=c++14}.
2451The name @samp{gnu++1y} is deprecated.
2452
2453@item c++17
2454@itemx c++1z
2455The 2017 ISO C++ standard plus amendments.
2456The name @samp{c++1z} is deprecated.
2457
2458@item gnu++17
2459@itemx gnu++1z
2460GNU dialect of @option{-std=c++17}.
2461This is the default for C++ code.
2462The name @samp{gnu++1z} is deprecated.
2463
2464@item c++20
2465@itemx c++2a
2466The 2020 ISO C++ standard plus amendments.
2467Support is experimental, and could change in incompatible ways in
2468future releases.
2469The name @samp{c++2a} is deprecated.
2470
2471@item gnu++20
2472@itemx gnu++2a
2473GNU dialect of @option{-std=c++20}.
2474Support is experimental, and could change in incompatible ways in
2475future releases.
2476The name @samp{gnu++2a} is deprecated.
2477
2478@item c++2b
2479@itemx c++23
2480The next revision of the ISO C++ standard, planned for
24812023. Support is highly experimental, and will almost certainly
2482change in incompatible ways in future releases.
2483
2484@item gnu++2b
2485@itemx gnu++23
2486GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2487and will almost certainly change in incompatible ways in future
2488releases.
2489@end table
2490
2491@item -aux-info @var{filename}
2492@opindex aux-info
2493Output to the given filename prototyped declarations for all functions
2494declared and/or defined in a translation unit, including those in header
2495files. This option is silently ignored in any language other than C@.
2496
2497Besides declarations, the file indicates, in comments, the origin of
2498each declaration (source file and line), whether the declaration was
2499implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2500@samp{O} for old, respectively, in the first character after the line
2501number and the colon), and whether it came from a declaration or a
2502definition (@samp{C} or @samp{F}, respectively, in the following
2503character). In the case of function definitions, a K&R-style list of
2504arguments followed by their declarations is also provided, inside
2505comments, after the declaration.
2506
2507@item -fno-asm
2508@opindex fno-asm
2509@opindex fasm
2510Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2511keyword, so that code can use these words as identifiers. You can use
2512the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2513instead. In C, @option{-ansi} implies @option{-fno-asm}.
2514
2515In C++, @code{inline} is a standard keyword and is not affected by
2516this switch. You may want to use the @option{-fno-gnu-keywords} flag
2517instead, which disables @code{typeof} but not @code{asm} and
2518@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2519this switch only affects the @code{asm} and @code{typeof} keywords,
2520since @code{inline} is a standard keyword in ISO C99. In C2X mode
2521(@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects
2522the @code{asm} keyword, since @code{typeof} is a standard keyword in
2523ISO C2X.
2524
2525@item -fno-builtin
2526@itemx -fno-builtin-@var{function}
2527@opindex fno-builtin
2528@opindex fbuiltin
2529@cindex built-in functions
2530Don't recognize built-in functions that do not begin with
2531@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2532functions provided by GCC}, for details of the functions affected,
2533including those which are not built-in functions when @option{-ansi} or
2534@option{-std} options for strict ISO C conformance are used because they
2535do not have an ISO standard meaning.
2536
2537GCC normally generates special code to handle certain built-in functions
2538more efficiently; for instance, calls to @code{alloca} may become single
2539instructions which adjust the stack directly, and calls to @code{memcpy}
2540may become inline copy loops. The resulting code is often both smaller
2541and faster, but since the function calls no longer appear as such, you
2542cannot set a breakpoint on those calls, nor can you change the behavior
2543of the functions by linking with a different library. In addition,
2544when a function is recognized as a built-in function, GCC may use
2545information about that function to warn about problems with calls to
2546that function, or to generate more efficient code, even if the
2547resulting code still contains calls to that function. For example,
2548warnings are given with @option{-Wformat} for bad calls to
2549@code{printf} when @code{printf} is built in and @code{strlen} is
2550known not to modify global memory.
2551
2552With the @option{-fno-builtin-@var{function}} option
2553only the built-in function @var{function} is
2554disabled. @var{function} must not begin with @samp{__builtin_}. If a
2555function is named that is not built-in in this version of GCC, this
2556option is ignored. There is no corresponding
2557@option{-fbuiltin-@var{function}} option; if you wish to enable
2558built-in functions selectively when using @option{-fno-builtin} or
2559@option{-ffreestanding}, you may define macros such as:
2560
2561@smallexample
2562#define abs(n) __builtin_abs ((n))
2563#define strcpy(d, s) __builtin_strcpy ((d), (s))
2564@end smallexample
2565
2566@item -fcond-mismatch
2567@opindex fcond-mismatch
2568Allow conditional expressions with mismatched types in the second and
2569third arguments. The value of such an expression is void. This option
2570is not supported for C++.
2571
2572@item -ffreestanding
2573@opindex ffreestanding
2574@cindex hosted environment
2575
2576Assert that compilation targets a freestanding environment. This
2577implies @option{-fno-builtin}. A freestanding environment
2578is one in which the standard library may not exist, and program startup may
2579not necessarily be at @code{main}. The most obvious example is an OS kernel.
2580This is equivalent to @option{-fno-hosted}.
2581
2582@xref{Standards,,Language Standards Supported by GCC}, for details of
2583freestanding and hosted environments.
2584
2585@item -fgimple
2586@opindex fgimple
2587
2588Enable parsing of function definitions marked with @code{__GIMPLE}.
2589This is an experimental feature that allows unit testing of GIMPLE
2590passes.
2591
2592@item -fgnu-tm
2593@opindex fgnu-tm
2594When the option @option{-fgnu-tm} is specified, the compiler
2595generates code for the Linux variant of Intel's current Transactional
2596Memory ABI specification document (Revision 1.1, May 6 2009). This is
2597an experimental feature whose interface may change in future versions
2598of GCC, as the official specification changes. Please note that not
2599all architectures are supported for this feature.
2600
2601For more information on GCC's support for transactional memory,
2602@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2603Transactional Memory Library}.
2604
2605Note that the transactional memory feature is not supported with
2606non-call exceptions (@option{-fnon-call-exceptions}).
2607
2608@item -fgnu89-inline
2609@opindex fgnu89-inline
2610The option @option{-fgnu89-inline} tells GCC to use the traditional
2611GNU semantics for @code{inline} functions when in C99 mode.
2612@xref{Inline,,An Inline Function is As Fast As a Macro}.
2613Using this option is roughly equivalent to adding the
2614@code{gnu_inline} function attribute to all inline functions
2615(@pxref{Function Attributes}).
2616
2617The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2618C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2619specifies the default behavior).
2620This option is not supported in @option{-std=c90} or
2621@option{-std=gnu90} mode.
2622
2623The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2624@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2625in effect for @code{inline} functions. @xref{Common Predefined
2626Macros,,,cpp,The C Preprocessor}.
2627
2628@item -fhosted
2629@opindex fhosted
2630@cindex hosted environment
2631
2632Assert that compilation targets a hosted environment. This implies
2633@option{-fbuiltin}. A hosted environment is one in which the
2634entire standard library is available, and in which @code{main} has a return
2635type of @code{int}. Examples are nearly everything except a kernel.
2636This is equivalent to @option{-fno-freestanding}.
2637
2638@item -flax-vector-conversions
2639@opindex flax-vector-conversions
2640Allow implicit conversions between vectors with differing numbers of
2641elements and/or incompatible element types. This option should not be
2642used for new code.
2643
2644@item -fms-extensions
2645@opindex fms-extensions
2646Accept some non-standard constructs used in Microsoft header files.
2647
2648In C++ code, this allows member names in structures to be similar
2649to previous types declarations.
2650
2651@smallexample
2652typedef int UOW;
2653struct ABC @{
2654 UOW UOW;
2655@};
2656@end smallexample
2657
2658Some cases of unnamed fields in structures and unions are only
2659accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2660fields within structs/unions}, for details.
2661
2662Note that this option is off for all targets except for x86
2663targets using ms-abi.
2664
2665@item -foffload=disable
2666@itemx -foffload=default
2667@itemx -foffload=@var{target-list}
2668@opindex foffload
2669@cindex Offloading targets
2670@cindex OpenACC offloading targets
2671@cindex OpenMP offloading targets
2672Specify for which OpenMP and OpenACC offload targets code should be generated.
2673The default behavior, equivalent to @option{-foffload=default}, is to generate
2674code for all supported offload targets. The @option{-foffload=disable} form
2675generates code only for the host fallback, while
2676@option{-foffload=@var{target-list}} generates code only for the specified
2677comma-separated list of offload targets.
2678
2679Offload targets are specified in GCC's internal target-triplet format. You can
2680run the compiler with @option{-v} to show the list of configured offload targets
2681under @code{OFFLOAD_TARGET_NAMES}.
2682
2683@item -foffload-options=@var{options}
2684@itemx -foffload-options=@var{target-triplet-list}=@var{options}
2685@opindex foffload-options
2686@cindex Offloading options
2687@cindex OpenACC offloading options
2688@cindex OpenMP offloading options
2689
2690With @option{-foffload-options=@var{options}}, GCC passes the specified
2691@var{options} to the compilers for all enabled offloading targets. You can
2692specify options that apply only to a specific target or targets by using
2693the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2694@var{target-list} is a comma-separated list in the same format as for the
2695@option{-foffload=} option.
2696
2697Typical command lines are
2698
2699@smallexample
2700-foffload-options=-lgfortran -foffload-options=-lm
2701-foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic
2702-foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm
2703@end smallexample
2704
2705@item -fopenacc
2706@opindex fopenacc
2707@cindex OpenACC accelerator programming
2708Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and
2709@code{!$acc} in Fortran. When @option{-fopenacc} is specified, the
2710compiler generates accelerated code according to the OpenACC Application
2711Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2712implies @option{-pthread}, and thus is only supported on targets that
2713have support for @option{-pthread}.
2714
2715@item -fopenacc-dim=@var{geom}
2716@opindex fopenacc-dim
2717@cindex OpenACC accelerator programming
2718Specify default compute dimensions for parallel offload regions that do
2719not explicitly specify. The @var{geom} value is a triple of
2720':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2721can be omitted, to use a target-specific default value.
2722
2723@item -fopenmp
2724@opindex fopenmp
2725@cindex OpenMP parallel
2726Enable handling of OpenMP directives @code{#pragma omp} in C/C++,
2727@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and
2728@code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
2729compiler generates parallel code according to the OpenMP Application
2730Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2731implies @option{-pthread}, and thus is only supported on targets that
2732have support for @option{-pthread}. @option{-fopenmp} implies
2733@option{-fopenmp-simd}.
2734
2735@item -fopenmp-simd
2736@opindex fopenmp-simd
2737@cindex OpenMP SIMD
2738@cindex SIMD
2739Enable handling of OpenMP's @code{simd}, @code{declare simd},
2740@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan},
2741@code{loop} directives and combined or composite directives with
2742@code{simd} as constituent with @code{#pragma omp} in C/C++,
2743@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++
2744and @code{!$omp} in Fortran. Other OpenMP directives are ignored.
2745
309e2d95
SL
2746@item -fopenmp-target-simd-clone
2747@item -fopenmp-target-simd-clone=@var{device-type}
2748@opindex fopenmp-target-simd-clone
2749@cindex OpenMP target SIMD clone
2750In addition to generating SIMD clones for functions marked with the
2751@code{declare simd} directive, GCC also generates clones
2752for functions marked with the OpenMP @code{declare target} directive
2753that are suitable for vectorization when this option is in effect. The
2754@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2755and @code{any}, which correspond to keywords for the @code{device_type}
2756clause of the @code{declare target} directive; clones are generated for
2757the intersection of devices specified.
2758@option{-fopenmp-target-simd-clone} is equivalent to
2759@option{-fopenmp-target-simd-clone=any} and
2760@option{-fno-openmp-target-simd-clone} is equivalent to
2761@option{-fopenmp-target-simd-clone=none}.
2762
2763At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2764optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2765it is disabled by default.
2766
d77de738
ML
2767@item -fpermitted-flt-eval-methods=@var{style}
2768@opindex fpermitted-flt-eval-methods
2769@opindex fpermitted-flt-eval-methods=c11
2770@opindex fpermitted-flt-eval-methods=ts-18661-3
2771ISO/IEC TS 18661-3 defines new permissible values for
2772@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2773a semantic type that is an interchange or extended format should be
2774evaluated to the precision and range of that type. These new values are
2775a superset of those permitted under C99/C11, which does not specify the
2776meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2777conforming to C11 may not have been written expecting the possibility of
2778the new values.
2779
2780@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2781should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2782or the extended set of values specified in ISO/IEC TS 18661-3.
2783
2784@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2785
2786The default when in a standards compliant mode (@option{-std=c11} or similar)
2787is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2788dialect (@option{-std=gnu11} or similar) is
2789@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2790
2791@item -fplan9-extensions
2792@opindex fplan9-extensions
2793Accept some non-standard constructs used in Plan 9 code.
2794
2795This enables @option{-fms-extensions}, permits passing pointers to
2796structures with anonymous fields to functions that expect pointers to
2797elements of the type of the field, and permits referring to anonymous
2798fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2799struct/union fields within structs/unions}, for details. This is only
2800supported for C, not C++.
2801
2802@item -fsigned-bitfields
2803@itemx -funsigned-bitfields
2804@itemx -fno-signed-bitfields
2805@itemx -fno-unsigned-bitfields
2806@opindex fsigned-bitfields
2807@opindex funsigned-bitfields
2808@opindex fno-signed-bitfields
2809@opindex fno-unsigned-bitfields
2810These options control whether a bit-field is signed or unsigned, when the
2811declaration does not use either @code{signed} or @code{unsigned}. By
2812default, such a bit-field is signed, because this is consistent: the
2813basic integer types such as @code{int} are signed types.
2814
2815@item -fsigned-char
2816@opindex fsigned-char
2817Let the type @code{char} be signed, like @code{signed char}.
2818
2819Note that this is equivalent to @option{-fno-unsigned-char}, which is
2820the negative form of @option{-funsigned-char}. Likewise, the option
2821@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2822
2823@item -funsigned-char
2824@opindex funsigned-char
2825Let the type @code{char} be unsigned, like @code{unsigned char}.
2826
2827Each kind of machine has a default for what @code{char} should
2828be. It is either like @code{unsigned char} by default or like
2829@code{signed char} by default.
2830
2831Ideally, a portable program should always use @code{signed char} or
2832@code{unsigned char} when it depends on the signedness of an object.
2833But many programs have been written to use plain @code{char} and
2834expect it to be signed, or expect it to be unsigned, depending on the
2835machines they were written for. This option, and its inverse, let you
2836make such a program work with the opposite default.
2837
2838The type @code{char} is always a distinct type from each of
2839@code{signed char} or @code{unsigned char}, even though its behavior
2840is always just like one of those two.
2841
2842@item -fstrict-flex-arrays
2843@opindex fstrict-flex-arrays
2844@opindex fno-strict-flex-arrays
2845Control when to treat the trailing array of a structure as a flexible array
2846member for the purpose of accessing the elements of such an array.
2847The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2848strictest. A trailing array is treated as a flexible array member only when it
2849is declared as a flexible array member per C99 standard onwards.
2850The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2851least strict. All trailing arrays of structures are treated as flexible array
2852members.
2853
2854@item -fstrict-flex-arrays=@var{level}
2855@opindex fstrict-flex-arrays=@var{level}
2856Control when to treat the trailing array of a structure as a flexible array
2857member for the purpose of accessing the elements of such an array. The value
2858of @var{level} controls the level of strictness.
2859
2860The possible values of @var{level} are the same as for the
2861@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2862
2863You can control this behavior for a specific trailing array field of a
2864structure by using the variable attribute @code{strict_flex_array} attribute
2865(@pxref{Variable Attributes}).
2866
2867@item -fsso-struct=@var{endianness}
2868@opindex fsso-struct
2869Set the default scalar storage order of structures and unions to the
2870specified endianness. The accepted values are @samp{big-endian},
2871@samp{little-endian} and @samp{native} for the native endianness of
2872the target (the default). This option is not supported for C++.
2873
2874@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2875code that is not binary compatible with code generated without it if the
2876specified endianness is not the native endianness of the target.
2877@end table
2878
2879@node C++ Dialect Options
2880@section Options Controlling C++ Dialect
2881
2882@cindex compiler options, C++
2883@cindex C++ options, command-line
2884@cindex options, C++
2885This section describes the command-line options that are only meaningful
2886for C++ programs. You can also use most of the GNU compiler options
2887regardless of what language your program is in. For example, you
2888might compile a file @file{firstClass.C} like this:
2889
2890@smallexample
2891g++ -g -fstrict-enums -O -c firstClass.C
2892@end smallexample
2893
2894@noindent
2895In this example, only @option{-fstrict-enums} is an option meant
2896only for C++ programs; you can use the other options with any
2897language supported by GCC@.
2898
2899Some options for compiling C programs, such as @option{-std}, are also
2900relevant for C++ programs.
2901@xref{C Dialect Options,,Options Controlling C Dialect}.
2902
2903Here is a list of options that are @emph{only} for compiling C++ programs:
2904
2905@table @gcctabopt
2906
2907@item -fabi-version=@var{n}
2908@opindex fabi-version
2909Use version @var{n} of the C++ ABI@. The default is version 0.
2910
2911Version 0 refers to the version conforming most closely to
2912the C++ ABI specification. Therefore, the ABI obtained using version 0
2913will change in different versions of G++ as ABI bugs are fixed.
2914
2915Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2916
2917Version 2 is the version of the C++ ABI that first appeared in G++
29183.4, and was the default through G++ 4.9.
2919
2920Version 3 corrects an error in mangling a constant address as a
2921template argument.
2922
2923Version 4, which first appeared in G++ 4.5, implements a standard
2924mangling for vector types.
2925
2926Version 5, which first appeared in G++ 4.6, corrects the mangling of
2927attribute const/volatile on function pointer types, decltype of a
2928plain decl, and use of a function parameter in the declaration of
2929another parameter.
2930
2931Version 6, which first appeared in G++ 4.7, corrects the promotion
2932behavior of C++11 scoped enums and the mangling of template argument
2933packs, const/static_cast, prefix ++ and --, and a class scope function
2934used as a template argument.
2935
2936Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2937builtin type and corrects the mangling of lambdas in default argument
2938scope.
2939
2940Version 8, which first appeared in G++ 4.9, corrects the substitution
2941behavior of function types with function-cv-qualifiers.
2942
2943Version 9, which first appeared in G++ 5.2, corrects the alignment of
2944@code{nullptr_t}.
2945
2946Version 10, which first appeared in G++ 6.1, adds mangling of
2947attributes that affect type identity, such as ia32 calling convention
2948attributes (e.g.@: @samp{stdcall}).
2949
2950Version 11, which first appeared in G++ 7, corrects the mangling of
2951sizeof... expressions and operator names. For multiple entities with
2952the same name within a function, that are declared in different scopes,
2953the mangling now changes starting with the twelfth occurrence. It also
2954implies @option{-fnew-inheriting-ctors}.
2955
2956Version 12, which first appeared in G++ 8, corrects the calling
2957conventions for empty classes on the x86_64 target and for classes
2958with only deleted copy/move constructors. It accidentally changes the
2959calling convention for classes with a deleted copy constructor and a
2960trivial move constructor.
2961
2962Version 13, which first appeared in G++ 8.2, fixes the accidental
2963change in version 12.
2964
2965Version 14, which first appeared in G++ 10, corrects the mangling of
2966the nullptr expression.
2967
2968Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2969tag regression.
2970
2971Version 16, which first appeared in G++ 11, changes the mangling of
2972@code{__alignof__} to be distinct from that of @code{alignof}, and
2973dependent operator names.
2974
2975Version 17, which first appeared in G++ 12, fixes layout of classes
2976that inherit from aggregate classes with default member initializers
2977in C++14 and up.
2978
2979Version 18, which first appeard in G++ 13, fixes manglings of lambdas
2980that have additional context.
2981
2982See also @option{-Wabi}.
2983
2984@item -fabi-compat-version=@var{n}
2985@opindex fabi-compat-version
2986On targets that support strong aliases, G++
2987works around mangling changes by creating an alias with the correct
2988mangled name when defining a symbol with an incorrect mangled name.
2989This switch specifies which ABI version to use for the alias.
2990
2991With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
2992compatibility). If another ABI version is explicitly selected, this
2993defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
2994use @option{-fabi-compat-version=2}.
2995
2996If this option is not provided but @option{-Wabi=@var{n}} is, that
2997version is used for compatibility aliases. If this option is provided
2998along with @option{-Wabi} (without the version), the version from this
2999option is used for the warning.
3000
3001@item -fno-access-control
3002@opindex fno-access-control
3003@opindex faccess-control
3004Turn off all access checking. This switch is mainly useful for working
3005around bugs in the access control code.
3006
3007@item -faligned-new
3008@opindex faligned-new
3009Enable support for C++17 @code{new} of types that require more
3010alignment than @code{void* ::operator new(std::size_t)} provides. A
3011numeric argument such as @code{-faligned-new=32} can be used to
3012specify how much alignment (in bytes) is provided by that function,
3013but few users will need to override the default of
3014@code{alignof(std::max_align_t)}.
3015
3016This flag is enabled by default for @option{-std=c++17}.
3017
3018@item -fchar8_t
3019@itemx -fno-char8_t
3020@opindex fchar8_t
3021@opindex fno-char8_t
3022Enable support for @code{char8_t} as adopted for C++20. This includes
3023the addition of a new @code{char8_t} fundamental type, changes to the
3024types of UTF-8 string and character literals, new signatures for
3025user-defined literals, associated standard library updates, and new
3026@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3027
3028This option enables functions to be overloaded for ordinary and UTF-8
3029strings:
3030
3031@smallexample
3032int f(const char *); // #1
3033int f(const char8_t *); // #2
3034int v1 = f("text"); // Calls #1
3035int v2 = f(u8"text"); // Calls #2
3036@end smallexample
3037
3038@noindent
3039and introduces new signatures for user-defined literals:
3040
3041@smallexample
3042int operator""_udl1(char8_t);
3043int v3 = u8'x'_udl1;
3044int operator""_udl2(const char8_t*, std::size_t);
3045int v4 = u8"text"_udl2;
3046template<typename T, T...> int operator""_udl3();
3047int v5 = u8"text"_udl3;
3048@end smallexample
3049
3050@noindent
3051The change to the types of UTF-8 string and character literals introduces
3052incompatibilities with ISO C++11 and later standards. For example, the
3053following code is well-formed under ISO C++11, but is ill-formed when
3054@option{-fchar8_t} is specified.
3055
3056@smallexample
3057char ca[] = u8"xx"; // error: char-array initialized from wide
3058 // string
3059const char *cp = u8"xx";// error: invalid conversion from
3060 // `const char8_t*' to `const char*'
3061int f(const char*);
3062auto v = f(u8"xx"); // error: invalid conversion from
3063 // `const char8_t*' to `const char*'
3064std::string s@{u8"xx"@}; // error: no matching function for call to
3065 // `std::basic_string<char>::basic_string()'
3066using namespace std::literals;
3067s = u8"xx"s; // error: conversion from
3068 // `basic_string<char8_t>' to non-scalar
3069 // type `basic_string<char>' requested
3070@end smallexample
3071
3072@item -fcheck-new
3073@opindex fcheck-new
3074Check that the pointer returned by @code{operator new} is non-null
3075before attempting to modify the storage allocated. This check is
3076normally unnecessary because the C++ standard specifies that
3077@code{operator new} only returns @code{0} if it is declared
3078@code{throw()}, in which case the compiler always checks the
3079return value even without this option. In all other cases, when
3080@code{operator new} has a non-empty exception specification, memory
3081exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3082@samp{new (nothrow)}.
3083
3084@item -fconcepts
3085@itemx -fconcepts-ts
3086@opindex fconcepts
3087@opindex fconcepts-ts
3088Enable support for the C++ Concepts feature for constraining template
3089arguments. With @option{-std=c++20} and above, Concepts are part of
3090the language standard, so @option{-fconcepts} defaults to on.
3091
3092Some constructs that were allowed by the earlier C++ Extensions for
3093Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3094into the standard, can additionally be enabled by
3095@option{-fconcepts-ts}.
3096
3097@item -fconstexpr-depth=@var{n}
3098@opindex fconstexpr-depth
3099Set the maximum nested evaluation depth for C++11 constexpr functions
3100to @var{n}. A limit is needed to detect endless recursion during
3101constant expression evaluation. The minimum specified by the standard
3102is 512.
3103
3104@item -fconstexpr-cache-depth=@var{n}
3105@opindex fconstexpr-cache-depth
3106Set the maximum level of nested evaluation depth for C++11 constexpr
3107functions that will be cached to @var{n}. This is a heuristic that
3108trades off compilation speed (when the cache avoids repeated
3109calculations) against memory consumption (when the cache grows very
3110large from highly recursive evaluations). The default is 8. Very few
3111users are likely to want to adjust it, but if your code does heavy
3112constexpr calculations you might want to experiment to find which
3113value works best for you.
3114
3115@item -fconstexpr-fp-except
3116@opindex fconstexpr-fp-except
3117Annex F of the C standard specifies that IEC559 floating point
3118exceptions encountered at compile time should not stop compilation.
3119C++ compilers have historically not followed this guidance, instead
3120treating floating point division by zero as non-constant even though
3121it has a well defined value. This flag tells the compiler to give
3122Annex F priority over other rules saying that a particular operation
3123is undefined.
3124
3125@smallexample
3126constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3127@end smallexample
3128
3129@item -fconstexpr-loop-limit=@var{n}
3130@opindex fconstexpr-loop-limit
3131Set the maximum number of iterations for a loop in C++14 constexpr functions
3132to @var{n}. A limit is needed to detect infinite loops during
3133constant expression evaluation. The default is 262144 (1<<18).
3134
3135@item -fconstexpr-ops-limit=@var{n}
3136@opindex fconstexpr-ops-limit
3137Set the maximum number of operations during a single constexpr evaluation.
3138Even when number of iterations of a single loop is limited with the above limit,
3139if there are several nested loops and each of them has many iterations but still
3140smaller than the above limit, or if in a body of some loop or even outside
3141of a loop too many expressions need to be evaluated, the resulting constexpr
3142evaluation might take too long.
3143The default is 33554432 (1<<25).
3144
2efb237f
JCI
3145@item -fcontracts
3146@opindex fcontracts
3147Enable experimental support for the C++ Contracts feature, as briefly
3148added to and then removed from the C++20 working paper (N4820). The
3149implementation also includes proposed enhancements from papers P1290,
3150P1332, and P1429. This functionality is intended mostly for those
3151interested in experimentation towards refining the feature to get it
3152into shape for a future C++ standard.
3153
3154On violation of a checked contract, the violation handler is called.
3155Users can replace the violation handler by defining
3156@smallexample
3157void handle_contract_violation (const std::experimental::contract_violation&);
3158@end smallexample
3159
3160There are different sets of additional flags that can be used together
3161to specify which contracts will be checked and how, for N4820
3162contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3163used together.
3164
3165@table @gcctabopt
3166@item -fcontract-mode=[on|off]
3167@opindex fcontract-mode
3168Control whether any contracts have any semantics at all. Defaults to on.
3169
3170@item -fcontract-assumption-mode=[on|off]
3171@opindex fcontract-assumption-mode
3172[N4820] Control whether contracts with level @samp{axiom}
3173should have the assume semantic. Defaults to on.
3174
3175@item -fcontract-build-level=[off|default|audit]
3176@opindex fcontract-build-level
3177[N4820] Specify which level of contracts to generate checks
3178for. Defaults to @samp{default}.
3179
3180@item -fcontract-continuation-mode=[on|off]
3181@opindex fcontract-continuation-mode
3182[N4820] Control whether to allow the program to continue executing
3183after a contract violation. That is, do checked contracts have the
3184@samp{maybe} semantic described below rather than the @samp{never}
3185semantic. Defaults to off.
3186
3187@item -fcontract-role=<name>:<default>,<audit>,<axiom>
3188@opindex fcontract-role
3189[P1332] Specify the concrete semantics for each contract level
3190of a particular contract role.
3191
3192@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3193[P1429] Specify the concrete semantic for a particular
3194contract level.
3195
3196@item -fcontract-strict-declarations=[on|off]
3197@opindex fcontract-strict-declarations
3198Control whether to reject adding contracts to a function after its
3199first declaration. Defaults to off.
3200@end table
3201
3202The possible concrete semantics for that can be specified with
3203@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3204
3205@table @code
3206@item ignore
3207This contract has no effect.
3208
3209@item assume
3210This contract is treated like C++23 @code{[[assume]]}.
3211
3212@item check_never_continue
3213@itemx never
3214@itemx abort
3215This contract is checked. If it fails, the violation handler is
3216called. If the handler returns, @code{std::terminate} is called.
3217
3218@item check_maybe_continue
3219@itemx maybe
3220This contract is checked. If it fails, the violation handler is
3221called. If the handler returns, execution continues normally.
3222@end table
3223
d77de738
ML
3224@item -fcoroutines
3225@opindex fcoroutines
3226Enable support for the C++ coroutines extension (experimental).
3227
3228@item -fno-elide-constructors
3229@opindex fno-elide-constructors
3230@opindex felide-constructors
3231The C++ standard allows an implementation to omit creating a temporary
3232that is only used to initialize another object of the same type.
3233Specifying this option disables that optimization, and forces G++ to
3234call the copy constructor in all cases. This option also causes G++
3235to call trivial member functions which otherwise would be expanded inline.
3236
3237In C++17, the compiler is required to omit these temporaries, but this
3238option still affects trivial member functions.
3239
3240@item -fno-enforce-eh-specs
3241@opindex fno-enforce-eh-specs
3242@opindex fenforce-eh-specs
3243Don't generate code to check for violation of exception specifications
3244at run time. This option violates the C++ standard, but may be useful
3245for reducing code size in production builds, much like defining
3246@code{NDEBUG}. This does not give user code permission to throw
3247exceptions in violation of the exception specifications; the compiler
3248still optimizes based on the specifications, so throwing an
3249unexpected exception results in undefined behavior at run time.
3250
3251@item -fextern-tls-init
3252@itemx -fno-extern-tls-init
3253@opindex fextern-tls-init
3254@opindex fno-extern-tls-init
3255The C++11 and OpenMP standards allow @code{thread_local} and
3256@code{threadprivate} variables to have dynamic (runtime)
3257initialization. To support this, any use of such a variable goes
3258through a wrapper function that performs any necessary initialization.
3259When the use and definition of the variable are in the same
3260translation unit, this overhead can be optimized away, but when the
3261use is in a different translation unit there is significant overhead
3262even if the variable doesn't actually need dynamic initialization. If
3263the programmer can be sure that no use of the variable in a
3264non-defining TU needs to trigger dynamic initialization (either
3265because the variable is statically initialized, or a use of the
3266variable in the defining TU will be executed before any uses in
3267another TU), they can avoid this overhead with the
3268@option{-fno-extern-tls-init} option.
3269
3270On targets that support symbol aliases, the default is
3271@option{-fextern-tls-init}. On targets that do not support symbol
3272aliases, the default is @option{-fno-extern-tls-init}.
3273
3274@item -ffold-simple-inlines
3275@itemx -fno-fold-simple-inlines
3276@opindex ffold-simple-inlines
3277@opindex fno-fold-simple-inlines
3278Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3279@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3280means no debug information will be generated for such calls. Since these
3281functions are rarely interesting to debug, this flag is enabled by default
3282unless @option{-fno-inline} is active.
3283
3284@item -fno-gnu-keywords
3285@opindex fno-gnu-keywords
3286@opindex fgnu-keywords
3287Do not recognize @code{typeof} as a keyword, so that code can use this
3288word as an identifier. You can use the keyword @code{__typeof__} instead.
3289This option is implied by the strict ISO C++ dialects: @option{-ansi},
3290@option{-std=c++98}, @option{-std=c++11}, etc.
3291
3292@item -fimplicit-constexpr
3293@opindex fimplicit-constexpr
3294Make inline functions implicitly constexpr, if they satisfy the
3295requirements for a constexpr function. This option can be used in
3296C++14 mode or later. This can result in initialization changing from
3297dynamic to static and other optimizations.
3298
3299@item -fno-implicit-templates
3300@opindex fno-implicit-templates
3301@opindex fimplicit-templates
3302Never emit code for non-inline templates that are instantiated
3303implicitly (i.e.@: by use); only emit code for explicit instantiations.
3304If you use this option, you must take care to structure your code to
3305include all the necessary explicit instantiations to avoid getting
3306undefined symbols at link time.
3307@xref{Template Instantiation}, for more information.
3308
3309@item -fno-implicit-inline-templates
3310@opindex fno-implicit-inline-templates
3311@opindex fimplicit-inline-templates
3312Don't emit code for implicit instantiations of inline templates, either.
3313The default is to handle inlines differently so that compiles with and
3314without optimization need the same set of explicit instantiations.
3315
3316@item -fno-implement-inlines
3317@opindex fno-implement-inlines
3318@opindex fimplement-inlines
3319To save space, do not emit out-of-line copies of inline functions
3320controlled by @code{#pragma implementation}. This causes linker
3321errors if these functions are not inlined everywhere they are called.
3322
3323@item -fmodules-ts
3324@itemx -fno-modules-ts
3325@opindex fmodules-ts
3326@opindex fno-modules-ts
3327Enable support for C++20 modules (@pxref{C++ Modules}). The
3328@option{-fno-modules-ts} is usually not needed, as that is the
3329default. Even though this is a C++20 feature, it is not currently
3330implicitly enabled by selecting that standard version.
3331
3332@item -fmodule-header
3333@itemx -fmodule-header=user
3334@itemx -fmodule-header=system
3335@opindex fmodule-header
3336Compile a header file to create an importable header unit.
3337
3338@item -fmodule-implicit-inline
3339@opindex fmodule-implicit-inline
3340Member functions defined in their class definitions are not implicitly
3341inline for modular code. This is different to traditional C++
3342behavior, for good reasons. However, it may result in a difficulty
3343during code porting. This option makes such function definitions
3344implicitly inline. It does however generate an ABI incompatibility,
3345so you must use it everywhere or nowhere. (Such definitions outside
3346of a named module remain implicitly inline, regardless.)
3347
3348@item -fno-module-lazy
3349@opindex fno-module-lazy
3350@opindex fmodule-lazy
3351Disable lazy module importing and module mapper creation.
3352
3353@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3354@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3355@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3356@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3357@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3358@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
3359@vindex CXX_MODULE_MAPPER @r{environment variable}
3360@opindex fmodule-mapper
3361An oracle to query for module name to filename mappings. If
3362unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3363and if that is unset, an in-process default is provided.
3364
3365@item -fmodule-only
3366@opindex fmodule-only
3367Only emit the Compiled Module Interface, inhibiting any object file.
3368
3369@item -fms-extensions
3370@opindex fms-extensions
3371Disable Wpedantic warnings about constructs used in MFC, such as implicit
3372int and getting a pointer to member function via non-standard syntax.
3373
3374@item -fnew-inheriting-ctors
3375@opindex fnew-inheriting-ctors
3376Enable the P0136 adjustment to the semantics of C++11 constructor
3377inheritance. This is part of C++17 but also considered to be a Defect
3378Report against C++11 and C++14. This flag is enabled by default
3379unless @option{-fabi-version=10} or lower is specified.
3380
3381@item -fnew-ttp-matching
3382@opindex fnew-ttp-matching
3383Enable the P0522 resolution to Core issue 150, template template
3384parameters and default arguments: this allows a template with default
3385template arguments as an argument for a template template parameter
3386with fewer template parameters. This flag is enabled by default for
3387@option{-std=c++17}.
3388
3389@item -fno-nonansi-builtins
3390@opindex fno-nonansi-builtins
3391@opindex fnonansi-builtins
3392Disable built-in declarations of functions that are not mandated by
3393ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3394@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3395
3396@item -fnothrow-opt
3397@opindex fnothrow-opt
3398Treat a @code{throw()} exception specification as if it were a
3399@code{noexcept} specification to reduce or eliminate the text size
3400overhead relative to a function with no exception specification. If
3401the function has local variables of types with non-trivial
3402destructors, the exception specification actually makes the
3403function smaller because the EH cleanups for those variables can be
3404optimized away. The semantic effect is that an exception thrown out of
3405a function with such an exception specification results in a call
3406to @code{terminate} rather than @code{unexpected}.
3407
3408@item -fno-operator-names
3409@opindex fno-operator-names
3410@opindex foperator-names
3411Do not treat the operator name keywords @code{and}, @code{bitand},
3412@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3413synonyms as keywords.
3414
3415@item -fno-optional-diags
3416@opindex fno-optional-diags
3417@opindex foptional-diags
3418Disable diagnostics that the standard says a compiler does not need to
3419issue. Currently, the only such diagnostic issued by G++ is the one for
3420a name having multiple meanings within a class.
3421
3422@item -fpermissive
3423@opindex fpermissive
3424Downgrade some diagnostics about nonconformant code from errors to
3425warnings. Thus, using @option{-fpermissive} allows some
3426nonconforming code to compile.
3427
3428@item -fno-pretty-templates
3429@opindex fno-pretty-templates
3430@opindex fpretty-templates
3431When an error message refers to a specialization of a function
3432template, the compiler normally prints the signature of the
3433template followed by the template arguments and any typedefs or
3434typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3435rather than @code{void f(int)}) so that it's clear which template is
3436involved. When an error message refers to a specialization of a class
3437template, the compiler omits any template arguments that match
3438the default template arguments for that template. If either of these
3439behaviors make it harder to understand the error message rather than
3440easier, you can use @option{-fno-pretty-templates} to disable them.
3441
3442@item -fno-rtti
3443@opindex fno-rtti
3444@opindex frtti
3445Disable generation of information about every class with virtual
3446functions for use by the C++ run-time type identification features
3447(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3448of the language, you can save some space by using this flag. Note that
3449exception handling uses the same information, but G++ generates it as
3450needed. The @code{dynamic_cast} operator can still be used for casts that
3451do not require run-time type information, i.e.@: casts to @code{void *} or to
3452unambiguous base classes.
3453
3454Mixing code compiled with @option{-frtti} with that compiled with
3455@option{-fno-rtti} may not work. For example, programs may
3456fail to link if a class compiled with @option{-fno-rtti} is used as a base
3457for a class compiled with @option{-frtti}.
3458
3459@item -fsized-deallocation
3460@opindex fsized-deallocation
3461Enable the built-in global declarations
3462@smallexample
3463void operator delete (void *, std::size_t) noexcept;
3464void operator delete[] (void *, std::size_t) noexcept;
3465@end smallexample
3466as introduced in C++14. This is useful for user-defined replacement
3467deallocation functions that, for example, use the size of the object
3468to make deallocation faster. Enabled by default under
3469@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3470warns about places that might want to add a definition.
3471
3472@item -fstrict-enums
3473@opindex fstrict-enums
3474Allow the compiler to optimize using the assumption that a value of
3475enumerated type can only be one of the values of the enumeration (as
3476defined in the C++ standard; basically, a value that can be
3477represented in the minimum number of bits needed to represent all the
3478enumerators). This assumption may not be valid if the program uses a
3479cast to convert an arbitrary integer value to the enumerated type.
3480
3481@item -fstrong-eval-order
3482@opindex fstrong-eval-order
3483Evaluate member access, array subscripting, and shift expressions in
3484left-to-right order, and evaluate assignment in right-to-left order,
3485as adopted for C++17. Enabled by default with @option{-std=c++17}.
3486@option{-fstrong-eval-order=some} enables just the ordering of member
3487access and shift expressions, and is the default without
3488@option{-std=c++17}.
3489
3490@item -ftemplate-backtrace-limit=@var{n}
3491@opindex ftemplate-backtrace-limit
3492Set the maximum number of template instantiation notes for a single
3493warning or error to @var{n}. The default value is 10.
3494
3495@item -ftemplate-depth=@var{n}
3496@opindex ftemplate-depth
3497Set the maximum instantiation depth for template classes to @var{n}.
3498A limit on the template instantiation depth is needed to detect
3499endless recursions during template class instantiation. ANSI/ISO C++
3500conforming programs must not rely on a maximum depth greater than 17
3501(changed to 1024 in C++11). The default value is 900, as the compiler
3502can run out of stack space before hitting 1024 in some situations.
3503
3504@item -fno-threadsafe-statics
3505@opindex fno-threadsafe-statics
3506@opindex fthreadsafe-statics
3507Do not emit the extra code to use the routines specified in the C++
3508ABI for thread-safe initialization of local statics. You can use this
3509option to reduce code size slightly in code that doesn't need to be
3510thread-safe.
3511
3512@item -fuse-cxa-atexit
3513@opindex fuse-cxa-atexit
3514Register destructors for objects with static storage duration with the
3515@code{__cxa_atexit} function rather than the @code{atexit} function.
3516This option is required for fully standards-compliant handling of static
3517destructors, but only works if your C library supports
3518@code{__cxa_atexit}.
3519
3520@item -fno-use-cxa-get-exception-ptr
3521@opindex fno-use-cxa-get-exception-ptr
3522@opindex fuse-cxa-get-exception-ptr
3523Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3524causes @code{std::uncaught_exception} to be incorrect, but is necessary
3525if the runtime routine is not available.
3526
3527@item -fvisibility-inlines-hidden
3528@opindex fvisibility-inlines-hidden
3529This switch declares that the user does not attempt to compare
3530pointers to inline functions or methods where the addresses of the two functions
3531are taken in different shared objects.
3532
3533The effect of this is that GCC may, effectively, mark inline methods with
3534@code{__attribute__ ((visibility ("hidden")))} so that they do not
3535appear in the export table of a DSO and do not require a PLT indirection
3536when used within the DSO@. Enabling this option can have a dramatic effect
3537on load and link times of a DSO as it massively reduces the size of the
3538dynamic export table when the library makes heavy use of templates.
3539
3540The behavior of this switch is not quite the same as marking the
3541methods as hidden directly, because it does not affect static variables
3542local to the function or cause the compiler to deduce that
3543the function is defined in only one shared object.
3544
3545You may mark a method as having a visibility explicitly to negate the
3546effect of the switch for that method. For example, if you do want to
3547compare pointers to a particular inline method, you might mark it as
3548having default visibility. Marking the enclosing class with explicit
3549visibility has no effect.
3550
3551Explicitly instantiated inline methods are unaffected by this option
3552as their linkage might otherwise cross a shared library boundary.
3553@xref{Template Instantiation}.
3554
3555@item -fvisibility-ms-compat
3556@opindex fvisibility-ms-compat
3557This flag attempts to use visibility settings to make GCC's C++
3558linkage model compatible with that of Microsoft Visual Studio.
3559
3560The flag makes these changes to GCC's linkage model:
3561
3562@enumerate
3563@item
3564It sets the default visibility to @code{hidden}, like
3565@option{-fvisibility=hidden}.
3566
3567@item
3568Types, but not their members, are not hidden by default.
3569
3570@item
3571The One Definition Rule is relaxed for types without explicit
3572visibility specifications that are defined in more than one
3573shared object: those declarations are permitted if they are
3574permitted when this option is not used.
3575@end enumerate
3576
3577In new code it is better to use @option{-fvisibility=hidden} and
3578export those classes that are intended to be externally visible.
3579Unfortunately it is possible for code to rely, perhaps accidentally,
3580on the Visual Studio behavior.
3581
3582Among the consequences of these changes are that static data members
3583of the same type with the same name but defined in different shared
3584objects are different, so changing one does not change the other;
3585and that pointers to function members defined in different shared
3586objects may not compare equal. When this flag is given, it is a
3587violation of the ODR to define types with the same name differently.
3588
3589@item -fno-weak
3590@opindex fno-weak
3591@opindex fweak
3592Do not use weak symbol support, even if it is provided by the linker.
3593By default, G++ uses weak symbols if they are available. This
3594option exists only for testing, and should not be used by end-users;
3595it results in inferior code and has no benefits. This option may
3596be removed in a future release of G++.
3597
3598@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
3599@opindex fext-numeric-literals
3600@opindex fno-ext-numeric-literals
3601Accept imaginary, fixed-point, or machine-defined
3602literal number suffixes as GNU extensions.
3603When this option is turned off these suffixes are treated
3604as C++11 user-defined literal numeric suffixes.
3605This is on by default for all pre-C++11 dialects and all GNU dialects:
3606@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3607@option{-std=gnu++14}.
3608This option is off by default
3609for ISO C++11 onwards (@option{-std=c++11}, ...).
3610
3611@item -nostdinc++
3612@opindex nostdinc++
3613Do not search for header files in the standard directories specific to
3614C++, but do still search the other standard directories. (This option
3615is used when building the C++ library.)
3616
3617@item -flang-info-include-translate
3618@itemx -flang-info-include-translate-not
3619@itemx -flang-info-include-translate=@var{header}
3620@opindex flang-info-include-translate
3621@opindex flang-info-include-translate-not
3622Inform of include translation events. The first will note accepted
3623include translations, the second will note declined include
3624translations. The @var{header} form will inform of include
3625translations relating to that specific header. If @var{header} is of
3626the form @code{"user"} or @code{<system>} it will be resolved to a
3627specific user or system header using the include path.
3628
3629@item -flang-info-module-cmi
3630@itemx -flang-info-module-cmi=@var{module}
3631@opindex flang-info-module-cmi
3632Inform of Compiled Module Interface pathnames. The first will note
3633all read CMI pathnames. The @var{module} form will not reading a
3634specific module's CMI. @var{module} may be a named module or a
3635header-unit (the latter indicated by either being a pathname containing
3636directory separators or enclosed in @code{<>} or @code{""}).
3637
3638@item -stdlib=@var{libstdc++,libc++}
3639@opindex stdlib
3640When G++ is configured to support this option, it allows specification of
3641alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3642(the default, native C++ runtime for G++) and @var{libc++} which is the
3643C++ runtime installed on some operating systems (e.g. Darwin versions from
3644Darwin11 onwards). The option switches G++ to use the headers from the
3645specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3646when a C++ runtime is required for linking.
3647@end table
3648
3649In addition, these warning options have meanings only for C++ programs:
3650
3651@table @gcctabopt
3652@item -Wabi-tag @r{(C++ and Objective-C++ only)}
3653@opindex Wabi-tag
3654Warn when a type with an ABI tag is used in a context that does not
3655have that ABI tag. See @ref{C++ Attributes} for more information
3656about ABI tags.
3657
3658@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
3659@opindex Wcomma-subscript
3660@opindex Wno-comma-subscript
3661Warn about uses of a comma expression within a subscripting expression.
3662This usage was deprecated in C++20 and is going to be removed in C++23.
3663However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3664
3665@smallexample
3666@group
3667void f(int *a, int b, int c) @{
3668 a[b,c]; // deprecated in C++20, invalid in C++23
3669 a[(b,c)]; // OK
3670@}
3671@end group
3672@end smallexample
3673
3674In C++23 it is valid to have comma separated expressions in a subscript
3675when an overloaded subscript operator is found and supports the right
3676number and types of arguments. G++ will accept the formerly valid syntax
3677for code that is not valid in C++23 but used to be valid but deprecated
3678in C++20 with a pedantic warning that can be disabled with
3679@option{-Wno-comma-subscript}.
3680
3681Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3682and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3683
3684@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
3685@opindex Wctad-maybe-unsupported
3686@opindex Wno-ctad-maybe-unsupported
3687Warn when performing class template argument deduction (CTAD) on a type with
3688no explicitly written deduction guides. This warning will point out cases
3689where CTAD succeeded only because the compiler synthesized the implicit
3690deduction guides, which might not be what the programmer intended. Certain
3691style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3692types that are designed to support CTAD. This warning can be suppressed with
3693the following pattern:
3694
3695@smallexample
3696struct allow_ctad_t; // any name works
3697template <typename T> struct S @{
3698 S(T) @{ @}
3699@};
3700S(allow_ctad_t) -> S<void>; // guide with incomplete parameter type will never be considered
3701@end smallexample
3702
3703@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
3704@opindex Wctor-dtor-privacy
3705@opindex Wno-ctor-dtor-privacy
3706Warn when a class seems unusable because all the constructors or
3707destructors in that class are private, and it has neither friends nor
3708public static member functions. Also warn if there are no non-private
3709methods, and there's at least one private member function that isn't
3710a constructor or destructor.
3711
3712@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
3713@opindex Wdangling-reference
3714@opindex Wno-dangling-reference
3715Warn when a reference is bound to a temporary whose lifetime has ended.
3716For example:
3717
3718@smallexample
3719int n = 1;
3720const int& r = std::max(n - 1, n + 1); // r is dangling
3721@end smallexample
3722
3723In the example above, two temporaries are created, one for each
3724argument, and a reference to one of the temporaries is returned.
3725However, both temporaries are destroyed at the end of the full
3726expression, so the reference @code{r} is dangling. This warning
3727also detects dangling references in member initializer lists:
3728
3729@smallexample
3730const int& f(const int& i) @{ return i; @}
3731struct S @{
3732 const int &r; // r is dangling
3733 S() : r(f(10)) @{ @}
3734@};
3735@end smallexample
3736
3737Member functions are checked as well, but only their object argument:
3738
3739@smallexample
3740struct S @{
3741 const S& self () @{ return *this; @}
3742@};
3743const S& s = S().self(); // s is dangling
3744@end smallexample
3745
3746Certain functions are safe in this respect, for example @code{std::use_facet}:
3747they take and return a reference, but they don't return one of its arguments,
3748which can fool the warning. Such functions can be excluded from the warning
3749by wrapping them in a @code{#pragma}:
3750
3751@smallexample
3752#pragma GCC diagnostic push
3753#pragma GCC diagnostic ignored "-Wdangling-reference"
3754const T& foo (const T&) @{ @dots{} @}
3755#pragma GCC diagnostic pop
3756@end smallexample
3757
ce51e843
ML
3758@option{-Wdangling-reference} also warns about code like
3759
3760@smallexample
3761auto p = std::minmax(1, 2);
3762@end smallexample
3763
3764where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3765both references dangle after the end of the full expression that contains
3766the call to @code{std::minmax}.
3767
d77de738
ML
3768This warning is enabled by @option{-Wall}.
3769
3770@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
3771@opindex Wdelete-non-virtual-dtor
3772@opindex Wno-delete-non-virtual-dtor
3773Warn when @code{delete} is used to destroy an instance of a class that
3774has virtual functions and non-virtual destructor. It is unsafe to delete
3775an instance of a derived class through a pointer to a base class if the
3776base class does not have a virtual destructor. This warning is enabled
3777by @option{-Wall}.
3778
3779@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
3780@opindex Wdeprecated-copy
3781@opindex Wno-deprecated-copy
3782Warn that the implicit declaration of a copy constructor or copy
3783assignment operator is deprecated if the class has a user-provided
3784copy constructor or copy assignment operator, in C++11 and up. This
3785warning is enabled by @option{-Wextra}. With
3786@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3787user-provided destructor.
3788
3789@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
3790@opindex Wdeprecated-enum-enum-conversion
3791@opindex Wno-deprecated-enum-enum-conversion
3792Disable the warning about the case when the usual arithmetic conversions
3793are applied on operands where one is of enumeration type and the other is
3794of a different enumeration type. This conversion was deprecated in C++20.
3795For example:
3796
3797@smallexample
3798enum E1 @{ e @};
3799enum E2 @{ f @};
3800int k = f - e;
3801@end smallexample
3802
3803@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3804@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3805by @option{-Wenum-conversion}.
3806
3807@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
3808@opindex Wdeprecated-enum-float-conversion
3809@opindex Wno-deprecated-enum-float-conversion
3810Disable the warning about the case when the usual arithmetic conversions
3811are applied on operands where one is of enumeration type and the other is
3812of a floating-point type. This conversion was deprecated in C++20. For
3813example:
3814
3815@smallexample
3816enum E1 @{ e @};
3817enum E2 @{ f @};
3818bool b = e <= 3.7;
3819@end smallexample
3820
3821@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3822@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3823by @option{-Wenum-conversion}.
3824
3825@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
3826@opindex Winit-list-lifetime
3827@opindex Wno-init-list-lifetime
3828Do not warn about uses of @code{std::initializer_list} that are likely
3829to result in dangling pointers. Since the underlying array for an
3830@code{initializer_list} is handled like a normal C++ temporary object,
3831it is easy to inadvertently keep a pointer to the array past the end
3832of the array's lifetime. For example:
3833
3834@itemize @bullet
3835@item
3836If a function returns a temporary @code{initializer_list}, or a local
3837@code{initializer_list} variable, the array's lifetime ends at the end
3838of the return statement, so the value returned has a dangling pointer.
3839
3840@item
3841If a new-expression creates an @code{initializer_list}, the array only
3842lives until the end of the enclosing full-expression, so the
3843@code{initializer_list} in the heap has a dangling pointer.
3844
3845@item
3846When an @code{initializer_list} variable is assigned from a
3847brace-enclosed initializer list, the temporary array created for the
3848right side of the assignment only lives until the end of the
3849full-expression, so at the next statement the @code{initializer_list}
3850variable has a dangling pointer.
3851
3852@smallexample
3853// li's initial underlying array lives as long as li
3854std::initializer_list<int> li = @{ 1,2,3 @};
3855// assignment changes li to point to a temporary array
3856li = @{ 4, 5 @};
3857// now the temporary is gone and li has a dangling pointer
3858int i = li.begin()[0] // undefined behavior
3859@end smallexample
3860
3861@item
3862When a list constructor stores the @code{begin} pointer from the
3863@code{initializer_list} argument, this doesn't extend the lifetime of
3864the array, so if a class variable is constructed from a temporary
3865@code{initializer_list}, the pointer is left dangling by the end of
3866the variable declaration statement.
3867
3868@end itemize
3869
c85f8dbb
MP
3870@item -Winvalid-constexpr
3871@opindex Winvalid-constexpr
3872@opindex Wno-invalid-constexpr
3873
3874Warn when a function never produces a constant expression. In C++20
3875and earlier, for every @code{constexpr} function and function template,
3876there must be at least one set of function arguments in at least one
3877instantiation such that an invocation of the function or constructor
3878could be an evaluated subexpression of a core constant expression.
3879C++23 removed this restriction, so it's possible to have a function
3880or a function template marked @code{constexpr} for which no invocation
3881satisfies the requirements of a core constant expression.
3882
3883This warning is enabled as a pedantic warning by default in C++20 and
3884earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3885which case it will be an ordinary warning. For example:
3886
3887@smallexample
3888void f (int& i);
3889constexpr void
3890g (int& i)
3891@{
3892 f(i); // warns by default in C++20, in C++23 only with -Winvalid-constexpr
3893@}
3894@end smallexample
3895
d77de738
ML
3896@item -Winvalid-imported-macros
3897@opindex Winvalid-imported-macros
3898@opindex Wno-invalid-imported-macros
3899Verify all imported macro definitions are valid at the end of
3900compilation. This is not enabled by default, as it requires
3901additional processing to determine. It may be useful when preparing
3902sets of header-units to ensure consistent macros.
3903
3904@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
3905@opindex Wliteral-suffix
3906@opindex Wno-literal-suffix
3907Do not warn when a string or character literal is followed by a
3908ud-suffix which does not begin with an underscore. As a conforming
3909extension, GCC treats such suffixes as separate preprocessing tokens
3910in order to maintain backwards compatibility with code that uses
3911formatting macros from @code{<inttypes.h>}. For example:
3912
3913@smallexample
3914#define __STDC_FORMAT_MACROS
3915#include <inttypes.h>
3916#include <stdio.h>
3917
3918int main() @{
3919 int64_t i64 = 123;
3920 printf("My int64: %" PRId64"\n", i64);
3921@}
3922@end smallexample
3923
3924In this case, @code{PRId64} is treated as a separate preprocessing token.
3925
3926This option also controls warnings when a user-defined literal
3927operator is declared with a literal suffix identifier that doesn't
3928begin with an underscore. Literal suffix identifiers that don't begin
3929with an underscore are reserved for future standardization.
3930
3931These warnings are enabled by default.
3932
3933@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
3934@opindex Wnarrowing
3935@opindex Wno-narrowing
3936For C++11 and later standards, narrowing conversions are diagnosed by default,
3937as required by the standard. A narrowing conversion from a constant produces
3938an error, and a narrowing conversion from a non-constant produces a warning,
3939but @option{-Wno-narrowing} suppresses the diagnostic.
3940Note that this does not affect the meaning of well-formed code;
3941narrowing conversions are still considered ill-formed in SFINAE contexts.
3942
3943With @option{-Wnarrowing} in C++98, warn when a narrowing
3944conversion prohibited by C++11 occurs within
3945@samp{@{ @}}, e.g.
3946
3947@smallexample
3948int i = @{ 2.2 @}; // error: narrowing from double to int
3949@end smallexample
3950
3951This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3952
3953@item -Wnoexcept @r{(C++ and Objective-C++ only)}
3954@opindex Wnoexcept
3955@opindex Wno-noexcept
3956Warn when a noexcept-expression evaluates to false because of a call
3957to a function that does not have a non-throwing exception
3958specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3959the compiler to never throw an exception.
3960
3961@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
3962@opindex Wnoexcept-type
3963@opindex Wno-noexcept-type
3964Warn if the C++17 feature making @code{noexcept} part of a function
3965type changes the mangled name of a symbol relative to C++14. Enabled
3966by @option{-Wabi} and @option{-Wc++17-compat}.
3967
3968As an example:
3969
3970@smallexample
3971template <class T> void f(T t) @{ t(); @};
3972void g() noexcept;
3973void h() @{ f(g); @}
3974@end smallexample
3975
3976@noindent
3977In C++14, @code{f} calls @code{f<void(*)()>}, but in
3978C++17 it calls @code{f<void(*)()noexcept>}.
3979
3980@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
3981@opindex Wclass-memaccess
3982@opindex Wno-class-memaccess
3983Warn when the destination of a call to a raw memory function such as
3984@code{memset} or @code{memcpy} is an object of class type, and when writing
3985into such an object might bypass the class non-trivial or deleted constructor
3986or copy assignment, violate const-correctness or encapsulation, or corrupt
3987virtual table pointers. Modifying the representation of such objects may
3988violate invariants maintained by member functions of the class. For example,
3989the call to @code{memset} below is undefined because it modifies a non-trivial
3990class object and is, therefore, diagnosed. The safe way to either initialize
3991or clear the storage of objects of such types is by using the appropriate
3992constructor or assignment operator, if one is available.
3993@smallexample
3994std::string str = "abc";
3995memset (&str, 0, sizeof str);
3996@end smallexample
3997The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
3998Explicitly casting the pointer to the class object to @code{void *} or
3999to a type that can be safely accessed by the raw memory function suppresses
4000the warning.
4001
4002@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
4003@opindex Wnon-virtual-dtor
4004@opindex Wno-non-virtual-dtor
4005Warn when a class has virtual functions and an accessible non-virtual
4006destructor itself or in an accessible polymorphic base class, in which
4007case it is possible but unsafe to delete an instance of a derived
4008class through a pointer to the class itself or base class. This
4009warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4010The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4011should be preferred because it warns about the unsafe cases without false
4012positives.
d77de738
ML
4013
4014@item -Wregister @r{(C++ and Objective-C++ only)}
4015@opindex Wregister
4016@opindex Wno-register
4017Warn on uses of the @code{register} storage class specifier, except
4018when it is part of the GNU @ref{Explicit Register Variables} extension.
4019The use of the @code{register} keyword as storage class specifier has
4020been deprecated in C++11 and removed in C++17.
4021Enabled by default with @option{-std=c++17}.
4022
4023@item -Wreorder @r{(C++ and Objective-C++ only)}
4024@opindex Wreorder
4025@opindex Wno-reorder
4026@cindex reordering, warning
4027@cindex warning for reordering of member initializers
4028Warn when the order of member initializers given in the code does not
4029match the order in which they must be executed. For instance:
4030
4031@smallexample
4032struct A @{
4033 int i;
4034 int j;
4035 A(): j (0), i (1) @{ @}
4036@};
4037@end smallexample
4038
4039@noindent
4040The compiler rearranges the member initializers for @code{i}
4041and @code{j} to match the declaration order of the members, emitting
4042a warning to that effect. This warning is enabled by @option{-Wall}.
4043
4044@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
4045@opindex Wpessimizing-move
4046@opindex Wno-pessimizing-move
4047This warning warns when a call to @code{std::move} prevents copy
4048elision. A typical scenario when copy elision can occur is when returning in
4049a function with a class return type, when the expression being returned is the
4050name of a non-volatile automatic object, and is not a function parameter, and
4051has the same type as the function return type.
4052
4053@smallexample
4054struct T @{
4055@dots{}
4056@};
4057T fn()
4058@{
4059 T t;
4060 @dots{}
4061 return std::move (t);
4062@}
4063@end smallexample
4064
4065But in this example, the @code{std::move} call prevents copy elision.
4066
4067This warning is enabled by @option{-Wall}.
4068
4069@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
4070@opindex Wredundant-move
4071@opindex Wno-redundant-move
4072This warning warns about redundant calls to @code{std::move}; that is, when
4073a move operation would have been performed even without the @code{std::move}
4074call. This happens because the compiler is forced to treat the object as if
4075it were an rvalue in certain situations such as returning a local variable,
4076where copy elision isn't applicable. Consider:
4077
4078@smallexample
4079struct T @{
4080@dots{}
4081@};
4082T fn(T t)
4083@{
4084 @dots{}
4085 return std::move (t);
4086@}
4087@end smallexample
4088
4089Here, the @code{std::move} call is redundant. Because G++ implements Core
4090Issue 1579, another example is:
4091
4092@smallexample
4093struct T @{ // convertible to U
4094@dots{}
4095@};
4096struct U @{
4097@dots{}
4098@};
4099U fn()
4100@{
4101 T t;
4102 @dots{}
4103 return std::move (t);
4104@}
4105@end smallexample
4106In this example, copy elision isn't applicable because the type of the
4107expression being returned and the function return type differ, yet G++
4108treats the return value as if it were designated by an rvalue.
4109
4110This warning is enabled by @option{-Wextra}.
4111
4112@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
4113@opindex Wrange-loop-construct
4114@opindex Wno-range-loop-construct
4115This warning warns when a C++ range-based for-loop is creating an unnecessary
4116copy. This can happen when the range declaration is not a reference, but
4117probably should be. For example:
4118
4119@smallexample
4120struct S @{ char arr[128]; @};
4121void fn () @{
4122 S arr[5];
4123 for (const auto x : arr) @{ @dots{} @}
4124@}
4125@end smallexample
4126
4127It does not warn when the type being copied is a trivially-copyable type whose
4128size is less than 64 bytes.
4129
4130This warning also warns when a loop variable in a range-based for-loop is
4131initialized with a value of a different type resulting in a copy. For example:
4132
4133@smallexample
4134void fn() @{
4135 int arr[10];
4136 for (const double &x : arr) @{ @dots{} @}
4137@}
4138@end smallexample
4139
4140In the example above, in every iteration of the loop a temporary value of
4141type @code{double} is created and destroyed, to which the reference
4142@code{const double &} is bound.
4143
4144This warning is enabled by @option{-Wall}.
4145
4146@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
4147@opindex Wredundant-tags
4148@opindex Wno-redundant-tags
4149Warn about redundant class-key and enum-key in references to class types
4150and enumerated types in contexts where the key can be eliminated without
4151causing an ambiguity. For example:
4152
4153@smallexample
4154struct foo;
4155struct foo *p; // warn that keyword struct can be eliminated
4156@end smallexample
4157
4158@noindent
4159On the other hand, in this example there is no warning:
4160
4161@smallexample
4162struct foo;
4163void foo (); // "hides" struct foo
4164void bar (struct foo&); // no warning, keyword struct is necessary
4165@end smallexample
4166
4167@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
4168@opindex Wsubobject-linkage
4169@opindex Wno-subobject-linkage
4170Do not warn
4171if a class type has a base or a field whose type uses the anonymous
4172namespace or depends on a type with no linkage. If a type A depends on
4173a type B with no or internal linkage, defining it in multiple
4174translation units would be an ODR violation because the meaning of B
4175is different in each translation unit. If A only appears in a single
4176translation unit, the best way to silence the warning is to give it
4177internal linkage by putting it in an anonymous namespace as well. The
4178compiler doesn't give this warning for types defined in the main .C
4179file, as those are unlikely to have multiple definitions.
4180@option{-Wsubobject-linkage} is enabled by default.
4181
4182@item -Weffc++ @r{(C++ and Objective-C++ only)}
4183@opindex Weffc++
4184@opindex Wno-effc++
4185Warn about violations of the following style guidelines from Scott Meyers'
4186@cite{Effective C++} series of books:
4187
4188@itemize @bullet
4189@item
4190Define a copy constructor and an assignment operator for classes
4191with dynamically-allocated memory.
4192
4193@item
4194Prefer initialization to assignment in constructors.
4195
4196@item
4197Have @code{operator=} return a reference to @code{*this}.
4198
4199@item
4200Don't try to return a reference when you must return an object.
4201
4202@item
4203Distinguish between prefix and postfix forms of increment and
4204decrement operators.
4205
4206@item
4207Never overload @code{&&}, @code{||}, or @code{,}.
4208
4209@end itemize
4210
4211This option also enables @option{-Wnon-virtual-dtor}, which is also
4212one of the effective C++ recommendations. However, the check is
4213extended to warn about the lack of virtual destructor in accessible
4214non-polymorphic bases classes too.
4215
4216When selecting this option, be aware that the standard library
4217headers do not obey all of these guidelines; use @samp{grep -v}
4218to filter out those warnings.
4219
4220@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
4221@opindex Wexceptions
4222@opindex Wno-exceptions
4223Disable the warning about the case when an exception handler is shadowed by
4224another handler, which can point out a wrong ordering of exception handlers.
4225
4226@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
4227@opindex Wstrict-null-sentinel
4228@opindex Wno-strict-null-sentinel
4229Warn about the use of an uncasted @code{NULL} as sentinel. When
4230compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4231to @code{__null}. Although it is a null pointer constant rather than a
4232null pointer, it is guaranteed to be of the same size as a pointer.
4233But this use is not portable across different compilers.
4234
4235@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
4236@opindex Wno-non-template-friend
4237@opindex Wnon-template-friend
4238Disable warnings when non-template friend functions are declared
4239within a template. In very old versions of GCC that predate implementation
4240of the ISO standard, declarations such as
4241@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4242could be interpreted as a particular specialization of a template
4243function; the warning exists to diagnose compatibility problems,
4244and is enabled by default.
4245
4246@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
4247@opindex Wold-style-cast
4248@opindex Wno-old-style-cast
4249Warn if an old-style (C-style) cast to a non-void type is used within
4250a C++ program. The new-style casts (@code{dynamic_cast},
4251@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4252less vulnerable to unintended effects and much easier to search for.
4253
4254@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4255@itemx -Woverloaded-virtual=@var{n}
4256@opindex Woverloaded-virtual
4257@opindex Wno-overloaded-virtual
4258@cindex overloaded virtual function, warning
4259@cindex warning for overloaded virtual function
4260Warn when a function declaration hides virtual functions from a
4261base class. For example, in:
4262
4263@smallexample
4264struct A @{
4265 virtual void f();
4266@};
4267
4268struct B: public A @{
4269 void f(int); // does not override
4270@};
4271@end smallexample
4272
4273the @code{A} class version of @code{f} is hidden in @code{B}, and code
4274like:
4275
4276@smallexample
4277B* b;
4278b->f();
4279@end smallexample
4280
4281@noindent
4282fails to compile.
4283
4284The optional level suffix controls the behavior when all the
4285declarations in the derived class override virtual functions in the
4286base class, even if not all of the base functions are overridden:
4287
4288@smallexample
4289struct C @{
4290 virtual void f();
4291 virtual void f(int);
4292@};
4293
4294struct D: public C @{
4295 void f(int); // does override
4296@}
4297@end smallexample
4298
4299This pattern is less likely to be a mistake; if D is only used
4300virtually, the user might have decided that the base class semantics
4301for some of the overloads are fine.
4302
4303At level 1, this case does not warn; at level 2, it does.
4304@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4305included in @option{-Wall}.
4306
4307@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
4308@opindex Wno-pmf-conversions
4309@opindex Wpmf-conversions
4310Disable the diagnostic for converting a bound pointer to member function
4311to a plain pointer.
4312
4313@item -Wsign-promo @r{(C++ and Objective-C++ only)}
4314@opindex Wsign-promo
4315@opindex Wno-sign-promo
4316Warn when overload resolution chooses a promotion from unsigned or
4317enumerated type to a signed type, over a conversion to an unsigned type of
4318the same size. Previous versions of G++ tried to preserve
4319unsignedness, but the standard mandates the current behavior.
4320
4321@item -Wtemplates @r{(C++ and Objective-C++ only)}
4322@opindex Wtemplates
4323@opindex Wno-templates
4324Warn when a primary template declaration is encountered. Some coding
4325rules disallow templates, and this may be used to enforce that rule.
4326The warning is inactive inside a system header file, such as the STL, so
4327one can still use the STL. One may also instantiate or specialize
4328templates.
4329
4330@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
4331@opindex Wmismatched-new-delete
4332@opindex Wno-mismatched-new-delete
4333Warn for mismatches between calls to @code{operator new} or @code{operator
4334delete} and the corresponding call to the allocation or deallocation function.
4335This includes invocations of C++ @code{operator delete} with pointers
4336returned from either mismatched forms of @code{operator new}, or from other
4337functions that allocate objects for which the @code{operator delete} isn't
4338a suitable deallocator, as well as calls to other deallocation functions
4339with pointers returned from @code{operator new} for which the deallocation
4340function isn't suitable.
4341
4342For example, the @code{delete} expression in the function below is diagnosed
4343because it doesn't match the array form of the @code{new} expression
4344the pointer argument was returned from. Similarly, the call to @code{free}
4345is also diagnosed.
4346
4347@smallexample
4348void f ()
4349@{
4350 int *a = new int[n];
4351 delete a; // warning: mismatch in array forms of expressions
4352
4353 char *p = new char[n];
4354 free (p); // warning: mismatch between new and free
4355@}
4356@end smallexample
4357
4358The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4359involving allocation and deallocation functions other than @code{operator
4360new} and @code{operator delete}.
4361
4362@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4363
4364@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
4365@opindex Wmismatched-tags
4366@opindex Wno-mismatched-tags
4367Warn for declarations of structs, classes, and class templates and their
4368specializations with a class-key that does not match either the definition
4369or the first declaration if no definition is provided.
4370
4371For example, the declaration of @code{struct Object} in the argument list
4372of @code{draw} triggers the warning. To avoid it, either remove the redundant
4373class-key @code{struct} or replace it with @code{class} to match its definition.
4374@smallexample
4375class Object @{
4376public:
4377 virtual ~Object () = 0;
4378@};
4379void draw (struct Object*);
4380@end smallexample
4381
4382It is not wrong to declare a class with the class-key @code{struct} as
4383the example above shows. The @option{-Wmismatched-tags} option is intended
4384to help achieve a consistent style of class declarations. In code that is
4385intended to be portable to Windows-based compilers the warning helps prevent
4386unresolved references due to the difference in the mangling of symbols
4387declared with different class-keys. The option can be used either on its
4388own or in conjunction with @option{-Wredundant-tags}.
4389
4390@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
4391@opindex Wmultiple-inheritance
4392@opindex Wno-multiple-inheritance
4393Warn when a class is defined with multiple direct base classes. Some
4394coding rules disallow multiple inheritance, and this may be used to
4395enforce that rule. The warning is inactive inside a system header file,
4396such as the STL, so one can still use the STL. One may also define
4397classes that indirectly use multiple inheritance.
4398
4399@item -Wvirtual-inheritance
4400@opindex Wvirtual-inheritance
4401@opindex Wno-virtual-inheritance
4402Warn when a class is defined with a virtual direct base class. Some
4403coding rules disallow multiple inheritance, and this may be used to
4404enforce that rule. The warning is inactive inside a system header file,
4405such as the STL, so one can still use the STL. One may also define
4406classes that indirectly use virtual inheritance.
4407
4408@item -Wno-virtual-move-assign
4409@opindex Wvirtual-move-assign
4410@opindex Wno-virtual-move-assign
4411Suppress warnings about inheriting from a virtual base with a
4412non-trivial C++11 move assignment operator. This is dangerous because
4413if the virtual base is reachable along more than one path, it is
4414moved multiple times, which can mean both objects end up in the
4415moved-from state. If the move assignment operator is written to avoid
4416moving from a moved-from object, this warning can be disabled.
4417
4418@item -Wnamespaces
4419@opindex Wnamespaces
4420@opindex Wno-namespaces
4421Warn when a namespace definition is opened. Some coding rules disallow
4422namespaces, and this may be used to enforce that rule. The warning is
4423inactive inside a system header file, such as the STL, so one can still
4424use the STL. One may also use using directives and qualified names.
4425
4426@item -Wno-terminate @r{(C++ and Objective-C++ only)}
4427@opindex Wterminate
4428@opindex Wno-terminate
4429Disable the warning about a throw-expression that will immediately
4430result in a call to @code{terminate}.
4431
4432@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
4433@opindex Wvexing-parse
4434@opindex Wno-vexing-parse
4435Warn about the most vexing parse syntactic ambiguity. This warns about
4436the cases when a declaration looks like a variable definition, but the
4437C++ language requires it to be interpreted as a function declaration.
4438For instance:
4439
4440@smallexample
4441void f(double a) @{
4442 int i(); // extern int i (void);
4443 int n(int(a)); // extern int n (int);
4444@}
4445@end smallexample
4446
4447Another example:
4448
4449@smallexample
4450struct S @{ S(int); @};
4451void f(double a) @{
4452 S x(int(a)); // extern struct S x (int);
4453 S y(int()); // extern struct S y (int (*) (void));
4454 S z(); // extern struct S z (void);
4455@}
4456@end smallexample
4457
4458The warning will suggest options how to deal with such an ambiguity; e.g.,
4459it can suggest removing the parentheses or using braces instead.
4460
4461This warning is enabled by default.
4462
4463@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
4464@opindex Wno-class-conversion
4465@opindex Wclass-conversion
4466Do not warn when a conversion function converts an
4467object to the same type, to a base class of that type, or to void; such
4468a conversion function will never be called.
4469
4470@item -Wvolatile @r{(C++ and Objective-C++ only)}
4471@opindex Wvolatile
4472@opindex Wno-volatile
4473Warn about deprecated uses of the @code{volatile} qualifier. This includes
4474postfix and prefix @code{++} and @code{--} expressions of
4475@code{volatile}-qualified types, using simple assignments where the left
4476operand is a @code{volatile}-qualified non-class type for their value,
4477compound assignments where the left operand is a @code{volatile}-qualified
4478non-class type, @code{volatile}-qualified function return type,
4479@code{volatile}-qualified parameter type, and structured bindings of a
4480@code{volatile}-qualified type. This usage was deprecated in C++20.
4481
4482Enabled by default with @option{-std=c++20}.
4483
4484@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
4485@opindex Wzero-as-null-pointer-constant
4486@opindex Wno-zero-as-null-pointer-constant
4487Warn when a literal @samp{0} is used as null pointer constant. This can
4488be useful to facilitate the conversion to @code{nullptr} in C++11.
4489
4490@item -Waligned-new
4491@opindex Waligned-new
4492@opindex Wno-aligned-new
4493Warn about a new-expression of a type that requires greater alignment
4494than the @code{alignof(std::max_align_t)} but uses an allocation
4495function without an explicit alignment parameter. This option is
4496enabled by @option{-Wall}.
4497
4498Normally this only warns about global allocation functions, but
4499@option{-Waligned-new=all} also warns about class member allocation
4500functions.
4501
4502@item -Wno-placement-new
4503@itemx -Wplacement-new=@var{n}
4504@opindex Wplacement-new
4505@opindex Wno-placement-new
4506Warn about placement new expressions with undefined behavior, such as
4507constructing an object in a buffer that is smaller than the type of
4508the object. For example, the placement new expression below is diagnosed
4509because it attempts to construct an array of 64 integers in a buffer only
451064 bytes large.
4511@smallexample
4512char buf [64];
4513new (buf) int[64];
4514@end smallexample
4515This warning is enabled by default.
4516
4517@table @gcctabopt
4518@item -Wplacement-new=1
4519This is the default warning level of @option{-Wplacement-new}. At this
4520level the warning is not issued for some strictly undefined constructs that
4521GCC allows as extensions for compatibility with legacy code. For example,
4522the following @code{new} expression is not diagnosed at this level even
4523though it has undefined behavior according to the C++ standard because
4524it writes past the end of the one-element array.
4525@smallexample
4526struct S @{ int n, a[1]; @};
4527S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4528new (s->a)int [32]();
4529@end smallexample
4530
4531@item -Wplacement-new=2
4532At this level, in addition to diagnosing all the same constructs as at level
45331, a diagnostic is also issued for placement new expressions that construct
4534an object in the last member of structure whose type is an array of a single
4535element and whose size is less than the size of the object being constructed.
4536While the previous example would be diagnosed, the following construct makes
4537use of the flexible member array extension to avoid the warning at level 2.
4538@smallexample
4539struct S @{ int n, a[]; @};
4540S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4541new (s->a)int [32]();
4542@end smallexample
4543
4544@end table
4545
4546@item -Wcatch-value
4547@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
4548@opindex Wcatch-value
4549@opindex Wno-catch-value
4550Warn about catch handlers that do not catch via reference.
4551With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4552warn about polymorphic class types that are caught by value.
4553With @option{-Wcatch-value=2} warn about all class types that are caught
4554by value. With @option{-Wcatch-value=3} warn about all types that are
4555not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4556
4557@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
4558@opindex Wconditionally-supported
4559@opindex Wno-conditionally-supported
4560Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4561
4562@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
4563@opindex Wdelete-incomplete
4564@opindex Wno-delete-incomplete
4565Do not warn when deleting a pointer to incomplete type, which may cause
4566undefined behavior at runtime. This warning is enabled by default.
4567
4568@item -Wextra-semi @r{(C++, Objective-C++ only)}
4569@opindex Wextra-semi
4570@opindex Wno-extra-semi
4571Warn about redundant semicolons after in-class function definitions.
4572
4573@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
4574@opindex Winaccessible-base
4575@opindex Wno-inaccessible-base
4576This option controls warnings
4577when a base class is inaccessible in a class derived from it due to
4578ambiguity. The warning is enabled by default.
4579Note that the warning for ambiguous virtual
4580bases is enabled by the @option{-Wextra} option.
4581@smallexample
4582@group
4583struct A @{ int a; @};
4584
4585struct B : A @{ @};
4586
4587struct C : B, A @{ @};
4588@end group
4589@end smallexample
4590
4591@item -Wno-inherited-variadic-ctor
4592@opindex Winherited-variadic-ctor
4593@opindex Wno-inherited-variadic-ctor
4594Suppress warnings about use of C++11 inheriting constructors when the
4595base class inherited from has a C variadic constructor; the warning is
4596on by default because the ellipsis is not inherited.
4597
4598@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
4599@opindex Wno-invalid-offsetof
4600@opindex Winvalid-offsetof
4601Suppress warnings from applying the @code{offsetof} macro to a non-POD
4602type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4603to a non-standard-layout type is undefined. In existing C++ implementations,
4604however, @code{offsetof} typically gives meaningful results.
4605This flag is for users who are aware that they are
4606writing nonportable code and who have deliberately chosen to ignore the
4607warning about it.
4608
4609The restrictions on @code{offsetof} may be relaxed in a future version
4610of the C++ standard.
4611
4612@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
4613@opindex Wsized-deallocation
4614@opindex Wno-sized-deallocation
4615Warn about a definition of an unsized deallocation function
4616@smallexample
4617void operator delete (void *) noexcept;
4618void operator delete[] (void *) noexcept;
4619@end smallexample
4620without a definition of the corresponding sized deallocation function
4621@smallexample
4622void operator delete (void *, std::size_t) noexcept;
4623void operator delete[] (void *, std::size_t) noexcept;
4624@end smallexample
4625or vice versa. Enabled by @option{-Wextra} along with
4626@option{-fsized-deallocation}.
4627
4628@item -Wsuggest-final-types
4629@opindex Wno-suggest-final-types
4630@opindex Wsuggest-final-types
4631Warn about types with virtual methods where code quality would be improved
4632if the type were declared with the C++11 @code{final} specifier,
4633or, if possible,
4634declared in an anonymous namespace. This allows GCC to more aggressively
4635devirtualize the polymorphic calls. This warning is more effective with
4636link-time optimization,
4637where the information about the class hierarchy graph is
4638more complete.
4639
4640@item -Wsuggest-final-methods
4641@opindex Wno-suggest-final-methods
4642@opindex Wsuggest-final-methods
4643Warn about virtual methods where code quality would be improved if the method
4644were declared with the C++11 @code{final} specifier,
4645or, if possible, its type were
4646declared in an anonymous namespace or with the @code{final} specifier.
4647This warning is
4648more effective with link-time optimization, where the information about the
4649class hierarchy graph is more complete. It is recommended to first consider
4650suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4651annotations.
4652
4653@item -Wsuggest-override
4654@opindex Wsuggest-override
4655@opindex Wno-suggest-override
4656Warn about overriding virtual functions that are not marked with the
4657@code{override} keyword.
4658
4659@item -Wuse-after-free
4660@itemx -Wuse-after-free=@var{n}
4661@opindex Wuse-after-free
4662@opindex Wno-use-after-free
4663Warn about uses of pointers to dynamically allocated objects that have
4664been rendered indeterminate by a call to a deallocation function.
4665The warning is enabled at all optimization levels but may yield different
4666results with optimization than without.
4667
4668@table @gcctabopt
4669@item -Wuse-after-free=1
4670At level 1 the warning attempts to diagnose only unconditional uses
4671of pointers made indeterminate by a deallocation call or a successful
4672call to @code{realloc}, regardless of whether or not the call resulted
4673in an actual reallocatio of memory. This includes double-@code{free}
4674calls as well as uses in arithmetic and relational expressions. Although
4675undefined, uses of indeterminate pointers in equality (or inequality)
4676expressions are not diagnosed at this level.
4677@item -Wuse-after-free=2
4678At level 2, in addition to unconditional uses, the warning also diagnoses
4679conditional uses of pointers made indeterminate by a deallocation call.
4680As at level 2, uses in equality (or inequality) expressions are not
4681diagnosed. For example, the second call to @code{free} in the following
4682function is diagnosed at this level:
4683@smallexample
4684struct A @{ int refcount; void *data; @};
4685
4686void release (struct A *p)
4687@{
4688 int refcount = --p->refcount;
4689 free (p);
4690 if (refcount == 0)
4691 free (p->data); // warning: p may be used after free
4692@}
4693@end smallexample
4694@item -Wuse-after-free=3
4695At level 3, the warning also diagnoses uses of indeterminate pointers in
4696equality expressions. All uses of indeterminate pointers are undefined
4697but equality tests sometimes appear after calls to @code{realloc} as
4698an attempt to determine whether the call resulted in relocating the object
4699to a different address. They are diagnosed at a separate level to aid
4700legacy code gradually transition to safe alternatives. For example,
4701the equality test in the function below is diagnosed at this level:
4702@smallexample
4703void adjust_pointers (int**, int);
4704
4705void grow (int **p, int n)
4706@{
4707 int **q = (int**)realloc (p, n *= 2);
4708 if (q == p)
4709 return;
4710 adjust_pointers ((int**)q, n);
4711@}
4712@end smallexample
4713To avoid the warning at this level, store offsets into allocated memory
4714instead of pointers. This approach obviates needing to adjust the stored
4715pointers after reallocation.
4716@end table
4717
4718@option{-Wuse-after-free=2} is included in @option{-Wall}.
4719
4720@item -Wuseless-cast @r{(C++ and Objective-C++ only)}
4721@opindex Wuseless-cast
4722@opindex Wno-useless-cast
4723Warn when an expression is cast to its own type. This warning does not
4724occur when a class object is converted to a non-reference type as that
4725is a way to create a temporary:
4726
4727@smallexample
4728struct S @{ @};
4729void g (S&&);
4730void f (S&& arg)
4731@{
4732 g (S(arg)); // make arg prvalue so that it can bind to S&&
4733@}
4734@end smallexample
4735
4736@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
4737@opindex Wconversion-null
4738@opindex Wno-conversion-null
4739Do not warn for conversions between @code{NULL} and non-pointer
4740types. @option{-Wconversion-null} is enabled by default.
4741
4742@end table
4743
4744@node Objective-C and Objective-C++ Dialect Options
4745@section Options Controlling Objective-C and Objective-C++ Dialects
4746
4747@cindex compiler options, Objective-C and Objective-C++
4748@cindex Objective-C and Objective-C++ options, command-line
4749@cindex options, Objective-C and Objective-C++
4750(NOTE: This manual does not describe the Objective-C and Objective-C++
4751languages themselves. @xref{Standards,,Language Standards
4752Supported by GCC}, for references.)
4753
4754This section describes the command-line options that are only meaningful
4755for Objective-C and Objective-C++ programs. You can also use most of
4756the language-independent GNU compiler options.
4757For example, you might compile a file @file{some_class.m} like this:
4758
4759@smallexample
4760gcc -g -fgnu-runtime -O -c some_class.m
4761@end smallexample
4762
4763@noindent
4764In this example, @option{-fgnu-runtime} is an option meant only for
4765Objective-C and Objective-C++ programs; you can use the other options with
4766any language supported by GCC@.
4767
4768Note that since Objective-C is an extension of the C language, Objective-C
4769compilations may also use options specific to the C front-end (e.g.,
4770@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4771C++-specific options (e.g., @option{-Wabi}).
4772
4773Here is a list of options that are @emph{only} for compiling Objective-C
4774and Objective-C++ programs:
4775
4776@table @gcctabopt
4777@item -fconstant-string-class=@var{class-name}
4778@opindex fconstant-string-class
4779Use @var{class-name} as the name of the class to instantiate for each
4780literal string specified with the syntax @code{@@"@dots{}"}. The default
4781class name is @code{NXConstantString} if the GNU runtime is being used, and
4782@code{NSConstantString} if the NeXT runtime is being used (see below). The
4783@option{-fconstant-cfstrings} option, if also present, overrides the
4784@option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4785to be laid out as constant CoreFoundation strings.
4786
4787@item -fgnu-runtime
4788@opindex fgnu-runtime
4789Generate object code compatible with the standard GNU Objective-C
4790runtime. This is the default for most types of systems.
4791
4792@item -fnext-runtime
4793@opindex fnext-runtime
4794Generate output compatible with the NeXT runtime. This is the default
4795for NeXT-based systems, including Darwin and Mac OS X@. The macro
4796@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4797used.
4798
4799@item -fno-nil-receivers
4800@opindex fno-nil-receivers
4801@opindex fnil-receivers
4802Assume that all Objective-C message dispatches (@code{[receiver
4803message:arg]}) in this translation unit ensure that the receiver is
4804not @code{nil}. This allows for more efficient entry points in the
4805runtime to be used. This option is only available in conjunction with
4806the NeXT runtime and ABI version 0 or 1.
4807
4808@item -fobjc-abi-version=@var{n}
4809@opindex fobjc-abi-version
4810Use version @var{n} of the Objective-C ABI for the selected runtime.
4811This option is currently supported only for the NeXT runtime. In that
4812case, Version 0 is the traditional (32-bit) ABI without support for
4813properties and other Objective-C 2.0 additions. Version 1 is the
4814traditional (32-bit) ABI with support for properties and other
4815Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4816nothing is specified, the default is Version 0 on 32-bit target
4817machines, and Version 2 on 64-bit target machines.
4818
4819@item -fobjc-call-cxx-cdtors
4820@opindex fobjc-call-cxx-cdtors
4821For each Objective-C class, check if any of its instance variables is a
4822C++ object with a non-trivial default constructor. If so, synthesize a
4823special @code{- (id) .cxx_construct} instance method which runs
4824non-trivial default constructors on any such instance variables, in order,
4825and then return @code{self}. Similarly, check if any instance variable
4826is a C++ object with a non-trivial destructor, and if so, synthesize a
4827special @code{- (void) .cxx_destruct} method which runs
4828all such default destructors, in reverse order.
4829
4830The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4831methods thusly generated only operate on instance variables
4832declared in the current Objective-C class, and not those inherited
4833from superclasses. It is the responsibility of the Objective-C
4834runtime to invoke all such methods in an object's inheritance
4835hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4836by the runtime immediately after a new object instance is allocated;
4837the @code{- (void) .cxx_destruct} methods are invoked immediately
4838before the runtime deallocates an object instance.
4839
4840As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4841support for invoking the @code{- (id) .cxx_construct} and
4842@code{- (void) .cxx_destruct} methods.
4843
4844@item -fobjc-direct-dispatch
4845@opindex fobjc-direct-dispatch
4846Allow fast jumps to the message dispatcher. On Darwin this is
4847accomplished via the comm page.
4848
4849@item -fobjc-exceptions
4850@opindex fobjc-exceptions
4851Enable syntactic support for structured exception handling in
4852Objective-C, similar to what is offered by C++. This option
4853is required to use the Objective-C keywords @code{@@try},
4854@code{@@throw}, @code{@@catch}, @code{@@finally} and
4855@code{@@synchronized}. This option is available with both the GNU
4856runtime and the NeXT runtime (but not available in conjunction with
4857the NeXT runtime on Mac OS X 10.2 and earlier).
4858
4859@item -fobjc-gc
4860@opindex fobjc-gc
4861Enable garbage collection (GC) in Objective-C and Objective-C++
4862programs. This option is only available with the NeXT runtime; the
4863GNU runtime has a different garbage collection implementation that
4864does not require special compiler flags.
4865
4866@item -fobjc-nilcheck
4867@opindex fobjc-nilcheck
4868For the NeXT runtime with version 2 of the ABI, check for a nil
4869receiver in method invocations before doing the actual method call.
4870This is the default and can be disabled using
4871@option{-fno-objc-nilcheck}. Class methods and super calls are never
4872checked for nil in this way no matter what this flag is set to.
4873Currently this flag does nothing when the GNU runtime, or an older
4874version of the NeXT runtime ABI, is used.
4875
4876@item -fobjc-std=objc1
4877@opindex fobjc-std
4878Conform to the language syntax of Objective-C 1.0, the language
4879recognized by GCC 4.0. This only affects the Objective-C additions to
4880the C/C++ language; it does not affect conformance to C/C++ standards,
4881which is controlled by the separate C/C++ dialect option flags. When
4882this option is used with the Objective-C or Objective-C++ compiler,
4883any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4884This is useful if you need to make sure that your Objective-C code can
4885be compiled with older versions of GCC@.
4886
4887@item -freplace-objc-classes
4888@opindex freplace-objc-classes
4889Emit a special marker instructing @command{ld(1)} not to statically link in
4890the resulting object file, and allow @command{dyld(1)} to load it in at
4891run time instead. This is used in conjunction with the Fix-and-Continue
4892debugging mode, where the object file in question may be recompiled and
4893dynamically reloaded in the course of program execution, without the need
4894to restart the program itself. Currently, Fix-and-Continue functionality
4895is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4896and later.
4897
4898@item -fzero-link
4899@opindex fzero-link
4900When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4901to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4902compile time) with static class references that get initialized at load time,
4903which improves run-time performance. Specifying the @option{-fzero-link} flag
4904suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4905to be retained. This is useful in Zero-Link debugging mode, since it allows
4906for individual class implementations to be modified during program execution.
4907The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4908regardless of command-line options.
4909
4910@item -fno-local-ivars
4911@opindex fno-local-ivars
4912@opindex flocal-ivars
4913By default instance variables in Objective-C can be accessed as if
4914they were local variables from within the methods of the class they're
4915declared in. This can lead to shadowing between instance variables
4916and other variables declared either locally inside a class method or
4917globally with the same name. Specifying the @option{-fno-local-ivars}
4918flag disables this behavior thus avoiding variable shadowing issues.
4919
4920@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
4921@opindex fivar-visibility
4922Set the default instance variable visibility to the specified option
4923so that instance variables declared outside the scope of any access
4924modifier directives default to the specified visibility.
4925
4926@item -gen-decls
4927@opindex gen-decls
4928Dump interface declarations for all classes seen in the source file to a
4929file named @file{@var{sourcename}.decl}.
4930
4931@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
4932@opindex Wassign-intercept
4933@opindex Wno-assign-intercept
4934Warn whenever an Objective-C assignment is being intercepted by the
4935garbage collector.
4936
4937@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
4938@opindex Wproperty-assign-default
4939@opindex Wno-property-assign-default
4940Do not warn if a property for an Objective-C object has no assign
4941semantics specified.
4942
4943@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
4944@opindex Wno-protocol
4945@opindex Wprotocol
4946If a class is declared to implement a protocol, a warning is issued for
4947every method in the protocol that is not implemented by the class. The
4948default behavior is to issue a warning for every method not explicitly
4949implemented in the class, even if a method implementation is inherited
4950from the superclass. If you use the @option{-Wno-protocol} option, then
4951methods inherited from the superclass are considered to be implemented,
4952and no warning is issued for them.
4953
4954@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
4955@opindex Wobjc-root-class
4956Warn if a class interface lacks a superclass. Most classes will inherit
4957from @code{NSObject} (or @code{Object}) for example. When declaring
4958classes intended to be root classes, the warning can be suppressed by
4959marking their interfaces with @code{__attribute__((objc_root_class))}.
4960
4961@item -Wselector @r{(Objective-C and Objective-C++ only)}
4962@opindex Wselector
4963@opindex Wno-selector
4964Warn if multiple methods of different types for the same selector are
4965found during compilation. The check is performed on the list of methods
4966in the final stage of compilation. Additionally, a check is performed
4967for each selector appearing in a @code{@@selector(@dots{})}
4968expression, and a corresponding method for that selector has been found
4969during compilation. Because these checks scan the method table only at
4970the end of compilation, these warnings are not produced if the final
4971stage of compilation is not reached, for example because an error is
4972found during compilation, or because the @option{-fsyntax-only} option is
4973being used.
4974
4975@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
4976@opindex Wstrict-selector-match
4977@opindex Wno-strict-selector-match
4978Warn if multiple methods with differing argument and/or return types are
4979found for a given selector when attempting to send a message using this
4980selector to a receiver of type @code{id} or @code{Class}. When this flag
4981is off (which is the default behavior), the compiler omits such warnings
4982if any differences found are confined to types that share the same size
4983and alignment.
4984
4985@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
4986@opindex Wundeclared-selector
4987@opindex Wno-undeclared-selector
4988Warn if a @code{@@selector(@dots{})} expression referring to an
4989undeclared selector is found. A selector is considered undeclared if no
4990method with that name has been declared before the
4991@code{@@selector(@dots{})} expression, either explicitly in an
4992@code{@@interface} or @code{@@protocol} declaration, or implicitly in
4993an @code{@@implementation} section. This option always performs its
4994checks as soon as a @code{@@selector(@dots{})} expression is found,
4995while @option{-Wselector} only performs its checks in the final stage of
4996compilation. This also enforces the coding style convention
4997that methods and selectors must be declared before being used.
4998
4999@item -print-objc-runtime-info
5000@opindex print-objc-runtime-info
5001Generate C header describing the largest structure that is passed by
5002value, if any.
5003
5004@end table
5005
5006@node Diagnostic Message Formatting Options
5007@section Options to Control Diagnostic Messages Formatting
5008@cindex options to control diagnostics formatting
5009@cindex diagnostic messages
5010@cindex message formatting
5011
5012Traditionally, diagnostic messages have been formatted irrespective of
5013the output device's aspect (e.g.@: its width, @dots{}). You can use the
5014options described below
5015to control the formatting algorithm for diagnostic messages,
5016e.g.@: how many characters per line, how often source location
5017information should be reported. Note that some language front ends may not
5018honor these options.
5019
5020@table @gcctabopt
5021@item -fmessage-length=@var{n}
5022@opindex fmessage-length
5023Try to format error messages so that they fit on lines of about
5024@var{n} characters. If @var{n} is zero, then no line-wrapping is
5025done; each error message appears on a single line. This is the
5026default for all front ends.
5027
5028Note - this option also affects the display of the @samp{#error} and
5029@samp{#warning} pre-processor directives, and the @samp{deprecated}
5030function/type/variable attribute. It does not however affect the
5031@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5032
5033@item -fdiagnostics-plain-output
5034This option requests that diagnostic output look as plain as possible, which
5035may be useful when running @command{dejagnu} or other utilities that need to
5036parse diagnostics output and prefer that it remain more stable over time.
5037@option{-fdiagnostics-plain-output} is currently equivalent to the following
5038options:
5039@gccoptlist{-fno-diagnostics-show-caret @gol
5040-fno-diagnostics-show-line-numbers @gol
5041-fdiagnostics-color=never @gol
5042-fdiagnostics-urls=never @gol
5043-fdiagnostics-path-format=separate-events}
5044In the future, if GCC changes the default appearance of its diagnostics, the
5045corresponding option to disable the new behavior will be added to this list.
5046
5047@item -fdiagnostics-show-location=once
5048@opindex fdiagnostics-show-location
5049Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5050reporter to emit source location information @emph{once}; that is, in
5051case the message is too long to fit on a single physical line and has to
5052be wrapped, the source location won't be emitted (as prefix) again,
5053over and over, in subsequent continuation lines. This is the default
5054behavior.
5055
5056@item -fdiagnostics-show-location=every-line
5057Only meaningful in line-wrapping mode. Instructs the diagnostic
5058messages reporter to emit the same source location information (as
5059prefix) for physical lines that result from the process of breaking
5060a message which is too long to fit on a single line.
5061
5062@item -fdiagnostics-color[=@var{WHEN}]
5063@itemx -fno-diagnostics-color
5064@opindex fdiagnostics-color
5065@cindex highlight, color
5066@vindex GCC_COLORS @r{environment variable}
5067Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5068or @samp{auto}. The default depends on how the compiler has been configured,
5069it can be any of the above @var{WHEN} options or also @samp{never}
5070if @env{GCC_COLORS} environment variable isn't present in the environment,
5071and @samp{auto} otherwise.
5072@samp{auto} makes GCC use color only when the standard error is a terminal,
5073and when not executing in an emacs shell.
5074The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5075aliases for @option{-fdiagnostics-color=always} and
5076@option{-fdiagnostics-color=never}, respectively.
5077
5078The colors are defined by the environment variable @env{GCC_COLORS}.
5079Its value is a colon-separated list of capabilities and Select Graphic
5080Rendition (SGR) substrings. SGR commands are interpreted by the
5081terminal or terminal emulator. (See the section in the documentation
5082of your text terminal for permitted values and their meanings as
5083character attributes.) These substring values are integers in decimal
5084representation and can be concatenated with semicolons.
5085Common values to concatenate include
5086@samp{1} for bold,
5087@samp{4} for underline,
5088@samp{5} for blink,
5089@samp{7} for inverse,
5090@samp{39} for default foreground color,
5091@samp{30} to @samp{37} for foreground colors,
5092@samp{90} to @samp{97} for 16-color mode foreground colors,
5093@samp{38;5;0} to @samp{38;5;255}
5094for 88-color and 256-color modes foreground colors,
5095@samp{49} for default background color,
5096@samp{40} to @samp{47} for background colors,
5097@samp{100} to @samp{107} for 16-color mode background colors,
5098and @samp{48;5;0} to @samp{48;5;255}
5099for 88-color and 256-color modes background colors.
5100
5101The default @env{GCC_COLORS} is
5102@smallexample
5103error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5104quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5105diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5106type-diff=01;32:fnname=01;32:targs=35
5107@end smallexample
5108@noindent
5109where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5110@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5111@samp{01} is bold, and @samp{31} is red.
5112Setting @env{GCC_COLORS} to the empty string disables colors.
5113Supported capabilities are as follows.
5114
5115@table @code
5116@item error=
5117@vindex error GCC_COLORS @r{capability}
5118SGR substring for error: markers.
5119
5120@item warning=
5121@vindex warning GCC_COLORS @r{capability}
5122SGR substring for warning: markers.
5123
5124@item note=
5125@vindex note GCC_COLORS @r{capability}
5126SGR substring for note: markers.
5127
5128@item path=
5129@vindex path GCC_COLORS @r{capability}
5130SGR substring for colorizing paths of control-flow events as printed
5131via @option{-fdiagnostics-path-format=}, such as the identifiers of
5132individual events and lines indicating interprocedural calls and returns.
5133
5134@item range1=
5135@vindex range1 GCC_COLORS @r{capability}
5136SGR substring for first additional range.
5137
5138@item range2=
5139@vindex range2 GCC_COLORS @r{capability}
5140SGR substring for second additional range.
5141
5142@item locus=
5143@vindex locus GCC_COLORS @r{capability}
5144SGR substring for location information, @samp{file:line} or
5145@samp{file:line:column} etc.
5146
5147@item quote=
5148@vindex quote GCC_COLORS @r{capability}
5149SGR substring for information printed within quotes.
5150
5151@item fnname=
5152@vindex fnname GCC_COLORS @r{capability}
5153SGR substring for names of C++ functions.
5154
5155@item targs=
5156@vindex targs GCC_COLORS @r{capability}
5157SGR substring for C++ function template parameter bindings.
5158
5159@item fixit-insert=
5160@vindex fixit-insert GCC_COLORS @r{capability}
5161SGR substring for fix-it hints suggesting text to
5162be inserted or replaced.
5163
5164@item fixit-delete=
5165@vindex fixit-delete GCC_COLORS @r{capability}
5166SGR substring for fix-it hints suggesting text to
5167be deleted.
5168
5169@item diff-filename=
5170@vindex diff-filename GCC_COLORS @r{capability}
5171SGR substring for filename headers within generated patches.
5172
5173@item diff-hunk=
5174@vindex diff-hunk GCC_COLORS @r{capability}
5175SGR substring for the starts of hunks within generated patches.
5176
5177@item diff-delete=
5178@vindex diff-delete GCC_COLORS @r{capability}
5179SGR substring for deleted lines within generated patches.
5180
5181@item diff-insert=
5182@vindex diff-insert GCC_COLORS @r{capability}
5183SGR substring for inserted lines within generated patches.
5184
5185@item type-diff=
5186@vindex type-diff GCC_COLORS @r{capability}
5187SGR substring for highlighting mismatching types within template
5188arguments in the C++ frontend.
5189@end table
5190
5191@item -fdiagnostics-urls[=@var{WHEN}]
5192@opindex fdiagnostics-urls
5193@cindex urls
5194@vindex GCC_URLS @r{environment variable}
5195@vindex TERM_URLS @r{environment variable}
5196Use escape sequences to embed URLs in diagnostics. For example, when
5197@option{-fdiagnostics-show-option} emits text showing the command-line
5198option controlling a diagnostic, embed a URL for documentation of that
5199option.
5200
5201@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5202@samp{auto} makes GCC use URL escape sequences only when the standard error
5203is a terminal, and when not executing in an emacs shell or any graphical
5204terminal which is known to be incompatible with this feature, see below.
5205
5206The default depends on how the compiler has been configured.
5207It can be any of the above @var{WHEN} options.
5208
5209GCC can also be configured (via the
5210@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5211so that the default is affected by environment variables.
5212Under such a configuration, GCC defaults to using @samp{auto}
5213if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5214present and non-empty in the environment of the compiler, or @samp{never}
5215if neither are.
5216
5217However, even with @option{-fdiagnostics-urls=always} the behavior is
5218dependent on those environment variables:
5219If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5220diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5221If set to @samp{bel}, the default, URLs use BEL escape sequences.
5222Any other non-empty value enables the feature.
5223If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5224Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5225BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5226
5227At this time GCC tries to detect also a few terminals that are known to
5228not implement the URL feature, and have bugs or at least had bugs in
5229some versions that are still in use, where the URL escapes are likely
5230to misbehave, i.e. print garbage on the screen.
5231That list is currently xfce4-terminal, certain known to be buggy
5232gnome-terminal versions, the linux console, and mingw.
5233This check can be skipped with the @option{-fdiagnostics-urls=always}.
5234
5235@item -fno-diagnostics-show-option
5236@opindex fno-diagnostics-show-option
5237@opindex fdiagnostics-show-option
5238By default, each diagnostic emitted includes text indicating the
5239command-line option that directly controls the diagnostic (if such an
5240option is known to the diagnostic machinery). Specifying the
5241@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5242
5243@item -fno-diagnostics-show-caret
5244@opindex fno-diagnostics-show-caret
5245@opindex fdiagnostics-show-caret
5246By default, each diagnostic emitted includes the original source line
5247and a caret @samp{^} indicating the column. This option suppresses this
5248information. The source line is truncated to @var{n} characters, if
5249the @option{-fmessage-length=n} option is given. When the output is done
5250to the terminal, the width is limited to the width given by the
5251@env{COLUMNS} environment variable or, if not set, to the terminal width.
5252
5253@item -fno-diagnostics-show-labels
5254@opindex fno-diagnostics-show-labels
5255@opindex fdiagnostics-show-labels
5256By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5257diagnostics can label ranges of source code with pertinent information, such
5258as the types of expressions:
5259
5260@smallexample
5261 printf ("foo %s bar", long_i + long_j);
5262 ~^ ~~~~~~~~~~~~~~~
5263 | |
5264 char * long int
5265@end smallexample
5266
5267This option suppresses the printing of these labels (in the example above,
5268the vertical bars and the ``char *'' and ``long int'' text).
5269
5270@item -fno-diagnostics-show-cwe
5271@opindex fno-diagnostics-show-cwe
5272@opindex fdiagnostics-show-cwe
5273Diagnostic messages can optionally have an associated
5274@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5275GCC itself only provides such metadata for some of the @option{-fanalyzer}
5276diagnostics. GCC plugins may also provide diagnostics with such metadata.
5277By default, if this information is present, it will be printed with
5278the diagnostic. This option suppresses the printing of this metadata.
5279
5280@item -fno-diagnostics-show-rules
5281@opindex fno-diagnostics-show-rules
5282@opindex fdiagnostics-show-rules
5283Diagnostic messages can optionally have rules associated with them, such
5284as from a coding standard, or a specification.
5285GCC itself does not do this for any of its diagnostics, but plugins may do so.
5286By default, if this information is present, it will be printed with
5287the diagnostic. This option suppresses the printing of this metadata.
5288
5289@item -fno-diagnostics-show-line-numbers
5290@opindex fno-diagnostics-show-line-numbers
5291@opindex fdiagnostics-show-line-numbers
5292By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5293a left margin is printed, showing line numbers. This option suppresses this
5294left margin.
5295
5296@item -fdiagnostics-minimum-margin-width=@var{width}
5297@opindex fdiagnostics-minimum-margin-width
5298This option controls the minimum width of the left margin printed by
5299@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5300
5301@item -fdiagnostics-parseable-fixits
5302@opindex fdiagnostics-parseable-fixits
5303Emit fix-it hints in a machine-parseable format, suitable for consumption
5304by IDEs. For each fix-it, a line will be printed after the relevant
5305diagnostic, starting with the string ``fix-it:''. For example:
5306
5307@smallexample
5308fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5309@end smallexample
5310
5311The location is expressed as a half-open range, expressed as a count of
5312bytes, starting at byte 1 for the initial column. In the above example,
5313bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5314given string:
5315
5316@smallexample
531700000000011111111112222222222
531812345678901234567890123456789
5319 gtk_widget_showall (dlg);
5320 ^^^^^^^^^^^^^^^^^^
5321 gtk_widget_show_all
5322@end smallexample
5323
5324The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5325newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5326(e.g. vertical tab as ``\013'').
5327
5328An empty replacement string indicates that the given range is to be removed.
5329An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5330be inserted at the given position.
5331
5332@item -fdiagnostics-generate-patch
5333@opindex fdiagnostics-generate-patch
5334Print fix-it hints to stderr in unified diff format, after any diagnostics
5335are printed. For example:
5336
5337@smallexample
5338--- test.c
5339+++ test.c
5340@@ -42,5 +42,5 @@
5341
5342 void show_cb(GtkDialog *dlg)
5343 @{
5344- gtk_widget_showall(dlg);
5345+ gtk_widget_show_all(dlg);
5346 @}
5347
5348@end smallexample
5349
5350The diff may or may not be colorized, following the same rules
5351as for diagnostics (see @option{-fdiagnostics-color}).
5352
5353@item -fdiagnostics-show-template-tree
5354@opindex fdiagnostics-show-template-tree
5355
5356In the C++ frontend, when printing diagnostics showing mismatching
5357template types, such as:
5358
5359@smallexample
5360 could not convert 'std::map<int, std::vector<double> >()'
5361 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5362@end smallexample
5363
5364the @option{-fdiagnostics-show-template-tree} flag enables printing a
5365tree-like structure showing the common and differing parts of the types,
5366such as:
5367
5368@smallexample
5369 map<
5370 [...],
5371 vector<
5372 [double != float]>>
5373@end smallexample
5374
5375The parts that differ are highlighted with color (``double'' and
5376``float'' in this case).
5377
5378@item -fno-elide-type
5379@opindex fno-elide-type
5380@opindex felide-type
5381By default when the C++ frontend prints diagnostics showing mismatching
5382template types, common parts of the types are printed as ``[...]'' to
5383simplify the error message. For example:
5384
5385@smallexample
5386 could not convert 'std::map<int, std::vector<double> >()'
5387 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5388@end smallexample
5389
5390Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5391This flag also affects the output of the
5392@option{-fdiagnostics-show-template-tree} flag.
5393
5394@item -fdiagnostics-path-format=@var{KIND}
5395@opindex fdiagnostics-path-format
5396Specify how to print paths of control-flow events for diagnostics that
5397have such a path associated with them.
5398
5399@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5400the default.
5401
5402@samp{none} means to not print diagnostic paths.
5403
5404@samp{separate-events} means to print a separate ``note'' diagnostic for
5405each event within the diagnostic. For example:
5406
5407@smallexample
5408test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5409test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5410test.c:27:3: note: (2) when 'i < count'
5411test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5412@end smallexample
5413
5414@samp{inline-events} means to print the events ``inline'' within the source
5415code. This view attempts to consolidate the events into runs of
5416sufficiently-close events, printing them as labelled ranges within the source.
5417
5418For example, the same events as above might be printed as:
5419
5420@smallexample
5421 'test': events 1-3
5422 |
5423 | 25 | list = PyList_New(0);
5424 | | ^~~~~~~~~~~~~
5425 | | |
5426 | | (1) when 'PyList_New' fails, returning NULL
5427 | 26 |
5428 | 27 | for (i = 0; i < count; i++) @{
5429 | | ~~~
5430 | | |
5431 | | (2) when 'i < count'
5432 | 28 | item = PyLong_FromLong(random());
5433 | 29 | PyList_Append(list, item);
5434 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5435 | | |
5436 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5437 |
5438@end smallexample
5439
5440Interprocedural control flow is shown by grouping the events by stack frame,
5441and using indentation to show how stack frames are nested, pushed, and popped.
5442
5443For example:
5444
5445@smallexample
5446 'test': events 1-2
5447 |
5448 | 133 | @{
5449 | | ^
5450 | | |
5451 | | (1) entering 'test'
5452 | 134 | boxed_int *obj = make_boxed_int (i);
5453 | | ~~~~~~~~~~~~~~~~~~
5454 | | |
5455 | | (2) calling 'make_boxed_int'
5456 |
5457 +--> 'make_boxed_int': events 3-4
5458 |
5459 | 120 | @{
5460 | | ^
5461 | | |
5462 | | (3) entering 'make_boxed_int'
5463 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5464 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5465 | | |
5466 | | (4) calling 'wrapped_malloc'
5467 |
5468 +--> 'wrapped_malloc': events 5-6
5469 |
5470 | 7 | @{
5471 | | ^
5472 | | |
5473 | | (5) entering 'wrapped_malloc'
5474 | 8 | return malloc (size);
5475 | | ~~~~~~~~~~~~~
5476 | | |
5477 | | (6) calling 'malloc'
5478 |
5479 <-------------+
5480 |
5481 'test': event 7
5482 |
5483 | 138 | free_boxed_int (obj);
5484 | | ^~~~~~~~~~~~~~~~~~~~
5485 | | |
5486 | | (7) calling 'free_boxed_int'
5487 |
5488(etc)
5489@end smallexample
5490
5491@item -fdiagnostics-show-path-depths
5492@opindex fdiagnostics-show-path-depths
5493This option provides additional information when printing control-flow paths
5494associated with a diagnostic.
5495
5496If this is option is provided then the stack depth will be printed for
5497each run of events within @option{-fdiagnostics-path-format=inline-events}.
5498If provided with @option{-fdiagnostics-path-format=separate-events}, then
5499the stack depth and function declaration will be appended when printing
5500each event.
5501
5502This is intended for use by GCC developers and plugin developers when
5503debugging diagnostics that report interprocedural control flow.
5504
5505@item -fno-show-column
5506@opindex fno-show-column
5507@opindex fshow-column
5508Do not print column numbers in diagnostics. This may be necessary if
5509diagnostics are being scanned by a program that does not understand the
5510column numbers, such as @command{dejagnu}.
5511
5512@item -fdiagnostics-column-unit=@var{UNIT}
5513@opindex fdiagnostics-column-unit
5514Select the units for the column number. This affects traditional diagnostics
5515(in the absence of @option{-fno-show-column}), as well as JSON format
5516diagnostics if requested.
5517
5518The default @var{UNIT}, @samp{display}, considers the number of display
5519columns occupied by each character. This may be larger than the number
5520of bytes required to encode the character, in the case of tab
5521characters, or it may be smaller, in the case of multibyte characters.
5522For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5523display column, and its UTF-8 encoding requires two bytes; the character
5524``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5525its UTF-8 encoding requires four bytes.
5526
5527Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5528count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5529
5530@item -fdiagnostics-column-origin=@var{ORIGIN}
5531@opindex fdiagnostics-column-origin
5532Select the origin for column numbers, i.e. the column number assigned to the
5533first column. The default value of 1 corresponds to traditional GCC
5534behavior and to the GNU style guide. Some utilities may perform better with an
5535origin of 0; any non-negative value may be specified.
5536
5537@item -fdiagnostics-escape-format=@var{FORMAT}
5538@opindex fdiagnostics-escape-format
5539When GCC prints pertinent source lines for a diagnostic it normally attempts
5540to print the source bytes directly. However, some diagnostics relate to encoding
5541issues in the source file, such as malformed UTF-8, or issues with Unicode
5542normalization. These diagnostics are flagged so that GCC will escape bytes
5543that are not printable ASCII when printing their pertinent source lines.
5544
5545This option controls how such bytes should be escaped.
5546
5547The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5548are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5549correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5550displayed as hexadecimal in the form @samp{<XX>}.
5551
5552For example, a source line containing the string @samp{before} followed by the
5553Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
55540xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5555the string @samp{after} will be printed for such a diagnostic as:
5556
5557@smallexample
5558 before<U+03C0><BF>after
5559@end smallexample
5560
5561Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5562in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5563Unicode characters. For the example above, the following will be printed:
5564
5565@smallexample
5566 before<CF><80><BF>after
5567@end smallexample
5568
5569@item -fdiagnostics-format=@var{FORMAT}
5570@opindex fdiagnostics-format
5571Select a different format for printing diagnostics.
5572@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5573@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5574
5575The default is @samp{text}.
5576
5577The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5578diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5579named @file{@var{source}.sarif}, respectively.
5580
5581The @samp{json} format is a synonym for @samp{json-stderr}.
5582The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5583where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5584whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5585
5586The emitted JSON consists of a top-level JSON array containing JSON objects
5587representing the diagnostics. The JSON is emitted as one line, without
5588formatting; the examples below have been formatted for clarity.
5589
5590Diagnostics can have child diagnostics. For example, this error and note:
5591
5592@smallexample
5593misleading-indentation.c:15:3: warning: this 'if' clause does not
5594 guard... [-Wmisleading-indentation]
5595 15 | if (flag)
5596 | ^~
5597misleading-indentation.c:17:5: note: ...this statement, but the latter
5598 is misleadingly indented as if it were guarded by the 'if'
5599 17 | y = 2;
5600 | ^
5601@end smallexample
5602
5603@noindent
5604might be printed in JSON form (after formatting) like this:
5605
5606@smallexample
5607[
5608 @{
5609 "kind": "warning",
5610 "locations": [
5611 @{
5612 "caret": @{
5613 "display-column": 3,
5614 "byte-column": 3,
5615 "column": 3,
5616 "file": "misleading-indentation.c",
5617 "line": 15
5618 @},
5619 "finish": @{
5620 "display-column": 4,
5621 "byte-column": 4,
5622 "column": 4,
5623 "file": "misleading-indentation.c",
5624 "line": 15
5625 @}
5626 @}
5627 ],
5628 "message": "this \u2018if\u2019 clause does not guard...",
5629 "option": "-Wmisleading-indentation",
5630 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5631 "children": [
5632 @{
5633 "kind": "note",
5634 "locations": [
5635 @{
5636 "caret": @{
5637 "display-column": 5,
5638 "byte-column": 5,
5639 "column": 5,
5640 "file": "misleading-indentation.c",
5641 "line": 17
5642 @}
5643 @}
5644 ],
5645 "escape-source": false,
5646 "message": "...this statement, but the latter is @dots{}"
5647 @}
5648 ]
5649 "escape-source": false,
5650 "column-origin": 1,
5651 @}
5652]
5653@end smallexample
5654
5655@noindent
5656where the @code{note} is a child of the @code{warning}.
5657
5658A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5659an @code{option} key describing the command-line option controlling the
5660warning.
5661
5662A diagnostic can contain zero or more locations. Each location has an
5663optional @code{label} string and up to three positions within it: a
5664@code{caret} position and optional @code{start} and @code{finish} positions.
5665A position is described by a @code{file} name, a @code{line} number, and
5666three numbers indicating a column position:
5667@itemize @bullet
5668
5669@item
5670@code{display-column} counts display columns, accounting for tabs and
5671multibyte characters.
5672
5673@item
5674@code{byte-column} counts raw bytes.
5675
5676@item
5677@code{column} is equal to one of
5678the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5679option.
5680
5681@end itemize
5682All three columns are relative to the origin specified by
5683@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5684be set, for instance, to 0 for compatibility with other utilities that
5685number columns from 0. The column origin is recorded in the JSON output in
5686the @code{column-origin} tag. In the remaining examples below, the extra
5687column number outputs have been omitted for brevity.
5688
5689For example, this error:
5690
5691@smallexample
5692bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5693 'struct s'@} and 'T' @{aka 'struct t'@})
5694 64 | return callee_4a () + callee_4b ();
5695 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5696 | | |
5697 | | T @{aka struct t@}
5698 | S @{aka struct s@}
5699@end smallexample
5700
5701@noindent
5702has three locations. Its primary location is at the ``+'' token at column
570323. It has two secondary locations, describing the left and right-hand sides
5704of the expression, which have labels. It might be printed in JSON form as:
5705
5706@smallexample
5707 @{
5708 "children": [],
5709 "kind": "error",
5710 "locations": [
5711 @{
5712 "caret": @{
5713 "column": 23, "file": "bad-binary-ops.c", "line": 64
5714 @}
5715 @},
5716 @{
5717 "caret": @{
5718 "column": 10, "file": "bad-binary-ops.c", "line": 64
5719 @},
5720 "finish": @{
5721 "column": 21, "file": "bad-binary-ops.c", "line": 64
5722 @},
5723 "label": "S @{aka struct s@}"
5724 @},
5725 @{
5726 "caret": @{
5727 "column": 25, "file": "bad-binary-ops.c", "line": 64
5728 @},
5729 "finish": @{
5730 "column": 36, "file": "bad-binary-ops.c", "line": 64
5731 @},
5732 "label": "T @{aka struct t@}"
5733 @}
5734 ],
5735 "escape-source": false,
5736 "message": "invalid operands to binary + @dots{}"
5737 @}
5738@end smallexample
5739
5740If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5741consisting of half-open intervals, similar to the output of
5742@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5743with a replacement fix-it hint:
5744
5745@smallexample
5746demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5747 mean 'color'?
5748 8 | return ptr->colour;
5749 | ^~~~~~
5750 | color
5751@end smallexample
5752
5753@noindent
5754might be printed in JSON form as:
5755
5756@smallexample
5757 @{
5758 "children": [],
5759 "fixits": [
5760 @{
5761 "next": @{
5762 "column": 21,
5763 "file": "demo.c",
5764 "line": 8
5765 @},
5766 "start": @{
5767 "column": 15,
5768 "file": "demo.c",
5769 "line": 8
5770 @},
5771 "string": "color"
5772 @}
5773 ],
5774 "kind": "error",
5775 "locations": [
5776 @{
5777 "caret": @{
5778 "column": 15,
5779 "file": "demo.c",
5780 "line": 8
5781 @},
5782 "finish": @{
5783 "column": 20,
5784 "file": "demo.c",
5785 "line": 8
5786 @}
5787 @}
5788 ],
5789 "escape-source": false,
5790 "message": "\u2018struct s\u2019 has no member named @dots{}"
5791 @}
5792@end smallexample
5793
5794@noindent
5795where the fix-it hint suggests replacing the text from @code{start} up
5796to but not including @code{next} with @code{string}'s value. Deletions
5797are expressed via an empty value for @code{string}, insertions by
5798having @code{start} equal @code{next}.
5799
5800If the diagnostic has a path of control-flow events associated with it,
5801it has a @code{path} array of objects representing the events. Each
5802event object has a @code{description} string, a @code{location} object,
5803along with a @code{function} string and a @code{depth} number for
5804representing interprocedural paths. The @code{function} represents the
5805current function at that event, and the @code{depth} represents the
5806stack depth relative to some baseline: the higher, the more frames are
5807within the stack.
5808
5809For example, the intraprocedural example shown for
5810@option{-fdiagnostics-path-format=} might have this JSON for its path:
5811
5812@smallexample
5813 "path": [
5814 @{
5815 "depth": 0,
5816 "description": "when 'PyList_New' fails, returning NULL",
5817 "function": "test",
5818 "location": @{
5819 "column": 10,
5820 "file": "test.c",
5821 "line": 25
5822 @}
5823 @},
5824 @{
5825 "depth": 0,
5826 "description": "when 'i < count'",
5827 "function": "test",
5828 "location": @{
5829 "column": 3,
5830 "file": "test.c",
5831 "line": 27
5832 @}
5833 @},
5834 @{
5835 "depth": 0,
5836 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5837 "function": "test",
5838 "location": @{
5839 "column": 5,
5840 "file": "test.c",
5841 "line": 29
5842 @}
5843 @}
5844 ]
5845@end smallexample
5846
5847Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5848non-ASCII bytes should be escaped when printing the pertinent lines of
5849source code (@code{true} for diagnostics involving source encoding issues).
5850
5851@end table
5852
5853@node Warning Options
5854@section Options to Request or Suppress Warnings
5855@cindex options to control warnings
5856@cindex warning messages
5857@cindex messages, warning
5858@cindex suppressing warnings
5859
5860Warnings are diagnostic messages that report constructions that
5861are not inherently erroneous but that are risky or suggest there
5862may have been an error.
5863
5864The following language-independent options do not enable specific
5865warnings but control the kinds of diagnostics produced by GCC@.
5866
5867@table @gcctabopt
5868@cindex syntax checking
5869@item -fsyntax-only
5870@opindex fsyntax-only
5871Check the code for syntax errors, but don't do anything beyond that.
5872
5873@item -fmax-errors=@var{n}
5874@opindex fmax-errors
5875Limits the maximum number of error messages to @var{n}, at which point
5876GCC bails out rather than attempting to continue processing the source
5877code. If @var{n} is 0 (the default), there is no limit on the number
5878of error messages produced. If @option{-Wfatal-errors} is also
5879specified, then @option{-Wfatal-errors} takes precedence over this
5880option.
5881
5882@item -w
5883@opindex w
5884Inhibit all warning messages.
5885
5886@item -Werror
5887@opindex Werror
5888@opindex Wno-error
5889Make all warnings into errors.
5890
5891@item -Werror=
5892@opindex Werror=
5893@opindex Wno-error=
5894Make the specified warning into an error. The specifier for a warning
5895is appended; for example @option{-Werror=switch} turns the warnings
5896controlled by @option{-Wswitch} into errors. This switch takes a
5897negative form, to be used to negate @option{-Werror} for specific
5898warnings; for example @option{-Wno-error=switch} makes
5899@option{-Wswitch} warnings not be errors, even when @option{-Werror}
5900is in effect.
5901
5902The warning message for each controllable warning includes the
5903option that controls the warning. That option can then be used with
5904@option{-Werror=} and @option{-Wno-error=} as described above.
5905(Printing of the option in the warning message can be disabled using the
5906@option{-fno-diagnostics-show-option} flag.)
5907
5908Note that specifying @option{-Werror=}@var{foo} automatically implies
5909@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5910imply anything.
5911
5912@item -Wfatal-errors
5913@opindex Wfatal-errors
5914@opindex Wno-fatal-errors
5915This option causes the compiler to abort compilation on the first error
5916occurred rather than trying to keep going and printing further error
5917messages.
5918
5919@end table
5920
5921You can request many specific warnings with options beginning with
5922@samp{-W}, for example @option{-Wimplicit} to request warnings on
5923implicit declarations. Each of these specific warning options also
5924has a negative form beginning @samp{-Wno-} to turn off warnings; for
5925example, @option{-Wno-implicit}. This manual lists only one of the
5926two forms, whichever is not the default. For further
5927language-specific options also refer to @ref{C++ Dialect Options} and
5928@ref{Objective-C and Objective-C++ Dialect Options}.
5929Additional warnings can be produced by enabling the static analyzer;
5930@xref{Static Analyzer Options}.
5931
5932Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5933options, such as @option{-Wunused}, which may turn on further options,
5934such as @option{-Wunused-value}. The combined effect of positive and
5935negative forms is that more specific options have priority over less
5936specific ones, independently of their position in the command-line. For
5937options of the same specificity, the last one takes effect. Options
5938enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5939as if they appeared at the end of the command-line.
5940
5941When an unrecognized warning option is requested (e.g.,
5942@option{-Wunknown-warning}), GCC emits a diagnostic stating
5943that the option is not recognized. However, if the @option{-Wno-} form
5944is used, the behavior is slightly different: no diagnostic is
5945produced for @option{-Wno-unknown-warning} unless other diagnostics
5946are being produced. This allows the use of new @option{-Wno-} options
5947with old compilers, but if something goes wrong, the compiler
5948warns that an unrecognized option is present.
5949
5950The effectiveness of some warnings depends on optimizations also being
5951enabled. For example @option{-Wsuggest-final-types} is more effective
5952with link-time optimization and some instances of other warnings may
5953not be issued at all unless optimization is enabled. While optimization
5954in general improves the efficacy of control and data flow sensitive
5955warnings, in some cases it may also cause false positives.
5956
5957@table @gcctabopt
5958@item -Wpedantic
5959@itemx -pedantic
5960@opindex pedantic
5961@opindex Wpedantic
5962@opindex Wno-pedantic
5963Issue all the warnings demanded by strict ISO C and ISO C++;
5964reject all programs that use forbidden extensions, and some other
5965programs that do not follow ISO C and ISO C++. For ISO C, follows the
5966version of the ISO C standard specified by any @option{-std} option used.
5967
5968Valid ISO C and ISO C++ programs should compile properly with or without
5969this option (though a rare few require @option{-ansi} or a
5970@option{-std} option specifying the required version of ISO C)@. However,
5971without this option, certain GNU extensions and traditional C and C++
5972features are supported as well. With this option, they are rejected.
5973
5974@option{-Wpedantic} does not cause warning messages for use of the
5975alternate keywords whose names begin and end with @samp{__}. This alternate
5976format can also be used to disable warnings for non-ISO @samp{__intN} types,
5977i.e. @samp{__intN__}.
5978Pedantic warnings are also disabled in the expression that follows
5979@code{__extension__}. However, only system header files should use
5980these escape routes; application programs should avoid them.
5981@xref{Alternate Keywords}.
5982
5983Some users try to use @option{-Wpedantic} to check programs for strict ISO
5984C conformance. They soon find that it does not do quite what they want:
5985it finds some non-ISO practices, but not all---only those for which
5986ISO C @emph{requires} a diagnostic, and some others for which
5987diagnostics have been added.
5988
5989A feature to report any failure to conform to ISO C might be useful in
5990some instances, but would require considerable additional work and would
5991be quite different from @option{-Wpedantic}. We don't have plans to
5992support such a feature in the near future.
5993
5994Where the standard specified with @option{-std} represents a GNU
5995extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
5996corresponding @dfn{base standard}, the version of ISO C on which the GNU
5997extended dialect is based. Warnings from @option{-Wpedantic} are given
5998where they are required by the base standard. (It does not make sense
5999for such warnings to be given only for features not in the specified GNU
6000C dialect, since by definition the GNU dialects of C include all
6001features the compiler supports with the given option, and there would be
6002nothing to warn about.)
6003
6004@item -pedantic-errors
6005@opindex pedantic-errors
6006Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6007requires a diagnostic, in some cases where there is undefined behavior
6008at compile-time and in some other cases that do not prevent compilation
6009of programs that are valid according to the standard. This is not
6010equivalent to @option{-Werror=pedantic}, since there are errors enabled
6011by this option and not enabled by the latter and vice versa.
6012
6013@item -Wall
6014@opindex Wall
6015@opindex Wno-all
6016This enables all the warnings about constructions that some users
6017consider questionable, and that are easy to avoid (or modify to
6018prevent the warning), even in conjunction with macros. This also
6019enables some language-specific warnings described in @ref{C++ Dialect
6020Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6021
6022@option{-Wall} turns on the following warning flags:
6023
6024@gccoptlist{-Waddress @gol
6025-Warray-bounds=1 @r{(only with} @option{-O2}@r{)} @gol
6026-Warray-compare @gol
6027-Warray-parameter=2 @r{(C and Objective-C only)} @gol
6028-Wbool-compare @gol
6029-Wbool-operation @gol
6030-Wc++11-compat -Wc++14-compat @gol
6031-Wcatch-value @r{(C++ and Objective-C++ only)} @gol
6032-Wchar-subscripts @gol
6033-Wcomment @gol
6034-Wdangling-pointer=2 @gol
6035-Wduplicate-decl-specifier @r{(C and Objective-C only)} @gol
6036-Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol
6037-Wenum-int-mismatch @r{(C and Objective-C only)} @gol
6038-Wformat @gol
6039-Wformat-overflow @gol
6040-Wformat-truncation @gol
6041-Wint-in-bool-context @gol
6042-Wimplicit @r{(C and Objective-C only)} @gol
6043-Wimplicit-int @r{(C and Objective-C only)} @gol
6044-Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
6045-Winit-self @r{(only for C++)} @gol
6046-Wlogical-not-parentheses @gol
6047-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
6048-Wmaybe-uninitialized @gol
6049-Wmemset-elt-size @gol
6050-Wmemset-transposed-args @gol
6051-Wmisleading-indentation @r{(only for C/C++)} @gol
6052-Wmismatched-dealloc @gol
6053-Wmismatched-new-delete @r{(only for C/C++)} @gol
6054-Wmissing-attributes @gol
6055-Wmissing-braces @r{(only for C/ObjC)} @gol
6056-Wmultistatement-macros @gol
6057-Wnarrowing @r{(only for C++)} @gol
6058-Wnonnull @gol
6059-Wnonnull-compare @gol
6060-Wopenmp-simd @gol
6061-Wparentheses @gol
6062-Wpessimizing-move @r{(only for C++)} @gol
6063-Wpointer-sign @gol
6064-Wrange-loop-construct @r{(only for C++)} @gol
6065-Wreorder @gol
6066-Wrestrict @gol
6067-Wreturn-type @gol
6068-Wself-move @r{(only for C++)} @gol
6069-Wsequence-point @gol
6070-Wsign-compare @r{(only in C++)} @gol
6071-Wsizeof-array-div @gol
6072-Wsizeof-pointer-div @gol
6073-Wsizeof-pointer-memaccess @gol
6074-Wstrict-aliasing @gol
6075-Wstrict-overflow=1 @gol
6076-Wswitch @gol
6077-Wtautological-compare @gol
6078-Wtrigraphs @gol
6079-Wuninitialized @gol
6080-Wunknown-pragmas @gol
6081-Wunused-function @gol
6082-Wunused-label @gol
6083-Wunused-value @gol
6084-Wunused-variable @gol
6085-Wuse-after-free=3 @gol
6086-Wvla-parameter @r{(C and Objective-C only)} @gol
6087-Wvolatile-register-var @gol
6088-Wzero-length-bounds}
6089
6090Note that some warning flags are not implied by @option{-Wall}. Some of
6091them warn about constructions that users generally do not consider
6092questionable, but which occasionally you might wish to check for;
6093others warn about constructions that are necessary or hard to avoid in
6094some cases, and there is no simple way to modify the code to suppress
6095the warning. Some of them are enabled by @option{-Wextra} but many of
6096them must be enabled individually.
6097
6098@item -Wextra
6099@opindex W
6100@opindex Wextra
6101@opindex Wno-extra
6102This enables some extra warning flags that are not enabled by
6103@option{-Wall}. (This option used to be called @option{-W}. The older
6104name is still supported, but the newer name is more descriptive.)
6105
6106@gccoptlist{-Wclobbered @gol
6107-Wcast-function-type @gol
6108-Wdeprecated-copy @r{(C++ only)} @gol
6109-Wempty-body @gol
6110-Wenum-conversion @r{(C only)} @gol
6111-Wignored-qualifiers @gol
6112-Wimplicit-fallthrough=3 @gol
6113-Wmissing-field-initializers @gol
6114-Wmissing-parameter-type @r{(C only)} @gol
6115-Wold-style-declaration @r{(C only)} @gol
6116-Woverride-init @gol
6117-Wsign-compare @r{(C only)} @gol
6118-Wstring-compare @gol
6119-Wredundant-move @r{(only for C++)} @gol
6120-Wtype-limits @gol
6121-Wuninitialized @gol
6122-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} @gol
6123-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol
6124-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6125
6126
6127The option @option{-Wextra} also prints warning messages for the
6128following cases:
6129
6130@itemize @bullet
6131
6132@item
6133A pointer is compared against integer zero with @code{<}, @code{<=},
6134@code{>}, or @code{>=}.
6135
6136@item
6137(C++ only) An enumerator and a non-enumerator both appear in a
6138conditional expression.
6139
6140@item
6141(C++ only) Ambiguous virtual bases.
6142
6143@item
6144(C++ only) Subscripting an array that has been declared @code{register}.
6145
6146@item
6147(C++ only) Taking the address of a variable that has been declared
6148@code{register}.
6149
6150@item
6151(C++ only) A base class is not initialized in the copy constructor
6152of a derived class.
6153
6154@end itemize
6155
6156@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
6157@opindex Wabi
6158@opindex Wno-abi
6159
6160Warn about code affected by ABI changes. This includes code that may
6161not be compatible with the vendor-neutral C++ ABI as well as the psABI
6162for the particular target.
6163
6164Since G++ now defaults to updating the ABI with each major release,
6165normally @option{-Wabi} warns only about C++ ABI compatibility
6166problems if there is a check added later in a release series for an
6167ABI issue discovered since the initial release. @option{-Wabi} warns
6168about more things if an older ABI version is selected (with
6169@option{-fabi-version=@var{n}}).
6170
6171@option{-Wabi} can also be used with an explicit version number to
6172warn about C++ ABI compatibility with a particular @option{-fabi-version}
6173level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6174@option{-fabi-version=2}.
6175
6176If an explicit version number is provided and
6177@option{-fabi-compat-version} is not specified, the version number
6178from this option is used for compatibility aliases. If no explicit
6179version number is provided with this option, but
6180@option{-fabi-compat-version} is specified, that version number is
6181used for C++ ABI warnings.
6182
6183Although an effort has been made to warn about
6184all such cases, there are probably some cases that are not warned about,
6185even though G++ is generating incompatible code. There may also be
6186cases where warnings are emitted even though the code that is generated
6187is compatible.
6188
6189You should rewrite your code to avoid these warnings if you are
6190concerned about the fact that code generated by G++ may not be binary
6191compatible with code generated by other compilers.
6192
6193Known incompatibilities in @option{-fabi-version=2} (which was the
6194default from GCC 3.4 to 4.9) include:
6195
6196@itemize @bullet
6197
6198@item
6199A template with a non-type template parameter of reference type was
6200mangled incorrectly:
6201@smallexample
6202extern int N;
6203template <int &> struct S @{@};
6204void n (S<N>) @{2@}
6205@end smallexample
6206
6207This was fixed in @option{-fabi-version=3}.
6208
6209@item
6210SIMD vector types declared using @code{__attribute ((vector_size))} were
6211mangled in a non-standard way that does not allow for overloading of
6212functions taking vectors of different sizes.
6213
6214The mangling was changed in @option{-fabi-version=4}.
6215
6216@item
6217@code{__attribute ((const))} and @code{noreturn} were mangled as type
6218qualifiers, and @code{decltype} of a plain declaration was folded away.
6219
6220These mangling issues were fixed in @option{-fabi-version=5}.
6221
6222@item
6223Scoped enumerators passed as arguments to a variadic function are
6224promoted like unscoped enumerators, causing @code{va_arg} to complain.
6225On most targets this does not actually affect the parameter passing
6226ABI, as there is no way to pass an argument smaller than @code{int}.
6227
6228Also, the ABI changed the mangling of template argument packs,
6229@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6230a class scope function used as a template argument.
6231
6232These issues were corrected in @option{-fabi-version=6}.
6233
6234@item
6235Lambdas in default argument scope were mangled incorrectly, and the
6236ABI changed the mangling of @code{nullptr_t}.
6237
6238These issues were corrected in @option{-fabi-version=7}.
6239
6240@item
6241When mangling a function type with function-cv-qualifiers, the
6242un-qualified function type was incorrectly treated as a substitution
6243candidate.
6244
6245This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6246
6247@item
6248@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6249unaligned accesses. Note that this did not affect the ABI of a
6250function with a @code{nullptr_t} parameter, as parameters have a
6251minimum alignment.
6252
6253This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6254
6255@item
6256Target-specific attributes that affect the identity of a type, such as
6257ia32 calling conventions on a function type (stdcall, regparm, etc.),
6258did not affect the mangled name, leading to name collisions when
6259function pointers were used as template arguments.
6260
6261This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6262
6263@end itemize
6264
6265This option also enables warnings about psABI-related changes.
6266The known psABI changes at this point include:
6267
6268@itemize @bullet
6269
6270@item
6271For SysV/x86-64, unions with @code{long double} members are
6272passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6273the case. For example:
6274
6275@smallexample
6276union U @{
6277 long double ld;
6278 int i;
6279@};
6280@end smallexample
6281
6282@noindent
6283@code{union U} is now always passed in memory.
6284
6285@end itemize
6286
6287@item -Wchar-subscripts
6288@opindex Wchar-subscripts
6289@opindex Wno-char-subscripts
6290Warn if an array subscript has type @code{char}. This is a common cause
6291of error, as programmers often forget that this type is signed on some
6292machines.
6293This warning is enabled by @option{-Wall}.
6294
6295@item -Wno-coverage-mismatch
6296@opindex Wno-coverage-mismatch
6297@opindex Wcoverage-mismatch
6298Warn if feedback profiles do not match when using the
6299@option{-fprofile-use} option.
6300If a source file is changed between compiling with @option{-fprofile-generate}
6301and with @option{-fprofile-use}, the files with the profile feedback can fail
6302to match the source file and GCC cannot use the profile feedback
6303information. By default, this warning is enabled and is treated as an
6304error. @option{-Wno-coverage-mismatch} can be used to disable the
6305warning or @option{-Wno-error=coverage-mismatch} can be used to
6306disable the error. Disabling the error for this warning can result in
6307poorly optimized code and is useful only in the
6308case of very minor changes such as bug fixes to an existing code-base.
6309Completely disabling the warning is not recommended.
6310
6311@item -Wno-coverage-invalid-line-number
6312@opindex Wno-coverage-invalid-line-number
6313@opindex Wcoverage-invalid-line-number
6314Warn in case a function ends earlier than it begins due
6315to an invalid linenum macros. The warning is emitted only
6316with @option{--coverage} enabled.
6317
6318By default, this warning is enabled and is treated as an
6319error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6320warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6321disable the error.
6322
6323@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
6324@opindex Wno-cpp
6325@opindex Wcpp
6326Suppress warning messages emitted by @code{#warning} directives.
6327
6328@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
6329@opindex Wdouble-promotion
6330@opindex Wno-double-promotion
6331Give a warning when a value of type @code{float} is implicitly
6332promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6333floating-point unit implement @code{float} in hardware, but emulate
6334@code{double} in software. On such a machine, doing computations
6335using @code{double} values is much more expensive because of the
6336overhead required for software emulation.
6337
6338It is easy to accidentally do computations with @code{double} because
6339floating-point literals are implicitly of type @code{double}. For
6340example, in:
6341@smallexample
6342@group
6343float area(float radius)
6344@{
6345 return 3.14159 * radius * radius;
6346@}
6347@end group
6348@end smallexample
6349the compiler performs the entire computation with @code{double}
6350because the floating-point literal is a @code{double}.
6351
6352@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6353@opindex Wduplicate-decl-specifier
6354@opindex Wno-duplicate-decl-specifier
6355Warn if a declaration has duplicate @code{const}, @code{volatile},
6356@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6357@option{-Wall}.
6358
6359@item -Wformat
6360@itemx -Wformat=@var{n}
6361@opindex Wformat
6362@opindex Wno-format
6363@opindex ffreestanding
6364@opindex fno-builtin
6365@opindex Wformat=
6366Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6367the arguments supplied have types appropriate to the format string
6368specified, and that the conversions specified in the format string make
6369sense. This includes standard functions, and others specified by format
6370attributes (@pxref{Function Attributes}), in the @code{printf},
6371@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6372not in the C standard) families (or other target-specific families).
6373Which functions are checked without format attributes having been
6374specified depends on the standard version selected, and such checks of
6375functions without the attribute specified are disabled by
6376@option{-ffreestanding} or @option{-fno-builtin}.
6377
6378The formats are checked against the format features supported by GNU
6379libc version 2.2. These include all ISO C90 and C99 features, as well
6380as features from the Single Unix Specification and some BSD and GNU
6381extensions. Other library implementations may not support all these
6382features; GCC does not support warning about features that go beyond a
6383particular library's limitations. However, if @option{-Wpedantic} is used
6384with @option{-Wformat}, warnings are given about format features not
6385in the selected standard version (but not for @code{strfmon} formats,
6386since those are not in any version of the C standard). @xref{C Dialect
6387Options,,Options Controlling C Dialect}.
6388
6389@table @gcctabopt
6390@item -Wformat=1
6391@itemx -Wformat
6392@opindex Wformat
6393@opindex Wformat=1
6394Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6395@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6396@option{-Wformat} also checks for null format arguments for several
6397functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6398aspects of this level of format checking can be disabled by the
6399options: @option{-Wno-format-contains-nul},
6400@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6401@option{-Wformat} is enabled by @option{-Wall}.
6402
6403@item -Wformat=2
6404@opindex Wformat=2
6405Enable @option{-Wformat} plus additional format checks. Currently
6406equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6407-Wformat-y2k}.
6408@end table
6409
6410@item -Wno-format-contains-nul
6411@opindex Wno-format-contains-nul
6412@opindex Wformat-contains-nul
6413If @option{-Wformat} is specified, do not warn about format strings that
6414contain NUL bytes.
6415
6416@item -Wno-format-extra-args
6417@opindex Wno-format-extra-args
6418@opindex Wformat-extra-args
6419If @option{-Wformat} is specified, do not warn about excess arguments to a
6420@code{printf} or @code{scanf} format function. The C standard specifies
6421that such arguments are ignored.
6422
6423Where the unused arguments lie between used arguments that are
6424specified with @samp{$} operand number specifications, normally
6425warnings are still given, since the implementation could not know what
6426type to pass to @code{va_arg} to skip the unused arguments. However,
6427in the case of @code{scanf} formats, this option suppresses the
6428warning if the unused arguments are all pointers, since the Single
6429Unix Specification says that such unused arguments are allowed.
6430
6431@item -Wformat-overflow
6432@itemx -Wformat-overflow=@var{level}
6433@opindex Wformat-overflow
6434@opindex Wno-format-overflow
6435Warn about calls to formatted input/output functions such as @code{sprintf}
6436and @code{vsprintf} that might overflow the destination buffer. When the
6437exact number of bytes written by a format directive cannot be determined
6438at compile-time it is estimated based on heuristics that depend on the
6439@var{level} argument and on optimization. While enabling optimization
6440will in most cases improve the accuracy of the warning, it may also
6441result in false positives.
6442
6443@table @gcctabopt
6444@item -Wformat-overflow
6445@itemx -Wformat-overflow=1
6446@opindex Wformat-overflow
6447@opindex Wno-format-overflow
6448Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6449employs a conservative approach that warns only about calls that most
6450likely overflow the buffer. At this level, numeric arguments to format
6451directives with unknown values are assumed to have the value of one, and
6452strings of unknown length to be empty. Numeric arguments that are known
6453to be bounded to a subrange of their type, or string arguments whose output
6454is bounded either by their directive's precision or by a finite set of
6455string literals, are assumed to take on the value within the range that
6456results in the most bytes on output. For example, the call to @code{sprintf}
6457below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6458the terminating NUL character (@code{'\0'}) appended by the function
6459to the destination buffer will be written past its end. Increasing
6460the size of the buffer by a single byte is sufficient to avoid the
6461warning, though it may not be sufficient to avoid the overflow.
6462
6463@smallexample
6464void f (int a, int b)
6465@{
6466 char buf [13];
6467 sprintf (buf, "a = %i, b = %i\n", a, b);
6468@}
6469@end smallexample
6470
6471@item -Wformat-overflow=2
6472Level @var{2} warns also about calls that might overflow the destination
6473buffer given an argument of sufficient length or magnitude. At level
6474@var{2}, unknown numeric arguments are assumed to have the minimum
6475representable value for signed types with a precision greater than 1, and
6476the maximum representable value otherwise. Unknown string arguments whose
6477length cannot be assumed to be bounded either by the directive's precision,
6478or by a finite set of string literals they may evaluate to, or the character
6479array they may point to, are assumed to be 1 character long.
6480
6481At level @var{2}, the call in the example above is again diagnosed, but
6482this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6483@code{%i} directive will write some of its digits beyond the end of
6484the destination buffer. To make the call safe regardless of the values
6485of the two variables, the size of the destination buffer must be increased
6486to at least 34 bytes. GCC includes the minimum size of the buffer in
6487an informational note following the warning.
6488
6489An alternative to increasing the size of the destination buffer is to
6490constrain the range of formatted values. The maximum length of string
6491arguments can be bounded by specifying the precision in the format
6492directive. When numeric arguments of format directives can be assumed
6493to be bounded by less than the precision of their type, choosing
6494an appropriate length modifier to the format specifier will reduce
6495the required buffer size. For example, if @var{a} and @var{b} in the
6496example above can be assumed to be within the precision of
6497the @code{short int} type then using either the @code{%hi} format
6498directive or casting the argument to @code{short} reduces the maximum
6499required size of the buffer to 24 bytes.
6500
6501@smallexample
6502void f (int a, int b)
6503@{
6504 char buf [23];
6505 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6506@}
6507@end smallexample
6508@end table
6509
6510@item -Wno-format-zero-length
6511@opindex Wno-format-zero-length
6512@opindex Wformat-zero-length
6513If @option{-Wformat} is specified, do not warn about zero-length formats.
6514The C standard specifies that zero-length formats are allowed.
6515
6516@item -Wformat-nonliteral
6517@opindex Wformat-nonliteral
6518@opindex Wno-format-nonliteral
6519If @option{-Wformat} is specified, also warn if the format string is not a
6520string literal and so cannot be checked, unless the format function
6521takes its format arguments as a @code{va_list}.
6522
6523@item -Wformat-security
6524@opindex Wformat-security
6525@opindex Wno-format-security
6526If @option{-Wformat} is specified, also warn about uses of format
6527functions that represent possible security problems. At present, this
6528warns about calls to @code{printf} and @code{scanf} functions where the
6529format string is not a string literal and there are no format arguments,
6530as in @code{printf (foo);}. This may be a security hole if the format
6531string came from untrusted input and contains @samp{%n}. (This is
6532currently a subset of what @option{-Wformat-nonliteral} warns about, but
6533in future warnings may be added to @option{-Wformat-security} that are not
6534included in @option{-Wformat-nonliteral}.)
6535
6536@item -Wformat-signedness
6537@opindex Wformat-signedness
6538@opindex Wno-format-signedness
6539If @option{-Wformat} is specified, also warn if the format string
6540requires an unsigned argument and the argument is signed and vice versa.
6541
6542@item -Wformat-truncation
6543@itemx -Wformat-truncation=@var{level}
6544@opindex Wformat-truncation
6545@opindex Wno-format-truncation
6546Warn about calls to formatted input/output functions such as @code{snprintf}
6547and @code{vsnprintf} that might result in output truncation. When the exact
6548number of bytes written by a format directive cannot be determined at
6549compile-time it is estimated based on heuristics that depend on
6550the @var{level} argument and on optimization. While enabling optimization
6551will in most cases improve the accuracy of the warning, it may also result
6552in false positives. Except as noted otherwise, the option uses the same
6553logic @option{-Wformat-overflow}.
6554
6555@table @gcctabopt
6556@item -Wformat-truncation
6557@itemx -Wformat-truncation=1
6558@opindex Wformat-truncation
6559@opindex Wno-format-truncation
6560Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6561employs a conservative approach that warns only about calls to bounded
6562functions whose return value is unused and that will most likely result
6563in output truncation.
6564
6565@item -Wformat-truncation=2
6566Level @var{2} warns also about calls to bounded functions whose return
6567value is used and that might result in truncation given an argument of
6568sufficient length or magnitude.
6569@end table
6570
6571@item -Wformat-y2k
6572@opindex Wformat-y2k
6573@opindex Wno-format-y2k
6574If @option{-Wformat} is specified, also warn about @code{strftime}
6575formats that may yield only a two-digit year.
6576
6577@item -Wnonnull
6578@opindex Wnonnull
6579@opindex Wno-nonnull
6580Warn about passing a null pointer for arguments marked as
6581requiring a non-null value by the @code{nonnull} function attribute.
6582
6583@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6584can be disabled with the @option{-Wno-nonnull} option.
6585
6586@item -Wnonnull-compare
6587@opindex Wnonnull-compare
6588@opindex Wno-nonnull-compare
6589Warn when comparing an argument marked with the @code{nonnull}
6590function attribute against null inside the function.
6591
6592@option{-Wnonnull-compare} is included in @option{-Wall}. It
6593can be disabled with the @option{-Wno-nonnull-compare} option.
6594
6595@item -Wnull-dereference
6596@opindex Wnull-dereference
6597@opindex Wno-null-dereference
6598Warn if the compiler detects paths that trigger erroneous or
6599undefined behavior due to dereferencing a null pointer. This option
6600is only active when @option{-fdelete-null-pointer-checks} is active,
6601which is enabled by optimizations in most targets. The precision of
6602the warnings depends on the optimization options used.
6603
6604@item -Winfinite-recursion
6605@opindex Winfinite-recursion
6606@opindex Wno-infinite-recursion
6607Warn about infinitely recursive calls. The warning is effective at all
6608optimization levels but requires optimization in order to detect infinite
6609recursion in calls between two or more functions.
6610@option{-Winfinite-recursion} is included in @option{-Wall}.
6611
ce51e843
ML
6612Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6613similar diagnostic, but is implemented in a different way (as part of
6614@option{-fanalyzer}).
6615
d77de738
ML
6616@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
6617@opindex Winit-self
6618@opindex Wno-init-self
6619Warn about uninitialized variables that are initialized with themselves.
6620Note this option can only be used with the @option{-Wuninitialized} option.
6621
6622For example, GCC warns about @code{i} being uninitialized in the
6623following snippet only when @option{-Winit-self} has been specified:
6624@smallexample
6625@group
6626int f()
6627@{
6628 int i = i;
6629 return i;
6630@}
6631@end group
6632@end smallexample
6633
6634This warning is enabled by @option{-Wall} in C++.
6635
6636@item -Wno-implicit-int @r{(C and Objective-C only)}
6637@opindex Wimplicit-int
6638@opindex Wno-implicit-int
6639This option controls warnings when a declaration does not specify a type.
6640This warning is enabled by default in C99 and later dialects of C,
6641and also by @option{-Wall}.
6642
6643@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
6644@opindex Wimplicit-function-declaration
6645@opindex Wno-implicit-function-declaration
6646This option controls warnings when a function is used before being declared.
6647This warning is enabled by default in C99 and later dialects of C,
6648and also by @option{-Wall}.
6649The warning is made into an error by @option{-pedantic-errors}.
6650
6651@item -Wimplicit @r{(C and Objective-C only)}
6652@opindex Wimplicit
6653@opindex Wno-implicit
6654Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6655This warning is enabled by @option{-Wall}.
6656
6657@item -Wimplicit-fallthrough
6658@opindex Wimplicit-fallthrough
6659@opindex Wno-implicit-fallthrough
6660@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6661and @option{-Wno-implicit-fallthrough} is the same as
6662@option{-Wimplicit-fallthrough=0}.
6663
6664@item -Wimplicit-fallthrough=@var{n}
6665@opindex Wimplicit-fallthrough=
6666Warn when a switch case falls through. For example:
6667
6668@smallexample
6669@group
6670switch (cond)
6671 @{
6672 case 1:
6673 a = 1;
6674 break;
6675 case 2:
6676 a = 2;
6677 case 3:
6678 a = 3;
6679 break;
6680 @}
6681@end group
6682@end smallexample
6683
6684This warning does not warn when the last statement of a case cannot
6685fall through, e.g. when there is a return statement or a call to function
6686declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6687also takes into account control flow statements, such as ifs, and only
6688warns when appropriate. E.g.@:
6689
6690@smallexample
6691@group
6692switch (cond)
6693 @{
6694 case 1:
6695 if (i > 3) @{
6696 bar (5);
6697 break;
6698 @} else if (i < 1) @{
6699 bar (0);
6700 @} else
6701 return;
6702 default:
6703 @dots{}
6704 @}
6705@end group
6706@end smallexample
6707
6708Since there are occasions where a switch case fall through is desirable,
6709GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6710to be used along with a null statement to suppress this warning that
6711would normally occur:
6712
6713@smallexample
6714@group
6715switch (cond)
6716 @{
6717 case 1:
6718 bar (0);
6719 __attribute__ ((fallthrough));
6720 default:
6721 @dots{}
6722 @}
6723@end group
6724@end smallexample
6725
6726C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6727warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6728or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6729Instead of these attributes, it is also possible to add a fallthrough comment
6730to silence the warning. The whole body of the C or C++ style comment should
6731match the given regular expressions listed below. The option argument @var{n}
6732specifies what kind of comments are accepted:
6733
6734@itemize @bullet
6735
6736@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6737
6738@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6739expression, any comment is used as fallthrough comment.
6740
6741@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6742@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6743
6744@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6745following regular expressions:
6746
6747@itemize @bullet
6748
6749@item @code{-fallthrough}
6750
6751@item @code{@@fallthrough@@}
6752
6753@item @code{lint -fallthrough[ \t]*}
6754
6755@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6756
6757@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6758
6759@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6760
6761@end itemize
6762
6763@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6764following regular expressions:
6765
6766@itemize @bullet
6767
6768@item @code{-fallthrough}
6769
6770@item @code{@@fallthrough@@}
6771
6772@item @code{lint -fallthrough[ \t]*}
6773
6774@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6775
6776@end itemize
6777
6778@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6779fallthrough comments, only attributes disable the warning.
6780
6781@end itemize
6782
6783The comment needs to be followed after optional whitespace and other comments
6784by @code{case} or @code{default} keywords or by a user label that precedes some
6785@code{case} or @code{default} label.
6786
6787@smallexample
6788@group
6789switch (cond)
6790 @{
6791 case 1:
6792 bar (0);
6793 /* FALLTHRU */
6794 default:
6795 @dots{}
6796 @}
6797@end group
6798@end smallexample
6799
6800The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6801
6802@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
6803@opindex Wif-not-aligned
6804@opindex Wno-if-not-aligned
6805Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6806should be issued. These warnings are enabled by default.
6807
6808@item -Wignored-qualifiers @r{(C and C++ only)}
6809@opindex Wignored-qualifiers
6810@opindex Wno-ignored-qualifiers
6811Warn if the return type of a function has a type qualifier
6812such as @code{const}. For ISO C such a type qualifier has no effect,
6813since the value returned by a function is not an lvalue.
6814For C++, the warning is only emitted for scalar types or @code{void}.
6815ISO C prohibits qualified @code{void} return types on function
6816definitions, so such return types always receive a warning
6817even without this option.
6818
6819This warning is also enabled by @option{-Wextra}.
6820
6821@item -Wno-ignored-attributes @r{(C and C++ only)}
6822@opindex Wignored-attributes
6823@opindex Wno-ignored-attributes
6824This option controls warnings when an attribute is ignored.
6825This is different from the
6826@option{-Wattributes} option in that it warns whenever the compiler decides
6827to drop an attribute, not that the attribute is either unknown, used in a
6828wrong place, etc. This warning is enabled by default.
6829
6830@item -Wmain
6831@opindex Wmain
6832@opindex Wno-main
6833Warn if the type of @code{main} is suspicious. @code{main} should be
6834a function with external linkage, returning int, taking either zero
6835arguments, two, or three arguments of appropriate types. This warning
6836is enabled by default in C++ and is enabled by either @option{-Wall}
6837or @option{-Wpedantic}.
6838
6839@item -Wmisleading-indentation @r{(C and C++ only)}
6840@opindex Wmisleading-indentation
6841@opindex Wno-misleading-indentation
6842Warn when the indentation of the code does not reflect the block structure.
6843Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6844@code{for} clauses with a guarded statement that does not use braces,
6845followed by an unguarded statement with the same indentation.
6846
6847In the following example, the call to ``bar'' is misleadingly indented as
6848if it were guarded by the ``if'' conditional.
6849
6850@smallexample
6851 if (some_condition ())
6852 foo ();
6853 bar (); /* Gotcha: this is not guarded by the "if". */
6854@end smallexample
6855
6856In the case of mixed tabs and spaces, the warning uses the
6857@option{-ftabstop=} option to determine if the statements line up
6858(defaulting to 8).
6859
6860The warning is not issued for code involving multiline preprocessor logic
6861such as the following example.
6862
6863@smallexample
6864 if (flagA)
6865 foo (0);
6866#if SOME_CONDITION_THAT_DOES_NOT_HOLD
6867 if (flagB)
6868#endif
6869 foo (1);
6870@end smallexample
6871
6872The warning is not issued after a @code{#line} directive, since this
6873typically indicates autogenerated code, and no assumptions can be made
6874about the layout of the file that the directive references.
6875
6876This warning is enabled by @option{-Wall} in C and C++.
6877
6878@item -Wmissing-attributes
6879@opindex Wmissing-attributes
6880@opindex Wno-missing-attributes
6881Warn when a declaration of a function is missing one or more attributes
6882that a related function is declared with and whose absence may adversely
6883affect the correctness or efficiency of generated code. For example,
6884the warning is issued for declarations of aliases that use attributes
6885to specify less restrictive requirements than those of their targets.
6886This typically represents a potential optimization opportunity.
6887By contrast, the @option{-Wattribute-alias=2} option controls warnings
6888issued when the alias is more restrictive than the target, which could
6889lead to incorrect code generation.
6890Attributes considered include @code{alloc_align}, @code{alloc_size},
6891@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6892@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6893@code{returns_nonnull}, and @code{returns_twice}.
6894
6895In C++, the warning is issued when an explicit specialization of a primary
6896template declared with attribute @code{alloc_align}, @code{alloc_size},
6897@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6898or @code{nonnull} is declared without it. Attributes @code{deprecated},
6899@code{error}, and @code{warning} suppress the warning.
6900(@pxref{Function Attributes}).
6901
6902You can use the @code{copy} attribute to apply the same
6903set of attributes to a declaration as that on another declaration without
6904explicitly enumerating the attributes. This attribute can be applied
6905to declarations of functions (@pxref{Common Function Attributes}),
6906variables (@pxref{Common Variable Attributes}), or types
6907(@pxref{Common Type Attributes}).
6908
6909@option{-Wmissing-attributes} is enabled by @option{-Wall}.
6910
6911For example, since the declaration of the primary function template
6912below makes use of both attribute @code{malloc} and @code{alloc_size}
6913the declaration of the explicit specialization of the template is
6914diagnosed because it is missing one of the attributes.
6915
6916@smallexample
6917template <class T>
6918T* __attribute__ ((malloc, alloc_size (1)))
6919allocate (size_t);
6920
6921template <>
6922void* __attribute__ ((malloc)) // missing alloc_size
6923allocate<void> (size_t);
6924@end smallexample
6925
6926@item -Wmissing-braces
6927@opindex Wmissing-braces
6928@opindex Wno-missing-braces
6929Warn if an aggregate or union initializer is not fully bracketed. In
6930the following example, the initializer for @code{a} is not fully
6931bracketed, but that for @code{b} is fully bracketed.
6932
6933@smallexample
6934int a[2][2] = @{ 0, 1, 2, 3 @};
6935int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
6936@end smallexample
6937
6938This warning is enabled by @option{-Wall}.
6939
6940@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
6941@opindex Wmissing-include-dirs
6942@opindex Wno-missing-include-dirs
6943Warn if a user-supplied include directory does not exist. This opions is disabled
6944by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
6945enabled by default by warning for -I and -J, only.
6946
6947@item -Wno-missing-profile
6948@opindex Wmissing-profile
6949@opindex Wno-missing-profile
6950This option controls warnings if feedback profiles are missing when using the
6951@option{-fprofile-use} option.
6952This option diagnoses those cases where a new function or a new file is added
6953between compiling with @option{-fprofile-generate} and with
6954@option{-fprofile-use}, without regenerating the profiles.
6955In these cases, the profile feedback data files do not contain any
6956profile feedback information for
6957the newly added function or file respectively. Also, in the case when profile
6958count data (.gcda) files are removed, GCC cannot use any profile feedback
6959information. In all these cases, warnings are issued to inform you that a
6960profile generation step is due.
6961Ignoring the warning can result in poorly optimized code.
6962@option{-Wno-missing-profile} can be used to
6963disable the warning, but this is not recommended and should be done only
6964when non-existent profile data is justified.
6965
6966@item -Wmismatched-dealloc
6967@opindex Wmismatched-dealloc
6968@opindex Wno-mismatched-dealloc
6969
6970Warn for calls to deallocation functions with pointer arguments returned
6971from from allocations functions for which the former isn't a suitable
6972deallocator. A pair of functions can be associated as matching allocators
6973and deallocators by use of attribute @code{malloc}. Unless disabled by
6974the @option{-fno-builtin} option the standard functions @code{calloc},
6975@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
6976forms of C++ @code{operator new} and @code{operator delete} are implicitly
6977associated as matching allocators and deallocators. In the following
6978example @code{mydealloc} is the deallocator for pointers returned from
6979@code{myalloc}.
6980
6981@smallexample
6982void mydealloc (void*);
6983
6984__attribute__ ((malloc (mydealloc, 1))) void*
6985myalloc (size_t);
6986
6987void f (void)
6988@{
6989 void *p = myalloc (32);
6990 // @dots{}use p@dots{}
6991 free (p); // warning: not a matching deallocator for myalloc
6992 mydealloc (p); // ok
6993@}
6994@end smallexample
6995
6996In C++, the related option @option{-Wmismatched-new-delete} diagnoses
6997mismatches involving either @code{operator new} or @code{operator delete}.
6998
6999Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7000
7001@item -Wmultistatement-macros
7002@opindex Wmultistatement-macros
7003@opindex Wno-multistatement-macros
7004Warn about unsafe multiple statement macros that appear to be guarded
7005by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7006@code{while}, in which only the first statement is actually guarded after
7007the macro is expanded.
7008
7009For example:
7010
7011@smallexample
7012#define DOIT x++; y++
7013if (c)
7014 DOIT;
7015@end smallexample
7016
7017will increment @code{y} unconditionally, not just when @code{c} holds.
7018The can usually be fixed by wrapping the macro in a do-while loop:
7019@smallexample
7020#define DOIT do @{ x++; y++; @} while (0)
7021if (c)
7022 DOIT;
7023@end smallexample
7024
7025This warning is enabled by @option{-Wall} in C and C++.
7026
7027@item -Wparentheses
7028@opindex Wparentheses
7029@opindex Wno-parentheses
7030Warn if parentheses are omitted in certain contexts, such
7031as when there is an assignment in a context where a truth value
7032is expected, or when operators are nested whose precedence people
7033often get confused about.
7034
7035Also warn if a comparison like @code{x<=y<=z} appears; this is
7036equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7037interpretation from that of ordinary mathematical notation.
7038
7039Also warn for dangerous uses of the GNU extension to
7040@code{?:} with omitted middle operand. When the condition
7041in the @code{?}: operator is a boolean expression, the omitted value is
7042always 1. Often programmers expect it to be a value computed
7043inside the conditional expression instead.
7044
7045For C++ this also warns for some cases of unnecessary parentheses in
7046declarations, which can indicate an attempt at a function call instead
7047of a declaration:
7048@smallexample
7049@{
7050 // Declares a local variable called mymutex.
7051 std::unique_lock<std::mutex> (mymutex);
7052 // User meant std::unique_lock<std::mutex> lock (mymutex);
7053@}
7054@end smallexample
7055
7056This warning is enabled by @option{-Wall}.
7057
7058@item -Wno-self-move @r{(C++ and Objective-C++ only)}
7059@opindex Wself-move
7060@opindex Wno-self-move
7061This warning warns when a value is moved to itself with @code{std::move}.
7062Such a @code{std::move} typically has no effect.
7063
7064@smallexample
7065struct T @{
7066@dots{}
7067@};
7068void fn()
7069@{
7070 T t;
7071 @dots{}
7072 t = std::move (t);
7073@}
7074@end smallexample
7075
7076This warning is enabled by @option{-Wall}.
7077
7078@item -Wsequence-point
7079@opindex Wsequence-point
7080@opindex Wno-sequence-point
7081Warn about code that may have undefined semantics because of violations
7082of sequence point rules in the C and C++ standards.
7083
7084The C and C++ standards define the order in which expressions in a C/C++
7085program are evaluated in terms of @dfn{sequence points}, which represent
7086a partial ordering between the execution of parts of the program: those
7087executed before the sequence point, and those executed after it. These
7088occur after the evaluation of a full expression (one which is not part
7089of a larger expression), after the evaluation of the first operand of a
7090@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7091function is called (but after the evaluation of its arguments and the
7092expression denoting the called function), and in certain other places.
7093Other than as expressed by the sequence point rules, the order of
7094evaluation of subexpressions of an expression is not specified. All
7095these rules describe only a partial order rather than a total order,
7096since, for example, if two functions are called within one expression
7097with no sequence point between them, the order in which the functions
7098are called is not specified. However, the standards committee have
7099ruled that function calls do not overlap.
7100
7101It is not specified when between sequence points modifications to the
7102values of objects take effect. Programs whose behavior depends on this
7103have undefined behavior; the C and C++ standards specify that ``Between
7104the previous and next sequence point an object shall have its stored
7105value modified at most once by the evaluation of an expression.
7106Furthermore, the prior value shall be read only to determine the value
7107to be stored.''. If a program breaks these rules, the results on any
7108particular implementation are entirely unpredictable.
7109
7110Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7111= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7112diagnosed by this option, and it may give an occasional false positive
7113result, but in general it has been found fairly effective at detecting
7114this sort of problem in programs.
7115
7116The C++17 standard will define the order of evaluation of operands in
7117more cases: in particular it requires that the right-hand side of an
7118assignment be evaluated before the left-hand side, so the above
7119examples are no longer undefined. But this option will still warn
7120about them, to help people avoid writing code that is undefined in C
7121and earlier revisions of C++.
7122
7123The standard is worded confusingly, therefore there is some debate
7124over the precise meaning of the sequence point rules in subtle cases.
7125Links to discussions of the problem, including proposed formal
7126definitions, may be found on the GCC readings page, at
7127@uref{https://gcc.gnu.org/@/readings.html}.
7128
7129This warning is enabled by @option{-Wall} for C and C++.
7130
7131@item -Wno-return-local-addr
7132@opindex Wno-return-local-addr
7133@opindex Wreturn-local-addr
7134Do not warn about returning a pointer (or in C++, a reference) to a
7135variable that goes out of scope after the function returns.
7136
7137@item -Wreturn-type
7138@opindex Wreturn-type
7139@opindex Wno-return-type
7140Warn whenever a function is defined with a return type that defaults
7141to @code{int}. Also warn about any @code{return} statement with no
7142return value in a function whose return type is not @code{void}
7143(falling off the end of the function body is considered returning
7144without a value).
7145
7146For C only, warn about a @code{return} statement with an expression in a
7147function whose return type is @code{void}, unless the expression type is
7148also @code{void}. As a GNU extension, the latter case is accepted
7149without a warning unless @option{-Wpedantic} is used. Attempting
7150to use the return value of a non-@code{void} function other than @code{main}
7151that flows off the end by reaching the closing curly brace that terminates
7152the function is undefined.
7153
7154Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7155than @code{main} results in undefined behavior even when the value of
7156the function is not used.
7157
7158This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7159
7160@item -Wno-shift-count-negative
7161@opindex Wshift-count-negative
7162@opindex Wno-shift-count-negative
7163Controls warnings if a shift count is negative.
7164This warning is enabled by default.
7165
7166@item -Wno-shift-count-overflow
7167@opindex Wshift-count-overflow
7168@opindex Wno-shift-count-overflow
7169Controls warnings if a shift count is greater than or equal to the bit width
7170of the type. This warning is enabled by default.
7171
7172@item -Wshift-negative-value
7173@opindex Wshift-negative-value
7174@opindex Wno-shift-negative-value
7175Warn if left shifting a negative value. This warning is enabled by
7176@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7177
7178@item -Wno-shift-overflow
7179@itemx -Wshift-overflow=@var{n}
7180@opindex Wshift-overflow
7181@opindex Wno-shift-overflow
7182These options control warnings about left shift overflows.
7183
7184@table @gcctabopt
7185@item -Wshift-overflow=1
7186This is the warning level of @option{-Wshift-overflow} and is enabled
7187by default in C99 and C++11 modes (and newer). This warning level does
7188not warn about left-shifting 1 into the sign bit. (However, in C, such
7189an overflow is still rejected in contexts where an integer constant expression
7190is required.) No warning is emitted in C++20 mode (and newer), as signed left
7191shifts always wrap.
7192
7193@item -Wshift-overflow=2
7194This warning level also warns about left-shifting 1 into the sign bit,
7195unless C++14 mode (or newer) is active.
7196@end table
7197
7198@item -Wswitch
7199@opindex Wswitch
7200@opindex Wno-switch
7201Warn whenever a @code{switch} statement has an index of enumerated type
7202and lacks a @code{case} for one or more of the named codes of that
7203enumeration. (The presence of a @code{default} label prevents this
7204warning.) @code{case} labels outside the enumeration range also
7205provoke warnings when this option is used (even if there is a
7206@code{default} label).
7207This warning is enabled by @option{-Wall}.
7208
7209@item -Wswitch-default
7210@opindex Wswitch-default
7211@opindex Wno-switch-default
7212Warn whenever a @code{switch} statement does not have a @code{default}
7213case.
7214
7215@item -Wswitch-enum
7216@opindex Wswitch-enum
7217@opindex Wno-switch-enum
7218Warn whenever a @code{switch} statement has an index of enumerated type
7219and lacks a @code{case} for one or more of the named codes of that
7220enumeration. @code{case} labels outside the enumeration range also
7221provoke warnings when this option is used. The only difference
7222between @option{-Wswitch} and this option is that this option gives a
7223warning about an omitted enumeration code even if there is a
7224@code{default} label.
7225
7226@item -Wno-switch-bool
7227@opindex Wswitch-bool
7228@opindex Wno-switch-bool
7229Do not warn when a @code{switch} statement has an index of boolean type
7230and the case values are outside the range of a boolean type.
7231It is possible to suppress this warning by casting the controlling
7232expression to a type other than @code{bool}. For example:
7233@smallexample
7234@group
7235switch ((int) (a == 4))
7236 @{
7237 @dots{}
7238 @}
7239@end group
7240@end smallexample
7241This warning is enabled by default for C and C++ programs.
7242
7243@item -Wno-switch-outside-range
7244@opindex Wswitch-outside-range
7245@opindex Wno-switch-outside-range
7246This option controls warnings when a @code{switch} case has a value
7247that is outside of its
7248respective type range. This warning is enabled by default for
7249C and C++ programs.
7250
7251@item -Wno-switch-unreachable
7252@opindex Wswitch-unreachable
7253@opindex Wno-switch-unreachable
7254Do not warn when a @code{switch} statement contains statements between the
7255controlling expression and the first case label, which will never be
7256executed. For example:
7257@smallexample
7258@group
7259switch (cond)
7260 @{
7261 i = 15;
7262 @dots{}
7263 case 5:
7264 @dots{}
7265 @}
7266@end group
7267@end smallexample
7268@option{-Wswitch-unreachable} does not warn if the statement between the
7269controlling expression and the first case label is just a declaration:
7270@smallexample
7271@group
7272switch (cond)
7273 @{
7274 int i;
7275 @dots{}
7276 case 5:
7277 i = 5;
7278 @dots{}
7279 @}
7280@end group
7281@end smallexample
7282This warning is enabled by default for C and C++ programs.
7283
7284@item -Wsync-nand @r{(C and C++ only)}
7285@opindex Wsync-nand
7286@opindex Wno-sync-nand
7287Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7288built-in functions are used. These functions changed semantics in GCC 4.4.
7289
7290@item -Wtrivial-auto-var-init
7291@opindex Wtrivial-auto-var-init
7292@opindex Wno-trivial-auto-var-init
7293Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7294variable. A common situation is an automatic variable that is declared
7295between the controlling expression and the first case label of a @code{switch}
7296statement.
7297
7298@item -Wunused-but-set-parameter
7299@opindex Wunused-but-set-parameter
7300@opindex Wno-unused-but-set-parameter
7301Warn whenever a function parameter is assigned to, but otherwise unused
7302(aside from its declaration).
7303
7304To suppress this warning use the @code{unused} attribute
7305(@pxref{Variable Attributes}).
7306
7307This warning is also enabled by @option{-Wunused} together with
7308@option{-Wextra}.
7309
7310@item -Wunused-but-set-variable
7311@opindex Wunused-but-set-variable
7312@opindex Wno-unused-but-set-variable
7313Warn whenever a local variable is assigned to, but otherwise unused
7314(aside from its declaration).
7315This warning is enabled by @option{-Wall}.
7316
7317To suppress this warning use the @code{unused} attribute
7318(@pxref{Variable Attributes}).
7319
7320This warning is also enabled by @option{-Wunused}, which is enabled
7321by @option{-Wall}.
7322
7323@item -Wunused-function
7324@opindex Wunused-function
7325@opindex Wno-unused-function
7326Warn whenever a static function is declared but not defined or a
7327non-inline static function is unused.
7328This warning is enabled by @option{-Wall}.
7329
7330@item -Wunused-label
7331@opindex Wunused-label
7332@opindex Wno-unused-label
7333Warn whenever a label is declared but not used.
7334This warning is enabled by @option{-Wall}.
7335
7336To suppress this warning use the @code{unused} attribute
7337(@pxref{Variable Attributes}).
7338
7339@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
7340@opindex Wunused-local-typedefs
7341@opindex Wno-unused-local-typedefs
7342Warn when a typedef locally defined in a function is not used.
7343This warning is enabled by @option{-Wall}.
7344
7345@item -Wunused-parameter
7346@opindex Wunused-parameter
7347@opindex Wno-unused-parameter
7348Warn whenever a function parameter is unused aside from its declaration.
7349
7350To suppress this warning use the @code{unused} attribute
7351(@pxref{Variable Attributes}).
7352
7353@item -Wno-unused-result
7354@opindex Wunused-result
7355@opindex Wno-unused-result
7356Do not warn if a caller of a function marked with attribute
7357@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7358its return value. The default is @option{-Wunused-result}.
7359
7360@item -Wunused-variable
7361@opindex Wunused-variable
7362@opindex Wno-unused-variable
7363Warn whenever a local or static variable is unused aside from its
7364declaration. This option implies @option{-Wunused-const-variable=1} for C,
7365but not for C++. This warning is enabled by @option{-Wall}.
7366
7367To suppress this warning use the @code{unused} attribute
7368(@pxref{Variable Attributes}).
7369
7370@item -Wunused-const-variable
7371@itemx -Wunused-const-variable=@var{n}
7372@opindex Wunused-const-variable
7373@opindex Wno-unused-const-variable
7374Warn whenever a constant static variable is unused aside from its declaration.
7375@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7376for C, but not for C++. In C this declares variable storage, but in C++ this
7377is not an error since const variables take the place of @code{#define}s.
7378
7379To suppress this warning use the @code{unused} attribute
7380(@pxref{Variable Attributes}).
7381
7382@table @gcctabopt
7383@item -Wunused-const-variable=1
7384This is the warning level that is enabled by @option{-Wunused-variable} for
7385C. It warns only about unused static const variables defined in the main
7386compilation unit, but not about static const variables declared in any
7387header included.
7388
7389@item -Wunused-const-variable=2
7390This warning level also warns for unused constant static variables in
7391headers (excluding system headers). This is the warning level of
7392@option{-Wunused-const-variable} and must be explicitly requested since
7393in C++ this isn't an error and in C it might be harder to clean up all
7394headers included.
7395@end table
7396
7397@item -Wunused-value
7398@opindex Wunused-value
7399@opindex Wno-unused-value
7400Warn whenever a statement computes a result that is explicitly not
7401used. To suppress this warning cast the unused expression to
7402@code{void}. This includes an expression-statement or the left-hand
7403side of a comma expression that contains no side effects. For example,
7404an expression such as @code{x[i,j]} causes a warning, while
7405@code{x[(void)i,j]} does not.
7406
7407This warning is enabled by @option{-Wall}.
7408
7409@item -Wunused
7410@opindex Wunused
7411@opindex Wno-unused
7412All the above @option{-Wunused} options combined.
7413
7414In order to get a warning about an unused function parameter, you must
7415either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7416@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7417
7418@item -Wuninitialized
7419@opindex Wuninitialized
7420@opindex Wno-uninitialized
7421Warn if an object with automatic or allocated storage duration is used
7422without having been initialized. In C++, also warn if a non-static
7423reference or non-static @code{const} member appears in a class without
7424constructors.
7425
7426In addition, passing a pointer (or in C++, a reference) to an uninitialized
7427object to a @code{const}-qualified argument of a built-in function known to
7428read the object is also diagnosed by this warning.
7429(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7430
7431If you want to warn about code that uses the uninitialized value of the
7432variable in its own initializer, use the @option{-Winit-self} option.
7433
7434These warnings occur for individual uninitialized elements of
7435structure, union or array variables as well as for variables that are
7436uninitialized as a whole. They do not occur for variables or elements
7437declared @code{volatile}. Because these warnings depend on
7438optimization, the exact variables or elements for which there are
7439warnings depend on the precise optimization options and version of GCC
7440used.
7441
7442Note that there may be no warning about a variable that is used only
7443to compute a value that itself is never used, because such
7444computations may be deleted by data flow analysis before the warnings
7445are printed.
7446
7447In C++, this warning also warns about using uninitialized objects in
7448member-initializer-lists. For example, GCC warns about @code{b} being
7449uninitialized in the following snippet:
7450
7451@smallexample
7452struct A @{
7453 int a;
7454 int b;
7455 A() : a(b) @{ @}
7456@};
7457@end smallexample
7458
7459@item -Wno-invalid-memory-model
7460@opindex Winvalid-memory-model
7461@opindex Wno-invalid-memory-model
7462This option controls warnings
7463for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7464and the C11 atomic generic functions with a memory consistency argument
7465that is either invalid for the operation or outside the range of values
7466of the @code{memory_order} enumeration. For example, since the
7467@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7468defined for the relaxed, release, and sequentially consistent memory
7469orders the following code is diagnosed:
7470
7471@smallexample
7472void store (int *i)
7473@{
7474 __atomic_store_n (i, 0, memory_order_consume);
7475@}
7476@end smallexample
7477
7478@option{-Winvalid-memory-model} is enabled by default.
7479
7480@item -Wmaybe-uninitialized
7481@opindex Wmaybe-uninitialized
7482@opindex Wno-maybe-uninitialized
7483For an object with automatic or allocated storage duration, if there exists
7484a path from the function entry to a use of the object that is initialized,
7485but there exist some other paths for which the object is not initialized,
7486the compiler emits a warning if it cannot prove the uninitialized paths
7487are not executed at run time.
7488
7489In addition, passing a pointer (or in C++, a reference) to an uninitialized
7490object to a @code{const}-qualified function argument is also diagnosed by
7491this warning. (@option{-Wuninitialized} is issued for built-in functions
7492known to read the object.) Annotating the function with attribute
7493@code{access (none)} indicates that the argument isn't used to access
7494the object and avoids the warning (@pxref{Common Function Attributes}).
7495
7496These warnings are only possible in optimizing compilation, because otherwise
7497GCC does not keep track of the state of variables.
7498
7499These warnings are made optional because GCC may not be able to determine when
7500the code is correct in spite of appearing to have an error. Here is one
7501example of how this can happen:
7502
7503@smallexample
7504@group
7505@{
7506 int x;
7507 switch (y)
7508 @{
7509 case 1: x = 1;
7510 break;
7511 case 2: x = 4;
7512 break;
7513 case 3: x = 5;
7514 @}
7515 foo (x);
7516@}
7517@end group
7518@end smallexample
7519
7520@noindent
7521If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7522always initialized, but GCC doesn't know this. To suppress the
7523warning, you need to provide a default case with assert(0) or
7524similar code.
7525
7526@cindex @code{longjmp} warnings
7527This option also warns when a non-volatile automatic variable might be
7528changed by a call to @code{longjmp}.
7529The compiler sees only the calls to @code{setjmp}. It cannot know
7530where @code{longjmp} will be called; in fact, a signal handler could
7531call it at any point in the code. As a result, you may get a warning
7532even when there is in fact no problem because @code{longjmp} cannot
7533in fact be called at the place that would cause a problem.
7534
7535Some spurious warnings can be avoided if you declare all the functions
7536you use that never return as @code{noreturn}. @xref{Function
7537Attributes}.
7538
7539This warning is enabled by @option{-Wall} or @option{-Wextra}.
7540
7541@item -Wunknown-pragmas
7542@opindex Wunknown-pragmas
7543@opindex Wno-unknown-pragmas
7544@cindex warning for unknown pragmas
7545@cindex unknown pragmas, warning
7546@cindex pragmas, warning of unknown
7547Warn when a @code{#pragma} directive is encountered that is not understood by
7548GCC@. If this command-line option is used, warnings are even issued
7549for unknown pragmas in system header files. This is not the case if
7550the warnings are only enabled by the @option{-Wall} command-line option.
7551
7552@item -Wno-pragmas
7553@opindex Wno-pragmas
7554@opindex Wpragmas
7555Do not warn about misuses of pragmas, such as incorrect parameters,
7556invalid syntax, or conflicts between pragmas. See also
7557@option{-Wunknown-pragmas}.
7558
7559@item -Wno-prio-ctor-dtor
7560@opindex Wno-prio-ctor-dtor
7561@opindex Wprio-ctor-dtor
7562Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7563The use of constructor and destructor attributes allow you to assign a
7564priority to the constructor/destructor to control its order of execution
7565before @code{main} is called or after it returns. The priority values must be
7566greater than 100 as the compiler reserves priority values between 0--100 for
7567the implementation.
7568
7569@item -Wstrict-aliasing
7570@opindex Wstrict-aliasing
7571@opindex Wno-strict-aliasing
7572This option is only active when @option{-fstrict-aliasing} is active.
7573It warns about code that might break the strict aliasing rules that the
7574compiler is using for optimization. The warning does not catch all
7575cases, but does attempt to catch the more common pitfalls. It is
7576included in @option{-Wall}.
7577It is equivalent to @option{-Wstrict-aliasing=3}
7578
7579@item -Wstrict-aliasing=n
7580@opindex Wstrict-aliasing=n
7581This option is only active when @option{-fstrict-aliasing} is active.
7582It warns about code that might break the strict aliasing rules that the
7583compiler is using for optimization.
7584Higher levels correspond to higher accuracy (fewer false positives).
7585Higher levels also correspond to more effort, similar to the way @option{-O}
7586works.
7587@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7588
7589Level 1: Most aggressive, quick, least accurate.
7590Possibly useful when higher levels
7591do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7592false negatives. However, it has many false positives.
7593Warns for all pointer conversions between possibly incompatible types,
7594even if never dereferenced. Runs in the front end only.
7595
7596Level 2: Aggressive, quick, not too precise.
7597May still have many false positives (not as many as level 1 though),
7598and few false negatives (but possibly more than level 1).
7599Unlike level 1, it only warns when an address is taken. Warns about
7600incomplete types. Runs in the front end only.
7601
7602Level 3 (default for @option{-Wstrict-aliasing}):
7603Should have very few false positives and few false
7604negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7605Takes care of the common pun+dereference pattern in the front end:
7606@code{*(int*)&some_float}.
7607If optimization is enabled, it also runs in the back end, where it deals
7608with multiple statement cases using flow-sensitive points-to information.
7609Only warns when the converted pointer is dereferenced.
7610Does not warn about incomplete types.
7611
7612@item -Wstrict-overflow
7613@itemx -Wstrict-overflow=@var{n}
7614@opindex Wstrict-overflow
7615@opindex Wno-strict-overflow
7616This option is only active when signed overflow is undefined.
7617It warns about cases where the compiler optimizes based on the
7618assumption that signed overflow does not occur. Note that it does not
7619warn about all cases where the code might overflow: it only warns
7620about cases where the compiler implements some optimization. Thus
7621this warning depends on the optimization level.
7622
7623An optimization that assumes that signed overflow does not occur is
7624perfectly safe if the values of the variables involved are such that
7625overflow never does, in fact, occur. Therefore this warning can
7626easily give a false positive: a warning about code that is not
7627actually a problem. To help focus on important issues, several
7628warning levels are defined. No warnings are issued for the use of
7629undefined signed overflow when estimating how many iterations a loop
7630requires, in particular when determining whether a loop will be
7631executed at all.
7632
7633@table @gcctabopt
7634@item -Wstrict-overflow=1
7635Warn about cases that are both questionable and easy to avoid. For
7636example the compiler simplifies
7637@code{x + 1 > x} to @code{1}. This level of
7638@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7639are not, and must be explicitly requested.
7640
7641@item -Wstrict-overflow=2
7642Also warn about other cases where a comparison is simplified to a
7643constant. For example: @code{abs (x) >= 0}. This can only be
7644simplified when signed integer overflow is undefined, because
7645@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7646zero. @option{-Wstrict-overflow} (with no level) is the same as
7647@option{-Wstrict-overflow=2}.
7648
7649@item -Wstrict-overflow=3
7650Also warn about other cases where a comparison is simplified. For
7651example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7652
7653@item -Wstrict-overflow=4
7654Also warn about other simplifications not covered by the above cases.
7655For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7656
7657@item -Wstrict-overflow=5
7658Also warn about cases where the compiler reduces the magnitude of a
7659constant involved in a comparison. For example: @code{x + 2 > y} is
7660simplified to @code{x + 1 >= y}. This is reported only at the
7661highest warning level because this simplification applies to many
7662comparisons, so this warning level gives a very large number of
7663false positives.
7664@end table
7665
7666@item -Wstring-compare
7667@opindex Wstring-compare
7668@opindex Wno-string-compare
7669Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7670determined to be either zero or non-zero in tests for such equality
7671owing to the length of one argument being greater than the size of
7672the array the other argument is stored in (or the bound in the case
7673of @code{strncmp}). Such calls could be mistakes. For example,
7674the call to @code{strcmp} below is diagnosed because its result is
7675necessarily non-zero irrespective of the contents of the array @code{a}.
7676
7677@smallexample
7678extern char a[4];
7679void f (char *d)
7680@{
7681 strcpy (d, "string");
7682 @dots{}
7683 if (0 == strcmp (a, d)) // cannot be true
7684 puts ("a and d are the same");
7685@}
7686@end smallexample
7687
7688@option{-Wstring-compare} is enabled by @option{-Wextra}.
7689
7690@item -Wno-stringop-overflow
7691@item -Wstringop-overflow
7692@itemx -Wstringop-overflow=@var{type}
7693@opindex Wstringop-overflow
7694@opindex Wno-stringop-overflow
7695Warn for calls to string manipulation functions such as @code{memcpy} and
7696@code{strcpy} that are determined to overflow the destination buffer. The
7697optional argument is one greater than the type of Object Size Checking to
7698perform to determine the size of the destination. @xref{Object Size Checking}.
7699The argument is meaningful only for functions that operate on character arrays
7700but not for raw memory functions like @code{memcpy} which always make use
7701of Object Size type-0. The option also warns for calls that specify a size
7702in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7703The option produces the best results with optimization enabled but can detect
7704a small subset of simple buffer overflows even without optimization in
7705calls to the GCC built-in functions like @code{__builtin_memcpy} that
7706correspond to the standard functions. In any case, the option warns about
7707just a subset of buffer overflows detected by the corresponding overflow
7708checking built-ins. For example, the option issues a warning for
7709the @code{strcpy} call below because it copies at least 5 characters
7710(the string @code{"blue"} including the terminating NUL) into the buffer
7711of size 4.
7712
7713@smallexample
7714enum Color @{ blue, purple, yellow @};
7715const char* f (enum Color clr)
7716@{
7717 static char buf [4];
7718 const char *str;
7719 switch (clr)
7720 @{
7721 case blue: str = "blue"; break;
7722 case purple: str = "purple"; break;
7723 case yellow: str = "yellow"; break;
7724 @}
7725
7726 return strcpy (buf, str); // warning here
7727@}
7728@end smallexample
7729
7730Option @option{-Wstringop-overflow=2} is enabled by default.
7731
7732@table @gcctabopt
7733@item -Wstringop-overflow
7734@itemx -Wstringop-overflow=1
7735@opindex Wstringop-overflow
7736@opindex Wno-stringop-overflow
7737The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7738to determine the sizes of destination objects. At this setting the option
7739does not warn for writes past the end of subobjects of larger objects accessed
7740by pointers unless the size of the largest surrounding object is known. When
7741the destination may be one of several objects it is assumed to be the largest
7742one of them. On Linux systems, when optimization is enabled at this setting
7743the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7744is defined to a non-zero value.
7745
7746@item -Wstringop-overflow=2
7747The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7748to determine the sizes of destination objects. At this setting the option
7749warns about overflows when writing to members of the largest complete
7750objects whose exact size is known. However, it does not warn for excessive
7751writes to the same members of unknown objects referenced by pointers since
7752they may point to arrays containing unknown numbers of elements. This is
7753the default setting of the option.
7754
7755@item -Wstringop-overflow=3
7756The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7757to determine the sizes of destination objects. At this setting the option
7758warns about overflowing the smallest object or data member. This is the
7759most restrictive setting of the option that may result in warnings for safe
7760code.
7761
7762@item -Wstringop-overflow=4
7763The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7764to determine the sizes of destination objects. At this setting the option
7765warns about overflowing any data members, and when the destination is
7766one of several objects it uses the size of the largest of them to decide
7767whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7768setting of the option may result in warnings for benign code.
7769@end table
7770
7771@item -Wno-stringop-overread
7772@opindex Wstringop-overread
7773@opindex Wno-stringop-overread
7774Warn for calls to string manipulation functions such as @code{memchr}, or
7775@code{strcpy} that are determined to read past the end of the source
7776sequence.
7777
7778Option @option{-Wstringop-overread} is enabled by default.
7779
7780@item -Wno-stringop-truncation
7781@opindex Wstringop-truncation
7782@opindex Wno-stringop-truncation
7783Do not warn for calls to bounded string manipulation functions
7784such as @code{strncat},
7785@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7786or leave the destination unchanged.
7787
7788In the following example, the call to @code{strncat} specifies a bound that
7789is less than the length of the source string. As a result, the copy of
7790the source will be truncated and so the call is diagnosed. To avoid the
7791warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7792
7793@smallexample
7794void append (char *buf, size_t bufsize)
7795@{
7796 strncat (buf, ".txt", 3);
7797@}
7798@end smallexample
7799
7800As another example, the following call to @code{strncpy} results in copying
7801to @code{d} just the characters preceding the terminating NUL, without
7802appending the NUL to the end. Assuming the result of @code{strncpy} is
7803necessarily a NUL-terminated string is a common mistake, and so the call
7804is diagnosed. To avoid the warning when the result is not expected to be
7805NUL-terminated, call @code{memcpy} instead.
7806
7807@smallexample
7808void copy (char *d, const char *s)
7809@{
7810 strncpy (d, s, strlen (s));
7811@}
7812@end smallexample
7813
7814In the following example, the call to @code{strncpy} specifies the size
7815of the destination buffer as the bound. If the length of the source
7816string is equal to or greater than this size the result of the copy will
7817not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7818the warning, specify @code{sizeof buf - 1} as the bound and set the last
7819element of the buffer to @code{NUL}.
7820
7821@smallexample
7822void copy (const char *s)
7823@{
7824 char buf[80];
7825 strncpy (buf, s, sizeof buf);
7826 @dots{}
7827@}
7828@end smallexample
7829
7830In situations where a character array is intended to store a sequence
7831of bytes with no terminating @code{NUL} such an array may be annotated
7832with attribute @code{nonstring} to avoid this warning. Such arrays,
7833however, are not suitable arguments to functions that expect
7834@code{NUL}-terminated strings. To help detect accidental misuses of
7835such arrays GCC issues warnings unless it can prove that the use is
7836safe. @xref{Common Variable Attributes}.
7837
2a27ae32
QZ
7838@item -Wstrict-flex-arrays
7839@opindex Wstrict-flex-arrays
7840@opindex Wno-strict-flex-arrays
7841Warn about inproper usages of flexible array members
7842according to the @var{level} of the @code{strict_flex_array (@var{level})}
7843attribute attached to the trailing array field of a structure if it's
7844available, otherwise according to the @var{level} of the option
7845@option{-fstrict-flex-arrays=@var{level}}.
7846
7847This option is effective only when @var{level} is bigger than 0. Otherwise,
7848it will be ignored with a warning.
7849
7850when @var{level}=1, warnings will be issued for a trailing array reference
7851of a structure that have 2 or more elements if the trailing array is referenced
7852as a flexible array member.
7853
7854when @var{level}=2, in addition to @var{level}=1, additional warnings will be
7855issued for a trailing one-element array reference of a structure
7856if the array is referenced as a flexible array member.
7857
7858when @var{level}=3, in addition to @var{level}=2, additional warnings will be
7859issued for a trailing zero-length array reference of a structure
7860if the array is referenced as a flexible array member.
7861
7862
d77de738
ML
7863@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
7864@opindex Wsuggest-attribute=
7865@opindex Wno-suggest-attribute=
7866Warn for cases where adding an attribute may be beneficial. The
7867attributes currently supported are listed below.
7868
7869@table @gcctabopt
7870@item -Wsuggest-attribute=pure
7871@itemx -Wsuggest-attribute=const
7872@itemx -Wsuggest-attribute=noreturn
7873@itemx -Wmissing-noreturn
7874@itemx -Wsuggest-attribute=malloc
7875@opindex Wsuggest-attribute=pure
7876@opindex Wno-suggest-attribute=pure
7877@opindex Wsuggest-attribute=const
7878@opindex Wno-suggest-attribute=const
7879@opindex Wsuggest-attribute=noreturn
7880@opindex Wno-suggest-attribute=noreturn
7881@opindex Wmissing-noreturn
7882@opindex Wno-missing-noreturn
7883@opindex Wsuggest-attribute=malloc
7884@opindex Wno-suggest-attribute=malloc
7885
7886Warn about functions that might be candidates for attributes
7887@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7888only warns for functions visible in other compilation units or (in the case of
7889@code{pure} and @code{const}) if it cannot prove that the function returns
7890normally. A function returns normally if it doesn't contain an infinite loop or
7891return abnormally by throwing, calling @code{abort} or trapping. This analysis
7892requires option @option{-fipa-pure-const}, which is enabled by default at
7893@option{-O} and higher. Higher optimization levels improve the accuracy
7894of the analysis.
7895
7896@item -Wsuggest-attribute=format
7897@itemx -Wmissing-format-attribute
7898@opindex Wsuggest-attribute=format
7899@opindex Wmissing-format-attribute
7900@opindex Wno-suggest-attribute=format
7901@opindex Wno-missing-format-attribute
7902@opindex Wformat
7903@opindex Wno-format
7904
7905Warn about function pointers that might be candidates for @code{format}
7906attributes. Note these are only possible candidates, not absolute ones.
7907GCC guesses that function pointers with @code{format} attributes that
7908are used in assignment, initialization, parameter passing or return
7909statements should have a corresponding @code{format} attribute in the
7910resulting type. I.e.@: the left-hand side of the assignment or
7911initialization, the type of the parameter variable, or the return type
7912of the containing function respectively should also have a @code{format}
7913attribute to avoid the warning.
7914
7915GCC also warns about function definitions that might be
7916candidates for @code{format} attributes. Again, these are only
7917possible candidates. GCC guesses that @code{format} attributes
7918might be appropriate for any function that calls a function like
7919@code{vprintf} or @code{vscanf}, but this might not always be the
7920case, and some functions for which @code{format} attributes are
7921appropriate may not be detected.
7922
7923@item -Wsuggest-attribute=cold
7924@opindex Wsuggest-attribute=cold
7925@opindex Wno-suggest-attribute=cold
7926
7927Warn about functions that might be candidates for @code{cold} attribute. This
7928is based on static detection and generally only warns about functions which
7929always leads to a call to another @code{cold} function such as wrappers of
7930C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
7931@end table
7932
7933@item -Walloc-zero
7934@opindex Wno-alloc-zero
7935@opindex Walloc-zero
7936Warn about calls to allocation functions decorated with attribute
7937@code{alloc_size} that specify zero bytes, including those to the built-in
7938forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
7939@code{malloc}, and @code{realloc}. Because the behavior of these functions
7940when called with a zero size differs among implementations (and in the case
7941of @code{realloc} has been deprecated) relying on it may result in subtle
7942portability bugs and should be avoided.
7943
7944@item -Walloc-size-larger-than=@var{byte-size}
7945@opindex Walloc-size-larger-than=
7946@opindex Wno-alloc-size-larger-than
7947Warn about calls to functions decorated with attribute @code{alloc_size}
7948that attempt to allocate objects larger than the specified number of bytes,
7949or where the result of the size computation in an integer type with infinite
7950precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
7951@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
7952Warnings controlled by the option can be disabled either by specifying
7953@var{byte-size} of @samp{SIZE_MAX} or more or by
7954@option{-Wno-alloc-size-larger-than}.
7955@xref{Function Attributes}.
7956
7957@item -Wno-alloc-size-larger-than
7958@opindex Wno-alloc-size-larger-than
7959Disable @option{-Walloc-size-larger-than=} warnings. The option is
7960equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
7961larger.
7962
7963@item -Walloca
7964@opindex Wno-alloca
7965@opindex Walloca
7966This option warns on all uses of @code{alloca} in the source.
7967
7968@item -Walloca-larger-than=@var{byte-size}
7969@opindex Walloca-larger-than=
7970@opindex Wno-alloca-larger-than
7971This option warns on calls to @code{alloca} with an integer argument whose
7972value is either zero, or that is not bounded by a controlling predicate
7973that limits its value to at most @var{byte-size}. It also warns for calls
7974to @code{alloca} where the bound value is unknown. Arguments of non-integer
7975types are considered unbounded even if they appear to be constrained to
7976the expected range.
7977
7978For example, a bounded case of @code{alloca} could be:
7979
7980@smallexample
7981void func (size_t n)
7982@{
7983 void *p;
7984 if (n <= 1000)
7985 p = alloca (n);
7986 else
7987 p = malloc (n);
7988 f (p);
7989@}
7990@end smallexample
7991
7992In the above example, passing @code{-Walloca-larger-than=1000} would not
7993issue a warning because the call to @code{alloca} is known to be at most
79941000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
7995the compiler would emit a warning.
7996
7997Unbounded uses, on the other hand, are uses of @code{alloca} with no
7998controlling predicate constraining its integer argument. For example:
7999
8000@smallexample
8001void func ()
8002@{
8003 void *p = alloca (n);
8004 f (p);
8005@}
8006@end smallexample
8007
8008If @code{-Walloca-larger-than=500} were passed, the above would trigger
8009a warning, but this time because of the lack of bounds checking.
8010
8011Note, that even seemingly correct code involving signed integers could
8012cause a warning:
8013
8014@smallexample
8015void func (signed int n)
8016@{
8017 if (n < 500)
8018 @{
8019 p = alloca (n);
8020 f (p);
8021 @}
8022@}
8023@end smallexample
8024
8025In the above example, @var{n} could be negative, causing a larger than
8026expected argument to be implicitly cast into the @code{alloca} call.
8027
8028This option also warns when @code{alloca} is used in a loop.
8029
8030@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8031but is usually only effective when @option{-ftree-vrp} is active (default
8032for @option{-O2} and above).
8033
8034See also @option{-Wvla-larger-than=}@samp{byte-size}.
8035
8036@item -Wno-alloca-larger-than
8037@opindex Wno-alloca-larger-than
8038Disable @option{-Walloca-larger-than=} warnings. The option is
8039equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8040
8041@item -Warith-conversion
8042@opindex Warith-conversion
8043@opindex Wno-arith-conversion
8044Do warn about implicit conversions from arithmetic operations even
8045when conversion of the operands to the same type cannot change their
8046values. This affects warnings from @option{-Wconversion},
8047@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8048
8049@smallexample
8050@group
8051void f (char c, int i)
8052@{
8053 c = c + i; // warns with @option{-Wconversion}
8054 c = c + 1; // only warns with @option{-Warith-conversion}
8055@}
8056@end group
8057@end smallexample
8058
8059@item -Warray-bounds
8060@itemx -Warray-bounds=@var{n}
8061@opindex Wno-array-bounds
8062@opindex Warray-bounds
8063Warn about out of bounds subscripts or offsets into arrays. This warning
8064is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8065is active (the default for @option{-O2} and above) but a subset of instances
8066are issued even without optimization.
8067
710c9676
QZ
8068By default, the trailing array of a structure will be treated as a flexible
8069array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8070if it is declared as either a flexible array member per C99 standard onwards
8071(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8072array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8073zero-length arrays or one-element arrays are not warned by default.
8074
8075You can add the option @option{-fstrict-flex-arrays} or
8076@option{-fstrict-flex-arrays=@var{level}} to control how this
8077option treat trailing array of a structure as a flexible array member:
8078
8079when @var{level}<=1, no change to the default behavior.
8080
8081when @var{level}=2, additional warnings will be issued for out of bounds
8082subscripts or offsets into one-element arrays;
8083
8084when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8085issued for out of bounds subscripts or offsets into zero-length arrays.
8086
d77de738
ML
8087@table @gcctabopt
8088@item -Warray-bounds=1
8089This is the default warning level of @option{-Warray-bounds} and is enabled
8090by @option{-Wall}; higher levels are not, and must be explicitly requested.
8091
8092@item -Warray-bounds=2
710c9676
QZ
8093This warning level also warns about the intermediate results of pointer
8094arithmetic that may yield out of bounds values. This warning level may
8095give a larger number of false positives and is deactivated by default.
d77de738
ML
8096@end table
8097
8098@item -Warray-compare
8099@opindex Warray-compare
8100@opindex Wno-array-compare
8101Warn about equality and relational comparisons between two operands of array
8102type. This comparison was deprecated in C++20. For example:
8103
8104@smallexample
8105int arr1[5];
8106int arr2[5];
8107bool same = arr1 == arr2;
8108@end smallexample
8109
8110@option{-Warray-compare} is enabled by @option{-Wall}.
8111
8112@item -Warray-parameter
8113@itemx -Warray-parameter=@var{n}
8114@opindex Wno-array-parameter
8115Warn about redeclarations of functions involving arguments of array or
8116pointer types of inconsistent kinds or forms, and enable the detection
8117of out-of-bounds accesses to such parameters by warnings such as
8118@option{-Warray-bounds}.
8119
8120If the first function declaration uses the array form the bound specified
8121in the array is assumed to be the minimum number of elements expected to
8122be provided in calls to the function and the maximum number of elements
8123accessed by it. Failing to provide arguments of sufficient size or accessing
8124more than the maximum number of elements may be diagnosed by warnings such
8125as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8126involving array parameters declared using the @code{T[static N]} form.
8127
8128For example, the warning triggers for the following redeclarations because
8129the first one allows an array of any size to be passed to @code{f} while
8130the second one with the keyword @code{static} specifies that the array
8131argument must have at least four elements.
8132
8133@smallexample
8134void f (int[static 4]);
8135void f (int[]); // warning (inconsistent array form)
8136
8137void g (void)
8138@{
8139 int *p = (int *)malloc (4);
8140 f (p); // warning (array too small)
8141 @dots{}
8142@}
8143@end smallexample
8144
8145At level 2 the warning also triggers for redeclarations involving any other
8146inconsistency in array or pointer argument forms denoting array sizes.
8147Pointers and arrays of unspecified bound are considered equivalent and do
8148not trigger a warning.
8149
8150@smallexample
8151void g (int*);
8152void g (int[]); // no warning
8153void g (int[8]); // warning (inconsistent array bound)
8154@end smallexample
8155
8156@option{-Warray-parameter=2} is included in @option{-Wall}. The
8157@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8158involving Variable Length Array arguments.
8159
8160@item -Wattribute-alias=@var{n}
8161@itemx -Wno-attribute-alias
8162@opindex Wattribute-alias
8163@opindex Wno-attribute-alias
8164Warn about declarations using the @code{alias} and similar attributes whose
8165target is incompatible with the type of the alias.
8166@xref{Function Attributes,,Declaring Attributes of Functions}.
8167
8168@table @gcctabopt
8169@item -Wattribute-alias=1
8170The default warning level of the @option{-Wattribute-alias} option diagnoses
8171incompatibilities between the type of the alias declaration and that of its
8172target. Such incompatibilities are typically indicative of bugs.
8173
8174@item -Wattribute-alias=2
8175
8176At this level @option{-Wattribute-alias} also diagnoses cases where
8177the attributes of the alias declaration are more restrictive than the
8178attributes applied to its target. These mismatches can potentially
8179result in incorrect code generation. In other cases they may be
8180benign and could be resolved simply by adding the missing attribute to
8181the target. For comparison, see the @option{-Wmissing-attributes}
8182option, which controls diagnostics when the alias declaration is less
8183restrictive than the target, rather than more restrictive.
8184
8185Attributes considered include @code{alloc_align}, @code{alloc_size},
8186@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8187@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8188@code{returns_nonnull}, and @code{returns_twice}.
8189@end table
8190
8191@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8192This is the default. You can disable these warnings with either
8193@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8194
8195@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
8196@opindex Wbidi-chars=
8197@opindex Wbidi-chars
8198@opindex Wno-bidi-chars
8199Warn about possibly misleading UTF-8 bidirectional control characters in
8200comments, string literals, character constants, and identifiers. Such
8201characters can change left-to-right writing direction into right-to-left
8202(and vice versa), which can cause confusion between the logical order and
8203visual order. This may be dangerous; for instance, it may seem that a piece
8204of code is not commented out, whereas it in fact is.
8205
8206There are three levels of warning supported by GCC@. The default is
8207@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8208bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8209@option{-Wbidi-chars=any} warns about any use of bidirectional control
8210characters.
8211
8212By default, this warning does not warn about UCNs. It is, however, possible
8213to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8214@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8215and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8216@option{-Wbidi-chars=any} was specified.
8217
8218@item -Wbool-compare
8219@opindex Wno-bool-compare
8220@opindex Wbool-compare
8221Warn about boolean expression compared with an integer value different from
8222@code{true}/@code{false}. For instance, the following comparison is
8223always false:
8224@smallexample
8225int n = 5;
8226@dots{}
8227if ((n > 1) == 2) @{ @dots{} @}
8228@end smallexample
8229This warning is enabled by @option{-Wall}.
8230
8231@item -Wbool-operation
8232@opindex Wno-bool-operation
8233@opindex Wbool-operation
8234Warn about suspicious operations on expressions of a boolean type. For
8235instance, bitwise negation of a boolean is very likely a bug in the program.
8236For C, this warning also warns about incrementing or decrementing a boolean,
8237which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8238Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8239
8240This warning is enabled by @option{-Wall}.
8241
8242@item -Wduplicated-branches
8243@opindex Wno-duplicated-branches
8244@opindex Wduplicated-branches
8245Warn when an if-else has identical branches. This warning detects cases like
8246@smallexample
8247if (p != NULL)
8248 return 0;
8249else
8250 return 0;
8251@end smallexample
8252It doesn't warn when both branches contain just a null statement. This warning
8253also warn for conditional operators:
8254@smallexample
8255 int i = x ? *p : *p;
8256@end smallexample
8257
8258@item -Wduplicated-cond
8259@opindex Wno-duplicated-cond
8260@opindex Wduplicated-cond
8261Warn about duplicated conditions in an if-else-if chain. For instance,
8262warn for the following code:
8263@smallexample
8264if (p->q != NULL) @{ @dots{} @}
8265else if (p->q != NULL) @{ @dots{} @}
8266@end smallexample
8267
8268@item -Wframe-address
8269@opindex Wno-frame-address
8270@opindex Wframe-address
8271Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8272is called with an argument greater than 0. Such calls may return indeterminate
8273values or crash the program. The warning is included in @option{-Wall}.
8274
8275@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
8276@opindex Wno-discarded-qualifiers
8277@opindex Wdiscarded-qualifiers
8278Do not warn if type qualifiers on pointers are being discarded.
8279Typically, the compiler warns if a @code{const char *} variable is
8280passed to a function that takes a @code{char *} parameter. This option
8281can be used to suppress such a warning.
8282
8283@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
8284@opindex Wno-discarded-array-qualifiers
8285@opindex Wdiscarded-array-qualifiers
8286Do not warn if type qualifiers on arrays which are pointer targets
8287are being discarded. Typically, the compiler warns if a
8288@code{const int (*)[]} variable is passed to a function that
8289takes a @code{int (*)[]} parameter. This option can be used to
8290suppress such a warning.
8291
8292@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
8293@opindex Wno-incompatible-pointer-types
8294@opindex Wincompatible-pointer-types
8295Do not warn when there is a conversion between pointers that have incompatible
8296types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8297which warns for pointer argument passing or assignment with different
8298signedness.
8299
8300@item -Wno-int-conversion @r{(C and Objective-C only)}
8301@opindex Wno-int-conversion
8302@opindex Wint-conversion
8303Do not warn about incompatible integer to pointer and pointer to integer
8304conversions. This warning is about implicit conversions; for explicit
8305conversions the warnings @option{-Wno-int-to-pointer-cast} and
8306@option{-Wno-pointer-to-int-cast} may be used.
8307
8308@item -Wzero-length-bounds
8309@opindex Wzero-length-bounds
8310@opindex Wzero-length-bounds
8311Warn about accesses to elements of zero-length array members that might
8312overlap other members of the same object. Declaring interior zero-length
8313arrays is discouraged because accesses to them are undefined. See
8314@xref{Zero Length}.
8315
8316For example, the first two stores in function @code{bad} are diagnosed
8317because the array elements overlap the subsequent members @code{b} and
8318@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8319because it is beyond the bounds of the enclosing object.
8320
8321@smallexample
8322struct X @{ int a[0]; int b, c; @};
8323struct X x;
8324
8325void bad (void)
8326@{
8327 x.a[0] = 0; // -Wzero-length-bounds
8328 x.a[1] = 1; // -Wzero-length-bounds
8329 x.a[2] = 2; // -Warray-bounds
8330@}
8331@end smallexample
8332
8333Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8334
8335@item -Wno-div-by-zero
8336@opindex Wno-div-by-zero
8337@opindex Wdiv-by-zero
8338Do not warn about compile-time integer division by zero. Floating-point
8339division by zero is not warned about, as it can be a legitimate way of
8340obtaining infinities and NaNs.
8341
8342@item -Wsystem-headers
8343@opindex Wsystem-headers
8344@opindex Wno-system-headers
8345@cindex warnings from system headers
8346@cindex system headers, warnings from
8347Print warning messages for constructs found in system header files.
8348Warnings from system headers are normally suppressed, on the assumption
8349that they usually do not indicate real problems and would only make the
8350compiler output harder to read. Using this command-line option tells
8351GCC to emit warnings from system headers as if they occurred in user
8352code. However, note that using @option{-Wall} in conjunction with this
8353option does @emph{not} warn about unknown pragmas in system
8354headers---for that, @option{-Wunknown-pragmas} must also be used.
8355
8356@item -Wtautological-compare
8357@opindex Wtautological-compare
8358@opindex Wno-tautological-compare
8359Warn if a self-comparison always evaluates to true or false. This
8360warning detects various mistakes such as:
8361@smallexample
8362int i = 1;
8363@dots{}
8364if (i > i) @{ @dots{} @}
8365@end smallexample
8366
8367This warning also warns about bitwise comparisons that always evaluate
8368to true or false, for instance:
8369@smallexample
8370if ((a & 16) == 10) @{ @dots{} @}
8371@end smallexample
8372will always be false.
8373
8374This warning is enabled by @option{-Wall}.
8375
8376@item -Wtrampolines
8377@opindex Wtrampolines
8378@opindex Wno-trampolines
8379Warn about trampolines generated for pointers to nested functions.
8380A trampoline is a small piece of data or code that is created at run
8381time on the stack when the address of a nested function is taken, and is
8382used to call the nested function indirectly. For some targets, it is
8383made up of data only and thus requires no special treatment. But, for
8384most targets, it is made up of code and thus requires the stack to be
8385made executable in order for the program to work properly.
8386
8387@item -Wfloat-equal
8388@opindex Wfloat-equal
8389@opindex Wno-float-equal
8390Warn if floating-point values are used in equality comparisons.
8391
8392The idea behind this is that sometimes it is convenient (for the
8393programmer) to consider floating-point values as approximations to
8394infinitely precise real numbers. If you are doing this, then you need
8395to compute (by analyzing the code, or in some other way) the maximum or
8396likely maximum error that the computation introduces, and allow for it
8397when performing comparisons (and when producing output, but that's a
8398different problem). In particular, instead of testing for equality, you
8399should check to see whether the two values have ranges that overlap; and
8400this is done with the relational operators, so equality comparisons are
8401probably mistaken.
8402
8403@item -Wtraditional @r{(C and Objective-C only)}
8404@opindex Wtraditional
8405@opindex Wno-traditional
8406Warn about certain constructs that behave differently in traditional and
8407ISO C@. Also warn about ISO C constructs that have no traditional C
8408equivalent, and/or problematic constructs that should be avoided.
8409
8410@itemize @bullet
8411@item
8412Macro parameters that appear within string literals in the macro body.
8413In traditional C macro replacement takes place within string literals,
8414but in ISO C it does not.
8415
8416@item
8417In traditional C, some preprocessor directives did not exist.
8418Traditional preprocessors only considered a line to be a directive
8419if the @samp{#} appeared in column 1 on the line. Therefore
8420@option{-Wtraditional} warns about directives that traditional C
8421understands but ignores because the @samp{#} does not appear as the
8422first character on the line. It also suggests you hide directives like
8423@code{#pragma} not understood by traditional C by indenting them. Some
8424traditional implementations do not recognize @code{#elif}, so this option
8425suggests avoiding it altogether.
8426
8427@item
8428A function-like macro that appears without arguments.
8429
8430@item
8431The unary plus operator.
8432
8433@item
8434The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8435constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8436constants.) Note, these suffixes appear in macros defined in the system
8437headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8438Use of these macros in user code might normally lead to spurious
8439warnings, however GCC's integrated preprocessor has enough context to
8440avoid warning in these cases.
8441
8442@item
8443A function declared external in one block and then used after the end of
8444the block.
8445
8446@item
8447A @code{switch} statement has an operand of type @code{long}.
8448
8449@item
8450A non-@code{static} function declaration follows a @code{static} one.
8451This construct is not accepted by some traditional C compilers.
8452
8453@item
8454The ISO type of an integer constant has a different width or
8455signedness from its traditional type. This warning is only issued if
8456the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8457typically represent bit patterns, are not warned about.
8458
8459@item
8460Usage of ISO string concatenation is detected.
8461
8462@item
8463Initialization of automatic aggregates.
8464
8465@item
8466Identifier conflicts with labels. Traditional C lacks a separate
8467namespace for labels.
8468
8469@item
8470Initialization of unions. If the initializer is zero, the warning is
8471omitted. This is done under the assumption that the zero initializer in
8472user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8473initializer warnings and relies on default initialization to zero in the
8474traditional C case.
8475
8476@item
8477Conversions by prototypes between fixed/floating-point values and vice
8478versa. The absence of these prototypes when compiling with traditional
8479C causes serious problems. This is a subset of the possible
8480conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8481
8482@item
8483Use of ISO C style function definitions. This warning intentionally is
8484@emph{not} issued for prototype declarations or variadic functions
8485because these ISO C features appear in your code when using
8486libiberty's traditional C compatibility macros, @code{PARAMS} and
8487@code{VPARAMS}. This warning is also bypassed for nested functions
8488because that feature is already a GCC extension and thus not relevant to
8489traditional C compatibility.
8490@end itemize
8491
8492@item -Wtraditional-conversion @r{(C and Objective-C only)}
8493@opindex Wtraditional-conversion
8494@opindex Wno-traditional-conversion
8495Warn if a prototype causes a type conversion that is different from what
8496would happen to the same argument in the absence of a prototype. This
8497includes conversions of fixed point to floating and vice versa, and
8498conversions changing the width or signedness of a fixed-point argument
8499except when the same as the default promotion.
8500
8501@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
8502@opindex Wdeclaration-after-statement
8503@opindex Wno-declaration-after-statement
8504Warn when a declaration is found after a statement in a block. This
8505construct, known from C++, was introduced with ISO C99 and is by default
8506allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8507
8508@item -Wshadow
8509@opindex Wshadow
8510@opindex Wno-shadow
8511Warn whenever a local variable or type declaration shadows another
8512variable, parameter, type, class member (in C++), or instance variable
8513(in Objective-C) or whenever a built-in function is shadowed. Note
8514that in C++, the compiler warns if a local variable shadows an
8515explicit typedef, but not if it shadows a struct/class/enum.
8516If this warning is enabled, it includes also all instances of
8517local shadowing. This means that @option{-Wno-shadow=local}
8518and @option{-Wno-shadow=compatible-local} are ignored when
8519@option{-Wshadow} is used.
8520Same as @option{-Wshadow=global}.
8521
8522@item -Wno-shadow-ivar @r{(Objective-C only)}
8523@opindex Wno-shadow-ivar
8524@opindex Wshadow-ivar
8525Do not warn whenever a local variable shadows an instance variable in an
8526Objective-C method.
8527
8528@item -Wshadow=global
8529@opindex Wshadow=global
8530Warn for any shadowing.
8531Same as @option{-Wshadow}.
8532
8533@item -Wshadow=local
8534@opindex Wshadow=local
8535Warn when a local variable shadows another local variable or parameter.
8536
8537@item -Wshadow=compatible-local
8538@opindex Wshadow=compatible-local
8539Warn when a local variable shadows another local variable or parameter
8540whose type is compatible with that of the shadowing variable. In C++,
8541type compatibility here means the type of the shadowing variable can be
8542converted to that of the shadowed variable. The creation of this flag
8543(in addition to @option{-Wshadow=local}) is based on the idea that when
8544a local variable shadows another one of incompatible type, it is most
8545likely intentional, not a bug or typo, as shown in the following example:
8546
8547@smallexample
8548@group
8549for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8550@{
8551 for (int i = 0; i < N; ++i)
8552 @{
8553 ...
8554 @}
8555 ...
8556@}
8557@end group
8558@end smallexample
8559
8560Since the two variable @code{i} in the example above have incompatible types,
8561enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8562Because their types are incompatible, if a programmer accidentally uses one
8563in place of the other, type checking is expected to catch that and emit an
8564error or warning. Use of this flag instead of @option{-Wshadow=local} can
8565possibly reduce the number of warnings triggered by intentional shadowing.
8566Note that this also means that shadowing @code{const char *i} by
8567@code{char *i} does not emit a warning.
8568
8569This warning is also enabled by @option{-Wshadow=local}.
8570
8571@item -Wlarger-than=@var{byte-size}
8572@opindex Wlarger-than=
8573@opindex Wlarger-than-@var{byte-size}
8574Warn whenever an object is defined whose size exceeds @var{byte-size}.
8575@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8576Warnings controlled by the option can be disabled either by specifying
8577@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8578
8579Also warn for calls to bounded functions such as @code{memchr} or
8580@code{strnlen} that specify a bound greater than the largest possible
8581object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8582can only be disabled by @option{-Wno-larger-than}.
8583
8584@item -Wno-larger-than
8585@opindex Wno-larger-than
8586Disable @option{-Wlarger-than=} warnings. The option is equivalent
8587to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8588
8589@item -Wframe-larger-than=@var{byte-size}
8590@opindex Wframe-larger-than=
8591@opindex Wno-frame-larger-than
8592Warn if the size of a function frame exceeds @var{byte-size}.
8593The computation done to determine the stack frame size is approximate
8594and not conservative.
8595The actual requirements may be somewhat greater than @var{byte-size}
8596even if you do not get a warning. In addition, any space allocated
8597via @code{alloca}, variable-length arrays, or related constructs
8598is not included by the compiler when determining
8599whether or not to issue a warning.
8600@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8601Warnings controlled by the option can be disabled either by specifying
8602@var{byte-size} of @samp{SIZE_MAX} or more or by
8603@option{-Wno-frame-larger-than}.
8604
8605@item -Wno-frame-larger-than
8606@opindex Wno-frame-larger-than
8607Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8608to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8609
8610@item -Wfree-nonheap-object
8611@opindex Wfree-nonheap-object
8612@opindex Wno-free-nonheap-object
8613Warn when attempting to deallocate an object that was either not allocated
8614on the heap, or by using a pointer that was not returned from a prior call
8615to the corresponding allocation function. For example, because the call
8616to @code{stpcpy} returns a pointer to the terminating nul character and
8617not to the beginning of the object, the call to @code{free} below is
8618diagnosed.
8619
8620@smallexample
8621void f (char *p)
8622@{
8623 p = stpcpy (p, "abc");
8624 // ...
8625 free (p); // warning
8626@}
8627@end smallexample
8628
8629@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8630
8631@item -Wstack-usage=@var{byte-size}
8632@opindex Wstack-usage
8633@opindex Wno-stack-usage
8634Warn if the stack usage of a function might exceed @var{byte-size}.
8635The computation done to determine the stack usage is conservative.
8636Any space allocated via @code{alloca}, variable-length arrays, or related
8637constructs is included by the compiler when determining whether or not to
8638issue a warning.
8639
8640The message is in keeping with the output of @option{-fstack-usage}.
8641
8642@itemize
8643@item
8644If the stack usage is fully static but exceeds the specified amount, it's:
8645
8646@smallexample
8647 warning: stack usage is 1120 bytes
8648@end smallexample
8649@item
8650If the stack usage is (partly) dynamic but bounded, it's:
8651
8652@smallexample
8653 warning: stack usage might be 1648 bytes
8654@end smallexample
8655@item
8656If the stack usage is (partly) dynamic and not bounded, it's:
8657
8658@smallexample
8659 warning: stack usage might be unbounded
8660@end smallexample
8661@end itemize
8662
8663@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8664Warnings controlled by the option can be disabled either by specifying
8665@var{byte-size} of @samp{SIZE_MAX} or more or by
8666@option{-Wno-stack-usage}.
8667
8668@item -Wno-stack-usage
8669@opindex Wno-stack-usage
8670Disable @option{-Wstack-usage=} warnings. The option is equivalent
8671to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8672
8673@item -Wunsafe-loop-optimizations
8674@opindex Wunsafe-loop-optimizations
8675@opindex Wno-unsafe-loop-optimizations
8676Warn if the loop cannot be optimized because the compiler cannot
8677assume anything on the bounds of the loop indices. With
8678@option{-funsafe-loop-optimizations} warn if the compiler makes
8679such assumptions.
8680
8681@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
8682@opindex Wno-pedantic-ms-format
8683@opindex Wpedantic-ms-format
8684When used in combination with @option{-Wformat}
8685and @option{-pedantic} without GNU extensions, this option
8686disables the warnings about non-ISO @code{printf} / @code{scanf} format
8687width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8688which depend on the MS runtime.
8689
8690@item -Wpointer-arith
8691@opindex Wpointer-arith
8692@opindex Wno-pointer-arith
8693Warn about anything that depends on the ``size of'' a function type or
8694of @code{void}. GNU C assigns these types a size of 1, for
8695convenience in calculations with @code{void *} pointers and pointers
8696to functions. In C++, warn also when an arithmetic operation involves
8697@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8698
8699@item -Wno-pointer-compare
8700@opindex Wpointer-compare
8701@opindex Wno-pointer-compare
8702Do not warn if a pointer is compared with a zero character constant.
8703This usually
8704means that the pointer was meant to be dereferenced. For example:
8705
8706@smallexample
8707const char *p = foo ();
8708if (p == '\0')
8709 return 42;
8710@end smallexample
8711
8712Note that the code above is invalid in C++11.
8713
8714This warning is enabled by default.
8715
8716@item -Wtsan
8717@opindex Wtsan
8718@opindex Wno-tsan
8719Warn about unsupported features in ThreadSanitizer.
8720
8721ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8722can report false positives.
8723
8724This warning is enabled by default.
8725
8726@item -Wtype-limits
8727@opindex Wtype-limits
8728@opindex Wno-type-limits
8729Warn if a comparison is always true or always false due to the limited
8730range of the data type, but do not warn for constant expressions. For
8731example, warn if an unsigned variable is compared against zero with
8732@code{<} or @code{>=}. This warning is also enabled by
8733@option{-Wextra}.
8734
8735@item -Wabsolute-value @r{(C and Objective-C only)}
8736@opindex Wabsolute-value
8737@opindex Wno-absolute-value
8738Warn for calls to standard functions that compute the absolute value
8739of an argument when a more appropriate standard function is available.
8740For example, calling @code{abs(3.14)} triggers the warning because the
8741appropriate function to call to compute the absolute value of a double
8742argument is @code{fabs}. The option also triggers warnings when the
8743argument in a call to such a function has an unsigned type. This
8744warning can be suppressed with an explicit type cast and it is also
8745enabled by @option{-Wextra}.
8746
8747@include cppwarnopts.texi
8748
8749@item -Wbad-function-cast @r{(C and Objective-C only)}
8750@opindex Wbad-function-cast
8751@opindex Wno-bad-function-cast
8752Warn when a function call is cast to a non-matching type.
8753For example, warn if a call to a function returning an integer type
8754is cast to a pointer type.
8755
8756@item -Wc90-c99-compat @r{(C and Objective-C only)}
8757@opindex Wc90-c99-compat
8758@opindex Wno-c90-c99-compat
8759Warn about features not present in ISO C90, but present in ISO C99.
8760For instance, warn about use of variable length arrays, @code{long long}
8761type, @code{bool} type, compound literals, designated initializers, and so
8762on. This option is independent of the standards mode. Warnings are disabled
8763in the expression that follows @code{__extension__}.
8764
8765@item -Wc99-c11-compat @r{(C and Objective-C only)}
8766@opindex Wc99-c11-compat
8767@opindex Wno-c99-c11-compat
8768Warn about features not present in ISO C99, but present in ISO C11.
8769For instance, warn about use of anonymous structures and unions,
8770@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8771@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8772and so on. This option is independent of the standards mode. Warnings are
8773disabled in the expression that follows @code{__extension__}.
8774
8775@item -Wc11-c2x-compat @r{(C and Objective-C only)}
8776@opindex Wc11-c2x-compat
8777@opindex Wno-c11-c2x-compat
8778Warn about features not present in ISO C11, but present in ISO C2X.
8779For instance, warn about omitting the string in @code{_Static_assert},
8780use of @samp{[[]]} syntax for attributes, use of decimal
8781floating-point types, and so on. This option is independent of the
8782standards mode. Warnings are disabled in the expression that follows
8783@code{__extension__}.
8784
8785@item -Wc++-compat @r{(C and Objective-C only)}
8786@opindex Wc++-compat
8787@opindex Wno-c++-compat
8788Warn about ISO C constructs that are outside of the common subset of
8789ISO C and ISO C++, e.g.@: request for implicit conversion from
8790@code{void *} to a pointer to non-@code{void} type.
8791
8792@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
8793@opindex Wc++11-compat
8794@opindex Wno-c++11-compat
8795Warn about C++ constructs whose meaning differs between ISO C++ 1998
8796and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8797in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8798enabled by @option{-Wall}.
8799
8800@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
8801@opindex Wc++14-compat
8802@opindex Wno-c++14-compat
8803Warn about C++ constructs whose meaning differs between ISO C++ 2011
8804and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8805
8806@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
8807@opindex Wc++17-compat
8808@opindex Wno-c++17-compat
8809Warn about C++ constructs whose meaning differs between ISO C++ 2014
8810and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8811
8812@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
8813@opindex Wc++20-compat
8814@opindex Wno-c++20-compat
8815Warn about C++ constructs whose meaning differs between ISO C++ 2017
8816and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8817
8818@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
8819@opindex Wc++11-extensions
8820@opindex Wno-c++11-extensions
8821Do not warn about C++11 constructs in code being compiled using
8822an older C++ standard. Even without this option, some C++11 constructs
8823will only be diagnosed if @option{-Wpedantic} is used.
8824
8825@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
8826@opindex Wc++14-extensions
8827@opindex Wno-c++14-extensions
8828Do not warn about C++14 constructs in code being compiled using
8829an older C++ standard. Even without this option, some C++14 constructs
8830will only be diagnosed if @option{-Wpedantic} is used.
8831
8832@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
8833@opindex Wc++17-extensions
8834@opindex Wno-c++17-extensions
8835Do not warn about C++17 constructs in code being compiled using
8836an older C++ standard. Even without this option, some C++17 constructs
8837will only be diagnosed if @option{-Wpedantic} is used.
8838
8839@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
8840@opindex Wc++20-extensions
8841@opindex Wno-c++20-extensions
8842Do not warn about C++20 constructs in code being compiled using
8843an older C++ standard. Even without this option, some C++20 constructs
8844will only be diagnosed if @option{-Wpedantic} is used.
8845
8846@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
8847@opindex Wc++23-extensions
8848@opindex Wno-c++23-extensions
8849Do not warn about C++23 constructs in code being compiled using
8850an older C++ standard. Even without this option, some C++23 constructs
8851will only be diagnosed if @option{-Wpedantic} is used.
8852
8853@item -Wcast-qual
8854@opindex Wcast-qual
8855@opindex Wno-cast-qual
8856Warn whenever a pointer is cast so as to remove a type qualifier from
8857the target type. For example, warn if a @code{const char *} is cast
8858to an ordinary @code{char *}.
8859
8860Also warn when making a cast that introduces a type qualifier in an
8861unsafe way. For example, casting @code{char **} to @code{const char **}
8862is unsafe, as in this example:
8863
8864@smallexample
8865 /* p is char ** value. */
8866 const char **q = (const char **) p;
8867 /* Assignment of readonly string to const char * is OK. */
8868 *q = "string";
8869 /* Now char** pointer points to read-only memory. */
8870 **p = 'b';
8871@end smallexample
8872
8873@item -Wcast-align
8874@opindex Wcast-align
8875@opindex Wno-cast-align
8876Warn whenever a pointer is cast such that the required alignment of the
8877target is increased. For example, warn if a @code{char *} is cast to
8878an @code{int *} on machines where integers can only be accessed at
8879two- or four-byte boundaries.
8880
8881@item -Wcast-align=strict
8882@opindex Wcast-align=strict
8883Warn whenever a pointer is cast such that the required alignment of the
8884target is increased. For example, warn if a @code{char *} is cast to
8885an @code{int *} regardless of the target machine.
8886
8887@item -Wcast-function-type
8888@opindex Wcast-function-type
8889@opindex Wno-cast-function-type
8890Warn when a function pointer is cast to an incompatible function pointer.
8891In a cast involving function types with a variable argument list only
8892the types of initial arguments that are provided are considered.
8893Any parameter of pointer-type matches any other pointer-type. Any benign
8894differences in integral types are ignored, like @code{int} vs.@: @code{long}
8895on ILP32 targets. Likewise type qualifiers are ignored. The function
8896type @code{void (*) (void)} is special and matches everything, which can
8897be used to suppress this warning.
8898In a cast involving pointer to member types this warning warns whenever
8899the type cast is changing the pointer to member type.
8900This warning is enabled by @option{-Wextra}.
8901
8902@item -Wwrite-strings
8903@opindex Wwrite-strings
8904@opindex Wno-write-strings
8905When compiling C, give string constants the type @code{const
8906char[@var{length}]} so that copying the address of one into a
8907non-@code{const} @code{char *} pointer produces a warning. These
8908warnings help you find at compile time code that can try to write
8909into a string constant, but only if you have been very careful about
8910using @code{const} in declarations and prototypes. Otherwise, it is
8911just a nuisance. This is why we did not make @option{-Wall} request
8912these warnings.
8913
8914When compiling C++, warn about the deprecated conversion from string
8915literals to @code{char *}. This warning is enabled by default for C++
8916programs.
8917
8918@item -Wclobbered
8919@opindex Wclobbered
8920@opindex Wno-clobbered
8921Warn for variables that might be changed by @code{longjmp} or
8922@code{vfork}. This warning is also enabled by @option{-Wextra}.
8923
8924@item -Wconversion
8925@opindex Wconversion
8926@opindex Wno-conversion
8927Warn for implicit conversions that may alter a value. This includes
8928conversions between real and integer, like @code{abs (x)} when
8929@code{x} is @code{double}; conversions between signed and unsigned,
8930like @code{unsigned ui = -1}; and conversions to smaller types, like
8931@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
8932((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
8933changed by the conversion like in @code{abs (2.0)}. Warnings about
8934conversions between signed and unsigned integers can be disabled by
8935using @option{-Wno-sign-conversion}.
8936
8937For C++, also warn for confusing overload resolution for user-defined
8938conversions; and conversions that never use a type conversion
8939operator: conversions to @code{void}, the same type, a base class or a
8940reference to them. Warnings about conversions between signed and
8941unsigned integers are disabled by default in C++ unless
8942@option{-Wsign-conversion} is explicitly enabled.
8943
8944Warnings about conversion from arithmetic on a small type back to that
8945type are only given with @option{-Warith-conversion}.
8946
8947@item -Wdangling-else
8948@opindex Wdangling-else
8949@opindex Wno-dangling-else
8950Warn about constructions where there may be confusion to which
8951@code{if} statement an @code{else} branch belongs. Here is an example of
8952such a case:
8953
8954@smallexample
8955@group
8956@{
8957 if (a)
8958 if (b)
8959 foo ();
8960 else
8961 bar ();
8962@}
8963@end group
8964@end smallexample
8965
8966In C/C++, every @code{else} branch belongs to the innermost possible
8967@code{if} statement, which in this example is @code{if (b)}. This is
8968often not what the programmer expected, as illustrated in the above
8969example by indentation the programmer chose. When there is the
8970potential for this confusion, GCC issues a warning when this flag
8971is specified. To eliminate the warning, add explicit braces around
8972the innermost @code{if} statement so there is no way the @code{else}
8973can belong to the enclosing @code{if}. The resulting code
8974looks like this:
8975
8976@smallexample
8977@group
8978@{
8979 if (a)
8980 @{
8981 if (b)
8982 foo ();
8983 else
8984 bar ();
8985 @}
8986@}
8987@end group
8988@end smallexample
8989
8990This warning is enabled by @option{-Wparentheses}.
8991
8992@item -Wdangling-pointer
8993@itemx -Wdangling-pointer=@var{n}
8994@opindex Wdangling-pointer
8995@opindex Wno-dangling-pointer
8996Warn about uses of pointers (or C++ references) to objects with automatic
8997storage duration after their lifetime has ended. This includes local
8998variables declared in nested blocks, compound literals and other unnamed
8999temporary objects. In addition, warn about storing the address of such
9000objects in escaped pointers. The warning is enabled at all optimization
9001levels but may yield different results with optimization than without.
9002
9003@table @gcctabopt
9004@item -Wdangling-pointer=1
9005At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9006For example
9007@smallexample
9008int f (int c1, int c2, x)
9009@{
9010 char *p = strchr ((char[])@{ c1, c2 @}, c3);
9011 return p ? *p : 'x'; // warning: dangling pointer to a compound literal
9012@}
9013@end smallexample
9014In the following function the store of the address of the local variable
9015@code{x} in the escaped pointer @code{*p} also triggers the warning.
9016@smallexample
9017void g (int **p)
9018@{
9019 int x = 7;
9020 *p = &x; // warning: storing the address of a local variable in *p
9021@}
9022@end smallexample
9023
9024@item -Wdangling-pointer=2
9025At level 2, in addition to unconditional uses the warning also diagnoses
9026conditional uses of dangling pointers.
9027
9028For example, because the array @var{a} in the following function is out of
9029scope when the pointer @var{s} that was set to point is used, the warning
9030triggers at this level.
9031
9032@smallexample
9033void f (char *s)
9034@{
9035 if (!s)
9036 @{
9037 char a[12] = "tmpname";
9038 s = a;
9039 @}
9040 strcat (s, ".tmp"); // warning: dangling pointer to a may be used
9041 ...
9042@}
9043@end smallexample
9044@end table
9045
9046@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9047
9048@item -Wdate-time
9049@opindex Wdate-time
9050@opindex Wno-date-time
9051Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9052are encountered as they might prevent bit-wise-identical reproducible
9053compilations.
9054
9055@item -Wempty-body
9056@opindex Wempty-body
9057@opindex Wno-empty-body
9058Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9059while} statement. This warning is also enabled by @option{-Wextra}.
9060
9061@item -Wno-endif-labels
9062@opindex Wendif-labels
9063@opindex Wno-endif-labels
9064Do not warn about stray tokens after @code{#else} and @code{#endif}.
9065
9066@item -Wenum-compare
9067@opindex Wenum-compare
9068@opindex Wno-enum-compare
9069Warn about a comparison between values of different enumerated types.
9070In C++ enumerated type mismatches in conditional expressions are also
9071diagnosed and the warning is enabled by default. In C this warning is
9072enabled by @option{-Wall}.
9073
9074@item -Wenum-conversion
9075@opindex Wenum-conversion
9076@opindex Wno-enum-conversion
9077Warn when a value of enumerated type is implicitly converted to a
9078different enumerated type. This warning is enabled by @option{-Wextra}
9079in C@.
9080
9081@item -Wenum-int-mismatch @r{(C and Objective-C only)}
9082@opindex Wenum-int-mismatch
9083@opindex Wno-enum-int-mismatch
9084Warn about mismatches between an enumerated type and an integer type in
9085declarations. For example:
9086
9087@smallexample
9088enum E @{ l = -1, z = 0, g = 1 @};
9089int foo(void);
9090enum E foo(void);
9091@end smallexample
9092
9093In C, an enumerated type is compatible with @code{char}, a signed
9094integer type, or an unsigned integer type. However, since the choice
9095of the underlying type of an enumerated type is implementation-defined,
9096such mismatches may cause portability issues. In C++, such mismatches
9097are an error. In C, this warning is enabled by @option{-Wall} and
9098@option{-Wc++-compat}.
9099
9100@item -Wjump-misses-init @r{(C, Objective-C only)}
9101@opindex Wjump-misses-init
9102@opindex Wno-jump-misses-init
9103Warn if a @code{goto} statement or a @code{switch} statement jumps
9104forward across the initialization of a variable, or jumps backward to a
9105label after the variable has been initialized. This only warns about
9106variables that are initialized when they are declared. This warning is
9107only supported for C and Objective-C; in C++ this sort of branch is an
9108error in any case.
9109
9110@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9111can be disabled with the @option{-Wno-jump-misses-init} option.
9112
9113@item -Wsign-compare
9114@opindex Wsign-compare
9115@opindex Wno-sign-compare
9116@cindex warning for comparison of signed and unsigned values
9117@cindex comparison of signed and unsigned values, warning
9118@cindex signed and unsigned values, comparison warning
9119Warn when a comparison between signed and unsigned values could produce
9120an incorrect result when the signed value is converted to unsigned.
9121In C++, this warning is also enabled by @option{-Wall}. In C, it is
9122also enabled by @option{-Wextra}.
9123
9124@item -Wsign-conversion
9125@opindex Wsign-conversion
9126@opindex Wno-sign-conversion
9127Warn for implicit conversions that may change the sign of an integer
9128value, like assigning a signed integer expression to an unsigned
9129integer variable. An explicit cast silences the warning. In C, this
9130option is enabled also by @option{-Wconversion}.
9131
9132@item -Wfloat-conversion
9133@opindex Wfloat-conversion
9134@opindex Wno-float-conversion
9135Warn for implicit conversions that reduce the precision of a real value.
9136This includes conversions from real to integer, and from higher precision
9137real to lower precision real values. This option is also enabled by
9138@option{-Wconversion}.
9139
9140@item -Wno-scalar-storage-order
9141@opindex Wno-scalar-storage-order
9142@opindex Wscalar-storage-order
9143Do not warn on suspicious constructs involving reverse scalar storage order.
9144
9145@item -Wsizeof-array-div
9146@opindex Wsizeof-array-div
9147@opindex Wno-sizeof-array-div
9148Warn about divisions of two sizeof operators when the first one is applied
9149to an array and the divisor does not equal the size of the array element.
9150In such a case, the computation will not yield the number of elements in the
9151array, which is likely what the user intended. This warning warns e.g. about
9152@smallexample
9153int fn ()
9154@{
9155 int arr[10];
9156 return sizeof (arr) / sizeof (short);
9157@}
9158@end smallexample
9159
9160This warning is enabled by @option{-Wall}.
9161
9162@item -Wsizeof-pointer-div
9163@opindex Wsizeof-pointer-div
9164@opindex Wno-sizeof-pointer-div
9165Warn for suspicious divisions of two sizeof expressions that divide
9166the pointer size by the element size, which is the usual way to compute
9167the array size but won't work out correctly with pointers. This warning
9168warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9169not an array, but a pointer. This warning is enabled by @option{-Wall}.
9170
9171@item -Wsizeof-pointer-memaccess
9172@opindex Wsizeof-pointer-memaccess
9173@opindex Wno-sizeof-pointer-memaccess
9174Warn for suspicious length parameters to certain string and memory built-in
9175functions if the argument uses @code{sizeof}. This warning triggers for
9176example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9177an array, but a pointer, and suggests a possible fix, or about
9178@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9179also warns about calls to bounded string copy functions like @code{strncat}
9180or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9181the source array. For example, in the following function the call to
9182@code{strncat} specifies the size of the source string as the bound. That
9183is almost certainly a mistake and so the call is diagnosed.
9184@smallexample
9185void make_file (const char *name)
9186@{
9187 char path[PATH_MAX];
9188 strncpy (path, name, sizeof path - 1);
9189 strncat (path, ".text", sizeof ".text");
9190 @dots{}
9191@}
9192@end smallexample
9193
9194The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9195
9196@item -Wno-sizeof-array-argument
9197@opindex Wsizeof-array-argument
9198@opindex Wno-sizeof-array-argument
9199Do not warn when the @code{sizeof} operator is applied to a parameter that is
9200declared as an array in a function definition. This warning is enabled by
9201default for C and C++ programs.
9202
9203@item -Wmemset-elt-size
9204@opindex Wmemset-elt-size
9205@opindex Wno-memset-elt-size
9206Warn for suspicious calls to the @code{memset} built-in function, if the
9207first argument references an array, and the third argument is a number
9208equal to the number of elements, but not equal to the size of the array
9209in memory. This indicates that the user has omitted a multiplication by
9210the element size. This warning is enabled by @option{-Wall}.
9211
9212@item -Wmemset-transposed-args
9213@opindex Wmemset-transposed-args
9214@opindex Wno-memset-transposed-args
9215Warn for suspicious calls to the @code{memset} built-in function where
9216the second argument is not zero and the third argument is zero. For
9217example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9218@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9219is only emitted if the third argument is a literal zero. Otherwise, if
9220it is an expression that is folded to zero, or a cast of zero to some
9221type, it is far less likely that the arguments have been mistakenly
9222transposed and no warning is emitted. This warning is enabled
9223by @option{-Wall}.
9224
9225@item -Waddress
9226@opindex Waddress
9227@opindex Wno-address
9228Warn about suspicious uses of address expressions. These include comparing
9229the address of a function or a declared object to the null pointer constant
9230such as in
9231@smallexample
9232void f (void);
9233void g (void)
9234@{
9235 if (!f) // warning: expression evaluates to false
9236 abort ();
9237@}
9238@end smallexample
9239comparisons of a pointer to a string literal, such as in
9240@smallexample
9241void f (const char *x)
9242@{
9243 if (x == "abc") // warning: expression evaluates to false
9244 puts ("equal");
9245@}
9246@end smallexample
9247and tests of the results of pointer addition or subtraction for equality
9248to null, such as in
9249@smallexample
9250void f (const int *p, int i)
9251@{
9252 return p + i == NULL;
9253@}
9254@end smallexample
9255Such uses typically indicate a programmer error: the address of most
9256functions and objects necessarily evaluates to true (the exception are
9257weak symbols), so their use in a conditional might indicate missing
9258parentheses in a function call or a missing dereference in an array
9259expression. The subset of the warning for object pointers can be
9260suppressed by casting the pointer operand to an integer type such
9261as @code{intptr_t} or @code{uintptr_t}.
9262Comparisons against string literals result in unspecified behavior
9263and are not portable, and suggest the intent was to call @code{strcmp}.
9264The warning is suppressed if the suspicious expression is the result
9265of macro expansion.
9266@option{-Waddress} warning is enabled by @option{-Wall}.
9267
9268@item -Wno-address-of-packed-member
9269@opindex Waddress-of-packed-member
9270@opindex Wno-address-of-packed-member
9271Do not warn when the address of packed member of struct or union is taken,
9272which usually results in an unaligned pointer value. This is
9273enabled by default.
9274
9275@item -Wlogical-op
9276@opindex Wlogical-op
9277@opindex Wno-logical-op
9278Warn about suspicious uses of logical operators in expressions.
9279This includes using logical operators in contexts where a
9280bit-wise operator is likely to be expected. Also warns when
9281the operands of a logical operator are the same:
9282@smallexample
9283extern int a;
9284if (a < 0 && a < 0) @{ @dots{} @}
9285@end smallexample
9286
9287@item -Wlogical-not-parentheses
9288@opindex Wlogical-not-parentheses
9289@opindex Wno-logical-not-parentheses
9290Warn about logical not used on the left hand side operand of a comparison.
9291This option does not warn if the right operand is considered to be a boolean
9292expression. Its purpose is to detect suspicious code like the following:
9293@smallexample
9294int a;
9295@dots{}
9296if (!a > 1) @{ @dots{} @}
9297@end smallexample
9298
9299It is possible to suppress the warning by wrapping the LHS into
9300parentheses:
9301@smallexample
9302if ((!a) > 1) @{ @dots{} @}
9303@end smallexample
9304
9305This warning is enabled by @option{-Wall}.
9306
9307@item -Waggregate-return
9308@opindex Waggregate-return
9309@opindex Wno-aggregate-return
9310Warn if any functions that return structures or unions are defined or
9311called. (In languages where you can return an array, this also elicits
9312a warning.)
9313
9314@item -Wno-aggressive-loop-optimizations
9315@opindex Wno-aggressive-loop-optimizations
9316@opindex Waggressive-loop-optimizations
9317Warn if in a loop with constant number of iterations the compiler detects
9318undefined behavior in some statement during one or more of the iterations.
9319
9320@item -Wno-attributes
9321@opindex Wno-attributes
9322@opindex Wattributes
9323Do not warn if an unexpected @code{__attribute__} is used, such as
9324unrecognized attributes, function attributes applied to variables,
9325etc. This does not stop errors for incorrect use of supported
9326attributes.
9327
9328Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9329warnings about unknown scoped attributes (in C++11 and C2X). For example,
9330@option{-Wno-attributes=vendor::attr} disables warning about the following
9331declaration:
9332
9333@smallexample
9334[[vendor::attr]] void f();
9335@end smallexample
9336
9337It is also possible to disable warning about all attributes in a namespace
9338using @option{-Wno-attributes=vendor::} which prevents warning about both
9339of these declarations:
9340
9341@smallexample
9342[[vendor::safe]] void f();
9343[[vendor::unsafe]] void f2();
9344@end smallexample
9345
9346Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9347
9348@item -Wno-builtin-declaration-mismatch
9349@opindex Wno-builtin-declaration-mismatch
9350@opindex Wbuiltin-declaration-mismatch
9351Warn if a built-in function is declared with an incompatible signature
9352or as a non-function, or when a built-in function declared with a type
9353that does not include a prototype is called with arguments whose promoted
9354types do not match those expected by the function. When @option{-Wextra}
9355is specified, also warn when a built-in function that takes arguments is
9356declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9357warning is enabled by default. To avoid the warning include the appropriate
9358header to bring the prototypes of built-in functions into scope.
9359
9360For example, the call to @code{memset} below is diagnosed by the warning
9361because the function expects a value of type @code{size_t} as its argument
9362but the type of @code{32} is @code{int}. With @option{-Wextra},
9363the declaration of the function is diagnosed as well.
9364@smallexample
9365extern void* memset ();
9366void f (void *d)
9367@{
9368 memset (d, '\0', 32);
9369@}
9370@end smallexample
9371
9372@item -Wno-builtin-macro-redefined
9373@opindex Wno-builtin-macro-redefined
9374@opindex Wbuiltin-macro-redefined
9375Do not warn if certain built-in macros are redefined. This suppresses
9376warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9377@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9378
9379@item -Wstrict-prototypes @r{(C and Objective-C only)}
9380@opindex Wstrict-prototypes
9381@opindex Wno-strict-prototypes
9382Warn if a function is declared or defined without specifying the
9383argument types. (An old-style function definition is permitted without
9384a warning if preceded by a declaration that specifies the argument
9385types.)
9386
9387@item -Wold-style-declaration @r{(C and Objective-C only)}
9388@opindex Wold-style-declaration
9389@opindex Wno-old-style-declaration
9390Warn for obsolescent usages, according to the C Standard, in a
9391declaration. For example, warn if storage-class specifiers like
9392@code{static} are not the first things in a declaration. This warning
9393is also enabled by @option{-Wextra}.
9394
9395@item -Wold-style-definition @r{(C and Objective-C only)}
9396@opindex Wold-style-definition
9397@opindex Wno-old-style-definition
9398Warn if an old-style function definition is used. A warning is given
9399even if there is a previous prototype. A definition using @samp{()}
9400is not considered an old-style definition in C2X mode, because it is
9401equivalent to @samp{(void)} in that case, but is considered an
9402old-style definition for older standards.
9403
9404@item -Wmissing-parameter-type @r{(C and Objective-C only)}
9405@opindex Wmissing-parameter-type
9406@opindex Wno-missing-parameter-type
9407A function parameter is declared without a type specifier in K&R-style
9408functions:
9409
9410@smallexample
9411void foo(bar) @{ @}
9412@end smallexample
9413
9414This warning is also enabled by @option{-Wextra}.
9415
9416@item -Wmissing-prototypes @r{(C and Objective-C only)}
9417@opindex Wmissing-prototypes
9418@opindex Wno-missing-prototypes
9419Warn if a global function is defined without a previous prototype
9420declaration. This warning is issued even if the definition itself
9421provides a prototype. Use this option to detect global functions
9422that do not have a matching prototype declaration in a header file.
9423This option is not valid for C++ because all function declarations
9424provide prototypes and a non-matching declaration declares an
9425overload rather than conflict with an earlier declaration.
9426Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9427
9428@item -Wmissing-declarations
9429@opindex Wmissing-declarations
9430@opindex Wno-missing-declarations
9431Warn if a global function is defined without a previous declaration.
9432Do so even if the definition itself provides a prototype.
9433Use this option to detect global functions that are not declared in
9434header files. In C, no warnings are issued for functions with previous
9435non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9436missing prototypes. In C++, no warnings are issued for function templates,
9437or for inline functions, or for functions in anonymous namespaces.
9438
9439@item -Wmissing-field-initializers
9440@opindex Wmissing-field-initializers
9441@opindex Wno-missing-field-initializers
9442@opindex W
9443@opindex Wextra
9444@opindex Wno-extra
9445Warn if a structure's initializer has some fields missing. For
9446example, the following code causes such a warning, because
9447@code{x.h} is implicitly zero:
9448
9449@smallexample
9450struct s @{ int f, g, h; @};
9451struct s x = @{ 3, 4 @};
9452@end smallexample
9453
9454This option does not warn about designated initializers, so the following
9455modification does not trigger a warning:
9456
9457@smallexample
9458struct s @{ int f, g, h; @};
9459struct s x = @{ .f = 3, .g = 4 @};
9460@end smallexample
9461
9462In C this option does not warn about the universal zero initializer
9463@samp{@{ 0 @}}:
9464
9465@smallexample
9466struct s @{ int f, g, h; @};
9467struct s x = @{ 0 @};
9468@end smallexample
9469
9470Likewise, in C++ this option does not warn about the empty @{ @}
9471initializer, for example:
9472
9473@smallexample
9474struct s @{ int f, g, h; @};
9475s x = @{ @};
9476@end smallexample
9477
9478This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9479warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9480
9481@item -Wno-missing-requires
9482@opindex Wmissing-requires
9483@opindex Wno-missing-requires
9484
9485By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9486
9487@smallexample
9488bool satisfied = requires @{ C<T> @};
9489@end smallexample
9490
9491Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9492expression, which it is for all T. Presumably the user meant to write
9493
9494@smallexample
9495bool satisfied = requires @{ requires C<T> @};
9496@end smallexample
9497
9498so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9499type @samp{T}.
9500
9501This warning can be disabled with @option{-Wno-missing-requires}.
9502
9503@item -Wno-missing-template-keyword
9504@opindex Wmissing-template-keyword
9505@opindex Wno-missing-template-keyword
9506
9507The member access tokens ., -> and :: must be followed by the @code{template}
9508keyword if the parent object is dependent and the member being named is a
9509template.
9510
9511@smallexample
9512template <class X>
9513void DoStuff (X x)
9514@{
9515 x.template DoSomeOtherStuff<X>(); // Good.
9516 x.DoMoreStuff<X>(); // Warning, x is dependent.
9517@}
9518@end smallexample
9519
9520In rare cases it is possible to get false positives. To silence this, wrap
9521the expression in parentheses. For example, the following is treated as a
9522template, even where m and N are integers:
9523
9524@smallexample
9525void NotATemplate (my_class t)
9526@{
9527 int N = 5;
9528
9529 bool test = t.m < N > (0); // Treated as a template.
9530 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9531@}
9532@end smallexample
9533
9534This warning can be disabled with @option{-Wno-missing-template-keyword}.
9535
9536@item -Wno-multichar
9537@opindex Wno-multichar
9538@opindex Wmultichar
9539Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9540Usually they indicate a typo in the user's code, as they have
9541implementation-defined values, and should not be used in portable code.
9542
9543@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
9544@opindex Wnormalized=
9545@opindex Wnormalized
9546@opindex Wno-normalized
9547@cindex NFC
9548@cindex NFKC
9549@cindex character set, input normalization
9550In ISO C and ISO C++, two identifiers are different if they are
9551different sequences of characters. However, sometimes when characters
9552outside the basic ASCII character set are used, you can have two
9553different character sequences that look the same. To avoid confusion,
9554the ISO 10646 standard sets out some @dfn{normalization rules} which
9555when applied ensure that two sequences that look the same are turned into
9556the same sequence. GCC can warn you if you are using identifiers that
9557have not been normalized; this option controls that warning.
9558
9559There are four levels of warning supported by GCC@. The default is
9560@option{-Wnormalized=nfc}, which warns about any identifier that is
9561not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9562recommended form for most uses. It is equivalent to
9563@option{-Wnormalized}.
9564
9565Unfortunately, there are some characters allowed in identifiers by
9566ISO C and ISO C++ that, when turned into NFC, are not allowed in
9567identifiers. That is, there's no way to use these symbols in portable
9568ISO C or C++ and have all your identifiers in NFC@.
9569@option{-Wnormalized=id} suppresses the warning for these characters.
9570It is hoped that future versions of the standards involved will correct
9571this, which is why this option is not the default.
9572
9573You can switch the warning off for all characters by writing
9574@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9575only do this if you are using some other normalization scheme (like
9576``D''), because otherwise you can easily create bugs that are
9577literally impossible to see.
9578
9579Some characters in ISO 10646 have distinct meanings but look identical
9580in some fonts or display methodologies, especially once formatting has
9581been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9582LETTER N'', displays just like a regular @code{n} that has been
9583placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9584normalization scheme to convert all these into a standard form as
9585well, and GCC warns if your code is not in NFKC if you use
9586@option{-Wnormalized=nfkc}. This warning is comparable to warning
9587about every identifier that contains the letter O because it might be
9588confused with the digit 0, and so is not the default, but may be
9589useful as a local coding convention if the programming environment
9590cannot be fixed to display these characters distinctly.
9591
9592@item -Wno-attribute-warning
9593@opindex Wno-attribute-warning
9594@opindex Wattribute-warning
9595Do not warn about usage of functions (@pxref{Function Attributes})
9596declared with @code{warning} attribute. By default, this warning is
9597enabled. @option{-Wno-attribute-warning} can be used to disable the
9598warning or @option{-Wno-error=attribute-warning} can be used to
9599disable the error when compiled with @option{-Werror} flag.
9600
9601@item -Wno-deprecated
9602@opindex Wno-deprecated
9603@opindex Wdeprecated
9604Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9605
9606@item -Wno-deprecated-declarations
9607@opindex Wno-deprecated-declarations
9608@opindex Wdeprecated-declarations
9609Do not warn about uses of functions (@pxref{Function Attributes}),
9610variables (@pxref{Variable Attributes}), and types (@pxref{Type
9611Attributes}) marked as deprecated by using the @code{deprecated}
9612attribute.
9613
9614@item -Wno-overflow
9615@opindex Wno-overflow
9616@opindex Woverflow
9617Do not warn about compile-time overflow in constant expressions.
9618
9619@item -Wno-odr
9620@opindex Wno-odr
9621@opindex Wodr
9622Warn about One Definition Rule violations during link-time optimization.
9623Enabled by default.
9624
9625@item -Wopenacc-parallelism
9626@opindex Wopenacc-parallelism
9627@opindex Wno-openacc-parallelism
9628@cindex OpenACC accelerator programming
9629Warn about potentially suboptimal choices related to OpenACC parallelism.
9630
9631@item -Wopenmp-simd
9632@opindex Wopenmp-simd
9633@opindex Wno-openmp-simd
9634Warn if the vectorizer cost model overrides the OpenMP
9635simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9636option can be used to relax the cost model.
9637
9638@item -Woverride-init @r{(C and Objective-C only)}
9639@opindex Woverride-init
9640@opindex Wno-override-init
9641@opindex W
9642@opindex Wextra
9643@opindex Wno-extra
9644Warn if an initialized field without side effects is overridden when
9645using designated initializers (@pxref{Designated Inits, , Designated
9646Initializers}).
9647
9648This warning is included in @option{-Wextra}. To get other
9649@option{-Wextra} warnings without this one, use @option{-Wextra
9650-Wno-override-init}.
9651
9652@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
9653@opindex Woverride-init-side-effects
9654@opindex Wno-override-init-side-effects
9655Do not warn if an initialized field with side effects is overridden when
9656using designated initializers (@pxref{Designated Inits, , Designated
9657Initializers}). This warning is enabled by default.
9658
9659@item -Wpacked
9660@opindex Wpacked
9661@opindex Wno-packed
9662Warn if a structure is given the packed attribute, but the packed
9663attribute has no effect on the layout or size of the structure.
9664Such structures may be mis-aligned for little benefit. For
9665instance, in this code, the variable @code{f.x} in @code{struct bar}
9666is misaligned even though @code{struct bar} does not itself
9667have the packed attribute:
9668
9669@smallexample
9670@group
9671struct foo @{
9672 int x;
9673 char a, b, c, d;
9674@} __attribute__((packed));
9675struct bar @{
9676 char z;
9677 struct foo f;
9678@};
9679@end group
9680@end smallexample
9681
9682@item -Wnopacked-bitfield-compat
9683@opindex Wpacked-bitfield-compat
9684@opindex Wno-packed-bitfield-compat
9685The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9686on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9687the change can lead to differences in the structure layout. GCC
9688informs you when the offset of such a field has changed in GCC 4.4.
9689For example there is no longer a 4-bit padding between field @code{a}
9690and @code{b} in this structure:
9691
9692@smallexample
9693struct foo
9694@{
9695 char a:4;
9696 char b:8;
9697@} __attribute__ ((packed));
9698@end smallexample
9699
9700This warning is enabled by default. Use
9701@option{-Wno-packed-bitfield-compat} to disable this warning.
9702
9703@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
9704@opindex Wpacked-not-aligned
9705@opindex Wno-packed-not-aligned
9706Warn if a structure field with explicitly specified alignment in a
9707packed struct or union is misaligned. For example, a warning will
9708be issued on @code{struct S}, like, @code{warning: alignment 1 of
9709'struct S' is less than 8}, in this code:
9710
9711@smallexample
9712@group
9713struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9714struct __attribute__ ((packed)) S @{
9715 struct S8 s8;
9716@};
9717@end group
9718@end smallexample
9719
9720This warning is enabled by @option{-Wall}.
9721
9722@item -Wpadded
9723@opindex Wpadded
9724@opindex Wno-padded
9725Warn if padding is included in a structure, either to align an element
9726of the structure or to align the whole structure. Sometimes when this
9727happens it is possible to rearrange the fields of the structure to
9728reduce the padding and so make the structure smaller.
9729
9730@item -Wredundant-decls
9731@opindex Wredundant-decls
9732@opindex Wno-redundant-decls
9733Warn if anything is declared more than once in the same scope, even in
9734cases where multiple declaration is valid and changes nothing.
9735
9736@item -Wrestrict
9737@opindex Wrestrict
9738@opindex Wno-restrict
9739Warn when an object referenced by a @code{restrict}-qualified parameter
9740(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9741argument, or when copies between such objects overlap. For example,
9742the call to the @code{strcpy} function below attempts to truncate the string
9743by replacing its initial characters with the last four. However, because
9744the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9745the call is diagnosed.
9746
9747@smallexample
9748void foo (void)
9749@{
9750 char a[] = "abcd1234";
9751 strcpy (a, a + 4);
9752 @dots{}
9753@}
9754@end smallexample
9755The @option{-Wrestrict} option detects some instances of simple overlap
9756even without optimization but works best at @option{-O2} and above. It
9757is included in @option{-Wall}.
9758
9759@item -Wnested-externs @r{(C and Objective-C only)}
9760@opindex Wnested-externs
9761@opindex Wno-nested-externs
9762Warn if an @code{extern} declaration is encountered within a function.
9763
9764@item -Winline
9765@opindex Winline
9766@opindex Wno-inline
9767Warn if a function that is declared as inline cannot be inlined.
9768Even with this option, the compiler does not warn about failures to
9769inline functions declared in system headers.
9770
9771The compiler uses a variety of heuristics to determine whether or not
9772to inline a function. For example, the compiler takes into account
9773the size of the function being inlined and the amount of inlining
9774that has already been done in the current function. Therefore,
9775seemingly insignificant changes in the source program can cause the
9776warnings produced by @option{-Winline} to appear or disappear.
9777
9778@item -Winterference-size
9779@opindex Winterference-size
9780Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9781without specifying its value with @option{--param destructive-interference-size}.
9782Also warn about questionable values for that option.
9783
9784This variable is intended to be used for controlling class layout, to
9785avoid false sharing in concurrent code:
9786
9787@smallexample
9788struct independent_fields @{
9789 alignas(std::hardware_destructive_interference_size) std::atomic<int> one;
9790 alignas(std::hardware_destructive_interference_size) std::atomic<int> two;
9791@};
9792@end smallexample
9793
9794Here @samp{one} and @samp{two} are intended to be far enough apart
9795that stores to one won't require accesses to the other to reload the
9796cache line.
9797
9798By default, @option{--param destructive-interference-size} and
9799@option{--param constructive-interference-size} are set based on the
9800current @option{-mtune} option, typically to the L1 cache line size
9801for the particular target CPU, sometimes to a range if tuning for a
9802generic target. So all translation units that depend on ABI
9803compatibility for the use of these variables must be compiled with
9804the same @option{-mtune} (or @option{-mcpu}).
9805
9806If ABI stability is important, such as if the use is in a header for a
9807library, you should probably not use the hardware interference size
9808variables at all. Alternatively, you can force a particular value
9809with @option{--param}.
9810
9811If you are confident that your use of the variable does not affect ABI
9812outside a single build of your project, you can turn off the warning
9813with @option{-Wno-interference-size}.
9814
9815@item -Wint-in-bool-context
9816@opindex Wint-in-bool-context
9817@opindex Wno-int-in-bool-context
9818Warn for suspicious use of integer values where boolean values are expected,
9819such as conditional expressions (?:) using non-boolean integer constants in
9820boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9821integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9822for all kinds of multiplications regardless of the data type.
9823This warning is enabled by @option{-Wall}.
9824
9825@item -Wno-int-to-pointer-cast
9826@opindex Wno-int-to-pointer-cast
9827@opindex Wint-to-pointer-cast
9828Suppress warnings from casts to pointer type of an integer of a
9829different size. In C++, casting to a pointer type of smaller size is
9830an error. @option{Wint-to-pointer-cast} is enabled by default.
9831
9832
9833@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
9834@opindex Wno-pointer-to-int-cast
9835@opindex Wpointer-to-int-cast
9836Suppress warnings from casts from a pointer to an integer type of a
9837different size.
9838
9839@item -Winvalid-pch
9840@opindex Winvalid-pch
9841@opindex Wno-invalid-pch
9842Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9843the search path but cannot be used.
9844
9845@item -Winvalid-utf8
9846@opindex Winvalid-utf8
9847@opindex Wno-invalid-utf8
9848Warn if an invalid UTF-8 character is found.
9849This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
9850is used and turned into error with @option{-pedantic-errors}.
9851
9852@item -Wno-unicode
9853@opindex Wunicode
9854@opindex Wno-unicode
9855Don't diagnose invalid forms of delimited or named escape sequences which are
9856treated as separate tokens. @option{Wunicode} is enabled by default.
9857
9858@item -Wlong-long
9859@opindex Wlong-long
9860@opindex Wno-long-long
9861Warn if @code{long long} type is used. This is enabled by either
9862@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
9863modes. To inhibit the warning messages, use @option{-Wno-long-long}.
9864
9865@item -Wvariadic-macros
9866@opindex Wvariadic-macros
9867@opindex Wno-variadic-macros
9868Warn if variadic macros are used in ISO C90 mode, or if the GNU
9869alternate syntax is used in ISO C99 mode. This is enabled by either
9870@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
9871messages, use @option{-Wno-variadic-macros}.
9872
9873@item -Wno-varargs
9874@opindex Wvarargs
9875@opindex Wno-varargs
9876Do not warn upon questionable usage of the macros used to handle variable
9877arguments like @code{va_start}. These warnings are enabled by default.
9878
9879@item -Wvector-operation-performance
9880@opindex Wvector-operation-performance
9881@opindex Wno-vector-operation-performance
9882Warn if vector operation is not implemented via SIMD capabilities of the
9883architecture. Mainly useful for the performance tuning.
9884Vector operation can be implemented @code{piecewise}, which means that the
9885scalar operation is performed on every vector element;
9886@code{in parallel}, which means that the vector operation is implemented
9887using scalars of wider type, which normally is more performance efficient;
9888and @code{as a single scalar}, which means that vector fits into a
9889scalar type.
9890
9891@item -Wvla
9892@opindex Wvla
9893@opindex Wno-vla
9894Warn if a variable-length array is used in the code.
9895@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
9896the variable-length array.
9897
9898@item -Wvla-larger-than=@var{byte-size}
9899@opindex Wvla-larger-than=
9900@opindex Wno-vla-larger-than
9901If this option is used, the compiler warns for declarations of
9902variable-length arrays whose size is either unbounded, or bounded
9903by an argument that allows the array size to exceed @var{byte-size}
9904bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
9905works, but with variable-length arrays.
9906
9907Note that GCC may optimize small variable-length arrays of a known
9908value into plain arrays, so this warning may not get triggered for
9909such arrays.
9910
9911@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
9912is typically only effective when @option{-ftree-vrp} is active (default
9913for @option{-O2} and above).
9914
9915See also @option{-Walloca-larger-than=@var{byte-size}}.
9916
9917@item -Wno-vla-larger-than
9918@opindex Wno-vla-larger-than
9919Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
9920to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
9921
9922@item -Wvla-parameter
9923@opindex Wno-vla-parameter
9924Warn about redeclarations of functions involving arguments of Variable
9925Length Array types of inconsistent kinds or forms, and enable the detection
9926of out-of-bounds accesses to such parameters by warnings such as
9927@option{-Warray-bounds}.
9928
9929If the first function declaration uses the VLA form the bound specified
9930in the array is assumed to be the minimum number of elements expected to
9931be provided in calls to the function and the maximum number of elements
9932accessed by it. Failing to provide arguments of sufficient size or
9933accessing more than the maximum number of elements may be diagnosed.
9934
9935For example, the warning triggers for the following redeclarations because
9936the first one allows an array of any size to be passed to @code{f} while
9937the second one specifies that the array argument must have at least @code{n}
9938elements. In addition, calling @code{f} with the associated VLA bound
9939parameter in excess of the actual VLA bound triggers a warning as well.
9940
9941@smallexample
9942void f (int n, int[n]);
9943void f (int, int[]); // warning: argument 2 previously declared as a VLA
9944
9945void g (int n)
9946@{
9947 if (n > 4)
9948 return;
9949 int a[n];
9950 f (sizeof a, a); // warning: access to a by f may be out of bounds
9951 @dots{}
9952@}
9953
9954@end smallexample
9955
9956@option{-Wvla-parameter} is included in @option{-Wall}. The
9957@option{-Warray-parameter} option triggers warnings for similar problems
9958involving ordinary array arguments.
9959
9960@item -Wvolatile-register-var
9961@opindex Wvolatile-register-var
9962@opindex Wno-volatile-register-var
9963Warn if a register variable is declared volatile. The volatile
9964modifier does not inhibit all optimizations that may eliminate reads
9965and/or writes to register variables. This warning is enabled by
9966@option{-Wall}.
9967
9968@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
9969@opindex Wxor-used-as-pow
9970@opindex Wno-xor-used-as-pow
9971Warn about uses of @code{^}, the exclusive or operator, where it appears
9972the user meant exponentiation. Specifically, the warning occurs when the
9973left-hand side is the decimal constant 2 or 10 and the right-hand side
9974is also a decimal constant.
9975
9976In C and C++, @code{^} means exclusive or, whereas in some other languages
9977(e.g. TeX and some versions of BASIC) it means exponentiation.
9978
9979This warning is enabled by default. It can be silenced by converting one
9980of the operands to hexadecimal.
9981
9982@item -Wdisabled-optimization
9983@opindex Wdisabled-optimization
9984@opindex Wno-disabled-optimization
9985Warn if a requested optimization pass is disabled. This warning does
9986not generally indicate that there is anything wrong with your code; it
9987merely indicates that GCC's optimizers are unable to handle the code
9988effectively. Often, the problem is that your code is too big or too
9989complex; GCC refuses to optimize programs when the optimization
9990itself is likely to take inordinate amounts of time.
9991
9992@item -Wpointer-sign @r{(C and Objective-C only)}
9993@opindex Wpointer-sign
9994@opindex Wno-pointer-sign
9995Warn for pointer argument passing or assignment with different signedness.
9996This option is only supported for C and Objective-C@. It is implied by
9997@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
9998@option{-Wno-pointer-sign}.
9999
10000@item -Wstack-protector
10001@opindex Wstack-protector
10002@opindex Wno-stack-protector
10003This option is only active when @option{-fstack-protector} is active. It
10004warns about functions that are not protected against stack smashing.
10005
10006@item -Woverlength-strings
10007@opindex Woverlength-strings
10008@opindex Wno-overlength-strings
10009Warn about string constants that are longer than the ``minimum
10010maximum'' length specified in the C standard. Modern compilers
10011generally allow string constants that are much longer than the
10012standard's minimum limit, but very portable programs should avoid
10013using longer strings.
10014
10015The limit applies @emph{after} string constant concatenation, and does
10016not count the trailing NUL@. In C90, the limit was 509 characters; in
10017C99, it was raised to 4095. C++98 does not specify a normative
10018minimum maximum, so we do not diagnose overlength strings in C++@.
10019
10020This option is implied by @option{-Wpedantic}, and can be disabled with
10021@option{-Wno-overlength-strings}.
10022
10023@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
10024@opindex Wunsuffixed-float-constants
10025@opindex Wno-unsuffixed-float-constants
10026
10027Issue a warning for any floating constant that does not have
10028a suffix. When used together with @option{-Wsystem-headers} it
10029warns about such constants in system header files. This can be useful
10030when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10031from the decimal floating-point extension to C99.
10032
10033@item -Wno-lto-type-mismatch
10034@opindex Wlto-type-mismatch
10035@opindex Wno-lto-type-mismatch
10036
10037During the link-time optimization, do not warn about type mismatches in
10038global declarations from different compilation units.
10039Requires @option{-flto} to be enabled. Enabled by default.
10040
10041@item -Wno-designated-init @r{(C and Objective-C only)}
10042@opindex Wdesignated-init
10043@opindex Wno-designated-init
10044Suppress warnings when a positional initializer is used to initialize
10045a structure that has been marked with the @code{designated_init}
10046attribute.
10047
10048@end table
10049
10050@node Static Analyzer Options
10051@section Options That Control Static Analysis
10052
10053@table @gcctabopt
10054@item -fanalyzer
10055@opindex analyzer
10056@opindex fanalyzer
10057@opindex fno-analyzer
10058This option enables an static analysis of program flow which looks
10059for ``interesting'' interprocedural paths through the
10060code, and issues warnings for problems found on them.
10061
10062This analysis is much more expensive than other GCC warnings.
10063
10064Enabling this option effectively enables the following warnings:
10065
10066@gccoptlist{ @gol
10067-Wanalyzer-allocation-size @gol
ce51e843 10068-Wanalyzer-deref-before-check @gol
d77de738
ML
10069-Wanalyzer-double-fclose @gol
10070-Wanalyzer-double-free @gol
10071-Wanalyzer-exposure-through-output-file @gol
10072-Wanalyzer-exposure-through-uninit-copy @gol
10073-Wanalyzer-fd-access-mode-mismatch @gol
10074-Wanalyzer-fd-double-close @gol
10075-Wanalyzer-fd-leak @gol
86a90006
DM
10076-Wanalyzer-fd-phase-mismatch @gol
10077-Wanalyzer-fd-type-mismatch @gol
d77de738
ML
10078-Wanalyzer-fd-use-after-close @gol
10079-Wanalyzer-fd-use-without-check @gol
10080-Wanalyzer-file-leak @gol
10081-Wanalyzer-free-of-non-heap @gol
10082-Wanalyzer-imprecise-fp-arithmetic @gol
ce51e843 10083-Wanalyzer-infinite-recursion @gol
d77de738
ML
10084-Wanalyzer-jump-through-null @gol
10085-Wanalyzer-malloc-leak @gol
10086-Wanalyzer-mismatching-deallocation @gol
10087-Wanalyzer-null-argument @gol
10088-Wanalyzer-null-dereference @gol
10089-Wanalyzer-out-of-bounds @gol
10090-Wanalyzer-possible-null-argument @gol
10091-Wanalyzer-possible-null-dereference @gol
10092-Wanalyzer-putenv-of-auto-var @gol
10093-Wanalyzer-shift-count-negative @gol
10094-Wanalyzer-shift-count-overflow @gol
10095-Wanalyzer-stale-setjmp-buffer @gol
10096-Wanalyzer-unsafe-call-within-signal-handler @gol
10097-Wanalyzer-use-after-free @gol
10098-Wanalyzer-use-of-pointer-in-stale-stack-frame @gol
10099-Wanalyzer-use-of-uninitialized-value @gol
10100-Wanalyzer-va-arg-type-mismatch @gol
10101-Wanalyzer-va-list-exhausted @gol
10102-Wanalyzer-va-list-leak @gol
10103-Wanalyzer-va-list-use-after-va-end @gol
10104-Wanalyzer-write-to-const @gol
10105-Wanalyzer-write-to-string-literal @gol
10106}
10107@ignore
10108-Wanalyzer-tainted-allocation-size @gol
10109-Wanalyzer-tainted-array-index @gol
10110-Wanalyzer-tainted-divisor @gol
10111-Wanalyzer-tainted-offset @gol
10112-Wanalyzer-tainted-size @gol
10113@end ignore
10114
10115This option is only available if GCC was configured with analyzer
10116support enabled.
10117
10118@item -Wanalyzer-too-complex
10119@opindex Wanalyzer-too-complex
10120@opindex Wno-analyzer-too-complex
10121If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10122to attempt to explore the control flow and data flow in the program,
10123but these can be defeated by sufficiently complicated code.
10124
10125By default, the analysis silently stops if the code is too
10126complicated for the analyzer to fully explore and it reaches an internal
10127limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10128
10129@item -Wno-analyzer-allocation-size
10130@opindex Wanalyzer-allocation-size
10131@opindex Wno-analyzer-allocation-size
10132This warning requires @option{-fanalyzer}, which enables it; use
10133@option{-Wno-analyzer-allocation-size}
10134to disable it.
10135
10136This diagnostic warns for paths through the code in which a pointer to
10137a buffer is assigned to point at a buffer with a size that is not a
10138multiple of @code{sizeof (*pointer)}.
10139
10140See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10141
ce51e843
ML
10142@item -Wno-analyzer-deref-before-check
10143@opindex Wanalyzer-deref-before-check
10144@opindex Wno-analyzer-deref-before-check
10145This warning requires @option{-fanalyzer}, which enables it; use
10146@option{-Wno-analyzer-deref-before-check}
10147to disable it.
10148
10149This diagnostic warns for paths through the code in which a pointer
10150is checked for @code{NULL} *after* it has already been
10151dereferenced, suggesting that the pointer could have been NULL.
10152Such cases suggest that the check for NULL is either redundant,
10153or that it needs to be moved to before the pointer is dereferenced.
10154
10155This diagnostic also considers values passed to a function argument
10156marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10157value, and thus will complain if such values are checked for @code{NULL}
10158after returning from such a function call.
10159
10160This diagnostic is unlikely to be reported when any level of optimization
10161is enabled, as GCC's optimization logic will typically consider such
10162checks for NULL as being redundant, and optimize them away before the
10163analyzer "sees" them. Hence optimization should be disabled when
10164attempting to trigger this diagnostic.
10165
d77de738
ML
10166@item -Wno-analyzer-double-fclose
10167@opindex Wanalyzer-double-fclose
10168@opindex Wno-analyzer-double-fclose
10169This warning requires @option{-fanalyzer}, which enables it; use
10170@option{-Wno-analyzer-double-fclose} to disable it.
10171
10172This diagnostic warns for paths through the code in which a @code{FILE *}
10173can have @code{fclose} called on it more than once.
10174
10175See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10176
10177@item -Wno-analyzer-double-free
10178@opindex Wanalyzer-double-free
10179@opindex Wno-analyzer-double-free
10180This warning requires @option{-fanalyzer}, which enables it; use
10181@option{-Wno-analyzer-double-free} to disable it.
10182
10183This diagnostic warns for paths through the code in which a pointer
10184can have a deallocator called on it more than once, either @code{free},
10185or a deallocator referenced by attribute @code{malloc}.
10186
10187See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10188
10189@item -Wno-analyzer-exposure-through-output-file
10190@opindex Wanalyzer-exposure-through-output-file
10191@opindex Wno-analyzer-exposure-through-output-file
10192This warning requires @option{-fanalyzer}, which enables it; use
10193@option{-Wno-analyzer-exposure-through-output-file}
10194to disable it.
10195
10196This diagnostic warns for paths through the code in which a
10197security-sensitive value is written to an output file
10198(such as writing a password to a log file).
10199
10200See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10201
10202@item -Wanalyzer-exposure-through-uninit-copy
10203@opindex Wanalyzer-exposure-through-uninit-copy
10204@opindex Wno-analyzer-exposure-through-uninit-copy
10205This warning requires both @option{-fanalyzer} and the use of a plugin
10206to specify a function that copies across a ``trust boundary''. Use
10207@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10208
10209This diagnostic warns for ``infoleaks'' - paths through the code in which
10210uninitialized values are copied across a security boundary
10211(such as code within an OS kernel that copies a partially-initialized
10212struct on the stack to user space).
10213
10214See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10215
10216@item -Wno-analyzer-fd-access-mode-mismatch
10217@opindex Wanalyzer-fd-access-mode-mismatch
10218@opindex Wno-analyzer-fd-access-mode-mismatch
10219This warning requires @option{-fanalyzer}, which enables it; use
10220@option{-Wno-analyzer-fd-access-mode-mismatch}
10221to disable it.
10222
10223This diagnostic warns for paths through code in which a
10224@code{read} on a write-only file descriptor is attempted, or vice versa.
10225
10226This diagnostic also warns for code paths in a which a function with attribute
10227@code{fd_arg_read (N)} is called with a file descriptor opened with
10228@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10229@code{fd_arg_write (N)} is called with a file descriptor opened with
10230@code{O_RDONLY} at referenced argument @var{N}.
10231
10232@item -Wno-analyzer-fd-double-close
10233@opindex Wanalyzer-fd-double-close
10234@opindex Wno-analyzer-fd-double-close
10235This warning requires @option{-fanalyzer}, which enables it; use
10236@option{-Wno-analyzer-fd-double-close}
10237to disable it.
10238
10239This diagnostic warns for paths through code in which a
10240file descriptor can be closed more than once.
10241
10242See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10243
10244@item -Wno-analyzer-fd-leak
10245@opindex Wanalyzer-fd-leak
10246@opindex Wno-analyzer-fd-leak
10247This warning requires @option{-fanalyzer}, which enables it; use
10248@option{-Wno-analyzer-fd-leak}
10249to disable it.
10250
10251This diagnostic warns for paths through code in which an
10252open file descriptor is leaked.
10253
10254See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10255
86a90006
DM
10256@item -Wno-analyzer-fd-phase-mismatch
10257@opindex Wanalyzer-fd-phase-mismatch
10258@opindex Wno-analyzer-fd-phase-mismatch
10259This warning requires @option{-fanalyzer}, which enables it; use
10260@option{-Wno-analyzer-fd-phase-mismatch}
10261to disable it.
10262
10263This diagnostic warns for paths through code in which an operation is
10264attempted in the wrong phase of a file descriptor's lifetime.
10265For example, it will warn on attempts to call @code{accept} on a stream
10266socket that has not yet had @code{listen} successfully called on it.
10267
10268See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10269
10270@item -Wno-analyzer-fd-type-mismatch
10271@opindex Wanalyzer-fd-type-mismatch
10272@opindex Wno-analyzer-fd-type-mismatch
10273This warning requires @option{-fanalyzer}, which enables it; use
10274@option{-Wno-analyzer-fd-type-mismatch}
10275to disable it.
10276
10277This diagnostic warns for paths through code in which an
10278operation is attempted on the wrong type of file descriptor.
10279For example, it will warn on attempts to use socket operations
10280on a file descriptor obtained via @code{open}, or when attempting
10281to use a stream socket operation on a datagram socket.
10282
d77de738
ML
10283@item -Wno-analyzer-fd-use-after-close
10284@opindex Wanalyzer-fd-use-after-close
10285@opindex Wno-analyzer-fd-use-after-close
10286This warning requires @option{-fanalyzer}, which enables it; use
10287@option{-Wno-analyzer-fd-use-after-close}
10288to disable it.
10289
10290This diagnostic warns for paths through code in which a
10291read or write is called on a closed file descriptor.
10292
10293This diagnostic also warns for paths through code in which
10294a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10295or @code{fd_arg_write (N)} is called with a closed file descriptor at
10296referenced argument @code{N}.
10297
10298@item -Wno-analyzer-fd-use-without-check
10299@opindex Wanalyzer-fd-use-without-check
10300@opindex Wno-analyzer-fd-use-without-check
10301This warning requires @option{-fanalyzer}, which enables it; use
10302@option{-Wno-analyzer-fd-use-without-check}
10303to disable it.
10304
10305This diagnostic warns for paths through code in which a
10306file descriptor is used without being checked for validity.
10307
10308This diagnostic also warns for paths through code in which
10309a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10310or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10311argument @code{N}, without being checked for validity.
10312
10313@item -Wno-analyzer-file-leak
10314@opindex Wanalyzer-file-leak
10315@opindex Wno-analyzer-file-leak
10316This warning requires @option{-fanalyzer}, which enables it; use
10317@option{-Wno-analyzer-file-leak}
10318to disable it.
10319
10320This diagnostic warns for paths through the code in which a
10321@code{<stdio.h>} @code{FILE *} stream object is leaked.
10322
10323See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10324
10325@item -Wno-analyzer-free-of-non-heap
10326@opindex Wanalyzer-free-of-non-heap
10327@opindex Wno-analyzer-free-of-non-heap
10328This warning requires @option{-fanalyzer}, which enables it; use
10329@option{-Wno-analyzer-free-of-non-heap}
10330to disable it.
10331
10332This diagnostic warns for paths through the code in which @code{free}
10333is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10334
10335See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10336
10337@item -Wno-analyzer-imprecise-fp-arithmetic
10338@opindex Wanalyzer-imprecise-fp-arithmetic
10339@opindex Wno-analyzer-imprecise-fp-arithmetic
10340This warning requires @option{-fanalyzer}, which enables it; use
10341@option{-Wno-analyzer-imprecise-fp-arithmetic}
10342to disable it.
10343
10344This diagnostic warns for paths through the code in which floating-point
10345arithmetic is used in locations where precise computation is needed. This
10346diagnostic only warns on use of floating-point operands inside the
10347calculation of an allocation size at the moment.
10348
ce51e843
ML
10349@item -Wno-analyzer-infinite-recursion
10350@opindex Wanalyzer-infinite-recursion
10351@opindex Wno-analyzer-infinite-recursion
10352This warning requires @option{-fanalyzer}, which enables it; use
10353@option{-Wno-analyzer-infinite-recursion} to disable it.
10354
10355This diagnostics warns for paths through the code which appear to
10356lead to infinite recursion.
10357
10358Specifically, when the analyzer "sees" a recursive call, it will compare
10359the state of memory at the entry to the new frame with that at the entry
10360to the previous frame of that function on the stack. The warning is
10361issued if nothing in memory appears to be changing; any changes observed
10362to parameters or globals are assumed to lead to termination of the
10363recursion and thus suppress the warning.
10364
10365This diagnostic is likely to miss cases of infinite recursion that
10366are convered to iteration by the optimizer before the analyzer "sees"
10367them. Hence optimization should be disabled when attempting to trigger
10368this diagnostic.
10369
10370Compare with @option{-Winfinite-recursion}, which provides a similar
10371diagnostic, but is implemented in a different way.
10372
d77de738
ML
10373@item -Wno-analyzer-jump-through-null
10374@opindex Wanalyzer-jump-through-null
10375@opindex Wno-analyzer-jump-through-null
10376This warning requires @option{-fanalyzer}, which enables it; use
10377@option{-Wno-analyzer-jump-through-null}
10378to disable it.
10379
10380This diagnostic warns for paths through the code in which a @code{NULL}
10381function pointer is called.
10382
10383@item -Wno-analyzer-malloc-leak
10384@opindex Wanalyzer-malloc-leak
10385@opindex Wno-analyzer-malloc-leak
10386This warning requires @option{-fanalyzer}, which enables it; use
10387@option{-Wno-analyzer-malloc-leak}
10388to disable it.
10389
10390This diagnostic warns for paths through the code in which a
10391pointer allocated via an allocator is leaked: either @code{malloc},
10392or a function marked with attribute @code{malloc}.
10393
10394See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10395
10396@item -Wno-analyzer-mismatching-deallocation
10397@opindex Wanalyzer-mismatching-deallocation
10398@opindex Wno-analyzer-mismatching-deallocation
10399This warning requires @option{-fanalyzer}, which enables it; use
10400@option{-Wno-analyzer-mismatching-deallocation}
10401to disable it.
10402
10403This diagnostic warns for paths through the code in which the
10404wrong deallocation function is called on a pointer value, based on
10405which function was used to allocate the pointer value. The diagnostic
10406will warn about mismatches between @code{free}, scalar @code{delete}
10407and vector @code{delete[]}, and those marked as allocator/deallocator
10408pairs using attribute @code{malloc}.
10409
10410See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10411
10412@item -Wno-analyzer-out-of-bounds
10413@opindex Wanalyzer-out-of-bounds
10414@opindex Wno-analyzer-out-of-bounds
10415This warning requires @option{-fanalyzer} to enable it; use
10416@option{-Wno-analyzer-out-of-bounds} to disable it.
10417
10418This diagnostic warns for path through the code in which a buffer is
10419definitely read or written out-of-bounds. The diagnostic applies for
10420cases where the analyzer is able to determine a constant offset and for
10421accesses past the end of a buffer, also a constant capacity. Further,
10422the diagnostic does limited checking for accesses past the end when the
10423offset as well as the capacity is symbolic.
10424
10425See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10426
10427@item -Wno-analyzer-possible-null-argument
10428@opindex Wanalyzer-possible-null-argument
10429@opindex Wno-analyzer-possible-null-argument
10430This warning requires @option{-fanalyzer}, which enables it; use
10431@option{-Wno-analyzer-possible-null-argument} to disable it.
10432
10433This diagnostic warns for paths through the code in which a
10434possibly-NULL value is passed to a function argument marked
10435with @code{__attribute__((nonnull))} as requiring a non-NULL
10436value.
10437
10438See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10439
10440@item -Wno-analyzer-possible-null-dereference
10441@opindex Wanalyzer-possible-null-dereference
10442@opindex Wno-analyzer-possible-null-dereference
10443This warning requires @option{-fanalyzer}, which enables it; use
10444@option{-Wno-analyzer-possible-null-dereference} to disable it.
10445
10446This diagnostic warns for paths through the code in which a
10447possibly-NULL value is dereferenced.
10448
10449See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10450
10451@item -Wno-analyzer-null-argument
10452@opindex Wanalyzer-null-argument
10453@opindex Wno-analyzer-null-argument
10454This warning requires @option{-fanalyzer}, which enables it; use
10455@option{-Wno-analyzer-null-argument} to disable it.
10456
10457This diagnostic warns for paths through the code in which a
10458value known to be NULL is passed to a function argument marked
10459with @code{__attribute__((nonnull))} as requiring a non-NULL
10460value.
10461
10462See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10463
10464@item -Wno-analyzer-null-dereference
10465@opindex Wanalyzer-null-dereference
10466@opindex Wno-analyzer-null-dereference
10467This warning requires @option{-fanalyzer}, which enables it; use
10468@option{-Wno-analyzer-null-dereference} to disable it.
10469
10470This diagnostic warns for paths through the code in which a
10471value known to be NULL is dereferenced.
10472
10473See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10474
10475@item -Wno-analyzer-putenv-of-auto-var
10476@opindex Wanalyzer-putenv-of-auto-var
10477@opindex Wno-analyzer-putenv-of-auto-var
10478This warning requires @option{-fanalyzer}, which enables it; use
10479@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10480
10481This diagnostic warns for paths through the code in which a
10482call to @code{putenv} is passed a pointer to an automatic variable
10483or an on-stack buffer.
10484
10485See @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}.
10486
10487@item -Wno-analyzer-shift-count-negative
10488@opindex Wanalyzer-shift-count-negative
10489@opindex Wno-analyzer-shift-count-negative
10490This warning requires @option{-fanalyzer}, which enables it; use
10491@option{-Wno-analyzer-shift-count-negative} to disable it.
10492
10493This diagnostic warns for paths through the code in which a
10494shift is attempted with a negative count. It is analogous to
10495the @option{-Wshift-count-negative} diagnostic implemented in
10496the C/C++ front ends, but is implemented based on analyzing
10497interprocedural paths, rather than merely parsing the syntax tree.
10498However, the analyzer does not prioritize detection of such paths, so
10499false negatives are more likely relative to other warnings.
10500
10501@item -Wno-analyzer-shift-count-overflow
10502@opindex Wanalyzer-shift-count-overflow
10503@opindex Wno-analyzer-shift-count-overflow
10504This warning requires @option{-fanalyzer}, which enables it; use
10505@option{-Wno-analyzer-shift-count-overflow} to disable it.
10506
10507This diagnostic warns for paths through the code in which a
10508shift is attempted with a count greater than or equal to the
10509precision of the operand's type. It is analogous to
10510the @option{-Wshift-count-overflow} diagnostic implemented in
10511the C/C++ front ends, but is implemented based on analyzing
10512interprocedural paths, rather than merely parsing the syntax tree.
10513However, the analyzer does not prioritize detection of such paths, so
10514false negatives are more likely relative to other warnings.
10515
10516@item -Wno-analyzer-stale-setjmp-buffer
10517@opindex Wanalyzer-stale-setjmp-buffer
10518@opindex Wno-analyzer-stale-setjmp-buffer
10519This warning requires @option{-fanalyzer}, which enables it; use
10520@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10521
10522This diagnostic warns for paths through the code in which
10523@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10524to a @code{setjmp} call in a function that has returned.
10525
10526When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10527location, it records the stack frame. The stack frame becomes invalid
10528when the function containing the @code{setjmp} call returns. Attempting
10529to rewind to it via @code{longjmp} would reference a stack frame that
10530no longer exists, and likely lead to a crash (or worse).
10531
10532@item -Wno-analyzer-tainted-allocation-size
10533@opindex Wanalyzer-tainted-allocation-size
10534@opindex Wno-analyzer-tainted-allocation-size
10535This warning requires both @option{-fanalyzer} and
10536@option{-fanalyzer-checker=taint} to enable it;
10537use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10538
10539This diagnostic warns for paths through the code in which a value
10540that could be under an attacker's control is used as the size
10541of an allocation without being sanitized, so that an attacker could
10542inject an excessively large allocation and potentially cause a denial
10543of service attack.
10544
10545See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10546
ce51e843
ML
10547@item -Wno-analyzer-tainted-assertion
10548@opindex Wanalyzer-tainted-assertion
10549@opindex Wno-analyzer-tainted-assertion
10550
10551This warning requires both @option{-fanalyzer} and
10552@option{-fanalyzer-checker=taint} to enable it;
10553use @option{-Wno-analyzer-tainted-assertion} to disable it.
10554
10555This diagnostic warns for paths through the code in which a value
10556that could be under an attacker's control is used as part of a
10557condition without being first sanitized, and that condition guards a
10558call to a function marked with attribute @code{noreturn}
10559(such as the function @code{__builtin_unreachable}). Such functions
10560typically indicate abnormal termination of the program, such as for
10561assertion failure handlers. For example:
10562
10563@smallexample
10564assert (some_tainted_value < SOME_LIMIT);
10565@end smallexample
10566
10567In such cases:
10568
10569@itemize
10570@item
10571when assertion-checking is enabled: an attacker could trigger
10572a denial of service by injecting an assertion failure
10573
10574@item
10575when assertion-checking is disabled, such as by defining @code{NDEBUG},
10576an attacker could inject data that subverts the process, since it
10577presumably violates a precondition that is being assumed by the code.
10578
10579@end itemize
10580
10581Note that when assertion-checking is disabled, the assertions are
10582typically removed by the preprocessor before the analyzer has a chance
10583to "see" them, so this diagnostic can only generate warnings on builds
10584in which assertion-checking is enabled.
10585
10586For the purpose of this warning, any function marked with attribute
10587@code{noreturn} is considered as a possible assertion failure
10588handler, including @code{__builtin_unreachable}. Note that these functions
10589are sometimes removed by the optimizer before the analyzer "sees" them.
10590Hence optimization should be disabled when attempting to trigger this
10591diagnostic.
10592
10593See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10594
10595The warning can also report problematic constructions such as
10596
10597@smallexample
10598switch (some_tainted_value) @{
10599case 0:
10600 /* [...etc; various valid cases omitted...] */
10601 break;
10602
10603default:
10604 __builtin_unreachable (); /* BUG: attacker can trigger this */
10605@}
10606@end smallexample
10607
10608despite the above not being an assertion failure, strictly speaking.
10609
d77de738
ML
10610@item -Wno-analyzer-tainted-array-index
10611@opindex Wanalyzer-tainted-array-index
10612@opindex Wno-analyzer-tainted-array-index
10613This warning requires both @option{-fanalyzer} and
10614@option{-fanalyzer-checker=taint} to enable it;
10615use @option{-Wno-analyzer-tainted-array-index} to disable it.
10616
10617This diagnostic warns for paths through the code in which a value
10618that could be under an attacker's control is used as the index
10619of an array access without being sanitized, so that an attacker
10620could inject an out-of-bounds access.
10621
10622See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10623
10624@item -Wno-analyzer-tainted-divisor
10625@opindex Wanalyzer-tainted-divisor
10626@opindex Wno-analyzer-tainted-divisor
10627This warning requires both @option{-fanalyzer} and
10628@option{-fanalyzer-checker=taint} to enable it;
10629use @option{-Wno-analyzer-tainted-divisor} to disable it.
10630
10631This diagnostic warns for paths through the code in which a value
10632that could be under an attacker's control is used as the divisor
10633in a division or modulus operation without being sanitized, so that
10634an attacker could inject a division-by-zero.
10635
10636See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10637
10638@item -Wno-analyzer-tainted-offset
10639@opindex Wanalyzer-tainted-offset
10640@opindex Wno-analyzer-tainted-offset
10641This warning requires both @option{-fanalyzer} and
10642@option{-fanalyzer-checker=taint} to enable it;
10643use @option{-Wno-analyzer-tainted-offset} to disable it.
10644
10645This diagnostic warns for paths through the code in which a value
10646that could be under an attacker's control is used as a pointer offset
10647without being sanitized, so that an attacker could inject an out-of-bounds
10648access.
10649
10650See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10651
10652@item -Wno-analyzer-tainted-size
10653@opindex Wanalyzer-tainted-size
10654@opindex Wno-analyzer-tainted-size
10655This warning requires both @option{-fanalyzer} and
10656@option{-fanalyzer-checker=taint} to enable it;
10657use @option{-Wno-analyzer-tainted-size} to disable it.
10658
10659This diagnostic warns for paths through the code in which a value
10660that could be under an attacker's control is used as the size of
10661an operation such as @code{memset} without being sanitized, so that an
10662attacker could inject an out-of-bounds access.
10663
10664See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10665
10666@item -Wno-analyzer-unsafe-call-within-signal-handler
10667@opindex Wanalyzer-unsafe-call-within-signal-handler
10668@opindex Wno-analyzer-unsafe-call-within-signal-handler
10669This warning requires @option{-fanalyzer}, which enables it; use
10670@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10671
10672This diagnostic warns for paths through the code in which a
10673function known to be async-signal-unsafe (such as @code{fprintf}) is
10674called from a signal handler.
10675
10676See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10677
10678@item -Wno-analyzer-use-after-free
10679@opindex Wanalyzer-use-after-free
10680@opindex Wno-analyzer-use-after-free
10681This warning requires @option{-fanalyzer}, which enables it; use
10682@option{-Wno-analyzer-use-after-free} to disable it.
10683
10684This diagnostic warns for paths through the code in which a
10685pointer is used after a deallocator is called on it: either @code{free},
10686or a deallocator referenced by attribute @code{malloc}.
10687
10688See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
10689
10690@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
10691@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
10692@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
10693This warning requires @option{-fanalyzer}, which enables it; use
10694@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
10695to disable it.
10696
10697This diagnostic warns for paths through the code in which a pointer
10698is dereferenced that points to a variable in a stale stack frame.
10699
10700@item -Wno-analyzer-va-arg-type-mismatch
10701@opindex Wanalyzer-va-arg-type-mismatch
10702@opindex Wno-analyzer-va-arg-type-mismatch
10703This warning requires @option{-fanalyzer}, which enables it; use
10704@option{-Wno-analyzer-va-arg-type-mismatch}
10705to disable it.
10706
10707This diagnostic warns for interprocedural paths through the code for which
10708the analyzer detects an attempt to use @code{va_arg} to extract a value
10709passed to a variadic call, but uses a type that does not match that of
10710the expression passed to the call.
10711
10712See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
10713
10714@item -Wno-analyzer-va-list-exhausted
10715@opindex Wanalyzer-va-list-exhausted
10716@opindex Wno-analyzer-va-list-exhausted
10717This warning requires @option{-fanalyzer}, which enables it; use
10718@option{-Wno-analyzer-va-list-exhausted}
10719to disable it.
10720
10721This diagnostic warns for interprocedural paths through the code for which
10722the analyzer detects an attempt to use @code{va_arg} to access the next
10723value passed to a variadic call, but all of the values in the
10724@code{va_list} have already been consumed.
10725
10726See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
10727
10728@item -Wno-analyzer-va-list-leak
10729@opindex Wanalyzer-va-list-leak
10730@opindex Wno-analyzer-va-list-leak
10731This warning requires @option{-fanalyzer}, which enables it; use
10732@option{-Wno-analyzer-va-list-leak}
10733to disable it.
10734
10735This diagnostic warns for interprocedural paths through the code for which
10736the analyzer detects that @code{va_start} or @code{va_copy} has been called
10737on a @code{va_list} without a corresponding call to @code{va_end}.
10738
10739@item -Wno-analyzer-va-list-use-after-va-end
10740@opindex Wanalyzer-va-list-use-after-va-end
10741@opindex Wno-analyzer-va-list-use-after-va-end
10742This warning requires @option{-fanalyzer}, which enables it; use
10743@option{-Wno-analyzer-va-list-use-after-va-end}
10744to disable it.
10745
10746This diagnostic warns for interprocedural paths through the code for which
10747the analyzer detects an attempt to use a @code{va_list} after
10748@code{va_end} has been called on it.
10749@code{va_list}.
10750
10751@item -Wno-analyzer-write-to-const
10752@opindex Wanalyzer-write-to-const
10753@opindex Wno-analyzer-write-to-const
10754This warning requires @option{-fanalyzer}, which enables it; use
10755@option{-Wno-analyzer-write-to-const}
10756to disable it.
10757
10758This diagnostic warns for paths through the code in which the analyzer
10759detects an attempt to write through a pointer to a @code{const} object.
10760However, the analyzer does not prioritize detection of such paths, so
10761false negatives are more likely relative to other warnings.
10762
10763@item -Wno-analyzer-write-to-string-literal
10764@opindex Wanalyzer-write-to-string-literal
10765@opindex Wno-analyzer-write-to-string-literal
10766This warning requires @option{-fanalyzer}, which enables it; use
10767@option{-Wno-analyzer-write-to-string-literal}
10768to disable it.
10769
10770This diagnostic warns for paths through the code in which the analyzer
10771detects an attempt to write through a pointer to a string literal.
10772However, the analyzer does not prioritize detection of such paths, so
10773false negatives are more likely relative to other warnings.
10774
10775@item -Wno-analyzer-use-of-uninitialized-value
10776@opindex Wanalyzer-use-of-uninitialized-value
10777@opindex Wno-analyzer-use-of-uninitialized-value
10778This warning requires @option{-fanalyzer}, which enables it; use
10779@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
10780
10781This diagnostic warns for paths through the code in which an uninitialized
10782value is used.
10783
10784See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
10785
10786@end table
10787
10788The analyzer has hardcoded knowledge about the behavior of the following
10789memory-management functions:
10790
10791@itemize @bullet
10792@item @code{alloca}
10793@item The built-in functions @code{__builtin_alloc},
10794@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
10795@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
10796@code{__builtin_memcpy_chk}, @code{__builtin_memset},
10797@code{__builtin_memset_chk}, @code{__builtin_realloc},
10798@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
10799@item @code{calloc}
10800@item @code{free}
10801@item @code{malloc}
10802@item @code{memset}
10803@item @code{operator delete}
10804@item @code{operator delete []}
10805@item @code{operator new}
10806@item @code{operator new []}
10807@item @code{realloc}
10808@item @code{strdup}
10809@item @code{strndup}
10810@end itemize
10811
10812of the following functions for working with file descriptors:
10813
10814@itemize @bullet
10815@item @code{open}
10816@item @code{close}
10817@item @code{creat}
10818@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 10819@item @code{isatty}
d77de738
ML
10820@item @code{pipe}, and @code{pipe2}
10821@item @code{read}
10822@item @code{write}
86a90006 10823@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
10824@end itemize
10825
10826of the following functions for working with @code{<stdio.h>} streams:
10827@itemize @bullet
10828@item The built-in functions @code{__builtin_fprintf},
10829@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
10830@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
10831@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
10832@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
10833@code{__builtin_printf_unlocked}, @code{__builtin_putc},
10834@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
10835@code{__builtin_putc_unlocked}, @code{__builtin_puts},
10836@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
10837@code{__builtin_vprintf}
10838@item @code{fopen}
10839@item @code{fclose}
78a17f44 10840@item @code{ferror}
d77de738
ML
10841@item @code{fgets}
10842@item @code{fgets_unlocked}
78a17f44 10843@item @code{fileno}
d77de738 10844@item @code{fread}
78a17f44 10845@item @code{getc}
d77de738
ML
10846@item @code{getchar}
10847@item @code{fprintf}
10848@item @code{printf}
10849@item @code{fwrite}
10850@end itemize
10851
10852and of the following functions:
10853
10854@itemize @bullet
10855@item The built-in functions @code{__builtin_expect},
10856@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
10857@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
10858@code{__builtin_strlen}, @code{__builtin_va_copy}, and
10859@code{__builtin_va_start}
10860@item The GNU extensions @code{error} and @code{error_at_line}
10861@item @code{getpass}
10862@item @code{longjmp}
10863@item @code{putenv}
10864@item @code{setjmp}
10865@item @code{siglongjmp}
10866@item @code{signal}
10867@item @code{sigsetjmp}
10868@item @code{strchr}
10869@item @code{strlen}
10870@end itemize
10871
10872In addition, various functions with an @code{__analyzer_} prefix have
10873special meaning to the analyzer, described in the GCC Internals manual.
10874
10875Pertinent parameters for controlling the exploration are:
10876@option{--param analyzer-bb-explosion-factor=@var{value}},
10877@option{--param analyzer-max-enodes-per-program-point=@var{value}},
10878@option{--param analyzer-max-recursion-depth=@var{value}}, and
10879@option{--param analyzer-min-snodes-for-call-summary=@var{value}}.
10880
10881The following options control the analyzer.
10882
10883@table @gcctabopt
10884
10885@item -fanalyzer-call-summaries
10886@opindex fanalyzer-call-summaries
10887@opindex fno-analyzer-call-summaries
10888Simplify interprocedural analysis by computing the effect of certain calls,
10889rather than exploring all paths through the function from callsite to each
10890possible return.
10891
10892If enabled, call summaries are only used for functions with more than one
10893call site, and that are sufficiently complicated (as per
10894@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
10895
10896@item -fanalyzer-checker=@var{name}
10897@opindex fanalyzer-checker
10898Restrict the analyzer to run just the named checker, and enable it.
10899
10900Some checkers are disabled by default (even with @option{-fanalyzer}),
10901such as the @code{taint} checker that implements
10902@option{-Wanalyzer-tainted-array-index}, and this option is required
10903to enable them.
10904
10905@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
10906following warnings from @option{-fanalyzer}:
10907
10908@gccoptlist{ @gol
ce51e843 10909-Wanalyzer-deref-before-check @gol
d77de738
ML
10910-Wanalyzer-double-fclose @gol
10911-Wanalyzer-double-free @gol
10912-Wanalyzer-exposure-through-output-file @gol
10913-Wanalyzer-fd-access-mode-mismatch @gol
10914-Wanalyzer-fd-double-close @gol
10915-Wanalyzer-fd-leak @gol
10916-Wanalyzer-fd-use-after-close @gol
10917-Wanalyzer-fd-use-without-check @gol
10918-Wanalyzer-file-leak @gol
10919-Wanalyzer-free-of-non-heap @gol
10920-Wanalyzer-malloc-leak @gol
10921-Wanalyzer-mismatching-deallocation @gol
10922-Wanalyzer-null-argument @gol
10923-Wanalyzer-null-dereference @gol
10924-Wanalyzer-possible-null-argument @gol
10925-Wanalyzer-possible-null-dereference @gol
10926-Wanalyzer-unsafe-call-within-signal-handler @gol
10927-Wanalyzer-use-after-free @gol
10928-Wanalyzer-va-list-leak @gol
10929-Wanalyzer-va-list-use-after-va-end @gol
10930}
10931
10932@item -fno-analyzer-feasibility
10933@opindex fanalyzer-feasibility
10934@opindex fno-analyzer-feasibility
10935This option is intended for analyzer developers.
10936
10937By default the analyzer verifies that there is a feasible control flow path
10938for each diagnostic it emits: that the conditions that hold are not mutually
10939exclusive. Diagnostics for which no feasible path can be found are rejected.
10940This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
10941debugging issues in this code.
10942
10943@item -fanalyzer-fine-grained
10944@opindex fanalyzer-fine-grained
10945@opindex fno-analyzer-fine-grained
10946This option is intended for analyzer developers.
10947
10948Internally the analyzer builds an ``exploded graph'' that combines
10949control flow graphs with data flow information.
10950
10951By default, an edge in this graph can contain the effects of a run
10952of multiple statements within a basic block. With
10953@option{-fanalyzer-fine-grained}, each statement gets its own edge.
10954
10955@item -fanalyzer-show-duplicate-count
10956@opindex fanalyzer-show-duplicate-count
10957@opindex fno-analyzer-show-duplicate-count
10958This option is intended for analyzer developers: if multiple diagnostics
10959have been detected as being duplicates of each other, it emits a note when
10960reporting the best diagnostic, giving the number of additional diagnostics
10961that were suppressed by the deduplication logic.
10962
10963@item -fno-analyzer-state-merge
10964@opindex fanalyzer-state-merge
10965@opindex fno-analyzer-state-merge
10966This option is intended for analyzer developers.
10967
10968By default the analyzer attempts to simplify analysis by merging
10969sufficiently similar states at each program point as it builds its
10970``exploded graph''. With @option{-fno-analyzer-state-merge} this
10971merging can be suppressed, for debugging state-handling issues.
10972
10973@item -fno-analyzer-state-purge
10974@opindex fanalyzer-state-purge
10975@opindex fno-analyzer-state-purge
10976This option is intended for analyzer developers.
10977
10978By default the analyzer attempts to simplify analysis by purging
10979aspects of state at a program point that appear to no longer be relevant
10980e.g. the values of locals that aren't accessed later in the function
10981and which aren't relevant to leak analysis.
10982
10983With @option{-fno-analyzer-state-purge} this purging of state can
10984be suppressed, for debugging state-handling issues.
10985
10986@item -fanalyzer-transitivity
10987@opindex fanalyzer-transitivity
10988@opindex fno-analyzer-transitivity
10989This option enables transitivity of constraints within the analyzer.
10990
10991@item -fno-analyzer-undo-inlining
10992@opindex fanalyzer-undo-inlining
10993@opindex fno-analyzer-undo-inlining
10994This option is intended for analyzer developers.
10995
10996@option{-fanalyzer} runs relatively late compared to other code analysis
10997tools, and some optimizations have already been applied to the code. In
10998particular function inlining may have occurred, leading to the
10999interprocedural execution paths emitted by the analyzer containing
11000function frames that don't correspond to those in the original source
11001code.
11002
11003By default the analyzer attempts to reconstruct the original function
11004frames, and to emit events showing the inlined calls.
11005
11006With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11007the original frame information can be be disabled, which may be of help
11008when debugging issues in the analyzer.
11009
11010@item -fanalyzer-verbose-edges
11011This option is intended for analyzer developers. It enables more
11012verbose, lower-level detail in the descriptions of control flow
11013within diagnostic paths.
11014
11015@item -fanalyzer-verbose-state-changes
11016This option is intended for analyzer developers. It enables more
11017verbose, lower-level detail in the descriptions of events relating
11018to state machines within diagnostic paths.
11019
11020@item -fanalyzer-verbosity=@var{level}
11021This option controls the complexity of the control flow paths that are
11022emitted for analyzer diagnostics.
11023
11024The @var{level} can be one of:
11025
11026@table @samp
11027@item 0
11028At this level, interprocedural call and return events are displayed,
11029along with the most pertinent state-change events relating to
11030a diagnostic. For example, for a double-@code{free} diagnostic,
11031both calls to @code{free} will be shown.
11032
11033@item 1
11034As per the previous level, but also show events for the entry
11035to each function.
11036
11037@item 2
11038As per the previous level, but also show events relating to
11039control flow that are significant to triggering the issue
11040(e.g. ``true path taken'' at a conditional).
11041
11042This level is the default.
11043
11044@item 3
11045As per the previous level, but show all control flow events, not
11046just significant ones.
11047
11048@item 4
11049This level is intended for analyzer developers; it adds various
11050other events intended for debugging the analyzer.
11051
11052@end table
11053
11054@item -fdump-analyzer
11055@opindex fdump-analyzer
11056Dump internal details about what the analyzer is doing to
11057@file{@var{file}.analyzer.txt}.
11058This option is overridden by @option{-fdump-analyzer-stderr}.
11059
11060@item -fdump-analyzer-stderr
11061@opindex fdump-analyzer-stderr
11062Dump internal details about what the analyzer is doing to stderr.
11063This option overrides @option{-fdump-analyzer}.
11064
11065@item -fdump-analyzer-callgraph
11066@opindex fdump-analyzer-callgraph
11067Dump a representation of the call graph suitable for viewing with
11068GraphViz to @file{@var{file}.callgraph.dot}.
11069
11070@item -fdump-analyzer-exploded-graph
11071@opindex fdump-analyzer-exploded-graph
11072Dump a representation of the ``exploded graph'' suitable for viewing with
11073GraphViz to @file{@var{file}.eg.dot}.
11074Nodes are color-coded based on state-machine states to emphasize
11075state changes.
11076
11077@item -fdump-analyzer-exploded-nodes
11078@opindex dump-analyzer-exploded-nodes
11079Emit diagnostics showing where nodes in the ``exploded graph'' are
11080in relation to the program source.
11081
11082@item -fdump-analyzer-exploded-nodes-2
11083@opindex dump-analyzer-exploded-nodes-2
11084Dump a textual representation of the ``exploded graph'' to
11085@file{@var{file}.eg.txt}.
11086
11087@item -fdump-analyzer-exploded-nodes-3
11088@opindex dump-analyzer-exploded-nodes-3
11089Dump a textual representation of the ``exploded graph'' to
11090one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11091This is typically a large number of dump files.
11092
11093@item -fdump-analyzer-exploded-paths
11094@opindex fdump-analyzer-exploded-paths
11095Dump a textual representation of the ``exploded path'' for each
11096diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11097
11098@item -fdump-analyzer-feasibility
11099@opindex dump-analyzer-feasibility
11100Dump internal details about the analyzer's search for feasible paths.
11101The details are written in a form suitable for viewing with GraphViz
11102to filenames of the form @file{@var{file}.*.fg.dot},
11103@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11104
11105@item -fdump-analyzer-json
11106@opindex fdump-analyzer-json
11107Dump a compressed JSON representation of analyzer internals to
11108@file{@var{file}.analyzer.json.gz}. The precise format is subject
11109to change.
11110
11111@item -fdump-analyzer-state-purge
11112@opindex fdump-analyzer-state-purge
11113As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11114``supergraph'' suitable for viewing with GraphViz, but annotate the
11115graph with information on what state will be purged at each node.
11116The graph is written to @file{@var{file}.state-purge.dot}.
11117
11118@item -fdump-analyzer-supergraph
11119@opindex fdump-analyzer-supergraph
11120Dump representations of the ``supergraph'' suitable for viewing with
11121GraphViz to @file{@var{file}.supergraph.dot} and to
11122@file{@var{file}.supergraph-eg.dot}. These show all of the
11123control flow graphs in the program, with interprocedural edges for
11124calls and returns. The second dump contains annotations showing nodes
11125in the ``exploded graph'' and diagnostics associated with them.
11126
11127@item -fdump-analyzer-untracked
11128@opindex fdump-analyzer-untracked
11129Emit custom warnings with internal details intended for analyzer developers.
11130
11131@end table
11132
11133@node Debugging Options
11134@section Options for Debugging Your Program
11135@cindex options, debugging
11136@cindex debugging information options
11137
11138To tell GCC to emit extra information for use by a debugger, in almost
11139all cases you need only to add @option{-g} to your other options. Some debug
11140formats can co-exist (like DWARF with CTF) when each of them is enabled
11141explicitly by adding the respective command line option to your other options.
11142
11143GCC allows you to use @option{-g} with
11144@option{-O}. The shortcuts taken by optimized code may occasionally
11145be surprising: some variables you declared may not exist
11146at all; flow of control may briefly move where you did not expect it;
11147some statements may not be executed because they compute constant
11148results or their values are already at hand; some statements may
11149execute in different places because they have been moved out of loops.
11150Nevertheless it is possible to debug optimized output. This makes
11151it reasonable to use the optimizer for programs that might have bugs.
11152
11153If you are not using some other optimization option, consider
11154using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11155With no @option{-O} option at all, some compiler passes that collect
11156information useful for debugging do not run at all, so that
11157@option{-Og} may result in a better debugging experience.
11158
11159@table @gcctabopt
11160@item -g
11161@opindex g
11162Produce debugging information in the operating system's native format
11163(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11164information.
11165
11166On most systems that use stabs format, @option{-g} enables use of extra
11167debugging information that only GDB can use; this extra information
11168makes debugging work better in GDB but probably makes other debuggers
11169crash or refuse to read the program. If you want to control for certain whether
11170to generate the extra information, use @option{-gvms} (see below).
11171
11172@item -ggdb
11173@opindex ggdb
11174Produce debugging information for use by GDB@. This means to use the
11175most expressive format available (DWARF, stabs, or the native format
11176if neither of those are supported), including GDB extensions if at all
11177possible.
11178
11179@item -gdwarf
11180@itemx -gdwarf-@var{version}
11181@opindex gdwarf
11182Produce debugging information in DWARF format (if that is supported).
11183The value of @var{version} may be either 2, 3, 4 or 5; the default
11184version for most targets is 5 (with the exception of VxWorks, TPF and
11185Darwin/Mac OS X, which default to version 2, and AIX, which defaults
11186to version 4).
11187
11188Note that with DWARF Version 2, some ports require and always
11189use some non-conflicting DWARF 3 extensions in the unwind tables.
11190
11191Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11192for maximum benefit. Version 5 requires GDB 8.0 or higher.
11193
11194GCC no longer supports DWARF Version 1, which is substantially
11195different than Version 2 and later. For historical reasons, some
11196other DWARF-related options such as
11197@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11198in their names, but apply to all currently-supported versions of DWARF.
11199
11200@item -gbtf
11201@opindex gbtf
11202Request BTF debug information. BTF is the default debugging format for the
11203eBPF target. On other targets, like x86, BTF debug information can be
11204generated along with DWARF debug information when both of the debug formats are
11205enabled explicitly via their respective command line options.
11206
11207@item -gctf
11208@itemx -gctf@var{level}
11209@opindex gctf
11210Request CTF debug information and use level to specify how much CTF debug
11211information should be produced. If @option{-gctf} is specified
11212without a value for level, the default level of CTF debug information is 2.
11213
11214CTF debug information can be generated along with DWARF debug information when
11215both of the debug formats are enabled explicitly via their respective command
11216line options.
11217
11218Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11219negates @option{-gctf}.
11220
11221Level 1 produces CTF information for tracebacks only. This includes callsite
11222information, but does not include type information.
11223
11224Level 2 produces type information for entities (functions, data objects etc.)
11225at file-scope or global-scope only.
11226
11227@item -gvms
11228@opindex gvms
11229Produce debugging information in Alpha/VMS debug format (if that is
11230supported). This is the format used by DEBUG on Alpha/VMS systems.
11231
11232@item -g@var{level}
11233@itemx -ggdb@var{level}
11234@itemx -gvms@var{level}
11235Request debugging information and also use @var{level} to specify how
11236much information. The default level is 2.
11237
11238Level 0 produces no debug information at all. Thus, @option{-g0} negates
11239@option{-g}.
11240
11241Level 1 produces minimal information, enough for making backtraces in
11242parts of the program that you don't plan to debug. This includes
11243descriptions of functions and external variables, and line number
11244tables, but no information about local variables.
11245
11246Level 3 includes extra information, such as all the macro definitions
11247present in the program. Some debuggers support macro expansion when
11248you use @option{-g3}.
11249
11250If you use multiple @option{-g} options, with or without level numbers,
11251the last such option is the one that is effective.
11252
11253@option{-gdwarf} does not accept a concatenated debug level, to avoid
11254confusion with @option{-gdwarf-@var{level}}.
11255Instead use an additional @option{-g@var{level}} option to change the
11256debug level for DWARF.
11257
11258@item -fno-eliminate-unused-debug-symbols
11259@opindex feliminate-unused-debug-symbols
11260@opindex fno-eliminate-unused-debug-symbols
11261By default, no debug information is produced for symbols that are not actually
11262used. Use this option if you want debug information for all symbols.
11263
11264@item -femit-class-debug-always
11265@opindex femit-class-debug-always
11266Instead of emitting debugging information for a C++ class in only one
11267object file, emit it in all object files using the class. This option
11268should be used only with debuggers that are unable to handle the way GCC
11269normally emits debugging information for classes because using this
11270option increases the size of debugging information by as much as a
11271factor of two.
11272
11273@item -fno-merge-debug-strings
11274@opindex fmerge-debug-strings
11275@opindex fno-merge-debug-strings
11276Direct the linker to not merge together strings in the debugging
11277information that are identical in different object files. Merging is
11278not supported by all assemblers or linkers. Merging decreases the size
11279of the debug information in the output file at the cost of increasing
11280link processing time. Merging is enabled by default.
11281
11282@item -fdebug-prefix-map=@var{old}=@var{new}
11283@opindex fdebug-prefix-map
11284When compiling files residing in directory @file{@var{old}}, record
11285debugging information describing them as if the files resided in
11286directory @file{@var{new}} instead. This can be used to replace a
11287build-time path with an install-time path in the debug info. It can
11288also be used to change an absolute path to a relative path by using
11289@file{.} for @var{new}. This can give more reproducible builds, which
11290are location independent, but may require an extra command to tell GDB
11291where to find the source files. See also @option{-ffile-prefix-map}.
11292
11293@item -fvar-tracking
11294@opindex fvar-tracking
11295Run variable tracking pass. It computes where variables are stored at each
11296position in code. Better debugging information is then generated
11297(if the debugging information format supports this information).
11298
11299It is enabled by default when compiling with optimization (@option{-Os},
11300@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11301the debug info format supports it.
11302
11303@item -fvar-tracking-assignments
11304@opindex fvar-tracking-assignments
11305@opindex fno-var-tracking-assignments
11306Annotate assignments to user variables early in the compilation and
11307attempt to carry the annotations over throughout the compilation all the
11308way to the end, in an attempt to improve debug information while
11309optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11310
11311It can be enabled even if var-tracking is disabled, in which case
11312annotations are created and maintained, but discarded at the end.
11313By default, this flag is enabled together with @option{-fvar-tracking},
11314except when selective scheduling is enabled.
11315
11316@item -gsplit-dwarf
11317@opindex gsplit-dwarf
11318If DWARF debugging information is enabled, separate as much debugging
11319information as possible into a separate output file with the extension
11320@file{.dwo}. This option allows the build system to avoid linking files with
11321debug information. To be useful, this option requires a debugger capable of
11322reading @file{.dwo} files.
11323
11324@item -gdwarf32
11325@itemx -gdwarf64
11326@opindex gdwarf32
11327@opindex gdwarf64
11328If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11329the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11330DWARF format. The default is target specific, on most targets it is
11331@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11332can't support more than 2GiB of debug information in any of the DWARF
11333debug information sections. The 64-bit DWARF format allows larger debug
11334information and might not be well supported by all consumers yet.
11335
11336@item -gdescribe-dies
11337@opindex gdescribe-dies
11338Add description attributes to some DWARF DIEs that have no name attribute,
11339such as artificial variables, external references and call site
11340parameter DIEs.
11341
11342@item -gpubnames
11343@opindex gpubnames
11344Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11345
11346@item -ggnu-pubnames
11347@opindex ggnu-pubnames
11348Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11349suitable for conversion into a GDB@ index. This option is only useful
11350with a linker that can produce GDB@ index version 7.
11351
11352@item -fdebug-types-section
11353@opindex fdebug-types-section
11354@opindex fno-debug-types-section
11355When using DWARF Version 4 or higher, type DIEs can be put into
11356their own @code{.debug_types} section instead of making them part of the
11357@code{.debug_info} section. It is more efficient to put them in a separate
11358comdat section since the linker can then remove duplicates.
11359But not all DWARF consumers support @code{.debug_types} sections yet
11360and on some objects @code{.debug_types} produces larger instead of smaller
11361debugging information.
11362
11363@item -grecord-gcc-switches
11364@itemx -gno-record-gcc-switches
11365@opindex grecord-gcc-switches
11366@opindex gno-record-gcc-switches
11367This switch causes the command-line options used to invoke the
11368compiler that may affect code generation to be appended to the
11369DW_AT_producer attribute in DWARF debugging information. The options
11370are concatenated with spaces separating them from each other and from
11371the compiler version.
11372It is enabled by default.
11373See also @option{-frecord-gcc-switches} for another
11374way of storing compiler options into the object file.
11375
11376@item -gstrict-dwarf
11377@opindex gstrict-dwarf
11378Disallow using extensions of later DWARF standard version than selected
11379with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11380DWARF extensions from later standard versions is allowed.
11381
11382@item -gno-strict-dwarf
11383@opindex gno-strict-dwarf
11384Allow using extensions of later DWARF standard version than selected with
11385@option{-gdwarf-@var{version}}.
11386
11387@item -gas-loc-support
11388@opindex gas-loc-support
11389Inform the compiler that the assembler supports @code{.loc} directives.
11390It may then use them for the assembler to generate DWARF2+ line number
11391tables.
11392
11393This is generally desirable, because assembler-generated line-number
11394tables are a lot more compact than those the compiler can generate
11395itself.
11396
11397This option will be enabled by default if, at GCC configure time, the
11398assembler was found to support such directives.
11399
11400@item -gno-as-loc-support
11401@opindex gno-as-loc-support
11402Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11403line number tables are to be generated.
11404
11405@item -gas-locview-support
11406@opindex gas-locview-support
11407Inform the compiler that the assembler supports @code{view} assignment
11408and reset assertion checking in @code{.loc} directives.
11409
11410This option will be enabled by default if, at GCC configure time, the
11411assembler was found to support them.
11412
11413@item -gno-as-locview-support
11414Force GCC to assign view numbers internally, if
11415@option{-gvariable-location-views} are explicitly requested.
11416
11417@item -gcolumn-info
11418@itemx -gno-column-info
11419@opindex gcolumn-info
11420@opindex gno-column-info
11421Emit location column information into DWARF debugging information, rather
11422than just file and line.
11423This option is enabled by default.
11424
11425@item -gstatement-frontiers
11426@itemx -gno-statement-frontiers
11427@opindex gstatement-frontiers
11428@opindex gno-statement-frontiers
11429This option causes GCC to create markers in the internal representation
11430at the beginning of statements, and to keep them roughly in place
11431throughout compilation, using them to guide the output of @code{is_stmt}
11432markers in the line number table. This is enabled by default when
11433compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11434@dots{}), and outputting DWARF 2 debug information at the normal level.
11435
11436@item -gvariable-location-views
11437@itemx -gvariable-location-views=incompat5
11438@itemx -gno-variable-location-views
11439@opindex gvariable-location-views
11440@opindex gvariable-location-views=incompat5
11441@opindex gno-variable-location-views
11442Augment variable location lists with progressive view numbers implied
11443from the line number table. This enables debug information consumers to
11444inspect state at certain points of the program, even if no instructions
11445associated with the corresponding source locations are present at that
11446point. If the assembler lacks support for view numbers in line number
11447tables, this will cause the compiler to emit the line number table,
11448which generally makes them somewhat less compact. The augmented line
11449number tables and location lists are fully backward-compatible, so they
11450can be consumed by debug information consumers that are not aware of
11451these augmentations, but they won't derive any benefit from them either.
11452
11453This is enabled by default when outputting DWARF 2 debug information at
11454the normal level, as long as there is assembler support,
11455@option{-fvar-tracking-assignments} is enabled and
11456@option{-gstrict-dwarf} is not. When assembler support is not
11457available, this may still be enabled, but it will force GCC to output
11458internal line number tables, and if
11459@option{-ginternal-reset-location-views} is not enabled, that will most
11460certainly lead to silently mismatching location views.
11461
11462There is a proposed representation for view numbers that is not backward
11463compatible with the location list format introduced in DWARF 5, that can
11464be enabled with @option{-gvariable-location-views=incompat5}. This
11465option may be removed in the future, is only provided as a reference
11466implementation of the proposed representation. Debug information
11467consumers are not expected to support this extended format, and they
11468would be rendered unable to decode location lists using it.
11469
11470@item -ginternal-reset-location-views
11471@itemx -gno-internal-reset-location-views
11472@opindex ginternal-reset-location-views
11473@opindex gno-internal-reset-location-views
11474Attempt to determine location views that can be omitted from location
11475view lists. This requires the compiler to have very accurate insn
11476length estimates, which isn't always the case, and it may cause
11477incorrect view lists to be generated silently when using an assembler
11478that does not support location view lists. The GNU assembler will flag
11479any such error as a @code{view number mismatch}. This is only enabled
11480on ports that define a reliable estimation function.
11481
11482@item -ginline-points
11483@itemx -gno-inline-points
11484@opindex ginline-points
11485@opindex gno-inline-points
11486Generate extended debug information for inlined functions. Location
11487view tracking markers are inserted at inlined entry points, so that
11488address and view numbers can be computed and output in debug
11489information. This can be enabled independently of location views, in
11490which case the view numbers won't be output, but it can only be enabled
11491along with statement frontiers, and it is only enabled by default if
11492location views are enabled.
11493
11494@item -gz@r{[}=@var{type}@r{]}
11495@opindex gz
11496Produce compressed debug sections in DWARF format, if that is supported.
11497If @var{type} is not given, the default type depends on the capabilities
11498of the assembler and linker used. @var{type} may be one of
11499@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11500compression in ELF gABI format). If the linker doesn't support writing
11501compressed debug sections, the option is rejected. Otherwise, if the
11502assembler does not support them, @option{-gz} is silently ignored when
11503producing object files.
11504
11505@item -femit-struct-debug-baseonly
11506@opindex femit-struct-debug-baseonly
11507Emit debug information for struct-like types
11508only when the base name of the compilation source file
11509matches the base name of file in which the struct is defined.
11510
11511This option substantially reduces the size of debugging information,
11512but at significant potential loss in type information to the debugger.
11513See @option{-femit-struct-debug-reduced} for a less aggressive option.
11514See @option{-femit-struct-debug-detailed} for more detailed control.
11515
11516This option works only with DWARF debug output.
11517
11518@item -femit-struct-debug-reduced
11519@opindex femit-struct-debug-reduced
11520Emit debug information for struct-like types
11521only when the base name of the compilation source file
11522matches the base name of file in which the type is defined,
11523unless the struct is a template or defined in a system header.
11524
11525This option significantly reduces the size of debugging information,
11526with some potential loss in type information to the debugger.
11527See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11528See @option{-femit-struct-debug-detailed} for more detailed control.
11529
11530This option works only with DWARF debug output.
11531
11532@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
11533@opindex femit-struct-debug-detailed
11534Specify the struct-like types
11535for which the compiler generates debug information.
11536The intent is to reduce duplicate struct debug information
11537between different object files within the same program.
11538
11539This option is a detailed version of
11540@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11541which serves for most needs.
11542
11543A specification has the syntax@*
11544[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11545
11546The optional first word limits the specification to
11547structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11548A struct type is used directly when it is the type of a variable, member.
11549Indirect uses arise through pointers to structs.
11550That is, when use of an incomplete struct is valid, the use is indirect.
11551An example is
11552@samp{struct one direct; struct two * indirect;}.
11553
11554The optional second word limits the specification to
11555ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11556Generic structs are a bit complicated to explain.
11557For C++, these are non-explicit specializations of template classes,
11558or non-template classes within the above.
11559Other programming languages have generics,
11560but @option{-femit-struct-debug-detailed} does not yet implement them.
11561
11562The third word specifies the source files for those
11563structs for which the compiler should emit debug information.
11564The values @samp{none} and @samp{any} have the normal meaning.
11565The value @samp{base} means that
11566the base of name of the file in which the type declaration appears
11567must match the base of the name of the main compilation file.
11568In practice, this means that when compiling @file{foo.c}, debug information
11569is generated for types declared in that file and @file{foo.h},
11570but not other header files.
11571The value @samp{sys} means those types satisfying @samp{base}
11572or declared in system or compiler headers.
11573
11574You may need to experiment to determine the best settings for your application.
11575
11576The default is @option{-femit-struct-debug-detailed=all}.
11577
11578This option works only with DWARF debug output.
11579
11580@item -fno-dwarf2-cfi-asm
11581@opindex fdwarf2-cfi-asm
11582@opindex fno-dwarf2-cfi-asm
11583Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11584instead of using GAS @code{.cfi_*} directives.
11585
11586@item -fno-eliminate-unused-debug-types
11587@opindex feliminate-unused-debug-types
11588@opindex fno-eliminate-unused-debug-types
11589Normally, when producing DWARF output, GCC avoids producing debug symbol
11590output for types that are nowhere used in the source file being compiled.
11591Sometimes it is useful to have GCC emit debugging
11592information for all types declared in a compilation
11593unit, regardless of whether or not they are actually used
11594in that compilation unit, for example
11595if, in the debugger, you want to cast a value to a type that is
11596not actually used in your program (but is declared). More often,
11597however, this results in a significant amount of wasted space.
11598@end table
11599
11600@node Optimize Options
11601@section Options That Control Optimization
11602@cindex optimize options
11603@cindex options, optimization
11604
11605These options control various sorts of optimizations.
11606
11607Without any optimization option, the compiler's goal is to reduce the
11608cost of compilation and to make debugging produce the expected
11609results. Statements are independent: if you stop the program with a
11610breakpoint between statements, you can then assign a new value to any
11611variable or change the program counter to any other statement in the
11612function and get exactly the results you expect from the source
11613code.
11614
11615Turning on optimization flags makes the compiler attempt to improve
11616the performance and/or code size at the expense of compilation time
11617and possibly the ability to debug the program.
11618
11619The compiler performs optimization based on the knowledge it has of the
11620program. Compiling multiple files at once to a single output file mode allows
11621the compiler to use information gained from all of the files when compiling
11622each of them.
11623
11624Not all optimizations are controlled directly by a flag. Only
11625optimizations that have a flag are listed in this section.
11626
11627Most optimizations are completely disabled at @option{-O0} or if an
11628@option{-O} level is not set on the command line, even if individual
11629optimization flags are specified. Similarly, @option{-Og} suppresses
11630many optimization passes.
11631
11632Depending on the target and how GCC was configured, a slightly different
11633set of optimizations may be enabled at each @option{-O} level than
11634those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11635to find out the exact set of optimizations that are enabled at each level.
11636@xref{Overall Options}, for examples.
11637
11638@table @gcctabopt
11639@item -O
11640@itemx -O1
11641@opindex O
11642@opindex O1
11643Optimize. Optimizing compilation takes somewhat more time, and a lot
11644more memory for a large function.
11645
11646With @option{-O}, the compiler tries to reduce code size and execution
11647time, without performing any optimizations that take a great deal of
11648compilation time.
11649
11650@c Note that in addition to the default_options_table list in opts.cc,
11651@c several optimization flags default to true but control optimization
11652@c passes that are explicitly disabled at -O0.
11653
11654@option{-O} turns on the following optimization flags:
11655
11656@c Please keep the following list alphabetized.
11657@gccoptlist{-fauto-inc-dec @gol
11658-fbranch-count-reg @gol
11659-fcombine-stack-adjustments @gol
11660-fcompare-elim @gol
11661-fcprop-registers @gol
11662-fdce @gol
11663-fdefer-pop @gol
11664-fdelayed-branch @gol
11665-fdse @gol
11666-fforward-propagate @gol
11667-fguess-branch-probability @gol
11668-fif-conversion @gol
11669-fif-conversion2 @gol
11670-finline-functions-called-once @gol
11671-fipa-modref @gol
11672-fipa-profile @gol
11673-fipa-pure-const @gol
11674-fipa-reference @gol
11675-fipa-reference-addressable @gol
11676-fmerge-constants @gol
11677-fmove-loop-invariants @gol
11678-fmove-loop-stores@gol
11679-fomit-frame-pointer @gol
11680-freorder-blocks @gol
11681-fshrink-wrap @gol
11682-fshrink-wrap-separate @gol
11683-fsplit-wide-types @gol
11684-fssa-backprop @gol
11685-fssa-phiopt @gol
11686-ftree-bit-ccp @gol
11687-ftree-ccp @gol
11688-ftree-ch @gol
11689-ftree-coalesce-vars @gol
11690-ftree-copy-prop @gol
11691-ftree-dce @gol
11692-ftree-dominator-opts @gol
11693-ftree-dse @gol
11694-ftree-forwprop @gol
11695-ftree-fre @gol
11696-ftree-phiprop @gol
11697-ftree-pta @gol
11698-ftree-scev-cprop @gol
11699-ftree-sink @gol
11700-ftree-slsr @gol
11701-ftree-sra @gol
11702-ftree-ter @gol
11703-funit-at-a-time}
11704
11705@item -O2
11706@opindex O2
11707Optimize even more. GCC performs nearly all supported optimizations
11708that do not involve a space-speed tradeoff.
11709As compared to @option{-O}, this option increases both compilation time
11710and the performance of the generated code.
11711
11712@option{-O2} turns on all optimization flags specified by @option{-O1}. It
11713also turns on the following optimization flags:
11714
11715@c Please keep the following list alphabetized!
11716@gccoptlist{-falign-functions -falign-jumps @gol
11717-falign-labels -falign-loops @gol
11718-fcaller-saves @gol
11719-fcode-hoisting @gol
11720-fcrossjumping @gol
11721-fcse-follow-jumps -fcse-skip-blocks @gol
11722-fdelete-null-pointer-checks @gol
11723-fdevirtualize -fdevirtualize-speculatively @gol
11724-fexpensive-optimizations @gol
11725-ffinite-loops @gol
11726-fgcse -fgcse-lm @gol
11727-fhoist-adjacent-loads @gol
11728-finline-functions @gol
11729-finline-small-functions @gol
11730-findirect-inlining @gol
11731-fipa-bit-cp -fipa-cp -fipa-icf @gol
11732-fipa-ra -fipa-sra -fipa-vrp @gol
11733-fisolate-erroneous-paths-dereference @gol
11734-flra-remat @gol
11735-foptimize-sibling-calls @gol
11736-foptimize-strlen @gol
11737-fpartial-inlining @gol
11738-fpeephole2 @gol
11739-freorder-blocks-algorithm=stc @gol
11740-freorder-blocks-and-partition -freorder-functions @gol
11741-frerun-cse-after-loop @gol
11742-fschedule-insns -fschedule-insns2 @gol
11743-fsched-interblock -fsched-spec @gol
11744-fstore-merging @gol
11745-fstrict-aliasing @gol
11746-fthread-jumps @gol
11747-ftree-builtin-call-dce @gol
11748-ftree-loop-vectorize @gol
11749-ftree-pre @gol
11750-ftree-slp-vectorize @gol
11751-ftree-switch-conversion -ftree-tail-merge @gol
11752-ftree-vrp @gol
11753-fvect-cost-model=very-cheap}
11754
11755Please note the warning under @option{-fgcse} about
11756invoking @option{-O2} on programs that use computed gotos.
11757
11758@item -O3
11759@opindex O3
11760Optimize yet more. @option{-O3} turns on all optimizations specified
11761by @option{-O2} and also turns on the following optimization flags:
11762
11763@c Please keep the following list alphabetized!
11764@gccoptlist{-fgcse-after-reload @gol
11765-fipa-cp-clone
11766-floop-interchange @gol
11767-floop-unroll-and-jam @gol
11768-fpeel-loops @gol
11769-fpredictive-commoning @gol
11770-fsplit-loops @gol
11771-fsplit-paths @gol
11772-ftree-loop-distribution @gol
11773-ftree-partial-pre @gol
11774-funswitch-loops @gol
11775-fvect-cost-model=dynamic @gol
11776-fversion-loops-for-strides}
11777
11778@item -O0
11779@opindex O0
11780Reduce compilation time and make debugging produce the expected
11781results. This is the default.
11782
11783@item -Os
11784@opindex Os
11785Optimize for size. @option{-Os} enables all @option{-O2} optimizations
11786except those that often increase code size:
11787
11788@gccoptlist{-falign-functions -falign-jumps @gol
11789-falign-labels -falign-loops @gol
11790-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
11791
11792It also enables @option{-finline-functions}, causes the compiler to tune for
11793code size rather than execution speed, and performs further optimizations
11794designed to reduce code size.
11795
11796@item -Ofast
11797@opindex Ofast
11798Disregard strict standards compliance. @option{-Ofast} enables all
11799@option{-O3} optimizations. It also enables optimizations that are not
11800valid for all standard-compliant programs.
11801It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
11802and the Fortran-specific @option{-fstack-arrays}, unless
11803@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
11804It turns off @option{-fsemantic-interposition}.
11805
11806@item -Og
11807@opindex Og
11808Optimize debugging experience. @option{-Og} should be the optimization
11809level of choice for the standard edit-compile-debug cycle, offering
11810a reasonable level of optimization while maintaining fast compilation
11811and a good debugging experience. It is a better choice than @option{-O0}
11812for producing debuggable code because some compiler passes
11813that collect debug information are disabled at @option{-O0}.
11814
11815Like @option{-O0}, @option{-Og} completely disables a number of
11816optimization passes so that individual options controlling them have
11817no effect. Otherwise @option{-Og} enables all @option{-O1}
11818optimization flags except for those that may interfere with debugging:
11819
11820@gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
11821-fdse -fif-conversion -fif-conversion2 @gol
11822-finline-functions-called-once @gol
11823-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol
11824-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
11825
11826@item -Oz
11827@opindex Oz
11828Optimize aggressively for size rather than speed. This may increase
11829the number of instructions executed if those instructions require
11830fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
11831including enabling most @option{-O2} optimizations.
11832
11833@end table
11834
11835If you use multiple @option{-O} options, with or without level numbers,
11836the last such option is the one that is effective.
11837
11838Options of the form @option{-f@var{flag}} specify machine-independent
11839flags. Most flags have both positive and negative forms; the negative
11840form of @option{-ffoo} is @option{-fno-foo}. In the table
11841below, only one of the forms is listed---the one you typically
11842use. You can figure out the other form by either removing @samp{no-}
11843or adding it.
11844
11845The following options control specific optimizations. They are either
11846activated by @option{-O} options or are related to ones that are. You
11847can use the following flags in the rare cases when ``fine-tuning'' of
11848optimizations to be performed is desired.
11849
11850@table @gcctabopt
11851@item -fno-defer-pop
11852@opindex fno-defer-pop
11853@opindex fdefer-pop
11854For machines that must pop arguments after a function call, always pop
11855the arguments as soon as each function returns.
11856At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
11857this allows the compiler to let arguments accumulate on the stack for several
11858function calls and pop them all at once.
11859
11860@item -fforward-propagate
11861@opindex fforward-propagate
11862Perform a forward propagation pass on RTL@. The pass tries to combine two
11863instructions and checks if the result can be simplified. If loop unrolling
11864is active, two passes are performed and the second is scheduled after
11865loop unrolling.
11866
11867This option is enabled by default at optimization levels @option{-O1},
11868@option{-O2}, @option{-O3}, @option{-Os}.
11869
11870@item -ffp-contract=@var{style}
11871@opindex ffp-contract
11872@option{-ffp-contract=off} disables floating-point expression contraction.
11873@option{-ffp-contract=fast} enables floating-point expression contraction
11874such as forming of fused multiply-add operations if the target has
11875native support for them.
11876@option{-ffp-contract=on} enables floating-point expression contraction
11877if allowed by the language standard. This is currently not implemented
11878and treated equal to @option{-ffp-contract=off}.
11879
11880The default is @option{-ffp-contract=fast}.
11881
11882@item -fomit-frame-pointer
11883@opindex fomit-frame-pointer
11884Omit the frame pointer in functions that don't need one. This avoids the
11885instructions to save, set up and restore the frame pointer; on many targets
11886it also makes an extra register available.
11887
11888On some targets this flag has no effect because the standard calling sequence
11889always uses a frame pointer, so it cannot be omitted.
11890
11891Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
11892is used in all functions. Several targets always omit the frame pointer in
11893leaf functions.
11894
11895Enabled by default at @option{-O1} and higher.
11896
11897@item -foptimize-sibling-calls
11898@opindex foptimize-sibling-calls
11899Optimize sibling and tail recursive calls.
11900
11901Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11902
11903@item -foptimize-strlen
11904@opindex foptimize-strlen
11905Optimize various standard C string functions (e.g.@: @code{strlen},
11906@code{strchr} or @code{strcpy}) and
11907their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
11908
11909Enabled at levels @option{-O2}, @option{-O3}.
11910
11911@item -fno-inline
11912@opindex fno-inline
11913@opindex finline
11914Do not expand any functions inline apart from those marked with
11915the @code{always_inline} attribute. This is the default when not
11916optimizing.
11917
11918Single functions can be exempted from inlining by marking them
11919with the @code{noinline} attribute.
11920
11921@item -finline-small-functions
11922@opindex finline-small-functions
11923Integrate functions into their callers when their body is smaller than expected
11924function call code (so overall size of program gets smaller). The compiler
11925heuristically decides which functions are simple enough to be worth integrating
11926in this way. This inlining applies to all functions, even those not declared
11927inline.
11928
11929Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11930
11931@item -findirect-inlining
11932@opindex findirect-inlining
11933Inline also indirect calls that are discovered to be known at compile
11934time thanks to previous inlining. This option has any effect only
11935when inlining itself is turned on by the @option{-finline-functions}
11936or @option{-finline-small-functions} options.
11937
11938Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11939
11940@item -finline-functions
11941@opindex finline-functions
11942Consider all functions for inlining, even if they are not declared inline.
11943The compiler heuristically decides which functions are worth integrating
11944in this way.
11945
11946If all calls to a given function are integrated, and the function is
11947declared @code{static}, then the function is normally not output as
11948assembler code in its own right.
11949
11950Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
11951by @option{-fprofile-use} and @option{-fauto-profile}.
11952
11953@item -finline-functions-called-once
11954@opindex finline-functions-called-once
11955Consider all @code{static} functions called once for inlining into their
11956caller even if they are not marked @code{inline}. If a call to a given
11957function is integrated, then the function is not output as assembler code
11958in its own right.
11959
11960Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
11961but not @option{-Og}.
11962
11963@item -fearly-inlining
11964@opindex fearly-inlining
11965Inline functions marked by @code{always_inline} and functions whose body seems
11966smaller than the function call overhead early before doing
11967@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
11968makes profiling significantly cheaper and usually inlining faster on programs
11969having large chains of nested wrapper functions.
11970
11971Enabled by default.
11972
11973@item -fipa-sra
11974@opindex fipa-sra
11975Perform interprocedural scalar replacement of aggregates, removal of
11976unused parameters and replacement of parameters passed by reference
11977by parameters passed by value.
11978
11979Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
11980
11981@item -finline-limit=@var{n}
11982@opindex finline-limit
11983By default, GCC limits the size of functions that can be inlined. This flag
11984allows coarse control of this limit. @var{n} is the size of functions that
11985can be inlined in number of pseudo instructions.
11986
11987Inlining is actually controlled by a number of parameters, which may be
11988specified individually by using @option{--param @var{name}=@var{value}}.
11989The @option{-finline-limit=@var{n}} option sets some of these parameters
11990as follows:
11991
11992@table @gcctabopt
11993@item max-inline-insns-single
11994is set to @var{n}/2.
11995@item max-inline-insns-auto
11996is set to @var{n}/2.
11997@end table
11998
11999See below for a documentation of the individual
12000parameters controlling inlining and for the defaults of these parameters.
12001
12002@emph{Note:} there may be no value to @option{-finline-limit} that results
12003in default behavior.
12004
12005@emph{Note:} pseudo instruction represents, in this particular context, an
12006abstract measurement of function's size. In no way does it represent a count
12007of assembly instructions and as such its exact meaning might change from one
12008release to an another.
12009
12010@item -fno-keep-inline-dllexport
12011@opindex fno-keep-inline-dllexport
12012@opindex fkeep-inline-dllexport
12013This is a more fine-grained version of @option{-fkeep-inline-functions},
12014which applies only to functions that are declared using the @code{dllexport}
12015attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12016Functions}.
12017
12018@item -fkeep-inline-functions
12019@opindex fkeep-inline-functions
12020In C, emit @code{static} functions that are declared @code{inline}
12021into the object file, even if the function has been inlined into all
12022of its callers. This switch does not affect functions using the
12023@code{extern inline} extension in GNU C90@. In C++, emit any and all
12024inline functions into the object file.
12025
12026@item -fkeep-static-functions
12027@opindex fkeep-static-functions
12028Emit @code{static} functions into the object file, even if the function
12029is never used.
12030
12031@item -fkeep-static-consts
12032@opindex fkeep-static-consts
12033Emit variables declared @code{static const} when optimization isn't turned
12034on, even if the variables aren't referenced.
12035
12036GCC enables this option by default. If you want to force the compiler to
12037check if a variable is referenced, regardless of whether or not
12038optimization is turned on, use the @option{-fno-keep-static-consts} option.
12039
12040@item -fmerge-constants
12041@opindex fmerge-constants
12042Attempt to merge identical constants (string constants and floating-point
12043constants) across compilation units.
12044
12045This option is the default for optimized compilation if the assembler and
12046linker support it. Use @option{-fno-merge-constants} to inhibit this
12047behavior.
12048
12049Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12050
12051@item -fmerge-all-constants
12052@opindex fmerge-all-constants
12053Attempt to merge identical constants and identical variables.
12054
12055This option implies @option{-fmerge-constants}. In addition to
12056@option{-fmerge-constants} this considers e.g.@: even constant initialized
12057arrays or initialized constant variables with integral or floating-point
12058types. Languages like C or C++ require each variable, including multiple
12059instances of the same variable in recursive calls, to have distinct locations,
12060so using this option results in non-conforming
12061behavior.
12062
12063@item -fmodulo-sched
12064@opindex fmodulo-sched
12065Perform swing modulo scheduling immediately before the first scheduling
12066pass. This pass looks at innermost loops and reorders their
12067instructions by overlapping different iterations.
12068
12069@item -fmodulo-sched-allow-regmoves
12070@opindex fmodulo-sched-allow-regmoves
12071Perform more aggressive SMS-based modulo scheduling with register moves
12072allowed. By setting this flag certain anti-dependences edges are
12073deleted, which triggers the generation of reg-moves based on the
12074life-range analysis. This option is effective only with
12075@option{-fmodulo-sched} enabled.
12076
12077@item -fno-branch-count-reg
12078@opindex fno-branch-count-reg
12079@opindex fbranch-count-reg
12080Disable the optimization pass that scans for opportunities to use
12081``decrement and branch'' instructions on a count register instead of
12082instruction sequences that decrement a register, compare it against zero, and
12083then branch based upon the result. This option is only meaningful on
12084architectures that support such instructions, which include x86, PowerPC,
12085IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12086doesn't remove the decrement and branch instructions from the generated
12087instruction stream introduced by other optimization passes.
12088
12089The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12090except for @option{-Og}.
12091
12092@item -fno-function-cse
12093@opindex fno-function-cse
12094@opindex ffunction-cse
12095Do not put function addresses in registers; make each instruction that
12096calls a constant function contain the function's address explicitly.
12097
12098This option results in less efficient code, but some strange hacks
12099that alter the assembler output may be confused by the optimizations
12100performed when this option is not used.
12101
12102The default is @option{-ffunction-cse}
12103
12104@item -fno-zero-initialized-in-bss
12105@opindex fno-zero-initialized-in-bss
12106@opindex fzero-initialized-in-bss
12107If the target supports a BSS section, GCC by default puts variables that
12108are initialized to zero into BSS@. This can save space in the resulting
12109code.
12110
12111This option turns off this behavior because some programs explicitly
12112rely on variables going to the data section---e.g., so that the
12113resulting executable can find the beginning of that section and/or make
12114assumptions based on that.
12115
12116The default is @option{-fzero-initialized-in-bss}.
12117
12118@item -fthread-jumps
12119@opindex fthread-jumps
12120Perform optimizations that check to see if a jump branches to a
12121location where another comparison subsumed by the first is found. If
12122so, the first branch is redirected to either the destination of the
12123second branch or a point immediately following it, depending on whether
12124the condition is known to be true or false.
12125
12126Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12127
12128@item -fsplit-wide-types
12129@opindex fsplit-wide-types
12130When using a type that occupies multiple registers, such as @code{long
12131long} on a 32-bit system, split the registers apart and allocate them
12132independently. This normally generates better code for those types,
12133but may make debugging more difficult.
12134
12135Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12136@option{-Os}.
12137
12138@item -fsplit-wide-types-early
12139@opindex fsplit-wide-types-early
12140Fully split wide types early, instead of very late.
12141This option has no effect unless @option{-fsplit-wide-types} is turned on.
12142
12143This is the default on some targets.
12144
12145@item -fcse-follow-jumps
12146@opindex fcse-follow-jumps
12147In common subexpression elimination (CSE), scan through jump instructions
12148when the target of the jump is not reached by any other path. For
12149example, when CSE encounters an @code{if} statement with an
12150@code{else} clause, CSE follows the jump when the condition
12151tested is false.
12152
12153Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12154
12155@item -fcse-skip-blocks
12156@opindex fcse-skip-blocks
12157This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12158follow jumps that conditionally skip over blocks. When CSE
12159encounters a simple @code{if} statement with no else clause,
12160@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12161body of the @code{if}.
12162
12163Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12164
12165@item -frerun-cse-after-loop
12166@opindex frerun-cse-after-loop
12167Re-run common subexpression elimination after loop optimizations are
12168performed.
12169
12170Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12171
12172@item -fgcse
12173@opindex fgcse
12174Perform a global common subexpression elimination pass.
12175This pass also performs global constant and copy propagation.
12176
12177@emph{Note:} When compiling a program using computed gotos, a GCC
12178extension, you may get better run-time performance if you disable
12179the global common subexpression elimination pass by adding
12180@option{-fno-gcse} to the command line.
12181
12182Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12183
12184@item -fgcse-lm
12185@opindex fgcse-lm
12186When @option{-fgcse-lm} is enabled, global common subexpression elimination
12187attempts to move loads that are only killed by stores into themselves. This
12188allows a loop containing a load/store sequence to be changed to a load outside
12189the loop, and a copy/store within the loop.
12190
12191Enabled by default when @option{-fgcse} is enabled.
12192
12193@item -fgcse-sm
12194@opindex fgcse-sm
12195When @option{-fgcse-sm} is enabled, a store motion pass is run after
12196global common subexpression elimination. This pass attempts to move
12197stores out of loops. When used in conjunction with @option{-fgcse-lm},
12198loops containing a load/store sequence can be changed to a load before
12199the loop and a store after the loop.
12200
12201Not enabled at any optimization level.
12202
12203@item -fgcse-las
12204@opindex fgcse-las
12205When @option{-fgcse-las} is enabled, the global common subexpression
12206elimination pass eliminates redundant loads that come after stores to the
12207same memory location (both partial and full redundancies).
12208
12209Not enabled at any optimization level.
12210
12211@item -fgcse-after-reload
12212@opindex fgcse-after-reload
12213When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12214pass is performed after reload. The purpose of this pass is to clean up
12215redundant spilling.
12216
12217Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12218
12219@item -faggressive-loop-optimizations
12220@opindex faggressive-loop-optimizations
12221This option tells the loop optimizer to use language constraints to
12222derive bounds for the number of iterations of a loop. This assumes that
12223loop code does not invoke undefined behavior by for example causing signed
12224integer overflows or out-of-bound array accesses. The bounds for the
12225number of iterations of a loop are used to guide loop unrolling and peeling
12226and loop exit test optimizations.
12227This option is enabled by default.
12228
12229@item -funconstrained-commons
12230@opindex funconstrained-commons
12231This option tells the compiler that variables declared in common blocks
12232(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12233prevents certain optimizations that depend on knowing the array bounds.
12234
12235@item -fcrossjumping
12236@opindex fcrossjumping
12237Perform cross-jumping transformation.
12238This transformation unifies equivalent code and saves code size. The
12239resulting code may or may not perform better than without cross-jumping.
12240
12241Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12242
12243@item -fauto-inc-dec
12244@opindex fauto-inc-dec
12245Combine increments or decrements of addresses with memory accesses.
12246This pass is always skipped on architectures that do not have
12247instructions to support this. Enabled by default at @option{-O1} and
12248higher on architectures that support this.
12249
12250@item -fdce
12251@opindex fdce
12252Perform dead code elimination (DCE) on RTL@.
12253Enabled by default at @option{-O1} and higher.
12254
12255@item -fdse
12256@opindex fdse
12257Perform dead store elimination (DSE) on RTL@.
12258Enabled by default at @option{-O1} and higher.
12259
12260@item -fif-conversion
12261@opindex fif-conversion
12262Attempt to transform conditional jumps into branch-less equivalents. This
12263includes use of conditional moves, min, max, set flags and abs instructions, and
12264some tricks doable by standard arithmetics. The use of conditional execution
12265on chips where it is available is controlled by @option{-fif-conversion2}.
12266
12267Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12268not with @option{-Og}.
12269
12270@item -fif-conversion2
12271@opindex fif-conversion2
12272Use conditional execution (where available) to transform conditional jumps into
12273branch-less equivalents.
12274
12275Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12276not with @option{-Og}.
12277
12278@item -fdeclone-ctor-dtor
12279@opindex fdeclone-ctor-dtor
12280The C++ ABI requires multiple entry points for constructors and
12281destructors: one for a base subobject, one for a complete object, and
12282one for a virtual destructor that calls operator delete afterwards.
12283For a hierarchy with virtual bases, the base and complete variants are
12284clones, which means two copies of the function. With this option, the
12285base and complete variants are changed to be thunks that call a common
12286implementation.
12287
12288Enabled by @option{-Os}.
12289
12290@item -fdelete-null-pointer-checks
12291@opindex fdelete-null-pointer-checks
12292Assume that programs cannot safely dereference null pointers, and that
12293no code or data element resides at address zero.
12294This option enables simple constant
12295folding optimizations at all optimization levels. In addition, other
12296optimization passes in GCC use this flag to control global dataflow
12297analyses that eliminate useless checks for null pointers; these assume
12298that a memory access to address zero always results in a trap, so
12299that if a pointer is checked after it has already been dereferenced,
12300it cannot be null.
12301
12302Note however that in some environments this assumption is not true.
12303Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12304for programs that depend on that behavior.
12305
12306This option is enabled by default on most targets. On Nios II ELF, it
12307defaults to off. On AVR and MSP430, this option is completely disabled.
12308
12309Passes that use the dataflow information
12310are enabled independently at different optimization levels.
12311
12312@item -fdevirtualize
12313@opindex fdevirtualize
12314Attempt to convert calls to virtual functions to direct calls. This
12315is done both within a procedure and interprocedurally as part of
12316indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12317propagation (@option{-fipa-cp}).
12318Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12319
12320@item -fdevirtualize-speculatively
12321@opindex fdevirtualize-speculatively
12322Attempt to convert calls to virtual functions to speculative direct calls.
12323Based on the analysis of the type inheritance graph, determine for a given call
12324the set of likely targets. If the set is small, preferably of size 1, change
12325the call into a conditional deciding between direct and indirect calls. The
12326speculative calls enable more optimizations, such as inlining. When they seem
12327useless after further optimization, they are converted back into original form.
12328
12329@item -fdevirtualize-at-ltrans
12330@opindex fdevirtualize-at-ltrans
12331Stream extra information needed for aggressive devirtualization when running
12332the link-time optimizer in local transformation mode.
12333This option enables more devirtualization but
12334significantly increases the size of streamed data. For this reason it is
12335disabled by default.
12336
12337@item -fexpensive-optimizations
12338@opindex fexpensive-optimizations
12339Perform a number of minor optimizations that are relatively expensive.
12340
12341Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12342
12343@item -free
12344@opindex free
12345Attempt to remove redundant extension instructions. This is especially
12346helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12347registers after writing to their lower 32-bit half.
12348
12349Enabled for Alpha, AArch64 and x86 at levels @option{-O2},
12350@option{-O3}, @option{-Os}.
12351
12352@item -fno-lifetime-dse
12353@opindex fno-lifetime-dse
12354@opindex flifetime-dse
12355In C++ the value of an object is only affected by changes within its
12356lifetime: when the constructor begins, the object has an indeterminate
12357value, and any changes during the lifetime of the object are dead when
12358the object is destroyed. Normally dead store elimination will take
12359advantage of this; if your code relies on the value of the object
12360storage persisting beyond the lifetime of the object, you can use this
12361flag to disable this optimization. To preserve stores before the
12362constructor starts (e.g.@: because your operator new clears the object
12363storage) but still treat the object as dead after the destructor, you
12364can use @option{-flifetime-dse=1}. The default behavior can be
12365explicitly selected with @option{-flifetime-dse=2}.
12366@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12367
12368@item -flive-range-shrinkage
12369@opindex flive-range-shrinkage
12370Attempt to decrease register pressure through register live range
12371shrinkage. This is helpful for fast processors with small or moderate
12372size register sets.
12373
12374@item -fira-algorithm=@var{algorithm}
12375@opindex fira-algorithm
12376Use the specified coloring algorithm for the integrated register
12377allocator. The @var{algorithm} argument can be @samp{priority}, which
12378specifies Chow's priority coloring, or @samp{CB}, which specifies
12379Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12380for all architectures, but for those targets that do support it, it is
12381the default because it generates better code.
12382
12383@item -fira-region=@var{region}
12384@opindex fira-region
12385Use specified regions for the integrated register allocator. The
12386@var{region} argument should be one of the following:
12387
12388@table @samp
12389
12390@item all
12391Use all loops as register allocation regions.
12392This can give the best results for machines with a small and/or
12393irregular register set.
12394
12395@item mixed
12396Use all loops except for loops with small register pressure
12397as the regions. This value usually gives
12398the best results in most cases and for most architectures,
12399and is enabled by default when compiling with optimization for speed
12400(@option{-O}, @option{-O2}, @dots{}).
12401
12402@item one
12403Use all functions as a single region.
12404This typically results in the smallest code size, and is enabled by default for
12405@option{-Os} or @option{-O0}.
12406
12407@end table
12408
12409@item -fira-hoist-pressure
12410@opindex fira-hoist-pressure
12411Use IRA to evaluate register pressure in the code hoisting pass for
12412decisions to hoist expressions. This option usually results in smaller
12413code, but it can slow the compiler down.
12414
12415This option is enabled at level @option{-Os} for all targets.
12416
12417@item -fira-loop-pressure
12418@opindex fira-loop-pressure
12419Use IRA to evaluate register pressure in loops for decisions to move
12420loop invariants. This option usually results in generation
12421of faster and smaller code on machines with large register files (>= 32
12422registers), but it can slow the compiler down.
12423
12424This option is enabled at level @option{-O3} for some targets.
12425
12426@item -fno-ira-share-save-slots
12427@opindex fno-ira-share-save-slots
12428@opindex fira-share-save-slots
12429Disable sharing of stack slots used for saving call-used hard
12430registers living through a call. Each hard register gets a
12431separate stack slot, and as a result function stack frames are
12432larger.
12433
12434@item -fno-ira-share-spill-slots
12435@opindex fno-ira-share-spill-slots
12436@opindex fira-share-spill-slots
12437Disable sharing of stack slots allocated for pseudo-registers. Each
12438pseudo-register that does not get a hard register gets a separate
12439stack slot, and as a result function stack frames are larger.
12440
12441@item -flra-remat
12442@opindex flra-remat
12443Enable CFG-sensitive rematerialization in LRA. Instead of loading
12444values of spilled pseudos, LRA tries to rematerialize (recalculate)
12445values if it is profitable.
12446
12447Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12448
12449@item -fdelayed-branch
12450@opindex fdelayed-branch
12451If supported for the target machine, attempt to reorder instructions
12452to exploit instruction slots available after delayed branch
12453instructions.
12454
12455Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12456but not at @option{-Og}.
12457
12458@item -fschedule-insns
12459@opindex fschedule-insns
12460If supported for the target machine, attempt to reorder instructions to
12461eliminate execution stalls due to required data being unavailable. This
12462helps machines that have slow floating point or memory load instructions
12463by allowing other instructions to be issued until the result of the load
12464or floating-point instruction is required.
12465
12466Enabled at levels @option{-O2}, @option{-O3}.
12467
12468@item -fschedule-insns2
12469@opindex fschedule-insns2
12470Similar to @option{-fschedule-insns}, but requests an additional pass of
12471instruction scheduling after register allocation has been done. This is
12472especially useful on machines with a relatively small number of
12473registers and where memory load instructions take more than one cycle.
12474
12475Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12476
12477@item -fno-sched-interblock
12478@opindex fno-sched-interblock
12479@opindex fsched-interblock
12480Disable instruction scheduling across basic blocks, which
12481is normally enabled when scheduling before register allocation, i.e.@:
12482with @option{-fschedule-insns} or at @option{-O2} or higher.
12483
12484@item -fno-sched-spec
12485@opindex fno-sched-spec
12486@opindex fsched-spec
12487Disable speculative motion of non-load instructions, which
12488is normally enabled when scheduling before register allocation, i.e.@:
12489with @option{-fschedule-insns} or at @option{-O2} or higher.
12490
12491@item -fsched-pressure
12492@opindex fsched-pressure
12493Enable register pressure sensitive insn scheduling before register
12494allocation. This only makes sense when scheduling before register
12495allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12496@option{-O2} or higher. Usage of this option can improve the
12497generated code and decrease its size by preventing register pressure
12498increase above the number of available hard registers and subsequent
12499spills in register allocation.
12500
12501@item -fsched-spec-load
12502@opindex fsched-spec-load
12503Allow speculative motion of some load instructions. This only makes
12504sense when scheduling before register allocation, i.e.@: with
12505@option{-fschedule-insns} or at @option{-O2} or higher.
12506
12507@item -fsched-spec-load-dangerous
12508@opindex fsched-spec-load-dangerous
12509Allow speculative motion of more load instructions. This only makes
12510sense when scheduling before register allocation, i.e.@: with
12511@option{-fschedule-insns} or at @option{-O2} or higher.
12512
12513@item -fsched-stalled-insns
12514@itemx -fsched-stalled-insns=@var{n}
12515@opindex fsched-stalled-insns
12516Define how many insns (if any) can be moved prematurely from the queue
12517of stalled insns into the ready list during the second scheduling pass.
12518@option{-fno-sched-stalled-insns} means that no insns are moved
12519prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12520on how many queued insns can be moved prematurely.
12521@option{-fsched-stalled-insns} without a value is equivalent to
12522@option{-fsched-stalled-insns=1}.
12523
12524@item -fsched-stalled-insns-dep
12525@itemx -fsched-stalled-insns-dep=@var{n}
12526@opindex fsched-stalled-insns-dep
12527Define how many insn groups (cycles) are examined for a dependency
12528on a stalled insn that is a candidate for premature removal from the queue
12529of stalled insns. This has an effect only during the second scheduling pass,
12530and only if @option{-fsched-stalled-insns} is used.
12531@option{-fno-sched-stalled-insns-dep} is equivalent to
12532@option{-fsched-stalled-insns-dep=0}.
12533@option{-fsched-stalled-insns-dep} without a value is equivalent to
12534@option{-fsched-stalled-insns-dep=1}.
12535
12536@item -fsched2-use-superblocks
12537@opindex fsched2-use-superblocks
12538When scheduling after register allocation, use superblock scheduling.
12539This allows motion across basic block boundaries,
12540resulting in faster schedules. This option is experimental, as not all machine
12541descriptions used by GCC model the CPU closely enough to avoid unreliable
12542results from the algorithm.
12543
12544This only makes sense when scheduling after register allocation, i.e.@: with
12545@option{-fschedule-insns2} or at @option{-O2} or higher.
12546
12547@item -fsched-group-heuristic
12548@opindex fsched-group-heuristic
12549Enable the group heuristic in the scheduler. This heuristic favors
12550the instruction that belongs to a schedule group. This is enabled
12551by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12552or @option{-fschedule-insns2} or at @option{-O2} or higher.
12553
12554@item -fsched-critical-path-heuristic
12555@opindex fsched-critical-path-heuristic
12556Enable the critical-path heuristic in the scheduler. This heuristic favors
12557instructions on the critical path. This is enabled by default when
12558scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12559or @option{-fschedule-insns2} or at @option{-O2} or higher.
12560
12561@item -fsched-spec-insn-heuristic
12562@opindex fsched-spec-insn-heuristic
12563Enable the speculative instruction heuristic in the scheduler. This
12564heuristic favors speculative instructions with greater dependency weakness.
12565This is enabled by default when scheduling is enabled, i.e.@:
12566with @option{-fschedule-insns} or @option{-fschedule-insns2}
12567or at @option{-O2} or higher.
12568
12569@item -fsched-rank-heuristic
12570@opindex fsched-rank-heuristic
12571Enable the rank heuristic in the scheduler. This heuristic favors
12572the instruction belonging to a basic block with greater size or frequency.
12573This is enabled by default when scheduling is enabled, i.e.@:
12574with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12575at @option{-O2} or higher.
12576
12577@item -fsched-last-insn-heuristic
12578@opindex fsched-last-insn-heuristic
12579Enable the last-instruction heuristic in the scheduler. This heuristic
12580favors the instruction that is less dependent on the last instruction
12581scheduled. This is enabled by default when scheduling is enabled,
12582i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12583at @option{-O2} or higher.
12584
12585@item -fsched-dep-count-heuristic
12586@opindex fsched-dep-count-heuristic
12587Enable the dependent-count heuristic in the scheduler. This heuristic
12588favors the instruction that has more instructions depending on it.
12589This is enabled by default when scheduling is enabled, i.e.@:
12590with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12591at @option{-O2} or higher.
12592
12593@item -freschedule-modulo-scheduled-loops
12594@opindex freschedule-modulo-scheduled-loops
12595Modulo scheduling is performed before traditional scheduling. If a loop
12596is modulo scheduled, later scheduling passes may change its schedule.
12597Use this option to control that behavior.
12598
12599@item -fselective-scheduling
12600@opindex fselective-scheduling
12601Schedule instructions using selective scheduling algorithm. Selective
12602scheduling runs instead of the first scheduler pass.
12603
12604@item -fselective-scheduling2
12605@opindex fselective-scheduling2
12606Schedule instructions using selective scheduling algorithm. Selective
12607scheduling runs instead of the second scheduler pass.
12608
12609@item -fsel-sched-pipelining
12610@opindex fsel-sched-pipelining
12611Enable software pipelining of innermost loops during selective scheduling.
12612This option has no effect unless one of @option{-fselective-scheduling} or
12613@option{-fselective-scheduling2} is turned on.
12614
12615@item -fsel-sched-pipelining-outer-loops
12616@opindex fsel-sched-pipelining-outer-loops
12617When pipelining loops during selective scheduling, also pipeline outer loops.
12618This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12619
12620@item -fsemantic-interposition
12621@opindex fsemantic-interposition
12622Some object formats, like ELF, allow interposing of symbols by the
12623dynamic linker.
12624This means that for symbols exported from the DSO, the compiler cannot perform
12625interprocedural propagation, inlining and other optimizations in anticipation
12626that the function or variable in question may change. While this feature is
12627useful, for example, to rewrite memory allocation functions by a debugging
12628implementation, it is expensive in the terms of code quality.
12629With @option{-fno-semantic-interposition} the compiler assumes that
12630if interposition happens for functions the overwriting function will have
12631precisely the same semantics (and side effects).
12632Similarly if interposition happens
12633for variables, the constructor of the variable will be the same. The flag
12634has no effect for functions explicitly declared inline
12635(where it is never allowed for interposition to change semantics)
12636and for symbols explicitly declared weak.
12637
12638@item -fshrink-wrap
12639@opindex fshrink-wrap
12640Emit function prologues only before parts of the function that need it,
12641rather than at the top of the function. This flag is enabled by default at
12642@option{-O} and higher.
12643
12644@item -fshrink-wrap-separate
12645@opindex fshrink-wrap-separate
12646Shrink-wrap separate parts of the prologue and epilogue separately, so that
12647those parts are only executed when needed.
12648This option is on by default, but has no effect unless @option{-fshrink-wrap}
12649is also turned on and the target supports this.
12650
12651@item -fcaller-saves
12652@opindex fcaller-saves
12653Enable allocation of values to registers that are clobbered by
12654function calls, by emitting extra instructions to save and restore the
12655registers around such calls. Such allocation is done only when it
12656seems to result in better code.
12657
12658This option is always enabled by default on certain machines, usually
12659those which have no call-preserved registers to use instead.
12660
12661Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12662
12663@item -fcombine-stack-adjustments
12664@opindex fcombine-stack-adjustments
12665Tracks stack adjustments (pushes and pops) and stack memory references
12666and then tries to find ways to combine them.
12667
12668Enabled by default at @option{-O1} and higher.
12669
12670@item -fipa-ra
12671@opindex fipa-ra
12672Use caller save registers for allocation if those registers are not used by
12673any called function. In that case it is not necessary to save and restore
12674them around calls. This is only possible if called functions are part of
12675same compilation unit as current function and they are compiled before it.
12676
12677Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
12678is disabled if generated code will be instrumented for profiling
12679(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
12680exactly (this happens on targets that do not expose prologues
12681and epilogues in RTL).
12682
12683@item -fconserve-stack
12684@opindex fconserve-stack
12685Attempt to minimize stack usage. The compiler attempts to use less
12686stack space, even if that makes the program slower. This option
12687implies setting the @option{large-stack-frame} parameter to 100
12688and the @option{large-stack-frame-growth} parameter to 400.
12689
12690@item -ftree-reassoc
12691@opindex ftree-reassoc
12692Perform reassociation on trees. This flag is enabled by default
12693at @option{-O1} and higher.
12694
12695@item -fcode-hoisting
12696@opindex fcode-hoisting
12697Perform code hoisting. Code hoisting tries to move the
12698evaluation of expressions executed on all paths to the function exit
12699as early as possible. This is especially useful as a code size
12700optimization, but it often helps for code speed as well.
12701This flag is enabled by default at @option{-O2} and higher.
12702
12703@item -ftree-pre
12704@opindex ftree-pre
12705Perform partial redundancy elimination (PRE) on trees. This flag is
12706enabled by default at @option{-O2} and @option{-O3}.
12707
12708@item -ftree-partial-pre
12709@opindex ftree-partial-pre
12710Make partial redundancy elimination (PRE) more aggressive. This flag is
12711enabled by default at @option{-O3}.
12712
12713@item -ftree-forwprop
12714@opindex ftree-forwprop
12715Perform forward propagation on trees. This flag is enabled by default
12716at @option{-O1} and higher.
12717
12718@item -ftree-fre
12719@opindex ftree-fre
12720Perform full redundancy elimination (FRE) on trees. The difference
12721between FRE and PRE is that FRE only considers expressions
12722that are computed on all paths leading to the redundant computation.
12723This analysis is faster than PRE, though it exposes fewer redundancies.
12724This flag is enabled by default at @option{-O1} and higher.
12725
12726@item -ftree-phiprop
12727@opindex ftree-phiprop
12728Perform hoisting of loads from conditional pointers on trees. This
12729pass is enabled by default at @option{-O1} and higher.
12730
12731@item -fhoist-adjacent-loads
12732@opindex fhoist-adjacent-loads
12733Speculatively hoist loads from both branches of an if-then-else if the
12734loads are from adjacent locations in the same structure and the target
12735architecture has a conditional move instruction. This flag is enabled
12736by default at @option{-O2} and higher.
12737
12738@item -ftree-copy-prop
12739@opindex ftree-copy-prop
12740Perform copy propagation on trees. This pass eliminates unnecessary
12741copy operations. This flag is enabled by default at @option{-O1} and
12742higher.
12743
12744@item -fipa-pure-const
12745@opindex fipa-pure-const
12746Discover which functions are pure or constant.
12747Enabled by default at @option{-O1} and higher.
12748
12749@item -fipa-reference
12750@opindex fipa-reference
12751Discover which static variables do not escape the
12752compilation unit.
12753Enabled by default at @option{-O1} and higher.
12754
12755@item -fipa-reference-addressable
12756@opindex fipa-reference-addressable
12757Discover read-only, write-only and non-addressable static variables.
12758Enabled by default at @option{-O1} and higher.
12759
12760@item -fipa-stack-alignment
12761@opindex fipa-stack-alignment
12762Reduce stack alignment on call sites if possible.
12763Enabled by default.
12764
12765@item -fipa-pta
12766@opindex fipa-pta
12767Perform interprocedural pointer analysis and interprocedural modification
12768and reference analysis. This option can cause excessive memory and
12769compile-time usage on large compilation units. It is not enabled by
12770default at any optimization level.
12771
12772@item -fipa-profile
12773@opindex fipa-profile
12774Perform interprocedural profile propagation. The functions called only from
12775cold functions are marked as cold. Also functions executed once (such as
12776@code{cold}, @code{noreturn}, static constructors or destructors) are
12777identified. Cold functions and loop less parts of functions executed once are
12778then optimized for size.
12779Enabled by default at @option{-O1} and higher.
12780
12781@item -fipa-modref
12782@opindex fipa-modref
12783Perform interprocedural mod/ref analysis. This optimization analyzes the side
12784effects of functions (memory locations that are modified or referenced) and
12785enables better optimization across the function call boundary. This flag is
12786enabled by default at @option{-O1} and higher.
12787
12788@item -fipa-cp
12789@opindex fipa-cp
12790Perform interprocedural constant propagation.
12791This optimization analyzes the program to determine when values passed
12792to functions are constants and then optimizes accordingly.
12793This optimization can substantially increase performance
12794if the application has constants passed to functions.
12795This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
12796It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12797
12798@item -fipa-cp-clone
12799@opindex fipa-cp-clone
12800Perform function cloning to make interprocedural constant propagation stronger.
12801When enabled, interprocedural constant propagation performs function cloning
12802when externally visible function can be called with constant arguments.
12803Because this optimization can create multiple copies of functions,
12804it may significantly increase code size
12805(see @option{--param ipa-cp-unit-growth=@var{value}}).
12806This flag is enabled by default at @option{-O3}.
12807It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12808
12809@item -fipa-bit-cp
12810@opindex fipa-bit-cp
12811When enabled, perform interprocedural bitwise constant
12812propagation. This flag is enabled by default at @option{-O2} and
12813by @option{-fprofile-use} and @option{-fauto-profile}.
12814It requires that @option{-fipa-cp} is enabled.
12815
12816@item -fipa-vrp
12817@opindex fipa-vrp
12818When enabled, perform interprocedural propagation of value
12819ranges. This flag is enabled by default at @option{-O2}. It requires
12820that @option{-fipa-cp} is enabled.
12821
12822@item -fipa-icf
12823@opindex fipa-icf
12824Perform Identical Code Folding for functions and read-only variables.
12825The optimization reduces code size and may disturb unwind stacks by replacing
12826a function by equivalent one with a different name. The optimization works
12827more effectively with link-time optimization enabled.
12828
12829Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
12830works on different levels and thus the optimizations are not same - there are
12831equivalences that are found only by GCC and equivalences found only by Gold.
12832
12833This flag is enabled by default at @option{-O2} and @option{-Os}.
12834
12835@item -flive-patching=@var{level}
12836@opindex flive-patching
12837Control GCC's optimizations to produce output suitable for live-patching.
12838
12839If the compiler's optimization uses a function's body or information extracted
12840from its body to optimize/change another function, the latter is called an
12841impacted function of the former. If a function is patched, its impacted
12842functions should be patched too.
12843
12844The impacted functions are determined by the compiler's interprocedural
12845optimizations. For example, a caller is impacted when inlining a function
12846into its caller,
12847cloning a function and changing its caller to call this new clone,
12848or extracting a function's pureness/constness information to optimize
12849its direct or indirect callers, etc.
12850
12851Usually, the more IPA optimizations enabled, the larger the number of
12852impacted functions for each function. In order to control the number of
12853impacted functions and more easily compute the list of impacted function,
12854IPA optimizations can be partially enabled at two different levels.
12855
12856The @var{level} argument should be one of the following:
12857
12858@table @samp
12859
12860@item inline-clone
12861
12862Only enable inlining and cloning optimizations, which includes inlining,
12863cloning, interprocedural scalar replacement of aggregates and partial inlining.
12864As a result, when patching a function, all its callers and its clones'
12865callers are impacted, therefore need to be patched as well.
12866
12867@option{-flive-patching=inline-clone} disables the following optimization flags:
12868@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra @gol
12869-fipa-icf -fipa-icf-functions -fipa-icf-variables @gol
12870-fipa-bit-cp -fipa-vrp -fipa-pure-const -fipa-reference-addressable @gol
12871-fipa-stack-alignment -fipa-modref}
12872
12873@item inline-only-static
12874
12875Only enable inlining of static functions.
12876As a result, when patching a static function, all its callers are impacted
12877and so need to be patched as well.
12878
12879In addition to all the flags that @option{-flive-patching=inline-clone}
12880disables,
12881@option{-flive-patching=inline-only-static} disables the following additional
12882optimization flags:
12883@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
12884
12885@end table
12886
12887When @option{-flive-patching} is specified without any value, the default value
12888is @var{inline-clone}.
12889
12890This flag is disabled by default.
12891
12892Note that @option{-flive-patching} is not supported with link-time optimization
12893(@option{-flto}).
12894
12895@item -fisolate-erroneous-paths-dereference
12896@opindex fisolate-erroneous-paths-dereference
12897Detect paths that trigger erroneous or undefined behavior due to
12898dereferencing a null pointer. Isolate those paths from the main control
12899flow and turn the statement with erroneous or undefined behavior into a trap.
12900This flag is enabled by default at @option{-O2} and higher and depends on
12901@option{-fdelete-null-pointer-checks} also being enabled.
12902
12903@item -fisolate-erroneous-paths-attribute
12904@opindex fisolate-erroneous-paths-attribute
12905Detect paths that trigger erroneous or undefined behavior due to a null value
12906being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
12907attribute. Isolate those paths from the main control flow and turn the
12908statement with erroneous or undefined behavior into a trap. This is not
12909currently enabled, but may be enabled by @option{-O2} in the future.
12910
12911@item -ftree-sink
12912@opindex ftree-sink
12913Perform forward store motion on trees. This flag is
12914enabled by default at @option{-O1} and higher.
12915
12916@item -ftree-bit-ccp
12917@opindex ftree-bit-ccp
12918Perform sparse conditional bit constant propagation on trees and propagate
12919pointer alignment information.
12920This pass only operates on local scalar variables and is enabled by default
12921at @option{-O1} and higher, except for @option{-Og}.
12922It requires that @option{-ftree-ccp} is enabled.
12923
12924@item -ftree-ccp
12925@opindex ftree-ccp
12926Perform sparse conditional constant propagation (CCP) on trees. This
12927pass only operates on local scalar variables and is enabled by default
12928at @option{-O1} and higher.
12929
12930@item -fssa-backprop
12931@opindex fssa-backprop
12932Propagate information about uses of a value up the definition chain
12933in order to simplify the definitions. For example, this pass strips
12934sign operations if the sign of a value never matters. The flag is
12935enabled by default at @option{-O1} and higher.
12936
12937@item -fssa-phiopt
12938@opindex fssa-phiopt
12939Perform pattern matching on SSA PHI nodes to optimize conditional
12940code. This pass is enabled by default at @option{-O1} and higher,
12941except for @option{-Og}.
12942
12943@item -ftree-switch-conversion
12944@opindex ftree-switch-conversion
12945Perform conversion of simple initializations in a switch to
12946initializations from a scalar array. This flag is enabled by default
12947at @option{-O2} and higher.
12948
12949@item -ftree-tail-merge
12950@opindex ftree-tail-merge
12951Look for identical code sequences. When found, replace one with a jump to the
12952other. This optimization is known as tail merging or cross jumping. This flag
12953is enabled by default at @option{-O2} and higher. The compilation time
12954in this pass can
12955be limited using @option{max-tail-merge-comparisons} parameter and
12956@option{max-tail-merge-iterations} parameter.
12957
12958@item -ftree-dce
12959@opindex ftree-dce
12960Perform dead code elimination (DCE) on trees. This flag is enabled by
12961default at @option{-O1} and higher.
12962
12963@item -ftree-builtin-call-dce
12964@opindex ftree-builtin-call-dce
12965Perform conditional dead code elimination (DCE) for calls to built-in functions
12966that may set @code{errno} but are otherwise free of side effects. This flag is
12967enabled by default at @option{-O2} and higher if @option{-Os} is not also
12968specified.
12969
12970@item -ffinite-loops
12971@opindex ffinite-loops
12972@opindex fno-finite-loops
12973Assume that a loop with an exit will eventually take the exit and not loop
12974indefinitely. This allows the compiler to remove loops that otherwise have
12975no side-effects, not considering eventual endless looping as such.
12976
12977This option is enabled by default at @option{-O2} for C++ with -std=c++11
12978or higher.
12979
12980@item -ftree-dominator-opts
12981@opindex ftree-dominator-opts
12982Perform a variety of simple scalar cleanups (constant/copy
12983propagation, redundancy elimination, range propagation and expression
12984simplification) based on a dominator tree traversal. This also
12985performs jump threading (to reduce jumps to jumps). This flag is
12986enabled by default at @option{-O1} and higher.
12987
12988@item -ftree-dse
12989@opindex ftree-dse
12990Perform dead store elimination (DSE) on trees. A dead store is a store into
12991a memory location that is later overwritten by another store without
12992any intervening loads. In this case the earlier store can be deleted. This
12993flag is enabled by default at @option{-O1} and higher.
12994
12995@item -ftree-ch
12996@opindex ftree-ch
12997Perform loop header copying on trees. This is beneficial since it increases
12998effectiveness of code motion optimizations. It also saves one jump. This flag
12999is enabled by default at @option{-O1} and higher. It is not enabled
13000for @option{-Os}, since it usually increases code size.
13001
13002@item -ftree-loop-optimize
13003@opindex ftree-loop-optimize
13004Perform loop optimizations on trees. This flag is enabled by default
13005at @option{-O1} and higher.
13006
13007@item -ftree-loop-linear
13008@itemx -floop-strip-mine
13009@itemx -floop-block
13010@opindex ftree-loop-linear
13011@opindex floop-strip-mine
13012@opindex floop-block
13013Perform loop nest optimizations. Same as
13014@option{-floop-nest-optimize}. To use this code transformation, GCC has
13015to be configured with @option{--with-isl} to enable the Graphite loop
13016transformation infrastructure.
13017
13018@item -fgraphite-identity
13019@opindex fgraphite-identity
13020Enable the identity transformation for graphite. For every SCoP we generate
13021the polyhedral representation and transform it back to gimple. Using
13022@option{-fgraphite-identity} we can check the costs or benefits of the
13023GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13024are also performed by the code generator isl, like index splitting and
13025dead code elimination in loops.
13026
13027@item -floop-nest-optimize
13028@opindex floop-nest-optimize
13029Enable the isl based loop nest optimizer. This is a generic loop nest
13030optimizer based on the Pluto optimization algorithms. It calculates a loop
13031structure optimized for data-locality and parallelism. This option
13032is experimental.
13033
13034@item -floop-parallelize-all
13035@opindex floop-parallelize-all
13036Use the Graphite data dependence analysis to identify loops that can
13037be parallelized. Parallelize all the loops that can be analyzed to
13038not contain loop carried dependences without checking that it is
13039profitable to parallelize the loops.
13040
13041@item -ftree-coalesce-vars
13042@opindex ftree-coalesce-vars
13043While transforming the program out of the SSA representation, attempt to
13044reduce copying by coalescing versions of different user-defined
13045variables, instead of just compiler temporaries. This may severely
13046limit the ability to debug an optimized program compiled with
13047@option{-fno-var-tracking-assignments}. In the negated form, this flag
13048prevents SSA coalescing of user variables. This option is enabled by
13049default if optimization is enabled, and it does very little otherwise.
13050
13051@item -ftree-loop-if-convert
13052@opindex ftree-loop-if-convert
13053Attempt to transform conditional jumps in the innermost loops to
13054branch-less equivalents. The intent is to remove control-flow from
13055the innermost loops in order to improve the ability of the
13056vectorization pass to handle these loops. This is enabled by default
13057if vectorization is enabled.
13058
13059@item -ftree-loop-distribution
13060@opindex ftree-loop-distribution
13061Perform loop distribution. This flag can improve cache performance on
13062big loop bodies and allow further loop optimizations, like
13063parallelization or vectorization, to take place. For example, the loop
13064@smallexample
13065DO I = 1, N
13066 A(I) = B(I) + C
13067 D(I) = E(I) * F
13068ENDDO
13069@end smallexample
13070is transformed to
13071@smallexample
13072DO I = 1, N
13073 A(I) = B(I) + C
13074ENDDO
13075DO I = 1, N
13076 D(I) = E(I) * F
13077ENDDO
13078@end smallexample
13079This flag is enabled by default at @option{-O3}.
13080It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13081
13082@item -ftree-loop-distribute-patterns
13083@opindex ftree-loop-distribute-patterns
13084Perform loop distribution of patterns that can be code generated with
13085calls to a library. This flag is enabled by default at @option{-O2} and
13086higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13087
13088This pass distributes the initialization loops and generates a call to
13089memset zero. For example, the loop
13090@smallexample
13091DO I = 1, N
13092 A(I) = 0
13093 B(I) = A(I) + I
13094ENDDO
13095@end smallexample
13096is transformed to
13097@smallexample
13098DO I = 1, N
13099 A(I) = 0
13100ENDDO
13101DO I = 1, N
13102 B(I) = A(I) + I
13103ENDDO
13104@end smallexample
13105and the initialization loop is transformed into a call to memset zero.
13106This flag is enabled by default at @option{-O3}.
13107It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13108
13109@item -floop-interchange
13110@opindex floop-interchange
13111Perform loop interchange outside of graphite. This flag can improve cache
13112performance on loop nest and allow further loop optimizations, like
13113vectorization, to take place. For example, the loop
13114@smallexample
13115for (int i = 0; i < N; i++)
13116 for (int j = 0; j < N; j++)
13117 for (int k = 0; k < N; k++)
13118 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13119@end smallexample
13120is transformed to
13121@smallexample
13122for (int i = 0; i < N; i++)
13123 for (int k = 0; k < N; k++)
13124 for (int j = 0; j < N; j++)
13125 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13126@end smallexample
13127This flag is enabled by default at @option{-O3}.
13128It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13129
13130@item -floop-unroll-and-jam
13131@opindex floop-unroll-and-jam
13132Apply unroll and jam transformations on feasible loops. In a loop
13133nest this unrolls the outer loop by some factor and fuses the resulting
13134multiple inner loops. This flag is enabled by default at @option{-O3}.
13135It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13136
13137@item -ftree-loop-im
13138@opindex ftree-loop-im
13139Perform loop invariant motion on trees. This pass moves only invariants that
13140are hard to handle at RTL level (function calls, operations that expand to
13141nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13142operands of conditions that are invariant out of the loop, so that we can use
13143just trivial invariantness analysis in loop unswitching. The pass also includes
13144store motion.
13145
13146@item -ftree-loop-ivcanon
13147@opindex ftree-loop-ivcanon
13148Create a canonical counter for number of iterations in loops for which
13149determining number of iterations requires complicated analysis. Later
13150optimizations then may determine the number easily. Useful especially
13151in connection with unrolling.
13152
13153@item -ftree-scev-cprop
13154@opindex ftree-scev-cprop
13155Perform final value replacement. If a variable is modified in a loop
13156in such a way that its value when exiting the loop can be determined using
13157only its initial value and the number of loop iterations, replace uses of
13158the final value by such a computation, provided it is sufficiently cheap.
13159This reduces data dependencies and may allow further simplifications.
13160Enabled by default at @option{-O1} and higher.
13161
13162@item -fivopts
13163@opindex fivopts
13164Perform induction variable optimizations (strength reduction, induction
13165variable merging and induction variable elimination) on trees.
13166
13167@item -ftree-parallelize-loops=n
13168@opindex ftree-parallelize-loops
13169Parallelize loops, i.e., split their iteration space to run in n threads.
13170This is only possible for loops whose iterations are independent
13171and can be arbitrarily reordered. The optimization is only
13172profitable on multiprocessor machines, for loops that are CPU-intensive,
13173rather than constrained e.g.@: by memory bandwidth. This option
13174implies @option{-pthread}, and thus is only supported on targets
13175that have support for @option{-pthread}.
13176
13177@item -ftree-pta
13178@opindex ftree-pta
13179Perform function-local points-to analysis on trees. This flag is
13180enabled by default at @option{-O1} and higher, except for @option{-Og}.
13181
13182@item -ftree-sra
13183@opindex ftree-sra
13184Perform scalar replacement of aggregates. This pass replaces structure
13185references with scalars to prevent committing structures to memory too
13186early. This flag is enabled by default at @option{-O1} and higher,
13187except for @option{-Og}.
13188
13189@item -fstore-merging
13190@opindex fstore-merging
13191Perform merging of narrow stores to consecutive memory addresses. This pass
13192merges contiguous stores of immediate values narrower than a word into fewer
13193wider stores to reduce the number of instructions. This is enabled by default
13194at @option{-O2} and higher as well as @option{-Os}.
13195
13196@item -ftree-ter
13197@opindex ftree-ter
13198Perform temporary expression replacement during the SSA->normal phase. Single
13199use/single def temporaries are replaced at their use location with their
13200defining expression. This results in non-GIMPLE code, but gives the expanders
13201much more complex trees to work on resulting in better RTL generation. This is
13202enabled by default at @option{-O1} and higher.
13203
13204@item -ftree-slsr
13205@opindex ftree-slsr
13206Perform straight-line strength reduction on trees. This recognizes related
13207expressions involving multiplications and replaces them by less expensive
13208calculations when possible. This is enabled by default at @option{-O1} and
13209higher.
13210
13211@item -ftree-vectorize
13212@opindex ftree-vectorize
13213Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13214and @option{-ftree-slp-vectorize} if not explicitly specified.
13215
13216@item -ftree-loop-vectorize
13217@opindex ftree-loop-vectorize
13218Perform loop vectorization on trees. This flag is enabled by default at
13219@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13220and @option{-fauto-profile}.
13221
13222@item -ftree-slp-vectorize
13223@opindex ftree-slp-vectorize
13224Perform basic block vectorization on trees. This flag is enabled by default at
13225@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13226and @option{-fauto-profile}.
13227
13228@item -ftrivial-auto-var-init=@var{choice}
13229@opindex ftrivial-auto-var-init
13230Initialize automatic variables with either a pattern or with zeroes to increase
13231the security and predictability of a program by preventing uninitialized memory
13232disclosure and use.
13233GCC still considers an automatic variable that doesn't have an explicit
13234initializer as uninitialized, @option{-Wuninitialized} and
13235@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13236warning messages on such automatic variables and the compiler will
13237perform optimization as if the variable were uninitialized.
d77de738
ML
13238With this option, GCC will also initialize any padding of automatic variables
13239that have structure or union types to zeroes.
13240However, the current implementation cannot initialize automatic variables that
13241are declared between the controlling expression and the first case of a
13242@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13243such cases.
13244
13245The three values of @var{choice} are:
13246
13247@itemize @bullet
13248@item
13249@samp{uninitialized} doesn't initialize any automatic variables.
13250This is C and C++'s default.
13251
13252@item
13253@samp{pattern} Initialize automatic variables with values which will likely
13254transform logic bugs into crashes down the line, are easily recognized in a
13255crash dump and without being values that programmers can rely on for useful
13256program semantics.
13257The current value is byte-repeatable pattern with byte "0xFE".
13258The values used for pattern initialization might be changed in the future.
13259
13260@item
13261@samp{zero} Initialize automatic variables with zeroes.
13262@end itemize
13263
13264The default is @samp{uninitialized}.
13265
13266You can control this behavior for a specific variable by using the variable
13267attribute @code{uninitialized} (@pxref{Variable Attributes}).
13268
13269@item -fvect-cost-model=@var{model}
13270@opindex fvect-cost-model
13271Alter the cost model used for vectorization. The @var{model} argument
13272should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13273@samp{very-cheap}.
13274With the @samp{unlimited} model the vectorized code-path is assumed
13275to be profitable while with the @samp{dynamic} model a runtime check
13276guards the vectorized code-path to enable it only for iteration
13277counts that will likely execute faster than when executing the original
13278scalar loop. The @samp{cheap} model disables vectorization of
13279loops where doing so would be cost prohibitive for example due to
13280required runtime checks for data dependence or alignment but otherwise
13281is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13282allows vectorization if the vector code would entirely replace the
13283scalar code that is being vectorized. For example, if each iteration
13284of a vectorized loop would only be able to handle exactly four iterations
13285of the scalar loop, the @samp{very-cheap} model would only allow
13286vectorization if the scalar iteration count is known to be a multiple
13287of four.
13288
13289The default cost model depends on other optimization flags and is
13290either @samp{dynamic} or @samp{cheap}.
13291
13292@item -fsimd-cost-model=@var{model}
13293@opindex fsimd-cost-model
13294Alter the cost model used for vectorization of loops marked with the OpenMP
13295simd directive. The @var{model} argument should be one of
13296@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13297have the same meaning as described in @option{-fvect-cost-model} and by
13298default a cost model defined with @option{-fvect-cost-model} is used.
13299
13300@item -ftree-vrp
13301@opindex ftree-vrp
13302Perform Value Range Propagation on trees. This is similar to the
13303constant propagation pass, but instead of values, ranges of values are
13304propagated. This allows the optimizers to remove unnecessary range
13305checks like array bound checks and null pointer checks. This is
13306enabled by default at @option{-O2} and higher. Null pointer check
13307elimination is only done if @option{-fdelete-null-pointer-checks} is
13308enabled.
13309
13310@item -fsplit-paths
13311@opindex fsplit-paths
13312Split paths leading to loop backedges. This can improve dead code
13313elimination and common subexpression elimination. This is enabled by
13314default at @option{-O3} and above.
13315
13316@item -fsplit-ivs-in-unroller
13317@opindex fsplit-ivs-in-unroller
13318Enables expression of values of induction variables in later iterations
13319of the unrolled loop using the value in the first iteration. This breaks
13320long dependency chains, thus improving efficiency of the scheduling passes.
13321
13322A combination of @option{-fweb} and CSE is often sufficient to obtain the
13323same effect. However, that is not reliable in cases where the loop body
13324is more complicated than a single basic block. It also does not work at all
13325on some architectures due to restrictions in the CSE pass.
13326
13327This optimization is enabled by default.
13328
13329@item -fvariable-expansion-in-unroller
13330@opindex fvariable-expansion-in-unroller
13331With this option, the compiler creates multiple copies of some
13332local variables when unrolling a loop, which can result in superior code.
13333
13334This optimization is enabled by default for PowerPC targets, but disabled
13335by default otherwise.
13336
13337@item -fpartial-inlining
13338@opindex fpartial-inlining
13339Inline parts of functions. This option has any effect only
13340when inlining itself is turned on by the @option{-finline-functions}
13341or @option{-finline-small-functions} options.
13342
13343Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13344
13345@item -fpredictive-commoning
13346@opindex fpredictive-commoning
13347Perform predictive commoning optimization, i.e., reusing computations
13348(especially memory loads and stores) performed in previous
13349iterations of loops.
13350
13351This option is enabled at level @option{-O3}.
13352It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13353
13354@item -fprefetch-loop-arrays
13355@opindex fprefetch-loop-arrays
13356If supported by the target machine, generate instructions to prefetch
13357memory to improve the performance of loops that access large arrays.
13358
13359This option may generate better or worse code; results are highly
13360dependent on the structure of loops within the source code.
13361
13362Disabled at level @option{-Os}.
13363
13364@item -fno-printf-return-value
13365@opindex fno-printf-return-value
13366@opindex fprintf-return-value
13367Do not substitute constants for known return value of formatted output
13368functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13369@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13370transformation allows GCC to optimize or even eliminate branches based
13371on the known return value of these functions called with arguments that
13372are either constant, or whose values are known to be in a range that
13373makes determining the exact return value possible. For example, when
13374@option{-fprintf-return-value} is in effect, both the branch and the
13375body of the @code{if} statement (but not the call to @code{snprint})
13376can be optimized away when @code{i} is a 32-bit or smaller integer
13377because the return value is guaranteed to be at most 8.
13378
13379@smallexample
13380char buf[9];
13381if (snprintf (buf, "%08x", i) >= sizeof buf)
13382 @dots{}
13383@end smallexample
13384
13385The @option{-fprintf-return-value} option relies on other optimizations
13386and yields best results with @option{-O2} and above. It works in tandem
13387with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13388options. The @option{-fprintf-return-value} option is enabled by default.
13389
13390@item -fno-peephole
13391@itemx -fno-peephole2
13392@opindex fno-peephole
13393@opindex fpeephole
13394@opindex fno-peephole2
13395@opindex fpeephole2
13396Disable any machine-specific peephole optimizations. The difference
13397between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13398are implemented in the compiler; some targets use one, some use the
13399other, a few use both.
13400
13401@option{-fpeephole} is enabled by default.
13402@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13403
13404@item -fno-guess-branch-probability
13405@opindex fno-guess-branch-probability
13406@opindex fguess-branch-probability
13407Do not guess branch probabilities using heuristics.
13408
13409GCC uses heuristics to guess branch probabilities if they are
13410not provided by profiling feedback (@option{-fprofile-arcs}). These
13411heuristics are based on the control flow graph. If some branch probabilities
13412are specified by @code{__builtin_expect}, then the heuristics are
13413used to guess branch probabilities for the rest of the control flow graph,
13414taking the @code{__builtin_expect} info into account. The interactions
13415between the heuristics and @code{__builtin_expect} can be complex, and in
13416some cases, it may be useful to disable the heuristics so that the effects
13417of @code{__builtin_expect} are easier to understand.
13418
13419It is also possible to specify expected probability of the expression
13420with @code{__builtin_expect_with_probability} built-in function.
13421
13422The default is @option{-fguess-branch-probability} at levels
13423@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13424
13425@item -freorder-blocks
13426@opindex freorder-blocks
13427Reorder basic blocks in the compiled function in order to reduce number of
13428taken branches and improve code locality.
13429
13430Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13431
13432@item -freorder-blocks-algorithm=@var{algorithm}
13433@opindex freorder-blocks-algorithm
13434Use the specified algorithm for basic block reordering. The
13435@var{algorithm} argument can be @samp{simple}, which does not increase
13436code size (except sometimes due to secondary effects like alignment),
13437or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13438put all often executed code together, minimizing the number of branches
13439executed by making extra copies of code.
13440
13441The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13442@samp{stc} at levels @option{-O2}, @option{-O3}.
13443
13444@item -freorder-blocks-and-partition
13445@opindex freorder-blocks-and-partition
13446In addition to reordering basic blocks in the compiled function, in order
13447to reduce number of taken branches, partitions hot and cold basic blocks
13448into separate sections of the assembly and @file{.o} files, to improve
13449paging and cache locality performance.
13450
13451This optimization is automatically turned off in the presence of
13452exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13453section attribute and on any architecture that does not support named
13454sections. When @option{-fsplit-stack} is used this option is not
13455enabled by default (to avoid linker errors), but may be enabled
13456explicitly (if using a working linker).
13457
13458Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13459
13460@item -freorder-functions
13461@opindex freorder-functions
13462Reorder functions in the object file in order to
13463improve code locality. This is implemented by using special
13464subsections @code{.text.hot} for most frequently executed functions and
13465@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13466the linker so object file format must support named sections and linker must
13467place them in a reasonable way.
13468
13469This option isn't effective unless you either provide profile feedback
13470(see @option{-fprofile-arcs} for details) or manually annotate functions with
13471@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13472
13473Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13474
13475@item -fstrict-aliasing
13476@opindex fstrict-aliasing
13477Allow the compiler to assume the strictest aliasing rules applicable to
13478the language being compiled. For C (and C++), this activates
13479optimizations based on the type of expressions. In particular, an
13480object of one type is assumed never to reside at the same address as an
13481object of a different type, unless the types are almost the same. For
13482example, an @code{unsigned int} can alias an @code{int}, but not a
13483@code{void*} or a @code{double}. A character type may alias any other
13484type.
13485
13486@anchor{Type-punning}Pay special attention to code like this:
13487@smallexample
13488union a_union @{
13489 int i;
13490 double d;
13491@};
13492
13493int f() @{
13494 union a_union t;
13495 t.d = 3.0;
13496 return t.i;
13497@}
13498@end smallexample
13499The practice of reading from a different union member than the one most
13500recently written to (called ``type-punning'') is common. Even with
13501@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13502is accessed through the union type. So, the code above works as
13503expected. @xref{Structures unions enumerations and bit-fields
13504implementation}. However, this code might not:
13505@smallexample
13506int f() @{
13507 union a_union t;
13508 int* ip;
13509 t.d = 3.0;
13510 ip = &t.i;
13511 return *ip;
13512@}
13513@end smallexample
13514
13515Similarly, access by taking the address, casting the resulting pointer
13516and dereferencing the result has undefined behavior, even if the cast
13517uses a union type, e.g.:
13518@smallexample
13519int f() @{
13520 double d = 3.0;
13521 return ((union a_union *) &d)->i;
13522@}
13523@end smallexample
13524
13525The @option{-fstrict-aliasing} option is enabled at levels
13526@option{-O2}, @option{-O3}, @option{-Os}.
13527
13528@item -fipa-strict-aliasing
13529@opindex fipa-strict-aliasing
13530Controls whether rules of @option{-fstrict-aliasing} are applied across
13531function boundaries. Note that if multiple functions gets inlined into a
13532single function the memory accesses are no longer considered to be crossing a
13533function boundary.
13534
13535The @option{-fipa-strict-aliasing} option is enabled by default and is
13536effective only in combination with @option{-fstrict-aliasing}.
13537
13538@item -falign-functions
13539@itemx -falign-functions=@var{n}
13540@itemx -falign-functions=@var{n}:@var{m}
13541@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13542@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
13543@opindex falign-functions
13544Align the start of functions to the next power-of-two greater than or
13545equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13546least the first @var{m} bytes of the function can be fetched by the CPU
13547without crossing an @var{n}-byte alignment boundary.
13548
13549If @var{m} is not specified, it defaults to @var{n}.
13550
13551Examples: @option{-falign-functions=32} aligns functions to the next
1355232-byte boundary, @option{-falign-functions=24} aligns to the next
1355332-byte boundary only if this can be done by skipping 23 bytes or less,
13554@option{-falign-functions=32:7} aligns to the next
1355532-byte boundary only if this can be done by skipping 6 bytes or less.
13556
13557The second pair of @var{n2}:@var{m2} values allows you to specify
13558a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13559the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13560otherwise aligns to the next 32-byte boundary if this can be done
13561by skipping 2 bytes or less.
13562If @var{m2} is not specified, it defaults to @var{n2}.
13563
13564Some assemblers only support this flag when @var{n} is a power of two;
13565in that case, it is rounded up.
13566
13567@option{-fno-align-functions} and @option{-falign-functions=1} are
13568equivalent and mean that functions are not aligned.
13569
13570If @var{n} is not specified or is zero, use a machine-dependent default.
13571The maximum allowed @var{n} option value is 65536.
13572
13573Enabled at levels @option{-O2}, @option{-O3}.
13574
13575@item -flimit-function-alignment
13576If this option is enabled, the compiler tries to avoid unnecessarily
13577overaligning functions. It attempts to instruct the assembler to align
13578by the amount specified by @option{-falign-functions}, but not to
13579skip more bytes than the size of the function.
13580
13581@item -falign-labels
13582@itemx -falign-labels=@var{n}
13583@itemx -falign-labels=@var{n}:@var{m}
13584@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13585@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
13586@opindex falign-labels
13587Align all branch targets to a power-of-two boundary.
13588
13589Parameters of this option are analogous to the @option{-falign-functions} option.
13590@option{-fno-align-labels} and @option{-falign-labels=1} are
13591equivalent and mean that labels are not aligned.
13592
13593If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13594are greater than this value, then their values are used instead.
13595
13596If @var{n} is not specified or is zero, use a machine-dependent default
13597which is very likely to be @samp{1}, meaning no alignment.
13598The maximum allowed @var{n} option value is 65536.
13599
13600Enabled at levels @option{-O2}, @option{-O3}.
13601
13602@item -falign-loops
13603@itemx -falign-loops=@var{n}
13604@itemx -falign-loops=@var{n}:@var{m}
13605@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13606@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
13607@opindex falign-loops
13608Align loops to a power-of-two boundary. If the loops are executed
13609many times, this makes up for any execution of the dummy padding
13610instructions.
13611
13612If @option{-falign-labels} is greater than this value, then its value
13613is used instead.
13614
13615Parameters of this option are analogous to the @option{-falign-functions} option.
13616@option{-fno-align-loops} and @option{-falign-loops=1} are
13617equivalent and mean that loops are not aligned.
13618The maximum allowed @var{n} option value is 65536.
13619
13620If @var{n} is not specified or is zero, use a machine-dependent default.
13621
13622Enabled at levels @option{-O2}, @option{-O3}.
13623
13624@item -falign-jumps
13625@itemx -falign-jumps=@var{n}
13626@itemx -falign-jumps=@var{n}:@var{m}
13627@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13628@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
13629@opindex falign-jumps
13630Align branch targets to a power-of-two boundary, for branch targets
13631where the targets can only be reached by jumping. In this case,
13632no dummy operations need be executed.
13633
13634If @option{-falign-labels} is greater than this value, then its value
13635is used instead.
13636
13637Parameters of this option are analogous to the @option{-falign-functions} option.
13638@option{-fno-align-jumps} and @option{-falign-jumps=1} are
13639equivalent and mean that loops are not aligned.
13640
13641If @var{n} is not specified or is zero, use a machine-dependent default.
13642The maximum allowed @var{n} option value is 65536.
13643
13644Enabled at levels @option{-O2}, @option{-O3}.
13645
13646@item -fno-allocation-dce
13647@opindex fno-allocation-dce
13648Do not remove unused C++ allocations in dead code elimination.
13649
13650@item -fallow-store-data-races
13651@opindex fallow-store-data-races
13652Allow the compiler to perform optimizations that may introduce new data races
13653on stores, without proving that the variable cannot be concurrently accessed
13654by other threads. Does not affect optimization of local data. It is safe to
13655use this option if it is known that global data will not be accessed by
13656multiple threads.
13657
13658Examples of optimizations enabled by @option{-fallow-store-data-races} include
13659hoisting or if-conversions that may cause a value that was already in memory
13660to be re-written with that same value. Such re-writing is safe in a single
13661threaded context but may be unsafe in a multi-threaded context. Note that on
13662some processors, if-conversions may be required in order to enable
13663vectorization.
13664
13665Enabled at level @option{-Ofast}.
13666
13667@item -funit-at-a-time
13668@opindex funit-at-a-time
13669This option is left for compatibility reasons. @option{-funit-at-a-time}
13670has no effect, while @option{-fno-unit-at-a-time} implies
13671@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
13672
13673Enabled by default.
13674
13675@item -fno-toplevel-reorder
13676@opindex fno-toplevel-reorder
13677@opindex ftoplevel-reorder
13678Do not reorder top-level functions, variables, and @code{asm}
13679statements. Output them in the same order that they appear in the
13680input file. When this option is used, unreferenced static variables
13681are not removed. This option is intended to support existing code
13682that relies on a particular ordering. For new code, it is better to
13683use attributes when possible.
13684
13685@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
13686also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
13687Additionally @option{-fno-toplevel-reorder} implies
13688@option{-fno-section-anchors}.
13689
13690@item -funreachable-traps
13691@opindex funreachable-traps
13692With this option, the compiler turns calls to
13693@code{__builtin_unreachable} into traps, instead of using them for
13694optimization. This also affects any such calls implicitly generated
13695by the compiler.
13696
13697This option has the same effect as @option{-fsanitize=unreachable
13698-fsanitize-trap=unreachable}, but does not affect the values of those
13699options. If @option{-fsanitize=unreachable} is enabled, that option
13700takes priority over this one.
13701
13702This option is enabled by default at @option{-O0} and @option{-Og}.
13703
13704@item -fweb
13705@opindex fweb
13706Constructs webs as commonly used for register allocation purposes and assign
13707each web individual pseudo register. This allows the register allocation pass
13708to operate on pseudos directly, but also strengthens several other optimization
13709passes, such as CSE, loop optimizer and trivial dead code remover. It can,
13710however, make debugging impossible, since variables no longer stay in a
13711``home register''.
13712
13713Enabled by default with @option{-funroll-loops}.
13714
13715@item -fwhole-program
13716@opindex fwhole-program
13717Assume that the current compilation unit represents the whole program being
13718compiled. All public functions and variables with the exception of @code{main}
13719and those merged by attribute @code{externally_visible} become static functions
13720and in effect are optimized more aggressively by interprocedural optimizers.
13721
39ebd3a9
JH
13722With @option{-flto} this option has a limited use. In most cases the
13723precise list of symbols used or exported from the binary is known the
13724resolution info passed to the link-time optimizer by the linker plugin. It is
13725still useful if no linker plugin is used or during incremental link step when
13726final code is produced (with @option{-flto}
13727@option{-flinker-output=nolto-rel}).
d77de738
ML
13728
13729@item -flto[=@var{n}]
13730@opindex flto
13731This option runs the standard link-time optimizer. When invoked
13732with source code, it generates GIMPLE (one of GCC's internal
13733representations) and writes it to special ELF sections in the object
13734file. When the object files are linked together, all the function
13735bodies are read from these ELF sections and instantiated as if they
13736had been part of the same translation unit.
13737
13738To use the link-time optimizer, @option{-flto} and optimization
13739options should be specified at compile time and during the final link.
13740It is recommended that you compile all the files participating in the
13741same link with the same options and also specify those options at
13742link time.
13743For example:
13744
13745@smallexample
13746gcc -c -O2 -flto foo.c
13747gcc -c -O2 -flto bar.c
13748gcc -o myprog -flto -O2 foo.o bar.o
13749@end smallexample
13750
13751The first two invocations to GCC save a bytecode representation
13752of GIMPLE into special ELF sections inside @file{foo.o} and
13753@file{bar.o}. The final invocation reads the GIMPLE bytecode from
13754@file{foo.o} and @file{bar.o}, merges the two files into a single
13755internal image, and compiles the result as usual. Since both
13756@file{foo.o} and @file{bar.o} are merged into a single image, this
13757causes all the interprocedural analyses and optimizations in GCC to
13758work across the two files as if they were a single one. This means,
13759for example, that the inliner is able to inline functions in
13760@file{bar.o} into functions in @file{foo.o} and vice-versa.
13761
13762Another (simpler) way to enable link-time optimization is:
13763
13764@smallexample
13765gcc -o myprog -flto -O2 foo.c bar.c
13766@end smallexample
13767
13768The above generates bytecode for @file{foo.c} and @file{bar.c},
13769merges them together into a single GIMPLE representation and optimizes
13770them as usual to produce @file{myprog}.
13771
13772The important thing to keep in mind is that to enable link-time
13773optimizations you need to use the GCC driver to perform the link step.
13774GCC automatically performs link-time optimization if any of the
13775objects involved were compiled with the @option{-flto} command-line option.
13776You can always override
13777the automatic decision to do link-time optimization
13778by passing @option{-fno-lto} to the link command.
13779
13780To make whole program optimization effective, it is necessary to make
13781certain whole program assumptions. The compiler needs to know
13782what functions and variables can be accessed by libraries and runtime
13783outside of the link-time optimized unit. When supported by the linker,
13784the linker plugin (see @option{-fuse-linker-plugin}) passes information
13785to the compiler about used and externally visible symbols. When
13786the linker plugin is not available, @option{-fwhole-program} should be
13787used to allow the compiler to make these assumptions, which leads
13788to more aggressive optimization decisions.
13789
13790When a file is compiled with @option{-flto} without
13791@option{-fuse-linker-plugin}, the generated object file is larger than
13792a regular object file because it contains GIMPLE bytecodes and the usual
13793final code (see @option{-ffat-lto-objects}). This means that
13794object files with LTO information can be linked as normal object
13795files; if @option{-fno-lto} is passed to the linker, no
13796interprocedural optimizations are applied. Note that when
13797@option{-fno-fat-lto-objects} is enabled the compile stage is faster
13798but you cannot perform a regular, non-LTO link on them.
13799
13800When producing the final binary, GCC only
13801applies link-time optimizations to those files that contain bytecode.
13802Therefore, you can mix and match object files and libraries with
13803GIMPLE bytecodes and final object code. GCC automatically selects
13804which files to optimize in LTO mode and which files to link without
13805further processing.
13806
13807Generally, options specified at link time override those
13808specified at compile time, although in some cases GCC attempts to infer
13809link-time options from the settings used to compile the input files.
13810
13811If you do not specify an optimization level option @option{-O} at
13812link time, then GCC uses the highest optimization level
13813used when compiling the object files. Note that it is generally
13814ineffective to specify an optimization level option only at link time and
13815not at compile time, for two reasons. First, compiling without
13816optimization suppresses compiler passes that gather information
13817needed for effective optimization at link time. Second, some early
13818optimization passes can be performed only at compile time and
13819not at link time.
13820
13821There are some code generation flags preserved by GCC when
13822generating bytecodes, as they need to be used during the final link.
13823Currently, the following options and their settings are taken from
13824the first object file that explicitly specifies them:
13825@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
13826@option{-fgnu-tm} and all the @option{-m} target flags.
13827
13828The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
13829@option{-fPIE} are combined based on the following scheme:
13830
13831@smallexample
13832@option{-fPIC} + @option{-fpic} = @option{-fpic}
13833@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
13834@option{-fpic/-fPIC} + (no option) = (no option)
13835@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
13836@option{-fpic} + @option{-fPIE} = @option{-fpie}
13837@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
13838@end smallexample
13839
13840Certain ABI-changing flags are required to match in all compilation units,
13841and trying to override this at link time with a conflicting value
13842is ignored. This includes options such as @option{-freg-struct-return}
13843and @option{-fpcc-struct-return}.
13844
13845Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
13846@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
13847are passed through to the link stage and merged conservatively for
13848conflicting translation units. Specifically
13849@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
13850precedence; and for example @option{-ffp-contract=off} takes precedence
13851over @option{-ffp-contract=fast}. You can override them at link time.
13852
13853Diagnostic options such as @option{-Wstringop-overflow} are passed
13854through to the link stage and their setting matches that of the
13855compile-step at function granularity. Note that this matters only
13856for diagnostics emitted during optimization. Note that code
13857transforms such as inlining can lead to warnings being enabled
13858or disabled for regions if code not consistent with the setting
13859at compile time.
13860
13861When you need to pass options to the assembler via @option{-Wa} or
13862@option{-Xassembler} make sure to either compile such translation
13863units with @option{-fno-lto} or consistently use the same assembler
13864options on all translation units. You can alternatively also
13865specify assembler options at LTO link time.
13866
13867To enable debug info generation you need to supply @option{-g} at
13868compile time. If any of the input files at link time were built
13869with debug info generation enabled the link will enable debug info
13870generation as well. Any elaborate debug info settings
13871like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
13872at the linker command line and mixing different settings in different
13873translation units is discouraged.
13874
13875If LTO encounters objects with C linkage declared with incompatible
13876types in separate translation units to be linked together (undefined
13877behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
13878issued. The behavior is still undefined at run time. Similar
13879diagnostics may be raised for other languages.
13880
13881Another feature of LTO is that it is possible to apply interprocedural
13882optimizations on files written in different languages:
13883
13884@smallexample
13885gcc -c -flto foo.c
13886g++ -c -flto bar.cc
13887gfortran -c -flto baz.f90
13888g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
13889@end smallexample
13890
13891Notice that the final link is done with @command{g++} to get the C++
13892runtime libraries and @option{-lgfortran} is added to get the Fortran
13893runtime libraries. In general, when mixing languages in LTO mode, you
13894should use the same link command options as when mixing languages in a
13895regular (non-LTO) compilation.
13896
13897If object files containing GIMPLE bytecode are stored in a library archive, say
13898@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
13899are using a linker with plugin support. To create static libraries suitable
13900for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
13901and @command{ranlib};
13902to show the symbols of object files with GIMPLE bytecode, use
13903@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
13904and @command{nm} have been compiled with plugin support. At link time, use the
13905flag @option{-fuse-linker-plugin} to ensure that the library participates in
13906the LTO optimization process:
13907
13908@smallexample
13909gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
13910@end smallexample
13911
13912With the linker plugin enabled, the linker extracts the needed
13913GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
13914to make them part of the aggregated GIMPLE image to be optimized.
13915
13916If you are not using a linker with plugin support and/or do not
13917enable the linker plugin, then the objects inside @file{libfoo.a}
13918are extracted and linked as usual, but they do not participate
13919in the LTO optimization process. In order to make a static library suitable
13920for both LTO optimization and usual linkage, compile its object files with
13921@option{-flto} @option{-ffat-lto-objects}.
13922
13923Link-time optimizations do not require the presence of the whole program to
13924operate. If the program does not require any symbols to be exported, it is
13925possible to combine @option{-flto} and @option{-fwhole-program} to allow
13926the interprocedural optimizers to use more aggressive assumptions which may
13927lead to improved optimization opportunities.
13928Use of @option{-fwhole-program} is not needed when linker plugin is
13929active (see @option{-fuse-linker-plugin}).
13930
13931The current implementation of LTO makes no
13932attempt to generate bytecode that is portable between different
13933types of hosts. The bytecode files are versioned and there is a
13934strict version check, so bytecode files generated in one version of
13935GCC do not work with an older or newer version of GCC.
13936
13937Link-time optimization does not work well with generation of debugging
13938information on systems other than those using a combination of ELF and
13939DWARF.
13940
13941If you specify the optional @var{n}, the optimization and code
13942generation done at link time is executed in parallel using @var{n}
13943parallel jobs by utilizing an installed @command{make} program. The
13944environment variable @env{MAKE} may be used to override the program
13945used.
13946
13947You can also specify @option{-flto=jobserver} to use GNU make's
13948job server mode to determine the number of parallel jobs. This
13949is useful when the Makefile calling GCC is already executing in parallel.
13950You must prepend a @samp{+} to the command recipe in the parent Makefile
13951for this to work. This option likely only works if @env{MAKE} is
13952GNU make. Even without the option value, GCC tries to automatically
13953detect a running GNU make's job server.
13954
13955Use @option{-flto=auto} to use GNU make's job server, if available,
13956or otherwise fall back to autodetection of the number of CPU threads
13957present in your system.
13958
13959@item -flto-partition=@var{alg}
13960@opindex flto-partition
13961Specify the partitioning algorithm used by the link-time optimizer.
13962The value is either @samp{1to1} to specify a partitioning mirroring
13963the original source files or @samp{balanced} to specify partitioning
13964into equally sized chunks (whenever possible) or @samp{max} to create
13965new partition for every symbol where possible. Specifying @samp{none}
13966as an algorithm disables partitioning and streaming completely.
13967The default value is @samp{balanced}. While @samp{1to1} can be used
13968as an workaround for various code ordering issues, the @samp{max}
13969partitioning is intended for internal testing only.
13970The value @samp{one} specifies that exactly one partition should be
13971used while the value @samp{none} bypasses partitioning and executes
13972the link-time optimization step directly from the WPA phase.
13973
13974@item -flto-compression-level=@var{n}
13975@opindex flto-compression-level
13976This option specifies the level of compression used for intermediate
13977language written to LTO object files, and is only meaningful in
13978conjunction with LTO mode (@option{-flto}). GCC currently supports two
13979LTO compression algorithms. For zstd, valid values are 0 (no compression)
13980to 19 (maximum compression), while zlib supports values from 0 to 9.
13981Values outside this range are clamped to either minimum or maximum
13982of the supported values. If the option is not given,
13983a default balanced compression setting is used.
13984
13985@item -fuse-linker-plugin
13986@opindex fuse-linker-plugin
13987Enables the use of a linker plugin during link-time optimization. This
13988option relies on plugin support in the linker, which is available in gold
13989or in GNU ld 2.21 or newer.
13990
13991This option enables the extraction of object files with GIMPLE bytecode out
13992of library archives. This improves the quality of optimization by exposing
13993more code to the link-time optimizer. This information specifies what
13994symbols can be accessed externally (by non-LTO object or during dynamic
13995linking). Resulting code quality improvements on binaries (and shared
13996libraries that use hidden visibility) are similar to @option{-fwhole-program}.
13997See @option{-flto} for a description of the effect of this flag and how to
13998use it.
13999
14000This option is enabled by default when LTO support in GCC is enabled
14001and GCC was configured for use with
14002a linker supporting plugins (GNU ld 2.21 or newer or gold).
14003
14004@item -ffat-lto-objects
14005@opindex ffat-lto-objects
14006Fat LTO objects are object files that contain both the intermediate language
14007and the object code. This makes them usable for both LTO linking and normal
14008linking. This option is effective only when compiling with @option{-flto}
14009and is ignored at link time.
14010
14011@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14012requires the complete toolchain to be aware of LTO. It requires a linker with
14013linker plugin support for basic functionality. Additionally,
14014@command{nm}, @command{ar} and @command{ranlib}
14015need to support linker plugins to allow a full-featured build environment
14016(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14017@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14018to these tools. With non fat LTO makefiles need to be modified to use them.
14019
14020Note that modern binutils provide plugin auto-load mechanism.
14021Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14022effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14023@command{gcc-ranlib}).
14024
14025The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14026support.
14027
14028@item -fcompare-elim
14029@opindex fcompare-elim
14030After register allocation and post-register allocation instruction splitting,
14031identify arithmetic instructions that compute processor flags similar to a
14032comparison operation based on that arithmetic. If possible, eliminate the
14033explicit comparison operation.
14034
14035This pass only applies to certain targets that cannot explicitly represent
14036the comparison operation before register allocation is complete.
14037
14038Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14039
14040@item -fcprop-registers
14041@opindex fcprop-registers
14042After register allocation and post-register allocation instruction splitting,
14043perform a copy-propagation pass to try to reduce scheduling dependencies
14044and occasionally eliminate the copy.
14045
14046Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14047
14048@item -fprofile-correction
14049@opindex fprofile-correction
14050Profiles collected using an instrumented binary for multi-threaded programs may
14051be inconsistent due to missed counter updates. When this option is specified,
14052GCC uses heuristics to correct or smooth out such inconsistencies. By
14053default, GCC emits an error message when an inconsistent profile is detected.
14054
14055This option is enabled by @option{-fauto-profile}.
14056
14057@item -fprofile-partial-training
14058@opindex fprofile-partial-training
14059With @code{-fprofile-use} all portions of programs not executed during train
14060run are optimized agressively for size rather than speed. In some cases it is
14061not practical to train all possible hot paths in the program. (For
14062example, program may contain functions specific for a given hardware and
14063trianing may not cover all hardware configurations program is run on.) With
14064@code{-fprofile-partial-training} profile feedback will be ignored for all
14065functions not executed during the train run leading them to be optimized as if
14066they were compiled without profile feedback. This leads to better performance
14067when train run is not representative but also leads to significantly bigger
14068code.
14069
14070@item -fprofile-use
14071@itemx -fprofile-use=@var{path}
14072@opindex fprofile-use
14073Enable profile feedback-directed optimizations,
14074and the following optimizations, many of which
14075are generally profitable only with profile feedback available:
14076
14077@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14078-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14079-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14080-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14081-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14082-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14083-fprofile-reorder-functions}
14084
14085Before you can use this option, you must first generate profiling information.
14086@xref{Instrumentation Options}, for information about the
14087@option{-fprofile-generate} option.
14088
14089By default, GCC emits an error message if the feedback profiles do not
14090match the source code. This error can be turned into a warning by using
14091@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14092optimized code. Additionally, by default, GCC also emits a warning message if
14093the feedback profiles do not exist (see @option{-Wmissing-profile}).
14094
14095If @var{path} is specified, GCC looks at the @var{path} to find
14096the profile feedback data files. See @option{-fprofile-dir}.
14097
14098@item -fauto-profile
14099@itemx -fauto-profile=@var{path}
14100@opindex fauto-profile
14101Enable sampling-based feedback-directed optimizations,
14102and the following optimizations,
14103many of which are generally profitable only with profile feedback available:
14104
14105@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14106-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14107-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14108-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14109-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14110-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14111-fprofile-correction}
14112
14113@var{path} is the name of a file containing AutoFDO profile information.
14114If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14115
14116Producing an AutoFDO profile data file requires running your program
14117with the @command{perf} utility on a supported GNU/Linux target system.
14118For more information, see @uref{https://perf.wiki.kernel.org/}.
14119
14120E.g.
14121@smallexample
14122perf record -e br_inst_retired:near_taken -b -o perf.data \
14123 -- your_program
14124@end smallexample
14125
14126Then use the @command{create_gcov} tool to convert the raw profile data
14127to a format that can be used by GCC.@ You must also supply the
14128unstripped binary for your program to this tool.
14129See @uref{https://github.com/google/autofdo}.
14130
14131E.g.
14132@smallexample
14133create_gcov --binary=your_program.unstripped --profile=perf.data \
14134 --gcov=profile.afdo
14135@end smallexample
14136@end table
14137
14138The following options control compiler behavior regarding floating-point
14139arithmetic. These options trade off between speed and
14140correctness. All must be specifically enabled.
14141
14142@table @gcctabopt
14143@item -ffloat-store
14144@opindex ffloat-store
14145Do not store floating-point variables in registers, and inhibit other
14146options that might change whether a floating-point value is taken from a
14147register or memory.
14148
14149@cindex floating-point precision
14150This option prevents undesirable excess precision on machines such as
14151the 68000 where the floating registers (of the 68881) keep more
14152precision than a @code{double} is supposed to have. Similarly for the
14153x86 architecture. For most programs, the excess precision does only
14154good, but a few programs rely on the precise definition of IEEE floating
14155point. Use @option{-ffloat-store} for such programs, after modifying
14156them to store all pertinent intermediate computations into variables.
14157
14158@item -fexcess-precision=@var{style}
14159@opindex fexcess-precision
14160This option allows further control over excess precision on machines
14161where floating-point operations occur in a format with more precision or
14162range than the IEEE standard and interchange floating-point types. By
14163default, @option{-fexcess-precision=fast} is in effect; this means that
14164operations may be carried out in a wider precision than the types specified
14165in the source if that would result in faster code, and it is unpredictable
14166when rounding to the types specified in the source code takes place.
14167When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14168then excess precision follows the rules specified in ISO C99 or C++; in particular,
14169both casts and assignments cause values to be rounded to their
14170semantic types (whereas @option{-ffloat-store} only affects
14171assignments). This option is enabled by default for C or C++ if a strict
14172conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14173@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14174regardless of whether a strict conformance option is used.
14175
14176@opindex mfpmath
14177@option{-fexcess-precision=standard} is not implemented for languages
14178other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14179or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14180semantics apply without excess precision, and in the latter, rounding
14181is unpredictable.
14182
14183@item -ffast-math
14184@opindex ffast-math
14185Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14186@option{-ffinite-math-only}, @option{-fno-rounding-math},
14187@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14188@option{-fexcess-precision=fast}.
14189
14190This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14191
14192This option is not turned on by any @option{-O} option besides
14193@option{-Ofast} since it can result in incorrect output for programs
14194that depend on an exact implementation of IEEE or ISO rules/specifications
14195for math functions. It may, however, yield faster code for programs
14196that do not require the guarantees of these specifications.
14197
14198@item -fno-math-errno
14199@opindex fno-math-errno
14200@opindex fmath-errno
14201Do not set @code{errno} after calling math functions that are executed
14202with a single instruction, e.g., @code{sqrt}. A program that relies on
14203IEEE exceptions for math error handling may want to use this flag
14204for speed while maintaining IEEE arithmetic compatibility.
14205
14206This option is not turned on by any @option{-O} option since
14207it can result in incorrect output for programs that depend on
14208an exact implementation of IEEE or ISO rules/specifications for
14209math functions. It may, however, yield faster code for programs
14210that do not require the guarantees of these specifications.
14211
14212The default is @option{-fmath-errno}.
14213
14214On Darwin systems, the math library never sets @code{errno}. There is
14215therefore no reason for the compiler to consider the possibility that
14216it might, and @option{-fno-math-errno} is the default.
14217
14218@item -funsafe-math-optimizations
14219@opindex funsafe-math-optimizations
14220
14221Allow optimizations for floating-point arithmetic that (a) assume
14222that arguments and results are valid and (b) may violate IEEE or
14223ANSI standards. When used at link time, it may include libraries
14224or startup files that change the default FPU control word or other
14225similar optimizations.
14226
14227This option is not turned on by any @option{-O} option since
14228it can result in incorrect output for programs that depend on
14229an exact implementation of IEEE or ISO rules/specifications for
14230math functions. It may, however, yield faster code for programs
14231that do not require the guarantees of these specifications.
14232Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14233@option{-fassociative-math} and @option{-freciprocal-math}.
14234
14235The default is @option{-fno-unsafe-math-optimizations}.
14236
14237@item -fassociative-math
14238@opindex fassociative-math
14239
14240Allow re-association of operands in series of floating-point operations.
14241This violates the ISO C and C++ language standard by possibly changing
14242computation result. NOTE: re-ordering may change the sign of zero as
14243well as ignore NaNs and inhibit or create underflow or overflow (and
14244thus cannot be used on code that relies on rounding behavior like
14245@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14246and thus may not be used when ordered comparisons are required.
14247This option requires that both @option{-fno-signed-zeros} and
14248@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14249much sense with @option{-frounding-math}. For Fortran the option
14250is automatically enabled when both @option{-fno-signed-zeros} and
14251@option{-fno-trapping-math} are in effect.
14252
14253The default is @option{-fno-associative-math}.
14254
14255@item -freciprocal-math
14256@opindex freciprocal-math
14257
14258Allow the reciprocal of a value to be used instead of dividing by
14259the value if this enables optimizations. For example @code{x / y}
14260can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14261is subject to common subexpression elimination. Note that this loses
14262precision and increases the number of flops operating on the value.
14263
14264The default is @option{-fno-reciprocal-math}.
14265
14266@item -ffinite-math-only
14267@opindex ffinite-math-only
14268Allow optimizations for floating-point arithmetic that assume
14269that arguments and results are not NaNs or +-Infs.
14270
14271This option is not turned on by any @option{-O} option since
14272it can result in incorrect output for programs that depend on
14273an exact implementation of IEEE or ISO rules/specifications for
14274math functions. It may, however, yield faster code for programs
14275that do not require the guarantees of these specifications.
14276
14277The default is @option{-fno-finite-math-only}.
14278
14279@item -fno-signed-zeros
14280@opindex fno-signed-zeros
14281@opindex fsigned-zeros
14282Allow optimizations for floating-point arithmetic that ignore the
14283signedness of zero. IEEE arithmetic specifies the behavior of
14284distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14285of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14286This option implies that the sign of a zero result isn't significant.
14287
14288The default is @option{-fsigned-zeros}.
14289
14290@item -fno-trapping-math
14291@opindex fno-trapping-math
14292@opindex ftrapping-math
14293Compile code assuming that floating-point operations cannot generate
14294user-visible traps. These traps include division by zero, overflow,
14295underflow, inexact result and invalid operation. This option requires
14296that @option{-fno-signaling-nans} be in effect. Setting this option may
14297allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14298
14299This option should never be turned on by any @option{-O} option since
14300it can result in incorrect output for programs that depend on
14301an exact implementation of IEEE or ISO rules/specifications for
14302math functions.
14303
14304The default is @option{-ftrapping-math}.
14305
14306Future versions of GCC may provide finer control of this setting
14307using C99's @code{FENV_ACCESS} pragma. This command-line option
14308will be used along with @option{-frounding-math} to specify the
14309default state for @code{FENV_ACCESS}.
14310
14311@item -frounding-math
14312@opindex frounding-math
14313Disable transformations and optimizations that assume default floating-point
14314rounding behavior. This is round-to-zero for all floating point
14315to integer conversions, and round-to-nearest for all other arithmetic
14316truncations. This option should be specified for programs that change
14317the FP rounding mode dynamically, or that may be executed with a
14318non-default rounding mode. This option disables constant folding of
14319floating-point expressions at compile time (which may be affected by
14320rounding mode) and arithmetic transformations that are unsafe in the
14321presence of sign-dependent rounding modes.
14322
14323The default is @option{-fno-rounding-math}.
14324
14325This option is experimental and does not currently guarantee to
14326disable all GCC optimizations that are affected by rounding mode.
14327Future versions of GCC may provide finer control of this setting
14328using C99's @code{FENV_ACCESS} pragma. This command-line option
14329will be used along with @option{-ftrapping-math} to specify the
14330default state for @code{FENV_ACCESS}.
14331
14332@item -fsignaling-nans
14333@opindex fsignaling-nans
14334Compile code assuming that IEEE signaling NaNs may generate user-visible
14335traps during floating-point operations. Setting this option disables
14336optimizations that may change the number of exceptions visible with
14337signaling NaNs. This option implies @option{-ftrapping-math}.
14338
14339This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14340be defined.
14341
14342The default is @option{-fno-signaling-nans}.
14343
14344This option is experimental and does not currently guarantee to
14345disable all GCC optimizations that affect signaling NaN behavior.
14346
14347@item -fno-fp-int-builtin-inexact
14348@opindex fno-fp-int-builtin-inexact
14349@opindex ffp-int-builtin-inexact
14350Do not allow the built-in functions @code{ceil}, @code{floor},
14351@code{round} and @code{trunc}, and their @code{float} and @code{long
14352double} variants, to generate code that raises the ``inexact''
14353floating-point exception for noninteger arguments. ISO C99 and C11
14354allow these functions to raise the ``inexact'' exception, but ISO/IEC
14355TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14356ISO C2X, does not allow these functions to do so.
14357
14358The default is @option{-ffp-int-builtin-inexact}, allowing the
14359exception to be raised, unless C2X or a later C standard is selected.
14360This option does nothing unless @option{-ftrapping-math} is in effect.
14361
14362Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14363generate a call to a library function then the ``inexact'' exception
14364may be raised if the library implementation does not follow TS 18661.
14365
14366@item -fsingle-precision-constant
14367@opindex fsingle-precision-constant
14368Treat floating-point constants as single precision instead of
14369implicitly converting them to double-precision constants.
14370
14371@item -fcx-limited-range
14372@opindex fcx-limited-range
14373When enabled, this option states that a range reduction step is not
14374needed when performing complex division. Also, there is no checking
14375whether the result of a complex multiplication or division is @code{NaN
14376+ I*NaN}, with an attempt to rescue the situation in that case. The
14377default is @option{-fno-cx-limited-range}, but is enabled by
14378@option{-ffast-math}.
14379
14380This option controls the default setting of the ISO C99
14381@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14382all languages.
14383
14384@item -fcx-fortran-rules
14385@opindex fcx-fortran-rules
14386Complex multiplication and division follow Fortran rules. Range
14387reduction is done as part of complex division, but there is no checking
14388whether the result of a complex multiplication or division is @code{NaN
14389+ I*NaN}, with an attempt to rescue the situation in that case.
14390
14391The default is @option{-fno-cx-fortran-rules}.
14392
14393@end table
14394
14395The following options control optimizations that may improve
14396performance, but are not enabled by any @option{-O} options. This
14397section includes experimental options that may produce broken code.
14398
14399@table @gcctabopt
14400@item -fbranch-probabilities
14401@opindex fbranch-probabilities
14402After running a program compiled with @option{-fprofile-arcs}
14403(@pxref{Instrumentation Options}),
14404you can compile it a second time using
14405@option{-fbranch-probabilities}, to improve optimizations based on
14406the number of times each branch was taken. When a program
14407compiled with @option{-fprofile-arcs} exits, it saves arc execution
14408counts to a file called @file{@var{sourcename}.gcda} for each source
14409file. The information in this data file is very dependent on the
14410structure of the generated code, so you must use the same source code
14411and the same optimization options for both compilations.
14412See details about the file naming in @option{-fprofile-arcs}.
14413
14414With @option{-fbranch-probabilities}, GCC puts a
14415@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14416These can be used to improve optimization. Currently, they are only
14417used in one place: in @file{reorg.cc}, instead of guessing which path a
14418branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14419exactly determine which path is taken more often.
14420
14421Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14422
14423@item -fprofile-values
14424@opindex fprofile-values
14425If combined with @option{-fprofile-arcs}, it adds code so that some
14426data about values of expressions in the program is gathered.
14427
14428With @option{-fbranch-probabilities}, it reads back the data gathered
14429from profiling values of expressions for usage in optimizations.
14430
14431Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14432@option{-fauto-profile}.
14433
14434@item -fprofile-reorder-functions
14435@opindex fprofile-reorder-functions
14436Function reordering based on profile instrumentation collects
14437first time of execution of a function and orders these functions
14438in ascending order.
14439
14440Enabled with @option{-fprofile-use}.
14441
14442@item -fvpt
14443@opindex fvpt
14444If combined with @option{-fprofile-arcs}, this option instructs the compiler
14445to add code to gather information about values of expressions.
14446
14447With @option{-fbranch-probabilities}, it reads back the data gathered
14448and actually performs the optimizations based on them.
14449Currently the optimizations include specialization of division operations
14450using the knowledge about the value of the denominator.
14451
14452Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14453
14454@item -frename-registers
14455@opindex frename-registers
14456Attempt to avoid false dependencies in scheduled code by making use
14457of registers left over after register allocation. This optimization
14458most benefits processors with lots of registers. Depending on the
14459debug information format adopted by the target, however, it can
14460make debugging impossible, since variables no longer stay in
14461a ``home register''.
14462
14463Enabled by default with @option{-funroll-loops}.
14464
14465@item -fschedule-fusion
14466@opindex fschedule-fusion
14467Performs a target dependent pass over the instruction stream to schedule
14468instructions of same type together because target machine can execute them
14469more efficiently if they are adjacent to each other in the instruction flow.
14470
14471Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14472
14473@item -ftracer
14474@opindex ftracer
14475Perform tail duplication to enlarge superblock size. This transformation
14476simplifies the control flow of the function allowing other optimizations to do
14477a better job.
14478
14479Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14480
14481@item -funroll-loops
14482@opindex funroll-loops
14483Unroll loops whose number of iterations can be determined at compile time or
14484upon entry to the loop. @option{-funroll-loops} implies
14485@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14486It also turns on complete loop peeling (i.e.@: complete removal of loops with
14487a small constant number of iterations). This option makes code larger, and may
14488or may not make it run faster.
14489
14490Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14491
14492@item -funroll-all-loops
14493@opindex funroll-all-loops
14494Unroll all loops, even if their number of iterations is uncertain when
14495the loop is entered. This usually makes programs run more slowly.
14496@option{-funroll-all-loops} implies the same options as
14497@option{-funroll-loops}.
14498
14499@item -fpeel-loops
14500@opindex fpeel-loops
14501Peels loops for which there is enough information that they do not
14502roll much (from profile feedback or static analysis). It also turns on
14503complete loop peeling (i.e.@: complete removal of loops with small constant
14504number of iterations).
14505
14506Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14507
14508@item -fmove-loop-invariants
14509@opindex fmove-loop-invariants
14510Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14511at level @option{-O1} and higher, except for @option{-Og}.
14512
14513@item -fmove-loop-stores
14514@opindex fmove-loop-stores
14515Enables the loop store motion pass in the GIMPLE loop optimizer. This
14516moves invariant stores to after the end of the loop in exchange for
14517carrying the stored value in a register across the iteration.
14518Note for this option to have an effect @option{-ftree-loop-im} has to
14519be enabled as well. Enabled at level @option{-O1} and higher, except
14520for @option{-Og}.
14521
14522@item -fsplit-loops
14523@opindex fsplit-loops
14524Split a loop into two if it contains a condition that's always true
14525for one side of the iteration space and false for the other.
14526
14527Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14528
14529@item -funswitch-loops
14530@opindex funswitch-loops
14531Move branches with loop invariant conditions out of the loop, with duplicates
14532of the loop on both branches (modified according to result of the condition).
14533
14534Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14535
14536@item -fversion-loops-for-strides
14537@opindex fversion-loops-for-strides
14538If a loop iterates over an array with a variable stride, create another
14539version of the loop that assumes the stride is always one. For example:
14540
14541@smallexample
14542for (int i = 0; i < n; ++i)
14543 x[i * stride] = @dots{};
14544@end smallexample
14545
14546becomes:
14547
14548@smallexample
14549if (stride == 1)
14550 for (int i = 0; i < n; ++i)
14551 x[i] = @dots{};
14552else
14553 for (int i = 0; i < n; ++i)
14554 x[i * stride] = @dots{};
14555@end smallexample
14556
14557This is particularly useful for assumed-shape arrays in Fortran where
14558(for example) it allows better vectorization assuming contiguous accesses.
14559This flag is enabled by default at @option{-O3}.
14560It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14561
14562@item -ffunction-sections
14563@itemx -fdata-sections
14564@opindex ffunction-sections
14565@opindex fdata-sections
14566Place each function or data item into its own section in the output
14567file if the target supports arbitrary sections. The name of the
14568function or the name of the data item determines the section's name
14569in the output file.
14570
14571Use these options on systems where the linker can perform optimizations to
14572improve locality of reference in the instruction space. Most systems using the
14573ELF object format have linkers with such optimizations. On AIX, the linker
14574rearranges sections (CSECTs) based on the call graph. The performance impact
14575varies.
14576
14577Together with a linker garbage collection (linker @option{--gc-sections}
14578option) these options may lead to smaller statically-linked executables (after
14579stripping).
14580
14581On ELF/DWARF systems these options do not degenerate the quality of the debug
14582information. There could be issues with other object files/debug info formats.
14583
14584Only use these options when there are significant benefits from doing so. When
14585you specify these options, the assembler and linker create larger object and
14586executable files and are also slower. These options affect code generation.
14587They prevent optimizations by the compiler and assembler using relative
14588locations inside a translation unit since the locations are unknown until
14589link time. An example of such an optimization is relaxing calls to short call
14590instructions.
14591
14592@item -fstdarg-opt
14593@opindex fstdarg-opt
14594Optimize the prologue of variadic argument functions with respect to usage of
14595those arguments.
14596
14597@item -fsection-anchors
14598@opindex fsection-anchors
14599Try to reduce the number of symbolic address calculations by using
14600shared ``anchor'' symbols to address nearby objects. This transformation
14601can help to reduce the number of GOT entries and GOT accesses on some
14602targets.
14603
14604For example, the implementation of the following function @code{foo}:
14605
14606@smallexample
14607static int a, b, c;
14608int foo (void) @{ return a + b + c; @}
14609@end smallexample
14610
14611@noindent
14612usually calculates the addresses of all three variables, but if you
14613compile it with @option{-fsection-anchors}, it accesses the variables
14614from a common anchor point instead. The effect is similar to the
14615following pseudocode (which isn't valid C):
14616
14617@smallexample
14618int foo (void)
14619@{
14620 register int *xr = &x;
14621 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14622@}
14623@end smallexample
14624
14625Not all targets support this option.
14626
14627@item -fzero-call-used-regs=@var{choice}
14628@opindex fzero-call-used-regs
14629Zero call-used registers at function return to increase program
14630security by either mitigating Return-Oriented Programming (ROP)
14631attacks or preventing information leakage through registers.
14632
14633The possible values of @var{choice} are the same as for the
14634@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
14635The default is @samp{skip}.
14636
14637You can control this behavior for a specific function by using the function
14638attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
14639
14640@item --param @var{name}=@var{value}
14641@opindex param
14642In some places, GCC uses various constants to control the amount of
14643optimization that is done. For example, GCC does not inline functions
14644that contain more than a certain number of instructions. You can
14645control some of these constants on the command line using the
14646@option{--param} option.
14647
14648The names of specific parameters, and the meaning of the values, are
14649tied to the internals of the compiler, and are subject to change
14650without notice in future releases.
14651
14652In order to get minimal, maximal and default value of a parameter,
14653one can use @option{--help=param -Q} options.
14654
14655In each case, the @var{value} is an integer. The following choices
14656of @var{name} are recognized for all targets:
14657
14658@table @gcctabopt
14659@item predictable-branch-outcome
14660When branch is predicted to be taken with probability lower than this threshold
14661(in percent), then it is considered well predictable.
14662
14663@item max-rtl-if-conversion-insns
14664RTL if-conversion tries to remove conditional branches around a block and
14665replace them with conditionally executed instructions. This parameter
14666gives the maximum number of instructions in a block which should be
14667considered for if-conversion. The compiler will
14668also use other heuristics to decide whether if-conversion is likely to be
14669profitable.
14670
14671@item max-rtl-if-conversion-predictable-cost
14672RTL if-conversion will try to remove conditional branches around a block
14673and replace them with conditionally executed instructions. These parameters
14674give the maximum permissible cost for the sequence that would be generated
14675by if-conversion depending on whether the branch is statically determined
14676to be predictable or not. The units for this parameter are the same as
14677those for the GCC internal seq_cost metric. The compiler will try to
14678provide a reasonable default for this parameter using the BRANCH_COST
14679target macro.
14680
14681@item max-crossjump-edges
14682The maximum number of incoming edges to consider for cross-jumping.
14683The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
14684the number of edges incoming to each block. Increasing values mean
14685more aggressive optimization, making the compilation time increase with
14686probably small improvement in executable size.
14687
14688@item min-crossjump-insns
14689The minimum number of instructions that must be matched at the end
14690of two blocks before cross-jumping is performed on them. This
14691value is ignored in the case where all instructions in the block being
14692cross-jumped from are matched.
14693
14694@item max-grow-copy-bb-insns
14695The maximum code size expansion factor when copying basic blocks
14696instead of jumping. The expansion is relative to a jump instruction.
14697
14698@item max-goto-duplication-insns
14699The maximum number of instructions to duplicate to a block that jumps
14700to a computed goto. To avoid @math{O(N^2)} behavior in a number of
14701passes, GCC factors computed gotos early in the compilation process,
14702and unfactors them as late as possible. Only computed jumps at the
14703end of a basic blocks with no more than max-goto-duplication-insns are
14704unfactored.
14705
14706@item max-delay-slot-insn-search
14707The maximum number of instructions to consider when looking for an
14708instruction to fill a delay slot. If more than this arbitrary number of
14709instructions are searched, the time savings from filling the delay slot
14710are minimal, so stop searching. Increasing values mean more
14711aggressive optimization, making the compilation time increase with probably
14712small improvement in execution time.
14713
14714@item max-delay-slot-live-search
14715When trying to fill delay slots, the maximum number of instructions to
14716consider when searching for a block with valid live register
14717information. Increasing this arbitrarily chosen value means more
14718aggressive optimization, increasing the compilation time. This parameter
14719should be removed when the delay slot code is rewritten to maintain the
14720control-flow graph.
14721
14722@item max-gcse-memory
14723The approximate maximum amount of memory in @code{kB} that can be allocated in
14724order to perform the global common subexpression elimination
14725optimization. If more memory than specified is required, the
14726optimization is not done.
14727
14728@item max-gcse-insertion-ratio
14729If the ratio of expression insertions to deletions is larger than this value
14730for any expression, then RTL PRE inserts or removes the expression and thus
14731leaves partially redundant computations in the instruction stream.
14732
14733@item max-pending-list-length
14734The maximum number of pending dependencies scheduling allows
14735before flushing the current state and starting over. Large functions
14736with few branches or calls can create excessively large lists which
14737needlessly consume memory and resources.
14738
14739@item max-modulo-backtrack-attempts
14740The maximum number of backtrack attempts the scheduler should make
14741when modulo scheduling a loop. Larger values can exponentially increase
14742compilation time.
14743
14744@item max-inline-functions-called-once-loop-depth
14745Maximal loop depth of a call considered by inline heuristics that tries to
14746inline all functions called once.
14747
14748@item max-inline-functions-called-once-insns
14749Maximal estimated size of functions produced while inlining functions called
14750once.
14751
14752@item max-inline-insns-single
14753Several parameters control the tree inliner used in GCC@. This number sets the
14754maximum number of instructions (counted in GCC's internal representation) in a
14755single function that the tree inliner considers for inlining. This only
14756affects functions declared inline and methods implemented in a class
14757declaration (C++).
14758
14759
14760@item max-inline-insns-auto
14761When you use @option{-finline-functions} (included in @option{-O3}),
14762a lot of functions that would otherwise not be considered for inlining
14763by the compiler are investigated. To those functions, a different
14764(more restrictive) limit compared to functions declared inline can
14765be applied (@option{--param max-inline-insns-auto}).
14766
14767@item max-inline-insns-small
14768This is bound applied to calls which are considered relevant with
14769@option{-finline-small-functions}.
14770
14771@item max-inline-insns-size
14772This is bound applied to calls which are optimized for size. Small growth
14773may be desirable to anticipate optimization oppurtunities exposed by inlining.
14774
14775@item uninlined-function-insns
14776Number of instructions accounted by inliner for function overhead such as
14777function prologue and epilogue.
14778
14779@item uninlined-function-time
14780Extra time accounted by inliner for function overhead such as time needed to
14781execute function prologue and epilogue.
14782
14783@item inline-heuristics-hint-percent
14784The scale (in percents) applied to @option{inline-insns-single},
14785@option{inline-insns-single-O2}, @option{inline-insns-auto}
14786when inline heuristics hints that inlining is
14787very profitable (will enable later optimizations).
14788
14789@item uninlined-thunk-insns
14790@item uninlined-thunk-time
14791Same as @option{--param uninlined-function-insns} and
14792@option{--param uninlined-function-time} but applied to function thunks.
14793
14794@item inline-min-speedup
14795When estimated performance improvement of caller + callee runtime exceeds this
14796threshold (in percent), the function can be inlined regardless of the limit on
14797@option{--param max-inline-insns-single} and @option{--param
14798max-inline-insns-auto}.
14799
14800@item large-function-insns
14801The limit specifying really large functions. For functions larger than this
14802limit after inlining, inlining is constrained by
14803@option{--param large-function-growth}. This parameter is useful primarily
14804to avoid extreme compilation time caused by non-linear algorithms used by the
14805back end.
14806
14807@item large-function-growth
14808Specifies maximal growth of large function caused by inlining in percents.
14809For example, parameter value 100 limits large function growth to 2.0 times
14810the original size.
14811
14812@item large-unit-insns
14813The limit specifying large translation unit. Growth caused by inlining of
14814units larger than this limit is limited by @option{--param inline-unit-growth}.
14815For small units this might be too tight.
14816For example, consider a unit consisting of function A
14817that is inline and B that just calls A three times. If B is small relative to
14818A, the growth of unit is 300\% and yet such inlining is very sane. For very
14819large units consisting of small inlineable functions, however, the overall unit
14820growth limit is needed to avoid exponential explosion of code size. Thus for
14821smaller units, the size is increased to @option{--param large-unit-insns}
14822before applying @option{--param inline-unit-growth}.
14823
14824@item lazy-modules
14825Maximum number of concurrently open C++ module files when lazy loading.
14826
14827@item inline-unit-growth
14828Specifies maximal overall growth of the compilation unit caused by inlining.
14829For example, parameter value 20 limits unit growth to 1.2 times the original
14830size. Cold functions (either marked cold via an attribute or by profile
14831feedback) are not accounted into the unit size.
14832
14833@item ipa-cp-unit-growth
14834Specifies maximal overall growth of the compilation unit caused by
14835interprocedural constant propagation. For example, parameter value 10 limits
14836unit growth to 1.1 times the original size.
14837
14838@item ipa-cp-large-unit-insns
14839The size of translation unit that IPA-CP pass considers large.
14840
14841@item large-stack-frame
14842The limit specifying large stack frames. While inlining the algorithm is trying
14843to not grow past this limit too much.
14844
14845@item large-stack-frame-growth
14846Specifies maximal growth of large stack frames caused by inlining in percents.
14847For example, parameter value 1000 limits large stack frame growth to 11 times
14848the original size.
14849
14850@item max-inline-insns-recursive
14851@itemx max-inline-insns-recursive-auto
14852Specifies the maximum number of instructions an out-of-line copy of a
14853self-recursive inline
14854function can grow into by performing recursive inlining.
14855
14856@option{--param max-inline-insns-recursive} applies to functions
14857declared inline.
14858For functions not declared inline, recursive inlining
14859happens only when @option{-finline-functions} (included in @option{-O3}) is
14860enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
14861
14862@item max-inline-recursive-depth
14863@itemx max-inline-recursive-depth-auto
14864Specifies the maximum recursion depth used for recursive inlining.
14865
14866@option{--param max-inline-recursive-depth} applies to functions
14867declared inline. For functions not declared inline, recursive inlining
14868happens only when @option{-finline-functions} (included in @option{-O3}) is
14869enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
14870
14871@item min-inline-recursive-probability
14872Recursive inlining is profitable only for function having deep recursion
14873in average and can hurt for function having little recursion depth by
14874increasing the prologue size or complexity of function body to other
14875optimizers.
14876
14877When profile feedback is available (see @option{-fprofile-generate}) the actual
14878recursion depth can be guessed from the probability that function recurses
14879via a given call expression. This parameter limits inlining only to call
14880expressions whose probability exceeds the given threshold (in percents).
14881
14882@item early-inlining-insns
14883Specify growth that the early inliner can make. In effect it increases
14884the amount of inlining for code having a large abstraction penalty.
14885
14886@item max-early-inliner-iterations
14887Limit of iterations of the early inliner. This basically bounds
14888the number of nested indirect calls the early inliner can resolve.
14889Deeper chains are still handled by late inlining.
14890
14891@item comdat-sharing-probability
14892Probability (in percent) that C++ inline function with comdat visibility
14893are shared across multiple compilation units.
14894
14895@item modref-max-bases
14896@item modref-max-refs
14897@item modref-max-accesses
14898Specifies the maximal number of base pointers, references and accesses stored
14899for a single function by mod/ref analysis.
14900
14901@item modref-max-tests
14902Specifies the maxmal number of tests alias oracle can perform to disambiguate
14903memory locations using the mod/ref information. This parameter ought to be
14904bigger than @option{--param modref-max-bases} and @option{--param
14905modref-max-refs}.
14906
14907@item modref-max-depth
14908Specifies the maximum depth of DFS walk used by modref escape analysis.
14909Setting to 0 disables the analysis completely.
14910
14911@item modref-max-escape-points
14912Specifies the maximum number of escape points tracked by modref per SSA-name.
14913
14914@item modref-max-adjustments
14915Specifies the maximum number the access range is enlarged during modref dataflow
14916analysis.
14917
14918@item profile-func-internal-id
14919A parameter to control whether to use function internal id in profile
14920database lookup. If the value is 0, the compiler uses an id that
14921is based on function assembler name and filename, which makes old profile
14922data more tolerant to source changes such as function reordering etc.
14923
14924@item min-vect-loop-bound
14925The minimum number of iterations under which loops are not vectorized
14926when @option{-ftree-vectorize} is used. The number of iterations after
14927vectorization needs to be greater than the value specified by this option
14928to allow vectorization.
14929
14930@item gcse-cost-distance-ratio
14931Scaling factor in calculation of maximum distance an expression
14932can be moved by GCSE optimizations. This is currently supported only in the
14933code hoisting pass. The bigger the ratio, the more aggressive code hoisting
14934is with simple expressions, i.e., the expressions that have cost
14935less than @option{gcse-unrestricted-cost}. Specifying 0 disables
14936hoisting of simple expressions.
14937
14938@item gcse-unrestricted-cost
14939Cost, roughly measured as the cost of a single typical machine
14940instruction, at which GCSE optimizations do not constrain
14941the distance an expression can travel. This is currently
14942supported only in the code hoisting pass. The lesser the cost,
14943the more aggressive code hoisting is. Specifying 0
14944allows all expressions to travel unrestricted distances.
14945
14946@item max-hoist-depth
14947The depth of search in the dominator tree for expressions to hoist.
14948This is used to avoid quadratic behavior in hoisting algorithm.
14949The value of 0 does not limit on the search, but may slow down compilation
14950of huge functions.
14951
14952@item max-tail-merge-comparisons
14953The maximum amount of similar bbs to compare a bb with. This is used to
14954avoid quadratic behavior in tree tail merging.
14955
14956@item max-tail-merge-iterations
14957The maximum amount of iterations of the pass over the function. This is used to
14958limit compilation time in tree tail merging.
14959
14960@item store-merging-allow-unaligned
14961Allow the store merging pass to introduce unaligned stores if it is legal to
14962do so.
14963
14964@item max-stores-to-merge
14965The maximum number of stores to attempt to merge into wider stores in the store
14966merging pass.
14967
14968@item max-store-chains-to-track
14969The maximum number of store chains to track at the same time in the attempt
14970to merge them into wider stores in the store merging pass.
14971
14972@item max-stores-to-track
14973The maximum number of stores to track at the same time in the attemt to
14974to merge them into wider stores in the store merging pass.
14975
14976@item max-unrolled-insns
14977The maximum number of instructions that a loop may have to be unrolled.
14978If a loop is unrolled, this parameter also determines how many times
14979the loop code is unrolled.
14980
14981@item max-average-unrolled-insns
14982The maximum number of instructions biased by probabilities of their execution
14983that a loop may have to be unrolled. If a loop is unrolled,
14984this parameter also determines how many times the loop code is unrolled.
14985
14986@item max-unroll-times
14987The maximum number of unrollings of a single loop.
14988
14989@item max-peeled-insns
14990The maximum number of instructions that a loop may have to be peeled.
14991If a loop is peeled, this parameter also determines how many times
14992the loop code is peeled.
14993
14994@item max-peel-times
14995The maximum number of peelings of a single loop.
14996
14997@item max-peel-branches
14998The maximum number of branches on the hot path through the peeled sequence.
14999
15000@item max-completely-peeled-insns
15001The maximum number of insns of a completely peeled loop.
15002
15003@item max-completely-peel-times
15004The maximum number of iterations of a loop to be suitable for complete peeling.
15005
15006@item max-completely-peel-loop-nest-depth
15007The maximum depth of a loop nest suitable for complete peeling.
15008
15009@item max-unswitch-insns
15010The maximum number of insns of an unswitched loop.
15011
5b50850c
RB
15012@item max-unswitch-depth
15013The maximum depth of a loop nest to be unswitched.
15014
d77de738
ML
15015@item lim-expensive
15016The minimum cost of an expensive expression in the loop invariant motion.
15017
15018@item min-loop-cond-split-prob
15019When FDO profile information is available, @option{min-loop-cond-split-prob}
15020specifies minimum threshold for probability of semi-invariant condition
15021statement to trigger loop split.
15022
15023@item iv-consider-all-candidates-bound
15024Bound on number of candidates for induction variables, below which
15025all candidates are considered for each use in induction variable
15026optimizations. If there are more candidates than this,
15027only the most relevant ones are considered to avoid quadratic time complexity.
15028
15029@item iv-max-considered-uses
15030The induction variable optimizations give up on loops that contain more
15031induction variable uses.
15032
15033@item iv-always-prune-cand-set-bound
15034If the number of candidates in the set is smaller than this value,
15035always try to remove unnecessary ivs from the set
15036when adding a new one.
15037
15038@item avg-loop-niter
15039Average number of iterations of a loop.
15040
15041@item dse-max-object-size
15042Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15043Larger values may result in larger compilation times.
15044
15045@item dse-max-alias-queries-per-store
15046Maximum number of queries into the alias oracle per store.
15047Larger values result in larger compilation times and may result in more
15048removed dead stores.
15049
15050@item scev-max-expr-size
15051Bound on size of expressions used in the scalar evolutions analyzer.
15052Large expressions slow the analyzer.
15053
15054@item scev-max-expr-complexity
15055Bound on the complexity of the expressions in the scalar evolutions analyzer.
15056Complex expressions slow the analyzer.
15057
15058@item max-tree-if-conversion-phi-args
15059Maximum number of arguments in a PHI supported by TREE if conversion
15060unless the loop is marked with simd pragma.
15061
15062@item vect-max-layout-candidates
15063The maximum number of possible vector layouts (such as permutations)
15064to consider when optimizing to-be-vectorized code.
15065
15066@item vect-max-version-for-alignment-checks
15067The maximum number of run-time checks that can be performed when
15068doing loop versioning for alignment in the vectorizer.
15069
15070@item vect-max-version-for-alias-checks
15071The maximum number of run-time checks that can be performed when
15072doing loop versioning for alias in the vectorizer.
15073
15074@item vect-max-peeling-for-alignment
15075The maximum number of loop peels to enhance access alignment
15076for vectorizer. Value -1 means no limit.
15077
15078@item max-iterations-to-track
15079The maximum number of iterations of a loop the brute-force algorithm
15080for analysis of the number of iterations of the loop tries to evaluate.
15081
15082@item hot-bb-count-fraction
15083The denominator n of fraction 1/n of the maximal execution count of a
15084basic block in the entire program that a basic block needs to at least
15085have in order to be considered hot. The default is 10000, which means
15086that a basic block is considered hot if its execution count is greater
15087than 1/10000 of the maximal execution count. 0 means that it is never
15088considered hot. Used in non-LTO mode.
15089
15090@item hot-bb-count-ws-permille
15091The number of most executed permilles, ranging from 0 to 1000, of the
15092profiled execution of the entire program to which the execution count
15093of a basic block must be part of in order to be considered hot. The
15094default is 990, which means that a basic block is considered hot if
15095its execution count contributes to the upper 990 permilles, or 99.0%,
15096of the profiled execution of the entire program. 0 means that it is
15097never considered hot. Used in LTO mode.
15098
15099@item hot-bb-frequency-fraction
15100The denominator n of fraction 1/n of the execution frequency of the
15101entry block of a function that a basic block of this function needs
15102to at least have in order to be considered hot. The default is 1000,
15103which means that a basic block is considered hot in a function if it
15104is executed more frequently than 1/1000 of the frequency of the entry
15105block of the function. 0 means that it is never considered hot.
15106
15107@item unlikely-bb-count-fraction
15108The denominator n of fraction 1/n of the number of profiled runs of
15109the entire program below which the execution count of a basic block
15110must be in order for the basic block to be considered unlikely executed.
15111The default is 20, which means that a basic block is considered unlikely
15112executed if it is executed in fewer than 1/20, or 5%, of the runs of
15113the program. 0 means that it is always considered unlikely executed.
15114
15115@item max-predicted-iterations
15116The maximum number of loop iterations we predict statically. This is useful
15117in cases where a function contains a single loop with known bound and
15118another loop with unknown bound.
15119The known number of iterations is predicted correctly, while
15120the unknown number of iterations average to roughly 10. This means that the
15121loop without bounds appears artificially cold relative to the other one.
15122
15123@item builtin-expect-probability
15124Control the probability of the expression having the specified value. This
15125parameter takes a percentage (i.e.@: 0 ... 100) as input.
15126
15127@item builtin-string-cmp-inline-length
15128The maximum length of a constant string for a builtin string cmp call
15129eligible for inlining.
15130
15131@item align-threshold
15132
15133Select fraction of the maximal frequency of executions of a basic block in
15134a function to align the basic block.
15135
15136@item align-loop-iterations
15137
15138A loop expected to iterate at least the selected number of iterations is
15139aligned.
15140
15141@item tracer-dynamic-coverage
15142@itemx tracer-dynamic-coverage-feedback
15143
15144This value is used to limit superblock formation once the given percentage of
15145executed instructions is covered. This limits unnecessary code size
15146expansion.
15147
15148The @option{tracer-dynamic-coverage-feedback} parameter
15149is used only when profile
15150feedback is available. The real profiles (as opposed to statically estimated
15151ones) are much less balanced allowing the threshold to be larger value.
15152
15153@item tracer-max-code-growth
15154Stop tail duplication once code growth has reached given percentage. This is
15155a rather artificial limit, as most of the duplicates are eliminated later in
15156cross jumping, so it may be set to much higher values than is the desired code
15157growth.
15158
15159@item tracer-min-branch-ratio
15160
15161Stop reverse growth when the reverse probability of best edge is less than this
15162threshold (in percent).
15163
15164@item tracer-min-branch-probability
15165@itemx tracer-min-branch-probability-feedback
15166
15167Stop forward growth if the best edge has probability lower than this
15168threshold.
15169
15170Similarly to @option{tracer-dynamic-coverage} two parameters are
15171provided. @option{tracer-min-branch-probability-feedback} is used for
15172compilation with profile feedback and @option{tracer-min-branch-probability}
15173compilation without. The value for compilation with profile feedback
15174needs to be more conservative (higher) in order to make tracer
15175effective.
15176
15177@item stack-clash-protection-guard-size
15178Specify the size of the operating system provided stack guard as
151792 raised to @var{num} bytes. Higher values may reduce the
15180number of explicit probes, but a value larger than the operating system
15181provided guard will leave code vulnerable to stack clash style attacks.
15182
15183@item stack-clash-protection-probe-interval
15184Stack clash protection involves probing stack space as it is allocated. This
15185param controls the maximum distance between probes into the stack as 2 raised
15186to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15187larger than the operating system provided guard will leave code vulnerable to
15188stack clash style attacks.
15189
15190@item max-cse-path-length
15191
15192The maximum number of basic blocks on path that CSE considers.
15193
15194@item max-cse-insns
15195The maximum number of instructions CSE processes before flushing.
15196
15197@item ggc-min-expand
15198
15199GCC uses a garbage collector to manage its own memory allocation. This
15200parameter specifies the minimum percentage by which the garbage
15201collector's heap should be allowed to expand between collections.
15202Tuning this may improve compilation speed; it has no effect on code
15203generation.
15204
15205The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15206RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15207the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15208GCC is not able to calculate RAM on a particular platform, the lower
15209bound of 30% is used. Setting this parameter and
15210@option{ggc-min-heapsize} to zero causes a full collection to occur at
15211every opportunity. This is extremely slow, but can be useful for
15212debugging.
15213
15214@item ggc-min-heapsize
15215
15216Minimum size of the garbage collector's heap before it begins bothering
15217to collect garbage. The first collection occurs after the heap expands
15218by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15219tuning this may improve compilation speed, and has no effect on code
15220generation.
15221
15222The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15223tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15224with a lower bound of 4096 (four megabytes) and an upper bound of
15225131072 (128 megabytes). If GCC is not able to calculate RAM on a
15226particular platform, the lower bound is used. Setting this parameter
15227very large effectively disables garbage collection. Setting this
15228parameter and @option{ggc-min-expand} to zero causes a full collection
15229to occur at every opportunity.
15230
15231@item max-reload-search-insns
15232The maximum number of instruction reload should look backward for equivalent
15233register. Increasing values mean more aggressive optimization, making the
15234compilation time increase with probably slightly better performance.
15235
15236@item max-cselib-memory-locations
15237The maximum number of memory locations cselib should take into account.
15238Increasing values mean more aggressive optimization, making the compilation time
15239increase with probably slightly better performance.
15240
15241@item max-sched-ready-insns
15242The maximum number of instructions ready to be issued the scheduler should
15243consider at any given time during the first scheduling pass. Increasing
15244values mean more thorough searches, making the compilation time increase
15245with probably little benefit.
15246
15247@item max-sched-region-blocks
15248The maximum number of blocks in a region to be considered for
15249interblock scheduling.
15250
15251@item max-pipeline-region-blocks
15252The maximum number of blocks in a region to be considered for
15253pipelining in the selective scheduler.
15254
15255@item max-sched-region-insns
15256The maximum number of insns in a region to be considered for
15257interblock scheduling.
15258
15259@item max-pipeline-region-insns
15260The maximum number of insns in a region to be considered for
15261pipelining in the selective scheduler.
15262
15263@item min-spec-prob
15264The minimum probability (in percents) of reaching a source block
15265for interblock speculative scheduling.
15266
15267@item max-sched-extend-regions-iters
15268The maximum number of iterations through CFG to extend regions.
15269A value of 0 disables region extensions.
15270
15271@item max-sched-insn-conflict-delay
15272The maximum conflict delay for an insn to be considered for speculative motion.
15273
15274@item sched-spec-prob-cutoff
15275The minimal probability of speculation success (in percents), so that
15276speculative insns are scheduled.
15277
15278@item sched-state-edge-prob-cutoff
15279The minimum probability an edge must have for the scheduler to save its
15280state across it.
15281
15282@item sched-mem-true-dep-cost
15283Minimal distance (in CPU cycles) between store and load targeting same
15284memory locations.
15285
15286@item selsched-max-lookahead
15287The maximum size of the lookahead window of selective scheduling. It is a
15288depth of search for available instructions.
15289
15290@item selsched-max-sched-times
15291The maximum number of times that an instruction is scheduled during
15292selective scheduling. This is the limit on the number of iterations
15293through which the instruction may be pipelined.
15294
15295@item selsched-insns-to-rename
15296The maximum number of best instructions in the ready list that are considered
15297for renaming in the selective scheduler.
15298
15299@item sms-min-sc
15300The minimum value of stage count that swing modulo scheduler
15301generates.
15302
15303@item max-last-value-rtl
15304The maximum size measured as number of RTLs that can be recorded in an expression
15305in combiner for a pseudo register as last known value of that register.
15306
15307@item max-combine-insns
15308The maximum number of instructions the RTL combiner tries to combine.
15309
15310@item integer-share-limit
15311Small integer constants can use a shared data structure, reducing the
15312compiler's memory usage and increasing its speed. This sets the maximum
15313value of a shared integer constant.
15314
15315@item ssp-buffer-size
15316The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15317protection when @option{-fstack-protector} is used.
15318
15319@item min-size-for-stack-sharing
15320The minimum size of variables taking part in stack slot sharing when not
15321optimizing.
15322
15323@item max-jump-thread-duplication-stmts
15324Maximum number of statements allowed in a block that needs to be
15325duplicated when threading jumps.
15326
15327@item max-jump-thread-paths
15328The maximum number of paths to consider when searching for jump threading
15329opportunities. When arriving at a block, incoming edges are only considered
15330if the number of paths to be searched so far multiplied by the number of
15331incoming edges does not exhaust the specified maximum number of paths to
15332consider.
15333
15334@item max-fields-for-field-sensitive
15335Maximum number of fields in a structure treated in
15336a field sensitive manner during pointer analysis.
15337
15338@item prefetch-latency
15339Estimate on average number of instructions that are executed before
15340prefetch finishes. The distance prefetched ahead is proportional
15341to this constant. Increasing this number may also lead to less
15342streams being prefetched (see @option{simultaneous-prefetches}).
15343
15344@item simultaneous-prefetches
15345Maximum number of prefetches that can run at the same time.
15346
15347@item l1-cache-line-size
15348The size of cache line in L1 data cache, in bytes.
15349
15350@item l1-cache-size
15351The size of L1 data cache, in kilobytes.
15352
15353@item l2-cache-size
15354The size of L2 data cache, in kilobytes.
15355
15356@item prefetch-dynamic-strides
15357Whether the loop array prefetch pass should issue software prefetch hints
15358for strides that are non-constant. In some cases this may be
15359beneficial, though the fact the stride is non-constant may make it
15360hard to predict when there is clear benefit to issuing these hints.
15361
15362Set to 1 if the prefetch hints should be issued for non-constant
15363strides. Set to 0 if prefetch hints should be issued only for strides that
15364are known to be constant and below @option{prefetch-minimum-stride}.
15365
15366@item prefetch-minimum-stride
15367Minimum constant stride, in bytes, to start using prefetch hints for. If
15368the stride is less than this threshold, prefetch hints will not be issued.
15369
15370This setting is useful for processors that have hardware prefetchers, in
15371which case there may be conflicts between the hardware prefetchers and
15372the software prefetchers. If the hardware prefetchers have a maximum
15373stride they can handle, it should be used here to improve the use of
15374software prefetchers.
15375
15376A value of -1 means we don't have a threshold and therefore
15377prefetch hints can be issued for any constant stride.
15378
15379This setting is only useful for strides that are known and constant.
15380
15381@item destructive-interference-size
15382@item constructive-interference-size
15383The values for the C++17 variables
15384@code{std::hardware_destructive_interference_size} and
15385@code{std::hardware_constructive_interference_size}. The destructive
15386interference size is the minimum recommended offset between two
15387independent concurrently-accessed objects; the constructive
15388interference size is the maximum recommended size of contiguous memory
15389accessed together. Typically both will be the size of an L1 cache
15390line for the target, in bytes. For a generic target covering a range of L1
15391cache line sizes, typically the constructive interference size will be
15392the small end of the range and the destructive size will be the large
15393end.
15394
15395The destructive interference size is intended to be used for layout,
15396and thus has ABI impact. The default value is not expected to be
15397stable, and on some targets varies with @option{-mtune}, so use of
15398this variable in a context where ABI stability is important, such as
15399the public interface of a library, is strongly discouraged; if it is
15400used in that context, users can stabilize the value using this
15401option.
15402
15403The constructive interference size is less sensitive, as it is
15404typically only used in a @samp{static_assert} to make sure that a type
15405fits within a cache line.
15406
15407See also @option{-Winterference-size}.
15408
15409@item loop-interchange-max-num-stmts
15410The maximum number of stmts in a loop to be interchanged.
15411
15412@item loop-interchange-stride-ratio
15413The minimum ratio between stride of two loops for interchange to be profitable.
15414
15415@item min-insn-to-prefetch-ratio
15416The minimum ratio between the number of instructions and the
15417number of prefetches to enable prefetching in a loop.
15418
15419@item prefetch-min-insn-to-mem-ratio
15420The minimum ratio between the number of instructions and the
15421number of memory references to enable prefetching in a loop.
15422
15423@item use-canonical-types
15424Whether the compiler should use the ``canonical'' type system.
15425Should always be 1, which uses a more efficient internal
15426mechanism for comparing types in C++ and Objective-C++. However, if
15427bugs in the canonical type system are causing compilation failures,
15428set this value to 0 to disable canonical types.
15429
15430@item switch-conversion-max-branch-ratio
15431Switch initialization conversion refuses to create arrays that are
15432bigger than @option{switch-conversion-max-branch-ratio} times the number of
15433branches in the switch.
15434
15435@item max-partial-antic-length
15436Maximum length of the partial antic set computed during the tree
15437partial redundancy elimination optimization (@option{-ftree-pre}) when
15438optimizing at @option{-O3} and above. For some sorts of source code
15439the enhanced partial redundancy elimination optimization can run away,
15440consuming all of the memory available on the host machine. This
15441parameter sets a limit on the length of the sets that are computed,
15442which prevents the runaway behavior. Setting a value of 0 for
15443this parameter allows an unlimited set length.
15444
15445@item rpo-vn-max-loop-depth
15446Maximum loop depth that is value-numbered optimistically.
15447When the limit hits the innermost
15448@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15449loop nest are value-numbered optimistically and the remaining ones not.
15450
15451@item sccvn-max-alias-queries-per-access
15452Maximum number of alias-oracle queries we perform when looking for
15453redundancies for loads and stores. If this limit is hit the search
15454is aborted and the load or store is not considered redundant. The
15455number of queries is algorithmically limited to the number of
15456stores on all paths from the load to the function entry.
15457
15458@item ira-max-loops-num
15459IRA uses regional register allocation by default. If a function
15460contains more loops than the number given by this parameter, only at most
15461the given number of the most frequently-executed loops form regions
15462for regional register allocation.
15463
15464@item ira-max-conflict-table-size
15465Although IRA uses a sophisticated algorithm to compress the conflict
15466table, the table can still require excessive amounts of memory for
15467huge functions. If the conflict table for a function could be more
15468than the size in MB given by this parameter, the register allocator
15469instead uses a faster, simpler, and lower-quality
15470algorithm that does not require building a pseudo-register conflict table.
15471
15472@item ira-loop-reserved-regs
15473IRA can be used to evaluate more accurate register pressure in loops
15474for decisions to move loop invariants (see @option{-O3}). The number
15475of available registers reserved for some other purposes is given
15476by this parameter. Default of the parameter
15477is the best found from numerous experiments.
15478
15479@item ira-consider-dup-in-all-alts
15480Make IRA to consider matching constraint (duplicated operand number)
15481heavily in all available alternatives for preferred register class.
15482If it is set as zero, it means IRA only respects the matching
15483constraint when it's in the only available alternative with an
15484appropriate register class. Otherwise, it means IRA will check all
15485available alternatives for preferred register class even if it has
15486found some choice with an appropriate register class and respect the
15487found qualified matching constraint.
15488
15489@item lra-inheritance-ebb-probability-cutoff
15490LRA tries to reuse values reloaded in registers in subsequent insns.
15491This optimization is called inheritance. EBB is used as a region to
15492do this optimization. The parameter defines a minimal fall-through
15493edge probability in percentage used to add BB to inheritance EBB in
15494LRA. The default value was chosen
15495from numerous runs of SPEC2000 on x86-64.
15496
15497@item loop-invariant-max-bbs-in-loop
15498Loop invariant motion can be very expensive, both in compilation time and
15499in amount of needed compile-time memory, with very large loops. Loops
15500with more basic blocks than this parameter won't have loop invariant
15501motion optimization performed on them.
15502
15503@item loop-max-datarefs-for-datadeps
15504Building data dependencies is expensive for very large loops. This
15505parameter limits the number of data references in loops that are
15506considered for data dependence analysis. These large loops are no
15507handled by the optimizations using loop data dependencies.
15508
15509@item max-vartrack-size
15510Sets a maximum number of hash table slots to use during variable
15511tracking dataflow analysis of any function. If this limit is exceeded
15512with variable tracking at assignments enabled, analysis for that
15513function is retried without it, after removing all debug insns from
15514the function. If the limit is exceeded even without debug insns, var
15515tracking analysis is completely disabled for the function. Setting
15516the parameter to zero makes it unlimited.
15517
15518@item max-vartrack-expr-depth
15519Sets a maximum number of recursion levels when attempting to map
15520variable names or debug temporaries to value expressions. This trades
15521compilation time for more complete debug information. If this is set too
15522low, value expressions that are available and could be represented in
15523debug information may end up not being used; setting this higher may
15524enable the compiler to find more complex debug expressions, but compile
15525time and memory use may grow.
15526
15527@item max-debug-marker-count
15528Sets a threshold on the number of debug markers (e.g.@: begin stmt
15529markers) to avoid complexity explosion at inlining or expanding to RTL.
15530If a function has more such gimple stmts than the set limit, such stmts
15531will be dropped from the inlined copy of a function, and from its RTL
15532expansion.
15533
15534@item min-nondebug-insn-uid
15535Use uids starting at this parameter for nondebug insns. The range below
15536the parameter is reserved exclusively for debug insns created by
15537@option{-fvar-tracking-assignments}, but debug insns may get
15538(non-overlapping) uids above it if the reserved range is exhausted.
15539
10478270
MJ
15540@item ipa-sra-deref-prob-threshold
15541IPA-SRA replaces a pointer which is known not be NULL with one or more
15542new parameters only when the probability (in percent, relative to
15543function entry) of it being dereferenced is higher than this parameter.
15544
d77de738
ML
15545@item ipa-sra-ptr-growth-factor
15546IPA-SRA replaces a pointer to an aggregate with one or more new
15547parameters only when their cumulative size is less or equal to
15548@option{ipa-sra-ptr-growth-factor} times the size of the original
15549pointer parameter.
15550
69363825
ML
15551@item ipa-sra-ptrwrap-growth-factor
15552Additional maximum allowed growth of total size of new parameters
15553that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
15554if it points to a local variable that the caller only writes to and
15555passes it as an argument to other functions.
69363825 15556
d77de738
ML
15557@item ipa-sra-max-replacements
15558Maximum pieces of an aggregate that IPA-SRA tracks. As a
15559consequence, it is also the maximum number of replacements of a formal
15560parameter.
15561
15562@item sra-max-scalarization-size-Ospeed
15563@itemx sra-max-scalarization-size-Osize
15564The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15565replace scalar parts of aggregates with uses of independent scalar
15566variables. These parameters control the maximum size, in storage units,
15567of aggregate which is considered for replacement when compiling for
15568speed
15569(@option{sra-max-scalarization-size-Ospeed}) or size
15570(@option{sra-max-scalarization-size-Osize}) respectively.
15571
15572@item sra-max-propagations
15573The maximum number of artificial accesses that Scalar Replacement of
15574Aggregates (SRA) will track, per one local variable, in order to
15575facilitate copy propagation.
15576
15577@item tm-max-aggregate-size
15578When making copies of thread-local variables in a transaction, this
15579parameter specifies the size in bytes after which variables are
15580saved with the logging functions as opposed to save/restore code
15581sequence pairs. This option only applies when using
15582@option{-fgnu-tm}.
15583
15584@item graphite-max-nb-scop-params
15585To avoid exponential effects in the Graphite loop transforms, the
15586number of parameters in a Static Control Part (SCoP) is bounded.
15587A value of zero can be used to lift
15588the bound. A variable whose value is unknown at compilation time and
15589defined outside a SCoP is a parameter of the SCoP.
15590
15591@item loop-block-tile-size
15592Loop blocking or strip mining transforms, enabled with
15593@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15594loop in the loop nest by a given number of iterations. The strip
15595length can be changed using the @option{loop-block-tile-size}
15596parameter.
15597
15598@item ipa-jump-function-lookups
15599Specifies number of statements visited during jump function offset discovery.
15600
15601@item ipa-cp-value-list-size
15602IPA-CP attempts to track all possible values and types passed to a function's
15603parameter in order to propagate them and perform devirtualization.
15604@option{ipa-cp-value-list-size} is the maximum number of values and types it
15605stores per one formal parameter of a function.
15606
15607@item ipa-cp-eval-threshold
15608IPA-CP calculates its own score of cloning profitability heuristics
15609and performs those cloning opportunities with scores that exceed
15610@option{ipa-cp-eval-threshold}.
15611
15612@item ipa-cp-max-recursive-depth
15613Maximum depth of recursive cloning for self-recursive function.
15614
15615@item ipa-cp-min-recursive-probability
15616Recursive cloning only when the probability of call being executed exceeds
15617the parameter.
15618
15619@item ipa-cp-profile-count-base
15620When using @option{-fprofile-use} option, IPA-CP will consider the measured
15621execution count of a call graph edge at this percentage position in their
15622histogram as the basis for its heuristics calculation.
15623
15624@item ipa-cp-recursive-freq-factor
15625The number of times interprocedural copy propagation expects recursive
15626functions to call themselves.
15627
15628@item ipa-cp-recursion-penalty
15629Percentage penalty the recursive functions will receive when they
15630are evaluated for cloning.
15631
15632@item ipa-cp-single-call-penalty
15633Percentage penalty functions containing a single call to another
15634function will receive when they are evaluated for cloning.
15635
15636@item ipa-max-agg-items
15637IPA-CP is also capable to propagate a number of scalar values passed
15638in an aggregate. @option{ipa-max-agg-items} controls the maximum
15639number of such values per one parameter.
15640
15641@item ipa-cp-loop-hint-bonus
15642When IPA-CP determines that a cloning candidate would make the number
15643of iterations of a loop known, it adds a bonus of
15644@option{ipa-cp-loop-hint-bonus} to the profitability score of
15645the candidate.
15646
15647@item ipa-max-loop-predicates
15648The maximum number of different predicates IPA will use to describe when
15649loops in a function have known properties.
15650
15651@item ipa-max-aa-steps
15652During its analysis of function bodies, IPA-CP employs alias analysis
15653in order to track values pointed to by function parameters. In order
15654not spend too much time analyzing huge functions, it gives up and
15655consider all memory clobbered after examining
15656@option{ipa-max-aa-steps} statements modifying memory.
15657
15658@item ipa-max-switch-predicate-bounds
15659Maximal number of boundary endpoints of case ranges of switch statement.
15660For switch exceeding this limit, IPA-CP will not construct cloning cost
15661predicate, which is used to estimate cloning benefit, for default case
15662of the switch statement.
15663
15664@item ipa-max-param-expr-ops
15665IPA-CP will analyze conditional statement that references some function
15666parameter to estimate benefit for cloning upon certain constant value.
15667But if number of operations in a parameter expression exceeds
15668@option{ipa-max-param-expr-ops}, the expression is treated as complicated
15669one, and is not handled by IPA analysis.
15670
15671@item lto-partitions
15672Specify desired number of partitions produced during WHOPR compilation.
15673The number of partitions should exceed the number of CPUs used for compilation.
15674
15675@item lto-min-partition
15676Size of minimal partition for WHOPR (in estimated instructions).
15677This prevents expenses of splitting very small programs into too many
15678partitions.
15679
15680@item lto-max-partition
15681Size of max partition for WHOPR (in estimated instructions).
15682to provide an upper bound for individual size of partition.
15683Meant to be used only with balanced partitioning.
15684
15685@item lto-max-streaming-parallelism
15686Maximal number of parallel processes used for LTO streaming.
15687
15688@item cxx-max-namespaces-for-diagnostic-help
15689The maximum number of namespaces to consult for suggestions when C++
15690name lookup fails for an identifier.
15691
15692@item sink-frequency-threshold
15693The maximum relative execution frequency (in percents) of the target block
15694relative to a statement's original block to allow statement sinking of a
15695statement. Larger numbers result in more aggressive statement sinking.
15696A small positive adjustment is applied for
15697statements with memory operands as those are even more profitable so sink.
15698
15699@item max-stores-to-sink
15700The maximum number of conditional store pairs that can be sunk. Set to 0
15701if either vectorization (@option{-ftree-vectorize}) or if-conversion
15702(@option{-ftree-loop-if-convert}) is disabled.
15703
15704@item case-values-threshold
15705The smallest number of different values for which it is best to use a
15706jump-table instead of a tree of conditional branches. If the value is
157070, use the default for the machine.
15708
15709@item jump-table-max-growth-ratio-for-size
15710The maximum code size growth ratio when expanding
15711into a jump table (in percent). The parameter is used when
15712optimizing for size.
15713
15714@item jump-table-max-growth-ratio-for-speed
15715The maximum code size growth ratio when expanding
15716into a jump table (in percent). The parameter is used when
15717optimizing for speed.
15718
15719@item tree-reassoc-width
15720Set the maximum number of instructions executed in parallel in
15721reassociated tree. This parameter overrides target dependent
15722heuristics used by default if has non zero value.
15723
15724@item sched-pressure-algorithm
15725Choose between the two available implementations of
15726@option{-fsched-pressure}. Algorithm 1 is the original implementation
15727and is the more likely to prevent instructions from being reordered.
15728Algorithm 2 was designed to be a compromise between the relatively
15729conservative approach taken by algorithm 1 and the rather aggressive
15730approach taken by the default scheduler. It relies more heavily on
15731having a regular register file and accurate register pressure classes.
15732See @file{haifa-sched.cc} in the GCC sources for more details.
15733
15734The default choice depends on the target.
15735
15736@item max-slsr-cand-scan
15737Set the maximum number of existing candidates that are considered when
15738seeking a basis for a new straight-line strength reduction candidate.
15739
15740@item asan-globals
15741Enable buffer overflow detection for global objects. This kind
15742of protection is enabled by default if you are using
15743@option{-fsanitize=address} option.
15744To disable global objects protection use @option{--param asan-globals=0}.
15745
15746@item asan-stack
15747Enable buffer overflow detection for stack objects. This kind of
15748protection is enabled by default when using @option{-fsanitize=address}.
15749To disable stack protection use @option{--param asan-stack=0} option.
15750
15751@item asan-instrument-reads
15752Enable buffer overflow detection for memory reads. This kind of
15753protection is enabled by default when using @option{-fsanitize=address}.
15754To disable memory reads protection use
15755@option{--param asan-instrument-reads=0}.
15756
15757@item asan-instrument-writes
15758Enable buffer overflow detection for memory writes. This kind of
15759protection is enabled by default when using @option{-fsanitize=address}.
15760To disable memory writes protection use
15761@option{--param asan-instrument-writes=0} option.
15762
15763@item asan-memintrin
15764Enable detection for built-in functions. This kind of protection
15765is enabled by default when using @option{-fsanitize=address}.
15766To disable built-in functions protection use
15767@option{--param asan-memintrin=0}.
15768
15769@item asan-use-after-return
15770Enable detection of use-after-return. This kind of protection
15771is enabled by default when using the @option{-fsanitize=address} option.
15772To disable it use @option{--param asan-use-after-return=0}.
15773
15774Note: By default the check is disabled at run time. To enable it,
15775add @code{detect_stack_use_after_return=1} to the environment variable
15776@env{ASAN_OPTIONS}.
15777
15778@item asan-instrumentation-with-call-threshold
15779If number of memory accesses in function being instrumented
15780is greater or equal to this number, use callbacks instead of inline checks.
15781E.g. to disable inline code use
15782@option{--param asan-instrumentation-with-call-threshold=0}.
15783
15784@item hwasan-instrument-stack
15785Enable hwasan instrumentation of statically sized stack-allocated variables.
15786This kind of instrumentation is enabled by default when using
15787@option{-fsanitize=hwaddress} and disabled by default when using
15788@option{-fsanitize=kernel-hwaddress}.
15789To disable stack instrumentation use
15790@option{--param hwasan-instrument-stack=0}, and to enable it use
15791@option{--param hwasan-instrument-stack=1}.
15792
15793@item hwasan-random-frame-tag
15794When using stack instrumentation, decide tags for stack variables using a
15795deterministic sequence beginning at a random tag for each frame. With this
15796parameter unset tags are chosen using the same sequence but beginning from 1.
15797This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
15798for @option{-fsanitize=kernel-hwaddress}.
15799To disable it use @option{--param hwasan-random-frame-tag=0}.
15800
15801@item hwasan-instrument-allocas
15802Enable hwasan instrumentation of dynamically sized stack-allocated variables.
15803This kind of instrumentation is enabled by default when using
15804@option{-fsanitize=hwaddress} and disabled by default when using
15805@option{-fsanitize=kernel-hwaddress}.
15806To disable instrumentation of such variables use
15807@option{--param hwasan-instrument-allocas=0}, and to enable it use
15808@option{--param hwasan-instrument-allocas=1}.
15809
15810@item hwasan-instrument-reads
15811Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
15812default for both @option{-fsanitize=hwaddress} and
15813@option{-fsanitize=kernel-hwaddress}.
15814To disable checking memory reads use
15815@option{--param hwasan-instrument-reads=0}.
15816
15817@item hwasan-instrument-writes
15818Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
15819default for both @option{-fsanitize=hwaddress} and
15820@option{-fsanitize=kernel-hwaddress}.
15821To disable checking memory writes use
15822@option{--param hwasan-instrument-writes=0}.
15823
15824@item hwasan-instrument-mem-intrinsics
15825Enable hwasan instrumentation of builtin functions. Instrumentation of these
15826builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
15827and @option{-fsanitize=kernel-hwaddress}.
15828To disable instrumentation of builtin functions use
15829@option{--param hwasan-instrument-mem-intrinsics=0}.
15830
15831@item use-after-scope-direct-emission-threshold
15832If the size of a local variable in bytes is smaller or equal to this
15833number, directly poison (or unpoison) shadow memory instead of using
15834run-time callbacks.
15835
15836@item tsan-distinguish-volatile
15837Emit special instrumentation for accesses to volatiles.
15838
15839@item tsan-instrument-func-entry-exit
15840Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
15841
15842@item max-fsm-thread-path-insns
15843Maximum number of instructions to copy when duplicating blocks on a
15844finite state automaton jump thread path.
15845
15846@item threader-debug
15847threader-debug=[none|all] Enables verbose dumping of the threader solver.
15848
15849@item parloops-chunk-size
15850Chunk size of omp schedule for loops parallelized by parloops.
15851
15852@item parloops-schedule
15853Schedule type of omp schedule for loops parallelized by parloops (static,
15854dynamic, guided, auto, runtime).
15855
15856@item parloops-min-per-thread
15857The minimum number of iterations per thread of an innermost parallelized
15858loop for which the parallelized variant is preferred over the single threaded
15859one. Note that for a parallelized loop nest the
15860minimum number of iterations of the outermost loop per thread is two.
15861
15862@item max-ssa-name-query-depth
15863Maximum depth of recursion when querying properties of SSA names in things
15864like fold routines. One level of recursion corresponds to following a
15865use-def chain.
15866
15867@item max-speculative-devirt-maydefs
15868The maximum number of may-defs we analyze when looking for a must-def
15869specifying the dynamic type of an object that invokes a virtual call
15870we may be able to devirtualize speculatively.
15871
d77de738
ML
15872@item evrp-sparse-threshold
15873Maximum number of basic blocks before EVRP uses a sparse cache.
15874
d77de738
ML
15875@item ranger-debug
15876Specifies the type of debug output to be issued for ranges.
15877
15878@item evrp-switch-limit
15879Specifies the maximum number of switch cases before EVRP ignores a switch.
15880
15881@item unroll-jam-min-percent
15882The minimum percentage of memory references that must be optimized
15883away for the unroll-and-jam transformation to be considered profitable.
15884
15885@item unroll-jam-max-unroll
15886The maximum number of times the outer loop should be unrolled by
15887the unroll-and-jam transformation.
15888
15889@item max-rtl-if-conversion-unpredictable-cost
15890Maximum permissible cost for the sequence that would be generated
15891by the RTL if-conversion pass for a branch that is considered unpredictable.
15892
15893@item max-variable-expansions-in-unroller
15894If @option{-fvariable-expansion-in-unroller} is used, the maximum number
15895of times that an individual variable will be expanded during loop unrolling.
15896
15897@item partial-inlining-entry-probability
15898Maximum probability of the entry BB of split region
15899(in percent relative to entry BB of the function)
15900to make partial inlining happen.
15901
15902@item max-tracked-strlens
15903Maximum number of strings for which strlen optimization pass will
15904track string lengths.
15905
15906@item gcse-after-reload-partial-fraction
15907The threshold ratio for performing partial redundancy
15908elimination after reload.
15909
15910@item gcse-after-reload-critical-fraction
15911The threshold ratio of critical edges execution count that
15912permit performing redundancy elimination after reload.
15913
15914@item max-loop-header-insns
15915The maximum number of insns in loop header duplicated
15916by the copy loop headers pass.
15917
15918@item vect-epilogues-nomask
15919Enable loop epilogue vectorization using smaller vector size.
15920
15921@item vect-partial-vector-usage
15922Controls when the loop vectorizer considers using partial vector loads
15923and stores as an alternative to falling back to scalar code. 0 stops
15924the vectorizer from ever using partial vector loads and stores. 1 allows
15925partial vector loads and stores if vectorization removes the need for the
15926code to iterate. 2 allows partial vector loads and stores in all loops.
15927The parameter only has an effect on targets that support partial
15928vector loads and stores.
15929
15930@item vect-inner-loop-cost-factor
15931The maximum factor which the loop vectorizer applies to the cost of statements
15932in an inner loop relative to the loop being vectorized. The factor applied
15933is the maximum of the estimated number of iterations of the inner loop and
15934this parameter. The default value of this parameter is 50.
15935
15936@item vect-induction-float
15937Enable loop vectorization of floating point inductions.
15938
15939@item avoid-fma-max-bits
15940Maximum number of bits for which we avoid creating FMAs.
15941
15942@item sms-loop-average-count-threshold
15943A threshold on the average loop count considered by the swing modulo scheduler.
15944
15945@item sms-dfa-history
15946The number of cycles the swing modulo scheduler considers when checking
15947conflicts using DFA.
15948
15949@item graphite-allow-codegen-errors
15950Whether codegen errors should be ICEs when @option{-fchecking}.
15951
15952@item sms-max-ii-factor
15953A factor for tuning the upper bound that swing modulo scheduler
15954uses for scheduling a loop.
15955
15956@item lra-max-considered-reload-pseudos
15957The max number of reload pseudos which are considered during
15958spilling a non-reload pseudo.
15959
15960@item max-pow-sqrt-depth
15961Maximum depth of sqrt chains to use when synthesizing exponentiation
15962by a real constant.
15963
15964@item max-dse-active-local-stores
15965Maximum number of active local stores in RTL dead store elimination.
15966
15967@item asan-instrument-allocas
15968Enable asan allocas/VLAs protection.
15969
15970@item max-iterations-computation-cost
15971Bound on the cost of an expression to compute the number of iterations.
15972
15973@item max-isl-operations
15974Maximum number of isl operations, 0 means unlimited.
15975
15976@item graphite-max-arrays-per-scop
15977Maximum number of arrays per scop.
15978
15979@item max-vartrack-reverse-op-size
15980Max. size of loc list for which reverse ops should be added.
15981
15982@item fsm-scale-path-stmts
15983Scale factor to apply to the number of statements in a threading path
15984when comparing to the number of (scaled) blocks.
15985
15986@item uninit-control-dep-attempts
15987Maximum number of nested calls to search for control dependencies
15988during uninitialized variable analysis.
15989
15990@item fsm-scale-path-blocks
15991Scale factor to apply to the number of blocks in a threading path
15992when comparing to the number of (scaled) statements.
15993
15994@item sched-autopref-queue-depth
15995Hardware autoprefetcher scheduler model control flag.
15996Number of lookahead cycles the model looks into; at '
15997' only enable instruction sorting heuristic.
15998
15999@item loop-versioning-max-inner-insns
16000The maximum number of instructions that an inner loop can have
16001before the loop versioning pass considers it too big to copy.
16002
16003@item loop-versioning-max-outer-insns
16004The maximum number of instructions that an outer loop can have
16005before the loop versioning pass considers it too big to copy,
16006discounting any instructions in inner loops that directly benefit
16007from versioning.
16008
16009@item ssa-name-def-chain-limit
16010The maximum number of SSA_NAME assignments to follow in determining
16011a property of a variable such as its value. This limits the number
16012of iterations or recursive calls GCC performs when optimizing certain
16013statements or when determining their validity prior to issuing
16014diagnostics.
16015
16016@item store-merging-max-size
16017Maximum size of a single store merging region in bytes.
16018
16019@item hash-table-verification-limit
16020The number of elements for which hash table verification is done
16021for each searched element.
16022
16023@item max-find-base-term-values
16024Maximum number of VALUEs handled during a single find_base_term call.
16025
16026@item analyzer-max-enodes-per-program-point
16027The maximum number of exploded nodes per program point within
16028the analyzer, before terminating analysis of that point.
16029
16030@item analyzer-max-constraints
16031The maximum number of constraints per state.
16032
16033@item analyzer-min-snodes-for-call-summary
16034The minimum number of supernodes within a function for the
16035analyzer to consider summarizing its effects at call sites.
16036
16037@item analyzer-max-enodes-for-full-dump
16038The maximum depth of exploded nodes that should appear in a dot dump
16039before switching to a less verbose format.
16040
16041@item analyzer-max-recursion-depth
16042The maximum number of times a callsite can appear in a call stack
16043within the analyzer, before terminating analysis of a call that would
16044recurse deeper.
16045
16046@item analyzer-max-svalue-depth
16047The maximum depth of a symbolic value, before approximating
16048the value as unknown.
16049
16050@item analyzer-max-infeasible-edges
16051The maximum number of infeasible edges to reject before declaring
16052a diagnostic as infeasible.
16053
16054@item gimple-fe-computed-hot-bb-threshold
16055The number of executions of a basic block which is considered hot.
16056The parameter is used only in GIMPLE FE.
16057
16058@item analyzer-bb-explosion-factor
16059The maximum number of 'after supernode' exploded nodes within the analyzer
16060per supernode, before terminating analysis.
16061
16062@item ranger-logical-depth
16063Maximum depth of logical expression evaluation ranger will look through
16064when evaluating outgoing edge ranges.
16065
16066@item relation-block-limit
16067Maximum number of relations the oracle will register in a basic block.
16068
16069@item min-pagesize
16070Minimum page size for warning purposes.
16071
16072@item openacc-kernels
16073Specify mode of OpenACC `kernels' constructs handling.
16074With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16075constructs are decomposed into parts, a sequence of compute
16076constructs, each then handled individually.
16077This is work in progress.
16078With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16079constructs are handled by the @samp{parloops} pass, en bloc.
16080This is the current default.
16081
16082@item openacc-privatization
16083Specify mode of OpenACC privatization diagnostics for
16084@option{-fopt-info-omp-note} and applicable
16085@option{-fdump-tree-*-details}.
16086With @option{--param=openacc-privatization=quiet}, don't diagnose.
16087This is the current default.
16088With @option{--param=openacc-privatization=noisy}, do diagnose.
16089
16090@end table
16091
16092The following choices of @var{name} are available on AArch64 targets:
16093
16094@table @gcctabopt
16095@item aarch64-sve-compare-costs
16096When vectorizing for SVE, consider using ``unpacked'' vectors for
16097smaller elements and use the cost model to pick the cheapest approach.
16098Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16099
16100Using unpacked vectors includes storing smaller elements in larger
16101containers and accessing elements with extending loads and truncating
16102stores.
16103
16104@item aarch64-float-recp-precision
16105The number of Newton iterations for calculating the reciprocal for float type.
16106The precision of division is proportional to this param when division
16107approximation is enabled. The default value is 1.
16108
16109@item aarch64-double-recp-precision
16110The number of Newton iterations for calculating the reciprocal for double type.
16111The precision of division is propotional to this param when division
16112approximation is enabled. The default value is 2.
16113
16114@item aarch64-autovec-preference
16115Force an ISA selection strategy for auto-vectorization. Accepts values from
161160 to 4, inclusive.
16117@table @samp
16118@item 0
16119Use the default heuristics.
16120@item 1
16121Use only Advanced SIMD for auto-vectorization.
16122@item 2
16123Use only SVE for auto-vectorization.
16124@item 3
16125Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16126deemed equal.
16127@item 4
16128Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16129@end table
16130The default value is 0.
16131
16132@item aarch64-loop-vect-issue-rate-niters
16133The tuning for some AArch64 CPUs tries to take both latencies and issue
16134rates into account when deciding whether a loop should be vectorized
16135using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16136If this parameter is set to @var{n}, GCC will not use this heuristic
16137for loops that are known to execute in fewer than @var{n} Advanced
16138SIMD iterations.
16139
16140@item aarch64-vect-unroll-limit
16141The vectorizer will use available tuning information to determine whether it
16142would be beneficial to unroll the main vectorized loop and by how much. This
16143parameter set's the upper bound of how much the vectorizer will unroll the main
16144loop. The default value is four.
16145
16146@end table
16147
16148The following choices of @var{name} are available on i386 and x86_64 targets:
16149
16150@table @gcctabopt
16151@item x86-stlf-window-ninsns
16152Instructions number above which STFL stall penalty can be compensated.
16153
16154@end table
16155
16156@end table
16157
16158@node Instrumentation Options
16159@section Program Instrumentation Options
16160@cindex instrumentation options
16161@cindex program instrumentation options
16162@cindex run-time error checking options
16163@cindex profiling options
16164@cindex options, program instrumentation
16165@cindex options, run-time error checking
16166@cindex options, profiling
16167
16168GCC supports a number of command-line options that control adding
16169run-time instrumentation to the code it normally generates.
16170For example, one purpose of instrumentation is collect profiling
16171statistics for use in finding program hot spots, code coverage
16172analysis, or profile-guided optimizations.
16173Another class of program instrumentation is adding run-time checking
16174to detect programming errors like invalid pointer
16175dereferences or out-of-bounds array accesses, as well as deliberately
16176hostile attacks such as stack smashing or C++ vtable hijacking.
16177There is also a general hook which can be used to implement other
16178forms of tracing or function-level instrumentation for debug or
16179program analysis purposes.
16180
16181@table @gcctabopt
16182@cindex @command{prof}
16183@cindex @command{gprof}
16184@item -p
16185@itemx -pg
16186@opindex p
16187@opindex pg
16188Generate extra code to write profile information suitable for the
16189analysis program @command{prof} (for @option{-p}) or @command{gprof}
16190(for @option{-pg}). You must use this option when compiling
16191the source files you want data about, and you must also use it when
16192linking.
16193
16194You can use the function attribute @code{no_instrument_function} to
16195suppress profiling of individual functions when compiling with these options.
16196@xref{Common Function Attributes}.
16197
16198@item -fprofile-arcs
16199@opindex fprofile-arcs
16200Add code so that program flow @dfn{arcs} are instrumented. During
16201execution the program records how many times each branch and call is
16202executed and how many times it is taken or returns. On targets that support
16203constructors with priority support, profiling properly handles constructors,
16204destructors and C++ constructors (and destructors) of classes which are used
16205as a type of a global variable.
16206
16207When the compiled
16208program exits it saves this data to a file called
16209@file{@var{auxname}.gcda} for each source file. The data may be used for
16210profile-directed optimizations (@option{-fbranch-probabilities}), or for
16211test coverage analysis (@option{-ftest-coverage}). Each object file's
16212@var{auxname} is generated from the name of the output file, if
16213explicitly specified and it is not the final executable, otherwise it is
16214the basename of the source file. In both cases any suffix is removed
16215(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16216@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16217
16218Note that if a command line directly links source files, the corresponding
16219@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16220E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16221@file{binary-b.gcda} files.
16222
16223@xref{Cross-profiling}.
16224
16225@cindex @command{gcov}
16226@item --coverage
16227@opindex coverage
16228
16229This option is used to compile and link code instrumented for coverage
16230analysis. The option is a synonym for @option{-fprofile-arcs}
16231@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16232linking). See the documentation for those options for more details.
16233
16234@itemize
16235
16236@item
16237Compile the source files with @option{-fprofile-arcs} plus optimization
16238and code generation options. For test coverage analysis, use the
16239additional @option{-ftest-coverage} option. You do not need to profile
16240every source file in a program.
16241
16242@item
16243Compile the source files additionally with @option{-fprofile-abs-path}
16244to create absolute path names in the @file{.gcno} files. This allows
16245@command{gcov} to find the correct sources in projects where compilations
16246occur with different working directories.
16247
16248@item
16249Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16250(the latter implies the former).
16251
16252@item
16253Run the program on a representative workload to generate the arc profile
16254information. This may be repeated any number of times. You can run
16255concurrent instances of your program, and provided that the file system
16256supports locking, the data files will be correctly updated. Unless
16257a strict ISO C dialect option is in effect, @code{fork} calls are
16258detected and correctly handled without double counting.
16259
16260Moreover, an object file can be recompiled multiple times
16261and the corresponding @file{.gcda} file merges as long as
16262the source file and the compiler options are unchanged.
16263
16264@item
16265For profile-directed optimizations, compile the source files again with
16266the same optimization and code generation options plus
16267@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16268Control Optimization}).
16269
16270@item
16271For test coverage analysis, use @command{gcov} to produce human readable
16272information from the @file{.gcno} and @file{.gcda} files. Refer to the
16273@command{gcov} documentation for further information.
16274
16275@end itemize
16276
16277With @option{-fprofile-arcs}, for each function of your program GCC
16278creates a program flow graph, then finds a spanning tree for the graph.
16279Only arcs that are not on the spanning tree have to be instrumented: the
16280compiler adds code to count the number of times that these arcs are
16281executed. When an arc is the only exit or only entrance to a block, the
16282instrumentation code can be added to the block; otherwise, a new basic
16283block must be created to hold the instrumentation code.
16284
16285@need 2000
16286@item -ftest-coverage
16287@opindex ftest-coverage
16288Produce a notes file that the @command{gcov} code-coverage utility
16289(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16290show program coverage. Each source file's note file is called
16291@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16292above for a description of @var{auxname} and instructions on how to
16293generate test coverage data. Coverage data matches the source files
16294more closely if you do not optimize.
16295
16296@item -fprofile-abs-path
16297@opindex fprofile-abs-path
16298Automatically convert relative source file names to absolute path names
16299in the @file{.gcno} files. This allows @command{gcov} to find the correct
16300sources in projects where compilations occur with different working
16301directories.
16302
16303@item -fprofile-dir=@var{path}
16304@opindex fprofile-dir
16305
16306Set the directory to search for the profile data files in to @var{path}.
16307This option affects only the profile data generated by
16308@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16309and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16310and its related options. Both absolute and relative paths can be used.
16311By default, GCC uses the current directory as @var{path}, thus the
16312profile data file appears in the same directory as the object file.
16313In order to prevent the file name clashing, if the object file name is
16314not an absolute path, we mangle the absolute path of the
16315@file{@var{sourcename}.gcda} file and use it as the file name of a
16316@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16317See similar option @option{-fprofile-note}.
16318
16319When an executable is run in a massive parallel environment, it is recommended
16320to save profile to different folders. That can be done with variables
16321in @var{path} that are exported during run-time:
16322
16323@table @gcctabopt
16324
16325@item %p
16326process ID.
16327
16328@item %q@{VAR@}
16329value of environment variable @var{VAR}
16330
16331@end table
16332
16333@item -fprofile-generate
16334@itemx -fprofile-generate=@var{path}
16335@opindex fprofile-generate
16336
16337Enable options usually used for instrumenting application to produce
16338profile useful for later recompilation with profile feedback based
16339optimization. You must use @option{-fprofile-generate} both when
16340compiling and when linking your program.
16341
16342The following options are enabled:
16343@option{-fprofile-arcs}, @option{-fprofile-values},
16344@option{-finline-functions}, and @option{-fipa-bit-cp}.
16345
16346If @var{path} is specified, GCC looks at the @var{path} to find
16347the profile feedback data files. See @option{-fprofile-dir}.
16348
16349To optimize the program based on the collected profile information, use
16350@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16351
16352@item -fprofile-info-section
16353@itemx -fprofile-info-section=@var{name}
16354@opindex fprofile-info-section
16355
16356Register the profile information in the specified section instead of using a
16357constructor/destructor. The section name is @var{name} if it is specified,
16358otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16359profile information generated by @option{-fprofile-arcs} is placed in the
16360specified section for each translation unit. This option disables the profile
16361information registration through a constructor and it disables the profile
16362information processing through a destructor. This option is not intended to be
16363used in hosted environments such as GNU/Linux. It targets freestanding
16364environments (for example embedded systems) with limited resources which do not
16365support constructors/destructors or the C library file I/O.
16366
16367The linker could collect the input sections in a continuous memory block and
16368define start and end symbols. A GNU linker script example which defines a
16369linker output section follows:
16370
16371@smallexample
16372 .gcov_info :
16373 @{
16374 PROVIDE (__gcov_info_start = .);
16375 KEEP (*(.gcov_info))
16376 PROVIDE (__gcov_info_end = .);
16377 @}
16378@end smallexample
16379
16380The program could dump the profiling information registered in this linker set
16381for example like this:
16382
16383@smallexample
16384#include <gcov.h>
16385#include <stdio.h>
16386#include <stdlib.h>
16387
16388extern const struct gcov_info *const __gcov_info_start[];
16389extern const struct gcov_info *const __gcov_info_end[];
16390
16391static void
16392dump (const void *d, unsigned n, void *arg)
16393@{
16394 const unsigned char *c = d;
16395
16396 for (unsigned i = 0; i < n; ++i)
16397 printf ("%02x", c[i]);
16398@}
16399
16400static void
16401filename (const char *f, void *arg)
16402@{
16403 __gcov_filename_to_gcfn (f, dump, arg );
16404@}
16405
16406static void *
16407allocate (unsigned length, void *arg)
16408@{
16409 return malloc (length);
16410@}
16411
16412static void
16413dump_gcov_info (void)
16414@{
16415 const struct gcov_info *const *info = __gcov_info_start;
16416 const struct gcov_info *const *end = __gcov_info_end;
16417
16418 /* Obfuscate variable to prevent compiler optimizations. */
16419 __asm__ ("" : "+r" (info));
16420
16421 while (info != end)
16422 @{
16423 void *arg = NULL;
16424 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16425 putchar ('\n');
16426 ++info;
16427 @}
16428@}
16429
16430int
16431main (void)
16432@{
16433 dump_gcov_info ();
16434 return 0;
16435@}
16436@end smallexample
16437
16438The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16439deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16440@code{__gcov_info_to_gcda} functions and merge the profile information into
16441@file{.gcda} files on the host filesystem.
16442
16443@item -fprofile-note=@var{path}
16444@opindex fprofile-note
16445
16446If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16447location. If you combine the option with multiple source files,
16448the @file{.gcno} file will be overwritten.
16449
16450@item -fprofile-prefix-path=@var{path}
16451@opindex fprofile-prefix-path
16452
16453This option can be used in combination with
16454@option{profile-generate=}@var{profile_dir} and
16455@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16456directory of built source tree. By default @var{profile_dir} will contain
16457files with mangled absolute paths of all object files in the built project.
16458This is not desirable when directory used to build the instrumented binary
16459differs from the directory used to build the binary optimized with profile
16460feedback because the profile data will not be found during the optimized build.
16461In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16462pointing to the base directory of the build can be used to strip the irrelevant
16463part of the path and keep all file names relative to the main build directory.
16464
16465@item -fprofile-prefix-map=@var{old}=@var{new}
16466@opindex fprofile-prefix-map
16467When compiling files residing in directory @file{@var{old}}, record
16468profiling information (with @option{--coverage})
16469describing them as if the files resided in
16470directory @file{@var{new}} instead.
16471See also @option{-ffile-prefix-map}.
16472
16473@item -fprofile-update=@var{method}
16474@opindex fprofile-update
16475
16476Alter the update method for an application instrumented for profile
16477feedback based optimization. The @var{method} argument should be one of
16478@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16479The first one is useful for single-threaded applications,
16480while the second one prevents profile corruption by emitting thread-safe code.
16481
16482@strong{Warning:} When an application does not properly join all threads
16483(or creates an detached thread), a profile file can be still corrupted.
16484
16485Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16486when supported by a target, or to @samp{single} otherwise. The GCC driver
16487automatically selects @samp{prefer-atomic} when @option{-pthread}
16488is present in the command line.
16489
16490@item -fprofile-filter-files=@var{regex}
16491@opindex fprofile-filter-files
16492
16493Instrument only functions from files whose name matches
16494any of the regular expressions (separated by semi-colons).
16495
16496For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16497only @file{main.c} and all C files starting with 'module'.
16498
16499@item -fprofile-exclude-files=@var{regex}
16500@opindex fprofile-exclude-files
16501
16502Instrument only functions from files whose name does not match
16503any of the regular expressions (separated by semi-colons).
16504
16505For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16506of all files that are located in the @file{/usr/} folder.
16507
16508@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
16509@opindex fprofile-reproducible
16510Control level of reproducibility of profile gathered by
16511@code{-fprofile-generate}. This makes it possible to rebuild program
16512with same outcome which is useful, for example, for distribution
16513packages.
16514
16515With @option{-fprofile-reproducible=serial} the profile gathered by
16516@option{-fprofile-generate} is reproducible provided the trained program
16517behaves the same at each invocation of the train run, it is not
16518multi-threaded and profile data streaming is always done in the same
16519order. Note that profile streaming happens at the end of program run but
16520also before @code{fork} function is invoked.
16521
16522Note that it is quite common that execution counts of some part of
16523programs depends, for example, on length of temporary file names or
16524memory space randomization (that may affect hash-table collision rate).
16525Such non-reproducible part of programs may be annotated by
16526@code{no_instrument_function} function attribute. @command{gcov-dump} with
16527@option{-l} can be used to dump gathered data and verify that they are
16528indeed reproducible.
16529
16530With @option{-fprofile-reproducible=parallel-runs} collected profile
16531stays reproducible regardless the order of streaming of the data into
16532gcda files. This setting makes it possible to run multiple instances of
16533instrumented program in parallel (such as with @code{make -j}). This
16534reduces quality of gathered data, in particular of indirect call
16535profiling.
16536
16537@item -fsanitize=address
16538@opindex fsanitize=address
16539Enable AddressSanitizer, a fast memory error detector.
16540Memory access instructions are instrumented to detect
16541out-of-bounds and use-after-free bugs.
16542The option enables @option{-fsanitize-address-use-after-scope}.
16543See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16544more details. The run-time behavior can be influenced using the
16545@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16546the available options are shown at startup of the instrumented program. See
16547@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16548for a list of supported options.
16549The option cannot be combined with @option{-fsanitize=thread} or
16550@option{-fsanitize=hwaddress}. Note that the only target
16551@option{-fsanitize=hwaddress} is currently supported on is AArch64.
16552
6a07798c
MP
16553To get more accurate stack traces, it is possible to use options such as
16554@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
16555most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
16556optimizing sibling and tail recursive calls; this option is implicit for
16557@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
16558disables Identical Code Folding for functions). Since multiple runs of the
16559program may yield backtraces with different addresses due to ASLR (Address
16560Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
16561this can be achieved with @samp{setarch `uname -m` -R ./prog}.
16562
d77de738
ML
16563@item -fsanitize=kernel-address
16564@opindex fsanitize=kernel-address
16565Enable AddressSanitizer for Linux kernel.
16566See @uref{https://github.com/google/kasan} for more details.
16567
16568@item -fsanitize=hwaddress
16569@opindex fsanitize=hwaddress
16570Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16571ignore the top byte of a pointer to allow the detection of memory errors with
16572a low memory overhead.
16573Memory access instructions are instrumented to detect out-of-bounds and
16574use-after-free bugs.
16575The option enables @option{-fsanitize-address-use-after-scope}.
16576See
16577@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
16578for more details. The run-time behavior can be influenced using the
16579@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
16580the available options are shown at startup of the instrumented program.
16581The option cannot be combined with @option{-fsanitize=thread} or
16582@option{-fsanitize=address}, and is currently only available on AArch64.
16583
16584@item -fsanitize=kernel-hwaddress
16585@opindex fsanitize=kernel-hwaddress
16586Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
16587Similar to @option{-fsanitize=kernel-address} but using an alternate
16588instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
16589instrumentation differences necessary for compiling the Linux kernel.
16590These differences are to avoid hwasan library initialization calls and to
16591account for the stack pointer having a different value in its top byte.
16592
16593@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
16594Instrumenting the stack and alloca calls are not on by default but are still
16595possible by specifying the command-line options
16596@option{--param hwasan-instrument-stack=1} and
16597@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
16598tag is not implemented for kernel instrumentation.
16599
16600@item -fsanitize=pointer-compare
16601@opindex fsanitize=pointer-compare
16602Instrument comparison operation (<, <=, >, >=) with pointer operands.
16603The option must be combined with either @option{-fsanitize=kernel-address} or
16604@option{-fsanitize=address}
16605The option cannot be combined with @option{-fsanitize=thread}.
16606Note: By default the check is disabled at run time. To enable it,
16607add @code{detect_invalid_pointer_pairs=2} to the environment variable
16608@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16609invalid operation only when both pointers are non-null.
16610
16611@item -fsanitize=pointer-subtract
16612@opindex fsanitize=pointer-subtract
16613Instrument subtraction with pointer operands.
16614The option must be combined with either @option{-fsanitize=kernel-address} or
16615@option{-fsanitize=address}
16616The option cannot be combined with @option{-fsanitize=thread}.
16617Note: By default the check is disabled at run time. To enable it,
16618add @code{detect_invalid_pointer_pairs=2} to the environment variable
16619@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16620invalid operation only when both pointers are non-null.
16621
16622@item -fsanitize=shadow-call-stack
16623@opindex fsanitize=shadow-call-stack
16624Enable ShadowCallStack, a security enhancement mechanism used to protect
16625programs against return address overwrites (e.g. stack buffer overflows.)
16626It works by saving a function's return address to a separately allocated
16627shadow call stack in the function prologue and restoring the return address
16628from the shadow call stack in the function epilogue. Instrumentation only
16629occurs in functions that need to save the return address to the stack.
16630
16631Currently it only supports the aarch64 platform. It is specifically
16632designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
16633For the user space programs, runtime support is not currently provided
16634in libc and libgcc. Users who want to use this feature in user space need
16635to provide their own support for the runtime. It should be noted that
16636this may cause the ABI rules to be broken.
16637
16638On aarch64, the instrumentation makes use of the platform register @code{x18}.
16639This generally means that any code that may run on the same thread as code
16640compiled with ShadowCallStack must be compiled with the flag
16641@option{-ffixed-x18}, otherwise functions compiled without
16642@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
16643stack pointer.
16644
16645Also, because there is no userspace runtime support, code compiled with
16646ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
16647to turn off exceptions.
16648
16649See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
16650details.
16651
16652@item -fsanitize=thread
16653@opindex fsanitize=thread
16654Enable ThreadSanitizer, a fast data race detector.
16655Memory access instructions are instrumented to detect
16656data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
16657details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
16658environment variable; see
16659@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
16660supported options.
16661The option cannot be combined with @option{-fsanitize=address},
16662@option{-fsanitize=leak}.
16663
16664Note that sanitized atomic builtins cannot throw exceptions when
16665operating on invalid memory addresses with non-call exceptions
16666(@option{-fnon-call-exceptions}).
16667
16668@item -fsanitize=leak
16669@opindex fsanitize=leak
16670Enable LeakSanitizer, a memory leak detector.
16671This option only matters for linking of executables and
16672the executable is linked against a library that overrides @code{malloc}
16673and other allocator functions. See
16674@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
16675details. The run-time behavior can be influenced using the
16676@env{LSAN_OPTIONS} environment variable.
16677The option cannot be combined with @option{-fsanitize=thread}.
16678
16679@item -fsanitize=undefined
16680@opindex fsanitize=undefined
16681Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
16682Various computations are instrumented to detect undefined behavior
16683at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
16684@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
16685
16686@table @gcctabopt
16687
16688@item -fsanitize=shift
16689@opindex fsanitize=shift
16690This option enables checking that the result of a shift operation is
16691not undefined. Note that what exactly is considered undefined differs
16692slightly between C and C++, as well as between ISO C90 and C99, etc.
16693This option has two suboptions, @option{-fsanitize=shift-base} and
16694@option{-fsanitize=shift-exponent}.
16695
16696@item -fsanitize=shift-exponent
16697@opindex fsanitize=shift-exponent
16698This option enables checking that the second argument of a shift operation
16699is not negative and is smaller than the precision of the promoted first
16700argument.
16701
16702@item -fsanitize=shift-base
16703@opindex fsanitize=shift-base
16704If the second argument of a shift operation is within range, check that the
16705result of a shift operation is not undefined. Note that what exactly is
16706considered undefined differs slightly between C and C++, as well as between
16707ISO C90 and C99, etc.
16708
16709@item -fsanitize=integer-divide-by-zero
16710@opindex fsanitize=integer-divide-by-zero
16711Detect integer division by zero.
16712
16713@item -fsanitize=unreachable
16714@opindex fsanitize=unreachable
16715With this option, the compiler turns the @code{__builtin_unreachable}
16716call into a diagnostics message call instead. When reaching the
16717@code{__builtin_unreachable} call, the behavior is undefined.
16718
16719@item -fsanitize=vla-bound
16720@opindex fsanitize=vla-bound
16721This option instructs the compiler to check that the size of a variable
16722length array is positive.
16723
16724@item -fsanitize=null
16725@opindex fsanitize=null
16726This option enables pointer checking. Particularly, the application
16727built with this option turned on will issue an error message when it
16728tries to dereference a NULL pointer, or if a reference (possibly an
16729rvalue reference) is bound to a NULL pointer, or if a method is invoked
16730on an object pointed by a NULL pointer.
16731
16732@item -fsanitize=return
16733@opindex fsanitize=return
16734This option enables return statement checking. Programs
16735built with this option turned on will issue an error message
16736when the end of a non-void function is reached without actually
16737returning a value. This option works in C++ only.
16738
16739@item -fsanitize=signed-integer-overflow
16740@opindex fsanitize=signed-integer-overflow
16741This option enables signed integer overflow checking. We check that
16742the result of @code{+}, @code{*}, and both unary and binary @code{-}
16743does not overflow in the signed arithmetics. This also detects
16744@code{INT_MIN / -1} signed division. Note, integer promotion
16745rules must be taken into account. That is, the following is not an
16746overflow:
16747@smallexample
16748signed char a = SCHAR_MAX;
16749a++;
16750@end smallexample
16751
16752@item -fsanitize=bounds
16753@opindex fsanitize=bounds
16754This option enables instrumentation of array bounds. Various out of bounds
16755accesses are detected. Flexible array members, flexible array member-like
16756arrays, and initializers of variables with static storage are not instrumented.
16757
16758@item -fsanitize=bounds-strict
16759@opindex fsanitize=bounds-strict
16760This option enables strict instrumentation of array bounds. Most out of bounds
16761accesses are detected, including flexible array members and flexible array
16762member-like arrays. Initializers of variables with static storage are not
16763instrumented.
16764
16765@item -fsanitize=alignment
16766@opindex fsanitize=alignment
16767
16768This option enables checking of alignment of pointers when they are
16769dereferenced, or when a reference is bound to insufficiently aligned target,
16770or when a method or constructor is invoked on insufficiently aligned object.
16771
16772@item -fsanitize=object-size
16773@opindex fsanitize=object-size
16774This option enables instrumentation of memory references using the
7283380a
SP
16775@code{__builtin_dynamic_object_size} function. Various out of bounds
16776pointer accesses are detected.
d77de738
ML
16777
16778@item -fsanitize=float-divide-by-zero
16779@opindex fsanitize=float-divide-by-zero
16780Detect floating-point division by zero. Unlike other similar options,
16781@option{-fsanitize=float-divide-by-zero} is not enabled by
16782@option{-fsanitize=undefined}, since floating-point division by zero can
16783be a legitimate way of obtaining infinities and NaNs.
16784
16785@item -fsanitize=float-cast-overflow
16786@opindex fsanitize=float-cast-overflow
16787This option enables floating-point type to integer conversion checking.
16788We check that the result of the conversion does not overflow.
16789Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
16790not enabled by @option{-fsanitize=undefined}.
16791This option does not work well with @code{FE_INVALID} exceptions enabled.
16792
16793@item -fsanitize=nonnull-attribute
16794@opindex fsanitize=nonnull-attribute
16795
16796This option enables instrumentation of calls, checking whether null values
16797are not passed to arguments marked as requiring a non-null value by the
16798@code{nonnull} function attribute.
16799
16800@item -fsanitize=returns-nonnull-attribute
16801@opindex fsanitize=returns-nonnull-attribute
16802
16803This option enables instrumentation of return statements in functions
16804marked with @code{returns_nonnull} function attribute, to detect returning
16805of null values from such functions.
16806
16807@item -fsanitize=bool
16808@opindex fsanitize=bool
16809
16810This option enables instrumentation of loads from bool. If a value other
16811than 0/1 is loaded, a run-time error is issued.
16812
16813@item -fsanitize=enum
16814@opindex fsanitize=enum
16815
16816This option enables instrumentation of loads from an enum type. If
16817a value outside the range of values for the enum type is loaded,
16818a run-time error is issued.
16819
16820@item -fsanitize=vptr
16821@opindex fsanitize=vptr
16822
16823This option enables instrumentation of C++ member function calls, member
16824accesses and some conversions between pointers to base and derived classes,
16825to verify the referenced object has the correct dynamic type.
16826
16827@item -fsanitize=pointer-overflow
16828@opindex fsanitize=pointer-overflow
16829
16830This option enables instrumentation of pointer arithmetics. If the pointer
16831arithmetics overflows, a run-time error is issued.
16832
16833@item -fsanitize=builtin
16834@opindex fsanitize=builtin
16835
16836This option enables instrumentation of arguments to selected builtin
16837functions. If an invalid value is passed to such arguments, a run-time
16838error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
16839or @code{__builtin_clz} invokes undefined behavior and is diagnosed
16840by this option.
16841
16842@end table
16843
16844Note that sanitizers tend to increase the rate of false positive
16845warnings, most notably those around @option{-Wmaybe-uninitialized}.
16846We recommend against combining @option{-Werror} and [the use of]
16847sanitizers.
16848
16849While @option{-ftrapv} causes traps for signed overflows to be emitted,
16850@option{-fsanitize=undefined} gives a diagnostic message.
16851This currently works only for the C family of languages.
16852
16853@item -fno-sanitize=all
16854@opindex fno-sanitize=all
16855
16856This option disables all previously enabled sanitizers.
16857@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
16858together.
16859
16860@item -fasan-shadow-offset=@var{number}
16861@opindex fasan-shadow-offset
16862This option forces GCC to use custom shadow offset in AddressSanitizer checks.
16863It is useful for experimenting with different shadow memory layouts in
16864Kernel AddressSanitizer.
16865
16866@item -fsanitize-sections=@var{s1},@var{s2},...
16867@opindex fsanitize-sections
16868Sanitize global variables in selected user-defined sections. @var{si} may
16869contain wildcards.
16870
16871@item -fsanitize-recover@r{[}=@var{opts}@r{]}
16872@opindex fsanitize-recover
16873@opindex fno-sanitize-recover
16874@option{-fsanitize-recover=} controls error recovery mode for sanitizers
16875mentioned in comma-separated list of @var{opts}. Enabling this option
16876for a sanitizer component causes it to attempt to continue
16877running the program as if no error happened. This means multiple
16878runtime errors can be reported in a single program run, and the exit
16879code of the program may indicate success even when errors
16880have been reported. The @option{-fno-sanitize-recover=} option
16881can be used to alter
16882this behavior: only the first detected error is reported
16883and program then exits with a non-zero exit code.
16884
16885Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
16886except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
16887@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
16888@option{-fsanitize=bounds-strict},
16889@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
16890For these sanitizers error recovery is turned on by default,
16891except @option{-fsanitize=address}, for which this feature is experimental.
16892@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
16893accepted, the former enables recovery for all sanitizers that support it,
16894the latter disables recovery for all sanitizers that support it.
16895
16896Even if a recovery mode is turned on the compiler side, it needs to be also
16897enabled on the runtime library side, otherwise the failures are still fatal.
16898The runtime library defaults to @code{halt_on_error=0} for
16899ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
16900AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
16901setting the @code{halt_on_error} flag in the corresponding environment variable.
16902
16903Syntax without an explicit @var{opts} parameter is deprecated. It is
16904equivalent to specifying an @var{opts} list of:
16905
16906@smallexample
16907undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
16908@end smallexample
16909
16910@item -fsanitize-address-use-after-scope
16911@opindex fsanitize-address-use-after-scope
16912Enable sanitization of local variables to detect use-after-scope bugs.
16913The option sets @option{-fstack-reuse} to @samp{none}.
16914
16915@item -fsanitize-trap@r{[}=@var{opts}@r{]}
16916@opindex fsanitize-trap
16917@opindex fno-sanitize-trap
16918The @option{-fsanitize-trap=} option instructs the compiler to
16919report for sanitizers mentioned in comma-separated list of @var{opts}
16920undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
16921library routine. If this option is enabled for certain sanitizer,
16922it takes precedence over the @option{-fsanitizer-recover=} for that
16923sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
16924of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
16925
16926The advantage of this is that the @code{libubsan} library is not needed
16927and is not linked in, so this is usable even in freestanding environments.
16928
16929Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
16930except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
16931@option{-fsanitize=float-divide-by-zero} and
16932@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
16933specified, which enables it for @code{undefined} suboptions,
16934@option{-fsanitize=float-cast-overflow},
16935@option{-fsanitize=float-divide-by-zero} and
16936@option{-fsanitize=bounds-strict}.
16937If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
16938and @code{-fsanitize=vptr} is enabled on the command line, the
16939instrumentation is silently ignored as the instrumentation always needs
16940@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
16941
16942@item -fsanitize-undefined-trap-on-error
16943@opindex fsanitize-undefined-trap-on-error
16944The @option{-fsanitize-undefined-trap-on-error} option is deprecated
16945equivalent of @option{-fsanitize-trap=all}.
16946
16947@item -fsanitize-coverage=trace-pc
16948@opindex fsanitize-coverage=trace-pc
16949Enable coverage-guided fuzzing code instrumentation.
16950Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
16951
16952@item -fsanitize-coverage=trace-cmp
16953@opindex fsanitize-coverage=trace-cmp
16954Enable dataflow guided fuzzing code instrumentation.
16955Inserts a call to @code{__sanitizer_cov_trace_cmp1},
16956@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
16957@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
16958variable or @code{__sanitizer_cov_trace_const_cmp1},
16959@code{__sanitizer_cov_trace_const_cmp2},
16960@code{__sanitizer_cov_trace_const_cmp4} or
16961@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
16962operand constant, @code{__sanitizer_cov_trace_cmpf} or
16963@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
16964@code{__sanitizer_cov_trace_switch} for switch statements.
16965
16966@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
16967@opindex fcf-protection
16968Enable code instrumentation of control-flow transfers to increase
16969program security by checking that target addresses of control-flow
16970transfer instructions (such as indirect function call, function return,
16971indirect jump) are valid. This prevents diverting the flow of control
16972to an unexpected target. This is intended to protect against such
16973threats as Return-oriented Programming (ROP), and similarly
16974call/jmp-oriented programming (COP/JOP).
16975
16976The value @code{branch} tells the compiler to implement checking of
16977validity of control-flow transfer at the point of indirect branch
16978instructions, i.e.@: call/jmp instructions. The value @code{return}
16979implements checking of validity at the point of returning from a
16980function. The value @code{full} is an alias for specifying both
16981@code{branch} and @code{return}. The value @code{none} turns off
16982instrumentation.
16983
16984The value @code{check} is used for the final link with link-time
16985optimization (LTO). An error is issued if LTO object files are
16986compiled with different @option{-fcf-protection} values. The
16987value @code{check} is ignored at the compile time.
16988
16989The macro @code{__CET__} is defined when @option{-fcf-protection} is
16990used. The first bit of @code{__CET__} is set to 1 for the value
16991@code{branch} and the second bit of @code{__CET__} is set to 1 for
16992the @code{return}.
16993
16994You can also use the @code{nocf_check} attribute to identify
16995which functions and calls should be skipped from instrumentation
16996(@pxref{Function Attributes}).
16997
16998Currently the x86 GNU/Linux target provides an implementation based
16999on Intel Control-flow Enforcement Technology (CET) which works for
17000i686 processor or newer.
17001
17002@item -fharden-compares
17003@opindex fharden-compares
17004For every logical test that survives gimple optimizations and is
17005@emph{not} the condition in a conditional branch (for example,
17006conditions tested for conditional moves, or to store in boolean
17007variables), emit extra code to compute and verify the reversed
17008condition, and to call @code{__builtin_trap} if the results do not
17009match. Use with @samp{-fharden-conditional-branches} to cover all
17010conditionals.
17011
17012@item -fharden-conditional-branches
17013@opindex fharden-conditional-branches
17014For every non-vectorized conditional branch that survives gimple
17015optimizations, emit extra code to compute and verify the reversed
17016condition, and to call @code{__builtin_trap} if the result is
17017unexpected. Use with @samp{-fharden-compares} to cover all
17018conditionals.
17019
17020@item -fstack-protector
17021@opindex fstack-protector
17022Emit extra code to check for buffer overflows, such as stack smashing
17023attacks. This is done by adding a guard variable to functions with
17024vulnerable objects. This includes functions that call @code{alloca}, and
17025functions with buffers larger than or equal to 8 bytes. The guards are
17026initialized when a function is entered and then checked when the function
17027exits. If a guard check fails, an error message is printed and the program
17028exits. Only variables that are actually allocated on the stack are
17029considered, optimized away variables or variables allocated in registers
17030don't count.
17031
17032@item -fstack-protector-all
17033@opindex fstack-protector-all
17034Like @option{-fstack-protector} except that all functions are protected.
17035
17036@item -fstack-protector-strong
17037@opindex fstack-protector-strong
17038Like @option{-fstack-protector} but includes additional functions to
17039be protected --- those that have local array definitions, or have
17040references to local frame addresses. Only variables that are actually
17041allocated on the stack are considered, optimized away variables or variables
17042allocated in registers don't count.
17043
17044@item -fstack-protector-explicit
17045@opindex fstack-protector-explicit
17046Like @option{-fstack-protector} but only protects those functions which
17047have the @code{stack_protect} attribute.
17048
17049@item -fstack-check
17050@opindex fstack-check
17051Generate code to verify that you do not go beyond the boundary of the
17052stack. You should specify this flag if you are running in an
17053environment with multiple threads, but you only rarely need to specify it in
17054a single-threaded environment since stack overflow is automatically
17055detected on nearly all systems if there is only one stack.
17056
17057Note that this switch does not actually cause checking to be done; the
17058operating system or the language runtime must do that. The switch causes
17059generation of code to ensure that they see the stack being extended.
17060
17061You can additionally specify a string parameter: @samp{no} means no
17062checking, @samp{generic} means force the use of old-style checking,
17063@samp{specific} means use the best checking method and is equivalent
17064to bare @option{-fstack-check}.
17065
17066Old-style checking is a generic mechanism that requires no specific
17067target support in the compiler but comes with the following drawbacks:
17068
17069@enumerate
17070@item
17071Modified allocation strategy for large objects: they are always
17072allocated dynamically if their size exceeds a fixed threshold. Note this
17073may change the semantics of some code.
17074
17075@item
17076Fixed limit on the size of the static frame of functions: when it is
17077topped by a particular function, stack checking is not reliable and
17078a warning is issued by the compiler.
17079
17080@item
17081Inefficiency: because of both the modified allocation strategy and the
17082generic implementation, code performance is hampered.
17083@end enumerate
17084
17085Note that old-style stack checking is also the fallback method for
17086@samp{specific} if no target support has been added in the compiler.
17087
17088@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17089and stack overflows. @samp{specific} is an excellent choice when compiling
17090Ada code. It is not generally sufficient to protect against stack-clash
17091attacks. To protect against those you want @samp{-fstack-clash-protection}.
17092
17093@item -fstack-clash-protection
17094@opindex fstack-clash-protection
17095Generate code to prevent stack clash style attacks. When this option is
17096enabled, the compiler will only allocate one page of stack space at a time
17097and each page is accessed immediately after allocation. Thus, it prevents
17098allocations from jumping over any stack guard page provided by the
17099operating system.
17100
17101Most targets do not fully support stack clash protection. However, on
17102those targets @option{-fstack-clash-protection} will protect dynamic stack
17103allocations. @option{-fstack-clash-protection} may also provide limited
17104protection for static stack allocations if the target supports
17105@option{-fstack-check=specific}.
17106
17107@item -fstack-limit-register=@var{reg}
17108@itemx -fstack-limit-symbol=@var{sym}
17109@itemx -fno-stack-limit
17110@opindex fstack-limit-register
17111@opindex fstack-limit-symbol
17112@opindex fno-stack-limit
17113Generate code to ensure that the stack does not grow beyond a certain value,
17114either the value of a register or the address of a symbol. If a larger
17115stack is required, a signal is raised at run time. For most targets,
17116the signal is raised before the stack overruns the boundary, so
17117it is possible to catch the signal without taking special precautions.
17118
17119For instance, if the stack starts at absolute address @samp{0x80000000}
17120and grows downwards, you can use the flags
17121@option{-fstack-limit-symbol=__stack_limit} and
17122@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17123of 128KB@. Note that this may only work with the GNU linker.
17124
17125You can locally override stack limit checking by using the
17126@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17127
17128@item -fsplit-stack
17129@opindex fsplit-stack
17130Generate code to automatically split the stack before it overflows.
17131The resulting program has a discontiguous stack which can only
17132overflow if the program is unable to allocate any more memory. This
17133is most useful when running threaded programs, as it is no longer
17134necessary to calculate a good stack size to use for each thread. This
17135is currently only implemented for the x86 targets running
17136GNU/Linux.
17137
17138When code compiled with @option{-fsplit-stack} calls code compiled
17139without @option{-fsplit-stack}, there may not be much stack space
17140available for the latter code to run. If compiling all code,
17141including library code, with @option{-fsplit-stack} is not an option,
17142then the linker can fix up these calls so that the code compiled
17143without @option{-fsplit-stack} always has a large stack. Support for
17144this is implemented in the gold linker in GNU binutils release 2.21
17145and later.
17146
17147@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
17148@opindex fvtable-verify
17149This option is only available when compiling C++ code.
17150It turns on (or off, if using @option{-fvtable-verify=none}) the security
17151feature that verifies at run time, for every virtual call, that
17152the vtable pointer through which the call is made is valid for the type of
17153the object, and has not been corrupted or overwritten. If an invalid vtable
17154pointer is detected at run time, an error is reported and execution of the
17155program is immediately halted.
17156
17157This option causes run-time data structures to be built at program startup,
17158which are used for verifying the vtable pointers.
17159The options @samp{std} and @samp{preinit}
17160control the timing of when these data structures are built. In both cases the
17161data structures are built before execution reaches @code{main}. Using
17162@option{-fvtable-verify=std} causes the data structures to be built after
17163shared libraries have been loaded and initialized.
17164@option{-fvtable-verify=preinit} causes them to be built before shared
17165libraries have been loaded and initialized.
17166
17167If this option appears multiple times in the command line with different
17168values specified, @samp{none} takes highest priority over both @samp{std} and
17169@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17170
17171@item -fvtv-debug
17172@opindex fvtv-debug
17173When used in conjunction with @option{-fvtable-verify=std} or
17174@option{-fvtable-verify=preinit}, causes debug versions of the
17175runtime functions for the vtable verification feature to be called.
17176This flag also causes the compiler to log information about which
17177vtable pointers it finds for each class.
17178This information is written to a file named @file{vtv_set_ptr_data.log}
17179in the directory named by the environment variable @env{VTV_LOGS_DIR}
17180if that is defined or the current working directory otherwise.
17181
17182Note: This feature @emph{appends} data to the log file. If you want a fresh log
17183file, be sure to delete any existing one.
17184
17185@item -fvtv-counts
17186@opindex fvtv-counts
17187This is a debugging flag. When used in conjunction with
17188@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17189causes the compiler to keep track of the total number of virtual calls
17190it encounters and the number of verifications it inserts. It also
17191counts the number of calls to certain run-time library functions
17192that it inserts and logs this information for each compilation unit.
17193The compiler writes this information to a file named
17194@file{vtv_count_data.log} in the directory named by the environment
17195variable @env{VTV_LOGS_DIR} if that is defined or the current working
17196directory otherwise. It also counts the size of the vtable pointer sets
17197for each class, and writes this information to @file{vtv_class_set_sizes.log}
17198in the same directory.
17199
17200Note: This feature @emph{appends} data to the log files. To get fresh log
17201files, be sure to delete any existing ones.
17202
17203@item -finstrument-functions
17204@opindex finstrument-functions
17205Generate instrumentation calls for entry and exit to functions. Just
17206after function entry and just before function exit, the following
17207profiling functions are called with the address of the current
17208function and its call site. (On some platforms,
17209@code{__builtin_return_address} does not work beyond the current
17210function, so the call site information may not be available to the
17211profiling functions otherwise.)
17212
17213@smallexample
17214void __cyg_profile_func_enter (void *this_fn,
17215 void *call_site);
17216void __cyg_profile_func_exit (void *this_fn,
17217 void *call_site);
17218@end smallexample
17219
17220The first argument is the address of the start of the current function,
17221which may be looked up exactly in the symbol table.
17222
17223This instrumentation is also done for functions expanded inline in other
17224functions. The profiling calls indicate where, conceptually, the
17225inline function is entered and exited. This means that addressable
17226versions of such functions must be available. If all your uses of a
17227function are expanded inline, this may mean an additional expansion of
17228code size. If you use @code{extern inline} in your C code, an
17229addressable version of such functions must be provided. (This is
17230normally the case anyway, but if you get lucky and the optimizer always
17231expands the functions inline, you might have gotten away without
17232providing static copies.)
17233
17234A function may be given the attribute @code{no_instrument_function}, in
17235which case this instrumentation is not done. This can be used, for
17236example, for the profiling functions listed above, high-priority
17237interrupt routines, and any functions from which the profiling functions
17238cannot safely be called (perhaps signal handlers, if the profiling
17239routines generate output or allocate memory).
17240@xref{Common Function Attributes}.
17241
17242@item -finstrument-functions-once
9c19597c 17243@opindex finstrument-functions-once
d77de738
ML
17244This is similar to @option{-finstrument-functions}, but the profiling
17245functions are called only once per instrumented function, i.e. the first
17246profiling function is called after the first entry into the instrumented
17247function and the second profiling function is called before the exit
17248corresponding to this first entry.
17249
17250The definition of @code{once} for the purpose of this option is a little
17251vague because the implementation is not protected against data races.
17252As a result, the implementation only guarantees that the profiling
17253functions are called at @emph{least} once per process and at @emph{most}
17254once per thread, but the calls are always paired, that is to say, if a
17255thread calls the first function, then it will call the second function,
17256unless it never reaches the exit of the instrumented function.
17257
17258@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
17259@opindex finstrument-functions-exclude-file-list
17260
17261Set the list of functions that are excluded from instrumentation (see
17262the description of @option{-finstrument-functions}). If the file that
17263contains a function definition matches with one of @var{file}, then
17264that function is not instrumented. The match is done on substrings:
17265if the @var{file} parameter is a substring of the file name, it is
17266considered to be a match.
17267
17268For example:
17269
17270@smallexample
17271-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17272@end smallexample
17273
17274@noindent
17275excludes any inline function defined in files whose pathnames
17276contain @file{/bits/stl} or @file{include/sys}.
17277
17278If, for some reason, you want to include letter @samp{,} in one of
17279@var{sym}, write @samp{\,}. For example,
17280@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17281(note the single quote surrounding the option).
17282
17283@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
17284@opindex finstrument-functions-exclude-function-list
17285
17286This is similar to @option{-finstrument-functions-exclude-file-list},
17287but this option sets the list of function names to be excluded from
17288instrumentation. The function name to be matched is its user-visible
17289name, such as @code{vector<int> blah(const vector<int> &)}, not the
17290internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17291match is done on substrings: if the @var{sym} parameter is a substring
17292of the function name, it is considered to be a match. For C99 and C++
17293extended identifiers, the function name must be given in UTF-8, not
17294using universal character names.
17295
17296@item -fpatchable-function-entry=@var{N}[,@var{M}]
17297@opindex fpatchable-function-entry
17298Generate @var{N} NOPs right at the beginning
17299of each function, with the function entry point before the @var{M}th NOP.
17300If @var{M} is omitted, it defaults to @code{0} so the
17301function entry points to the address just at the first NOP.
17302The NOP instructions reserve extra space which can be used to patch in
17303any desired instrumentation at run time, provided that the code segment
17304is writable. The amount of space is controllable indirectly via
17305the number of NOPs; the NOP instruction used corresponds to the instruction
17306emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17307is target-specific and may also depend on the architecture variant and/or
17308other compilation options.
17309
17310For run-time identification, the starting addresses of these areas,
17311which correspond to their respective function entries minus @var{M},
17312are additionally collected in the @code{__patchable_function_entries}
17313section of the resulting binary.
17314
17315Note that the value of @code{__attribute__ ((patchable_function_entry
17316(N,M)))} takes precedence over command-line option
17317@option{-fpatchable-function-entry=N,M}. This can be used to increase
17318the area size or to remove it completely on a single function.
17319If @code{N=0}, no pad location is recorded.
17320
17321The NOP instructions are inserted at---and maybe before, depending on
17322@var{M}---the function entry address, even before the prologue. On
17323PowerPC with the ELFv2 ABI, for a function with dual entry points,
17324the local entry point is this function entry address.
17325
17326The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17327ELFv2 ABI, for a function with dual entry points, the supported values
17328for @var{M} are 0, 2, 6 and 14.
17329@end table
17330
17331
17332@node Preprocessor Options
17333@section Options Controlling the Preprocessor
17334@cindex preprocessor options
17335@cindex options, preprocessor
17336
17337These options control the C preprocessor, which is run on each C source
17338file before actual compilation.
17339
17340If you use the @option{-E} option, nothing is done except preprocessing.
17341Some of these options make sense only together with @option{-E} because
17342they cause the preprocessor output to be unsuitable for actual
17343compilation.
17344
17345In addition to the options listed here, there are a number of options
17346to control search paths for include files documented in
17347@ref{Directory Options}.
17348Options to control preprocessor diagnostics are listed in
17349@ref{Warning Options}.
17350
17351@table @gcctabopt
17352@include cppopts.texi
17353
17354@item -Wp,@var{option}
17355@opindex Wp
17356You can use @option{-Wp,@var{option}} to bypass the compiler driver
17357and pass @var{option} directly through to the preprocessor. If
17358@var{option} contains commas, it is split into multiple options at the
17359commas. However, many options are modified, translated or interpreted
17360by the compiler driver before being passed to the preprocessor, and
17361@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17362interface is undocumented and subject to change, so whenever possible
17363you should avoid using @option{-Wp} and let the driver handle the
17364options instead.
17365
17366@item -Xpreprocessor @var{option}
17367@opindex Xpreprocessor
17368Pass @var{option} as an option to the preprocessor. You can use this to
17369supply system-specific preprocessor options that GCC does not
17370recognize.
17371
17372If you want to pass an option that takes an argument, you must use
17373@option{-Xpreprocessor} twice, once for the option and once for the argument.
17374
17375@item -no-integrated-cpp
17376@opindex no-integrated-cpp
17377Perform preprocessing as a separate pass before compilation.
17378By default, GCC performs preprocessing as an integrated part of
17379input tokenization and parsing.
17380If this option is provided, the appropriate language front end
17381(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17382and Objective-C, respectively) is instead invoked twice,
17383once for preprocessing only and once for actual compilation
17384of the preprocessed input.
17385This option may be useful in conjunction with the @option{-B} or
17386@option{-wrapper} options to specify an alternate preprocessor or
17387perform additional processing of the program source between
17388normal preprocessing and compilation.
17389
17390@item -flarge-source-files
17391@opindex flarge-source-files
17392Adjust GCC to expect large source files, at the expense of slower
17393compilation and higher memory usage.
17394
17395Specifically, GCC normally tracks both column numbers and line numbers
17396within source files and it normally prints both of these numbers in
17397diagnostics. However, once it has processed a certain number of source
17398lines, it stops tracking column numbers and only tracks line numbers.
17399This means that diagnostics for later lines do not include column numbers.
17400It also means that options like @option{-Wmisleading-indentation} cease to work
17401at that point, although the compiler prints a note if this happens.
17402Passing @option{-flarge-source-files} significantly increases the number
17403of source lines that GCC can process before it stops tracking columns.
17404
17405@end table
17406
17407@node Assembler Options
17408@section Passing Options to the Assembler
17409
17410@c prevent bad page break with this line
17411You can pass options to the assembler.
17412
17413@table @gcctabopt
17414@item -Wa,@var{option}
17415@opindex Wa
17416Pass @var{option} as an option to the assembler. If @var{option}
17417contains commas, it is split into multiple options at the commas.
17418
17419@item -Xassembler @var{option}
17420@opindex Xassembler
17421Pass @var{option} as an option to the assembler. You can use this to
17422supply system-specific assembler options that GCC does not
17423recognize.
17424
17425If you want to pass an option that takes an argument, you must use
17426@option{-Xassembler} twice, once for the option and once for the argument.
17427
17428@end table
17429
17430@node Link Options
17431@section Options for Linking
17432@cindex link options
17433@cindex options, linking
17434
17435These options come into play when the compiler links object files into
17436an executable output file. They are meaningless if the compiler is
17437not doing a link step.
17438
17439@table @gcctabopt
17440@cindex file names
17441@item @var{object-file-name}
17442A file name that does not end in a special recognized suffix is
17443considered to name an object file or library. (Object files are
17444distinguished from libraries by the linker according to the file
17445contents.) If linking is done, these object files are used as input
17446to the linker.
17447
17448@item -c
17449@itemx -S
17450@itemx -E
17451@opindex c
17452@opindex S
17453@opindex E
17454If any of these options is used, then the linker is not run, and
17455object file names should not be used as arguments. @xref{Overall
17456Options}.
17457
17458@item -flinker-output=@var{type}
17459@opindex flinker-output
17460This option controls code generation of the link-time optimizer. By
17461default the linker output is automatically determined by the linker
17462plugin. For debugging the compiler and if incremental linking with a
17463non-LTO object file is desired, it may be useful to control the type
17464manually.
17465
17466If @var{type} is @samp{exec}, code generation produces a static
17467binary. In this case @option{-fpic} and @option{-fpie} are both
17468disabled.
17469
17470If @var{type} is @samp{dyn}, code generation produces a shared
17471library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17472but not enabled automatically. This allows to build shared libraries
17473without position-independent code on architectures where this is
17474possible, i.e.@: on x86.
17475
17476If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17477executable. This results in similar optimizations as @samp{exec}
17478except that @option{-fpie} is not disabled if specified at compilation
17479time.
17480
17481If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17482done. The sections containing intermediate code for link-time optimization are
17483merged, pre-optimized, and output to the resulting object file. In addition, if
17484@option{-ffat-lto-objects} is specified, binary code is produced for future
17485non-LTO linking. The object file produced by incremental linking is smaller
17486than a static library produced from the same object files. At link time the
17487result of incremental linking also loads faster than a static
17488library assuming that the majority of objects in the library are used.
17489
17490Finally @samp{nolto-rel} configures the compiler for incremental linking where
17491code generation is forced, a final binary is produced, and the intermediate
17492code for later link-time optimization is stripped. When multiple object files
17493are linked together the resulting code is better optimized than with
17494link-time optimizations disabled (for example, cross-module inlining
17495happens), but most of benefits of whole program optimizations are lost.
17496
17497During the incremental link (by @option{-r}) the linker plugin defaults to
17498@option{rel}. With current interfaces to GNU Binutils it is however not
17499possible to incrementally link LTO objects and non-LTO objects into a single
17500mixed object file. If any of object files in incremental link cannot
17501be used for link-time optimization, the linker plugin issues a warning and
17502uses @samp{nolto-rel}. To maintain whole program optimization, it is
17503recommended to link such objects into static library instead. Alternatively it
17504is possible to use H.J. Lu's binutils with support for mixed objects.
17505
17506@item -fuse-ld=bfd
17507@opindex fuse-ld=bfd
17508Use the @command{bfd} linker instead of the default linker.
17509
17510@item -fuse-ld=gold
17511@opindex fuse-ld=gold
17512Use the @command{gold} linker instead of the default linker.
17513
17514@item -fuse-ld=lld
17515@opindex fuse-ld=lld
17516Use the LLVM @command{lld} linker instead of the default linker.
17517
17518@item -fuse-ld=mold
17519@opindex fuse-ld=mold
17520Use the Modern Linker (@command{mold}) instead of the default linker.
17521
17522@cindex Libraries
17523@item -l@var{library}
17524@itemx -l @var{library}
17525@opindex l
17526Search the library named @var{library} when linking. (The second
17527alternative with the library as a separate argument is only for
17528POSIX compliance and is not recommended.)
17529
17530The @option{-l} option is passed directly to the linker by GCC. Refer
17531to your linker documentation for exact details. The general
17532description below applies to the GNU linker.
17533
17534The linker searches a standard list of directories for the library.
17535The directories searched include several standard system directories
17536plus any that you specify with @option{-L}.
17537
17538Static libraries are archives of object files, and have file names
17539like @file{lib@var{library}.a}. Some targets also support shared
17540libraries, which typically have names like @file{lib@var{library}.so}.
17541If both static and shared libraries are found, the linker gives
17542preference to linking with the shared library unless the
17543@option{-static} option is used.
17544
17545It makes a difference where in the command you write this option; the
17546linker searches and processes libraries and object files in the order they
17547are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17548after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17549to functions in @samp{z}, those functions may not be loaded.
17550
17551@item -lobjc
17552@opindex lobjc
17553You need this special case of the @option{-l} option in order to
17554link an Objective-C or Objective-C++ program.
17555
17556@item -nostartfiles
17557@opindex nostartfiles
17558Do not use the standard system startup files when linking.
17559The standard system libraries are used normally, unless @option{-nostdlib},
17560@option{-nolibc}, or @option{-nodefaultlibs} is used.
17561
17562@item -nodefaultlibs
17563@opindex nodefaultlibs
17564Do not use the standard system libraries when linking.
17565Only the libraries you specify are passed to the linker, and options
17566specifying linkage of the system libraries, such as @option{-static-libgcc}
17567or @option{-shared-libgcc}, are ignored.
17568The standard startup files are used normally, unless @option{-nostartfiles}
17569is used.
17570
17571The compiler may generate calls to @code{memcmp},
17572@code{memset}, @code{memcpy} and @code{memmove}.
17573These entries are usually resolved by entries in
17574libc. These entry points should be supplied through some other
17575mechanism when this option is specified.
17576
17577@item -nolibc
17578@opindex nolibc
17579Do not use the C library or system libraries tightly coupled with it when
17580linking. Still link with the startup files, @file{libgcc} or toolchain
17581provided language support libraries such as @file{libgnat}, @file{libgfortran}
17582or @file{libstdc++} unless options preventing their inclusion are used as
17583well. This typically removes @option{-lc} from the link command line, as well
17584as system libraries that normally go with it and become meaningless when
17585absence of a C library is assumed, for example @option{-lpthread} or
17586@option{-lm} in some configurations. This is intended for bare-board
17587targets when there is indeed no C library available.
17588
17589@item -nostdlib
17590@opindex nostdlib
17591Do not use the standard system startup files or libraries when linking.
17592No startup files and only the libraries you specify are passed to
17593the linker, and options specifying linkage of the system libraries, such as
17594@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
17595
17596The compiler may generate calls to @code{memcmp}, @code{memset},
17597@code{memcpy} and @code{memmove}.
17598These entries are usually resolved by entries in
17599libc. These entry points should be supplied through some other
17600mechanism when this option is specified.
17601
17602@cindex @option{-lgcc}, use with @option{-nostdlib}
17603@cindex @option{-nostdlib} and unresolved references
17604@cindex unresolved references and @option{-nostdlib}
17605@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
17606@cindex @option{-nodefaultlibs} and unresolved references
17607@cindex unresolved references and @option{-nodefaultlibs}
17608One of the standard libraries bypassed by @option{-nostdlib} and
17609@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
17610which GCC uses to overcome shortcomings of particular machines, or special
17611needs for some languages.
17612(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
17613Collection (GCC) Internals},
17614for more discussion of @file{libgcc.a}.)
17615In most cases, you need @file{libgcc.a} even when you want to avoid
17616other standard libraries. In other words, when you specify @option{-nostdlib}
17617or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
17618This ensures that you have no unresolved references to internal GCC
17619library subroutines.
17620(An example of such an internal subroutine is @code{__main}, used to ensure C++
17621constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
17622GNU Compiler Collection (GCC) Internals}.)
17623
17624@item -nostdlib++
17625@opindex nostdlib++
17626Do not implicitly link with standard C++ libraries.
17627
17628@item -e @var{entry}
17629@itemx --entry=@var{entry}
17630@opindex e
17631@opindex entry
17632
17633Specify that the program entry point is @var{entry}. The argument is
17634interpreted by the linker; the GNU linker accepts either a symbol name
17635or an address.
17636
17637@item -pie
17638@opindex pie
17639Produce a dynamically linked position independent executable on targets
17640that support it. For predictable results, you must also specify the same
17641set of options used for compilation (@option{-fpie}, @option{-fPIE},
17642or model suboptions) when you specify this linker option.
17643
17644@item -no-pie
17645@opindex no-pie
17646Don't produce a dynamically linked position independent executable.
17647
17648@item -static-pie
17649@opindex static-pie
17650Produce a static position independent executable on targets that support
17651it. A static position independent executable is similar to a static
17652executable, but can be loaded at any address without a dynamic linker.
17653For predictable results, you must also specify the same set of options
17654used for compilation (@option{-fpie}, @option{-fPIE}, or model
17655suboptions) when you specify this linker option.
17656
17657@item -pthread
17658@opindex pthread
17659Link with the POSIX threads library. This option is supported on
17660GNU/Linux targets, most other Unix derivatives, and also on
17661x86 Cygwin and MinGW targets. On some targets this option also sets
17662flags for the preprocessor, so it should be used consistently for both
17663compilation and linking.
17664
17665@item -r
17666@opindex r
17667Produce a relocatable object as output. This is also known as partial
17668linking.
17669
17670@item -rdynamic
17671@opindex rdynamic
17672Pass the flag @option{-export-dynamic} to the ELF linker, on targets
17673that support it. This instructs the linker to add all symbols, not
17674only used ones, to the dynamic symbol table. This option is needed
17675for some uses of @code{dlopen} or to allow obtaining backtraces
17676from within a program.
17677
17678@item -s
17679@opindex s
17680Remove all symbol table and relocation information from the executable.
17681
17682@item -static
17683@opindex static
17684On systems that support dynamic linking, this overrides @option{-pie}
17685and prevents linking with the shared libraries. On other systems, this
17686option has no effect.
17687
17688@item -shared
17689@opindex shared
17690Produce a shared object which can then be linked with other objects to
17691form an executable. Not all systems support this option. For predictable
17692results, you must also specify the same set of options used for compilation
17693(@option{-fpic}, @option{-fPIC}, or model suboptions) when
17694you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
17695needs to build supplementary stub code for constructors to work. On
17696multi-libbed systems, @samp{gcc -shared} must select the correct support
17697libraries to link against. Failing to supply the correct flags may lead
17698to subtle defects. Supplying them in cases where they are not necessary
88b531d0 17699is innocuous. For x86, crtfastmath.o will not be added when
17700@option{-shared} is specified. }
d77de738
ML
17701
17702@item -shared-libgcc
17703@itemx -static-libgcc
17704@opindex shared-libgcc
17705@opindex static-libgcc
17706On systems that provide @file{libgcc} as a shared library, these options
17707force the use of either the shared or static version, respectively.
17708If no shared version of @file{libgcc} was built when the compiler was
17709configured, these options have no effect.
17710
17711There are several situations in which an application should use the
17712shared @file{libgcc} instead of the static version. The most common
17713of these is when the application wishes to throw and catch exceptions
17714across different shared libraries. In that case, each of the libraries
17715as well as the application itself should use the shared @file{libgcc}.
17716
17717Therefore, the G++ driver automatically adds @option{-shared-libgcc}
17718whenever you build a shared library or a main executable, because C++
17719programs typically use exceptions, so this is the right thing to do.
17720
17721If, instead, you use the GCC driver to create shared libraries, you may
17722find that they are not always linked with the shared @file{libgcc}.
17723If GCC finds, at its configuration time, that you have a non-GNU linker
17724or a GNU linker that does not support option @option{--eh-frame-hdr},
17725it links the shared version of @file{libgcc} into shared libraries
17726by default. Otherwise, it takes advantage of the linker and optimizes
17727away the linking with the shared version of @file{libgcc}, linking with
17728the static version of libgcc by default. This allows exceptions to
17729propagate through such shared libraries, without incurring relocation
17730costs at library load time.
17731
17732However, if a library or main executable is supposed to throw or catch
17733exceptions, you must link it using the G++ driver, or using the option
17734@option{-shared-libgcc}, such that it is linked with the shared
17735@file{libgcc}.
17736
17737@item -static-libasan
17738@opindex static-libasan
17739When the @option{-fsanitize=address} option is used to link a program,
17740the GCC driver automatically links against @option{libasan}. If
17741@file{libasan} is available as a shared library, and the @option{-static}
17742option is not used, then this links against the shared version of
17743@file{libasan}. The @option{-static-libasan} option directs the GCC
17744driver to link @file{libasan} statically, without necessarily linking
17745other libraries statically.
17746
17747@item -static-libtsan
17748@opindex static-libtsan
17749When the @option{-fsanitize=thread} option is used to link a program,
17750the GCC driver automatically links against @option{libtsan}. If
17751@file{libtsan} is available as a shared library, and the @option{-static}
17752option is not used, then this links against the shared version of
17753@file{libtsan}. The @option{-static-libtsan} option directs the GCC
17754driver to link @file{libtsan} statically, without necessarily linking
17755other libraries statically.
17756
17757@item -static-liblsan
17758@opindex static-liblsan
17759When the @option{-fsanitize=leak} option is used to link a program,
17760the GCC driver automatically links against @option{liblsan}. If
17761@file{liblsan} is available as a shared library, and the @option{-static}
17762option is not used, then this links against the shared version of
17763@file{liblsan}. The @option{-static-liblsan} option directs the GCC
17764driver to link @file{liblsan} statically, without necessarily linking
17765other libraries statically.
17766
17767@item -static-libubsan
17768@opindex static-libubsan
17769When the @option{-fsanitize=undefined} option is used to link a program,
17770the GCC driver automatically links against @option{libubsan}. If
17771@file{libubsan} is available as a shared library, and the @option{-static}
17772option is not used, then this links against the shared version of
17773@file{libubsan}. The @option{-static-libubsan} option directs the GCC
17774driver to link @file{libubsan} statically, without necessarily linking
17775other libraries statically.
17776
17777@item -static-libstdc++
17778@opindex static-libstdc++
17779When the @command{g++} program is used to link a C++ program, it
17780normally automatically links against @option{libstdc++}. If
17781@file{libstdc++} is available as a shared library, and the
17782@option{-static} option is not used, then this links against the
17783shared version of @file{libstdc++}. That is normally fine. However, it
17784is sometimes useful to freeze the version of @file{libstdc++} used by
17785the program without going all the way to a fully static link. The
17786@option{-static-libstdc++} option directs the @command{g++} driver to
17787link @file{libstdc++} statically, without necessarily linking other
17788libraries statically.
17789
17790@item -symbolic
17791@opindex symbolic
17792Bind references to global symbols when building a shared object. Warn
17793about any unresolved references (unless overridden by the link editor
17794option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
17795this option.
17796
17797@item -T @var{script}
17798@opindex T
17799@cindex linker script
17800Use @var{script} as the linker script. This option is supported by most
17801systems using the GNU linker. On some targets, such as bare-board
17802targets without an operating system, the @option{-T} option may be required
17803when linking to avoid references to undefined symbols.
17804
17805@item -Xlinker @var{option}
17806@opindex Xlinker
17807Pass @var{option} as an option to the linker. You can use this to
17808supply system-specific linker options that GCC does not recognize.
17809
17810If you want to pass an option that takes a separate argument, you must use
17811@option{-Xlinker} twice, once for the option and once for the argument.
17812For example, to pass @option{-assert definitions}, you must write
17813@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
17814@option{-Xlinker "-assert definitions"}, because this passes the entire
17815string as a single argument, which is not what the linker expects.
17816
17817When using the GNU linker, it is usually more convenient to pass
17818arguments to linker options using the @option{@var{option}=@var{value}}
17819syntax than as separate arguments. For example, you can specify
17820@option{-Xlinker -Map=output.map} rather than
17821@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
17822this syntax for command-line options.
17823
17824@item -Wl,@var{option}
17825@opindex Wl
17826Pass @var{option} as an option to the linker. If @var{option} contains
17827commas, it is split into multiple options at the commas. You can use this
17828syntax to pass an argument to the option.
17829For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
17830linker. When using the GNU linker, you can also get the same effect with
17831@option{-Wl,-Map=output.map}.
17832
17833@item -u @var{symbol}
17834@opindex u
17835Pretend the symbol @var{symbol} is undefined, to force linking of
17836library modules to define it. You can use @option{-u} multiple times with
17837different symbols to force loading of additional library modules.
17838
17839@item -z @var{keyword}
17840@opindex z
17841@option{-z} is passed directly on to the linker along with the keyword
17842@var{keyword}. See the section in the documentation of your linker for
17843permitted values and their meanings.
17844@end table
17845
17846@node Directory Options
17847@section Options for Directory Search
17848@cindex directory options
17849@cindex options, directory search
17850@cindex search path
17851
17852These options specify directories to search for header files, for
17853libraries and for parts of the compiler:
17854
17855@table @gcctabopt
17856@include cppdiropts.texi
17857
17858@item -iplugindir=@var{dir}
17859@opindex iplugindir=
17860Set the directory to search for plugins that are passed
17861by @option{-fplugin=@var{name}} instead of
17862@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
17863to be used by the user, but only passed by the driver.
17864
17865@item -L@var{dir}
17866@opindex L
17867Add directory @var{dir} to the list of directories to be searched
17868for @option{-l}.
17869
17870@item -B@var{prefix}
17871@opindex B
17872This option specifies where to find the executables, libraries,
17873include files, and data files of the compiler itself.
17874
17875The compiler driver program runs one or more of the subprograms
17876@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
17877@var{prefix} as a prefix for each program it tries to run, both with and
17878without @samp{@var{machine}/@var{version}/} for the corresponding target
17879machine and compiler version.
17880
17881For each subprogram to be run, the compiler driver first tries the
17882@option{-B} prefix, if any. If that name is not found, or if @option{-B}
17883is not specified, the driver tries two standard prefixes,
17884@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
17885those results in a file name that is found, the unmodified program
17886name is searched for using the directories specified in your
17887@env{PATH} environment variable.
17888
17889The compiler checks to see if the path provided by @option{-B}
17890refers to a directory, and if necessary it adds a directory
17891separator character at the end of the path.
17892
17893@option{-B} prefixes that effectively specify directory names also apply
17894to libraries in the linker, because the compiler translates these
17895options into @option{-L} options for the linker. They also apply to
17896include files in the preprocessor, because the compiler translates these
17897options into @option{-isystem} options for the preprocessor. In this case,
17898the compiler appends @samp{include} to the prefix.
17899
17900The runtime support file @file{libgcc.a} can also be searched for using
17901the @option{-B} prefix, if needed. If it is not found there, the two
17902standard prefixes above are tried, and that is all. The file is left
17903out of the link if it is not found by those means.
17904
17905Another way to specify a prefix much like the @option{-B} prefix is to use
17906the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
17907Variables}.
17908
17909As a special kludge, if the path provided by @option{-B} is
17910@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
179119, then it is replaced by @file{[dir/]include}. This is to help
17912with boot-strapping the compiler.
17913
17914@item -no-canonical-prefixes
17915@opindex no-canonical-prefixes
17916Do not expand any symbolic links, resolve references to @samp{/../}
17917or @samp{/./}, or make the path absolute when generating a relative
17918prefix.
17919
17920@item --sysroot=@var{dir}
17921@opindex sysroot
17922Use @var{dir} as the logical root directory for headers and libraries.
17923For example, if the compiler normally searches for headers in
17924@file{/usr/include} and libraries in @file{/usr/lib}, it instead
17925searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
17926
17927If you use both this option and the @option{-isysroot} option, then
17928the @option{--sysroot} option applies to libraries, but the
17929@option{-isysroot} option applies to header files.
17930
17931The GNU linker (beginning with version 2.16) has the necessary support
17932for this option. If your linker does not support this option, the
17933header file aspect of @option{--sysroot} still works, but the
17934library aspect does not.
17935
17936@item --no-sysroot-suffix
17937@opindex no-sysroot-suffix
17938For some targets, a suffix is added to the root directory specified
17939with @option{--sysroot}, depending on the other options used, so that
17940headers may for example be found in
17941@file{@var{dir}/@var{suffix}/usr/include} instead of
17942@file{@var{dir}/usr/include}. This option disables the addition of
17943such a suffix.
17944
17945@end table
17946
17947@node Code Gen Options
17948@section Options for Code Generation Conventions
17949@cindex code generation conventions
17950@cindex options, code generation
17951@cindex run-time options
17952
17953These machine-independent options control the interface conventions
17954used in code generation.
17955
17956Most of them have both positive and negative forms; the negative form
17957of @option{-ffoo} is @option{-fno-foo}. In the table below, only
17958one of the forms is listed---the one that is not the default. You
17959can figure out the other form by either removing @samp{no-} or adding
17960it.
17961
17962@table @gcctabopt
17963@item -fstack-reuse=@var{reuse-level}
17964@opindex fstack_reuse
17965This option controls stack space reuse for user declared local/auto variables
17966and compiler generated temporaries. @var{reuse_level} can be @samp{all},
17967@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
17968local variables and temporaries, @samp{named_vars} enables the reuse only for
17969user defined local variables with names, and @samp{none} disables stack reuse
17970completely. The default value is @samp{all}. The option is needed when the
17971program extends the lifetime of a scoped local variable or a compiler generated
17972temporary beyond the end point defined by the language. When a lifetime of
17973a variable ends, and if the variable lives in memory, the optimizing compiler
17974has the freedom to reuse its stack space with other temporaries or scoped
17975local variables whose live range does not overlap with it. Legacy code extending
17976local lifetime is likely to break with the stack reuse optimization.
17977
17978For example,
17979
17980@smallexample
17981 int *p;
17982 @{
17983 int local1;
17984
17985 p = &local1;
17986 local1 = 10;
17987 ....
17988 @}
17989 @{
17990 int local2;
17991 local2 = 20;
17992 ...
17993 @}
17994
17995 if (*p == 10) // out of scope use of local1
17996 @{
17997
17998 @}
17999@end smallexample
18000
18001Another example:
18002@smallexample
18003
18004 struct A
18005 @{
18006 A(int k) : i(k), j(k) @{ @}
18007 int i;
18008 int j;
18009 @};
18010
18011 A *ap;
18012
18013 void foo(const A& ar)
18014 @{
18015 ap = &ar;
18016 @}
18017
18018 void bar()
18019 @{
18020 foo(A(10)); // temp object's lifetime ends when foo returns
18021
18022 @{
18023 A a(20);
18024 ....
18025 @}
18026 ap->i+= 10; // ap references out of scope temp whose space
18027 // is reused with a. What is the value of ap->i?
18028 @}
18029
18030@end smallexample
18031
18032The lifetime of a compiler generated temporary is well defined by the C++
18033standard. When a lifetime of a temporary ends, and if the temporary lives
18034in memory, the optimizing compiler has the freedom to reuse its stack
18035space with other temporaries or scoped local variables whose live range
18036does not overlap with it. However some of the legacy code relies on
18037the behavior of older compilers in which temporaries' stack space is
18038not reused, the aggressive stack reuse can lead to runtime errors. This
18039option is used to control the temporary stack reuse optimization.
18040
18041@item -ftrapv
18042@opindex ftrapv
18043This option generates traps for signed overflow on addition, subtraction,
18044multiplication operations.
18045The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18046@option{-ftrapv} @option{-fwrapv} on the command-line results in
18047@option{-fwrapv} being effective. Note that only active options override, so
18048using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18049results in @option{-ftrapv} being effective.
18050
18051@item -fwrapv
18052@opindex fwrapv
18053This option instructs the compiler to assume that signed arithmetic
18054overflow of addition, subtraction and multiplication wraps around
18055using twos-complement representation. This flag enables some optimizations
18056and disables others.
18057The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18058@option{-ftrapv} @option{-fwrapv} on the command-line results in
18059@option{-fwrapv} being effective. Note that only active options override, so
18060using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18061results in @option{-ftrapv} being effective.
18062
18063@item -fwrapv-pointer
18064@opindex fwrapv-pointer
18065This option instructs the compiler to assume that pointer arithmetic
18066overflow on addition and subtraction wraps around using twos-complement
18067representation. This flag disables some optimizations which assume
18068pointer overflow is invalid.
18069
18070@item -fstrict-overflow
18071@opindex fstrict-overflow
18072This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18073negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18074
18075@item -fexceptions
18076@opindex fexceptions
18077Enable exception handling. Generates extra code needed to propagate
18078exceptions. For some targets, this implies GCC generates frame
18079unwind information for all functions, which can produce significant data
18080size overhead, although it does not affect execution. If you do not
18081specify this option, GCC enables it by default for languages like
18082C++ that normally require exception handling, and disables it for
18083languages like C that do not normally require it. However, you may need
18084to enable this option when compiling C code that needs to interoperate
18085properly with exception handlers written in C++. You may also wish to
18086disable this option if you are compiling older C++ programs that don't
18087use exception handling.
18088
18089@item -fnon-call-exceptions
18090@opindex fnon-call-exceptions
18091Generate code that allows trapping instructions to throw exceptions.
18092Note that this requires platform-specific runtime support that does
18093not exist everywhere. Moreover, it only allows @emph{trapping}
18094instructions to throw exceptions, i.e.@: memory references or floating-point
18095instructions. It does not allow exceptions to be thrown from
18096arbitrary signal handlers such as @code{SIGALRM}. This enables
18097@option{-fexceptions}.
18098
18099@item -fdelete-dead-exceptions
18100@opindex fdelete-dead-exceptions
18101Consider that instructions that may throw exceptions but don't otherwise
18102contribute to the execution of the program can be optimized away.
18103This does not affect calls to functions except those with the
18104@code{pure} or @code{const} attributes.
18105This option is enabled by default for the Ada and C++ compilers, as permitted by
18106the language specifications.
18107Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18108
18109@item -funwind-tables
18110@opindex funwind-tables
18111Similar to @option{-fexceptions}, except that it just generates any needed
18112static data, but does not affect the generated code in any other way.
18113You normally do not need to enable this option; instead, a language processor
18114that needs this handling enables it on your behalf.
18115
18116@item -fasynchronous-unwind-tables
18117@opindex fasynchronous-unwind-tables
18118Generate unwind table in DWARF format, if supported by target machine. The
18119table is exact at each instruction boundary, so it can be used for stack
18120unwinding from asynchronous events (such as debugger or garbage collector).
18121
18122@item -fno-gnu-unique
18123@opindex fno-gnu-unique
18124@opindex fgnu-unique
18125On systems with recent GNU assembler and C library, the C++ compiler
18126uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18127of template static data members and static local variables in inline
18128functions are unique even in the presence of @code{RTLD_LOCAL}; this
18129is necessary to avoid problems with a library used by two different
18130@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18131therefore disagreeing with the other one about the binding of the
18132symbol. But this causes @code{dlclose} to be ignored for affected
18133DSOs; if your program relies on reinitialization of a DSO via
18134@code{dlclose} and @code{dlopen}, you can use
18135@option{-fno-gnu-unique}.
18136
18137@item -fpcc-struct-return
18138@opindex fpcc-struct-return
18139Return ``short'' @code{struct} and @code{union} values in memory like
18140longer ones, rather than in registers. This convention is less
18141efficient, but it has the advantage of allowing intercallability between
18142GCC-compiled files and files compiled with other compilers, particularly
18143the Portable C Compiler (pcc).
18144
18145The precise convention for returning structures in memory depends
18146on the target configuration macros.
18147
18148Short structures and unions are those whose size and alignment match
18149that of some integer type.
18150
18151@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18152switch is not binary compatible with code compiled with the
18153@option{-freg-struct-return} switch.
18154Use it to conform to a non-default application binary interface.
18155
18156@item -freg-struct-return
18157@opindex freg-struct-return
18158Return @code{struct} and @code{union} values in registers when possible.
18159This is more efficient for small structures than
18160@option{-fpcc-struct-return}.
18161
18162If you specify neither @option{-fpcc-struct-return} nor
18163@option{-freg-struct-return}, GCC defaults to whichever convention is
18164standard for the target. If there is no standard convention, GCC
18165defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18166the principal compiler. In those cases, we can choose the standard, and
18167we chose the more efficient register return alternative.
18168
18169@strong{Warning:} code compiled with the @option{-freg-struct-return}
18170switch is not binary compatible with code compiled with the
18171@option{-fpcc-struct-return} switch.
18172Use it to conform to a non-default application binary interface.
18173
18174@item -fshort-enums
18175@opindex fshort-enums
18176Allocate to an @code{enum} type only as many bytes as it needs for the
18177declared range of possible values. Specifically, the @code{enum} type
18178is equivalent to the smallest integer type that has enough room.
18179
18180@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18181code that is not binary compatible with code generated without that switch.
18182Use it to conform to a non-default application binary interface.
18183
18184@item -fshort-wchar
18185@opindex fshort-wchar
18186Override the underlying type for @code{wchar_t} to be @code{short
18187unsigned int} instead of the default for the target. This option is
18188useful for building programs to run under WINE@.
18189
18190@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18191code that is not binary compatible with code generated without that switch.
18192Use it to conform to a non-default application binary interface.
18193
18194@item -fcommon
18195@opindex fcommon
18196@opindex fno-common
18197@cindex tentative definitions
18198In C code, this option controls the placement of global variables
18199defined without an initializer, known as @dfn{tentative definitions}
18200in the C standard. Tentative definitions are distinct from declarations
18201of a variable with the @code{extern} keyword, which do not allocate storage.
18202
18203The default is @option{-fno-common}, which specifies that the compiler places
18204uninitialized global variables in the BSS section of the object file.
18205This inhibits the merging of tentative definitions by the linker so you get a
18206multiple-definition error if the same variable is accidentally defined in more
18207than one compilation unit.
18208
18209The @option{-fcommon} places uninitialized global variables in a common block.
18210This allows the linker to resolve all tentative definitions of the same variable
18211in different compilation units to the same object, or to a non-tentative
18212definition. This behavior is inconsistent with C++, and on many targets implies
18213a speed and code size penalty on global variable references. It is mainly
18214useful to enable legacy code to link without errors.
18215
18216@item -fno-ident
18217@opindex fno-ident
18218@opindex fident
18219Ignore the @code{#ident} directive.
18220
18221@item -finhibit-size-directive
18222@opindex finhibit-size-directive
18223Don't output a @code{.size} assembler directive, or anything else that
18224would cause trouble if the function is split in the middle, and the
18225two halves are placed at locations far apart in memory. This option is
18226used when compiling @file{crtstuff.c}; you should not need to use it
18227for anything else.
18228
18229@item -fverbose-asm
18230@opindex fverbose-asm
18231Put extra commentary information in the generated assembly code to
18232make it more readable. This option is generally only of use to those
18233who actually need to read the generated assembly code (perhaps while
18234debugging the compiler itself).
18235
18236@option{-fno-verbose-asm}, the default, causes the
18237extra information to be omitted and is useful when comparing two assembler
18238files.
18239
18240The added comments include:
18241
18242@itemize @bullet
18243
18244@item
18245information on the compiler version and command-line options,
18246
18247@item
18248the source code lines associated with the assembly instructions,
18249in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18250
18251@item
18252hints on which high-level expressions correspond to
18253the various assembly instruction operands.
18254
18255@end itemize
18256
18257For example, given this C source file:
18258
18259@smallexample
18260int test (int n)
18261@{
18262 int i;
18263 int total = 0;
18264
18265 for (i = 0; i < n; i++)
18266 total += i * i;
18267
18268 return total;
18269@}
18270@end smallexample
18271
18272compiling to (x86_64) assembly via @option{-S} and emitting the result
18273direct to stdout via @option{-o} @option{-}
18274
18275@smallexample
18276gcc -S test.c -fverbose-asm -Os -o -
18277@end smallexample
18278
18279gives output similar to this:
18280
18281@smallexample
18282 .file "test.c"
18283# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18284 [...snip...]
18285# options passed:
18286 [...snip...]
18287
18288 .text
18289 .globl test
18290 .type test, @@function
18291test:
18292.LFB0:
18293 .cfi_startproc
18294# test.c:4: int total = 0;
18295 xorl %eax, %eax # <retval>
18296# test.c:6: for (i = 0; i < n; i++)
18297 xorl %edx, %edx # i
18298.L2:
18299# test.c:6: for (i = 0; i < n; i++)
18300 cmpl %edi, %edx # n, i
18301 jge .L5 #,
18302# test.c:7: total += i * i;
18303 movl %edx, %ecx # i, tmp92
18304 imull %edx, %ecx # i, tmp92
18305# test.c:6: for (i = 0; i < n; i++)
18306 incl %edx # i
18307# test.c:7: total += i * i;
18308 addl %ecx, %eax # tmp92, <retval>
18309 jmp .L2 #
18310.L5:
18311# test.c:10: @}
18312 ret
18313 .cfi_endproc
18314.LFE0:
18315 .size test, .-test
18316 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18317 .section .note.GNU-stack,"",@@progbits
18318@end smallexample
18319
18320The comments are intended for humans rather than machines and hence the
18321precise format of the comments is subject to change.
18322
18323@item -frecord-gcc-switches
18324@opindex frecord-gcc-switches
18325This switch causes the command line used to invoke the
18326compiler to be recorded into the object file that is being created.
18327This switch is only implemented on some targets and the exact format
18328of the recording is target and binary file format dependent, but it
18329usually takes the form of a section containing ASCII text. This
18330switch is related to the @option{-fverbose-asm} switch, but that
18331switch only records information in the assembler output file as
18332comments, so it never reaches the object file.
18333See also @option{-grecord-gcc-switches} for another
18334way of storing compiler options into the object file.
18335
18336@item -fpic
18337@opindex fpic
18338@cindex global offset table
18339@cindex PIC
18340Generate position-independent code (PIC) suitable for use in a shared
18341library, if supported for the target machine. Such code accesses all
18342constant addresses through a global offset table (GOT)@. The dynamic
18343loader resolves the GOT entries when the program starts (the dynamic
18344loader is not part of GCC; it is part of the operating system). If
18345the GOT size for the linked executable exceeds a machine-specific
18346maximum size, you get an error message from the linker indicating that
18347@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18348instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18349on the m68k and RS/6000. The x86 has no such limit.)
18350
18351Position-independent code requires special support, and therefore works
18352only on certain machines. For the x86, GCC supports PIC for System V
18353but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18354position-independent.
18355
18356When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18357are defined to 1.
18358
18359@item -fPIC
18360@opindex fPIC
18361If supported for the target machine, emit position-independent code,
18362suitable for dynamic linking and avoiding any limit on the size of the
18363global offset table. This option makes a difference on AArch64, m68k,
18364PowerPC and SPARC@.
18365
18366Position-independent code requires special support, and therefore works
18367only on certain machines.
18368
18369When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18370are defined to 2.
18371
18372@item -fpie
18373@itemx -fPIE
18374@opindex fpie
18375@opindex fPIE
18376These options are similar to @option{-fpic} and @option{-fPIC}, but the
18377generated position-independent code can be only linked into executables.
18378Usually these options are used to compile code that will be linked using
18379the @option{-pie} GCC option.
18380
18381@option{-fpie} and @option{-fPIE} both define the macros
18382@code{__pie__} and @code{__PIE__}. The macros have the value 1
18383for @option{-fpie} and 2 for @option{-fPIE}.
18384
18385@item -fno-plt
18386@opindex fno-plt
18387@opindex fplt
18388Do not use the PLT for external function calls in position-independent code.
18389Instead, load the callee address at call sites from the GOT and branch to it.
18390This leads to more efficient code by eliminating PLT stubs and exposing
18391GOT loads to optimizations. On architectures such as 32-bit x86 where
18392PLT stubs expect the GOT pointer in a specific register, this gives more
18393register allocation freedom to the compiler.
18394Lazy binding requires use of the PLT;
18395with @option{-fno-plt} all external symbols are resolved at load time.
18396
18397Alternatively, the function attribute @code{noplt} can be used to avoid calls
18398through the PLT for specific external functions.
18399
18400In position-dependent code, a few targets also convert calls to
18401functions that are marked to not use the PLT to use the GOT instead.
18402
18403@item -fno-jump-tables
18404@opindex fno-jump-tables
18405@opindex fjump-tables
18406Do not use jump tables for switch statements even where it would be
18407more efficient than other code generation strategies. This option is
18408of use in conjunction with @option{-fpic} or @option{-fPIC} for
18409building code that forms part of a dynamic linker and cannot
18410reference the address of a jump table. On some targets, jump tables
18411do not require a GOT and this option is not needed.
18412
18413@item -fno-bit-tests
18414@opindex fno-bit-tests
18415@opindex fbit-tests
18416Do not use bit tests for switch statements even where it would be
18417more efficient than other code generation strategies.
18418
18419@item -ffixed-@var{reg}
18420@opindex ffixed
18421Treat the register named @var{reg} as a fixed register; generated code
18422should never refer to it (except perhaps as a stack pointer, frame
18423pointer or in some other fixed role).
18424
18425@var{reg} must be the name of a register. The register names accepted
18426are machine-specific and are defined in the @code{REGISTER_NAMES}
18427macro in the machine description macro file.
18428
18429This flag does not have a negative form, because it specifies a
18430three-way choice.
18431
18432@item -fcall-used-@var{reg}
18433@opindex fcall-used
18434Treat the register named @var{reg} as an allocable register that is
18435clobbered by function calls. It may be allocated for temporaries or
18436variables that do not live across a call. Functions compiled this way
18437do not save and restore the register @var{reg}.
18438
18439It is an error to use this flag with the frame pointer or stack pointer.
18440Use of this flag for other registers that have fixed pervasive roles in
18441the machine's execution model produces disastrous results.
18442
18443This flag does not have a negative form, because it specifies a
18444three-way choice.
18445
18446@item -fcall-saved-@var{reg}
18447@opindex fcall-saved
18448Treat the register named @var{reg} as an allocable register saved by
18449functions. It may be allocated even for temporaries or variables that
18450live across a call. Functions compiled this way save and restore
18451the register @var{reg} if they use it.
18452
18453It is an error to use this flag with the frame pointer or stack pointer.
18454Use of this flag for other registers that have fixed pervasive roles in
18455the machine's execution model produces disastrous results.
18456
18457A different sort of disaster results from the use of this flag for
18458a register in which function values may be returned.
18459
18460This flag does not have a negative form, because it specifies a
18461three-way choice.
18462
18463@item -fpack-struct[=@var{n}]
18464@opindex fpack-struct
18465Without a value specified, pack all structure members together without
18466holes. When a value is specified (which must be a small power of two), pack
18467structure members according to this value, representing the maximum
18468alignment (that is, objects with default alignment requirements larger than
18469this are output potentially unaligned at the next fitting location.
18470
18471@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18472code that is not binary compatible with code generated without that switch.
18473Additionally, it makes the code suboptimal.
18474Use it to conform to a non-default application binary interface.
18475
18476@item -fleading-underscore
18477@opindex fleading-underscore
18478This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18479change the way C symbols are represented in the object file. One use
18480is to help link with legacy assembly code.
18481
18482@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18483generate code that is not binary compatible with code generated without that
18484switch. Use it to conform to a non-default application binary interface.
18485Not all targets provide complete support for this switch.
18486
18487@item -ftls-model=@var{model}
18488@opindex ftls-model
18489Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18490The @var{model} argument should be one of @samp{global-dynamic},
18491@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18492Note that the choice is subject to optimization: the compiler may use
18493a more efficient model for symbols not visible outside of the translation
18494unit, or if @option{-fpic} is not given on the command line.
18495
18496The default without @option{-fpic} is @samp{initial-exec}; with
18497@option{-fpic} the default is @samp{global-dynamic}.
18498
18499@item -ftrampolines
18500@opindex ftrampolines
18501For targets that normally need trampolines for nested functions, always
18502generate them instead of using descriptors. Otherwise, for targets that
18503do not need them, like for example HP-PA or IA-64, do nothing.
18504
18505A trampoline is a small piece of code that is created at run time on the
18506stack when the address of a nested function is taken, and is used to call
18507the nested function indirectly. Therefore, it requires the stack to be
18508made executable in order for the program to work properly.
18509
18510@option{-fno-trampolines} is enabled by default on a language by language
18511basis to let the compiler avoid generating them, if it computes that this
18512is safe, and replace them with descriptors. Descriptors are made up of data
18513only, but the generated code must be prepared to deal with them. As of this
18514writing, @option{-fno-trampolines} is enabled by default only for Ada.
18515
18516Moreover, code compiled with @option{-ftrampolines} and code compiled with
18517@option{-fno-trampolines} are not binary compatible if nested functions are
18518present. This option must therefore be used on a program-wide basis and be
18519manipulated with extreme care.
18520
18521For languages other than Ada, the @code{-ftrampolines} and
18522@code{-fno-trampolines} options currently have no effect, and
18523trampolines are always generated on platforms that need them
18524for nested functions.
18525
18526@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
18527@opindex fvisibility
18528Set the default ELF image symbol visibility to the specified option---all
18529symbols are marked with this unless overridden within the code.
18530Using this feature can very substantially improve linking and
18531load times of shared object libraries, produce more optimized
18532code, provide near-perfect API export and prevent symbol clashes.
18533It is @strong{strongly} recommended that you use this in any shared objects
18534you distribute.
18535
18536Despite the nomenclature, @samp{default} always means public; i.e.,
18537available to be linked against from outside the shared object.
18538@samp{protected} and @samp{internal} are pretty useless in real-world
18539usage so the only other commonly used option is @samp{hidden}.
18540The default if @option{-fvisibility} isn't specified is
18541@samp{default}, i.e., make every symbol public.
18542
18543A good explanation of the benefits offered by ensuring ELF
18544symbols have the correct visibility is given by ``How To Write
18545Shared Libraries'' by Ulrich Drepper (which can be found at
18546@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18547solution made possible by this option to marking things hidden when
18548the default is public is to make the default hidden and mark things
18549public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18550and @code{__attribute__ ((visibility("default")))} instead of
18551@code{__declspec(dllexport)} you get almost identical semantics with
18552identical syntax. This is a great boon to those working with
18553cross-platform projects.
18554
18555For those adding visibility support to existing code, you may find
18556@code{#pragma GCC visibility} of use. This works by you enclosing
18557the declarations you wish to set visibility for with (for example)
18558@code{#pragma GCC visibility push(hidden)} and
18559@code{#pragma GCC visibility pop}.
18560Bear in mind that symbol visibility should be viewed @strong{as
18561part of the API interface contract} and thus all new code should
18562always specify visibility when it is not the default; i.e., declarations
18563only for use within the local DSO should @strong{always} be marked explicitly
18564as hidden as so to avoid PLT indirection overheads---making this
18565abundantly clear also aids readability and self-documentation of the code.
18566Note that due to ISO C++ specification requirements, @code{operator new} and
18567@code{operator delete} must always be of default visibility.
18568
18569Be aware that headers from outside your project, in particular system
18570headers and headers from any other library you use, may not be
18571expecting to be compiled with visibility other than the default. You
18572may need to explicitly say @code{#pragma GCC visibility push(default)}
18573before including any such headers.
18574
18575@code{extern} declarations are not affected by @option{-fvisibility}, so
18576a lot of code can be recompiled with @option{-fvisibility=hidden} with
18577no modifications. However, this means that calls to @code{extern}
18578functions with no explicit visibility use the PLT, so it is more
18579effective to use @code{__attribute ((visibility))} and/or
18580@code{#pragma GCC visibility} to tell the compiler which @code{extern}
18581declarations should be treated as hidden.
18582
18583Note that @option{-fvisibility} does affect C++ vague linkage
18584entities. This means that, for instance, an exception class that is
18585be thrown between DSOs must be explicitly marked with default
18586visibility so that the @samp{type_info} nodes are unified between
18587the DSOs.
18588
18589An overview of these techniques, their benefits and how to use them
18590is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
18591
18592@item -fstrict-volatile-bitfields
18593@opindex fstrict-volatile-bitfields
18594This option should be used if accesses to volatile bit-fields (or other
18595structure fields, although the compiler usually honors those types
18596anyway) should use a single access of the width of the
18597field's type, aligned to a natural alignment if possible. For
18598example, targets with memory-mapped peripheral registers might require
18599all such accesses to be 16 bits wide; with this flag you can
18600declare all peripheral bit-fields as @code{unsigned short} (assuming short
18601is 16 bits on these targets) to force GCC to use 16-bit accesses
18602instead of, perhaps, a more efficient 32-bit access.
18603
18604If this option is disabled, the compiler uses the most efficient
18605instruction. In the previous example, that might be a 32-bit load
18606instruction, even though that accesses bytes that do not contain
18607any portion of the bit-field, or memory-mapped registers unrelated to
18608the one being updated.
18609
18610In some cases, such as when the @code{packed} attribute is applied to a
18611structure field, it may not be possible to access the field with a single
18612read or write that is correctly aligned for the target machine. In this
18613case GCC falls back to generating multiple accesses rather than code that
18614will fault or truncate the result at run time.
18615
18616Note: Due to restrictions of the C/C++11 memory model, write accesses are
18617not allowed to touch non bit-field members. It is therefore recommended
18618to define all bits of the field's type as bit-field members.
18619
18620The default value of this option is determined by the application binary
18621interface for the target processor.
18622
18623@item -fsync-libcalls
18624@opindex fsync-libcalls
18625This option controls whether any out-of-line instance of the @code{__sync}
18626family of functions may be used to implement the C++11 @code{__atomic}
18627family of functions.
18628
18629The default value of this option is enabled, thus the only useful form
18630of the option is @option{-fno-sync-libcalls}. This option is used in
18631the implementation of the @file{libatomic} runtime library.
18632
18633@end table
18634
18635@node Developer Options
18636@section GCC Developer Options
18637@cindex developer options
18638@cindex debugging GCC
18639@cindex debug dump options
18640@cindex dump options
18641@cindex compilation statistics
18642
18643This section describes command-line options that are primarily of
18644interest to GCC developers, including options to support compiler
18645testing and investigation of compiler bugs and compile-time
18646performance problems. This includes options that produce debug dumps
18647at various points in the compilation; that print statistics such as
18648memory use and execution time; and that print information about GCC's
18649configuration, such as where it searches for libraries. You should
18650rarely need to use any of these options for ordinary compilation and
18651linking tasks.
18652
18653Many developer options that cause GCC to dump output to a file take an
18654optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
18655or @samp{-} to dump to standard output, and @samp{stderr} for standard
18656error.
18657
18658If @samp{=@var{filename}} is omitted, a default dump file name is
18659constructed by concatenating the base dump file name, a pass number,
18660phase letter, and pass name. The base dump file name is the name of
18661output file produced by the compiler if explicitly specified and not
18662an executable; otherwise it is the source file name.
18663The pass number is determined by the order passes are registered with
18664the compiler's pass manager.
18665This is generally the same as the order of execution, but passes
18666registered by plugins, target-specific passes, or passes that are
18667otherwise registered late are numbered higher than the pass named
18668@samp{final}, even if they are executed earlier. The phase letter is
18669one of @samp{i} (inter-procedural analysis), @samp{l}
18670(language-specific), @samp{r} (RTL), or @samp{t} (tree).
18671The files are created in the directory of the output file.
18672
18673@table @gcctabopt
18674
18675@item -fcallgraph-info
18676@itemx -fcallgraph-info=@var{MARKERS}
18677@opindex fcallgraph-info
18678Makes the compiler output callgraph information for the program, on a
18679per-object-file basis. The information is generated in the common VCG
18680format. It can be decorated with additional, per-node and/or per-edge
18681information, if a list of comma-separated markers is additionally
18682specified. When the @code{su} marker is specified, the callgraph is
18683decorated with stack usage information; it is equivalent to
18684@option{-fstack-usage}. When the @code{da} marker is specified, the
18685callgraph is decorated with information about dynamically allocated
18686objects.
18687
18688When compiling with @option{-flto}, no callgraph information is output
18689along with the object file. At LTO link time, @option{-fcallgraph-info}
18690may generate multiple callgraph information files next to intermediate
18691LTO output files.
18692
18693@item -d@var{letters}
18694@itemx -fdump-rtl-@var{pass}
18695@itemx -fdump-rtl-@var{pass}=@var{filename}
18696@opindex d
18697@opindex fdump-rtl-@var{pass}
18698Says to make debugging dumps during compilation at times specified by
18699@var{letters}. This is used for debugging the RTL-based passes of the
18700compiler.
18701
18702Some @option{-d@var{letters}} switches have different meaning when
18703@option{-E} is used for preprocessing. @xref{Preprocessor Options},
18704for information about preprocessor-specific dump options.
18705
18706Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
18707@option{-d} option @var{letters}. Here are the possible
18708letters for use in @var{pass} and @var{letters}, and their meanings:
18709
18710@table @gcctabopt
18711
18712@item -fdump-rtl-alignments
18713@opindex fdump-rtl-alignments
18714Dump after branch alignments have been computed.
18715
18716@item -fdump-rtl-asmcons
18717@opindex fdump-rtl-asmcons
18718Dump after fixing rtl statements that have unsatisfied in/out constraints.
18719
18720@item -fdump-rtl-auto_inc_dec
18721@opindex fdump-rtl-auto_inc_dec
18722Dump after auto-inc-dec discovery. This pass is only run on
18723architectures that have auto inc or auto dec instructions.
18724
18725@item -fdump-rtl-barriers
18726@opindex fdump-rtl-barriers
18727Dump after cleaning up the barrier instructions.
18728
18729@item -fdump-rtl-bbpart
18730@opindex fdump-rtl-bbpart
18731Dump after partitioning hot and cold basic blocks.
18732
18733@item -fdump-rtl-bbro
18734@opindex fdump-rtl-bbro
18735Dump after block reordering.
18736
18737@item -fdump-rtl-btl1
18738@itemx -fdump-rtl-btl2
18739@opindex fdump-rtl-btl2
18740@opindex fdump-rtl-btl2
18741@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
18742after the two branch
18743target load optimization passes.
18744
18745@item -fdump-rtl-bypass
18746@opindex fdump-rtl-bypass
18747Dump after jump bypassing and control flow optimizations.
18748
18749@item -fdump-rtl-combine
18750@opindex fdump-rtl-combine
18751Dump after the RTL instruction combination pass.
18752
18753@item -fdump-rtl-compgotos
18754@opindex fdump-rtl-compgotos
18755Dump after duplicating the computed gotos.
18756
18757@item -fdump-rtl-ce1
18758@itemx -fdump-rtl-ce2
18759@itemx -fdump-rtl-ce3
18760@opindex fdump-rtl-ce1
18761@opindex fdump-rtl-ce2
18762@opindex fdump-rtl-ce3
18763@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
18764@option{-fdump-rtl-ce3} enable dumping after the three
18765if conversion passes.
18766
18767@item -fdump-rtl-cprop_hardreg
18768@opindex fdump-rtl-cprop_hardreg
18769Dump after hard register copy propagation.
18770
18771@item -fdump-rtl-csa
18772@opindex fdump-rtl-csa
18773Dump after combining stack adjustments.
18774
18775@item -fdump-rtl-cse1
18776@itemx -fdump-rtl-cse2
18777@opindex fdump-rtl-cse1
18778@opindex fdump-rtl-cse2
18779@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
18780the two common subexpression elimination passes.
18781
18782@item -fdump-rtl-dce
18783@opindex fdump-rtl-dce
18784Dump after the standalone dead code elimination passes.
18785
18786@item -fdump-rtl-dbr
18787@opindex fdump-rtl-dbr
18788Dump after delayed branch scheduling.
18789
18790@item -fdump-rtl-dce1
18791@itemx -fdump-rtl-dce2
18792@opindex fdump-rtl-dce1
18793@opindex fdump-rtl-dce2
18794@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
18795the two dead store elimination passes.
18796
18797@item -fdump-rtl-eh
18798@opindex fdump-rtl-eh
18799Dump after finalization of EH handling code.
18800
18801@item -fdump-rtl-eh_ranges
18802@opindex fdump-rtl-eh_ranges
18803Dump after conversion of EH handling range regions.
18804
18805@item -fdump-rtl-expand
18806@opindex fdump-rtl-expand
18807Dump after RTL generation.
18808
18809@item -fdump-rtl-fwprop1
18810@itemx -fdump-rtl-fwprop2
18811@opindex fdump-rtl-fwprop1
18812@opindex fdump-rtl-fwprop2
18813@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
18814dumping after the two forward propagation passes.
18815
18816@item -fdump-rtl-gcse1
18817@itemx -fdump-rtl-gcse2
18818@opindex fdump-rtl-gcse1
18819@opindex fdump-rtl-gcse2
18820@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
18821after global common subexpression elimination.
18822
18823@item -fdump-rtl-init-regs
18824@opindex fdump-rtl-init-regs
18825Dump after the initialization of the registers.
18826
18827@item -fdump-rtl-initvals
18828@opindex fdump-rtl-initvals
18829Dump after the computation of the initial value sets.
18830
18831@item -fdump-rtl-into_cfglayout
18832@opindex fdump-rtl-into_cfglayout
18833Dump after converting to cfglayout mode.
18834
18835@item -fdump-rtl-ira
18836@opindex fdump-rtl-ira
18837Dump after iterated register allocation.
18838
18839@item -fdump-rtl-jump
18840@opindex fdump-rtl-jump
18841Dump after the second jump optimization.
18842
18843@item -fdump-rtl-loop2
18844@opindex fdump-rtl-loop2
18845@option{-fdump-rtl-loop2} enables dumping after the rtl
18846loop optimization passes.
18847
18848@item -fdump-rtl-mach
18849@opindex fdump-rtl-mach
18850Dump after performing the machine dependent reorganization pass, if that
18851pass exists.
18852
18853@item -fdump-rtl-mode_sw
18854@opindex fdump-rtl-mode_sw
18855Dump after removing redundant mode switches.
18856
18857@item -fdump-rtl-rnreg
18858@opindex fdump-rtl-rnreg
18859Dump after register renumbering.
18860
18861@item -fdump-rtl-outof_cfglayout
18862@opindex fdump-rtl-outof_cfglayout
18863Dump after converting from cfglayout mode.
18864
18865@item -fdump-rtl-peephole2
18866@opindex fdump-rtl-peephole2
18867Dump after the peephole pass.
18868
18869@item -fdump-rtl-postreload
18870@opindex fdump-rtl-postreload
18871Dump after post-reload optimizations.
18872
18873@item -fdump-rtl-pro_and_epilogue
18874@opindex fdump-rtl-pro_and_epilogue
18875Dump after generating the function prologues and epilogues.
18876
18877@item -fdump-rtl-sched1
18878@itemx -fdump-rtl-sched2
18879@opindex fdump-rtl-sched1
18880@opindex fdump-rtl-sched2
18881@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
18882after the basic block scheduling passes.
18883
18884@item -fdump-rtl-ree
18885@opindex fdump-rtl-ree
18886Dump after sign/zero extension elimination.
18887
18888@item -fdump-rtl-seqabstr
18889@opindex fdump-rtl-seqabstr
18890Dump after common sequence discovery.
18891
18892@item -fdump-rtl-shorten
18893@opindex fdump-rtl-shorten
18894Dump after shortening branches.
18895
18896@item -fdump-rtl-sibling
18897@opindex fdump-rtl-sibling
18898Dump after sibling call optimizations.
18899
18900@item -fdump-rtl-split1
18901@itemx -fdump-rtl-split2
18902@itemx -fdump-rtl-split3
18903@itemx -fdump-rtl-split4
18904@itemx -fdump-rtl-split5
18905@opindex fdump-rtl-split1
18906@opindex fdump-rtl-split2
18907@opindex fdump-rtl-split3
18908@opindex fdump-rtl-split4
18909@opindex fdump-rtl-split5
18910These options enable dumping after five rounds of
18911instruction splitting.
18912
18913@item -fdump-rtl-sms
18914@opindex fdump-rtl-sms
18915Dump after modulo scheduling. This pass is only run on some
18916architectures.
18917
18918@item -fdump-rtl-stack
18919@opindex fdump-rtl-stack
18920Dump after conversion from GCC's ``flat register file'' registers to the
18921x87's stack-like registers. This pass is only run on x86 variants.
18922
18923@item -fdump-rtl-subreg1
18924@itemx -fdump-rtl-subreg2
18925@opindex fdump-rtl-subreg1
18926@opindex fdump-rtl-subreg2
18927@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
18928the two subreg expansion passes.
18929
18930@item -fdump-rtl-unshare
18931@opindex fdump-rtl-unshare
18932Dump after all rtl has been unshared.
18933
18934@item -fdump-rtl-vartrack
18935@opindex fdump-rtl-vartrack
18936Dump after variable tracking.
18937
18938@item -fdump-rtl-vregs
18939@opindex fdump-rtl-vregs
18940Dump after converting virtual registers to hard registers.
18941
18942@item -fdump-rtl-web
18943@opindex fdump-rtl-web
18944Dump after live range splitting.
18945
18946@item -fdump-rtl-regclass
18947@itemx -fdump-rtl-subregs_of_mode_init
18948@itemx -fdump-rtl-subregs_of_mode_finish
18949@itemx -fdump-rtl-dfinit
18950@itemx -fdump-rtl-dfinish
18951@opindex fdump-rtl-regclass
18952@opindex fdump-rtl-subregs_of_mode_init
18953@opindex fdump-rtl-subregs_of_mode_finish
18954@opindex fdump-rtl-dfinit
18955@opindex fdump-rtl-dfinish
18956These dumps are defined but always produce empty files.
18957
18958@item -da
18959@itemx -fdump-rtl-all
18960@opindex da
18961@opindex fdump-rtl-all
18962Produce all the dumps listed above.
18963
18964@item -dA
18965@opindex dA
18966Annotate the assembler output with miscellaneous debugging information.
18967
18968@item -dD
18969@opindex dD
18970Dump all macro definitions, at the end of preprocessing, in addition to
18971normal output.
18972
18973@item -dH
18974@opindex dH
18975Produce a core dump whenever an error occurs.
18976
18977@item -dp
18978@opindex dp
18979Annotate the assembler output with a comment indicating which
18980pattern and alternative is used. The length and cost of each instruction are
18981also printed.
18982
18983@item -dP
18984@opindex dP
18985Dump the RTL in the assembler output as a comment before each instruction.
18986Also turns on @option{-dp} annotation.
18987
18988@item -dx
18989@opindex dx
18990Just generate RTL for a function instead of compiling it. Usually used
18991with @option{-fdump-rtl-expand}.
18992@end table
18993
18994@item -fdump-debug
18995@opindex fdump-debug
18996Dump debugging information generated during the debug
18997generation phase.
18998
18999@item -fdump-earlydebug
19000@opindex fdump-earlydebug
19001Dump debugging information generated during the early debug
19002generation phase.
19003
19004@item -fdump-noaddr
19005@opindex fdump-noaddr
19006When doing debugging dumps, suppress address output. This makes it more
19007feasible to use diff on debugging dumps for compiler invocations with
19008different compiler binaries and/or different
19009text / bss / data / heap / stack / dso start locations.
19010
19011@item -freport-bug
19012@opindex freport-bug
19013Collect and dump debug information into a temporary file if an
19014internal compiler error (ICE) occurs.
19015
19016@item -fdump-unnumbered
19017@opindex fdump-unnumbered
19018When doing debugging dumps, suppress instruction numbers and address output.
19019This makes it more feasible to use diff on debugging dumps for compiler
19020invocations with different options, in particular with and without
19021@option{-g}.
19022
19023@item -fdump-unnumbered-links
19024@opindex fdump-unnumbered-links
19025When doing debugging dumps (see @option{-d} option above), suppress
19026instruction numbers for the links to the previous and next instructions
19027in a sequence.
19028
19029@item -fdump-ipa-@var{switch}
19030@itemx -fdump-ipa-@var{switch}-@var{options}
19031@opindex fdump-ipa
19032Control the dumping at various stages of inter-procedural analysis
19033language tree to a file. The file name is generated by appending a
19034switch specific suffix to the source file name, and the file is created
19035in the same directory as the output file. The following dumps are
19036possible:
19037
19038@table @samp
19039@item all
19040Enables all inter-procedural analysis dumps.
19041
19042@item cgraph
19043Dumps information about call-graph optimization, unused function removal,
19044and inlining decisions.
19045
19046@item inline
19047Dump after function inlining.
19048
19049@end table
19050
19051Additionally, the options @option{-optimized}, @option{-missed},
19052@option{-note}, and @option{-all} can be provided, with the same meaning
19053as for @option{-fopt-info}, defaulting to @option{-optimized}.
19054
19055For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19056information on callsites that were inlined, along with callsites
19057that were not inlined.
19058
19059By default, the dump will contain messages about successful
19060optimizations (equivalent to @option{-optimized}) together with
19061low-level details about the analysis.
19062
19063@item -fdump-lang
19064@opindex fdump-lang
19065Dump language-specific information. The file name is made by appending
19066@file{.lang} to the source file name.
19067
19068@item -fdump-lang-all
19069@itemx -fdump-lang-@var{switch}
19070@itemx -fdump-lang-@var{switch}-@var{options}
19071@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
19072@opindex fdump-lang-all
19073@opindex fdump-lang
19074Control the dumping of language-specific information. The @var{options}
19075and @var{filename} portions behave as described in the
19076@option{-fdump-tree} option. The following @var{switch} values are
19077accepted:
19078
19079@table @samp
19080@item all
19081
19082Enable all language-specific dumps.
19083
19084@item class
19085Dump class hierarchy information. Virtual table information is emitted
19086unless '@option{slim}' is specified. This option is applicable to C++ only.
19087
19088@item module
19089Dump module information. Options @option{lineno} (locations),
19090@option{graph} (reachability), @option{blocks} (clusters),
19091@option{uid} (serialization), @option{alias} (mergeable),
19092@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19093(macros) may provide additional information. This option is
19094applicable to C++ only.
19095
19096@item raw
19097Dump the raw internal tree data. This option is applicable to C++ only.
19098
19099@end table
19100
19101@item -fdump-passes
19102@opindex fdump-passes
19103Print on @file{stderr} the list of optimization passes that are turned
19104on and off by the current command-line options.
19105
19106@item -fdump-statistics-@var{option}
19107@opindex fdump-statistics
19108Enable and control dumping of pass statistics in a separate file. The
19109file name is generated by appending a suffix ending in
19110@samp{.statistics} to the source file name, and the file is created in
19111the same directory as the output file. If the @samp{-@var{option}}
19112form is used, @samp{-stats} causes counters to be summed over the
19113whole compilation unit while @samp{-details} dumps every event as
19114the passes generate them. The default with no option is to sum
19115counters for each function compiled.
19116
19117@item -fdump-tree-all
19118@itemx -fdump-tree-@var{switch}
19119@itemx -fdump-tree-@var{switch}-@var{options}
19120@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
19121@opindex fdump-tree-all
19122@opindex fdump-tree
19123Control the dumping at various stages of processing the intermediate
19124language tree to a file. If the @samp{-@var{options}}
19125form is used, @var{options} is a list of @samp{-} separated options
19126which control the details of the dump. Not all options are applicable
19127to all dumps; those that are not meaningful are ignored. The
19128following options are available
19129
19130@table @samp
19131@item address
19132Print the address of each node. Usually this is not meaningful as it
19133changes according to the environment and source file. Its primary use
19134is for tying up a dump file with a debug environment.
19135@item asmname
19136If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19137in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19138use working backward from mangled names in the assembly file.
19139@item slim
19140When dumping front-end intermediate representations, inhibit dumping
19141of members of a scope or body of a function merely because that scope
19142has been reached. Only dump such items when they are directly reachable
19143by some other path.
19144
19145When dumping pretty-printed trees, this option inhibits dumping the
19146bodies of control structures.
19147
19148When dumping RTL, print the RTL in slim (condensed) form instead of
19149the default LISP-like representation.
19150@item raw
19151Print a raw representation of the tree. By default, trees are
19152pretty-printed into a C-like representation.
19153@item details
19154Enable more detailed dumps (not honored by every dump option). Also
19155include information from the optimization passes.
19156@item stats
19157Enable dumping various statistics about the pass (not honored by every dump
19158option).
19159@item blocks
19160Enable showing basic block boundaries (disabled in raw dumps).
19161@item graph
19162For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19163dump a representation of the control flow graph suitable for viewing with
19164GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19165the file is pretty-printed as a subgraph, so that GraphViz can render them
19166all in a single plot.
19167
19168This option currently only works for RTL dumps, and the RTL is always
19169dumped in slim form.
19170@item vops
19171Enable showing virtual operands for every statement.
19172@item lineno
19173Enable showing line numbers for statements.
19174@item uid
19175Enable showing the unique ID (@code{DECL_UID}) for each variable.
19176@item verbose
19177Enable showing the tree dump for each statement.
19178@item eh
19179Enable showing the EH region number holding each statement.
19180@item scev
19181Enable showing scalar evolution analysis details.
19182@item optimized
19183Enable showing optimization information (only available in certain
19184passes).
19185@item missed
19186Enable showing missed optimization information (only available in certain
19187passes).
19188@item note
19189Enable other detailed optimization information (only available in
19190certain passes).
19191@item all
19192Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19193and @option{lineno}.
19194@item optall
19195Turn on all optimization options, i.e., @option{optimized},
19196@option{missed}, and @option{note}.
19197@end table
19198
19199To determine what tree dumps are available or find the dump for a pass
19200of interest follow the steps below.
19201
19202@enumerate
19203@item
19204Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19205look for a code that corresponds to the pass you are interested in.
19206For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19207@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19208The number at the end distinguishes distinct invocations of the same pass.
19209@item
19210To enable the creation of the dump file, append the pass code to
19211the @option{-fdump-} option prefix and invoke GCC with it. For example,
19212to enable the dump from the Early Value Range Propagation pass, invoke
19213GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19214specify the name of the dump file. If you don't specify one, GCC
19215creates as described below.
19216@item
19217Find the pass dump in a file whose name is composed of three components
19218separated by a period: the name of the source file GCC was invoked to
19219compile, a numeric suffix indicating the pass number followed by the
19220letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19221and finally the pass code. For example, the Early VRP pass dump might
19222be in a file named @file{myfile.c.038t.evrp} in the current working
19223directory. Note that the numeric codes are not stable and may change
19224from one version of GCC to another.
19225@end enumerate
19226
19227@item -fopt-info
19228@itemx -fopt-info-@var{options}
19229@itemx -fopt-info-@var{options}=@var{filename}
19230@opindex fopt-info
19231Controls optimization dumps from various optimization passes. If the
19232@samp{-@var{options}} form is used, @var{options} is a list of
19233@samp{-} separated option keywords to select the dump details and
19234optimizations.
19235
19236The @var{options} can be divided into three groups:
19237@enumerate
19238@item
19239options describing what kinds of messages should be emitted,
19240@item
19241options describing the verbosity of the dump, and
19242@item
19243options describing which optimizations should be included.
19244@end enumerate
19245The options from each group can be freely mixed as they are
19246non-overlapping. However, in case of any conflicts,
19247the later options override the earlier options on the command
19248line.
19249
19250The following options control which kinds of messages should be emitted:
19251
19252@table @samp
19253@item optimized
19254Print information when an optimization is successfully applied. It is
19255up to a pass to decide which information is relevant. For example, the
19256vectorizer passes print the source location of loops which are
19257successfully vectorized.
19258@item missed
19259Print information about missed optimizations. Individual passes
19260control which information to include in the output.
19261@item note
19262Print verbose information about optimizations, such as certain
19263transformations, more detailed messages about decisions etc.
19264@item all
19265Print detailed optimization information. This includes
19266@samp{optimized}, @samp{missed}, and @samp{note}.
19267@end table
19268
19269The following option controls the dump verbosity:
19270
19271@table @samp
19272@item internals
19273By default, only ``high-level'' messages are emitted. This option enables
19274additional, more detailed, messages, which are likely to only be of interest
19275to GCC developers.
19276@end table
19277
19278One or more of the following option keywords can be used to describe a
19279group of optimizations:
19280
19281@table @samp
19282@item ipa
19283Enable dumps from all interprocedural optimizations.
19284@item loop
19285Enable dumps from all loop optimizations.
19286@item inline
19287Enable dumps from all inlining optimizations.
19288@item omp
19289Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19290@item vec
19291Enable dumps from all vectorization optimizations.
19292@item optall
19293Enable dumps from all optimizations. This is a superset of
19294the optimization groups listed above.
19295@end table
19296
19297If @var{options} is
19298omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19299about successful optimizations from all the passes, omitting messages
19300that are treated as ``internals''.
19301
19302If the @var{filename} is provided, then the dumps from all the
19303applicable optimizations are concatenated into the @var{filename}.
19304Otherwise the dump is output onto @file{stderr}. Though multiple
19305@option{-fopt-info} options are accepted, only one of them can include
19306a @var{filename}. If other filenames are provided then all but the
19307first such option are ignored.
19308
19309Note that the output @var{filename} is overwritten
19310in case of multiple translation units. If a combined output from
19311multiple translation units is desired, @file{stderr} should be used
19312instead.
19313
19314In the following example, the optimization info is output to
19315@file{stderr}:
19316
19317@smallexample
19318gcc -O3 -fopt-info
19319@end smallexample
19320
19321This example:
19322@smallexample
19323gcc -O3 -fopt-info-missed=missed.all
19324@end smallexample
19325
19326@noindent
19327outputs missed optimization report from all the passes into
19328@file{missed.all}, and this one:
19329
19330@smallexample
19331gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19332@end smallexample
19333
19334@noindent
19335prints information about missed optimization opportunities from
19336vectorization passes on @file{stderr}.
19337Note that @option{-fopt-info-vec-missed} is equivalent to
19338@option{-fopt-info-missed-vec}. The order of the optimization group
19339names and message types listed after @option{-fopt-info} does not matter.
19340
19341As another example,
19342@smallexample
19343gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19344@end smallexample
19345
19346@noindent
19347outputs information about missed optimizations as well as
19348optimized locations from all the inlining passes into
19349@file{inline.txt}.
19350
19351Finally, consider:
19352
19353@smallexample
19354gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19355@end smallexample
19356
19357@noindent
19358Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19359in conflict since only one output file is allowed. In this case, only
19360the first option takes effect and the subsequent options are
19361ignored. Thus only @file{vec.miss} is produced which contains
19362dumps from the vectorizer about missed opportunities.
19363
19364@item -fsave-optimization-record
19365@opindex fsave-optimization-record
19366Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19367were performed, for those optimizations that support @option{-fopt-info}.
19368
19369This option is experimental and the format of the data within the
19370compressed JSON file is subject to change.
19371
19372It is roughly equivalent to a machine-readable version of
19373@option{-fopt-info-all}, as a collection of messages with source file,
19374line number and column number, with the following additional data for
19375each message:
19376
19377@itemize @bullet
19378
19379@item
19380the execution count of the code being optimized, along with metadata about
19381whether this was from actual profile data, or just an estimate, allowing
19382consumers to prioritize messages by code hotness,
19383
19384@item
19385the function name of the code being optimized, where applicable,
19386
19387@item
19388the ``inlining chain'' for the code being optimized, so that when
19389a function is inlined into several different places (which might
19390themselves be inlined), the reader can distinguish between the copies,
19391
19392@item
19393objects identifying those parts of the message that refer to expressions,
19394statements or symbol-table nodes, which of these categories they are, and,
19395when available, their source code location,
19396
19397@item
19398the GCC pass that emitted the message, and
19399
19400@item
19401the location in GCC's own code from which the message was emitted
19402
19403@end itemize
19404
19405Additionally, some messages are logically nested within other
19406messages, reflecting implementation details of the optimization
19407passes.
19408
19409@item -fsched-verbose=@var{n}
19410@opindex fsched-verbose
19411On targets that use instruction scheduling, this option controls the
19412amount of debugging output the scheduler prints to the dump files.
19413
19414For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19415same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19416For @var{n} greater than one, it also output basic block probabilities,
19417detailed ready list information and unit/insn info. For @var{n} greater
19418than two, it includes RTL at abort point, control-flow and regions info.
19419And for @var{n} over four, @option{-fsched-verbose} also includes
19420dependence info.
19421
19422
19423
19424@item -fenable-@var{kind}-@var{pass}
19425@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
19426@opindex fdisable-
19427@opindex fenable-
19428
19429This is a set of options that are used to explicitly disable/enable
19430optimization passes. These options are intended for use for debugging GCC.
19431Compiler users should use regular options for enabling/disabling
19432passes instead.
19433
19434@table @gcctabopt
19435
19436@item -fdisable-ipa-@var{pass}
19437Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19438statically invoked in the compiler multiple times, the pass name should be
19439appended with a sequential number starting from 1.
19440
19441@item -fdisable-rtl-@var{pass}
19442@itemx -fdisable-rtl-@var{pass}=@var{range-list}
19443Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19444statically invoked in the compiler multiple times, the pass name should be
19445appended with a sequential number starting from 1. @var{range-list} is a
19446comma-separated list of function ranges or assembler names. Each range is a number
19447pair separated by a colon. The range is inclusive in both ends. If the range
19448is trivial, the number pair can be simplified as a single number. If the
19449function's call graph node's @var{uid} falls within one of the specified ranges,
19450the @var{pass} is disabled for that function. The @var{uid} is shown in the
19451function header of a dump file, and the pass names can be dumped by using
19452option @option{-fdump-passes}.
19453
19454@item -fdisable-tree-@var{pass}
19455@itemx -fdisable-tree-@var{pass}=@var{range-list}
19456Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19457option arguments.
19458
19459@item -fenable-ipa-@var{pass}
19460Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19461statically invoked in the compiler multiple times, the pass name should be
19462appended with a sequential number starting from 1.
19463
19464@item -fenable-rtl-@var{pass}
19465@itemx -fenable-rtl-@var{pass}=@var{range-list}
19466Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19467description and examples.
19468
19469@item -fenable-tree-@var{pass}
19470@itemx -fenable-tree-@var{pass}=@var{range-list}
19471Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19472of option arguments.
19473
19474@end table
19475
19476Here are some examples showing uses of these options.
19477
19478@smallexample
19479
19480# disable ccp1 for all functions
19481 -fdisable-tree-ccp1
19482# disable complete unroll for function whose cgraph node uid is 1
19483 -fenable-tree-cunroll=1
19484# disable gcse2 for functions at the following ranges [1,1],
19485# [300,400], and [400,1000]
19486# disable gcse2 for functions foo and foo2
19487 -fdisable-rtl-gcse2=foo,foo2
19488# disable early inlining
19489 -fdisable-tree-einline
19490# disable ipa inlining
19491 -fdisable-ipa-inline
19492# enable tree full unroll
19493 -fenable-tree-unroll
19494
19495@end smallexample
19496
19497@item -fchecking
19498@itemx -fchecking=@var{n}
19499@opindex fchecking
19500@opindex fno-checking
19501Enable internal consistency checking. The default depends on
19502the compiler configuration. @option{-fchecking=2} enables further
19503internal consistency checking that might affect code generation.
19504
19505@item -frandom-seed=@var{string}
19506@opindex frandom-seed
19507This option provides a seed that GCC uses in place of
19508random numbers in generating certain symbol names
19509that have to be different in every compiled file. It is also used to
19510place unique stamps in coverage data files and the object files that
19511produce them. You can use the @option{-frandom-seed} option to produce
19512reproducibly identical object files.
19513
19514The @var{string} can either be a number (decimal, octal or hex) or an
19515arbitrary string (in which case it's converted to a number by
19516computing CRC32).
19517
19518The @var{string} should be different for every file you compile.
19519
19520@item -save-temps
19521@opindex save-temps
19522Store the usual ``temporary'' intermediate files permanently; name them
19523as auxiliary output files, as specified described under
19524@option{-dumpbase} and @option{-dumpdir}.
19525
19526When used in combination with the @option{-x} command-line option,
19527@option{-save-temps} is sensible enough to avoid overwriting an
19528input source file with the same extension as an intermediate file.
19529The corresponding intermediate file may be obtained by renaming the
19530source file before using @option{-save-temps}.
19531
19532@item -save-temps=cwd
19533@opindex save-temps=cwd
19534Equivalent to @option{-save-temps -dumpdir ./}.
19535
19536@item -save-temps=obj
19537@opindex save-temps=obj
19538Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19539@file{outdir/} is the directory of the output file specified after the
19540@option{-o} option, including any directory separators. If the
19541@option{-o} option is not used, the @option{-save-temps=obj} switch
19542behaves like @option{-save-temps=cwd}.
19543
19544@item -time@r{[}=@var{file}@r{]}
19545@opindex time
19546Report the CPU time taken by each subprocess in the compilation
19547sequence. For C source files, this is the compiler proper and assembler
19548(plus the linker if linking is done).
19549
19550Without the specification of an output file, the output looks like this:
19551
19552@smallexample
19553# cc1 0.12 0.01
19554# as 0.00 0.01
19555@end smallexample
19556
19557The first number on each line is the ``user time'', that is time spent
19558executing the program itself. The second number is ``system time'',
19559time spent executing operating system routines on behalf of the program.
19560Both numbers are in seconds.
19561
19562With the specification of an output file, the output is appended to the
19563named file, and it looks like this:
19564
19565@smallexample
195660.12 0.01 cc1 @var{options}
195670.00 0.01 as @var{options}
19568@end smallexample
19569
19570The ``user time'' and the ``system time'' are moved before the program
19571name, and the options passed to the program are displayed, so that one
19572can later tell what file was being compiled, and with which options.
19573
19574@item -fdump-final-insns@r{[}=@var{file}@r{]}
19575@opindex fdump-final-insns
19576Dump the final internal representation (RTL) to @var{file}. If the
19577optional argument is omitted (or if @var{file} is @code{.}), the name
19578of the dump file is determined by appending @code{.gkd} to the
19579dump base name, see @option{-dumpbase}.
19580
19581@item -fcompare-debug@r{[}=@var{opts}@r{]}
19582@opindex fcompare-debug
19583@opindex fno-compare-debug
19584If no error occurs during compilation, run the compiler a second time,
19585adding @var{opts} and @option{-fcompare-debug-second} to the arguments
19586passed to the second compilation. Dump the final internal
19587representation in both compilations, and print an error if they differ.
19588
19589If the equal sign is omitted, the default @option{-gtoggle} is used.
19590
19591The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
19592and nonzero, implicitly enables @option{-fcompare-debug}. If
19593@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
19594then it is used for @var{opts}, otherwise the default @option{-gtoggle}
19595is used.
19596
19597@option{-fcompare-debug=}, with the equal sign but without @var{opts},
19598is equivalent to @option{-fno-compare-debug}, which disables the dumping
19599of the final representation and the second compilation, preventing even
19600@env{GCC_COMPARE_DEBUG} from taking effect.
19601
19602To verify full coverage during @option{-fcompare-debug} testing, set
19603@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
19604which GCC rejects as an invalid option in any actual compilation
19605(rather than preprocessing, assembly or linking). To get just a
19606warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
19607not overridden} will do.
19608
19609@item -fcompare-debug-second
19610@opindex fcompare-debug-second
19611This option is implicitly passed to the compiler for the second
19612compilation requested by @option{-fcompare-debug}, along with options to
19613silence warnings, and omitting other options that would cause the compiler
19614to produce output to files or to standard output as a side effect. Dump
19615files and preserved temporary files are renamed so as to contain the
19616@code{.gk} additional extension during the second compilation, to avoid
19617overwriting those generated by the first.
19618
19619When this option is passed to the compiler driver, it causes the
19620@emph{first} compilation to be skipped, which makes it useful for little
19621other than debugging the compiler proper.
19622
19623@item -gtoggle
19624@opindex gtoggle
19625Turn off generation of debug info, if leaving out this option
19626generates it, or turn it on at level 2 otherwise. The position of this
19627argument in the command line does not matter; it takes effect after all
19628other options are processed, and it does so only once, no matter how
19629many times it is given. This is mainly intended to be used with
19630@option{-fcompare-debug}.
19631
19632@item -fvar-tracking-assignments-toggle
19633@opindex fvar-tracking-assignments-toggle
19634@opindex fno-var-tracking-assignments-toggle
19635Toggle @option{-fvar-tracking-assignments}, in the same way that
19636@option{-gtoggle} toggles @option{-g}.
19637
19638@item -Q
19639@opindex Q
19640Makes the compiler print out each function name as it is compiled, and
19641print some statistics about each pass when it finishes.
19642
19643@item -ftime-report
19644@opindex ftime-report
19645Makes the compiler print some statistics about the time consumed by each
19646pass when it finishes.
19647
19648@item -ftime-report-details
19649@opindex ftime-report-details
19650Record the time consumed by infrastructure parts separately for each pass.
19651
19652@item -fira-verbose=@var{n}
19653@opindex fira-verbose
19654Control the verbosity of the dump file for the integrated register allocator.
19655The default value is 5. If the value @var{n} is greater or equal to 10,
19656the dump output is sent to stderr using the same format as @var{n} minus 10.
19657
19658@item -flto-report
19659@opindex flto-report
19660Prints a report with internal details on the workings of the link-time
19661optimizer. The contents of this report vary from version to version.
19662It is meant to be useful to GCC developers when processing object
19663files in LTO mode (via @option{-flto}).
19664
19665Disabled by default.
19666
19667@item -flto-report-wpa
19668@opindex flto-report-wpa
19669Like @option{-flto-report}, but only print for the WPA phase of link-time
19670optimization.
19671
19672@item -fmem-report
19673@opindex fmem-report
19674Makes the compiler print some statistics about permanent memory
19675allocation when it finishes.
19676
19677@item -fmem-report-wpa
19678@opindex fmem-report-wpa
19679Makes the compiler print some statistics about permanent memory
19680allocation for the WPA phase only.
19681
19682@item -fpre-ipa-mem-report
19683@opindex fpre-ipa-mem-report
19684@item -fpost-ipa-mem-report
19685@opindex fpost-ipa-mem-report
19686Makes the compiler print some statistics about permanent memory
19687allocation before or after interprocedural optimization.
19688
19689@item -fmultiflags
19690@opindex fmultiflags
19691This option enables multilib-aware @code{TFLAGS} to be used to build
19692target libraries with options different from those the compiler is
19693configured to use by default, through the use of specs (@xref{Spec
19694Files}) set up by compiler internals, by the target, or by builders at
19695configure time.
19696
19697Like @code{TFLAGS}, this allows the target libraries to be built for
19698portable baseline environments, while the compiler defaults to more
19699demanding ones. That's useful because users can easily override the
19700defaults the compiler is configured to use to build their own programs,
19701if the defaults are not ideal for their target environment, whereas
19702rebuilding the runtime libraries is usually not as easy or desirable.
19703
19704Unlike @code{TFLAGS}, the use of specs enables different flags to be
19705selected for different multilibs. The way to accomplish that is to
19706build with @samp{make TFLAGS=-fmultiflags}, after configuring
19707@samp{--with-specs=%@{fmultiflags:...@}}.
19708
19709This option is discarded by the driver once it's done processing driver
19710self spec.
19711
19712It is also useful to check that @code{TFLAGS} are being used to build
19713all target libraries, by configuring a non-bootstrap compiler
19714@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
19715the compiler and target libraries.
19716
19717@item -fprofile-report
19718@opindex fprofile-report
19719Makes the compiler print some statistics about consistency of the
19720(estimated) profile and effect of individual passes.
19721
19722@item -fstack-usage
19723@opindex fstack-usage
19724Makes the compiler output stack usage information for the program, on a
19725per-function basis. The filename for the dump is made by appending
19726@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
19727the output file, if explicitly specified and it is not an executable,
19728otherwise it is the basename of the source file. An entry is made up
19729of three fields:
19730
19731@itemize
19732@item
19733The name of the function.
19734@item
19735A number of bytes.
19736@item
19737One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
19738@end itemize
19739
19740The qualifier @code{static} means that the function manipulates the stack
19741statically: a fixed number of bytes are allocated for the frame on function
19742entry and released on function exit; no stack adjustments are otherwise made
19743in the function. The second field is this fixed number of bytes.
19744
19745The qualifier @code{dynamic} means that the function manipulates the stack
19746dynamically: in addition to the static allocation described above, stack
19747adjustments are made in the body of the function, for example to push/pop
19748arguments around function calls. If the qualifier @code{bounded} is also
19749present, the amount of these adjustments is bounded at compile time and
19750the second field is an upper bound of the total amount of stack used by
19751the function. If it is not present, the amount of these adjustments is
19752not bounded at compile time and the second field only represents the
19753bounded part.
19754
19755@item -fstats
19756@opindex fstats
19757Emit statistics about front-end processing at the end of the compilation.
19758This option is supported only by the C++ front end, and
19759the information is generally only useful to the G++ development team.
19760
19761@item -fdbg-cnt-list
19762@opindex fdbg-cnt-list
19763Print the name and the counter upper bound for all debug counters.
19764
19765
19766@item -fdbg-cnt=@var{counter-value-list}
19767@opindex fdbg-cnt
19768Set the internal debug counter lower and upper bound. @var{counter-value-list}
19769is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
19770[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
19771the name of the counter and list of closed intervals.
19772The @var{lower_bound} is optional and is zero
19773initialized if not set.
19774For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
19775@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
19776eleventh invocation.
19777For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
19778
19779@item -print-file-name=@var{library}
19780@opindex print-file-name
19781Print the full absolute name of the library file @var{library} that
19782would be used when linking---and don't do anything else. With this
19783option, GCC does not compile or link anything; it just prints the
19784file name.
19785
19786@item -print-multi-directory
19787@opindex print-multi-directory
19788Print the directory name corresponding to the multilib selected by any
19789other switches present in the command line. This directory is supposed
19790to exist in @env{GCC_EXEC_PREFIX}.
19791
19792@item -print-multi-lib
19793@opindex print-multi-lib
19794Print the mapping from multilib directory names to compiler switches
19795that enable them. The directory name is separated from the switches by
19796@samp{;}, and each switch starts with an @samp{@@} instead of the
19797@samp{-}, without spaces between multiple switches. This is supposed to
19798ease shell processing.
19799
19800@item -print-multi-os-directory
19801@opindex print-multi-os-directory
19802Print the path to OS libraries for the selected
19803multilib, relative to some @file{lib} subdirectory. If OS libraries are
19804present in the @file{lib} subdirectory and no multilibs are used, this is
19805usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
19806sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
19807@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
19808subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
19809
19810@item -print-multiarch
19811@opindex print-multiarch
19812Print the path to OS libraries for the selected multiarch,
19813relative to some @file{lib} subdirectory.
19814
19815@item -print-prog-name=@var{program}
19816@opindex print-prog-name
19817Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
19818
19819@item -print-libgcc-file-name
19820@opindex print-libgcc-file-name
19821Same as @option{-print-file-name=libgcc.a}.
19822
19823This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
19824but you do want to link with @file{libgcc.a}. You can do:
19825
19826@smallexample
19827gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
19828@end smallexample
19829
19830@item -print-search-dirs
19831@opindex print-search-dirs
19832Print the name of the configured installation directory and a list of
19833program and library directories @command{gcc} searches---and don't do anything else.
19834
19835This is useful when @command{gcc} prints the error message
19836@samp{installation problem, cannot exec cpp0: No such file or directory}.
19837To resolve this you either need to put @file{cpp0} and the other compiler
19838components where @command{gcc} expects to find them, or you can set the environment
19839variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
19840Don't forget the trailing @samp{/}.
19841@xref{Environment Variables}.
19842
19843@item -print-sysroot
19844@opindex print-sysroot
19845Print the target sysroot directory that is used during
19846compilation. This is the target sysroot specified either at configure
19847time or using the @option{--sysroot} option, possibly with an extra
19848suffix that depends on compilation options. If no target sysroot is
19849specified, the option prints nothing.
19850
19851@item -print-sysroot-headers-suffix
19852@opindex print-sysroot-headers-suffix
19853Print the suffix added to the target sysroot when searching for
19854headers, or give an error if the compiler is not configured with such
19855a suffix---and don't do anything else.
19856
19857@item -dumpmachine
19858@opindex dumpmachine
19859Print the compiler's target machine (for example,
19860@samp{i686-pc-linux-gnu})---and don't do anything else.
19861
19862@item -dumpversion
19863@opindex dumpversion
19864Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
19865anything else. This is the compiler version used in filesystem paths and
19866specs. Depending on how the compiler has been configured it can be just
19867a single number (major version), two numbers separated by a dot (major and
19868minor version) or three numbers separated by dots (major, minor and patchlevel
19869version).
19870
19871@item -dumpfullversion
19872@opindex dumpfullversion
19873Print the full compiler version---and don't do anything else. The output is
19874always three numbers separated by dots, major, minor and patchlevel version.
19875
19876@item -dumpspecs
19877@opindex dumpspecs
19878Print the compiler's built-in specs---and don't do anything else. (This
19879is used when GCC itself is being built.) @xref{Spec Files}.
19880@end table
19881
19882@node Submodel Options
19883@section Machine-Dependent Options
19884@cindex submodel options
19885@cindex specifying hardware config
19886@cindex hardware models and configurations, specifying
19887@cindex target-dependent options
19888@cindex machine-dependent options
19889
19890Each target machine supported by GCC can have its own options---for
19891example, to allow you to compile for a particular processor variant or
19892ABI, or to control optimizations specific to that machine. By
19893convention, the names of machine-specific options start with
19894@samp{-m}.
19895
19896Some configurations of the compiler also support additional target-specific
19897options, usually for compatibility with other compilers on the same
19898platform.
19899
19900@c This list is ordered alphanumerically by subsection name.
19901@c It should be the same order and spelling as these options are listed
19902@c in Machine Dependent Options
19903
19904@menu
19905* AArch64 Options::
19906* Adapteva Epiphany Options::
19907* AMD GCN Options::
19908* ARC Options::
19909* ARM Options::
19910* AVR Options::
19911* Blackfin Options::
19912* C6X Options::
19913* CRIS Options::
19914* C-SKY Options::
19915* Darwin Options::
19916* DEC Alpha Options::
19917* eBPF Options::
19918* FR30 Options::
19919* FT32 Options::
19920* FRV Options::
19921* GNU/Linux Options::
19922* H8/300 Options::
19923* HPPA Options::
19924* IA-64 Options::
19925* LM32 Options::
19926* LoongArch Options::
19927* M32C Options::
19928* M32R/D Options::
19929* M680x0 Options::
19930* MCore Options::
d77de738
ML
19931* MicroBlaze Options::
19932* MIPS Options::
19933* MMIX Options::
19934* MN10300 Options::
19935* Moxie Options::
19936* MSP430 Options::
19937* NDS32 Options::
19938* Nios II Options::
19939* Nvidia PTX Options::
19940* OpenRISC Options::
19941* PDP-11 Options::
d77de738
ML
19942* PowerPC Options::
19943* PRU Options::
19944* RISC-V Options::
19945* RL78 Options::
19946* RS/6000 and PowerPC Options::
19947* RX Options::
19948* S/390 and zSeries Options::
d77de738
ML
19949* SH Options::
19950* Solaris 2 Options::
19951* SPARC Options::
19952* System V Options::
19953* V850 Options::
19954* VAX Options::
19955* Visium Options::
19956* VMS Options::
19957* VxWorks Options::
19958* x86 Options::
19959* x86 Windows Options::
19960* Xstormy16 Options::
19961* Xtensa Options::
19962* zSeries Options::
19963@end menu
19964
19965@node AArch64 Options
19966@subsection AArch64 Options
19967@cindex AArch64 Options
19968
19969These options are defined for AArch64 implementations:
19970
19971@table @gcctabopt
19972
19973@item -mabi=@var{name}
19974@opindex mabi
19975Generate code for the specified data model. Permissible values
19976are @samp{ilp32} for SysV-like data model where int, long int and pointers
19977are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
19978but long int and pointers are 64 bits.
19979
19980The default depends on the specific target configuration. Note that
19981the LP64 and ILP32 ABIs are not link-compatible; you must compile your
19982entire program with the same ABI, and link with a compatible set of libraries.
19983
19984@item -mbig-endian
19985@opindex mbig-endian
19986Generate big-endian code. This is the default when GCC is configured for an
19987@samp{aarch64_be-*-*} target.
19988
19989@item -mgeneral-regs-only
19990@opindex mgeneral-regs-only
19991Generate code which uses only the general-purpose registers. This will prevent
19992the compiler from using floating-point and Advanced SIMD registers but will not
19993impose any restrictions on the assembler.
19994
19995@item -mlittle-endian
19996@opindex mlittle-endian
19997Generate little-endian code. This is the default when GCC is configured for an
19998@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
19999
20000@item -mcmodel=tiny
20001@opindex mcmodel=tiny
20002Generate code for the tiny code model. The program and its statically defined
20003symbols must be within 1MB of each other. Programs can be statically or
20004dynamically linked.
20005
20006@item -mcmodel=small
20007@opindex mcmodel=small
20008Generate code for the small code model. The program and its statically defined
20009symbols must be within 4GB of each other. Programs can be statically or
20010dynamically linked. This is the default code model.
20011
20012@item -mcmodel=large
20013@opindex mcmodel=large
20014Generate code for the large code model. This makes no assumptions about
20015addresses and sizes of sections. Programs can be statically linked only. The
20016@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20017@option{-fpic} and @option{-fPIC}.
20018
20019@item -mstrict-align
20020@itemx -mno-strict-align
20021@opindex mstrict-align
20022@opindex mno-strict-align
20023Avoid or allow generating memory accesses that may not be aligned on a natural
20024object boundary as described in the architecture specification.
20025
20026@item -momit-leaf-frame-pointer
20027@itemx -mno-omit-leaf-frame-pointer
20028@opindex momit-leaf-frame-pointer
20029@opindex mno-omit-leaf-frame-pointer
20030Omit or keep the frame pointer in leaf functions. The former behavior is the
20031default.
20032
20033@item -mstack-protector-guard=@var{guard}
20034@itemx -mstack-protector-guard-reg=@var{reg}
20035@itemx -mstack-protector-guard-offset=@var{offset}
20036@opindex mstack-protector-guard
20037@opindex mstack-protector-guard-reg
20038@opindex mstack-protector-guard-offset
20039Generate stack protection code using canary at @var{guard}. Supported
20040locations are @samp{global} for a global canary or @samp{sysreg} for a
20041canary in an appropriate system register.
20042
20043With the latter choice the options
20044@option{-mstack-protector-guard-reg=@var{reg}} and
20045@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20046which system register to use as base register for reading the canary,
20047and from what offset from that base register. There is no default
20048register or offset as this is entirely for use within the Linux
20049kernel.
20050
20051@item -mtls-dialect=desc
20052@opindex mtls-dialect=desc
20053Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20054of TLS variables. This is the default.
20055
20056@item -mtls-dialect=traditional
20057@opindex mtls-dialect=traditional
20058Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20059of TLS variables.
20060
20061@item -mtls-size=@var{size}
20062@opindex mtls-size
20063Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20064This option requires binutils 2.26 or newer.
20065
20066@item -mfix-cortex-a53-835769
20067@itemx -mno-fix-cortex-a53-835769
20068@opindex mfix-cortex-a53-835769
20069@opindex mno-fix-cortex-a53-835769
20070Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20071This involves inserting a NOP instruction between memory instructions and
2007264-bit integer multiply-accumulate instructions.
20073
20074@item -mfix-cortex-a53-843419
20075@itemx -mno-fix-cortex-a53-843419
20076@opindex mfix-cortex-a53-843419
20077@opindex mno-fix-cortex-a53-843419
20078Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20079This erratum workaround is made at link time and this will only pass the
20080corresponding flag to the linker.
20081
20082@item -mlow-precision-recip-sqrt
20083@itemx -mno-low-precision-recip-sqrt
20084@opindex mlow-precision-recip-sqrt
20085@opindex mno-low-precision-recip-sqrt
20086Enable or disable the reciprocal square root approximation.
20087This option only has an effect if @option{-ffast-math} or
20088@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20089precision of reciprocal square root results to about 16 bits for
20090single precision and to 32 bits for double precision.
20091
20092@item -mlow-precision-sqrt
20093@itemx -mno-low-precision-sqrt
20094@opindex mlow-precision-sqrt
20095@opindex mno-low-precision-sqrt
20096Enable or disable the square root approximation.
20097This option only has an effect if @option{-ffast-math} or
20098@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20099precision of square root results to about 16 bits for
20100single precision and to 32 bits for double precision.
20101If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20102
20103@item -mlow-precision-div
20104@itemx -mno-low-precision-div
20105@opindex mlow-precision-div
20106@opindex mno-low-precision-div
20107Enable or disable the division approximation.
20108This option only has an effect if @option{-ffast-math} or
20109@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20110precision of division results to about 16 bits for
20111single precision and to 32 bits for double precision.
20112
20113@item -mtrack-speculation
20114@itemx -mno-track-speculation
20115Enable or disable generation of additional code to track speculative
20116execution through conditional branches. The tracking state can then
20117be used by the compiler when expanding calls to
20118@code{__builtin_speculation_safe_copy} to permit a more efficient code
20119sequence to be generated.
20120
20121@item -moutline-atomics
20122@itemx -mno-outline-atomics
20123Enable or disable calls to out-of-line helpers to implement atomic operations.
20124These helpers will, at runtime, determine if the LSE instructions from
20125ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20126instructions that are present in the base ARMv8.0 ISA.
20127
20128This option is only applicable when compiling for the base ARMv8.0
20129instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20130or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20131used directly. The same applies when using @option{-mcpu=} when the
20132selected cpu supports the @samp{lse} feature.
20133This option is on by default.
20134
20135@item -march=@var{name}
20136@opindex march
20137Specify the name of the target architecture and, optionally, one or
20138more feature modifiers. This option has the form
20139@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20140
20141The table below summarizes the permissible values for @var{arch}
20142and the features that they enable by default:
20143
20144@multitable @columnfractions 0.20 0.20 0.60
20145@headitem @var{arch} value @tab Architecture @tab Includes by default
20146@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20147@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20148@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20149@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20150@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20151@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20152@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20153@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20154@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20155@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20156@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20157@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20158@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20159@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20160@end multitable
20161
20162The value @samp{native} is available on native AArch64 GNU/Linux and
20163causes the compiler to pick the architecture of the host system. This
20164option has no effect if the compiler is unable to recognize the
20165architecture of the host system,
20166
20167The permissible values for @var{feature} are listed in the sub-section
20168on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20169Feature Modifiers}. Where conflicting feature modifiers are
20170specified, the right-most feature is used.
20171
20172GCC uses @var{name} to determine what kind of instructions it can emit
20173when generating assembly code. If @option{-march} is specified
20174without either of @option{-mtune} or @option{-mcpu} also being
20175specified, the code is tuned to perform well across a range of target
20176processors implementing the target architecture.
20177
20178@item -mtune=@var{name}
20179@opindex mtune
20180Specify the name of the target processor for which GCC should tune the
20181performance of the code. Permissible values for this option are:
20182@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20183@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20184@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20185@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20186@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20187@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20188@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20189@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20190@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20191@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20192@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20193@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20194@samp{octeontx2f95mm},
20195@samp{a64fx},
20196@samp{thunderx}, @samp{thunderxt88},
20197@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20198@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20199@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20200@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20201@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20202@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
e07556a8
SP
20203@samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715},
20204@samp{ampere1}, @samp{ampere1a}, and @samp{native}.
d77de738
ML
20205
20206The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20207@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20208@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20209should tune for a big.LITTLE system.
20210
20211The value @samp{neoverse-512tvb} specifies that GCC should tune
20212for Neoverse cores that (a) implement SVE and (b) have a total vector
20213bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20214tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20215instructions a cycle and that can execute an equivalent number of SVE
20216arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20217This is more general than tuning for a specific core like Neoverse V1
20218but is more specific than the default tuning described below.
20219
20220Additionally on native AArch64 GNU/Linux systems the value
20221@samp{native} tunes performance to the host system. This option has no effect
20222if the compiler is unable to recognize the processor of the host system.
20223
20224Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20225are specified, the code is tuned to perform well across a range
20226of target processors.
20227
20228This option cannot be suffixed by feature modifiers.
20229
20230@item -mcpu=@var{name}
20231@opindex mcpu
20232Specify the name of the target processor, optionally suffixed by one
20233or more feature modifiers. This option has the form
20234@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20235the permissible values for @var{cpu} are the same as those available
20236for @option{-mtune}. The permissible values for @var{feature} are
20237documented in the sub-section on
20238@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20239Feature Modifiers}. Where conflicting feature modifiers are
20240specified, the right-most feature is used.
20241
20242GCC uses @var{name} to determine what kind of instructions it can emit when
20243generating assembly code (as if by @option{-march}) and to determine
20244the target processor for which to tune for performance (as if
20245by @option{-mtune}). Where this option is used in conjunction
20246with @option{-march} or @option{-mtune}, those options take precedence
20247over the appropriate part of this option.
20248
20249@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20250to a specific core, but instead refers to all Neoverse cores that
20251(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20252a cycle. Unless overridden by @option{-march},
20253@option{-mcpu=neoverse-512tvb} generates code that can run on a
20254Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20255these properties. Unless overridden by @option{-mtune},
20256@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20257@option{-mtune=neoverse-512tvb}.
20258
20259@item -moverride=@var{string}
20260@opindex moverride
20261Override tuning decisions made by the back-end in response to a
20262@option{-mtune=} switch. The syntax, semantics, and accepted values
20263for @var{string} in this option are not guaranteed to be consistent
20264across releases.
20265
20266This option is only intended to be useful when developing GCC.
20267
20268@item -mverbose-cost-dump
20269@opindex mverbose-cost-dump
20270Enable verbose cost model dumping in the debug dump files. This option is
20271provided for use in debugging the compiler.
20272
20273@item -mpc-relative-literal-loads
20274@itemx -mno-pc-relative-literal-loads
20275@opindex mpc-relative-literal-loads
20276@opindex mno-pc-relative-literal-loads
20277Enable or disable PC-relative literal loads. With this option literal pools are
20278accessed using a single instruction and emitted after each function. This
20279limits the maximum size of functions to 1MB. This is enabled by default for
20280@option{-mcmodel=tiny}.
20281
20282@item -msign-return-address=@var{scope}
20283@opindex msign-return-address
20284Select the function scope on which return address signing will be applied.
20285Permissible values are @samp{none}, which disables return address signing,
20286@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20287functions, and @samp{all}, which enables pointer signing for all functions. The
20288default value is @samp{none}. This option has been deprecated by
20289-mbranch-protection.
20290
20291@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
20292@opindex mbranch-protection
20293Select the branch protection features to use.
20294@samp{none} is the default and turns off all types of branch protection.
20295@samp{standard} turns on all types of branch protection features. If a feature
20296has additional tuning options, then @samp{standard} sets it to its standard
20297level.
20298@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20299level: signing functions that save the return address to memory (non-leaf
20300functions will practically always do this) using the a-key. The optional
20301argument @samp{leaf} can be used to extend the signing to include leaf
20302functions. The optional argument @samp{b-key} can be used to sign the functions
20303with the B-key instead of the A-key.
20304@samp{bti} turns on branch target identification mechanism.
20305
20306@item -mharden-sls=@var{opts}
20307@opindex mharden-sls
20308Enable compiler hardening against straight line speculation (SLS).
20309@var{opts} is a comma-separated list of the following options:
20310@table @samp
20311@item retbr
20312@item blr
20313@end table
20314In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20315@samp{-mharden-sls=none} disables all SLS hardening.
20316
20317@item -msve-vector-bits=@var{bits}
20318@opindex msve-vector-bits
20319Specify the number of bits in an SVE vector register. This option only has
20320an effect when SVE is enabled.
20321
20322GCC supports two forms of SVE code generation: ``vector-length
20323agnostic'' output that works with any size of vector register and
20324``vector-length specific'' output that allows GCC to make assumptions
20325about the vector length when it is useful for optimization reasons.
20326The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20327@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20328Specifying @samp{scalable} selects vector-length agnostic
20329output. At present @samp{-msve-vector-bits=128} also generates vector-length
20330agnostic output for big-endian targets. All other values generate
20331vector-length specific code. The behavior of these values may change
20332in future releases and no value except @samp{scalable} should be
20333relied on for producing code that is portable across different
20334hardware SVE vector lengths.
20335
20336The default is @samp{-msve-vector-bits=scalable}, which produces
20337vector-length agnostic code.
20338@end table
20339
20340@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20341@anchor{aarch64-feature-modifiers}
20342@cindex @option{-march} feature modifiers
20343@cindex @option{-mcpu} feature modifiers
20344Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20345the following and their inverses @option{no@var{feature}}:
20346
20347@table @samp
20348@item crc
20349Enable CRC extension. This is on by default for
20350@option{-march=armv8.1-a}.
20351@item crypto
20352Enable Crypto extension. This also enables Advanced SIMD and floating-point
20353instructions.
20354@item fp
20355Enable floating-point instructions. This is on by default for all possible
20356values for options @option{-march} and @option{-mcpu}.
20357@item simd
20358Enable Advanced SIMD instructions. This also enables floating-point
20359instructions. This is on by default for all possible values for options
20360@option{-march} and @option{-mcpu}.
20361@item sve
20362Enable Scalable Vector Extension instructions. This also enables Advanced
20363SIMD and floating-point instructions.
20364@item lse
20365Enable Large System Extension instructions. This is on by default for
20366@option{-march=armv8.1-a}.
20367@item rdma
20368Enable Round Double Multiply Accumulate instructions. This is on by default
20369for @option{-march=armv8.1-a}.
20370@item fp16
20371Enable FP16 extension. This also enables floating-point instructions.
20372@item fp16fml
20373Enable FP16 fmla extension. This also enables FP16 extensions and
20374floating-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.
20375
20376@item rcpc
0431e8ae
AV
20377Enable the RCpc extension. This enables the use of the LDAPR instructions for
20378load-acquire atomic semantics, and passes it on to the assembler, enabling
20379inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20380@item dotprod
20381Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20382@item aes
20383Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20384SIMD instructions.
20385@item sha2
20386Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20387@item sha3
20388Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20389instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20390@item sm4
20391Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20392Use of this option with architectures prior to Armv8.2-A is not supported.
20393@item profile
20394Enable the Statistical Profiling extension. This option is only to enable the
20395extension at the assembler level and does not affect code generation.
20396@item rng
20397Enable the Armv8.5-a Random Number instructions. This option is only to
20398enable the extension at the assembler level and does not affect code
20399generation.
20400@item memtag
20401Enable the Armv8.5-a Memory Tagging Extensions.
20402Use of this option with architectures prior to Armv8.5-A is not supported.
20403@item sb
20404Enable the Armv8-a Speculation Barrier instruction. This option is only to
20405enable the extension at the assembler level and does not affect code
20406generation. This option is enabled by default for @option{-march=armv8.5-a}.
20407@item ssbs
20408Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20409is only to enable the extension at the assembler level and does not affect code
20410generation. This option is enabled by default for @option{-march=armv8.5-a}.
20411@item predres
20412Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20413This option is only to enable the extension at the assembler level and does
20414not affect code generation. This option is enabled by default for
20415@option{-march=armv8.5-a}.
20416@item sve2
20417Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20418instructions.
20419@item sve2-bitperm
20420Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20421@item sve2-sm4
20422Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20423@item sve2-aes
20424Enable SVE2 aes instructions. This also enables SVE2 instructions.
20425@item sve2-sha3
20426Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20427@item tme
20428Enable the Transactional Memory Extension.
20429@item i8mm
20430Enable 8-bit Integer Matrix Multiply instructions. This also enables
20431Advanced SIMD and floating-point instructions. This option is enabled by
20432default for @option{-march=armv8.6-a}. Use of this option with architectures
20433prior to Armv8.2-A is not supported.
20434@item f32mm
20435Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20436SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20437not supported.
20438@item f64mm
20439Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20440SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20441not supported.
20442@item bf16
20443Enable brain half-precision floating-point instructions. This also enables
20444Advanced SIMD and floating-point instructions. This option is enabled by
20445default for @option{-march=armv8.6-a}. Use of this option with architectures
20446prior to Armv8.2-A is not supported.
20447@item ls64
20448Enable the 64-byte atomic load and store instructions for accelerators.
20449This option is enabled by default for @option{-march=armv8.7-a}.
20450@item mops
20451Enable the instructions to accelerate memory operations like @code{memcpy},
20452@code{memmove}, @code{memset}. This option is enabled by default for
20453@option{-march=armv8.8-a}
20454@item flagm
20455Enable the Flag Manipulation instructions Extension.
20456@item pauth
20457Enable the Pointer Authentication Extension.
d758d190
KT
20458@item cssc
20459Enable the Common Short Sequence Compression instructions.
d77de738
ML
20460
20461@end table
20462
20463Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20464which implies @option{fp}.
20465Conversely, @option{nofp} implies @option{nosimd}, which implies
20466@option{nocrypto}, @option{noaes} and @option{nosha2}.
20467
20468@node Adapteva Epiphany Options
20469@subsection Adapteva Epiphany Options
20470
20471These @samp{-m} options are defined for Adapteva Epiphany:
20472
20473@table @gcctabopt
20474@item -mhalf-reg-file
20475@opindex mhalf-reg-file
20476Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20477That allows code to run on hardware variants that lack these registers.
20478
20479@item -mprefer-short-insn-regs
20480@opindex mprefer-short-insn-regs
20481Preferentially allocate registers that allow short instruction generation.
20482This can result in increased instruction count, so this may either reduce or
20483increase overall code size.
20484
20485@item -mbranch-cost=@var{num}
20486@opindex mbranch-cost
20487Set the cost of branches to roughly @var{num} ``simple'' instructions.
20488This cost is only a heuristic and is not guaranteed to produce
20489consistent results across releases.
20490
20491@item -mcmove
20492@opindex mcmove
20493Enable the generation of conditional moves.
20494
20495@item -mnops=@var{num}
20496@opindex mnops
20497Emit @var{num} NOPs before every other generated instruction.
20498
20499@item -mno-soft-cmpsf
20500@opindex mno-soft-cmpsf
20501@opindex msoft-cmpsf
20502For single-precision floating-point comparisons, emit an @code{fsub} instruction
20503and test the flags. This is faster than a software comparison, but can
20504get incorrect results in the presence of NaNs, or when two different small
20505numbers are compared such that their difference is calculated as zero.
20506The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20507software comparisons.
20508
20509@item -mstack-offset=@var{num}
20510@opindex mstack-offset
20511Set the offset between the top of the stack and the stack pointer.
20512E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20513can be used by leaf functions without stack allocation.
20514Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20515Note also that this option changes the ABI; compiling a program with a
20516different stack offset than the libraries have been compiled with
20517generally does not work.
20518This option can be useful if you want to evaluate if a different stack
20519offset would give you better code, but to actually use a different stack
20520offset to build working programs, it is recommended to configure the
20521toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20522
20523@item -mno-round-nearest
20524@opindex mno-round-nearest
20525@opindex mround-nearest
20526Make the scheduler assume that the rounding mode has been set to
20527truncating. The default is @option{-mround-nearest}.
20528
20529@item -mlong-calls
20530@opindex mlong-calls
20531If not otherwise specified by an attribute, assume all calls might be beyond
20532the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20533function address into a register before performing a (otherwise direct) call.
20534This is the default.
20535
20536@item -mshort-calls
20537@opindex short-calls
20538If not otherwise specified by an attribute, assume all direct calls are
20539in the range of the @code{b} / @code{bl} instructions, so use these instructions
20540for direct calls. The default is @option{-mlong-calls}.
20541
20542@item -msmall16
20543@opindex msmall16
20544Assume addresses can be loaded as 16-bit unsigned values. This does not
20545apply to function addresses for which @option{-mlong-calls} semantics
20546are in effect.
20547
20548@item -mfp-mode=@var{mode}
20549@opindex mfp-mode
20550Set the prevailing mode of the floating-point unit.
20551This determines the floating-point mode that is provided and expected
20552at function call and return time. Making this mode match the mode you
20553predominantly need at function start can make your programs smaller and
20554faster by avoiding unnecessary mode switches.
20555
20556@var{mode} can be set to one the following values:
20557
20558@table @samp
20559@item caller
20560Any mode at function entry is valid, and retained or restored when
20561the function returns, and when it calls other functions.
20562This mode is useful for compiling libraries or other compilation units
20563you might want to incorporate into different programs with different
20564prevailing FPU modes, and the convenience of being able to use a single
20565object file outweighs the size and speed overhead for any extra
20566mode switching that might be needed, compared with what would be needed
20567with a more specific choice of prevailing FPU mode.
20568
20569@item truncate
20570This is the mode used for floating-point calculations with
20571truncating (i.e.@: round towards zero) rounding mode. That includes
20572conversion from floating point to integer.
20573
20574@item round-nearest
20575This is the mode used for floating-point calculations with
20576round-to-nearest-or-even rounding mode.
20577
20578@item int
20579This is the mode used to perform integer calculations in the FPU, e.g.@:
20580integer multiply, or integer multiply-and-accumulate.
20581@end table
20582
20583The default is @option{-mfp-mode=caller}
20584
20585@item -mno-split-lohi
20586@itemx -mno-postinc
20587@itemx -mno-postmodify
20588@opindex mno-split-lohi
20589@opindex msplit-lohi
20590@opindex mno-postinc
20591@opindex mpostinc
20592@opindex mno-postmodify
20593@opindex mpostmodify
20594Code generation tweaks that disable, respectively, splitting of 32-bit
20595loads, generation of post-increment addresses, and generation of
20596post-modify addresses. The defaults are @option{msplit-lohi},
20597@option{-mpost-inc}, and @option{-mpost-modify}.
20598
20599@item -mnovect-double
20600@opindex mno-vect-double
20601@opindex mvect-double
20602Change the preferred SIMD mode to SImode. The default is
20603@option{-mvect-double}, which uses DImode as preferred SIMD mode.
20604
20605@item -max-vect-align=@var{num}
20606@opindex max-vect-align
20607The maximum alignment for SIMD vector mode types.
20608@var{num} may be 4 or 8. The default is 8.
20609Note that this is an ABI change, even though many library function
20610interfaces are unaffected if they don't use SIMD vector modes
20611in places that affect size and/or alignment of relevant types.
20612
20613@item -msplit-vecmove-early
20614@opindex msplit-vecmove-early
20615Split vector moves into single word moves before reload. In theory this
20616can give better register allocation, but so far the reverse seems to be
20617generally the case.
20618
20619@item -m1reg-@var{reg}
20620@opindex m1reg-
20621Specify a register to hold the constant @minus{}1, which makes loading small negative
20622constants and certain bitmasks faster.
20623Allowable values for @var{reg} are @samp{r43} and @samp{r63},
20624which specify use of that register as a fixed register,
20625and @samp{none}, which means that no register is used for this
20626purpose. The default is @option{-m1reg-none}.
20627
20628@end table
20629
20630@node AMD GCN Options
20631@subsection AMD GCN Options
20632@cindex AMD GCN Options
20633
20634These options are defined specifically for the AMD GCN port.
20635
20636@table @gcctabopt
20637
20638@item -march=@var{gpu}
20639@opindex march
20640@itemx -mtune=@var{gpu}
20641@opindex mtune
20642Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
20643are
20644
20645@table @samp
20646@item fiji
20647Compile for GCN3 Fiji devices (gfx803).
20648
20649@item gfx900
20650Compile for GCN5 Vega 10 devices (gfx900).
20651
20652@item gfx906
20653Compile for GCN5 Vega 20 devices (gfx906).
20654
20655@item gfx908
20656Compile for CDNA1 Instinct MI100 series devices (gfx908).
20657
20658@item gfx90a
20659Compile for CDNA2 Instinct MI200 series devices (gfx90a).
20660
20661@end table
20662
20663@item -msram-ecc=on
20664@itemx -msram-ecc=off
20665@itemx -msram-ecc=any
20666@opindex msram-ecc
20667Compile binaries suitable for devices with the SRAM-ECC feature enabled,
20668disabled, or either mode. This feature can be enabled per-process on some
20669devices. The compiled code must match the device mode. The default is
20670@samp{any}, for devices that support it.
20671
20672@item -mstack-size=@var{bytes}
20673@opindex mstack-size
20674Specify how many @var{bytes} of stack space will be requested for each GPU
20675thread (wave-front). Beware that there may be many threads and limited memory
20676available. The size of the stack allocation may also have an impact on
20677run-time performance. The default is 32KB when using OpenACC or OpenMP, and
206781MB otherwise.
20679
20680@item -mxnack
20681@opindex mxnack
20682Compile binaries suitable for devices with the XNACK feature enabled. Some
20683devices always require XNACK and some allow the user to configure XNACK. The
20684compiled code must match the device mode. The default is @samp{-mno-xnack}.
20685At present this option is a placeholder for support that is not yet
20686implemented.
20687
20688@end table
20689
20690@node ARC Options
20691@subsection ARC Options
20692@cindex ARC options
20693
20694The following options control the architecture variant for which code
20695is being compiled:
20696
20697@c architecture variants
20698@table @gcctabopt
20699
20700@item -mbarrel-shifter
20701@opindex mbarrel-shifter
20702Generate instructions supported by barrel shifter. This is the default
20703unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
20704
20705@item -mjli-always
20706@opindex mjli-always
20707Force to call a function using jli_s instruction. This option is
20708valid only for ARCv2 architecture.
20709
20710@item -mcpu=@var{cpu}
20711@opindex mcpu
20712Set architecture type, register usage, and instruction scheduling
20713parameters for @var{cpu}. There are also shortcut alias options
20714available for backward compatibility and convenience. Supported
20715values for @var{cpu} are
20716
20717@table @samp
20718@opindex mA6
20719@opindex mARC600
20720@item arc600
20721Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
20722
20723@item arc601
20724@opindex mARC601
20725Compile for ARC601. Alias: @option{-mARC601}.
20726
20727@item arc700
20728@opindex mA7
20729@opindex mARC700
20730Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
20731This is the default when configured with @option{--with-cpu=arc700}@.
20732
20733@item arcem
20734Compile for ARC EM.
20735
20736@item archs
20737Compile for ARC HS.
20738
20739@item em
20740Compile for ARC EM CPU with no hardware extensions.
20741
20742@item em4
20743Compile for ARC EM4 CPU.
20744
20745@item em4_dmips
20746Compile for ARC EM4 DMIPS CPU.
20747
20748@item em4_fpus
20749Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
20750extension.
20751
20752@item em4_fpuda
20753Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
20754double assist instructions.
20755
20756@item hs
20757Compile for ARC HS CPU with no hardware extensions except the atomic
20758instructions.
20759
20760@item hs34
20761Compile for ARC HS34 CPU.
20762
20763@item hs38
20764Compile for ARC HS38 CPU.
20765
20766@item hs38_linux
20767Compile for ARC HS38 CPU with all hardware extensions on.
20768
20769@item hs4x
20770Compile for ARC HS4x CPU.
20771
20772@item hs4xd
20773Compile for ARC HS4xD CPU.
20774
20775@item hs4x_rel31
20776Compile for ARC HS4x CPU release 3.10a.
20777
20778@item arc600_norm
20779Compile for ARC 600 CPU with @code{norm} instructions enabled.
20780
20781@item arc600_mul32x16
20782Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
20783instructions enabled.
20784
20785@item arc600_mul64
20786Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
20787instructions enabled.
20788
20789@item arc601_norm
20790Compile for ARC 601 CPU with @code{norm} instructions enabled.
20791
20792@item arc601_mul32x16
20793Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
20794instructions enabled.
20795
20796@item arc601_mul64
20797Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
20798instructions enabled.
20799
20800@item nps400
20801Compile for ARC 700 on NPS400 chip.
20802
20803@item em_mini
20804Compile for ARC EM minimalist configuration featuring reduced register
20805set.
20806
20807@end table
20808
20809@item -mdpfp
20810@opindex mdpfp
20811@itemx -mdpfp-compact
20812@opindex mdpfp-compact
20813Generate double-precision FPX instructions, tuned for the compact
20814implementation.
20815
20816@item -mdpfp-fast
20817@opindex mdpfp-fast
20818Generate double-precision FPX instructions, tuned for the fast
20819implementation.
20820
20821@item -mno-dpfp-lrsr
20822@opindex mno-dpfp-lrsr
20823Disable @code{lr} and @code{sr} instructions from using FPX extension
20824aux registers.
20825
20826@item -mea
20827@opindex mea
20828Generate extended arithmetic instructions. Currently only
20829@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
20830supported. Only valid for @option{-mcpu=ARC700}.
20831
20832@item -mno-mpy
20833@opindex mno-mpy
20834@opindex mmpy
20835Do not generate @code{mpy}-family instructions for ARC700. This option is
20836deprecated.
20837
20838@item -mmul32x16
20839@opindex mmul32x16
20840Generate 32x16-bit multiply and multiply-accumulate instructions.
20841
20842@item -mmul64
20843@opindex mmul64
20844Generate @code{mul64} and @code{mulu64} instructions.
20845Only valid for @option{-mcpu=ARC600}.
20846
20847@item -mnorm
20848@opindex mnorm
20849Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
20850is in effect.
20851
20852@item -mspfp
20853@opindex mspfp
20854@itemx -mspfp-compact
20855@opindex mspfp-compact
20856Generate single-precision FPX instructions, tuned for the compact
20857implementation.
20858
20859@item -mspfp-fast
20860@opindex mspfp-fast
20861Generate single-precision FPX instructions, tuned for the fast
20862implementation.
20863
20864@item -msimd
20865@opindex msimd
20866Enable generation of ARC SIMD instructions via target-specific
20867builtins. Only valid for @option{-mcpu=ARC700}.
20868
20869@item -msoft-float
20870@opindex msoft-float
20871This option ignored; it is provided for compatibility purposes only.
20872Software floating-point code is emitted by default, and this default
20873can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
20874@option{-mspfp-fast} for single precision, and @option{-mdpfp},
20875@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
20876
20877@item -mswap
20878@opindex mswap
20879Generate @code{swap} instructions.
20880
20881@item -matomic
20882@opindex matomic
20883This enables use of the locked load/store conditional extension to implement
20884atomic memory built-in functions. Not available for ARC 6xx or ARC
20885EM cores.
20886
20887@item -mdiv-rem
20888@opindex mdiv-rem
20889Enable @code{div} and @code{rem} instructions for ARCv2 cores.
20890
20891@item -mcode-density
20892@opindex mcode-density
20893Enable code density instructions for ARC EM.
20894This option is on by default for ARC HS.
20895
20896@item -mll64
20897@opindex mll64
20898Enable double load/store operations for ARC HS cores.
20899
20900@item -mtp-regno=@var{regno}
20901@opindex mtp-regno
20902Specify thread pointer register number.
20903
20904@item -mmpy-option=@var{multo}
20905@opindex mmpy-option
20906Compile ARCv2 code with a multiplier design option. You can specify
20907the option using either a string or numeric value for @var{multo}.
20908@samp{wlh1} is the default value. The recognized values are:
20909
20910@table @samp
20911@item 0
20912@itemx none
20913No multiplier available.
20914
20915@item 1
20916@itemx w
2091716x16 multiplier, fully pipelined.
20918The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
20919
20920@item 2
20921@itemx wlh1
2092232x32 multiplier, fully
20923pipelined (1 stage). The following instructions are additionally
20924enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20925
20926@item 3
20927@itemx wlh2
2092832x32 multiplier, fully pipelined
20929(2 stages). The following instructions are additionally enabled: @code{mpy},
20930@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20931
20932@item 4
20933@itemx wlh3
20934Two 16x16 multipliers, blocking,
20935sequential. The following instructions are additionally enabled: @code{mpy},
20936@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20937
20938@item 5
20939@itemx wlh4
20940One 16x16 multiplier, blocking,
20941sequential. The following instructions are additionally enabled: @code{mpy},
20942@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20943
20944@item 6
20945@itemx wlh5
20946One 32x4 multiplier, blocking,
20947sequential. The following instructions are additionally enabled: @code{mpy},
20948@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20949
20950@item 7
20951@itemx plus_dmpy
20952ARC HS SIMD support.
20953
20954@item 8
20955@itemx plus_macd
20956ARC HS SIMD support.
20957
20958@item 9
20959@itemx plus_qmacw
20960ARC HS SIMD support.
20961
20962@end table
20963
20964This option is only available for ARCv2 cores@.
20965
20966@item -mfpu=@var{fpu}
20967@opindex mfpu
20968Enables support for specific floating-point hardware extensions for ARCv2
20969cores. Supported values for @var{fpu} are:
20970
20971@table @samp
20972
20973@item fpus
20974Enables support for single-precision floating-point hardware
20975extensions@.
20976
20977@item fpud
20978Enables support for double-precision floating-point hardware
20979extensions. The single-precision floating-point extension is also
20980enabled. Not available for ARC EM@.
20981
20982@item fpuda
20983Enables support for double-precision floating-point hardware
20984extensions using double-precision assist instructions. The single-precision
20985floating-point extension is also enabled. This option is
20986only available for ARC EM@.
20987
20988@item fpuda_div
20989Enables support for double-precision floating-point hardware
20990extensions using double-precision assist instructions.
20991The single-precision floating-point, square-root, and divide
20992extensions are also enabled. This option is
20993only available for ARC EM@.
20994
20995@item fpuda_fma
20996Enables support for double-precision floating-point hardware
20997extensions using double-precision assist instructions.
20998The single-precision floating-point and fused multiply and add
20999hardware extensions are also enabled. This option is
21000only available for ARC EM@.
21001
21002@item fpuda_all
21003Enables support for double-precision floating-point hardware
21004extensions using double-precision assist instructions.
21005All single-precision floating-point hardware extensions are also
21006enabled. This option is only available for ARC EM@.
21007
21008@item fpus_div
21009Enables support for single-precision floating-point, square-root and divide
21010hardware extensions@.
21011
21012@item fpud_div
21013Enables support for double-precision floating-point, square-root and divide
21014hardware extensions. This option
21015includes option @samp{fpus_div}. Not available for ARC EM@.
21016
21017@item fpus_fma
21018Enables support for single-precision floating-point and
21019fused multiply and add hardware extensions@.
21020
21021@item fpud_fma
21022Enables support for double-precision floating-point and
21023fused multiply and add hardware extensions. This option
21024includes option @samp{fpus_fma}. Not available for ARC EM@.
21025
21026@item fpus_all
21027Enables support for all single-precision floating-point hardware
21028extensions@.
21029
21030@item fpud_all
21031Enables support for all single- and double-precision floating-point
21032hardware extensions. Not available for ARC EM@.
21033
21034@end table
21035
21036@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
21037@opindex mirq-ctrl-saved
21038Specifies general-purposes registers that the processor automatically
21039saves/restores on interrupt entry and exit. @var{register-range} is
21040specified as two registers separated by a dash. The register range
21041always starts with @code{r0}, the upper limit is @code{fp} register.
21042@var{blink} and @var{lp_count} are optional. This option is only
21043valid for ARC EM and ARC HS cores.
21044
21045@item -mrgf-banked-regs=@var{number}
21046@opindex mrgf-banked-regs
21047Specifies the number of registers replicated in second register bank
21048on entry to fast interrupt. Fast interrupts are interrupts with the
21049highest priority level P0. These interrupts save only PC and STATUS32
21050registers to avoid memory transactions during interrupt entry and exit
21051sequences. Use this option when you are using fast interrupts in an
21052ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21053
21054@item -mlpc-width=@var{width}
21055@opindex mlpc-width
21056Specify the width of the @code{lp_count} register. Valid values for
21057@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21058fixed to 32 bits. If the width is less than 32, the compiler does not
21059attempt to transform loops in your program to use the zero-delay loop
21060mechanism unless it is known that the @code{lp_count} register can
21061hold the required loop-counter value. Depending on the width
21062specified, the compiler and run-time library might continue to use the
21063loop mechanism for various needs. This option defines macro
21064@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21065
21066@item -mrf16
21067@opindex mrf16
21068This option instructs the compiler to generate code for a 16-entry
21069register file. This option defines the @code{__ARC_RF16__}
21070preprocessor macro.
21071
21072@item -mbranch-index
21073@opindex mbranch-index
21074Enable use of @code{bi} or @code{bih} instructions to implement jump
21075tables.
21076
21077@end table
21078
21079The following options are passed through to the assembler, and also
21080define preprocessor macro symbols.
21081
21082@c Flags used by the assembler, but for which we define preprocessor
21083@c macro symbols as well.
21084@table @gcctabopt
21085@item -mdsp-packa
21086@opindex mdsp-packa
21087Passed down to the assembler to enable the DSP Pack A extensions.
21088Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21089deprecated.
21090
21091@item -mdvbf
21092@opindex mdvbf
21093Passed down to the assembler to enable the dual Viterbi butterfly
21094extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21095option is deprecated.
21096
21097@c ARC700 4.10 extension instruction
21098@item -mlock
21099@opindex mlock
21100Passed down to the assembler to enable the locked load/store
21101conditional extension. Also sets the preprocessor symbol
21102@code{__Xlock}.
21103
21104@item -mmac-d16
21105@opindex mmac-d16
21106Passed down to the assembler. Also sets the preprocessor symbol
21107@code{__Xxmac_d16}. This option is deprecated.
21108
21109@item -mmac-24
21110@opindex mmac-24
21111Passed down to the assembler. Also sets the preprocessor symbol
21112@code{__Xxmac_24}. This option is deprecated.
21113
21114@c ARC700 4.10 extension instruction
21115@item -mrtsc
21116@opindex mrtsc
21117Passed down to the assembler to enable the 64-bit time-stamp counter
21118extension instruction. Also sets the preprocessor symbol
21119@code{__Xrtsc}. This option is deprecated.
21120
21121@c ARC700 4.10 extension instruction
21122@item -mswape
21123@opindex mswape
21124Passed down to the assembler to enable the swap byte ordering
21125extension instruction. Also sets the preprocessor symbol
21126@code{__Xswape}.
21127
21128@item -mtelephony
21129@opindex mtelephony
21130Passed down to the assembler to enable dual- and single-operand
21131instructions for telephony. Also sets the preprocessor symbol
21132@code{__Xtelephony}. This option is deprecated.
21133
21134@item -mxy
21135@opindex mxy
21136Passed down to the assembler to enable the XY memory extension. Also
21137sets the preprocessor symbol @code{__Xxy}.
21138
21139@end table
21140
21141The following options control how the assembly code is annotated:
21142
21143@c Assembly annotation options
21144@table @gcctabopt
21145@item -misize
21146@opindex misize
21147Annotate assembler instructions with estimated addresses.
21148
21149@item -mannotate-align
21150@opindex mannotate-align
21151Explain what alignment considerations lead to the decision to make an
21152instruction short or long.
21153
21154@end table
21155
21156The following options are passed through to the linker:
21157
21158@c options passed through to the linker
21159@table @gcctabopt
21160@item -marclinux
21161@opindex marclinux
21162Passed through to the linker, to specify use of the @code{arclinux} emulation.
21163This option is enabled by default in tool chains built for
21164@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21165when profiling is not requested.
21166
21167@item -marclinux_prof
21168@opindex marclinux_prof
21169Passed through to the linker, to specify use of the
21170@code{arclinux_prof} emulation. This option is enabled by default in
21171tool chains built for @w{@code{arc-linux-uclibc}} and
21172@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21173
21174@end table
21175
21176The following options control the semantics of generated code:
21177
21178@c semantically relevant code generation options
21179@table @gcctabopt
21180@item -mlong-calls
21181@opindex mlong-calls
21182Generate calls as register indirect calls, thus providing access
21183to the full 32-bit address range.
21184
21185@item -mmedium-calls
21186@opindex mmedium-calls
21187Don't use less than 25-bit addressing range for calls, which is the
21188offset available for an unconditional branch-and-link
21189instruction. Conditional execution of function calls is suppressed, to
21190allow use of the 25-bit range, rather than the 21-bit range with
21191conditional branch-and-link. This is the default for tool chains built
21192for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21193
21194@item -G @var{num}
21195@opindex G
21196Put definitions of externally-visible data in a small data section if
21197that data is no bigger than @var{num} bytes. The default value of
21198@var{num} is 4 for any ARC configuration, or 8 when we have double
21199load/store operations.
21200
21201@item -mno-sdata
21202@opindex mno-sdata
21203@opindex msdata
21204Do not generate sdata references. This is the default for tool chains
21205built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21206targets.
21207
21208@item -mvolatile-cache
21209@opindex mvolatile-cache
21210Use ordinarily cached memory accesses for volatile references. This is the
21211default.
21212
21213@item -mno-volatile-cache
21214@opindex mno-volatile-cache
21215@opindex mvolatile-cache
21216Enable cache bypass for volatile references.
21217
21218@end table
21219
21220The following options fine tune code generation:
21221@c code generation tuning options
21222@table @gcctabopt
21223@item -malign-call
21224@opindex malign-call
21225Does nothing. Preserved for backward compatibility.
21226
21227@item -mauto-modify-reg
21228@opindex mauto-modify-reg
21229Enable the use of pre/post modify with register displacement.
21230
21231@item -mbbit-peephole
21232@opindex mbbit-peephole
21233Enable bbit peephole2.
21234
21235@item -mno-brcc
21236@opindex mno-brcc
21237This option disables a target-specific pass in @file{arc_reorg} to
21238generate compare-and-branch (@code{br@var{cc}}) instructions.
21239It has no effect on
21240generation of these instructions driven by the combiner pass.
21241
21242@item -mcase-vector-pcrel
21243@opindex mcase-vector-pcrel
21244Use PC-relative switch case tables to enable case table shortening.
21245This is the default for @option{-Os}.
21246
21247@item -mcompact-casesi
21248@opindex mcompact-casesi
21249Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21250and only available for ARCv1 cores. This option is deprecated.
21251
21252@item -mno-cond-exec
21253@opindex mno-cond-exec
21254Disable the ARCompact-specific pass to generate conditional
21255execution instructions.
21256
21257Due to delay slot scheduling and interactions between operand numbers,
21258literal sizes, instruction lengths, and the support for conditional execution,
21259the target-independent pass to generate conditional execution is often lacking,
21260so the ARC port has kept a special pass around that tries to find more
21261conditional execution generation opportunities after register allocation,
21262branch shortening, and delay slot scheduling have been done. This pass
21263generally, but not always, improves performance and code size, at the cost of
21264extra compilation time, which is why there is an option to switch it off.
21265If you have a problem with call instructions exceeding their allowable
21266offset range because they are conditionalized, you should consider using
21267@option{-mmedium-calls} instead.
21268
21269@item -mearly-cbranchsi
21270@opindex mearly-cbranchsi
21271Enable pre-reload use of the @code{cbranchsi} pattern.
21272
21273@item -mexpand-adddi
21274@opindex mexpand-adddi
21275Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21276@code{add.f}, @code{adc} etc. This option is deprecated.
21277
21278@item -mindexed-loads
21279@opindex mindexed-loads
21280Enable the use of indexed loads. This can be problematic because some
21281optimizers then assume that indexed stores exist, which is not
21282the case.
21283
21284@item -mlra
21285@opindex mlra
21286Enable Local Register Allocation. This is still experimental for ARC,
21287so by default the compiler uses standard reload
21288(i.e.@: @option{-mno-lra}).
21289
21290@item -mlra-priority-none
21291@opindex mlra-priority-none
21292Don't indicate any priority for target registers.
21293
21294@item -mlra-priority-compact
21295@opindex mlra-priority-compact
21296Indicate target register priority for r0..r3 / r12..r15.
21297
21298@item -mlra-priority-noncompact
21299@opindex mlra-priority-noncompact
21300Reduce target register priority for r0..r3 / r12..r15.
21301
21302@item -mmillicode
21303@opindex mmillicode
21304When optimizing for size (using @option{-Os}), prologues and epilogues
21305that have to save or restore a large number of registers are often
21306shortened by using call to a special function in libgcc; this is
21307referred to as a @emph{millicode} call. As these calls can pose
21308performance issues, and/or cause linking issues when linking in a
21309nonstandard way, this option is provided to turn on or off millicode
21310call generation.
21311
21312@item -mcode-density-frame
21313@opindex mcode-density-frame
21314This option enable the compiler to emit @code{enter} and @code{leave}
21315instructions. These instructions are only valid for CPUs with
21316code-density feature.
21317
21318@item -mmixed-code
21319@opindex mmixed-code
21320Does nothing. Preserved for backward compatibility.
21321
21322@item -mq-class
21323@opindex mq-class
21324Ths option is deprecated. Enable @samp{q} instruction alternatives.
21325This is the default for @option{-Os}.
21326
21327@item -mRcq
21328@opindex mRcq
21329Does nothing. Preserved for backward compatibility.
21330
21331@item -mRcw
21332@opindex mRcw
21333Does nothing. Preserved for backward compatibility.
21334
21335@item -msize-level=@var{level}
21336@opindex msize-level
21337Fine-tune size optimization with regards to instruction lengths and alignment.
21338The recognized values for @var{level} are:
21339@table @samp
21340@item 0
21341No size optimization. This level is deprecated and treated like @samp{1}.
21342
21343@item 1
21344Short instructions are used opportunistically.
21345
21346@item 2
21347In addition, alignment of loops and of code after barriers are dropped.
21348
21349@item 3
21350In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21351
21352@end table
21353
21354This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21355the behavior when this is not set is equivalent to level @samp{1}.
21356
21357@item -mtune=@var{cpu}
21358@opindex mtune
21359Set instruction scheduling parameters for @var{cpu}, overriding any implied
21360by @option{-mcpu=}.
21361
21362Supported values for @var{cpu} are
21363
21364@table @samp
21365@item ARC600
21366Tune for ARC600 CPU.
21367
21368@item ARC601
21369Tune for ARC601 CPU.
21370
21371@item ARC700
21372Tune for ARC700 CPU with standard multiplier block.
21373
21374@item ARC700-xmac
21375Tune for ARC700 CPU with XMAC block.
21376
21377@item ARC725D
21378Tune for ARC725D CPU.
21379
21380@item ARC750D
21381Tune for ARC750D CPU.
21382
21383@item core3
21384Tune for ARCv2 core3 type CPU. This option enable usage of
21385@code{dbnz} instruction.
21386
21387@item release31a
21388Tune for ARC4x release 3.10a.
21389
21390@end table
21391
21392@item -mmultcost=@var{num}
21393@opindex mmultcost
21394Cost to assume for a multiply instruction, with @samp{4} being equal to a
21395normal instruction.
21396
21397@item -munalign-prob-threshold=@var{probability}
21398@opindex munalign-prob-threshold
21399Does nothing. Preserved for backward compatibility.
21400
21401@end table
21402
21403The following options are maintained for backward compatibility, but
21404are now deprecated and will be removed in a future release:
21405
21406@c Deprecated options
21407@table @gcctabopt
21408
21409@item -margonaut
21410@opindex margonaut
21411Obsolete FPX.
21412
21413@item -mbig-endian
21414@opindex mbig-endian
21415@itemx -EB
21416@opindex EB
21417Compile code for big-endian targets. Use of these options is now
21418deprecated. Big-endian code is supported by configuring GCC to build
21419@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21420for which big endian is the default.
21421
21422@item -mlittle-endian
21423@opindex mlittle-endian
21424@itemx -EL
21425@opindex EL
21426Compile code for little-endian targets. Use of these options is now
21427deprecated. Little-endian code is supported by configuring GCC to build
21428@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21429for which little endian is the default.
21430
21431@item -mbarrel_shifter
21432@opindex mbarrel_shifter
21433Replaced by @option{-mbarrel-shifter}.
21434
21435@item -mdpfp_compact
21436@opindex mdpfp_compact
21437Replaced by @option{-mdpfp-compact}.
21438
21439@item -mdpfp_fast
21440@opindex mdpfp_fast
21441Replaced by @option{-mdpfp-fast}.
21442
21443@item -mdsp_packa
21444@opindex mdsp_packa
21445Replaced by @option{-mdsp-packa}.
21446
21447@item -mEA
21448@opindex mEA
21449Replaced by @option{-mea}.
21450
21451@item -mmac_24
21452@opindex mmac_24
21453Replaced by @option{-mmac-24}.
21454
21455@item -mmac_d16
21456@opindex mmac_d16
21457Replaced by @option{-mmac-d16}.
21458
21459@item -mspfp_compact
21460@opindex mspfp_compact
21461Replaced by @option{-mspfp-compact}.
21462
21463@item -mspfp_fast
21464@opindex mspfp_fast
21465Replaced by @option{-mspfp-fast}.
21466
21467@item -mtune=@var{cpu}
21468@opindex mtune
21469Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21470@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21471@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21472
21473@item -multcost=@var{num}
21474@opindex multcost
21475Replaced by @option{-mmultcost}.
21476
21477@end table
21478
21479@node ARM Options
21480@subsection ARM Options
21481@cindex ARM options
21482
21483These @samp{-m} options are defined for the ARM port:
21484
21485@table @gcctabopt
21486@item -mabi=@var{name}
21487@opindex mabi
21488Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21489@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21490
21491@item -mapcs-frame
21492@opindex mapcs-frame
21493Generate a stack frame that is compliant with the ARM Procedure Call
21494Standard for all functions, even if this is not strictly necessary for
21495correct execution of the code. Specifying @option{-fomit-frame-pointer}
21496with this option causes the stack frames not to be generated for
21497leaf functions. The default is @option{-mno-apcs-frame}.
21498This option is deprecated.
21499
21500@item -mapcs
21501@opindex mapcs
21502This is a synonym for @option{-mapcs-frame} and is deprecated.
21503
21504@ignore
21505@c not currently implemented
21506@item -mapcs-stack-check
21507@opindex mapcs-stack-check
21508Generate code to check the amount of stack space available upon entry to
21509every function (that actually uses some stack space). If there is
21510insufficient space available then either the function
21511@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21512called, depending upon the amount of stack space required. The runtime
21513system is required to provide these functions. The default is
21514@option{-mno-apcs-stack-check}, since this produces smaller code.
21515
21516@c not currently implemented
21517@item -mapcs-reentrant
21518@opindex mapcs-reentrant
21519Generate reentrant, position-independent code. The default is
21520@option{-mno-apcs-reentrant}.
21521@end ignore
21522
21523@item -mthumb-interwork
21524@opindex mthumb-interwork
21525Generate code that supports calling between the ARM and Thumb
21526instruction sets. Without this option, on pre-v5 architectures, the
21527two instruction sets cannot be reliably used inside one program. The
21528default is @option{-mno-thumb-interwork}, since slightly larger code
21529is generated when @option{-mthumb-interwork} is specified. In AAPCS
21530configurations this option is meaningless.
21531
21532@item -mno-sched-prolog
21533@opindex mno-sched-prolog
21534@opindex msched-prolog
21535Prevent the reordering of instructions in the function prologue, or the
21536merging of those instruction with the instructions in the function's
21537body. This means that all functions start with a recognizable set
21538of instructions (or in fact one of a choice from a small set of
21539different function prologues), and this information can be used to
21540locate the start of functions inside an executable piece of code. The
21541default is @option{-msched-prolog}.
21542
21543@item -mfloat-abi=@var{name}
21544@opindex mfloat-abi
21545Specifies which floating-point ABI to use. Permissible values
21546are: @samp{soft}, @samp{softfp} and @samp{hard}.
21547
21548Specifying @samp{soft} causes GCC to generate output containing
21549library calls for floating-point operations.
21550@samp{softfp} allows the generation of code using hardware floating-point
21551instructions, but still uses the soft-float calling conventions.
21552@samp{hard} allows generation of floating-point instructions
21553and uses FPU-specific calling conventions.
21554
21555The default depends on the specific target configuration. Note that
21556the hard-float and soft-float ABIs are not link-compatible; you must
21557compile your entire program with the same ABI, and link with a
21558compatible set of libraries.
21559
21560@item -mgeneral-regs-only
21561@opindex mgeneral-regs-only
21562Generate code which uses only the general-purpose registers. This will prevent
21563the compiler from using floating-point and Advanced SIMD registers but will not
21564impose any restrictions on the assembler.
21565
21566@item -mlittle-endian
21567@opindex mlittle-endian
21568Generate code for a processor running in little-endian mode. This is
21569the default for all standard configurations.
21570
21571@item -mbig-endian
21572@opindex mbig-endian
21573Generate code for a processor running in big-endian mode; the default is
21574to compile code for a little-endian processor.
21575
21576@item -mbe8
21577@itemx -mbe32
21578@opindex mbe8
21579When linking a big-endian image select between BE8 and BE32 formats.
21580The option has no effect for little-endian images and is ignored. The
21581default is dependent on the selected target architecture. For ARMv6
21582and later architectures the default is BE8, for older architectures
21583the default is BE32. BE32 format has been deprecated by ARM.
21584
21585@item -march=@var{name}@r{[}+extension@dots{}@r{]}
21586@opindex march
21587This specifies the name of the target ARM architecture. GCC uses this
21588name to determine what kind of instructions it can emit when generating
21589assembly code. This option can be used in conjunction with or instead
21590of the @option{-mcpu=} option.
21591
21592Permissible names are:
21593@samp{armv4t},
21594@samp{armv5t}, @samp{armv5te},
21595@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
21596@samp{armv6z}, @samp{armv6zk},
21597@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
21598@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
21599@samp{armv8.4-a},
21600@samp{armv8.5-a},
21601@samp{armv8.6-a},
21602@samp{armv9-a},
21603@samp{armv7-r},
21604@samp{armv8-r},
21605@samp{armv6-m}, @samp{armv6s-m},
21606@samp{armv7-m}, @samp{armv7e-m},
21607@samp{armv8-m.base}, @samp{armv8-m.main},
21608@samp{armv8.1-m.main},
21609@samp{armv9-a},
21610@samp{iwmmxt} and @samp{iwmmxt2}.
21611
21612Additionally, the following architectures, which lack support for the
21613Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
21614
21615Many of the architectures support extensions. These can be added by
21616appending @samp{+@var{extension}} to the architecture name. Extension
21617options are processed in order and capabilities accumulate. An extension
21618will also enable any necessary base extensions
21619upon which it depends. For example, the @samp{+crypto} extension
21620will always enable the @samp{+simd} extension. The exception to the
21621additive construction is for extensions that are prefixed with
21622@samp{+no@dots{}}: these extensions disable the specified option and
21623any other extensions that may depend on the presence of that
21624extension.
21625
21626For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
21627writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
21628entirely disabled by the @samp{+nofp} option that follows it.
21629
21630Most extension names are generically named, but have an effect that is
21631dependent upon the architecture to which it is applied. For example,
21632the @samp{+simd} option can be applied to both @samp{armv7-a} and
21633@samp{armv8-a} architectures, but will enable the original ARMv7-A
21634Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
21635variant for @samp{armv8-a}.
21636
21637The table below lists the supported extensions for each architecture.
21638Architectures not mentioned do not support any extensions.
21639
21640@table @samp
21641@item armv5te
21642@itemx armv6
21643@itemx armv6j
21644@itemx armv6k
21645@itemx armv6kz
21646@itemx armv6t2
21647@itemx armv6z
21648@itemx armv6zk
21649@table @samp
21650@item +fp
21651The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
21652used as an alias for this extension.
21653
21654@item +nofp
21655Disable the floating-point instructions.
21656@end table
21657
21658@item armv7
21659The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
21660@table @samp
21661@item +fp
21662The VFPv3 floating-point instructions, with 16 double-precision
21663registers. The extension @samp{+vfpv3-d16} can be used as an alias
21664for this extension. Note that floating-point is not supported by the
21665base ARMv7-M architecture, but is compatible with both the ARMv7-A and
21666ARMv7-R architectures.
21667
21668@item +nofp
21669Disable the floating-point instructions.
21670@end table
21671
21672@item armv7-a
21673@table @samp
21674@item +mp
21675The multiprocessing extension.
21676
21677@item +sec
21678The security extension.
21679
21680@item +fp
21681The VFPv3 floating-point instructions, with 16 double-precision
21682registers. The extension @samp{+vfpv3-d16} can be used as an alias
21683for this extension.
21684
21685@item +simd
21686The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21687The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
21688for this extension.
21689
21690@item +vfpv3
21691The VFPv3 floating-point instructions, with 32 double-precision
21692registers.
21693
21694@item +vfpv3-d16-fp16
21695The VFPv3 floating-point instructions, with 16 double-precision
21696registers and the half-precision floating-point conversion operations.
21697
21698@item +vfpv3-fp16
21699The VFPv3 floating-point instructions, with 32 double-precision
21700registers and the half-precision floating-point conversion operations.
21701
21702@item +vfpv4-d16
21703The VFPv4 floating-point instructions, with 16 double-precision
21704registers.
21705
21706@item +vfpv4
21707The VFPv4 floating-point instructions, with 32 double-precision
21708registers.
21709
21710@item +neon-fp16
21711The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21712the half-precision floating-point conversion operations.
21713
21714@item +neon-vfpv4
21715The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
21716
21717@item +nosimd
21718Disable the Advanced SIMD instructions (does not disable floating point).
21719
21720@item +nofp
21721Disable the floating-point and Advanced SIMD instructions.
21722@end table
21723
21724@item armv7ve
21725The extended version of the ARMv7-A architecture with support for
21726virtualization.
21727@table @samp
21728@item +fp
21729The VFPv4 floating-point instructions, with 16 double-precision registers.
21730The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
21731
21732@item +simd
21733The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
21734extension @samp{+neon-vfpv4} can be used as an alias for this extension.
21735
21736@item +vfpv3-d16
21737The VFPv3 floating-point instructions, with 16 double-precision
21738registers.
21739
21740@item +vfpv3
21741The VFPv3 floating-point instructions, with 32 double-precision
21742registers.
21743
21744@item +vfpv3-d16-fp16
21745The VFPv3 floating-point instructions, with 16 double-precision
21746registers and the half-precision floating-point conversion operations.
21747
21748@item +vfpv3-fp16
21749The VFPv3 floating-point instructions, with 32 double-precision
21750registers and the half-precision floating-point conversion operations.
21751
21752@item +vfpv4-d16
21753The VFPv4 floating-point instructions, with 16 double-precision
21754registers.
21755
21756@item +vfpv4
21757The VFPv4 floating-point instructions, with 32 double-precision
21758registers.
21759
21760@item +neon
21761The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21762The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
21763
21764@item +neon-fp16
21765The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21766the half-precision floating-point conversion operations.
21767
21768@item +nosimd
21769Disable the Advanced SIMD instructions (does not disable floating point).
21770
21771@item +nofp
21772Disable the floating-point and Advanced SIMD instructions.
21773@end table
21774
21775@item armv8-a
21776@table @samp
21777@item +crc
21778The Cyclic Redundancy Check (CRC) instructions.
21779@item +simd
21780The ARMv8-A Advanced SIMD and floating-point instructions.
21781@item +crypto
21782The cryptographic instructions.
21783@item +nocrypto
21784Disable the cryptographic instructions.
21785@item +nofp
21786Disable the floating-point, Advanced SIMD and cryptographic instructions.
21787@item +sb
21788Speculation Barrier Instruction.
21789@item +predres
21790Execution and Data Prediction Restriction Instructions.
21791@end table
21792
21793@item armv8.1-a
21794@table @samp
21795@item +simd
21796The ARMv8.1-A Advanced SIMD and floating-point instructions.
21797
21798@item +crypto
21799The cryptographic instructions. This also enables the Advanced SIMD and
21800floating-point instructions.
21801
21802@item +nocrypto
21803Disable the cryptographic instructions.
21804
21805@item +nofp
21806Disable the floating-point, Advanced SIMD and cryptographic instructions.
21807
21808@item +sb
21809Speculation Barrier Instruction.
21810
21811@item +predres
21812Execution and Data Prediction Restriction Instructions.
21813@end table
21814
21815@item armv8.2-a
21816@itemx armv8.3-a
21817@table @samp
21818@item +fp16
21819The half-precision floating-point data processing instructions.
21820This also enables the Advanced SIMD and floating-point instructions.
21821
21822@item +fp16fml
21823The half-precision floating-point fmla extension. This also enables
21824the half-precision floating-point extension and Advanced SIMD and
21825floating-point instructions.
21826
21827@item +simd
21828The ARMv8.1-A Advanced SIMD and floating-point instructions.
21829
21830@item +crypto
21831The cryptographic instructions. This also enables the Advanced SIMD and
21832floating-point instructions.
21833
21834@item +dotprod
21835Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21836
21837@item +nocrypto
21838Disable the cryptographic extension.
21839
21840@item +nofp
21841Disable the floating-point, Advanced SIMD and cryptographic instructions.
21842
21843@item +sb
21844Speculation Barrier Instruction.
21845
21846@item +predres
21847Execution and Data Prediction Restriction Instructions.
21848
21849@item +i8mm
218508-bit Integer Matrix Multiply instructions.
21851This also enables Advanced SIMD and floating-point instructions.
21852
21853@item +bf16
21854Brain half-precision floating-point instructions.
21855This also enables Advanced SIMD and floating-point instructions.
21856@end table
21857
21858@item armv8.4-a
21859@table @samp
21860@item +fp16
21861The half-precision floating-point data processing instructions.
21862This also enables the Advanced SIMD and floating-point instructions as well
21863as the Dot Product extension and the half-precision floating-point fmla
21864extension.
21865
21866@item +simd
21867The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21868Dot Product extension.
21869
21870@item +crypto
21871The cryptographic instructions. This also enables the Advanced SIMD and
21872floating-point instructions as well as the Dot Product extension.
21873
21874@item +nocrypto
21875Disable the cryptographic extension.
21876
21877@item +nofp
21878Disable the floating-point, Advanced SIMD and cryptographic instructions.
21879
21880@item +sb
21881Speculation Barrier Instruction.
21882
21883@item +predres
21884Execution and Data Prediction Restriction Instructions.
21885
21886@item +i8mm
218878-bit Integer Matrix Multiply instructions.
21888This also enables Advanced SIMD and floating-point instructions.
21889
21890@item +bf16
21891Brain half-precision floating-point instructions.
21892This also enables Advanced SIMD and floating-point instructions.
21893@end table
21894
21895@item armv8.5-a
21896@table @samp
21897@item +fp16
21898The half-precision floating-point data processing instructions.
21899This also enables the Advanced SIMD and floating-point instructions as well
21900as the Dot Product extension and the half-precision floating-point fmla
21901extension.
21902
21903@item +simd
21904The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21905Dot Product extension.
21906
21907@item +crypto
21908The cryptographic instructions. This also enables the Advanced SIMD and
21909floating-point instructions as well as the Dot Product extension.
21910
21911@item +nocrypto
21912Disable the cryptographic extension.
21913
21914@item +nofp
21915Disable the floating-point, Advanced SIMD and cryptographic instructions.
21916
21917@item +i8mm
219188-bit Integer Matrix Multiply instructions.
21919This also enables Advanced SIMD and floating-point instructions.
21920
21921@item +bf16
21922Brain half-precision floating-point instructions.
21923This also enables Advanced SIMD and floating-point instructions.
21924@end table
21925
21926@item armv8.6-a
21927@table @samp
21928@item +fp16
21929The half-precision floating-point data processing instructions.
21930This also enables the Advanced SIMD and floating-point instructions as well
21931as the Dot Product extension and the half-precision floating-point fmla
21932extension.
21933
21934@item +simd
21935The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21936Dot Product extension.
21937
21938@item +crypto
21939The cryptographic instructions. This also enables the Advanced SIMD and
21940floating-point instructions as well as the Dot Product extension.
21941
21942@item +nocrypto
21943Disable the cryptographic extension.
21944
21945@item +nofp
21946Disable the floating-point, Advanced SIMD and cryptographic instructions.
21947
21948@item +i8mm
219498-bit Integer Matrix Multiply instructions.
21950This also enables Advanced SIMD and floating-point instructions.
21951
21952@item +bf16
21953Brain half-precision floating-point instructions.
21954This also enables Advanced SIMD and floating-point instructions.
21955@end table
21956
21957@item armv7-r
21958@table @samp
21959@item +fp.sp
21960The single-precision VFPv3 floating-point instructions. The extension
21961@samp{+vfpv3xd} can be used as an alias for this extension.
21962
21963@item +fp
21964The VFPv3 floating-point instructions with 16 double-precision registers.
21965The extension +vfpv3-d16 can be used as an alias for this extension.
21966
21967@item +vfpv3xd-d16-fp16
21968The single-precision VFPv3 floating-point instructions with 16 double-precision
21969registers and the half-precision floating-point conversion operations.
21970
21971@item +vfpv3-d16-fp16
21972The VFPv3 floating-point instructions with 16 double-precision
21973registers and the half-precision floating-point conversion operations.
21974
21975@item +nofp
21976Disable the floating-point extension.
21977
21978@item +idiv
21979The ARM-state integer division instructions.
21980
21981@item +noidiv
21982Disable the ARM-state integer division extension.
21983@end table
21984
21985@item armv7e-m
21986@table @samp
21987@item +fp
21988The single-precision VFPv4 floating-point instructions.
21989
21990@item +fpv5
21991The single-precision FPv5 floating-point instructions.
21992
21993@item +fp.dp
21994The single- and double-precision FPv5 floating-point instructions.
21995
21996@item +nofp
21997Disable the floating-point extensions.
21998@end table
21999
22000@item armv8.1-m.main
22001@table @samp
22002
22003@item +dsp
22004The DSP instructions.
22005
22006@item +mve
22007The M-Profile Vector Extension (MVE) integer instructions.
22008
22009@item +mve.fp
22010The M-Profile Vector Extension (MVE) integer and single precision
22011floating-point instructions.
22012
22013@item +fp
22014The single-precision floating-point instructions.
22015
22016@item +fp.dp
22017The single- and double-precision floating-point instructions.
22018
22019@item +nofp
22020Disable the floating-point extension.
22021
22022@item +cdecp0, +cdecp1, ... , +cdecp7
22023Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22024to the numbers given in the options in the range 0 to 7.
22025@end table
22026
22027@item armv8-m.main
22028@table @samp
22029@item +dsp
22030The DSP instructions.
22031
22032@item +nodsp
22033Disable the DSP extension.
22034
22035@item +fp
22036The single-precision floating-point instructions.
22037
22038@item +fp.dp
22039The single- and double-precision floating-point instructions.
22040
22041@item +nofp
22042Disable the floating-point extension.
22043
22044@item +cdecp0, +cdecp1, ... , +cdecp7
22045Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22046to the numbers given in the options in the range 0 to 7.
22047@end table
22048
22049@item armv8-r
22050@table @samp
22051@item +crc
22052The Cyclic Redundancy Check (CRC) instructions.
22053@item +fp.sp
22054The single-precision FPv5 floating-point instructions.
22055@item +simd
22056The ARMv8-A Advanced SIMD and floating-point instructions.
22057@item +crypto
22058The cryptographic instructions.
22059@item +nocrypto
22060Disable the cryptographic instructions.
22061@item +nofp
22062Disable the floating-point, Advanced SIMD and cryptographic instructions.
22063@end table
22064
22065@end table
22066
22067@option{-march=native} causes the compiler to auto-detect the architecture
22068of the build computer. At present, this feature is only supported on
22069GNU/Linux, and not all architectures are recognized. If the auto-detect
22070is unsuccessful the option has no effect.
22071
22072@item -mtune=@var{name}
22073@opindex mtune
22074This option specifies the name of the target ARM processor for
22075which GCC should tune the performance of the code.
22076For some ARM implementations better performance can be obtained by using
22077this option.
22078Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22079@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22080@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22081@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22082@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22083@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22084@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22085@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22086@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22087@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22088@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22089@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22090@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22091@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22092@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22093@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22094@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22095@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22096@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
23a121d4 22097@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-x1}, @samp{cortex-x1c},
d77de738
ML
22098@samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
22099@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22100@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22101@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22102@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22103@samp{xgene1}.
22104
22105Additionally, this option can specify that GCC should tune the performance
22106of the code for a big.LITTLE system. Permissible names are:
22107@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22108@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22109@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22110@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22111
22112@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22113performance for a blend of processors within architecture @var{arch}.
22114The aim is to generate code that run well on the current most popular
22115processors, balancing between optimizations that benefit some CPUs in the
22116range, and avoiding performance pitfalls of other CPUs. The effects of
22117this option may change in future GCC versions as CPU models come and go.
22118
22119@option{-mtune} permits the same extension options as @option{-mcpu}, but
22120the extension options do not affect the tuning of the generated code.
22121
22122@option{-mtune=native} causes the compiler to auto-detect the CPU
22123of the build computer. At present, this feature is only supported on
22124GNU/Linux, and not all architectures are recognized. If the auto-detect is
22125unsuccessful the option has no effect.
22126
22127@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
22128@opindex mcpu
22129This specifies the name of the target ARM processor. GCC uses this name
22130to derive the name of the target ARM architecture (as if specified
22131by @option{-march}) and the ARM processor type for which to tune for
22132performance (as if specified by @option{-mtune}). Where this option
22133is used in conjunction with @option{-march} or @option{-mtune},
22134those options take precedence over the appropriate part of this option.
22135
22136Many of the supported CPUs implement optional architectural
22137extensions. Where this is so the architectural extensions are
22138normally enabled by default. If implementations that lack the
22139extension exist, then the extension syntax can be used to disable
22140those extensions that have been omitted. For floating-point and
22141Advanced SIMD (Neon) instructions, the settings of the options
22142@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22143floating-point and Advanced SIMD instructions will only be used if
22144@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22145@option{-mfpu} other than @samp{auto} will override the available
22146floating-point and SIMD extension instructions.
22147
22148For example, @samp{cortex-a9} can be found in three major
22149configurations: integer only, with just a floating-point unit or with
22150floating-point and Advanced SIMD. The default is to enable all the
22151instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22152be used to disable just the SIMD or both the SIMD and floating-point
22153instructions respectively.
22154
22155Permissible names for this option are the same as those for
22156@option{-mtune}.
22157
22158The following extension options are common to the listed CPUs:
22159
22160@table @samp
22161@item +nodsp
22162Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}
22163and @samp{cortex-m55}. Also disable the M-Profile Vector Extension (MVE)
22164integer and single precision floating-point instructions on @samp{cortex-m55}.
22165
22166@item +nomve
22167Disable the M-Profile Vector Extension (MVE) integer and single precision
22168floating-point instructions on @samp{cortex-m55}.
22169
22170@item +nomve.fp
22171Disable the M-Profile Vector Extension (MVE) single precision floating-point
22172instructions on @samp{cortex-m55}.
22173
22174@item +nofp
22175Disables the floating-point instructions on @samp{arm9e},
22176@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22177@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22178@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22179@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
22180and @samp{cortex-m55}.
22181Disables the floating-point and SIMD instructions on
22182@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22183@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22184@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22185@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22186@samp{cortex-a53} and @samp{cortex-a55}.
22187
22188@item +nofp.dp
22189Disables the double-precision component of the floating-point instructions
22190on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22191@samp{cortex-r52plus} and @samp{cortex-m7}.
22192
22193@item +nosimd
22194Disables the SIMD (but not floating-point) instructions on
22195@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22196and @samp{cortex-a9}.
22197
22198@item +crypto
22199Enables the cryptographic instructions on @samp{cortex-a32},
22200@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22201@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22202@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22203@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22204@samp{cortex-a75.cortex-a55}.
22205@end table
22206
22207Additionally the @samp{generic-armv7-a} pseudo target defaults to
22208VFPv3 with 16 double-precision registers. It supports the following
22209extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22210@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22211@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22212@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22213the extensions to @option{-march=armv7-a}.
22214
22215@option{-mcpu=generic-@var{arch}} is also permissible, and is
22216equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22217See @option{-mtune} for more information.
22218
22219@option{-mcpu=native} causes the compiler to auto-detect the CPU
22220of the build computer. At present, this feature is only supported on
22221GNU/Linux, and not all architectures are recognized. If the auto-detect
22222is unsuccessful the option has no effect.
22223
22224@item -mfpu=@var{name}
22225@opindex mfpu
22226This specifies what floating-point hardware (or hardware emulation) is
22227available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22228@samp{vfpv3},
22229@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22230@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22231@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22232@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22233@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22234Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22235is an alias for @samp{vfpv2}.
22236
22237The setting @samp{auto} is the default and is special. It causes the
22238compiler to select the floating-point and Advanced SIMD instructions
22239based on the settings of @option{-mcpu} and @option{-march}.
22240
22241If the selected floating-point hardware includes the NEON extension
22242(e.g.@: @option{-mfpu=neon}), note that floating-point
22243operations are not generated by GCC's auto-vectorization pass unless
22244@option{-funsafe-math-optimizations} is also specified. This is
22245because NEON hardware does not fully implement the IEEE 754 standard for
22246floating-point arithmetic (in particular denormal values are treated as
22247zero), so the use of NEON instructions may lead to a loss of precision.
22248
22249You 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}).
22250
22251@item -mfp16-format=@var{name}
22252@opindex mfp16-format
22253Specify the format of the @code{__fp16} half-precision floating-point type.
22254Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22255the default is @samp{none}, in which case the @code{__fp16} type is not
22256defined. @xref{Half-Precision}, for more information.
22257
22258@item -mstructure-size-boundary=@var{n}
22259@opindex mstructure-size-boundary
22260The sizes of all structures and unions are rounded up to a multiple
22261of the number of bits set by this option. Permissible values are 8, 32
22262and 64. The default value varies for different toolchains. For the COFF
22263targeted toolchain the default value is 8. A value of 64 is only allowed
22264if the underlying ABI supports it.
22265
22266Specifying a larger number can produce faster, more efficient code, but
22267can also increase the size of the program. Different values are potentially
22268incompatible. Code compiled with one value cannot necessarily expect to
22269work with code or libraries compiled with another value, if they exchange
22270information using structures or unions.
22271
22272This option is deprecated.
22273
22274@item -mabort-on-noreturn
22275@opindex mabort-on-noreturn
22276Generate a call to the function @code{abort} at the end of a
22277@code{noreturn} function. It is executed if the function tries to
22278return.
22279
22280@item -mlong-calls
22281@itemx -mno-long-calls
22282@opindex mlong-calls
22283@opindex mno-long-calls
22284Tells the compiler to perform function calls by first loading the
22285address of the function into a register and then performing a subroutine
22286call on this register. This switch is needed if the target function
22287lies outside of the 64-megabyte addressing range of the offset-based
22288version of subroutine call instruction.
22289
22290Even if this switch is enabled, not all function calls are turned
22291into long calls. The heuristic is that static functions, functions
22292that have the @code{short_call} attribute, functions that are inside
22293the scope of a @code{#pragma no_long_calls} directive, and functions whose
22294definitions have already been compiled within the current compilation
22295unit are not turned into long calls. The exceptions to this rule are
22296that weak function definitions, functions with the @code{long_call}
22297attribute or the @code{section} attribute, and functions that are within
22298the scope of a @code{#pragma long_calls} directive are always
22299turned into long calls.
22300
22301This feature is not enabled by default. Specifying
22302@option{-mno-long-calls} restores the default behavior, as does
22303placing the function calls within the scope of a @code{#pragma
22304long_calls_off} directive. Note these switches have no effect on how
22305the compiler generates code to handle function calls via function
22306pointers.
22307
22308@item -msingle-pic-base
22309@opindex msingle-pic-base
22310Treat the register used for PIC addressing as read-only, rather than
22311loading it in the prologue for each function. The runtime system is
22312responsible for initializing this register with an appropriate value
22313before execution begins.
22314
22315@item -mpic-register=@var{reg}
22316@opindex mpic-register
22317Specify the register to be used for PIC addressing.
22318For standard PIC base case, the default is any suitable register
22319determined by compiler. For single PIC base case, the default is
22320@samp{R9} if target is EABI based or stack-checking is enabled,
22321otherwise the default is @samp{R10}.
22322
22323@item -mpic-data-is-text-relative
22324@opindex mpic-data-is-text-relative
22325Assume that the displacement between the text and data segments is fixed
22326at static link time. This permits using PC-relative addressing
22327operations to access data known to be in the data segment. For
22328non-VxWorks RTP targets, this option is enabled by default. When
22329disabled on such targets, it will enable @option{-msingle-pic-base} by
22330default.
22331
22332@item -mpoke-function-name
22333@opindex mpoke-function-name
22334Write the name of each function into the text section, directly
22335preceding the function prologue. The generated code is similar to this:
22336
22337@smallexample
22338 t0
22339 .ascii "arm_poke_function_name", 0
22340 .align
22341 t1
22342 .word 0xff000000 + (t1 - t0)
22343 arm_poke_function_name
22344 mov ip, sp
22345 stmfd sp!, @{fp, ip, lr, pc@}
22346 sub fp, ip, #4
22347@end smallexample
22348
22349When performing a stack backtrace, code can inspect the value of
22350@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22351location @code{pc - 12} and the top 8 bits are set, then we know that
22352there is a function name embedded immediately preceding this location
22353and has length @code{((pc[-3]) & 0xff000000)}.
22354
22355@item -mthumb
22356@itemx -marm
22357@opindex marm
22358@opindex mthumb
22359
22360Select between generating code that executes in ARM and Thumb
22361states. The default for most configurations is to generate code
22362that executes in ARM state, but the default can be changed by
22363configuring GCC with the @option{--with-mode=}@var{state}
22364configure option.
22365
22366You can also override the ARM and Thumb mode for each function
22367by using the @code{target("thumb")} and @code{target("arm")} function attributes
22368(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22369
22370@item -mflip-thumb
22371@opindex mflip-thumb
22372Switch ARM/Thumb modes on alternating functions.
22373This option is provided for regression testing of mixed Thumb/ARM code
22374generation, and is not intended for ordinary use in compiling code.
22375
22376@item -mtpcs-frame
22377@opindex mtpcs-frame
22378Generate a stack frame that is compliant with the Thumb Procedure Call
22379Standard for all non-leaf functions. (A leaf function is one that does
22380not call any other functions.) The default is @option{-mno-tpcs-frame}.
22381
22382@item -mtpcs-leaf-frame
22383@opindex mtpcs-leaf-frame
22384Generate a stack frame that is compliant with the Thumb Procedure Call
22385Standard for all leaf functions. (A leaf function is one that does
22386not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22387
22388@item -mcallee-super-interworking
22389@opindex mcallee-super-interworking
22390Gives all externally visible functions in the file being compiled an ARM
22391instruction set header which switches to Thumb mode before executing the
22392rest of the function. This allows these functions to be called from
22393non-interworking code. This option is not valid in AAPCS configurations
22394because interworking is enabled by default.
22395
22396@item -mcaller-super-interworking
22397@opindex mcaller-super-interworking
22398Allows calls via function pointers (including virtual functions) to
22399execute correctly regardless of whether the target code has been
22400compiled for interworking or not. There is a small overhead in the cost
22401of executing a function pointer if this option is enabled. This option
22402is not valid in AAPCS configurations because interworking is enabled
22403by default.
22404
22405@item -mtp=@var{name}
22406@opindex mtp
22407Specify the access model for the thread local storage pointer. The valid
22408models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
22409@samp{cp15}, which fetches the thread pointer from @code{cp15} directly
22410(supported in the arm6k architecture), and @samp{auto}, which uses the
22411best available method for the selected processor. The default setting is
22412@samp{auto}.
22413
22414@item -mtls-dialect=@var{dialect}
22415@opindex mtls-dialect
22416Specify the dialect to use for accessing thread local storage. Two
22417@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22418@samp{gnu} dialect selects the original GNU scheme for supporting
22419local and global dynamic TLS models. The @samp{gnu2} dialect
22420selects the GNU descriptor scheme, which provides better performance
22421for shared libraries. The GNU descriptor scheme is compatible with
22422the original scheme, but does require new assembler, linker and
22423library support. Initial and local exec TLS models are unaffected by
22424this option and always use the original scheme.
22425
22426@item -mword-relocations
22427@opindex mword-relocations
22428Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22429This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22430loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22431is specified. This option conflicts with @option{-mslow-flash-data}.
22432
22433@item -mfix-cortex-m3-ldrd
22434@opindex mfix-cortex-m3-ldrd
22435Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22436with overlapping destination and base registers are used. This option avoids
22437generating these instructions. This option is enabled by default when
22438@option{-mcpu=cortex-m3} is specified.
22439
22440@item -mfix-cortex-a57-aes-1742098
22441@itemx -mno-fix-cortex-a57-aes-1742098
22442@itemx -mfix-cortex-a72-aes-1655431
22443@itemx -mno-fix-cortex-a72-aes-1655431
22444Enable (disable) mitigation for an erratum on Cortex-A57 and
22445Cortex-A72 that affects the AES cryptographic instructions. This
22446option is enabled by default when either @option{-mcpu=cortex-a57} or
22447@option{-mcpu=cortex-a72} is specified.
22448
22449@item -munaligned-access
22450@itemx -mno-unaligned-access
22451@opindex munaligned-access
22452@opindex mno-unaligned-access
22453Enables (or disables) reading and writing of 16- and 32- bit values
22454from addresses that are not 16- or 32- bit aligned. By default
22455unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22456ARMv8-M Baseline architectures, and enabled for all other
22457architectures. If unaligned access is not enabled then words in packed
22458data structures are accessed a byte at a time.
22459
22460The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22461generated object file to either true or false, depending upon the
22462setting of this option. If unaligned access is enabled then the
22463preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22464defined.
22465
22466@item -mneon-for-64bits
22467@opindex mneon-for-64bits
22468This option is deprecated and has no effect.
22469
22470@item -mslow-flash-data
22471@opindex mslow-flash-data
22472Assume loading data from flash is slower than fetching instruction.
22473Therefore literal load is minimized for better performance.
22474This option is only supported when compiling for ARMv7 M-profile and
22475off by default. It conflicts with @option{-mword-relocations}.
22476
22477@item -masm-syntax-unified
22478@opindex masm-syntax-unified
22479Assume inline assembler is using unified asm syntax. The default is
22480currently off which implies divided syntax. This option has no impact
22481on Thumb2. However, this may change in future releases of GCC.
22482Divided syntax should be considered deprecated.
22483
22484@item -mrestrict-it
22485@opindex mrestrict-it
22486Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22487IT blocks can only contain a single 16-bit instruction from a select
22488set of instructions. This option is on by default for ARMv8-A Thumb mode.
22489
22490@item -mprint-tune-info
22491@opindex mprint-tune-info
22492Print CPU tuning information as comment in assembler file. This is
22493an option used only for regression testing of the compiler and not
22494intended for ordinary use in compiling code. This option is disabled
22495by default.
22496
22497@item -mverbose-cost-dump
22498@opindex mverbose-cost-dump
22499Enable verbose cost model dumping in the debug dump files. This option is
22500provided for use in debugging the compiler.
22501
22502@item -mpure-code
22503@opindex mpure-code
22504Do not allow constant data to be placed in code sections.
22505Additionally, when compiling for ELF object format give all text sections the
22506ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22507is only available when generating non-pic code for M-profile targets.
22508
22509@item -mcmse
22510@opindex mcmse
22511Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22512Development Tools Engineering Specification", which can be found on
22513@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22514
22515@item -mfix-cmse-cve-2021-35465
22516@opindex mfix-cmse-cve-2021-35465
22517Mitigate against a potential security issue with the @code{VLLDM} instruction
22518in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22519enabled by default when the option @option{-mcpu=} is used with
22520@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55} or @code{star-mc1}.
22521The option @option{-mno-fix-cmse-cve-2021-35465} can be used to disable
22522the mitigation.
22523
22524@item -mstack-protector-guard=@var{guard}
22525@itemx -mstack-protector-guard-offset=@var{offset}
22526@opindex mstack-protector-guard
22527@opindex mstack-protector-guard-offset
22528Generate stack protection code using canary at @var{guard}. Supported
22529locations are @samp{global} for a global canary or @samp{tls} for a
22530canary accessible via the TLS register. The option
22531@option{-mstack-protector-guard-offset=} is for use with
22532@option{-fstack-protector-guard=tls} and not for use in user-land code.
22533
22534@item -mfdpic
22535@itemx -mno-fdpic
22536@opindex mfdpic
22537@opindex mno-fdpic
22538Select the FDPIC ABI, which uses 64-bit function descriptors to
22539represent pointers to functions. When the compiler is configured for
22540@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
22541and implies @option{-fPIE} if none of the PIC/PIE-related options is
22542provided. On other targets, it only enables the FDPIC-specific code
22543generation features, and the user should explicitly provide the
22544PIC/PIE-related options as needed.
22545
22546Note that static linking is not supported because it would still
22547involve the dynamic linker when the program self-relocates. If such
22548behavior is acceptable, use -static and -Wl,-dynamic-linker options.
22549
22550The opposite @option{-mno-fdpic} option is useful (and required) to
22551build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
22552toolchain as the one used to build the userland programs.
22553
22554@end table
22555
22556@node AVR Options
22557@subsection AVR Options
22558@cindex AVR Options
22559
22560These options are defined for AVR implementations:
22561
22562@table @gcctabopt
22563@item -mmcu=@var{mcu}
22564@opindex mmcu
22565Specify Atmel AVR instruction set architectures (ISA) or MCU type.
22566
22567The default for this option is@tie{}@samp{avr2}.
22568
22569GCC supports the following AVR devices and ISAs:
22570
22571@include avr-mmcu.texi
22572
22573@item -mabsdata
22574@opindex mabsdata
22575
22576Assume that all data in static storage can be accessed by LDS / STS
22577instructions. This option has only an effect on reduced Tiny devices like
22578ATtiny40. See also the @code{absdata}
22579@ref{AVR Variable Attributes,variable attribute}.
22580
22581@item -maccumulate-args
22582@opindex maccumulate-args
22583Accumulate outgoing function arguments and acquire/release the needed
22584stack space for outgoing function arguments once in function
22585prologue/epilogue. Without this option, outgoing arguments are pushed
22586before calling a function and popped afterwards.
22587
22588Popping the arguments after the function call can be expensive on
22589AVR so that accumulating the stack space might lead to smaller
22590executables because arguments need not be removed from the
22591stack after such a function call.
22592
22593This option can lead to reduced code size for functions that perform
22594several calls to functions that get their arguments on the stack like
22595calls to printf-like functions.
22596
22597@item -mbranch-cost=@var{cost}
22598@opindex mbranch-cost
22599Set the branch costs for conditional branch instructions to
22600@var{cost}. Reasonable values for @var{cost} are small, non-negative
22601integers. The default branch cost is 0.
22602
22603@item -mcall-prologues
22604@opindex mcall-prologues
22605Functions prologues/epilogues are expanded as calls to appropriate
22606subroutines. Code size is smaller.
22607
22608@item -mdouble=@var{bits}
22609@itemx -mlong-double=@var{bits}
22610@opindex mdouble
22611@opindex mlong-double
22612Set the size (in bits) of the @code{double} or @code{long double} type,
22613respectively. Possible values for @var{bits} are 32 and 64.
22614Whether or not a specific value for @var{bits} is allowed depends on
22615the @code{--with-double=} and @code{--with-long-double=}
22616@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
22617and the same applies for the default values of the options.
22618
22619@item -mgas-isr-prologues
22620@opindex mgas-isr-prologues
22621Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
22622instruction supported by GNU Binutils.
22623If this option is on, the feature can still be disabled for individual
22624ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
22625function attribute. This feature is activated per default
22626if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
22627and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
22628
22629@item -mint8
22630@opindex mint8
22631Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
22632@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
22633and @code{long long} is 4 bytes. Please note that this option does not
22634conform to the C standards, but it results in smaller code
22635size.
22636
22637@item -mmain-is-OS_task
22638@opindex mmain-is-OS_task
22639Do not save registers in @code{main}. The effect is the same like
22640attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
22641to @code{main}. It is activated per default if optimization is on.
22642
22643@item -mn-flash=@var{num}
22644@opindex mn-flash
22645Assume that the flash memory has a size of
22646@var{num} times 64@tie{}KiB.
22647
22648@item -mno-interrupts
22649@opindex mno-interrupts
22650Generated code is not compatible with hardware interrupts.
22651Code size is smaller.
22652
22653@item -mrelax
22654@opindex mrelax
22655Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
22656@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
22657Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
22658the assembler's command line and the @option{--relax} option to the
22659linker's command line.
22660
22661Jump relaxing is performed by the linker because jump offsets are not
22662known before code is located. Therefore, the assembler code generated by the
22663compiler is the same, but the instructions in the executable may
22664differ from instructions in the assembler code.
22665
22666Relaxing must be turned on if linker stubs are needed, see the
22667section on @code{EIND} and linker stubs below.
22668
22669@item -mrmw
22670@opindex mrmw
22671Assume that the device supports the Read-Modify-Write
22672instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
22673
22674@item -mshort-calls
22675@opindex mshort-calls
22676
22677Assume that @code{RJMP} and @code{RCALL} can target the whole
22678program memory.
22679
22680This option is used internally for multilib selection. It is
22681not an optimization option, and you don't need to set it by hand.
22682
22683@item -msp8
22684@opindex msp8
22685Treat the stack pointer register as an 8-bit register,
22686i.e.@: assume the high byte of the stack pointer is zero.
22687In general, you don't need to set this option by hand.
22688
22689This option is used internally by the compiler to select and
22690build multilibs for architectures @code{avr2} and @code{avr25}.
22691These architectures mix devices with and without @code{SPH}.
22692For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
22693the compiler driver adds or removes this option from the compiler
22694proper's command line, because the compiler then knows if the device
22695or architecture has an 8-bit stack pointer and thus no @code{SPH}
22696register or not.
22697
22698@item -mstrict-X
22699@opindex mstrict-X
22700Use address register @code{X} in a way proposed by the hardware. This means
22701that @code{X} is only used in indirect, post-increment or
22702pre-decrement addressing.
22703
22704Without this option, the @code{X} register may be used in the same way
22705as @code{Y} or @code{Z} which then is emulated by additional
22706instructions.
22707For example, loading a value with @code{X+const} addressing with a
22708small non-negative @code{const < 64} to a register @var{Rn} is
22709performed as
22710
22711@example
22712adiw r26, const ; X += const
22713ld @var{Rn}, X ; @var{Rn} = *X
22714sbiw r26, const ; X -= const
22715@end example
22716
22717@item -mtiny-stack
22718@opindex mtiny-stack
22719Only change the lower 8@tie{}bits of the stack pointer.
22720
22721@item -mfract-convert-truncate
22722@opindex mfract-convert-truncate
22723Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
22724
22725@item -nodevicelib
22726@opindex nodevicelib
22727Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
22728
22729@item -nodevicespecs
22730@opindex nodevicespecs
22731Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
22732command line. The user takes responsibility for supplying the sub-processes
22733like compiler proper, assembler and linker with appropriate command line
22734options. This means that the user has to supply her private device specs
22735file by means of @option{-specs=@var{path-to-specs-file}}. There is no
22736more need for option @option{-mmcu=@var{mcu}}.
22737
22738This option can also serve as a replacement for the older way of
22739specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
22740which contains a folder named @code{device-specs} which contains a specs file named
22741@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
22742
22743@item -Waddr-space-convert
22744@opindex Waddr-space-convert
22745@opindex Wno-addr-space-convert
22746Warn about conversions between address spaces in the case where the
22747resulting address space is not contained in the incoming address space.
22748
22749@item -Wmisspelled-isr
22750@opindex Wmisspelled-isr
22751@opindex Wno-misspelled-isr
22752Warn if the ISR is misspelled, i.e.@: without __vector prefix.
22753Enabled by default.
22754@end table
22755
22756@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
22757@cindex @code{EIND}
22758Pointers in the implementation are 16@tie{}bits wide.
22759The address of a function or label is represented as word address so
22760that indirect jumps and calls can target any code address in the
22761range of 64@tie{}Ki words.
22762
22763In order to facilitate indirect jump on devices with more than 128@tie{}Ki
22764bytes of program memory space, there is a special function register called
22765@code{EIND} that serves as most significant part of the target address
22766when @code{EICALL} or @code{EIJMP} instructions are used.
22767
22768Indirect jumps and calls on these devices are handled as follows by
22769the compiler and are subject to some limitations:
22770
22771@itemize @bullet
22772
22773@item
22774The compiler never sets @code{EIND}.
22775
22776@item
22777The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
22778instructions or might read @code{EIND} directly in order to emulate an
22779indirect call/jump by means of a @code{RET} instruction.
22780
22781@item
22782The compiler assumes that @code{EIND} never changes during the startup
22783code or during the application. In particular, @code{EIND} is not
22784saved/restored in function or interrupt service routine
22785prologue/epilogue.
22786
22787@item
22788For indirect calls to functions and computed goto, the linker
22789generates @emph{stubs}. Stubs are jump pads sometimes also called
22790@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
22791The stub contains a direct jump to the desired address.
22792
22793@item
22794Linker relaxation must be turned on so that the linker generates
22795the stubs correctly in all situations. See the compiler option
22796@option{-mrelax} and the linker option @option{--relax}.
22797There are corner cases where the linker is supposed to generate stubs
22798but aborts without relaxation and without a helpful error message.
22799
22800@item
22801The default linker script is arranged for code with @code{EIND = 0}.
22802If code is supposed to work for a setup with @code{EIND != 0}, a custom
22803linker script has to be used in order to place the sections whose
22804name start with @code{.trampolines} into the segment where @code{EIND}
22805points to.
22806
22807@item
22808The startup code from libgcc never sets @code{EIND}.
22809Notice that startup code is a blend of code from libgcc and AVR-LibC.
22810For the impact of AVR-LibC on @code{EIND}, see the
22811@w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
22812
22813@item
22814It is legitimate for user-specific startup code to set up @code{EIND}
22815early, for example by means of initialization code located in
22816section @code{.init3}. Such code runs prior to general startup code
22817that initializes RAM and calls constructors, but after the bit
22818of startup code from AVR-LibC that sets @code{EIND} to the segment
22819where the vector table is located.
22820@example
22821#include <avr/io.h>
22822
22823static void
22824__attribute__((section(".init3"),naked,used,no_instrument_function))
22825init3_set_eind (void)
22826@{
22827 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
22828 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
22829@}
22830@end example
22831
22832@noindent
22833The @code{__trampolines_start} symbol is defined in the linker script.
22834
22835@item
22836Stubs are generated automatically by the linker if
22837the following two conditions are met:
22838@itemize @minus
22839
22840@item The address of a label is taken by means of the @code{gs} modifier
22841(short for @emph{generate stubs}) like so:
22842@example
22843LDI r24, lo8(gs(@var{func}))
22844LDI r25, hi8(gs(@var{func}))
22845@end example
22846@item The final location of that label is in a code segment
22847@emph{outside} the segment where the stubs are located.
22848@end itemize
22849
22850@item
22851The compiler emits such @code{gs} modifiers for code labels in the
22852following situations:
22853@itemize @minus
22854@item Taking address of a function or code label.
22855@item Computed goto.
22856@item If prologue-save function is used, see @option{-mcall-prologues}
22857command-line option.
22858@item Switch/case dispatch tables. If you do not want such dispatch
22859tables you can specify the @option{-fno-jump-tables} command-line option.
22860@item C and C++ constructors/destructors called during startup/shutdown.
22861@item If the tools hit a @code{gs()} modifier explained above.
22862@end itemize
22863
22864@item
22865Jumping to non-symbolic addresses like so is @emph{not} supported:
22866
22867@example
22868int main (void)
22869@{
22870 /* Call function at word address 0x2 */
22871 return ((int(*)(void)) 0x2)();
22872@}
22873@end example
22874
22875Instead, a stub has to be set up, i.e.@: the function has to be called
22876through a symbol (@code{func_4} in the example):
22877
22878@example
22879int main (void)
22880@{
22881 extern int func_4 (void);
22882
22883 /* Call function at byte address 0x4 */
22884 return func_4();
22885@}
22886@end example
22887
22888and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
22889Alternatively, @code{func_4} can be defined in the linker script.
22890@end itemize
22891
22892@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
22893@cindex @code{RAMPD}
22894@cindex @code{RAMPX}
22895@cindex @code{RAMPY}
22896@cindex @code{RAMPZ}
22897Some AVR devices support memories larger than the 64@tie{}KiB range
22898that can be accessed with 16-bit pointers. To access memory locations
22899outside this 64@tie{}KiB range, the content of a @code{RAMP}
22900register is used as high part of the address:
22901The @code{X}, @code{Y}, @code{Z} address register is concatenated
22902with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
22903register, respectively, to get a wide address. Similarly,
22904@code{RAMPD} is used together with direct addressing.
22905
22906@itemize
22907@item
22908The startup code initializes the @code{RAMP} special function
22909registers with zero.
22910
22911@item
22912If a @ref{AVR Named Address Spaces,named address space} other than
22913generic or @code{__flash} is used, then @code{RAMPZ} is set
22914as needed before the operation.
22915
22916@item
22917If the device supports RAM larger than 64@tie{}KiB and the compiler
22918needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
22919is reset to zero after the operation.
22920
22921@item
22922If the device comes with a specific @code{RAMP} register, the ISR
22923prologue/epilogue saves/restores that SFR and initializes it with
22924zero in case the ISR code might (implicitly) use it.
22925
22926@item
22927RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
22928If you use inline assembler to read from locations outside the
2292916-bit address range and change one of the @code{RAMP} registers,
22930you must reset it to zero after the access.
22931
22932@end itemize
22933
22934@subsubsection AVR Built-in Macros
22935
22936GCC defines several built-in macros so that the user code can test
22937for the presence or absence of features. Almost any of the following
22938built-in macros are deduced from device capabilities and thus
22939triggered by the @option{-mmcu=} command-line option.
22940
22941For even more AVR-specific built-in macros see
22942@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
22943
22944@table @code
22945
22946@item __AVR_ARCH__
22947Build-in macro that resolves to a decimal number that identifies the
22948architecture and depends on the @option{-mmcu=@var{mcu}} option.
22949Possible values are:
22950
22951@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
22952@code{4}, @code{5}, @code{51}, @code{6}
22953
22954for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
22955@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
22956
22957respectively and
22958
22959@code{100},
22960@code{102}, @code{103}, @code{104},
22961@code{105}, @code{106}, @code{107}
22962
22963for @var{mcu}=@code{avrtiny},
22964@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
22965@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
22966If @var{mcu} specifies a device, this built-in macro is set
22967accordingly. For example, with @option{-mmcu=atmega8} the macro is
22968defined to @code{4}.
22969
22970@item __AVR_@var{Device}__
22971Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
22972the device's name. For example, @option{-mmcu=atmega8} defines the
22973built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
22974@code{__AVR_ATtiny261A__}, etc.
22975
22976The built-in macros' names follow
22977the scheme @code{__AVR_@var{Device}__} where @var{Device} is
22978the device name as from the AVR user manual. The difference between
22979@var{Device} in the built-in macro and @var{device} in
22980@option{-mmcu=@var{device}} is that the latter is always lowercase.
22981
22982If @var{device} is not a device but only a core architecture like
22983@samp{avr51}, this macro is not defined.
22984
22985@item __AVR_DEVICE_NAME__
22986Setting @option{-mmcu=@var{device}} defines this built-in macro to
22987the device's name. For example, with @option{-mmcu=atmega8} the macro
22988is defined to @code{atmega8}.
22989
22990If @var{device} is not a device but only a core architecture like
22991@samp{avr51}, this macro is not defined.
22992
22993@item __AVR_XMEGA__
22994The device / architecture belongs to the XMEGA family of devices.
22995
22996@item __AVR_HAVE_ELPM__
22997The device has the @code{ELPM} instruction.
22998
22999@item __AVR_HAVE_ELPMX__
23000The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23001R@var{n},Z+} instructions.
23002
23003@item __AVR_HAVE_MOVW__
23004The device has the @code{MOVW} instruction to perform 16-bit
23005register-register moves.
23006
23007@item __AVR_HAVE_LPMX__
23008The device has the @code{LPM R@var{n},Z} and
23009@code{LPM R@var{n},Z+} instructions.
23010
23011@item __AVR_HAVE_MUL__
23012The device has a hardware multiplier.
23013
23014@item __AVR_HAVE_JMP_CALL__
23015The device has the @code{JMP} and @code{CALL} instructions.
23016This is the case for devices with more than 8@tie{}KiB of program
23017memory.
23018
23019@item __AVR_HAVE_EIJMP_EICALL__
23020@itemx __AVR_3_BYTE_PC__
23021The device has the @code{EIJMP} and @code{EICALL} instructions.
23022This is the case for devices with more than 128@tie{}KiB of program memory.
23023This also means that the program counter
23024(PC) is 3@tie{}bytes wide.
23025
23026@item __AVR_2_BYTE_PC__
23027The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23028with up to 128@tie{}KiB of program memory.
23029
23030@item __AVR_HAVE_8BIT_SP__
23031@itemx __AVR_HAVE_16BIT_SP__
23032The stack pointer (SP) register is treated as 8-bit respectively
2303316-bit register by the compiler.
23034The definition of these macros is affected by @option{-mtiny-stack}.
23035
23036@item __AVR_HAVE_SPH__
23037@itemx __AVR_SP8__
23038The device has the SPH (high part of stack pointer) special function
23039register or has an 8-bit stack pointer, respectively.
23040The definition of these macros is affected by @option{-mmcu=} and
23041in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23042by @option{-msp8}.
23043
23044@item __AVR_HAVE_RAMPD__
23045@itemx __AVR_HAVE_RAMPX__
23046@itemx __AVR_HAVE_RAMPY__
23047@itemx __AVR_HAVE_RAMPZ__
23048The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23049@code{RAMPZ} special function register, respectively.
23050
23051@item __NO_INTERRUPTS__
23052This macro reflects the @option{-mno-interrupts} command-line option.
23053
23054@item __AVR_ERRATA_SKIP__
23055@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23056Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23057instructions because of a hardware erratum. Skip instructions are
23058@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23059The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23060set.
23061
23062@item __AVR_ISA_RMW__
23063The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23064
23065@item __AVR_SFR_OFFSET__=@var{offset}
23066Instructions that can address I/O special function registers directly
23067like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23068address as if addressed by an instruction to access RAM like @code{LD}
23069or @code{STS}. This offset depends on the device architecture and has
23070to be subtracted from the RAM address in order to get the
23071respective I/O@tie{}address.
23072
23073@item __AVR_SHORT_CALLS__
23074The @option{-mshort-calls} command line option is set.
23075
23076@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23077Some devices support reading from flash memory by means of @code{LD*}
23078instructions. The flash memory is seen in the data address space
23079at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23080is not defined, this feature is not available. If defined,
23081the address space is linear and there is no need to put
23082@code{.rodata} into RAM. This is handled by the default linker
23083description file, and is currently available for
23084@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23085there is no need to use address spaces like @code{__flash} or
23086features like attribute @code{progmem} and @code{pgm_read_*}.
23087
23088@item __WITH_AVRLIBC__
23089The compiler is configured to be used together with AVR-Libc.
23090See the @option{--with-avrlibc} configure option.
23091
23092@item __HAVE_DOUBLE_MULTILIB__
23093Defined if @option{-mdouble=} acts as a multilib option.
23094
23095@item __HAVE_DOUBLE32__
23096@itemx __HAVE_DOUBLE64__
23097Defined if the compiler supports 32-bit double resp. 64-bit double.
23098The actual layout is specified by option @option{-mdouble=}.
23099
23100@item __DEFAULT_DOUBLE__
23101The size in bits of @code{double} if @option{-mdouble=} is not set.
23102To test the layout of @code{double} in a program, use the built-in
23103macro @code{__SIZEOF_DOUBLE__}.
23104
23105@item __HAVE_LONG_DOUBLE32__
23106@itemx __HAVE_LONG_DOUBLE64__
23107@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23108@itemx __DEFAULT_LONG_DOUBLE__
23109Same as above, but for @code{long double} instead of @code{double}.
23110
23111@item __WITH_DOUBLE_COMPARISON__
23112Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23113@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23114and is defined to @code{2} or @code{3}.
23115
23116@item __WITH_LIBF7_LIBGCC__
23117@itemx __WITH_LIBF7_MATH__
23118@itemx __WITH_LIBF7_MATH_SYMBOLS__
23119Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23120@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23121
23122@end table
23123
23124@node Blackfin Options
23125@subsection Blackfin Options
23126@cindex Blackfin Options
23127
23128@table @gcctabopt
23129@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
23130@opindex mcpu=
23131Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23132can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23133@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23134@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23135@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23136@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23137@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23138@samp{bf561}, @samp{bf592}.
23139
23140The optional @var{sirevision} specifies the silicon revision of the target
23141Blackfin processor. Any workarounds available for the targeted silicon revision
23142are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23143If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23144are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23145hexadecimal digits representing the major and minor numbers in the silicon
23146revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23147is not defined. If @var{sirevision} is @samp{any}, the
23148@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23149If this optional @var{sirevision} is not used, GCC assumes the latest known
23150silicon revision of the targeted Blackfin processor.
23151
23152GCC defines a preprocessor macro for the specified @var{cpu}.
23153For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23154provided by libgloss to be linked in if @option{-msim} is not given.
23155
23156Without this option, @samp{bf532} is used as the processor by default.
23157
23158Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23159only the preprocessor macro is defined.
23160
23161@item -msim
23162@opindex msim
23163Specifies that the program will be run on the simulator. This causes
23164the simulator BSP provided by libgloss to be linked in. This option
23165has effect only for @samp{bfin-elf} toolchain.
23166Certain other options, such as @option{-mid-shared-library} and
23167@option{-mfdpic}, imply @option{-msim}.
23168
23169@item -momit-leaf-frame-pointer
23170@opindex momit-leaf-frame-pointer
23171Don't keep the frame pointer in a register for leaf functions. This
23172avoids the instructions to save, set up and restore frame pointers and
23173makes an extra register available in leaf functions.
23174
23175@item -mspecld-anomaly
23176@opindex mspecld-anomaly
23177When enabled, the compiler ensures that the generated code does not
23178contain speculative loads after jump instructions. If this option is used,
23179@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23180
23181@item -mno-specld-anomaly
23182@opindex mno-specld-anomaly
23183@opindex mspecld-anomaly
23184Don't generate extra code to prevent speculative loads from occurring.
23185
23186@item -mcsync-anomaly
23187@opindex mcsync-anomaly
23188When enabled, the compiler ensures that the generated code does not
23189contain CSYNC or SSYNC instructions too soon after conditional branches.
23190If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23191
23192@item -mno-csync-anomaly
23193@opindex mno-csync-anomaly
23194@opindex mcsync-anomaly
23195Don't generate extra code to prevent CSYNC or SSYNC instructions from
23196occurring too soon after a conditional branch.
23197
23198@item -mlow64k
23199@opindex mlow64k
23200When enabled, the compiler is free to take advantage of the knowledge that
23201the entire program fits into the low 64k of memory.
23202
23203@item -mno-low64k
23204@opindex mno-low64k
23205Assume that the program is arbitrarily large. This is the default.
23206
23207@item -mstack-check-l1
23208@opindex mstack-check-l1
23209Do stack checking using information placed into L1 scratchpad memory by the
23210uClinux kernel.
23211
23212@item -mid-shared-library
23213@opindex mid-shared-library
23214Generate code that supports shared libraries via the library ID method.
23215This allows for execute in place and shared libraries in an environment
23216without virtual memory management. This option implies @option{-fPIC}.
23217With a @samp{bfin-elf} target, this option implies @option{-msim}.
23218
23219@item -mno-id-shared-library
23220@opindex mno-id-shared-library
23221@opindex mid-shared-library
23222Generate code that doesn't assume ID-based shared libraries are being used.
23223This is the default.
23224
23225@item -mleaf-id-shared-library
23226@opindex mleaf-id-shared-library
23227Generate code that supports shared libraries via the library ID method,
23228but assumes that this library or executable won't link against any other
23229ID shared libraries. That allows the compiler to use faster code for jumps
23230and calls.
23231
23232@item -mno-leaf-id-shared-library
23233@opindex mno-leaf-id-shared-library
23234@opindex mleaf-id-shared-library
23235Do not assume that the code being compiled won't link against any ID shared
23236libraries. Slower code is generated for jump and call insns.
23237
23238@item -mshared-library-id=n
23239@opindex mshared-library-id
23240Specifies the identification number of the ID-based shared library being
23241compiled. Specifying a value of 0 generates more compact code; specifying
23242other values forces the allocation of that number to the current
23243library but is no more space- or time-efficient than omitting this option.
23244
23245@item -msep-data
23246@opindex msep-data
23247Generate code that allows the data segment to be located in a different
23248area of memory from the text segment. This allows for execute in place in
23249an environment without virtual memory management by eliminating relocations
23250against the text section.
23251
23252@item -mno-sep-data
23253@opindex mno-sep-data
23254@opindex msep-data
23255Generate code that assumes that the data segment follows the text segment.
23256This is the default.
23257
23258@item -mlong-calls
23259@itemx -mno-long-calls
23260@opindex mlong-calls
23261@opindex mno-long-calls
23262Tells the compiler to perform function calls by first loading the
23263address of the function into a register and then performing a subroutine
23264call on this register. This switch is needed if the target function
23265lies outside of the 24-bit addressing range of the offset-based
23266version of subroutine call instruction.
23267
23268This feature is not enabled by default. Specifying
23269@option{-mno-long-calls} restores the default behavior. Note these
23270switches have no effect on how the compiler generates code to handle
23271function calls via function pointers.
23272
23273@item -mfast-fp
23274@opindex mfast-fp
23275Link with the fast floating-point library. This library relaxes some of
23276the IEEE floating-point standard's rules for checking inputs against
23277Not-a-Number (NAN), in the interest of performance.
23278
23279@item -minline-plt
23280@opindex minline-plt
23281Enable inlining of PLT entries in function calls to functions that are
23282not known to bind locally. It has no effect without @option{-mfdpic}.
23283
23284@item -mmulticore
23285@opindex mmulticore
23286Build a standalone application for multicore Blackfin processors.
23287This option causes proper start files and link scripts supporting
23288multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23289It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23290
23291This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23292selects the one-application-per-core programming model. Without
23293@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23294programming model is used. In this model, the main function of Core B
23295should be named as @code{coreb_main}.
23296
23297If this option is not used, the single-core application programming
23298model is used.
23299
23300@item -mcorea
23301@opindex mcorea
23302Build a standalone application for Core A of BF561 when using
23303the one-application-per-core programming model. Proper start files
23304and link scripts are used to support Core A, and the macro
23305@code{__BFIN_COREA} is defined.
23306This option can only be used in conjunction with @option{-mmulticore}.
23307
23308@item -mcoreb
23309@opindex mcoreb
23310Build a standalone application for Core B of BF561 when using
23311the one-application-per-core programming model. Proper start files
23312and link scripts are used to support Core B, and the macro
23313@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23314should be used instead of @code{main}.
23315This option can only be used in conjunction with @option{-mmulticore}.
23316
23317@item -msdram
23318@opindex msdram
23319Build a standalone application for SDRAM. Proper start files and
23320link scripts are used to put the application into SDRAM, and the macro
23321@code{__BFIN_SDRAM} is defined.
23322The loader should initialize SDRAM before loading the application.
23323
23324@item -micplb
23325@opindex micplb
23326Assume that ICPLBs are enabled at run time. This has an effect on certain
23327anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23328are enabled; for standalone applications the default is off.
23329@end table
23330
23331@node C6X Options
23332@subsection C6X Options
23333@cindex C6X Options
23334
23335@table @gcctabopt
23336@item -march=@var{name}
23337@opindex march
23338This specifies the name of the target architecture. GCC uses this
23339name to determine what kind of instructions it can emit when generating
23340assembly code. Permissible names are: @samp{c62x},
23341@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23342
23343@item -mbig-endian
23344@opindex mbig-endian
23345Generate code for a big-endian target.
23346
23347@item -mlittle-endian
23348@opindex mlittle-endian
23349Generate code for a little-endian target. This is the default.
23350
23351@item -msim
23352@opindex msim
23353Choose startup files and linker script suitable for the simulator.
23354
23355@item -msdata=default
23356@opindex msdata=default
23357Put small global and static data in the @code{.neardata} section,
23358which is pointed to by register @code{B14}. Put small uninitialized
23359global and static data in the @code{.bss} section, which is adjacent
23360to the @code{.neardata} section. Put small read-only data into the
23361@code{.rodata} section. The corresponding sections used for large
23362pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23363
23364@item -msdata=all
23365@opindex msdata=all
23366Put all data, not just small objects, into the sections reserved for
23367small data, and use addressing relative to the @code{B14} register to
23368access them.
23369
23370@item -msdata=none
23371@opindex msdata=none
23372Make no use of the sections reserved for small data, and use absolute
23373addresses to access all data. Put all initialized global and static
23374data in the @code{.fardata} section, and all uninitialized data in the
23375@code{.far} section. Put all constant data into the @code{.const}
23376section.
23377@end table
23378
23379@node CRIS Options
23380@subsection CRIS Options
23381@cindex CRIS Options
23382
23383These options are defined specifically for the CRIS ports.
23384
23385@table @gcctabopt
23386@item -march=@var{architecture-type}
23387@itemx -mcpu=@var{architecture-type}
23388@opindex march
23389@opindex mcpu
23390Generate code for the specified architecture. The choices for
23391@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23392respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23393Default is @samp{v0}.
23394
23395@item -mtune=@var{architecture-type}
23396@opindex mtune
23397Tune to @var{architecture-type} everything applicable about the generated
23398code, except for the ABI and the set of available instructions. The
23399choices for @var{architecture-type} are the same as for
23400@option{-march=@var{architecture-type}}.
23401
23402@item -mmax-stack-frame=@var{n}
23403@opindex mmax-stack-frame
23404Warn when the stack frame of a function exceeds @var{n} bytes.
23405
23406@item -metrax4
23407@itemx -metrax100
23408@opindex metrax4
23409@opindex metrax100
23410The options @option{-metrax4} and @option{-metrax100} are synonyms for
23411@option{-march=v3} and @option{-march=v8} respectively.
23412
23413@item -mmul-bug-workaround
23414@itemx -mno-mul-bug-workaround
23415@opindex mmul-bug-workaround
23416@opindex mno-mul-bug-workaround
23417Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23418models where it applies. This option is disabled by default.
23419
23420@item -mpdebug
23421@opindex mpdebug
23422Enable CRIS-specific verbose debug-related information in the assembly
23423code. This option also has the effect of turning off the @samp{#NO_APP}
23424formatted-code indicator to the assembler at the beginning of the
23425assembly file.
23426
23427@item -mcc-init
23428@opindex mcc-init
23429Do not use condition-code results from previous instruction; always emit
23430compare and test instructions before use of condition codes.
23431
23432@item -mno-side-effects
23433@opindex mno-side-effects
23434@opindex mside-effects
23435Do not emit instructions with side effects in addressing modes other than
23436post-increment.
23437
23438@item -mstack-align
23439@itemx -mno-stack-align
23440@itemx -mdata-align
23441@itemx -mno-data-align
23442@itemx -mconst-align
23443@itemx -mno-const-align
23444@opindex mstack-align
23445@opindex mno-stack-align
23446@opindex mdata-align
23447@opindex mno-data-align
23448@opindex mconst-align
23449@opindex mno-const-align
23450These options (@samp{no-} options) arrange (eliminate arrangements) for the
23451stack frame, individual data and constants to be aligned for the maximum
23452single data access size for the chosen CPU model. The default is to
23453arrange for 32-bit alignment. ABI details such as structure layout are
23454not affected by these options.
23455
23456@item -m32-bit
23457@itemx -m16-bit
23458@itemx -m8-bit
23459@opindex m32-bit
23460@opindex m16-bit
23461@opindex m8-bit
23462Similar to the stack- data- and const-align options above, these options
23463arrange for stack frame, writable data and constants to all be 32-bit,
2346416-bit or 8-bit aligned. The default is 32-bit alignment.
23465
23466@item -mno-prologue-epilogue
23467@itemx -mprologue-epilogue
23468@opindex mno-prologue-epilogue
23469@opindex mprologue-epilogue
23470With @option{-mno-prologue-epilogue}, the normal function prologue and
23471epilogue which set up the stack frame are omitted and no return
23472instructions or return sequences are generated in the code. Use this
23473option only together with visual inspection of the compiled code: no
23474warnings or errors are generated when call-saved registers must be saved,
23475or storage for local variables needs to be allocated.
23476
23477@item -melf
23478@opindex melf
23479Legacy no-op option.
23480
23481@item -sim
23482@opindex sim
23483This option arranges
23484to link with input-output functions from a simulator library. Code,
23485initialized data and zero-initialized data are allocated consecutively.
23486
23487@item -sim2
23488@opindex sim2
23489Like @option{-sim}, but pass linker options to locate initialized data at
234900x40000000 and zero-initialized data at 0x80000000.
23491@end table
23492
23493@node C-SKY Options
23494@subsection C-SKY Options
23495@cindex C-SKY Options
23496
23497GCC supports these options when compiling for C-SKY V2 processors.
23498
23499@table @gcctabopt
23500
23501@item -march=@var{arch}
23502@opindex march=
23503Specify the C-SKY target architecture. Valid values for @var{arch} are:
23504@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
23505The default is @samp{ck810}.
23506
23507@item -mcpu=@var{cpu}
23508@opindex mcpu=
23509Specify the C-SKY target processor. Valid values for @var{cpu} are:
23510@samp{ck801}, @samp{ck801t},
23511@samp{ck802}, @samp{ck802t}, @samp{ck802j},
23512@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
23513@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
23514@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
23515@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
23516@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
23517@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
23518@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
23519@samp{ck803eftr1}, @samp{ck803efhtr1},
23520@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
23521@samp{ck803sef}, @samp{ck803seft},
23522@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
23523@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
23524@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
23525@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
23526
23527@item -mbig-endian
23528@opindex mbig-endian
23529@itemx -EB
23530@opindex EB
23531@itemx -mlittle-endian
23532@opindex mlittle-endian
23533@itemx -EL
23534@opindex EL
23535
23536Select big- or little-endian code. The default is little-endian.
23537
23538@item -mfloat-abi=@var{name}
23539@opindex mfloat-abi
23540Specifies which floating-point ABI to use. Permissible values
23541are: @samp{soft}, @samp{softfp} and @samp{hard}.
23542
23543Specifying @samp{soft} causes GCC to generate output containing
23544library calls for floating-point operations.
23545@samp{softfp} allows the generation of code using hardware floating-point
23546instructions, but still uses the soft-float calling conventions.
23547@samp{hard} allows generation of floating-point instructions
23548and uses FPU-specific calling conventions.
23549
23550The default depends on the specific target configuration. Note that
23551the hard-float and soft-float ABIs are not link-compatible; you must
23552compile your entire program with the same ABI, and link with a
23553compatible set of libraries.
23554
23555@item -mhard-float
23556@opindex mhard-float
23557@itemx -msoft-float
23558@opindex msoft-float
23559
23560Select hardware or software floating-point implementations.
23561The default is soft float.
23562
23563@item -mdouble-float
23564@itemx -mno-double-float
23565@opindex mdouble-float
23566When @option{-mhard-float} is in effect, enable generation of
23567double-precision float instructions. This is the default except
23568when compiling for CK803.
23569
23570@item -mfdivdu
23571@itemx -mno-fdivdu
23572@opindex mfdivdu
23573When @option{-mhard-float} is in effect, enable generation of
23574@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
23575This is the default except when compiling for CK803.
23576
23577@item -mfpu=@var{fpu}
23578@opindex mfpu=
23579Select the floating-point processor. This option can only be used with
23580@option{-mhard-float}.
23581Values for @var{fpu} are
23582@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
23583@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
23584@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
23585
23586@item -melrw
23587@itemx -mno-elrw
23588@opindex melrw
23589Enable the extended @code{lrw} instruction. This option defaults to on
23590for CK801 and off otherwise.
23591
23592@item -mistack
23593@itemx -mno-istack
23594@opindex mistack
23595Enable interrupt stack instructions; the default is off.
23596
23597The @option{-mistack} option is required to handle the
23598@code{interrupt} and @code{isr} function attributes
23599(@pxref{C-SKY Function Attributes}).
23600
23601@item -mmp
23602@opindex mmp
23603Enable multiprocessor instructions; the default is off.
23604
23605@item -mcp
23606@opindex mcp
23607Enable coprocessor instructions; the default is off.
23608
23609@item -mcache
23610@opindex mcache
23611Enable coprocessor instructions; the default is off.
23612
23613@item -msecurity
23614@opindex msecurity
23615Enable C-SKY security instructions; the default is off.
23616
23617@item -mtrust
23618@opindex mtrust
23619Enable C-SKY trust instructions; the default is off.
23620
23621@item -mdsp
23622@opindex mdsp
23623@itemx -medsp
23624@opindex medsp
23625@itemx -mvdsp
23626@opindex mvdsp
23627Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
23628All of these options default to off.
23629
23630@item -mdiv
23631@itemx -mno-div
23632@opindex mdiv
23633Generate divide instructions. Default is off.
23634
23635@item -msmart
23636@itemx -mno-smart
23637@opindex msmart
23638Generate code for Smart Mode, using only registers numbered 0-7 to allow
23639use of 16-bit instructions. This option is ignored for CK801 where this
23640is the required behavior, and it defaults to on for CK802.
23641For other targets, the default is off.
23642
23643@item -mhigh-registers
23644@itemx -mno-high-registers
23645@opindex mhigh-registers
23646Generate code using the high registers numbered 16-31. This option
23647is not supported on CK801, CK802, or CK803, and is enabled by default
23648for other processors.
23649
23650@item -manchor
23651@itemx -mno-anchor
23652@opindex manchor
23653Generate code using global anchor symbol addresses.
23654
23655@item -mpushpop
23656@itemx -mno-pushpop
23657@opindex mpushpop
23658Generate code using @code{push} and @code{pop} instructions. This option
23659defaults to on.
23660
23661@item -mmultiple-stld
23662@itemx -mstm
23663@itemx -mno-multiple-stld
23664@itemx -mno-stm
23665@opindex mmultiple-stld
23666Generate code using @code{stm} and @code{ldm} instructions. This option
23667isn't supported on CK801 but is enabled by default on other processors.
23668
23669@item -mconstpool
23670@itemx -mno-constpool
23671@opindex mconstpool
23672Create constant pools in the compiler instead of deferring it to the
23673assembler. This option is the default and required for correct code
23674generation on CK801 and CK802, and is optional on other processors.
23675
23676@item -mstack-size
23677@item -mno-stack-size
23678@opindex mstack-size
23679Emit @code{.stack_size} directives for each function in the assembly
23680output. This option defaults to off.
23681
23682@item -mccrt
23683@itemx -mno-ccrt
23684@opindex mccrt
23685Generate code for the C-SKY compiler runtime instead of libgcc. This
23686option defaults to off.
23687
23688@item -mbranch-cost=@var{n}
23689@opindex mbranch-cost=
23690Set the branch costs to roughly @code{n} instructions. The default is 1.
23691
23692@item -msched-prolog
23693@itemx -mno-sched-prolog
23694@opindex msched-prolog
23695Permit scheduling of function prologue and epilogue sequences. Using
23696this option can result in code that is not compliant with the C-SKY V2 ABI
23697prologue requirements and that cannot be debugged or backtraced.
23698It is disabled by default.
23699
23700@item -msim
23701@opindex msim
23702Links the library libsemi.a which is in compatible with simulator. Applicable
23703to ELF compiler only.
23704
23705@end table
23706
23707@node Darwin Options
23708@subsection Darwin Options
23709@cindex Darwin options
23710
23711These options are defined for all architectures running the Darwin operating
23712system.
23713
23714FSF GCC on Darwin does not create ``fat'' object files; it creates
23715an object file for the single architecture that GCC was built to
23716target. Apple's GCC on Darwin does create ``fat'' files if multiple
23717@option{-arch} options are used; it does so by running the compiler or
23718linker multiple times and joining the results together with
23719@file{lipo}.
23720
23721The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
23722@samp{i686}) is determined by the flags that specify the ISA
23723that GCC is targeting, like @option{-mcpu} or @option{-march}. The
23724@option{-force_cpusubtype_ALL} option can be used to override this.
23725
23726The Darwin tools vary in their behavior when presented with an ISA
23727mismatch. The assembler, @file{as}, only permits instructions to
23728be used that are valid for the subtype of the file it is generating,
23729so you cannot put 64-bit instructions in a @samp{ppc750} object file.
23730The linker for shared libraries, @file{/usr/bin/libtool}, fails
23731and prints an error if asked to create a shared library with a less
23732restrictive subtype than its input files (for instance, trying to put
23733a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
23734for executables, @command{ld}, quietly gives the executable the most
23735restrictive subtype of any of its input files.
23736
23737@table @gcctabopt
23738@item -F@var{dir}
23739@opindex F
23740Add the framework directory @var{dir} to the head of the list of
23741directories to be searched for header files. These directories are
23742interleaved with those specified by @option{-I} options and are
23743scanned in a left-to-right order.
23744
23745A framework directory is a directory with frameworks in it. A
23746framework is a directory with a @file{Headers} and/or
23747@file{PrivateHeaders} directory contained directly in it that ends
23748in @file{.framework}. The name of a framework is the name of this
23749directory excluding the @file{.framework}. Headers associated with
23750the framework are found in one of those two directories, with
23751@file{Headers} being searched first. A subframework is a framework
23752directory that is in a framework's @file{Frameworks} directory.
23753Includes of subframework headers can only appear in a header of a
23754framework that contains the subframework, or in a sibling subframework
23755header. Two subframeworks are siblings if they occur in the same
23756framework. A subframework should not have the same name as a
23757framework; a warning is issued if this is violated. Currently a
23758subframework cannot have subframeworks; in the future, the mechanism
23759may be extended to support this. The standard frameworks can be found
23760in @file{/System/Library/Frameworks} and
23761@file{/Library/Frameworks}. An example include looks like
23762@code{#include <Framework/header.h>}, where @file{Framework} denotes
23763the name of the framework and @file{header.h} is found in the
23764@file{PrivateHeaders} or @file{Headers} directory.
23765
23766@item -iframework@var{dir}
23767@opindex iframework
23768Like @option{-F} except the directory is a treated as a system
23769directory. The main difference between this @option{-iframework} and
23770@option{-F} is that with @option{-iframework} the compiler does not
23771warn about constructs contained within header files found via
23772@var{dir}. This option is valid only for the C family of languages.
23773
23774@item -gused
23775@opindex gused
23776Emit debugging information for symbols that are used. For stabs
23777debugging format, this enables @option{-feliminate-unused-debug-symbols}.
23778This is by default ON@.
23779
23780@item -gfull
23781@opindex gfull
23782Emit debugging information for all symbols and types.
23783
23784@item -mmacosx-version-min=@var{version}
23785The earliest version of MacOS X that this executable will run on
23786is @var{version}. Typical values of @var{version} include @code{10.1},
23787@code{10.2}, and @code{10.3.9}.
23788
23789If the compiler was built to use the system's headers by default,
23790then the default for this option is the system version on which the
23791compiler is running, otherwise the default is to make choices that
23792are compatible with as many systems and code bases as possible.
23793
23794@item -mkernel
23795@opindex mkernel
23796Enable kernel development mode. The @option{-mkernel} option sets
23797@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
23798@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
23799@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
23800applicable. This mode also sets @option{-mno-altivec},
23801@option{-msoft-float}, @option{-fno-builtin} and
23802@option{-mlong-branch} for PowerPC targets.
23803
23804@item -mone-byte-bool
23805@opindex mone-byte-bool
23806Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
23807By default @code{sizeof(bool)} is @code{4} when compiling for
23808Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
23809option has no effect on x86.
23810
23811@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
23812to generate code that is not binary compatible with code generated
23813without that switch. Using this switch may require recompiling all
23814other modules in a program, including system libraries. Use this
23815switch to conform to a non-default data model.
23816
23817@item -mfix-and-continue
23818@itemx -ffix-and-continue
23819@itemx -findirect-data
23820@opindex mfix-and-continue
23821@opindex ffix-and-continue
23822@opindex findirect-data
23823Generate code suitable for fast turnaround development, such as to
23824allow GDB to dynamically load @file{.o} files into already-running
23825programs. @option{-findirect-data} and @option{-ffix-and-continue}
23826are provided for backwards compatibility.
23827
23828@item -all_load
23829@opindex all_load
23830Loads all members of static archive libraries.
23831See man ld(1) for more information.
23832
23833@item -arch_errors_fatal
23834@opindex arch_errors_fatal
23835Cause the errors having to do with files that have the wrong architecture
23836to be fatal.
23837
23838@item -bind_at_load
23839@opindex bind_at_load
23840Causes the output file to be marked such that the dynamic linker will
23841bind all undefined references when the file is loaded or launched.
23842
23843@item -bundle
23844@opindex bundle
23845Produce a Mach-o bundle format file.
23846See man ld(1) for more information.
23847
23848@item -bundle_loader @var{executable}
23849@opindex bundle_loader
23850This option specifies the @var{executable} that will load the build
23851output file being linked. See man ld(1) for more information.
23852
23853@item -dynamiclib
23854@opindex dynamiclib
23855When passed this option, GCC produces a dynamic library instead of
23856an executable when linking, using the Darwin @file{libtool} command.
23857
23858@item -force_cpusubtype_ALL
23859@opindex force_cpusubtype_ALL
23860This causes GCC's output file to have the @samp{ALL} subtype, instead of
23861one controlled by the @option{-mcpu} or @option{-march} option.
23862
23863@item -allowable_client @var{client_name}
23864@itemx -client_name
23865@itemx -compatibility_version
23866@itemx -current_version
23867@itemx -dead_strip
23868@itemx -dependency-file
23869@itemx -dylib_file
23870@itemx -dylinker_install_name
23871@itemx -dynamic
23872@itemx -exported_symbols_list
23873@itemx -filelist
23874@need 800
23875@itemx -flat_namespace
23876@itemx -force_flat_namespace
23877@itemx -headerpad_max_install_names
23878@itemx -image_base
23879@itemx -init
23880@itemx -install_name
23881@itemx -keep_private_externs
23882@itemx -multi_module
23883@itemx -multiply_defined
23884@itemx -multiply_defined_unused
23885@need 800
23886@itemx -noall_load
23887@itemx -no_dead_strip_inits_and_terms
23888@itemx -nofixprebinding
23889@itemx -nomultidefs
23890@itemx -noprebind
23891@itemx -noseglinkedit
23892@itemx -pagezero_size
23893@itemx -prebind
23894@itemx -prebind_all_twolevel_modules
23895@itemx -private_bundle
23896@need 800
23897@itemx -read_only_relocs
23898@itemx -sectalign
23899@itemx -sectobjectsymbols
23900@itemx -whyload
23901@itemx -seg1addr
23902@itemx -sectcreate
23903@itemx -sectobjectsymbols
23904@itemx -sectorder
23905@itemx -segaddr
23906@itemx -segs_read_only_addr
23907@need 800
23908@itemx -segs_read_write_addr
23909@itemx -seg_addr_table
23910@itemx -seg_addr_table_filename
23911@itemx -seglinkedit
23912@itemx -segprot
23913@itemx -segs_read_only_addr
23914@itemx -segs_read_write_addr
23915@itemx -single_module
23916@itemx -static
23917@itemx -sub_library
23918@need 800
23919@itemx -sub_umbrella
23920@itemx -twolevel_namespace
23921@itemx -umbrella
23922@itemx -undefined
23923@itemx -unexported_symbols_list
23924@itemx -weak_reference_mismatches
23925@itemx -whatsloaded
23926@opindex allowable_client
23927@opindex client_name
23928@opindex compatibility_version
23929@opindex current_version
23930@opindex dead_strip
23931@opindex dependency-file
23932@opindex dylib_file
23933@opindex dylinker_install_name
23934@opindex dynamic
23935@opindex exported_symbols_list
23936@opindex filelist
23937@opindex flat_namespace
23938@opindex force_flat_namespace
23939@opindex headerpad_max_install_names
23940@opindex image_base
23941@opindex init
23942@opindex install_name
23943@opindex keep_private_externs
23944@opindex multi_module
23945@opindex multiply_defined
23946@opindex multiply_defined_unused
23947@opindex noall_load
23948@opindex no_dead_strip_inits_and_terms
23949@opindex nofixprebinding
23950@opindex nomultidefs
23951@opindex noprebind
23952@opindex noseglinkedit
23953@opindex pagezero_size
23954@opindex prebind
23955@opindex prebind_all_twolevel_modules
23956@opindex private_bundle
23957@opindex read_only_relocs
23958@opindex sectalign
23959@opindex sectobjectsymbols
23960@opindex whyload
23961@opindex seg1addr
23962@opindex sectcreate
23963@opindex sectobjectsymbols
23964@opindex sectorder
23965@opindex segaddr
23966@opindex segs_read_only_addr
23967@opindex segs_read_write_addr
23968@opindex seg_addr_table
23969@opindex seg_addr_table_filename
23970@opindex seglinkedit
23971@opindex segprot
23972@opindex segs_read_only_addr
23973@opindex segs_read_write_addr
23974@opindex single_module
23975@opindex static
23976@opindex sub_library
23977@opindex sub_umbrella
23978@opindex twolevel_namespace
23979@opindex umbrella
23980@opindex undefined
23981@opindex unexported_symbols_list
23982@opindex weak_reference_mismatches
23983@opindex whatsloaded
23984These options are passed to the Darwin linker. The Darwin linker man page
23985describes them in detail.
23986@end table
23987
23988@node DEC Alpha Options
23989@subsection DEC Alpha Options
23990
23991These @samp{-m} options are defined for the DEC Alpha implementations:
23992
23993@table @gcctabopt
23994@item -mno-soft-float
23995@itemx -msoft-float
23996@opindex mno-soft-float
23997@opindex msoft-float
23998Use (do not use) the hardware floating-point instructions for
23999floating-point operations. When @option{-msoft-float} is specified,
24000functions in @file{libgcc.a} are used to perform floating-point
24001operations. Unless they are replaced by routines that emulate the
24002floating-point operations, or compiled in such a way as to call such
24003emulations routines, these routines issue floating-point
24004operations. If you are compiling for an Alpha without floating-point
24005operations, you must ensure that the library is built so as not to call
24006them.
24007
24008Note that Alpha implementations without floating-point operations are
24009required to have floating-point registers.
24010
24011@item -mfp-reg
24012@itemx -mno-fp-regs
24013@opindex mfp-reg
24014@opindex mno-fp-regs
24015Generate code that uses (does not use) the floating-point register set.
24016@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24017register set is not used, floating-point operands are passed in integer
24018registers as if they were integers and floating-point results are passed
24019in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24020so any function with a floating-point argument or return value called by code
24021compiled with @option{-mno-fp-regs} must also be compiled with that
24022option.
24023
24024A typical use of this option is building a kernel that does not use,
24025and hence need not save and restore, any floating-point registers.
24026
24027@item -mieee
24028@opindex mieee
24029The Alpha architecture implements floating-point hardware optimized for
24030maximum performance. It is mostly compliant with the IEEE floating-point
24031standard. However, for full compliance, software assistance is
24032required. This option generates code fully IEEE-compliant code
24033@emph{except} that the @var{inexact-flag} is not maintained (see below).
24034If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24035defined during compilation. The resulting code is less efficient but is
24036able to correctly support denormalized numbers and exceptional IEEE
24037values such as not-a-number and plus/minus infinity. Other Alpha
24038compilers call this option @option{-ieee_with_no_inexact}.
24039
24040@item -mieee-with-inexact
24041@opindex mieee-with-inexact
24042This is like @option{-mieee} except the generated code also maintains
24043the IEEE @var{inexact-flag}. Turning on this option causes the
24044generated code to implement fully-compliant IEEE math. In addition to
24045@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24046macro. On some Alpha implementations the resulting code may execute
24047significantly slower than the code generated by default. Since there is
24048very little code that depends on the @var{inexact-flag}, you should
24049normally not specify this option. Other Alpha compilers call this
24050option @option{-ieee_with_inexact}.
24051
24052@item -mfp-trap-mode=@var{trap-mode}
24053@opindex mfp-trap-mode
24054This option controls what floating-point related traps are enabled.
24055Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24056The trap mode can be set to one of four values:
24057
24058@table @samp
24059@item n
24060This is the default (normal) setting. The only traps that are enabled
24061are the ones that cannot be disabled in software (e.g., division by zero
24062trap).
24063
24064@item u
24065In addition to the traps enabled by @samp{n}, underflow traps are enabled
24066as well.
24067
24068@item su
24069Like @samp{u}, but the instructions are marked to be safe for software
24070completion (see Alpha architecture manual for details).
24071
24072@item sui
24073Like @samp{su}, but inexact traps are enabled as well.
24074@end table
24075
24076@item -mfp-rounding-mode=@var{rounding-mode}
24077@opindex mfp-rounding-mode
24078Selects the IEEE rounding mode. Other Alpha compilers call this option
24079@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24080of:
24081
24082@table @samp
24083@item n
24084Normal IEEE rounding mode. Floating-point numbers are rounded towards
24085the nearest machine number or towards the even machine number in case
24086of a tie.
24087
24088@item m
24089Round towards minus infinity.
24090
24091@item c
24092Chopped rounding mode. Floating-point numbers are rounded towards zero.
24093
24094@item d
24095Dynamic rounding mode. A field in the floating-point control register
24096(@var{fpcr}, see Alpha architecture reference manual) controls the
24097rounding mode in effect. The C library initializes this register for
24098rounding towards plus infinity. Thus, unless your program modifies the
24099@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24100@end table
24101
24102@item -mtrap-precision=@var{trap-precision}
24103@opindex mtrap-precision
24104In the Alpha architecture, floating-point traps are imprecise. This
24105means without software assistance it is impossible to recover from a
24106floating trap and program execution normally needs to be terminated.
24107GCC can generate code that can assist operating system trap handlers
24108in determining the exact location that caused a floating-point trap.
24109Depending on the requirements of an application, different levels of
24110precisions can be selected:
24111
24112@table @samp
24113@item p
24114Program precision. This option is the default and means a trap handler
24115can only identify which program caused a floating-point exception.
24116
24117@item f
24118Function precision. The trap handler can determine the function that
24119caused a floating-point exception.
24120
24121@item i
24122Instruction precision. The trap handler can determine the exact
24123instruction that caused a floating-point exception.
24124@end table
24125
24126Other Alpha compilers provide the equivalent options called
24127@option{-scope_safe} and @option{-resumption_safe}.
24128
24129@item -mieee-conformant
24130@opindex mieee-conformant
24131This option marks the generated code as IEEE conformant. You must not
24132use this option unless you also specify @option{-mtrap-precision=i} and either
24133@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24134is to emit the line @samp{.eflag 48} in the function prologue of the
24135generated assembly file.
24136
24137@item -mbuild-constants
24138@opindex mbuild-constants
24139Normally GCC examines a 32- or 64-bit integer constant to
24140see if it can construct it from smaller constants in two or three
24141instructions. If it cannot, it outputs the constant as a literal and
24142generates code to load it from the data segment at run time.
24143
24144Use this option to require GCC to construct @emph{all} integer constants
24145using code, even if it takes more instructions (the maximum is six).
24146
24147You typically use this option to build a shared library dynamic
24148loader. Itself a shared library, it must relocate itself in memory
24149before it can find the variables and constants in its own data segment.
24150
24151@item -mbwx
24152@itemx -mno-bwx
24153@itemx -mcix
24154@itemx -mno-cix
24155@itemx -mfix
24156@itemx -mno-fix
24157@itemx -mmax
24158@itemx -mno-max
24159@opindex mbwx
24160@opindex mno-bwx
24161@opindex mcix
24162@opindex mno-cix
24163@opindex mfix
24164@opindex mno-fix
24165@opindex mmax
24166@opindex mno-max
24167Indicate whether GCC should generate code to use the optional BWX,
24168CIX, FIX and MAX instruction sets. The default is to use the instruction
24169sets supported by the CPU type specified via @option{-mcpu=} option or that
24170of the CPU on which GCC was built if none is specified.
24171
24172@item -mfloat-vax
24173@itemx -mfloat-ieee
24174@opindex mfloat-vax
24175@opindex mfloat-ieee
24176Generate code that uses (does not use) VAX F and G floating-point
24177arithmetic instead of IEEE single and double precision.
24178
24179@item -mexplicit-relocs
24180@itemx -mno-explicit-relocs
24181@opindex mexplicit-relocs
24182@opindex mno-explicit-relocs
24183Older Alpha assemblers provided no way to generate symbol relocations
24184except via assembler macros. Use of these macros does not allow
24185optimal instruction scheduling. GNU binutils as of version 2.12
24186supports a new syntax that allows the compiler to explicitly mark
24187which relocations should apply to which instructions. This option
24188is mostly useful for debugging, as GCC detects the capabilities of
24189the assembler when it is built and sets the default accordingly.
24190
24191@item -msmall-data
24192@itemx -mlarge-data
24193@opindex msmall-data
24194@opindex mlarge-data
24195When @option{-mexplicit-relocs} is in effect, static data is
24196accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24197is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24198(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2419916-bit relocations off of the @code{$gp} register. This limits the
24200size of the small data area to 64KB, but allows the variables to be
24201directly accessed via a single instruction.
24202
24203The default is @option{-mlarge-data}. With this option the data area
24204is limited to just below 2GB@. Programs that require more than 2GB of
24205data must use @code{malloc} or @code{mmap} to allocate the data in the
24206heap instead of in the program's data segment.
24207
24208When generating code for shared libraries, @option{-fpic} implies
24209@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24210
24211@item -msmall-text
24212@itemx -mlarge-text
24213@opindex msmall-text
24214@opindex mlarge-text
24215When @option{-msmall-text} is used, the compiler assumes that the
24216code of the entire program (or shared library) fits in 4MB, and is
24217thus reachable with a branch instruction. When @option{-msmall-data}
24218is used, the compiler can assume that all local symbols share the
24219same @code{$gp} value, and thus reduce the number of instructions
24220required for a function call from 4 to 1.
24221
24222The default is @option{-mlarge-text}.
24223
24224@item -mcpu=@var{cpu_type}
24225@opindex mcpu
24226Set the instruction set and instruction scheduling parameters for
24227machine type @var{cpu_type}. You can specify either the @samp{EV}
24228style name or the corresponding chip number. GCC supports scheduling
24229parameters for the EV4, EV5 and EV6 family of processors and
24230chooses the default values for the instruction set from the processor
24231you specify. If you do not specify a processor type, GCC defaults
24232to the processor on which the compiler was built.
24233
24234Supported values for @var{cpu_type} are
24235
24236@table @samp
24237@item ev4
24238@itemx ev45
24239@itemx 21064
24240Schedules as an EV4 and has no instruction set extensions.
24241
24242@item ev5
24243@itemx 21164
24244Schedules as an EV5 and has no instruction set extensions.
24245
24246@item ev56
24247@itemx 21164a
24248Schedules as an EV5 and supports the BWX extension.
24249
24250@item pca56
24251@itemx 21164pc
24252@itemx 21164PC
24253Schedules as an EV5 and supports the BWX and MAX extensions.
24254
24255@item ev6
24256@itemx 21264
24257Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24258
24259@item ev67
24260@itemx 21264a
24261Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24262@end table
24263
24264Native toolchains also support the value @samp{native},
24265which selects the best architecture option for the host processor.
24266@option{-mcpu=native} has no effect if GCC does not recognize
24267the processor.
24268
24269@item -mtune=@var{cpu_type}
24270@opindex mtune
24271Set only the instruction scheduling parameters for machine type
24272@var{cpu_type}. The instruction set is not changed.
24273
24274Native toolchains also support the value @samp{native},
24275which selects the best architecture option for the host processor.
24276@option{-mtune=native} has no effect if GCC does not recognize
24277the processor.
24278
24279@item -mmemory-latency=@var{time}
24280@opindex mmemory-latency
24281Sets the latency the scheduler should assume for typical memory
24282references as seen by the application. This number is highly
24283dependent on the memory access patterns used by the application
24284and the size of the external cache on the machine.
24285
24286Valid options for @var{time} are
24287
24288@table @samp
24289@item @var{number}
24290A decimal number representing clock cycles.
24291
24292@item L1
24293@itemx L2
24294@itemx L3
24295@itemx main
24296The compiler contains estimates of the number of clock cycles for
24297``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24298(also called Dcache, Scache, and Bcache), as well as to main memory.
24299Note that L3 is only valid for EV5.
24300
24301@end table
24302@end table
24303
24304@node eBPF Options
24305@subsection eBPF Options
24306@cindex eBPF Options
24307
24308@table @gcctabopt
24309@item -mframe-limit=@var{bytes}
24310This specifies the hard limit for frame sizes, in bytes. Currently,
24311the value that can be specified should be less than or equal to
24312@samp{32767}. Defaults to whatever limit is imposed by the version of
24313the Linux kernel targeted.
24314
24315@item -mkernel=@var{version}
24316@opindex mkernel
24317This specifies the minimum version of the kernel that will run the
24318compiled program. GCC uses this version to determine which
24319instructions to use, what kernel helpers to allow, etc. Currently,
24320@var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
24321@samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
24322@samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
24323@samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
24324@samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
24325@samp{5.2}, @samp{latest} and @samp{native}.
24326
24327@item -mbig-endian
24328@opindex mbig-endian
24329Generate code for a big-endian target.
24330
24331@item -mlittle-endian
24332@opindex mlittle-endian
24333Generate code for a little-endian target. This is the default.
24334
24335@item -mjmpext
24336@opindex mjmpext
24337Enable generation of extra conditional-branch instructions.
24338Enabled for CPU v2 and above.
24339
24340@item -mjmp32
24341@opindex mjmp32
24342Enable 32-bit jump instructions. Enabled for CPU v3 and above.
24343
24344@item -malu32
24345@opindex malu32
24346Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
24347
24348@item -mcpu=@var{version}
24349@opindex mcpu
24350This specifies which version of the eBPF ISA to target. Newer versions
24351may not be supported by all kernels. The default is @samp{v3}.
24352
24353Supported values for @var{version} are:
24354
24355@table @samp
24356@item v1
24357The first stable eBPF ISA with no special features or extensions.
24358
24359@item v2
24360Supports the jump extensions, as in @option{-mjmpext}.
24361
24362@item v3
24363All features of v2, plus:
24364@itemize @minus
24365@item 32-bit jump operations, as in @option{-mjmp32}
24366@item 32-bit ALU operations, as in @option{-malu32}
24367@end itemize
24368
24369@end table
24370
24371@item -mco-re
24372@opindex mco-re
24373Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24374is implied by @option{-gbtf}.
24375
24376@item -mno-co-re
24377@opindex mno-co-re
24378Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24379support is enabled by default when generating BTF debug information for
24380the BPF target.
24381
24382@item -mxbpf
24383Generate code for an expanded version of BPF, which relaxes some of
24384the restrictions imposed by the BPF architecture:
24385@itemize @minus
24386@item Save and restore callee-saved registers at function entry and
24387exit, respectively.
24388@end itemize
24389@end table
24390
24391@node FR30 Options
24392@subsection FR30 Options
24393@cindex FR30 Options
24394
24395These options are defined specifically for the FR30 port.
24396
24397@table @gcctabopt
24398
24399@item -msmall-model
24400@opindex msmall-model
24401Use the small address space model. This can produce smaller code, but
24402it does assume that all symbolic values and addresses fit into a
2440320-bit range.
24404
24405@item -mno-lsim
24406@opindex mno-lsim
24407Assume that runtime support has been provided and so there is no need
24408to include the simulator library (@file{libsim.a}) on the linker
24409command line.
24410
24411@end table
24412
24413@node FT32 Options
24414@subsection FT32 Options
24415@cindex FT32 Options
24416
24417These options are defined specifically for the FT32 port.
24418
24419@table @gcctabopt
24420
24421@item -msim
24422@opindex msim
24423Specifies that the program will be run on the simulator. This causes
24424an alternate runtime startup and library to be linked.
24425You must not use this option when generating programs that will run on
24426real hardware; you must provide your own runtime library for whatever
24427I/O functions are needed.
24428
24429@item -mlra
24430@opindex mlra
24431Enable Local Register Allocation. This is still experimental for FT32,
24432so by default the compiler uses standard reload.
24433
24434@item -mnodiv
24435@opindex mnodiv
24436Do not use div and mod instructions.
24437
24438@item -mft32b
24439@opindex mft32b
24440Enable use of the extended instructions of the FT32B processor.
24441
24442@item -mcompress
24443@opindex mcompress
24444Compress all code using the Ft32B code compression scheme.
24445
24446@item -mnopm
24447@opindex mnopm
24448Do not generate code that reads program memory.
24449
24450@end table
24451
24452@node FRV Options
24453@subsection FRV Options
24454@cindex FRV Options
24455
24456@table @gcctabopt
24457@item -mgpr-32
24458@opindex mgpr-32
24459
24460Only use the first 32 general-purpose registers.
24461
24462@item -mgpr-64
24463@opindex mgpr-64
24464
24465Use all 64 general-purpose registers.
24466
24467@item -mfpr-32
24468@opindex mfpr-32
24469
24470Use only the first 32 floating-point registers.
24471
24472@item -mfpr-64
24473@opindex mfpr-64
24474
24475Use all 64 floating-point registers.
24476
24477@item -mhard-float
24478@opindex mhard-float
24479
24480Use hardware instructions for floating-point operations.
24481
24482@item -msoft-float
24483@opindex msoft-float
24484
24485Use library routines for floating-point operations.
24486
24487@item -malloc-cc
24488@opindex malloc-cc
24489
24490Dynamically allocate condition code registers.
24491
24492@item -mfixed-cc
24493@opindex mfixed-cc
24494
24495Do not try to dynamically allocate condition code registers, only
24496use @code{icc0} and @code{fcc0}.
24497
24498@item -mdword
24499@opindex mdword
24500
24501Change ABI to use double word insns.
24502
24503@item -mno-dword
24504@opindex mno-dword
24505@opindex mdword
24506
24507Do not use double word instructions.
24508
24509@item -mdouble
24510@opindex mdouble
24511
24512Use floating-point double instructions.
24513
24514@item -mno-double
24515@opindex mno-double
24516
24517Do not use floating-point double instructions.
24518
24519@item -mmedia
24520@opindex mmedia
24521
24522Use media instructions.
24523
24524@item -mno-media
24525@opindex mno-media
24526
24527Do not use media instructions.
24528
24529@item -mmuladd
24530@opindex mmuladd
24531
24532Use multiply and add/subtract instructions.
24533
24534@item -mno-muladd
24535@opindex mno-muladd
24536
24537Do not use multiply and add/subtract instructions.
24538
24539@item -mfdpic
24540@opindex mfdpic
24541
24542Select the FDPIC ABI, which uses function descriptors to represent
24543pointers to functions. Without any PIC/PIE-related options, it
24544implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
24545assumes GOT entries and small data are within a 12-bit range from the
24546GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
24547are computed with 32 bits.
24548With a @samp{bfin-elf} target, this option implies @option{-msim}.
24549
24550@item -minline-plt
24551@opindex minline-plt
24552
24553Enable inlining of PLT entries in function calls to functions that are
24554not known to bind locally. It has no effect without @option{-mfdpic}.
24555It's enabled by default if optimizing for speed and compiling for
24556shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
24557optimization option such as @option{-O3} or above is present in the
24558command line.
24559
24560@item -mTLS
24561@opindex mTLS
24562
24563Assume a large TLS segment when generating thread-local code.
24564
24565@item -mtls
24566@opindex mtls
24567
24568Do not assume a large TLS segment when generating thread-local code.
24569
24570@item -mgprel-ro
24571@opindex mgprel-ro
24572
24573Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
24574that is known to be in read-only sections. It's enabled by default,
24575except for @option{-fpic} or @option{-fpie}: even though it may help
24576make the global offset table smaller, it trades 1 instruction for 4.
24577With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
24578one of which may be shared by multiple symbols, and it avoids the need
24579for a GOT entry for the referenced symbol, so it's more likely to be a
24580win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
24581
24582@item -multilib-library-pic
24583@opindex multilib-library-pic
24584
24585Link with the (library, not FD) pic libraries. It's implied by
24586@option{-mlibrary-pic}, as well as by @option{-fPIC} and
24587@option{-fpic} without @option{-mfdpic}. You should never have to use
24588it explicitly.
24589
24590@item -mlinked-fp
24591@opindex mlinked-fp
24592
24593Follow the EABI requirement of always creating a frame pointer whenever
24594a stack frame is allocated. This option is enabled by default and can
24595be disabled with @option{-mno-linked-fp}.
24596
24597@item -mlong-calls
24598@opindex mlong-calls
24599
24600Use indirect addressing to call functions outside the current
24601compilation unit. This allows the functions to be placed anywhere
24602within the 32-bit address space.
24603
24604@item -malign-labels
24605@opindex malign-labels
24606
24607Try to align labels to an 8-byte boundary by inserting NOPs into the
24608previous packet. This option only has an effect when VLIW packing
24609is enabled. It doesn't create new packets; it merely adds NOPs to
24610existing ones.
24611
24612@item -mlibrary-pic
24613@opindex mlibrary-pic
24614
24615Generate position-independent EABI code.
24616
24617@item -macc-4
24618@opindex macc-4
24619
24620Use only the first four media accumulator registers.
24621
24622@item -macc-8
24623@opindex macc-8
24624
24625Use all eight media accumulator registers.
24626
24627@item -mpack
24628@opindex mpack
24629
24630Pack VLIW instructions.
24631
24632@item -mno-pack
24633@opindex mno-pack
24634
24635Do not pack VLIW instructions.
24636
24637@item -mno-eflags
24638@opindex mno-eflags
24639
24640Do not mark ABI switches in e_flags.
24641
24642@item -mcond-move
24643@opindex mcond-move
24644
24645Enable the use of conditional-move instructions (default).
24646
24647This switch is mainly for debugging the compiler and will likely be removed
24648in a future version.
24649
24650@item -mno-cond-move
24651@opindex mno-cond-move
24652
24653Disable the use of conditional-move instructions.
24654
24655This switch is mainly for debugging the compiler and will likely be removed
24656in a future version.
24657
24658@item -mscc
24659@opindex mscc
24660
24661Enable the use of conditional set instructions (default).
24662
24663This switch is mainly for debugging the compiler and will likely be removed
24664in a future version.
24665
24666@item -mno-scc
24667@opindex mno-scc
24668
24669Disable the use of conditional set instructions.
24670
24671This switch is mainly for debugging the compiler and will likely be removed
24672in a future version.
24673
24674@item -mcond-exec
24675@opindex mcond-exec
24676
24677Enable the use of conditional execution (default).
24678
24679This switch is mainly for debugging the compiler and will likely be removed
24680in a future version.
24681
24682@item -mno-cond-exec
24683@opindex mno-cond-exec
24684
24685Disable the use of conditional execution.
24686
24687This switch is mainly for debugging the compiler and will likely be removed
24688in a future version.
24689
24690@item -mvliw-branch
24691@opindex mvliw-branch
24692
24693Run a pass to pack branches into VLIW instructions (default).
24694
24695This switch is mainly for debugging the compiler and will likely be removed
24696in a future version.
24697
24698@item -mno-vliw-branch
24699@opindex mno-vliw-branch
24700
24701Do not run a pass to pack branches into VLIW instructions.
24702
24703This switch is mainly for debugging the compiler and will likely be removed
24704in a future version.
24705
24706@item -mmulti-cond-exec
24707@opindex mmulti-cond-exec
24708
24709Enable optimization of @code{&&} and @code{||} in conditional execution
24710(default).
24711
24712This switch is mainly for debugging the compiler and will likely be removed
24713in a future version.
24714
24715@item -mno-multi-cond-exec
24716@opindex mno-multi-cond-exec
24717
24718Disable optimization of @code{&&} and @code{||} in conditional execution.
24719
24720This switch is mainly for debugging the compiler and will likely be removed
24721in a future version.
24722
24723@item -mnested-cond-exec
24724@opindex mnested-cond-exec
24725
24726Enable nested conditional execution optimizations (default).
24727
24728This switch is mainly for debugging the compiler and will likely be removed
24729in a future version.
24730
24731@item -mno-nested-cond-exec
24732@opindex mno-nested-cond-exec
24733
24734Disable nested conditional execution optimizations.
24735
24736This switch is mainly for debugging the compiler and will likely be removed
24737in a future version.
24738
24739@item -moptimize-membar
24740@opindex moptimize-membar
24741
24742This switch removes redundant @code{membar} instructions from the
24743compiler-generated code. It is enabled by default.
24744
24745@item -mno-optimize-membar
24746@opindex mno-optimize-membar
24747@opindex moptimize-membar
24748
24749This switch disables the automatic removal of redundant @code{membar}
24750instructions from the generated code.
24751
24752@item -mtomcat-stats
24753@opindex mtomcat-stats
24754
24755Cause gas to print out tomcat statistics.
24756
24757@item -mcpu=@var{cpu}
24758@opindex mcpu
24759
24760Select the processor type for which to generate code. Possible values are
24761@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
24762@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
24763
24764@end table
24765
24766@node GNU/Linux Options
24767@subsection GNU/Linux Options
24768
24769These @samp{-m} options are defined for GNU/Linux targets:
24770
24771@table @gcctabopt
24772@item -mglibc
24773@opindex mglibc
24774Use the GNU C library. This is the default except
24775on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
24776@samp{*-*-linux-*android*} targets.
24777
24778@item -muclibc
24779@opindex muclibc
24780Use uClibc C library. This is the default on
24781@samp{*-*-linux-*uclibc*} targets.
24782
24783@item -mmusl
24784@opindex mmusl
24785Use the musl C library. This is the default on
24786@samp{*-*-linux-*musl*} targets.
24787
24788@item -mbionic
24789@opindex mbionic
24790Use Bionic C library. This is the default on
24791@samp{*-*-linux-*android*} targets.
24792
24793@item -mandroid
24794@opindex mandroid
24795Compile code compatible with Android platform. This is the default on
24796@samp{*-*-linux-*android*} targets.
24797
24798When compiling, this option enables @option{-mbionic}, @option{-fPIC},
24799@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
24800this option makes the GCC driver pass Android-specific options to the linker.
24801Finally, this option causes the preprocessor macro @code{__ANDROID__}
24802to be defined.
24803
24804@item -tno-android-cc
24805@opindex tno-android-cc
24806Disable compilation effects of @option{-mandroid}, i.e., do not enable
24807@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
24808@option{-fno-rtti} by default.
24809
24810@item -tno-android-ld
24811@opindex tno-android-ld
24812Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
24813linking options to the linker.
24814
24815@end table
24816
24817@node H8/300 Options
24818@subsection H8/300 Options
24819
24820These @samp{-m} options are defined for the H8/300 implementations:
24821
24822@table @gcctabopt
24823@item -mrelax
24824@opindex mrelax
24825Shorten some address references at link time, when possible; uses the
24826linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
24827ld, Using ld}, for a fuller description.
24828
24829@item -mh
24830@opindex mh
24831Generate code for the H8/300H@.
24832
24833@item -ms
24834@opindex ms
24835Generate code for the H8S@.
24836
24837@item -mn
24838@opindex mn
24839Generate code for the H8S and H8/300H in the normal mode. This switch
24840must be used either with @option{-mh} or @option{-ms}.
24841
24842@item -ms2600
24843@opindex ms2600
24844Generate code for the H8S/2600. This switch must be used with @option{-ms}.
24845
24846@item -mexr
24847@opindex mexr
24848Extended registers are stored on stack before execution of function
24849with monitor attribute. Default option is @option{-mexr}.
24850This option is valid only for H8S targets.
24851
24852@item -mno-exr
24853@opindex mno-exr
24854@opindex mexr
24855Extended registers are not stored on stack before execution of function
24856with monitor attribute. Default option is @option{-mno-exr}.
24857This option is valid only for H8S targets.
24858
24859@item -mint32
24860@opindex mint32
24861Make @code{int} data 32 bits by default.
24862
24863@item -malign-300
24864@opindex malign-300
24865On the H8/300H and H8S, use the same alignment rules as for the H8/300.
24866The default for the H8/300H and H8S is to align longs and floats on
248674-byte boundaries.
24868@option{-malign-300} causes them to be aligned on 2-byte boundaries.
24869This option has no effect on the H8/300.
24870@end table
24871
24872@node HPPA Options
24873@subsection HPPA Options
24874@cindex HPPA Options
24875
24876These @samp{-m} options are defined for the HPPA family of computers:
24877
24878@table @gcctabopt
24879@item -march=@var{architecture-type}
24880@opindex march
24881Generate code for the specified architecture. The choices for
24882@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
248831.1, and @samp{2.0} for PA 2.0 processors. Refer to
24884@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
24885architecture option for your machine. Code compiled for lower numbered
24886architectures runs on higher numbered architectures, but not the
24887other way around.
24888
24889@item -mpa-risc-1-0
24890@itemx -mpa-risc-1-1
24891@itemx -mpa-risc-2-0
24892@opindex mpa-risc-1-0
24893@opindex mpa-risc-1-1
24894@opindex mpa-risc-2-0
24895Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
24896
24897@item -mcaller-copies
24898@opindex mcaller-copies
24899The caller copies function arguments passed by hidden reference. This
24900option should be used with care as it is not compatible with the default
2490132-bit runtime. However, only aggregates larger than eight bytes are
24902passed by hidden reference and the option provides better compatibility
24903with OpenMP.
24904
24905@item -mjump-in-delay
24906@opindex mjump-in-delay
24907This option is ignored and provided for compatibility purposes only.
24908
24909@item -mdisable-fpregs
24910@opindex mdisable-fpregs
24911Prevent floating-point registers from being used in any manner. This is
24912necessary for compiling kernels that perform lazy context switching of
24913floating-point registers. If you use this option and attempt to perform
24914floating-point operations, the compiler aborts.
24915
24916@item -mdisable-indexing
24917@opindex mdisable-indexing
24918Prevent the compiler from using indexing address modes. This avoids some
24919rather obscure problems when compiling MIG generated code under MACH@.
24920
24921@item -mno-space-regs
24922@opindex mno-space-regs
24923@opindex mspace-regs
24924Generate code that assumes the target has no space registers. This allows
24925GCC to generate faster indirect calls and use unscaled index address modes.
24926
24927Such code is suitable for level 0 PA systems and kernels.
24928
24929@item -mfast-indirect-calls
24930@opindex mfast-indirect-calls
24931Generate code that assumes calls never cross space boundaries. This
24932allows GCC to emit code that performs faster indirect calls.
24933
24934This option does not work in the presence of shared libraries or nested
24935functions.
24936
24937@item -mfixed-range=@var{register-range}
24938@opindex mfixed-range
24939Generate code treating the given register range as fixed registers.
24940A fixed register is one that the register allocator cannot use. This is
24941useful when compiling kernel code. A register range is specified as
24942two registers separated by a dash. Multiple register ranges can be
24943specified separated by a comma.
24944
24945@item -mlong-load-store
24946@opindex mlong-load-store
24947Generate 3-instruction load and store sequences as sometimes required by
24948the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
24949the HP compilers.
24950
24951@item -mportable-runtime
24952@opindex mportable-runtime
24953Use the portable calling conventions proposed by HP for ELF systems.
24954
24955@item -mgas
24956@opindex mgas
24957Enable the use of assembler directives only GAS understands.
24958
24959@item -mschedule=@var{cpu-type}
24960@opindex mschedule
24961Schedule code according to the constraints for the machine type
24962@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
24963@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
24964to @file{/usr/lib/sched.models} on an HP-UX system to determine the
24965proper scheduling option for your machine. The default scheduling is
24966@samp{8000}.
24967
24968@item -mlinker-opt
24969@opindex mlinker-opt
24970Enable the optimization pass in the HP-UX linker. Note this makes symbolic
24971debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
24972linkers in which they give bogus error messages when linking some programs.
24973
24974@item -msoft-float
24975@opindex msoft-float
24976Generate output containing library calls for floating point.
24977@strong{Warning:} the requisite libraries are not available for all HPPA
24978targets. Normally the facilities of the machine's usual C compiler are
24979used, but this cannot be done directly in cross-compilation. You must make
24980your own arrangements to provide suitable library functions for
24981cross-compilation.
24982
24983@option{-msoft-float} changes the calling convention in the output file;
24984therefore, it is only useful if you compile @emph{all} of a program with
24985this option. In particular, you need to compile @file{libgcc.a}, the
24986library that comes with GCC, with @option{-msoft-float} in order for
24987this to work.
24988
24989@item -msio
24990@opindex msio
24991Generate the predefine, @code{_SIO}, for server IO@. The default is
24992@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
24993@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
24994options are available under HP-UX and HI-UX@.
24995
24996@item -mgnu-ld
24997@opindex mgnu-ld
24998Use options specific to GNU @command{ld}.
24999This passes @option{-shared} to @command{ld} when
25000building a shared library. It is the default when GCC is configured,
25001explicitly or implicitly, with the GNU linker. This option does not
25002affect which @command{ld} is called; it only changes what parameters
25003are passed to that @command{ld}.
25004The @command{ld} that is called is determined by the
25005@option{--with-ld} configure option, GCC's program search path, and
25006finally by the user's @env{PATH}. The linker used by GCC can be printed
25007using @samp{which `gcc -print-prog-name=ld`}. This option is only available
25008on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25009
25010@item -mhp-ld
25011@opindex mhp-ld
25012Use options specific to HP @command{ld}.
25013This passes @option{-b} to @command{ld} when building
25014a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
25015links. It is the default when GCC is configured, explicitly or
25016implicitly, with the HP linker. This option does not affect
25017which @command{ld} is called; it only changes what parameters are passed to that
25018@command{ld}.
25019The @command{ld} that is called is determined by the @option{--with-ld}
25020configure option, GCC's program search path, and finally by the user's
25021@env{PATH}. The linker used by GCC can be printed using @samp{which
25022`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
25023HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
25024
25025@item -mlong-calls
25026@opindex mno-long-calls
25027@opindex mlong-calls
25028Generate code that uses long call sequences. This ensures that a call
25029is always able to reach linker generated stubs. The default is to generate
25030long calls only when the distance from the call site to the beginning
25031of the function or translation unit, as the case may be, exceeds a
25032predefined limit set by the branch type being used. The limits for
25033normal calls are 7,600,000 and 240,000 bytes, respectively for the
25034PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25035240,000 bytes.
25036
25037Distances are measured from the beginning of functions when using the
25038@option{-ffunction-sections} option, or when using the @option{-mgas}
25039and @option{-mno-portable-runtime} options together under HP-UX with
25040the SOM linker.
25041
25042It is normally not desirable to use this option as it degrades
25043performance. However, it may be useful in large applications,
25044particularly when partial linking is used to build the application.
25045
25046The types of long calls used depends on the capabilities of the
25047assembler and linker, and the type of code being generated. The
25048impact on systems that support long absolute calls, and long pic
25049symbol-difference or pc-relative calls should be relatively small.
25050However, an indirect call is used on 32-bit ELF systems in pic code
25051and it is quite long.
25052
25053@item -munix=@var{unix-std}
25054@opindex march
25055Generate compiler predefines and select a startfile for the specified
25056UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25057and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25058is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2505911.11 and later. The default values are @samp{93} for HP-UX 10.00,
25060@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25061and later.
25062
25063@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25064@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25065and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25066@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25067@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25068@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25069
25070It is @emph{important} to note that this option changes the interfaces
25071for various library routines. It also affects the operational behavior
25072of the C library. Thus, @emph{extreme} care is needed in using this
25073option.
25074
25075Library code that is intended to operate with more than one UNIX
25076standard must test, set and restore the variable @code{__xpg4_extended_mask}
25077as appropriate. Most GNU software doesn't provide this capability.
25078
25079@item -nolibdld
25080@opindex nolibdld
25081Suppress the generation of link options to search libdld.sl when the
25082@option{-static} option is specified on HP-UX 10 and later.
25083
25084@item -static
25085@opindex static
25086The HP-UX implementation of setlocale in libc has a dependency on
25087libdld.sl. There isn't an archive version of libdld.sl. Thus,
25088when the @option{-static} option is specified, special link options
25089are needed to resolve this dependency.
25090
25091On HP-UX 10 and later, the GCC driver adds the necessary options to
25092link with libdld.sl when the @option{-static} option is specified.
25093This causes the resulting binary to be dynamic. On the 64-bit port,
25094the linkers generate dynamic binaries by default in any case. The
25095@option{-nolibdld} option can be used to prevent the GCC driver from
25096adding these link options.
25097
25098@item -threads
25099@opindex threads
25100Add support for multithreading with the @dfn{dce thread} library
25101under HP-UX@. This option sets flags for both the preprocessor and
25102linker.
25103@end table
25104
25105@node IA-64 Options
25106@subsection IA-64 Options
25107@cindex IA-64 Options
25108
25109These are the @samp{-m} options defined for the Intel IA-64 architecture.
25110
25111@table @gcctabopt
25112@item -mbig-endian
25113@opindex mbig-endian
25114Generate code for a big-endian target. This is the default for HP-UX@.
25115
25116@item -mlittle-endian
25117@opindex mlittle-endian
25118Generate code for a little-endian target. This is the default for AIX5
25119and GNU/Linux.
25120
25121@item -mgnu-as
25122@itemx -mno-gnu-as
25123@opindex mgnu-as
25124@opindex mno-gnu-as
25125Generate (or don't) code for the GNU assembler. This is the default.
25126@c Also, this is the default if the configure option @option{--with-gnu-as}
25127@c is used.
25128
25129@item -mgnu-ld
25130@itemx -mno-gnu-ld
25131@opindex mgnu-ld
25132@opindex mno-gnu-ld
25133Generate (or don't) code for the GNU linker. This is the default.
25134@c Also, this is the default if the configure option @option{--with-gnu-ld}
25135@c is used.
25136
25137@item -mno-pic
25138@opindex mno-pic
25139Generate code that does not use a global pointer register. The result
25140is not position independent code, and violates the IA-64 ABI@.
25141
25142@item -mvolatile-asm-stop
25143@itemx -mno-volatile-asm-stop
25144@opindex mvolatile-asm-stop
25145@opindex mno-volatile-asm-stop
25146Generate (or don't) a stop bit immediately before and after volatile asm
25147statements.
25148
25149@item -mregister-names
25150@itemx -mno-register-names
25151@opindex mregister-names
25152@opindex mno-register-names
25153Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25154the stacked registers. This may make assembler output more readable.
25155
25156@item -mno-sdata
25157@itemx -msdata
25158@opindex mno-sdata
25159@opindex msdata
25160Disable (or enable) optimizations that use the small data section. This may
25161be useful for working around optimizer bugs.
25162
25163@item -mconstant-gp
25164@opindex mconstant-gp
25165Generate code that uses a single constant global pointer value. This is
25166useful when compiling kernel code.
25167
25168@item -mauto-pic
25169@opindex mauto-pic
25170Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25171This is useful when compiling firmware code.
25172
25173@item -minline-float-divide-min-latency
25174@opindex minline-float-divide-min-latency
25175Generate code for inline divides of floating-point values
25176using the minimum latency algorithm.
25177
25178@item -minline-float-divide-max-throughput
25179@opindex minline-float-divide-max-throughput
25180Generate code for inline divides of floating-point values
25181using the maximum throughput algorithm.
25182
25183@item -mno-inline-float-divide
25184@opindex mno-inline-float-divide
25185Do not generate inline code for divides of floating-point values.
25186
25187@item -minline-int-divide-min-latency
25188@opindex minline-int-divide-min-latency
25189Generate code for inline divides of integer values
25190using the minimum latency algorithm.
25191
25192@item -minline-int-divide-max-throughput
25193@opindex minline-int-divide-max-throughput
25194Generate code for inline divides of integer values
25195using the maximum throughput algorithm.
25196
25197@item -mno-inline-int-divide
25198@opindex mno-inline-int-divide
25199@opindex minline-int-divide
25200Do not generate inline code for divides of integer values.
25201
25202@item -minline-sqrt-min-latency
25203@opindex minline-sqrt-min-latency
25204Generate code for inline square roots
25205using the minimum latency algorithm.
25206
25207@item -minline-sqrt-max-throughput
25208@opindex minline-sqrt-max-throughput
25209Generate code for inline square roots
25210using the maximum throughput algorithm.
25211
25212@item -mno-inline-sqrt
25213@opindex mno-inline-sqrt
25214Do not generate inline code for @code{sqrt}.
25215
25216@item -mfused-madd
25217@itemx -mno-fused-madd
25218@opindex mfused-madd
25219@opindex mno-fused-madd
25220Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25221instructions. The default is to use these instructions.
25222
25223@item -mno-dwarf2-asm
25224@itemx -mdwarf2-asm
25225@opindex mno-dwarf2-asm
25226@opindex mdwarf2-asm
25227Don't (or do) generate assembler code for the DWARF line number debugging
25228info. This may be useful when not using the GNU assembler.
25229
25230@item -mearly-stop-bits
25231@itemx -mno-early-stop-bits
25232@opindex mearly-stop-bits
25233@opindex mno-early-stop-bits
25234Allow stop bits to be placed earlier than immediately preceding the
25235instruction that triggered the stop bit. This can improve instruction
25236scheduling, but does not always do so.
25237
25238@item -mfixed-range=@var{register-range}
25239@opindex mfixed-range
25240Generate code treating the given register range as fixed registers.
25241A fixed register is one that the register allocator cannot use. This is
25242useful when compiling kernel code. A register range is specified as
25243two registers separated by a dash. Multiple register ranges can be
25244specified separated by a comma.
25245
25246@item -mtls-size=@var{tls-size}
25247@opindex mtls-size
25248Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2524964.
25250
25251@item -mtune=@var{cpu-type}
25252@opindex mtune
25253Tune the instruction scheduling for a particular CPU, Valid values are
25254@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25255and @samp{mckinley}.
25256
25257@item -milp32
25258@itemx -mlp64
25259@opindex milp32
25260@opindex mlp64
25261Generate code for a 32-bit or 64-bit environment.
25262The 32-bit environment sets int, long and pointer to 32 bits.
25263The 64-bit environment sets int to 32 bits and long and pointer
25264to 64 bits. These are HP-UX specific flags.
25265
25266@item -mno-sched-br-data-spec
25267@itemx -msched-br-data-spec
25268@opindex mno-sched-br-data-spec
25269@opindex msched-br-data-spec
25270(Dis/En)able data speculative scheduling before reload.
25271This results in generation of @code{ld.a} instructions and
25272the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25273The default setting is disabled.
25274
25275@item -msched-ar-data-spec
25276@itemx -mno-sched-ar-data-spec
25277@opindex msched-ar-data-spec
25278@opindex mno-sched-ar-data-spec
25279(En/Dis)able data speculative scheduling after reload.
25280This results in generation of @code{ld.a} instructions and
25281the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25282The default setting is enabled.
25283
25284@item -mno-sched-control-spec
25285@itemx -msched-control-spec
25286@opindex mno-sched-control-spec
25287@opindex msched-control-spec
25288(Dis/En)able control speculative scheduling. This feature is
25289available only during region scheduling (i.e.@: before reload).
25290This results in generation of the @code{ld.s} instructions and
25291the corresponding check instructions @code{chk.s}.
25292The default setting is disabled.
25293
25294@item -msched-br-in-data-spec
25295@itemx -mno-sched-br-in-data-spec
25296@opindex msched-br-in-data-spec
25297@opindex mno-sched-br-in-data-spec
25298(En/Dis)able speculative scheduling of the instructions that
25299are dependent on the data speculative loads before reload.
25300This is effective only with @option{-msched-br-data-spec} enabled.
25301The default setting is enabled.
25302
25303@item -msched-ar-in-data-spec
25304@itemx -mno-sched-ar-in-data-spec
25305@opindex msched-ar-in-data-spec
25306@opindex mno-sched-ar-in-data-spec
25307(En/Dis)able speculative scheduling of the instructions that
25308are dependent on the data speculative loads after reload.
25309This is effective only with @option{-msched-ar-data-spec} enabled.
25310The default setting is enabled.
25311
25312@item -msched-in-control-spec
25313@itemx -mno-sched-in-control-spec
25314@opindex msched-in-control-spec
25315@opindex mno-sched-in-control-spec
25316(En/Dis)able speculative scheduling of the instructions that
25317are dependent on the control speculative loads.
25318This is effective only with @option{-msched-control-spec} enabled.
25319The default setting is enabled.
25320
25321@item -mno-sched-prefer-non-data-spec-insns
25322@itemx -msched-prefer-non-data-spec-insns
25323@opindex mno-sched-prefer-non-data-spec-insns
25324@opindex msched-prefer-non-data-spec-insns
25325If enabled, data-speculative instructions are chosen for schedule
25326only if there are no other choices at the moment. This makes
25327the use of the data speculation much more conservative.
25328The default setting is disabled.
25329
25330@item -mno-sched-prefer-non-control-spec-insns
25331@itemx -msched-prefer-non-control-spec-insns
25332@opindex mno-sched-prefer-non-control-spec-insns
25333@opindex msched-prefer-non-control-spec-insns
25334If enabled, control-speculative instructions are chosen for schedule
25335only if there are no other choices at the moment. This makes
25336the use of the control speculation much more conservative.
25337The default setting is disabled.
25338
25339@item -mno-sched-count-spec-in-critical-path
25340@itemx -msched-count-spec-in-critical-path
25341@opindex mno-sched-count-spec-in-critical-path
25342@opindex msched-count-spec-in-critical-path
25343If enabled, speculative dependencies are considered during
25344computation of the instructions priorities. This makes the use of the
25345speculation a bit more conservative.
25346The default setting is disabled.
25347
25348@item -msched-spec-ldc
25349@opindex msched-spec-ldc
25350Use a simple data speculation check. This option is on by default.
25351
25352@item -msched-control-spec-ldc
25353@opindex msched-spec-ldc
25354Use a simple check for control speculation. This option is on by default.
25355
25356@item -msched-stop-bits-after-every-cycle
25357@opindex msched-stop-bits-after-every-cycle
25358Place a stop bit after every cycle when scheduling. This option is on
25359by default.
25360
25361@item -msched-fp-mem-deps-zero-cost
25362@opindex msched-fp-mem-deps-zero-cost
25363Assume that floating-point stores and loads are not likely to cause a conflict
25364when placed into the same instruction group. This option is disabled by
25365default.
25366
25367@item -msel-sched-dont-check-control-spec
25368@opindex msel-sched-dont-check-control-spec
25369Generate checks for control speculation in selective scheduling.
25370This flag is disabled by default.
25371
25372@item -msched-max-memory-insns=@var{max-insns}
25373@opindex msched-max-memory-insns
25374Limit on the number of memory insns per instruction group, giving lower
25375priority to subsequent memory insns attempting to schedule in the same
25376instruction group. Frequently useful to prevent cache bank conflicts.
25377The default value is 1.
25378
25379@item -msched-max-memory-insns-hard-limit
25380@opindex msched-max-memory-insns-hard-limit
25381Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25382disallowing more than that number in an instruction group.
25383Otherwise, the limit is ``soft'', meaning that non-memory operations
25384are preferred when the limit is reached, but memory operations may still
25385be scheduled.
25386
25387@end table
25388
25389@node LM32 Options
25390@subsection LM32 Options
25391@cindex LM32 options
25392
25393These @option{-m} options are defined for the LatticeMico32 architecture:
25394
25395@table @gcctabopt
25396@item -mbarrel-shift-enabled
25397@opindex mbarrel-shift-enabled
25398Enable barrel-shift instructions.
25399
25400@item -mdivide-enabled
25401@opindex mdivide-enabled
25402Enable divide and modulus instructions.
25403
25404@item -mmultiply-enabled
25405@opindex multiply-enabled
25406Enable multiply instructions.
25407
25408@item -msign-extend-enabled
25409@opindex msign-extend-enabled
25410Enable sign extend instructions.
25411
25412@item -muser-enabled
25413@opindex muser-enabled
25414Enable user-defined instructions.
25415
25416@end table
25417
25418@node LoongArch Options
25419@subsection LoongArch Options
25420@cindex LoongArch Options
25421
25422These command-line options are defined for LoongArch targets:
25423
25424@table @gcctabopt
25425@item -march=@var{cpu-type}
9c19597c 25426@opindex march
d77de738
ML
25427Generate instructions for the machine type @var{cpu-type}. In contrast to
25428@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
25429for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
25430to generate code that may not run at all on processors other than the one
25431indicated. Specifying @option{-march=@var{cpu-type}} implies
25432@option{-mtune=@var{cpu-type}}, except where noted otherwise.
25433
25434The choices for @var{cpu-type} are:
25435
25436@table @samp
25437@item native
25438This selects the CPU to generate code for at compilation time by determining
25439the processor type of the compiling machine. Using @option{-march=native}
25440enables all instruction subsets supported by the local machine (hence
25441the result might not run on different machines). Using @option{-mtune=native}
25442produces code optimized for the local machine under the constraints
25443of the selected instruction set.
25444@item loongarch64
25445A generic CPU with 64-bit extensions.
25446@item la464
25447LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
25448@end table
25449
25450@item -mtune=@var{cpu-type}
25451@opindex mtune
25452Optimize the output for the given processor, specified by microarchitecture
25453name.
25454
25455@item -mabi=@var{base-abi-type}
25456@opindex mabi
25457Generate code for the specified calling convention.
25458@var{base-abi-type} can be one of:
25459@table @samp
25460@item lp64d
25461Uses 64-bit general purpose registers and 32/64-bit floating-point
25462registers for parameter passing. Data model is LP64, where @samp{int}
25463is 32 bits, while @samp{long int} and pointers are 64 bits.
25464@item lp64f
25465Uses 64-bit general purpose registers and 32-bit floating-point
25466registers for parameter passing. Data model is LP64, where @samp{int}
25467is 32 bits, while @samp{long int} and pointers are 64 bits.
25468@item lp64s
25469Uses 64-bit general purpose registers and no floating-point
25470registers for parameter passing. Data model is LP64, where @samp{int}
25471is 32 bits, while @samp{long int} and pointers are 64 bits.
25472@end table
25473
25474@item -mfpu=@var{fpu-type}
25475@opindex mfpu
25476Generate code for the specified FPU type, which can be one of:
25477@table @samp
25478@item 64
25479Allow the use of hardware floating-point instructions for 32-bit
25480and 64-bit operations.
25481@item 32
25482Allow the use of hardware floating-point instructions for 32-bit
25483operations.
25484@item none
25485@item 0
25486Prevent the use of hardware floating-point instructions.
25487@end table
25488
25489@item -msoft-float
25490@opindex msoft-float
25491Force @option{-mfpu=none} and prevents the use of floating-point
25492registers for parameter passing. This option may change the target
25493ABI.
25494
25495@item -msingle-float
9c19597c 25496@opindex msingle-float
d77de738
ML
25497Force @option{-mfpu=32} and allow the use of 32-bit floating-point
25498registers for parameter passing. This option may change the target
25499ABI.
25500
25501@item -mdouble-float
9c19597c 25502@opindex mdouble-float
d77de738
ML
25503Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
25504registers for parameter passing. This option may change the target
25505ABI.
25506
25507@item -mbranch-cost=@var{n}
9c19597c 25508@opindex mbranch-cost
d77de738
ML
25509Set the cost of branches to roughly @var{n} instructions.
25510
25511@item -mcheck-zero-division
25512@itemx -mno-check-zero-divison
9c19597c 25513@opindex mcheck-zero-division
d77de738
ML
25514Trap (do not trap) on integer division by zero. The default is
25515@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
25516@option{-mno-check-zero-division} for other optimization levels.
25517
25518@item -mcond-move-int
25519@itemx -mno-cond-move-int
9c19597c 25520@opindex mcond-move-int
d77de738
ML
25521Conditional moves for integral data in general-purpose registers
25522are enabled (disabled). The default is @option{-mcond-move-int}.
25523
25524@item -mcond-move-float
25525@itemx -mno-cond-move-float
9c19597c 25526@opindex mcond-move-float
d77de738
ML
25527Conditional moves for floating-point registers are enabled (disabled).
25528The default is @option{-mcond-move-float}.
25529
25530@item -mmemcpy
25531@itemx -mno-memcpy
9c19597c 25532@opindex mmemcpy
d77de738
ML
25533Force (do not force) the use of @code{memcpy} for non-trivial block moves.
25534The default is @option{-mno-memcpy}, which allows GCC to inline most
25535constant-sized copies. Setting optimization level to @option{-Os} also
25536forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
25537behavior if explicitly specified, regardless of the order these options on
25538the command line.
25539
25540@item -mstrict-align
25541@itemx -mno-strict-align
9c19597c 25542@opindex mstrict-align
d77de738
ML
25543Avoid or allow generating memory accesses that may not be aligned on a natural
25544object boundary as described in the architecture specification. The default is
25545@option{-mno-strict-align}.
25546
25547@item -msmall-data-limit=@var{number}
9c19597c 25548@opindex msmall-data-limit
d77de738
ML
25549Put global and static data smaller than @var{number} bytes into a special
25550section (on some targets). The default value is 0.
25551
25552@item -mmax-inline-memcpy-size=@var{n}
9c19597c 25553@opindex mmax-inline-memcpy-size
d77de738
ML
25554Inline all block moves (such as calls to @code{memcpy} or structure copies)
25555less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
25556
25557@item -mcmodel=@var{code-model}
25558Set the code model to one of:
25559@table @samp
25560@item tiny-static (Not implemented yet)
25561@item tiny (Not implemented yet)
25562
25563@item normal
25564The text segment must be within 128MB addressing space. The data segment must
25565be within 2GB addressing space.
25566
25567@item medium
25568The text segment and data segment must be within 2GB addressing space.
25569
25570@item large (Not implemented yet)
25571
25572@item extreme
25573This mode does not limit the size of the code segment and data segment.
25574The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
25575@option{-mno-explicit-relocs}.
25576@end table
25577The default code model is @code{normal}.
25578
25579@item -mexplicit-relocs
25580@itemx -mno-explicit-relocs
25581@opindex mexplicit-relocs
25582@opindex mno-explicit-relocs
25583Use or do not use assembler relocation operators when dealing with symbolic
25584addresses. The alternative is to use assembler macros instead, which may
25585limit optimization. The default value for the option is determined during
25586GCC build-time by detecting corresponding assembler support:
25587@code{-mexplicit-relocs} if said support is present,
25588@code{-mno-explicit-relocs} otherwise. This option is mostly useful for
25589debugging, or interoperation with assemblers different from the build-time
25590one.
25591
25592@item -mdirect-extern-access
25593@itemx -mno-direct-extern-access
25594@opindex mdirect-extern-access
25595Do not use or use GOT to access external symbols. The default is
25596@option{-mno-direct-extern-access}: GOT is used for external symbols with
25597default visibility, but not used for other external symbols.
25598
25599With @option{-mdirect-extern-access}, GOT is not used and all external
25600symbols are PC-relatively addressed. It is @strong{only} suitable for
25601environments where no dynamic link is performed, like firmwares, OS
25602kernels, executables linked with @option{-static} or @option{-static-pie}.
25603@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
25604@option{-fpic}.
25605@end table
25606
25607@node M32C Options
25608@subsection M32C Options
25609@cindex M32C options
25610
25611@table @gcctabopt
25612@item -mcpu=@var{name}
25613@opindex mcpu=
25614Select the CPU for which code is generated. @var{name} may be one of
25615@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
25616/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
25617the M32C/80 series.
25618
25619@item -msim
25620@opindex msim
25621Specifies that the program will be run on the simulator. This causes
25622an alternate runtime library to be linked in which supports, for
25623example, file I/O@. You must not use this option when generating
25624programs that will run on real hardware; you must provide your own
25625runtime library for whatever I/O functions are needed.
25626
25627@item -memregs=@var{number}
25628@opindex memregs=
25629Specifies the number of memory-based pseudo-registers GCC uses
25630during code generation. These pseudo-registers are used like real
25631registers, so there is a tradeoff between GCC's ability to fit the
25632code into available registers, and the performance penalty of using
25633memory instead of registers. Note that all modules in a program must
25634be compiled with the same value for this option. Because of that, you
25635must not use this option with GCC's default runtime libraries.
25636
25637@end table
25638
25639@node M32R/D Options
25640@subsection M32R/D Options
25641@cindex M32R/D options
25642
25643These @option{-m} options are defined for Renesas M32R/D architectures:
25644
25645@table @gcctabopt
25646@item -m32r2
25647@opindex m32r2
25648Generate code for the M32R/2@.
25649
25650@item -m32rx
25651@opindex m32rx
25652Generate code for the M32R/X@.
25653
25654@item -m32r
25655@opindex m32r
25656Generate code for the M32R@. This is the default.
25657
25658@item -mmodel=small
25659@opindex mmodel=small
25660Assume all objects live in the lower 16MB of memory (so that their addresses
25661can be loaded with the @code{ld24} instruction), and assume all subroutines
25662are reachable with the @code{bl} instruction.
25663This is the default.
25664
25665The addressability of a particular object can be set with the
25666@code{model} attribute.
25667
25668@item -mmodel=medium
25669@opindex mmodel=medium
25670Assume objects may be anywhere in the 32-bit address space (the compiler
25671generates @code{seth/add3} instructions to load their addresses), and
25672assume all subroutines are reachable with the @code{bl} instruction.
25673
25674@item -mmodel=large
25675@opindex mmodel=large
25676Assume objects may be anywhere in the 32-bit address space (the compiler
25677generates @code{seth/add3} instructions to load their addresses), and
25678assume subroutines may not be reachable with the @code{bl} instruction
25679(the compiler generates the much slower @code{seth/add3/jl}
25680instruction sequence).
25681
25682@item -msdata=none
25683@opindex msdata=none
25684Disable use of the small data area. Variables are put into
25685one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
25686@code{section} attribute has been specified).
25687This is the default.
25688
25689The small data area consists of sections @code{.sdata} and @code{.sbss}.
25690Objects may be explicitly put in the small data area with the
25691@code{section} attribute using one of these sections.
25692
25693@item -msdata=sdata
25694@opindex msdata=sdata
25695Put small global and static data in the small data area, but do not
25696generate special code to reference them.
25697
25698@item -msdata=use
25699@opindex msdata=use
25700Put small global and static data in the small data area, and generate
25701special instructions to reference them.
25702
25703@item -G @var{num}
25704@opindex G
25705@cindex smaller data references
25706Put global and static objects less than or equal to @var{num} bytes
25707into the small data or BSS sections instead of the normal data or BSS
25708sections. The default value of @var{num} is 8.
25709The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
25710for this option to have any effect.
25711
25712All modules should be compiled with the same @option{-G @var{num}} value.
25713Compiling with different values of @var{num} may or may not work; if it
25714doesn't the linker gives an error message---incorrect code is not
25715generated.
25716
25717@item -mdebug
25718@opindex mdebug
25719Makes the M32R-specific code in the compiler display some statistics
25720that might help in debugging programs.
25721
25722@item -malign-loops
25723@opindex malign-loops
25724Align all loops to a 32-byte boundary.
25725
25726@item -mno-align-loops
25727@opindex mno-align-loops
25728Do not enforce a 32-byte alignment for loops. This is the default.
25729
25730@item -missue-rate=@var{number}
25731@opindex missue-rate=@var{number}
25732Issue @var{number} instructions per cycle. @var{number} can only be 1
25733or 2.
25734
25735@item -mbranch-cost=@var{number}
25736@opindex mbranch-cost=@var{number}
25737@var{number} can only be 1 or 2. If it is 1 then branches are
25738preferred over conditional code, if it is 2, then the opposite applies.
25739
25740@item -mflush-trap=@var{number}
25741@opindex mflush-trap=@var{number}
25742Specifies the trap number to use to flush the cache. The default is
2574312. Valid numbers are between 0 and 15 inclusive.
25744
25745@item -mno-flush-trap
25746@opindex mno-flush-trap
25747Specifies that the cache cannot be flushed by using a trap.
25748
25749@item -mflush-func=@var{name}
25750@opindex mflush-func=@var{name}
25751Specifies the name of the operating system function to call to flush
25752the cache. The default is @samp{_flush_cache}, but a function call
25753is only used if a trap is not available.
25754
25755@item -mno-flush-func
25756@opindex mno-flush-func
25757Indicates that there is no OS function for flushing the cache.
25758
25759@end table
25760
25761@node M680x0 Options
25762@subsection M680x0 Options
25763@cindex M680x0 options
25764
25765These are the @samp{-m} options defined for M680x0 and ColdFire processors.
25766The default settings depend on which architecture was selected when
25767the compiler was configured; the defaults for the most common choices
25768are given below.
25769
25770@table @gcctabopt
25771@item -march=@var{arch}
25772@opindex march
25773Generate code for a specific M680x0 or ColdFire instruction set
25774architecture. Permissible values of @var{arch} for M680x0
25775architectures are: @samp{68000}, @samp{68010}, @samp{68020},
25776@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
25777architectures are selected according to Freescale's ISA classification
25778and the permissible values are: @samp{isaa}, @samp{isaaplus},
25779@samp{isab} and @samp{isac}.
25780
25781GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
25782code for a ColdFire target. The @var{arch} in this macro is one of the
25783@option{-march} arguments given above.
25784
25785When used together, @option{-march} and @option{-mtune} select code
25786that runs on a family of similar processors but that is optimized
25787for a particular microarchitecture.
25788
25789@item -mcpu=@var{cpu}
25790@opindex mcpu
25791Generate code for a specific M680x0 or ColdFire processor.
25792The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
25793@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
25794and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
25795below, which also classifies the CPUs into families:
25796
25797@multitable @columnfractions 0.20 0.80
25798@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
25799@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}
25800@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
25801@item @samp{5206e} @tab @samp{5206e}
25802@item @samp{5208} @tab @samp{5207} @samp{5208}
25803@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
25804@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
25805@item @samp{5216} @tab @samp{5214} @samp{5216}
25806@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
25807@item @samp{5225} @tab @samp{5224} @samp{5225}
25808@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
25809@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
25810@item @samp{5249} @tab @samp{5249}
25811@item @samp{5250} @tab @samp{5250}
25812@item @samp{5271} @tab @samp{5270} @samp{5271}
25813@item @samp{5272} @tab @samp{5272}
25814@item @samp{5275} @tab @samp{5274} @samp{5275}
25815@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
25816@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
25817@item @samp{5307} @tab @samp{5307}
25818@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
25819@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
25820@item @samp{5407} @tab @samp{5407}
25821@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}
25822@end multitable
25823
25824@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
25825@var{arch} is compatible with @var{cpu}. Other combinations of
25826@option{-mcpu} and @option{-march} are rejected.
25827
25828GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
25829@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
25830where the value of @var{family} is given by the table above.
25831
25832@item -mtune=@var{tune}
25833@opindex mtune
25834Tune the code for a particular microarchitecture within the
25835constraints set by @option{-march} and @option{-mcpu}.
25836The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
25837@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
25838and @samp{cpu32}. The ColdFire microarchitectures
25839are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
25840
25841You can also use @option{-mtune=68020-40} for code that needs
25842to run relatively well on 68020, 68030 and 68040 targets.
25843@option{-mtune=68020-60} is similar but includes 68060 targets
25844as well. These two options select the same tuning decisions as
25845@option{-m68020-40} and @option{-m68020-60} respectively.
25846
25847GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
25848when tuning for 680x0 architecture @var{arch}. It also defines
25849@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
25850option is used. If GCC is tuning for a range of architectures,
25851as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
25852it defines the macros for every architecture in the range.
25853
25854GCC also defines the macro @code{__m@var{uarch}__} when tuning for
25855ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
25856of the arguments given above.
25857
25858@item -m68000
25859@itemx -mc68000
25860@opindex m68000
25861@opindex mc68000
25862Generate output for a 68000. This is the default
25863when the compiler is configured for 68000-based systems.
25864It is equivalent to @option{-march=68000}.
25865
25866Use this option for microcontrollers with a 68000 or EC000 core,
25867including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
25868
25869@item -m68010
25870@opindex m68010
25871Generate output for a 68010. This is the default
25872when the compiler is configured for 68010-based systems.
25873It is equivalent to @option{-march=68010}.
25874
25875@item -m68020
25876@itemx -mc68020
25877@opindex m68020
25878@opindex mc68020
25879Generate output for a 68020. This is the default
25880when the compiler is configured for 68020-based systems.
25881It is equivalent to @option{-march=68020}.
25882
25883@item -m68030
25884@opindex m68030
25885Generate output for a 68030. This is the default when the compiler is
25886configured for 68030-based systems. It is equivalent to
25887@option{-march=68030}.
25888
25889@item -m68040
25890@opindex m68040
25891Generate output for a 68040. This is the default when the compiler is
25892configured for 68040-based systems. It is equivalent to
25893@option{-march=68040}.
25894
25895This option inhibits the use of 68881/68882 instructions that have to be
25896emulated by software on the 68040. Use this option if your 68040 does not
25897have code to emulate those instructions.
25898
25899@item -m68060
25900@opindex m68060
25901Generate output for a 68060. This is the default when the compiler is
25902configured for 68060-based systems. It is equivalent to
25903@option{-march=68060}.
25904
25905This option inhibits the use of 68020 and 68881/68882 instructions that
25906have to be emulated by software on the 68060. Use this option if your 68060
25907does not have code to emulate those instructions.
25908
25909@item -mcpu32
25910@opindex mcpu32
25911Generate output for a CPU32. This is the default
25912when the compiler is configured for CPU32-based systems.
25913It is equivalent to @option{-march=cpu32}.
25914
25915Use this option for microcontrollers with a
25916CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2591768336, 68340, 68341, 68349 and 68360.
25918
25919@item -m5200
25920@opindex m5200
25921Generate output for a 520X ColdFire CPU@. This is the default
25922when the compiler is configured for 520X-based systems.
25923It is equivalent to @option{-mcpu=5206}, and is now deprecated
25924in favor of that option.
25925
25926Use this option for microcontroller with a 5200 core, including
25927the MCF5202, MCF5203, MCF5204 and MCF5206.
25928
25929@item -m5206e
25930@opindex m5206e
25931Generate output for a 5206e ColdFire CPU@. The option is now
25932deprecated in favor of the equivalent @option{-mcpu=5206e}.
25933
25934@item -m528x
25935@opindex m528x
25936Generate output for a member of the ColdFire 528X family.
25937The option is now deprecated in favor of the equivalent
25938@option{-mcpu=528x}.
25939
25940@item -m5307
25941@opindex m5307
25942Generate output for a ColdFire 5307 CPU@. The option is now deprecated
25943in favor of the equivalent @option{-mcpu=5307}.
25944
25945@item -m5407
25946@opindex m5407
25947Generate output for a ColdFire 5407 CPU@. The option is now deprecated
25948in favor of the equivalent @option{-mcpu=5407}.
25949
25950@item -mcfv4e
25951@opindex mcfv4e
25952Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
25953This includes use of hardware floating-point instructions.
25954The option is equivalent to @option{-mcpu=547x}, and is now
25955deprecated in favor of that option.
25956
25957@item -m68020-40
25958@opindex m68020-40
25959Generate output for a 68040, without using any of the new instructions.
25960This results in code that can run relatively efficiently on either a
2596168020/68881 or a 68030 or a 68040. The generated code does use the
2596268881 instructions that are emulated on the 68040.
25963
25964The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
25965
25966@item -m68020-60
25967@opindex m68020-60
25968Generate output for a 68060, without using any of the new instructions.
25969This results in code that can run relatively efficiently on either a
2597068020/68881 or a 68030 or a 68040. The generated code does use the
2597168881 instructions that are emulated on the 68060.
25972
25973The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
25974
25975@item -mhard-float
25976@itemx -m68881
25977@opindex mhard-float
25978@opindex m68881
25979Generate floating-point instructions. This is the default for 68020
25980and above, and for ColdFire devices that have an FPU@. It defines the
25981macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
25982on ColdFire targets.
25983
25984@item -msoft-float
25985@opindex msoft-float
25986Do not generate floating-point instructions; use library calls instead.
25987This is the default for 68000, 68010, and 68832 targets. It is also
25988the default for ColdFire devices that have no FPU.
25989
25990@item -mdiv
25991@itemx -mno-div
25992@opindex mdiv
25993@opindex mno-div
25994Generate (do not generate) ColdFire hardware divide and remainder
25995instructions. If @option{-march} is used without @option{-mcpu},
25996the default is ``on'' for ColdFire architectures and ``off'' for M680x0
25997architectures. Otherwise, the default is taken from the target CPU
25998(either the default CPU, or the one specified by @option{-mcpu}). For
25999example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26000@option{-mcpu=5206e}.
26001
26002GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26003
26004@item -mshort
26005@opindex mshort
26006Consider type @code{int} to be 16 bits wide, like @code{short int}.
26007Additionally, parameters passed on the stack are also aligned to a
2600816-bit boundary even on targets whose API mandates promotion to 32-bit.
26009
26010@item -mno-short
26011@opindex mno-short
26012Do not consider type @code{int} to be 16 bits wide. This is the default.
26013
26014@item -mnobitfield
26015@itemx -mno-bitfield
26016@opindex mnobitfield
26017@opindex mno-bitfield
26018Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26019and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26020
26021@item -mbitfield
26022@opindex mbitfield
26023Do use the bit-field instructions. The @option{-m68020} option implies
26024@option{-mbitfield}. This is the default if you use a configuration
26025designed for a 68020.
26026
26027@item -mrtd
26028@opindex mrtd
26029Use a different function-calling convention, in which functions
26030that take a fixed number of arguments return with the @code{rtd}
26031instruction, which pops their arguments while returning. This
26032saves one instruction in the caller since there is no need to pop
26033the arguments there.
26034
26035This calling convention is incompatible with the one normally
26036used on Unix, so you cannot use it if you need to call libraries
26037compiled with the Unix compiler.
26038
26039Also, you must provide function prototypes for all functions that
26040take variable numbers of arguments (including @code{printf});
26041otherwise incorrect code is generated for calls to those
26042functions.
26043
26044In addition, seriously incorrect code results if you call a
26045function with too many arguments. (Normally, extra arguments are
26046harmlessly ignored.)
26047
26048The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2604968040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26050
26051The default is @option{-mno-rtd}.
26052
26053@item -malign-int
26054@itemx -mno-align-int
26055@opindex malign-int
26056@opindex mno-align-int
26057Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26058@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26059boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26060Aligning variables on 32-bit boundaries produces code that runs somewhat
26061faster on processors with 32-bit busses at the expense of more memory.
26062
26063@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26064aligns structures containing the above types differently than
26065most published application binary interface specifications for the m68k.
26066
26067@opindex mpcrel
26068Use the pc-relative addressing mode of the 68000 directly, instead of
26069using a global offset table. At present, this option implies @option{-fpic},
26070allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26071not presently supported with @option{-mpcrel}, though this could be supported for
2607268020 and higher processors.
26073
26074@item -mno-strict-align
26075@itemx -mstrict-align
26076@opindex mno-strict-align
26077@opindex mstrict-align
26078Do not (do) assume that unaligned memory references are handled by
26079the system.
26080
26081@item -msep-data
26082Generate code that allows the data segment to be located in a different
26083area of memory from the text segment. This allows for execute-in-place in
26084an environment without virtual memory management. This option implies
26085@option{-fPIC}.
26086
26087@item -mno-sep-data
26088Generate code that assumes that the data segment follows the text segment.
26089This is the default.
26090
26091@item -mid-shared-library
26092Generate code that supports shared libraries via the library ID method.
26093This allows for execute-in-place and shared libraries in an environment
26094without virtual memory management. This option implies @option{-fPIC}.
26095
26096@item -mno-id-shared-library
26097Generate code that doesn't assume ID-based shared libraries are being used.
26098This is the default.
26099
26100@item -mshared-library-id=n
26101Specifies the identification number of the ID-based shared library being
26102compiled. Specifying a value of 0 generates more compact code; specifying
26103other values forces the allocation of that number to the current
26104library, but is no more space- or time-efficient than omitting this option.
26105
26106@item -mxgot
26107@itemx -mno-xgot
26108@opindex mxgot
26109@opindex mno-xgot
26110When generating position-independent code for ColdFire, generate code
26111that works if the GOT has more than 8192 entries. This code is
26112larger and slower than code generated without this option. On M680x0
26113processors, this option is not needed; @option{-fPIC} suffices.
26114
26115GCC normally uses a single instruction to load values from the GOT@.
26116While this is relatively efficient, it only works if the GOT
26117is smaller than about 64k. Anything larger causes the linker
26118to report an error such as:
26119
26120@cindex relocation truncated to fit (ColdFire)
26121@smallexample
26122relocation truncated to fit: R_68K_GOT16O foobar
26123@end smallexample
26124
26125If this happens, you should recompile your code with @option{-mxgot}.
26126It should then work with very large GOTs. However, code generated with
26127@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26128the value of a global symbol.
26129
26130Note that some linkers, including newer versions of the GNU linker,
26131can create multiple GOTs and sort GOT entries. If you have such a linker,
26132you should only need to use @option{-mxgot} when compiling a single
26133object file that accesses more than 8192 GOT entries. Very few do.
26134
26135These options have no effect unless GCC is generating
26136position-independent code.
26137
26138@item -mlong-jump-table-offsets
26139@opindex mlong-jump-table-offsets
26140Use 32-bit offsets in @code{switch} tables. The default is to use
2614116-bit offsets.
26142
26143@end table
26144
26145@node MCore Options
26146@subsection MCore Options
26147@cindex MCore options
26148
26149These are the @samp{-m} options defined for the Motorola M*Core
26150processors.
26151
26152@table @gcctabopt
26153
26154@item -mhardlit
26155@itemx -mno-hardlit
26156@opindex mhardlit
26157@opindex mno-hardlit
26158Inline constants into the code stream if it can be done in two
26159instructions or less.
26160
26161@item -mdiv
26162@itemx -mno-div
26163@opindex mdiv
26164@opindex mno-div
26165Use the divide instruction. (Enabled by default).
26166
26167@item -mrelax-immediate
26168@itemx -mno-relax-immediate
26169@opindex mrelax-immediate
26170@opindex mno-relax-immediate
26171Allow arbitrary-sized immediates in bit operations.
26172
26173@item -mwide-bitfields
26174@itemx -mno-wide-bitfields
26175@opindex mwide-bitfields
26176@opindex mno-wide-bitfields
26177Always treat bit-fields as @code{int}-sized.
26178
26179@item -m4byte-functions
26180@itemx -mno-4byte-functions
26181@opindex m4byte-functions
26182@opindex mno-4byte-functions
26183Force all functions to be aligned to a 4-byte boundary.
26184
26185@item -mcallgraph-data
26186@itemx -mno-callgraph-data
26187@opindex mcallgraph-data
26188@opindex mno-callgraph-data
26189Emit callgraph information.
26190
26191@item -mslow-bytes
26192@itemx -mno-slow-bytes
26193@opindex mslow-bytes
26194@opindex mno-slow-bytes
26195Prefer word access when reading byte quantities.
26196
26197@item -mlittle-endian
26198@itemx -mbig-endian
26199@opindex mlittle-endian
26200@opindex mbig-endian
26201Generate code for a little-endian target.
26202
26203@item -m210
26204@itemx -m340
26205@opindex m210
26206@opindex m340
26207Generate code for the 210 processor.
26208
26209@item -mno-lsim
26210@opindex mno-lsim
26211Assume that runtime support has been provided and so omit the
26212simulator library (@file{libsim.a)} from the linker command line.
26213
26214@item -mstack-increment=@var{size}
26215@opindex mstack-increment
26216Set the maximum amount for a single stack increment operation. Large
26217values can increase the speed of programs that contain functions
26218that need a large amount of stack space, but they can also trigger a
26219segmentation fault if the stack is extended too much. The default
26220value is 0x1000.
26221
26222@end table
26223
d77de738
ML
26224@node MicroBlaze Options
26225@subsection MicroBlaze Options
26226@cindex MicroBlaze Options
26227
26228@table @gcctabopt
26229
26230@item -msoft-float
26231@opindex msoft-float
26232Use software emulation for floating point (default).
26233
26234@item -mhard-float
26235@opindex mhard-float
26236Use hardware floating-point instructions.
26237
26238@item -mmemcpy
26239@opindex mmemcpy
26240Do not optimize block moves, use @code{memcpy}.
26241
26242@item -mno-clearbss
26243@opindex mno-clearbss
26244This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26245
26246@item -mcpu=@var{cpu-type}
26247@opindex mcpu=
26248Use features of, and schedule code for, the given CPU.
26249Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26250where @var{X} is a major version, @var{YY} is the minor version, and
26251@var{Z} is compatibility code. Example values are @samp{v3.00.a},
26252@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26253
26254@item -mxl-soft-mul
26255@opindex mxl-soft-mul
26256Use software multiply emulation (default).
26257
26258@item -mxl-soft-div
26259@opindex mxl-soft-div
26260Use software emulation for divides (default).
26261
26262@item -mxl-barrel-shift
26263@opindex mxl-barrel-shift
26264Use the hardware barrel shifter.
26265
26266@item -mxl-pattern-compare
26267@opindex mxl-pattern-compare
26268Use pattern compare instructions.
26269
26270@item -msmall-divides
26271@opindex msmall-divides
26272Use table lookup optimization for small signed integer divisions.
26273
26274@item -mxl-stack-check
26275@opindex mxl-stack-check
26276This option is deprecated. Use @option{-fstack-check} instead.
26277
26278@item -mxl-gp-opt
26279@opindex mxl-gp-opt
26280Use GP-relative @code{.sdata}/@code{.sbss} sections.
26281
26282@item -mxl-multiply-high
26283@opindex mxl-multiply-high
26284Use multiply high instructions for high part of 32x32 multiply.
26285
26286@item -mxl-float-convert
26287@opindex mxl-float-convert
26288Use hardware floating-point conversion instructions.
26289
26290@item -mxl-float-sqrt
26291@opindex mxl-float-sqrt
26292Use hardware floating-point square root instruction.
26293
26294@item -mbig-endian
26295@opindex mbig-endian
26296Generate code for a big-endian target.
26297
26298@item -mlittle-endian
26299@opindex mlittle-endian
26300Generate code for a little-endian target.
26301
26302@item -mxl-reorder
26303@opindex mxl-reorder
26304Use reorder instructions (swap and byte reversed load/store).
26305
26306@item -mxl-mode-@var{app-model}
26307Select application model @var{app-model}. Valid models are
26308@table @samp
26309@item executable
26310normal executable (default), uses startup code @file{crt0.o}.
26311
26312@item xmdstub
26313for use with Xilinx Microprocessor Debugger (XMD) based
26314software intrusive debug agent called xmdstub. This uses startup file
26315@file{crt1.o} and sets the start address of the program to 0x800.
26316
26317@item bootstrap
26318for applications that are loaded using a bootloader.
26319This model uses startup file @file{crt2.o} which does not contain a processor
26320reset vector handler. This is suitable for transferring control on a
26321processor reset to the bootloader rather than the application.
26322
26323@item novectors
26324for applications that do not require any of the
26325MicroBlaze vectors. This option may be useful for applications running
26326within a monitoring application. This model uses @file{crt3.o} as a startup file.
26327@end table
26328
26329Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26330@option{-mxl-mode-@var{app-model}}.
26331
26332@item -mpic-data-is-text-relative
26333@opindex mpic-data-is-text-relative
26334Assume that the displacement between the text and data segments is fixed
26335at static link time. This allows data to be referenced by offset from start of
26336text address instead of GOT since PC-relative addressing is not supported.
26337
26338@end table
26339
26340@node MIPS Options
26341@subsection MIPS Options
26342@cindex MIPS options
26343
26344@table @gcctabopt
26345
26346@item -EB
26347@opindex EB
26348Generate big-endian code.
26349
26350@item -EL
26351@opindex EL
26352Generate little-endian code. This is the default for @samp{mips*el-*-*}
26353configurations.
26354
26355@item -march=@var{arch}
26356@opindex march
26357Generate code that runs on @var{arch}, which can be the name of a
26358generic MIPS ISA, or the name of a particular processor.
26359The ISA names are:
26360@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26361@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26362@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26363@samp{mips64r5} and @samp{mips64r6}.
26364The processor names are:
26365@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26366@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26367@samp{5kc}, @samp{5kf},
26368@samp{20kc},
26369@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26370@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26371@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26372@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26373@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26374@samp{i6400}, @samp{i6500},
26375@samp{interaptiv},
26376@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
26377@samp{gs464e}, @samp{gs264e},
26378@samp{m4k},
26379@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
26380@samp{m5100}, @samp{m5101},
26381@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
26382@samp{orion},
26383@samp{p5600}, @samp{p6600},
26384@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
26385@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
26386@samp{r6000}, @samp{r8000},
26387@samp{rm7000}, @samp{rm9000},
26388@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
26389@samp{sb1},
26390@samp{sr71000},
26391@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
26392@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
26393@samp{xlr} and @samp{xlp}.
26394The special value @samp{from-abi} selects the
26395most compatible architecture for the selected ABI (that is,
26396@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
26397
26398The native Linux/GNU toolchain also supports the value @samp{native},
26399which selects the best architecture option for the host processor.
26400@option{-march=native} has no effect if GCC does not recognize
26401the processor.
26402
26403In processor names, a final @samp{000} can be abbreviated as @samp{k}
26404(for example, @option{-march=r2k}). Prefixes are optional, and
26405@samp{vr} may be written @samp{r}.
26406
26407Names of the form @samp{@var{n}f2_1} refer to processors with
26408FPUs clocked at half the rate of the core, names of the form
26409@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
26410rate as the core, and names of the form @samp{@var{n}f3_2} refer to
26411processors with FPUs clocked a ratio of 3:2 with respect to the core.
26412For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
26413for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
26414accepted as synonyms for @samp{@var{n}f1_1}.
26415
26416GCC defines two macros based on the value of this option. The first
26417is @code{_MIPS_ARCH}, which gives the name of target architecture, as
26418a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
26419where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
26420For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
26421to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
26422
26423Note that the @code{_MIPS_ARCH} macro uses the processor names given
26424above. In other words, it has the full prefix and does not
26425abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
26426the macro names the resolved architecture (either @code{"mips1"} or
26427@code{"mips3"}). It names the default architecture when no
26428@option{-march} option is given.
26429
26430@item -mtune=@var{arch}
26431@opindex mtune
26432Optimize for @var{arch}. Among other things, this option controls
26433the way instructions are scheduled, and the perceived cost of arithmetic
26434operations. The list of @var{arch} values is the same as for
26435@option{-march}.
26436
26437When this option is not used, GCC optimizes for the processor
26438specified by @option{-march}. By using @option{-march} and
26439@option{-mtune} together, it is possible to generate code that
26440runs on a family of processors, but optimize the code for one
26441particular member of that family.
26442
26443@option{-mtune} defines the macros @code{_MIPS_TUNE} and
26444@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
26445@option{-march} ones described above.
26446
26447@item -mips1
26448@opindex mips1
26449Equivalent to @option{-march=mips1}.
26450
26451@item -mips2
26452@opindex mips2
26453Equivalent to @option{-march=mips2}.
26454
26455@item -mips3
26456@opindex mips3
26457Equivalent to @option{-march=mips3}.
26458
26459@item -mips4
26460@opindex mips4
26461Equivalent to @option{-march=mips4}.
26462
26463@item -mips32
26464@opindex mips32
26465Equivalent to @option{-march=mips32}.
26466
26467@item -mips32r3
26468@opindex mips32r3
26469Equivalent to @option{-march=mips32r3}.
26470
26471@item -mips32r5
26472@opindex mips32r5
26473Equivalent to @option{-march=mips32r5}.
26474
26475@item -mips32r6
26476@opindex mips32r6
26477Equivalent to @option{-march=mips32r6}.
26478
26479@item -mips64
26480@opindex mips64
26481Equivalent to @option{-march=mips64}.
26482
26483@item -mips64r2
26484@opindex mips64r2
26485Equivalent to @option{-march=mips64r2}.
26486
26487@item -mips64r3
26488@opindex mips64r3
26489Equivalent to @option{-march=mips64r3}.
26490
26491@item -mips64r5
26492@opindex mips64r5
26493Equivalent to @option{-march=mips64r5}.
26494
26495@item -mips64r6
26496@opindex mips64r6
26497Equivalent to @option{-march=mips64r6}.
26498
26499@item -mips16
26500@itemx -mno-mips16
26501@opindex mips16
26502@opindex mno-mips16
26503Generate (do not generate) MIPS16 code. If GCC is targeting a
26504MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
26505
26506MIPS16 code generation can also be controlled on a per-function basis
26507by means of @code{mips16} and @code{nomips16} attributes.
26508@xref{Function Attributes}, for more information.
26509
26510@item -mflip-mips16
26511@opindex mflip-mips16
26512Generate MIPS16 code on alternating functions. This option is provided
26513for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
26514not intended for ordinary use in compiling user code.
26515
26516@item -minterlink-compressed
26517@itemx -mno-interlink-compressed
26518@opindex minterlink-compressed
26519@opindex mno-interlink-compressed
26520Require (do not require) that code using the standard (uncompressed) MIPS ISA
26521be link-compatible with MIPS16 and microMIPS code, and vice versa.
26522
26523For example, code using the standard ISA encoding cannot jump directly
26524to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
26525@option{-minterlink-compressed} therefore disables direct jumps unless GCC
26526knows that the target of the jump is not compressed.
26527
26528@item -minterlink-mips16
26529@itemx -mno-interlink-mips16
26530@opindex minterlink-mips16
26531@opindex mno-interlink-mips16
26532Aliases of @option{-minterlink-compressed} and
26533@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
26534and are retained for backwards compatibility.
26535
26536@item -mabi=32
26537@itemx -mabi=o64
26538@itemx -mabi=n32
26539@itemx -mabi=64
26540@itemx -mabi=eabi
26541@opindex mabi=32
26542@opindex mabi=o64
26543@opindex mabi=n32
26544@opindex mabi=64
26545@opindex mabi=eabi
26546Generate code for the given ABI@.
26547
26548Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
26549generates 64-bit code when you select a 64-bit architecture, but you
26550can use @option{-mgp32} to get 32-bit code instead.
26551
26552For information about the O64 ABI, see
26553@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
26554
26555GCC supports a variant of the o32 ABI in which floating-point registers
26556are 64 rather than 32 bits wide. You can select this combination with
26557@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
26558and @code{mfhc1} instructions and is therefore only supported for
26559MIPS32R2, MIPS32R3 and MIPS32R5 processors.
26560
26561The register assignments for arguments and return values remain the
26562same, but each scalar value is passed in a single 64-bit register
26563rather than a pair of 32-bit registers. For example, scalar
26564floating-point values are returned in @samp{$f0} only, not a
26565@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
26566remains the same in that the even-numbered double-precision registers
26567are saved.
26568
26569Two additional variants of the o32 ABI are supported to enable
26570a transition from 32-bit to 64-bit registers. These are FPXX
26571(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
26572The FPXX extension mandates that all code must execute correctly
26573when run using 32-bit or 64-bit registers. The code can be interlinked
26574with either FP32 or FP64, but not both.
26575The FP64A extension is similar to the FP64 extension but forbids the
26576use of odd-numbered single-precision registers. This can be used
26577in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
26578processors and allows both FP32 and FP64A code to interlink and
26579run in the same process without changing FPU modes.
26580
26581@item -mabicalls
26582@itemx -mno-abicalls
26583@opindex mabicalls
26584@opindex mno-abicalls
26585Generate (do not generate) code that is suitable for SVR4-style
26586dynamic objects. @option{-mabicalls} is the default for SVR4-based
26587systems.
26588
26589@item -mshared
26590@itemx -mno-shared
26591Generate (do not generate) code that is fully position-independent,
26592and that can therefore be linked into shared libraries. This option
26593only affects @option{-mabicalls}.
26594
26595All @option{-mabicalls} code has traditionally been position-independent,
26596regardless of options like @option{-fPIC} and @option{-fpic}. However,
26597as an extension, the GNU toolchain allows executables to use absolute
26598accesses for locally-binding symbols. It can also use shorter GP
26599initialization sequences and generate direct calls to locally-defined
26600functions. This mode is selected by @option{-mno-shared}.
26601
26602@option{-mno-shared} depends on binutils 2.16 or higher and generates
26603objects that can only be linked by the GNU linker. However, the option
26604does not affect the ABI of the final executable; it only affects the ABI
26605of relocatable objects. Using @option{-mno-shared} generally makes
26606executables both smaller and quicker.
26607
26608@option{-mshared} is the default.
26609
26610@item -mplt
26611@itemx -mno-plt
26612@opindex mplt
26613@opindex mno-plt
26614Assume (do not assume) that the static and dynamic linkers
26615support PLTs and copy relocations. This option only affects
26616@option{-mno-shared -mabicalls}. For the n64 ABI, this option
26617has no effect without @option{-msym32}.
26618
26619You can make @option{-mplt} the default by configuring
26620GCC with @option{--with-mips-plt}. The default is
26621@option{-mno-plt} otherwise.
26622
26623@item -mxgot
26624@itemx -mno-xgot
26625@opindex mxgot
26626@opindex mno-xgot
26627Lift (do not lift) the usual restrictions on the size of the global
26628offset table.
26629
26630GCC normally uses a single instruction to load values from the GOT@.
26631While this is relatively efficient, it only works if the GOT
26632is smaller than about 64k. Anything larger causes the linker
26633to report an error such as:
26634
26635@cindex relocation truncated to fit (MIPS)
26636@smallexample
26637relocation truncated to fit: R_MIPS_GOT16 foobar
26638@end smallexample
26639
26640If this happens, you should recompile your code with @option{-mxgot}.
26641This works with very large GOTs, although the code is also
26642less efficient, since it takes three instructions to fetch the
26643value of a global symbol.
26644
26645Note that some linkers can create multiple GOTs. If you have such a
26646linker, you should only need to use @option{-mxgot} when a single object
26647file accesses more than 64k's worth of GOT entries. Very few do.
26648
26649These options have no effect unless GCC is generating position
26650independent code.
26651
26652@item -mgp32
26653@opindex mgp32
26654Assume that general-purpose registers are 32 bits wide.
26655
26656@item -mgp64
26657@opindex mgp64
26658Assume that general-purpose registers are 64 bits wide.
26659
26660@item -mfp32
26661@opindex mfp32
26662Assume that floating-point registers are 32 bits wide.
26663
26664@item -mfp64
26665@opindex mfp64
26666Assume that floating-point registers are 64 bits wide.
26667
26668@item -mfpxx
26669@opindex mfpxx
26670Do not assume the width of floating-point registers.
26671
26672@item -mhard-float
26673@opindex mhard-float
26674Use floating-point coprocessor instructions.
26675
26676@item -msoft-float
26677@opindex msoft-float
26678Do not use floating-point coprocessor instructions. Implement
26679floating-point calculations using library calls instead.
26680
26681@item -mno-float
26682@opindex mno-float
26683Equivalent to @option{-msoft-float}, but additionally asserts that the
26684program being compiled does not perform any floating-point operations.
26685This option is presently supported only by some bare-metal MIPS
26686configurations, where it may select a special set of libraries
26687that lack all floating-point support (including, for example, the
26688floating-point @code{printf} formats).
26689If code compiled with @option{-mno-float} accidentally contains
26690floating-point operations, it is likely to suffer a link-time
26691or run-time failure.
26692
26693@item -msingle-float
26694@opindex msingle-float
26695Assume that the floating-point coprocessor only supports single-precision
26696operations.
26697
26698@item -mdouble-float
26699@opindex mdouble-float
26700Assume that the floating-point coprocessor supports double-precision
26701operations. This is the default.
26702
26703@item -modd-spreg
26704@itemx -mno-odd-spreg
26705@opindex modd-spreg
26706@opindex mno-odd-spreg
26707Enable the use of odd-numbered single-precision floating-point registers
26708for the o32 ABI. This is the default for processors that are known to
26709support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
26710is set by default.
26711
26712@item -mabs=2008
26713@itemx -mabs=legacy
26714@opindex mabs=2008
26715@opindex mabs=legacy
26716These options control the treatment of the special not-a-number (NaN)
26717IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
26718@code{neg.@i{fmt}} machine instructions.
26719
26720By default or when @option{-mabs=legacy} is used the legacy
26721treatment is selected. In this case these instructions are considered
26722arithmetic and avoided where correct operation is required and the
26723input operand might be a NaN. A longer sequence of instructions that
26724manipulate the sign bit of floating-point datum manually is used
26725instead unless the @option{-ffinite-math-only} option has also been
26726specified.
26727
26728The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
26729this case these instructions are considered non-arithmetic and therefore
26730operating correctly in all cases, including in particular where the
26731input operand is a NaN. These instructions are therefore always used
26732for the respective operations.
26733
26734@item -mnan=2008
26735@itemx -mnan=legacy
26736@opindex mnan=2008
26737@opindex mnan=legacy
26738These options control the encoding of the special not-a-number (NaN)
26739IEEE 754 floating-point data.
26740
26741The @option{-mnan=legacy} option selects the legacy encoding. In this
26742case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
26743significand field being 0, whereas signaling NaNs (sNaNs) are denoted
26744by the first bit of their trailing significand field being 1.
26745
26746The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
26747this case qNaNs are denoted by the first bit of their trailing
26748significand field being 1, whereas sNaNs are denoted by the first bit of
26749their trailing significand field being 0.
26750
26751The default is @option{-mnan=legacy} unless GCC has been configured with
26752@option{--with-nan=2008}.
26753
26754@item -mllsc
26755@itemx -mno-llsc
26756@opindex mllsc
26757@opindex mno-llsc
26758Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
26759implement atomic memory built-in functions. When neither option is
26760specified, GCC uses the instructions if the target architecture
26761supports them.
26762
26763@option{-mllsc} is useful if the runtime environment can emulate the
26764instructions and @option{-mno-llsc} can be useful when compiling for
26765nonstandard ISAs. You can make either option the default by
26766configuring GCC with @option{--with-llsc} and @option{--without-llsc}
26767respectively. @option{--with-llsc} is the default for some
26768configurations; see the installation documentation for details.
26769
26770@item -mdsp
26771@itemx -mno-dsp
26772@opindex mdsp
26773@opindex mno-dsp
26774Use (do not use) revision 1 of the MIPS DSP ASE@.
26775@xref{MIPS DSP Built-in Functions}. This option defines the
26776preprocessor macro @code{__mips_dsp}. It also defines
26777@code{__mips_dsp_rev} to 1.
26778
26779@item -mdspr2
26780@itemx -mno-dspr2
26781@opindex mdspr2
26782@opindex mno-dspr2
26783Use (do not use) revision 2 of the MIPS DSP ASE@.
26784@xref{MIPS DSP Built-in Functions}. This option defines the
26785preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
26786It also defines @code{__mips_dsp_rev} to 2.
26787
26788@item -msmartmips
26789@itemx -mno-smartmips
26790@opindex msmartmips
26791@opindex mno-smartmips
26792Use (do not use) the MIPS SmartMIPS ASE.
26793
26794@item -mpaired-single
26795@itemx -mno-paired-single
26796@opindex mpaired-single
26797@opindex mno-paired-single
26798Use (do not use) paired-single floating-point instructions.
26799@xref{MIPS Paired-Single Support}. This option requires
26800hardware floating-point support to be enabled.
26801
26802@item -mdmx
26803@itemx -mno-mdmx
26804@opindex mdmx
26805@opindex mno-mdmx
26806Use (do not use) MIPS Digital Media Extension instructions.
26807This option can only be used when generating 64-bit code and requires
26808hardware floating-point support to be enabled.
26809
26810@item -mips3d
26811@itemx -mno-mips3d
26812@opindex mips3d
26813@opindex mno-mips3d
26814Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
26815The option @option{-mips3d} implies @option{-mpaired-single}.
26816
26817@item -mmicromips
26818@itemx -mno-micromips
26819@opindex mmicromips
26820@opindex mno-mmicromips
26821Generate (do not generate) microMIPS code.
26822
26823MicroMIPS code generation can also be controlled on a per-function basis
26824by means of @code{micromips} and @code{nomicromips} attributes.
26825@xref{Function Attributes}, for more information.
26826
26827@item -mmt
26828@itemx -mno-mt
26829@opindex mmt
26830@opindex mno-mt
26831Use (do not use) MT Multithreading instructions.
26832
26833@item -mmcu
26834@itemx -mno-mcu
26835@opindex mmcu
26836@opindex mno-mcu
26837Use (do not use) the MIPS MCU ASE instructions.
26838
26839@item -meva
26840@itemx -mno-eva
26841@opindex meva
26842@opindex mno-eva
26843Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
26844
26845@item -mvirt
26846@itemx -mno-virt
26847@opindex mvirt
26848@opindex mno-virt
26849Use (do not use) the MIPS Virtualization (VZ) instructions.
26850
26851@item -mxpa
26852@itemx -mno-xpa
26853@opindex mxpa
26854@opindex mno-xpa
26855Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
26856
26857@item -mcrc
26858@itemx -mno-crc
26859@opindex mcrc
26860@opindex mno-crc
26861Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
26862
26863@item -mginv
26864@itemx -mno-ginv
26865@opindex mginv
26866@opindex mno-ginv
26867Use (do not use) the MIPS Global INValidate (GINV) instructions.
26868
26869@item -mloongson-mmi
26870@itemx -mno-loongson-mmi
26871@opindex mloongson-mmi
26872@opindex mno-loongson-mmi
26873Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
26874
26875@item -mloongson-ext
26876@itemx -mno-loongson-ext
26877@opindex mloongson-ext
26878@opindex mno-loongson-ext
26879Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
26880
26881@item -mloongson-ext2
26882@itemx -mno-loongson-ext2
26883@opindex mloongson-ext2
26884@opindex mno-loongson-ext2
26885Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
26886
26887@item -mlong64
26888@opindex mlong64
26889Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
26890an explanation of the default and the way that the pointer size is
26891determined.
26892
26893@item -mlong32
26894@opindex mlong32
26895Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
26896
26897The default size of @code{int}s, @code{long}s and pointers depends on
26898the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
26899uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2690032-bit @code{long}s. Pointers are the same size as @code{long}s,
26901or the same size as integer registers, whichever is smaller.
26902
26903@item -msym32
26904@itemx -mno-sym32
26905@opindex msym32
26906@opindex mno-sym32
26907Assume (do not assume) that all symbols have 32-bit values, regardless
26908of the selected ABI@. This option is useful in combination with
26909@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
26910to generate shorter and faster references to symbolic addresses.
26911
26912@item -G @var{num}
26913@opindex G
26914Put definitions of externally-visible data in a small data section
26915if that data is no bigger than @var{num} bytes. GCC can then generate
26916more efficient accesses to the data; see @option{-mgpopt} for details.
26917
26918The default @option{-G} option depends on the configuration.
26919
26920@item -mlocal-sdata
26921@itemx -mno-local-sdata
26922@opindex mlocal-sdata
26923@opindex mno-local-sdata
26924Extend (do not extend) the @option{-G} behavior to local data too,
26925such as to static variables in C@. @option{-mlocal-sdata} is the
26926default for all configurations.
26927
26928If the linker complains that an application is using too much small data,
26929you might want to try rebuilding the less performance-critical parts with
26930@option{-mno-local-sdata}. You might also want to build large
26931libraries with @option{-mno-local-sdata}, so that the libraries leave
26932more room for the main program.
26933
26934@item -mextern-sdata
26935@itemx -mno-extern-sdata
26936@opindex mextern-sdata
26937@opindex mno-extern-sdata
26938Assume (do not assume) that externally-defined data is in
26939a small data section if the size of that data is within the @option{-G} limit.
26940@option{-mextern-sdata} is the default for all configurations.
26941
26942If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
26943@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
26944that is no bigger than @var{num} bytes, you must make sure that @var{Var}
26945is placed in a small data section. If @var{Var} is defined by another
26946module, you must either compile that module with a high-enough
26947@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
26948definition. If @var{Var} is common, you must link the application
26949with a high-enough @option{-G} setting.
26950
26951The easiest way of satisfying these restrictions is to compile
26952and link every module with the same @option{-G} option. However,
26953you may wish to build a library that supports several different
26954small data limits. You can do this by compiling the library with
26955the highest supported @option{-G} setting and additionally using
26956@option{-mno-extern-sdata} to stop the library from making assumptions
26957about externally-defined data.
26958
26959@item -mgpopt
26960@itemx -mno-gpopt
26961@opindex mgpopt
26962@opindex mno-gpopt
26963Use (do not use) GP-relative accesses for symbols that are known to be
26964in a small data section; see @option{-G}, @option{-mlocal-sdata} and
26965@option{-mextern-sdata}. @option{-mgpopt} is the default for all
26966configurations.
26967
26968@option{-mno-gpopt} is useful for cases where the @code{$gp} register
26969might not hold the value of @code{_gp}. For example, if the code is
26970part of a library that might be used in a boot monitor, programs that
26971call boot monitor routines pass an unknown value in @code{$gp}.
26972(In such situations, the boot monitor itself is usually compiled
26973with @option{-G0}.)
26974
26975@option{-mno-gpopt} implies @option{-mno-local-sdata} and
26976@option{-mno-extern-sdata}.
26977
26978@item -membedded-data
26979@itemx -mno-embedded-data
26980@opindex membedded-data
26981@opindex mno-embedded-data
26982Allocate variables to the read-only data section first if possible, then
26983next in the small data section if possible, otherwise in data. This gives
26984slightly slower code than the default, but reduces the amount of RAM required
26985when executing, and thus may be preferred for some embedded systems.
26986
26987@item -muninit-const-in-rodata
26988@itemx -mno-uninit-const-in-rodata
26989@opindex muninit-const-in-rodata
26990@opindex mno-uninit-const-in-rodata
26991Put uninitialized @code{const} variables in the read-only data section.
26992This option is only meaningful in conjunction with @option{-membedded-data}.
26993
26994@item -mcode-readable=@var{setting}
26995@opindex mcode-readable
26996Specify whether GCC may generate code that reads from executable sections.
26997There are three possible settings:
26998
26999@table @gcctabopt
27000@item -mcode-readable=yes
27001Instructions may freely access executable sections. This is the
27002default setting.
27003
27004@item -mcode-readable=pcrel
27005MIPS16 PC-relative load instructions can access executable sections,
27006but other instructions must not do so. This option is useful on 4KSc
27007and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27008It is also useful on processors that can be configured to have a dual
27009instruction/data SRAM interface and that, like the M4K, automatically
27010redirect PC-relative loads to the instruction RAM.
27011
27012@item -mcode-readable=no
27013Instructions must not access executable sections. This option can be
27014useful on targets that are configured to have a dual instruction/data
27015SRAM interface but that (unlike the M4K) do not automatically redirect
27016PC-relative loads to the instruction RAM.
27017@end table
27018
27019@item -msplit-addresses
27020@itemx -mno-split-addresses
27021@opindex msplit-addresses
27022@opindex mno-split-addresses
27023Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27024relocation operators. This option has been superseded by
27025@option{-mexplicit-relocs} but is retained for backwards compatibility.
27026
27027@item -mexplicit-relocs
27028@itemx -mno-explicit-relocs
27029@opindex mexplicit-relocs
27030@opindex mno-explicit-relocs
27031Use (do not use) assembler relocation operators when dealing with symbolic
27032addresses. The alternative, selected by @option{-mno-explicit-relocs},
27033is to use assembler macros instead.
27034
27035@option{-mexplicit-relocs} is the default if GCC was configured
27036to use an assembler that supports relocation operators.
27037
27038@item -mcheck-zero-division
27039@itemx -mno-check-zero-division
27040@opindex mcheck-zero-division
27041@opindex mno-check-zero-division
27042Trap (do not trap) on integer division by zero.
27043
27044The default is @option{-mcheck-zero-division}.
27045
27046@item -mdivide-traps
27047@itemx -mdivide-breaks
27048@opindex mdivide-traps
27049@opindex mdivide-breaks
27050MIPS systems check for division by zero by generating either a
27051conditional trap or a break instruction. Using traps results in
27052smaller code, but is only supported on MIPS II and later. Also, some
27053versions of the Linux kernel have a bug that prevents trap from
27054generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27055allow conditional traps on architectures that support them and
27056@option{-mdivide-breaks} to force the use of breaks.
27057
27058The default is usually @option{-mdivide-traps}, but this can be
27059overridden at configure time using @option{--with-divide=breaks}.
27060Divide-by-zero checks can be completely disabled using
27061@option{-mno-check-zero-division}.
27062
27063@item -mload-store-pairs
27064@itemx -mno-load-store-pairs
27065@opindex mload-store-pairs
27066@opindex mno-load-store-pairs
27067Enable (disable) an optimization that pairs consecutive load or store
27068instructions to enable load/store bonding. This option is enabled by
27069default but only takes effect when the selected architecture is known
27070to support bonding.
27071
27072@item -munaligned-access
27073@itemx -mno-unaligned-access
27074@opindex munaligned-access
27075@opindex mno-unaligned-access
27076Enable (disable) direct unaligned access for MIPS Release 6.
27077MIPSr6 requires load/store unaligned-access support,
27078by hardware or trap&emulate.
27079So @option{-mno-unaligned-access} may be needed by kernel.
27080
27081@item -mmemcpy
27082@itemx -mno-memcpy
27083@opindex mmemcpy
27084@opindex mno-memcpy
27085Force (do not force) the use of @code{memcpy} for non-trivial block
27086moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27087most constant-sized copies.
27088
27089@item -mlong-calls
27090@itemx -mno-long-calls
27091@opindex mlong-calls
27092@opindex mno-long-calls
27093Disable (do not disable) use of the @code{jal} instruction. Calling
27094functions using @code{jal} is more efficient but requires the caller
27095and callee to be in the same 256 megabyte segment.
27096
27097This option has no effect on abicalls code. The default is
27098@option{-mno-long-calls}.
27099
27100@item -mmad
27101@itemx -mno-mad
27102@opindex mmad
27103@opindex mno-mad
27104Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27105instructions, as provided by the R4650 ISA@.
27106
27107@item -mimadd
27108@itemx -mno-imadd
27109@opindex mimadd
27110@opindex mno-imadd
27111Enable (disable) use of the @code{madd} and @code{msub} integer
27112instructions. The default is @option{-mimadd} on architectures
27113that support @code{madd} and @code{msub} except for the 74k
27114architecture where it was found to generate slower code.
27115
27116@item -mfused-madd
27117@itemx -mno-fused-madd
27118@opindex mfused-madd
27119@opindex mno-fused-madd
27120Enable (disable) use of the floating-point multiply-accumulate
27121instructions, when they are available. The default is
27122@option{-mfused-madd}.
27123
27124On the R8000 CPU when multiply-accumulate instructions are used,
27125the intermediate product is calculated to infinite precision
27126and is not subject to the FCSR Flush to Zero bit. This may be
27127undesirable in some circumstances. On other processors the result
27128is numerically identical to the equivalent computation using
27129separate multiply, add, subtract and negate instructions.
27130
27131@item -nocpp
27132@opindex nocpp
27133Tell the MIPS assembler to not run its preprocessor over user
27134assembler files (with a @samp{.s} suffix) when assembling them.
27135
27136@item -mfix-24k
27137@itemx -mno-fix-24k
27138@opindex mfix-24k
27139@opindex mno-fix-24k
27140Work around the 24K E48 (lost data on stores during refill) errata.
27141The workarounds are implemented by the assembler rather than by GCC@.
27142
27143@item -mfix-r4000
27144@itemx -mno-fix-r4000
27145@opindex mfix-r4000
27146@opindex mno-fix-r4000
27147Work around certain R4000 CPU errata:
27148@itemize @minus
27149@item
27150A double-word or a variable shift may give an incorrect result if executed
27151immediately after starting an integer division.
27152@item
27153A double-word or a variable shift may give an incorrect result if executed
27154while an integer multiplication is in progress.
27155@item
27156An integer division may give an incorrect result if started in a delay slot
27157of a taken branch or a jump.
27158@end itemize
27159
27160@item -mfix-r4400
27161@itemx -mno-fix-r4400
27162@opindex mfix-r4400
27163@opindex mno-fix-r4400
27164Work around certain R4400 CPU errata:
27165@itemize @minus
27166@item
27167A double-word or a variable shift may give an incorrect result if executed
27168immediately after starting an integer division.
27169@end itemize
27170
27171@item -mfix-r10000
27172@itemx -mno-fix-r10000
27173@opindex mfix-r10000
27174@opindex mno-fix-r10000
27175Work around certain R10000 errata:
27176@itemize @minus
27177@item
27178@code{ll}/@code{sc} sequences may not behave atomically on revisions
27179prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27180@end itemize
27181
27182This option can only be used if the target architecture supports
27183branch-likely instructions. @option{-mfix-r10000} is the default when
27184@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27185otherwise.
27186
27187@item -mfix-r5900
27188@itemx -mno-fix-r5900
27189@opindex mfix-r5900
27190Do not attempt to schedule the preceding instruction into the delay slot
27191of a branch instruction placed at the end of a short loop of six
27192instructions or fewer and always schedule a @code{nop} instruction there
27193instead. The short loop bug under certain conditions causes loops to
27194execute only once or twice, due to a hardware bug in the R5900 chip. The
27195workaround is implemented by the assembler rather than by GCC@.
27196
27197@item -mfix-rm7000
27198@itemx -mno-fix-rm7000
27199@opindex mfix-rm7000
27200Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27201workarounds are implemented by the assembler rather than by GCC@.
27202
27203@item -mfix-vr4120
27204@itemx -mno-fix-vr4120
27205@opindex mfix-vr4120
27206Work around certain VR4120 errata:
27207@itemize @minus
27208@item
27209@code{dmultu} does not always produce the correct result.
27210@item
27211@code{div} and @code{ddiv} do not always produce the correct result if one
27212of the operands is negative.
27213@end itemize
27214The workarounds for the division errata rely on special functions in
27215@file{libgcc.a}. At present, these functions are only provided by
27216the @code{mips64vr*-elf} configurations.
27217
27218Other VR4120 errata require a NOP to be inserted between certain pairs of
27219instructions. These errata are handled by the assembler, not by GCC itself.
27220
27221@item -mfix-vr4130
27222@opindex mfix-vr4130
27223Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27224workarounds are implemented by the assembler rather than by GCC,
27225although GCC avoids using @code{mflo} and @code{mfhi} if the
27226VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27227instructions are available instead.
27228
27229@item -mfix-sb1
27230@itemx -mno-fix-sb1
27231@opindex mfix-sb1
27232Work around certain SB-1 CPU core errata.
27233(This flag currently works around the SB-1 revision 2
27234``F1'' and ``F2'' floating-point errata.)
27235
27236@item -mr10k-cache-barrier=@var{setting}
27237@opindex mr10k-cache-barrier
27238Specify whether GCC should insert cache barriers to avoid the
27239side effects of speculation on R10K processors.
27240
27241In common with many processors, the R10K tries to predict the outcome
27242of a conditional branch and speculatively executes instructions from
27243the ``taken'' branch. It later aborts these instructions if the
27244predicted outcome is wrong. However, on the R10K, even aborted
27245instructions can have side effects.
27246
27247This problem only affects kernel stores and, depending on the system,
27248kernel loads. As an example, a speculatively-executed store may load
27249the target memory into cache and mark the cache line as dirty, even if
27250the store itself is later aborted. If a DMA operation writes to the
27251same area of memory before the ``dirty'' line is flushed, the cached
27252data overwrites the DMA-ed data. See the R10K processor manual
27253for a full description, including other potential problems.
27254
27255One workaround is to insert cache barrier instructions before every memory
27256access that might be speculatively executed and that might have side
27257effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27258controls GCC's implementation of this workaround. It assumes that
27259aborted accesses to any byte in the following regions does not have
27260side effects:
27261
27262@enumerate
27263@item
27264the memory occupied by the current function's stack frame;
27265
27266@item
27267the memory occupied by an incoming stack argument;
27268
27269@item
27270the memory occupied by an object with a link-time-constant address.
27271@end enumerate
27272
27273It is the kernel's responsibility to ensure that speculative
27274accesses to these regions are indeed safe.
27275
27276If the input program contains a function declaration such as:
27277
27278@smallexample
27279void foo (void);
27280@end smallexample
27281
27282then the implementation of @code{foo} must allow @code{j foo} and
27283@code{jal foo} to be executed speculatively. GCC honors this
27284restriction for functions it compiles itself. It expects non-GCC
27285functions (such as hand-written assembly code) to do the same.
27286
27287The option has three forms:
27288
27289@table @gcctabopt
27290@item -mr10k-cache-barrier=load-store
27291Insert a cache barrier before a load or store that might be
27292speculatively executed and that might have side effects even
27293if aborted.
27294
27295@item -mr10k-cache-barrier=store
27296Insert a cache barrier before a store that might be speculatively
27297executed and that might have side effects even if aborted.
27298
27299@item -mr10k-cache-barrier=none
27300Disable the insertion of cache barriers. This is the default setting.
27301@end table
27302
27303@item -mflush-func=@var{func}
27304@itemx -mno-flush-func
27305@opindex mflush-func
27306Specifies the function to call to flush the I and D caches, or to not
27307call any such function. If called, the function must take the same
27308arguments as the common @code{_flush_func}, that is, the address of the
27309memory range for which the cache is being flushed, the size of the
27310memory range, and the number 3 (to flush both caches). The default
27311depends on the target GCC was configured for, but commonly is either
27312@code{_flush_func} or @code{__cpu_flush}.
27313
27314@item mbranch-cost=@var{num}
27315@opindex mbranch-cost
27316Set the cost of branches to roughly @var{num} ``simple'' instructions.
27317This cost is only a heuristic and is not guaranteed to produce
27318consistent results across releases. A zero cost redundantly selects
27319the default, which is based on the @option{-mtune} setting.
27320
27321@item -mbranch-likely
27322@itemx -mno-branch-likely
27323@opindex mbranch-likely
27324@opindex mno-branch-likely
27325Enable or disable use of Branch Likely instructions, regardless of the
27326default for the selected architecture. By default, Branch Likely
27327instructions may be generated if they are supported by the selected
27328architecture. An exception is for the MIPS32 and MIPS64 architectures
27329and processors that implement those architectures; for those, Branch
27330Likely instructions are not be generated by default because the MIPS32
27331and MIPS64 architectures specifically deprecate their use.
27332
27333@item -mcompact-branches=never
27334@itemx -mcompact-branches=optimal
27335@itemx -mcompact-branches=always
27336@opindex mcompact-branches=never
27337@opindex mcompact-branches=optimal
27338@opindex mcompact-branches=always
27339These options control which form of branches will be generated. The
27340default is @option{-mcompact-branches=optimal}.
27341
27342The @option{-mcompact-branches=never} option ensures that compact branch
27343instructions will never be generated.
27344
27345The @option{-mcompact-branches=always} option ensures that a compact
27346branch instruction will be generated if available for MIPS Release 6 onwards.
27347If a compact branch instruction is not available (or pre-R6),
27348a delay slot form of the branch will be used instead.
27349
27350If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27351The behaviour for MIPS16/microMIPS may change in future,
27352since they do have some compact branch instructions.
27353
27354The @option{-mcompact-branches=optimal} option will cause a delay slot
27355branch to be used if one is available in the current ISA and the delay
27356slot is successfully filled. If the delay slot is not filled, a compact
27357branch will be chosen if one is available.
27358
27359@item -mfp-exceptions
27360@itemx -mno-fp-exceptions
27361@opindex mfp-exceptions
27362Specifies whether FP exceptions are enabled. This affects how
27363FP instructions are scheduled for some processors.
27364The default is that FP exceptions are
27365enabled.
27366
27367For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2736864-bit code, then we can use both FP pipes. Otherwise, we can only use one
27369FP pipe.
27370
27371@item -mvr4130-align
27372@itemx -mno-vr4130-align
27373@opindex mvr4130-align
27374The VR4130 pipeline is two-way superscalar, but can only issue two
27375instructions together if the first one is 8-byte aligned. When this
27376option is enabled, GCC aligns pairs of instructions that it
27377thinks should execute in parallel.
27378
27379This option only has an effect when optimizing for the VR4130.
27380It normally makes code faster, but at the expense of making it bigger.
27381It is enabled by default at optimization level @option{-O3}.
27382
27383@item -msynci
27384@itemx -mno-synci
27385@opindex msynci
27386Enable (disable) generation of @code{synci} instructions on
27387architectures that support it. The @code{synci} instructions (if
27388enabled) are generated when @code{__builtin___clear_cache} is
27389compiled.
27390
27391This option defaults to @option{-mno-synci}, but the default can be
27392overridden by configuring GCC with @option{--with-synci}.
27393
27394When compiling code for single processor systems, it is generally safe
27395to use @code{synci}. However, on many multi-core (SMP) systems, it
27396does not invalidate the instruction caches on all cores and may lead
27397to undefined behavior.
27398
27399@item -mrelax-pic-calls
27400@itemx -mno-relax-pic-calls
27401@opindex mrelax-pic-calls
27402Try to turn PIC calls that are normally dispatched via register
27403@code{$25} into direct calls. This is only possible if the linker can
27404resolve the destination at link time and if the destination is within
27405range for a direct call.
27406
27407@option{-mrelax-pic-calls} is the default if GCC was configured to use
27408an assembler and a linker that support the @code{.reloc} assembly
27409directive and @option{-mexplicit-relocs} is in effect. With
27410@option{-mno-explicit-relocs}, this optimization can be performed by the
27411assembler and the linker alone without help from the compiler.
27412
27413@item -mmcount-ra-address
27414@itemx -mno-mcount-ra-address
27415@opindex mmcount-ra-address
27416@opindex mno-mcount-ra-address
27417Emit (do not emit) code that allows @code{_mcount} to modify the
27418calling function's return address. When enabled, this option extends
27419the usual @code{_mcount} interface with a new @var{ra-address}
27420parameter, which has type @code{intptr_t *} and is passed in register
27421@code{$12}. @code{_mcount} can then modify the return address by
27422doing both of the following:
27423@itemize
27424@item
27425Returning the new address in register @code{$31}.
27426@item
27427Storing the new address in @code{*@var{ra-address}},
27428if @var{ra-address} is nonnull.
27429@end itemize
27430
27431The default is @option{-mno-mcount-ra-address}.
27432
27433@item -mframe-header-opt
27434@itemx -mno-frame-header-opt
27435@opindex mframe-header-opt
27436Enable (disable) frame header optimization in the o32 ABI. When using the
27437o32 ABI, calling functions will allocate 16 bytes on the stack for the called
27438function to write out register arguments. When enabled, this optimization
27439will suppress the allocation of the frame header if it can be determined that
27440it is unused.
27441
27442This optimization is off by default at all optimization levels.
27443
27444@item -mlxc1-sxc1
27445@itemx -mno-lxc1-sxc1
27446@opindex mlxc1-sxc1
27447When applicable, enable (disable) the generation of @code{lwxc1},
27448@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
27449
27450@item -mmadd4
27451@itemx -mno-madd4
27452@opindex mmadd4
27453When applicable, enable (disable) the generation of 4-operand @code{madd.s},
27454@code{madd.d} and related instructions. Enabled by default.
27455
27456@end table
27457
27458@node MMIX Options
27459@subsection MMIX Options
27460@cindex MMIX Options
27461
27462These options are defined for the MMIX:
27463
27464@table @gcctabopt
27465@item -mlibfuncs
27466@itemx -mno-libfuncs
27467@opindex mlibfuncs
27468@opindex mno-libfuncs
27469Specify that intrinsic library functions are being compiled, passing all
27470values in registers, no matter the size.
27471
27472@item -mepsilon
27473@itemx -mno-epsilon
27474@opindex mepsilon
27475@opindex mno-epsilon
27476Generate floating-point comparison instructions that compare with respect
27477to the @code{rE} epsilon register.
27478
27479@item -mabi=mmixware
27480@itemx -mabi=gnu
27481@opindex mabi=mmixware
27482@opindex mabi=gnu
27483Generate code that passes function parameters and return values that (in
27484the called function) are seen as registers @code{$0} and up, as opposed to
27485the GNU ABI which uses global registers @code{$231} and up.
27486
27487@item -mzero-extend
27488@itemx -mno-zero-extend
27489@opindex mzero-extend
27490@opindex mno-zero-extend
27491When reading data from memory in sizes shorter than 64 bits, use (do not
27492use) zero-extending load instructions by default, rather than
27493sign-extending ones.
27494
27495@item -mknuthdiv
27496@itemx -mno-knuthdiv
27497@opindex mknuthdiv
27498@opindex mno-knuthdiv
27499Make the result of a division yielding a remainder have the same sign as
27500the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
27501remainder follows the sign of the dividend. Both methods are
27502arithmetically valid, the latter being almost exclusively used.
27503
27504@item -mtoplevel-symbols
27505@itemx -mno-toplevel-symbols
27506@opindex mtoplevel-symbols
27507@opindex mno-toplevel-symbols
27508Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
27509code can be used with the @code{PREFIX} assembly directive.
27510
27511@item -melf
27512@opindex melf
27513Generate an executable in the ELF format, rather than the default
27514@samp{mmo} format used by the @command{mmix} simulator.
27515
27516@item -mbranch-predict
27517@itemx -mno-branch-predict
27518@opindex mbranch-predict
27519@opindex mno-branch-predict
27520Use (do not use) the probable-branch instructions, when static branch
27521prediction indicates a probable branch.
27522
27523@item -mbase-addresses
27524@itemx -mno-base-addresses
27525@opindex mbase-addresses
27526@opindex mno-base-addresses
27527Generate (do not generate) code that uses @emph{base addresses}. Using a
27528base address automatically generates a request (handled by the assembler
27529and the linker) for a constant to be set up in a global register. The
27530register is used for one or more base address requests within the range 0
27531to 255 from the value held in the register. The generally leads to short
27532and fast code, but the number of different data items that can be
27533addressed is limited. This means that a program that uses lots of static
27534data may require @option{-mno-base-addresses}.
27535
27536@item -msingle-exit
27537@itemx -mno-single-exit
27538@opindex msingle-exit
27539@opindex mno-single-exit
27540Force (do not force) generated code to have a single exit point in each
27541function.
27542@end table
27543
27544@node MN10300 Options
27545@subsection MN10300 Options
27546@cindex MN10300 options
27547
27548These @option{-m} options are defined for Matsushita MN10300 architectures:
27549
27550@table @gcctabopt
27551@item -mmult-bug
27552@opindex mmult-bug
27553Generate code to avoid bugs in the multiply instructions for the MN10300
27554processors. This is the default.
27555
27556@item -mno-mult-bug
27557@opindex mno-mult-bug
27558Do not generate code to avoid bugs in the multiply instructions for the
27559MN10300 processors.
27560
27561@item -mam33
27562@opindex mam33
27563Generate code using features specific to the AM33 processor.
27564
27565@item -mno-am33
27566@opindex mno-am33
27567Do not generate code using features specific to the AM33 processor. This
27568is the default.
27569
27570@item -mam33-2
27571@opindex mam33-2
27572Generate code using features specific to the AM33/2.0 processor.
27573
27574@item -mam34
27575@opindex mam34
27576Generate code using features specific to the AM34 processor.
27577
27578@item -mtune=@var{cpu-type}
27579@opindex mtune
27580Use the timing characteristics of the indicated CPU type when
27581scheduling instructions. This does not change the targeted processor
27582type. The CPU type must be one of @samp{mn10300}, @samp{am33},
27583@samp{am33-2} or @samp{am34}.
27584
27585@item -mreturn-pointer-on-d0
27586@opindex mreturn-pointer-on-d0
27587When generating a function that returns a pointer, return the pointer
27588in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
27589only in @code{a0}, and attempts to call such functions without a prototype
27590result in errors. Note that this option is on by default; use
27591@option{-mno-return-pointer-on-d0} to disable it.
27592
27593@item -mno-crt0
27594@opindex mno-crt0
27595Do not link in the C run-time initialization object file.
27596
27597@item -mrelax
27598@opindex mrelax
27599Indicate to the linker that it should perform a relaxation optimization pass
27600to shorten branches, calls and absolute memory addresses. This option only
27601has an effect when used on the command line for the final link step.
27602
27603This option makes symbolic debugging impossible.
27604
27605@item -mliw
27606@opindex mliw
27607Allow the compiler to generate @emph{Long Instruction Word}
27608instructions if the target is the @samp{AM33} or later. This is the
27609default. This option defines the preprocessor macro @code{__LIW__}.
27610
27611@item -mno-liw
27612@opindex mno-liw
27613Do not allow the compiler to generate @emph{Long Instruction Word}
27614instructions. This option defines the preprocessor macro
27615@code{__NO_LIW__}.
27616
27617@item -msetlb
27618@opindex msetlb
27619Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
27620instructions if the target is the @samp{AM33} or later. This is the
27621default. This option defines the preprocessor macro @code{__SETLB__}.
27622
27623@item -mno-setlb
27624@opindex mno-setlb
27625Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
27626instructions. This option defines the preprocessor macro
27627@code{__NO_SETLB__}.
27628
27629@end table
27630
27631@node Moxie Options
27632@subsection Moxie Options
27633@cindex Moxie Options
27634
27635@table @gcctabopt
27636
27637@item -meb
27638@opindex meb
27639Generate big-endian code. This is the default for @samp{moxie-*-*}
27640configurations.
27641
27642@item -mel
27643@opindex mel
27644Generate little-endian code.
27645
27646@item -mmul.x
27647@opindex mmul.x
27648Generate mul.x and umul.x instructions. This is the default for
27649@samp{moxiebox-*-*} configurations.
27650
27651@item -mno-crt0
27652@opindex mno-crt0
27653Do not link in the C run-time initialization object file.
27654
27655@end table
27656
27657@node MSP430 Options
27658@subsection MSP430 Options
27659@cindex MSP430 Options
27660
27661These options are defined for the MSP430:
27662
27663@table @gcctabopt
27664
27665@item -masm-hex
27666@opindex masm-hex
27667Force assembly output to always use hex constants. Normally such
27668constants are signed decimals, but this option is available for
27669testsuite and/or aesthetic purposes.
27670
27671@item -mmcu=
27672@opindex mmcu=
27673Select the MCU to target. This is used to create a C preprocessor
27674symbol based upon the MCU name, converted to upper case and pre- and
27675post-fixed with @samp{__}. This in turn is used by the
27676@file{msp430.h} header file to select an MCU-specific supplementary
27677header file.
27678
27679The option also sets the ISA to use. If the MCU name is one that is
27680known to only support the 430 ISA then that is selected, otherwise the
27681430X ISA is selected. A generic MCU name of @samp{msp430} can also be
27682used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
27683name selects the 430X ISA.
27684
27685In addition an MCU-specific linker script is added to the linker
27686command line. The script's name is the name of the MCU with
27687@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
27688command line defines the C preprocessor symbol @code{__XXX__} and
27689cause the linker to search for a script called @file{xxx.ld}.
27690
27691The ISA and hardware multiply supported for the different MCUs is hard-coded
27692into GCC. However, an external @samp{devices.csv} file can be used to
27693extend device support beyond those that have been hard-coded.
27694
27695GCC searches for the @samp{devices.csv} file using the following methods in the
27696given precedence order, where the first method takes precendence over the
27697second which takes precedence over the third.
27698
27699@table @asis
27700@item Include path specified with @code{-I} and @code{-L}
27701@samp{devices.csv} will be searched for in each of the directories specified by
27702include paths and linker library search paths.
27703@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
27704Define the value of the global environment variable
27705@samp{MSP430_GCC_INCLUDE_DIR}
27706to the full path to the directory containing devices.csv, and GCC will search
27707this directory for devices.csv. If devices.csv is found, this directory will
27708also be registered as an include path, and linker library path. Header files
27709and linker scripts in this directory can therefore be used without manually
27710specifying @code{-I} and @code{-L} on the command line.
27711@item The @samp{msp430-elf@{,bare@}/include/devices} directory
27712Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
27713toolchain root directory. This directory does not exist in a default
27714installation, but if the user has created it and copied @samp{devices.csv}
27715there, then the MCU data will be read. As above, this directory will
27716also be registered as an include path, and linker library path.
27717
27718@end table
27719If none of the above search methods find @samp{devices.csv}, then the
27720hard-coded MCU data is used.
27721
27722
27723@item -mwarn-mcu
27724@itemx -mno-warn-mcu
27725@opindex mwarn-mcu
27726@opindex mno-warn-mcu
27727This option enables or disables warnings about conflicts between the
27728MCU name specified by the @option{-mmcu} option and the ISA set by the
27729@option{-mcpu} option and/or the hardware multiply support set by the
27730@option{-mhwmult} option. It also toggles warnings about unrecognized
27731MCU names. This option is on by default.
27732
27733@item -mcpu=
27734@opindex mcpu=
27735Specifies the ISA to use. Accepted values are @samp{msp430},
27736@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
27737@option{-mmcu=} option should be used to select the ISA.
27738
27739@item -msim
27740@opindex msim
27741Link to the simulator runtime libraries and linker script. Overrides
27742any scripts that would be selected by the @option{-mmcu=} option.
27743
27744@item -mlarge
27745@opindex mlarge
27746Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
27747
27748@item -msmall
27749@opindex msmall
27750Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
27751
27752@item -mrelax
27753@opindex mrelax
27754This option is passed to the assembler and linker, and allows the
27755linker to perform certain optimizations that cannot be done until
27756the final link.
27757
27758@item mhwmult=
27759@opindex mhwmult=
27760Describes the type of hardware multiply supported by the target.
27761Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
27762for the original 16-bit-only multiply supported by early MCUs.
27763@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
27764@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
27765A value of @samp{auto} can also be given. This tells GCC to deduce
27766the hardware multiply support based upon the MCU name provided by the
27767@option{-mmcu} option. If no @option{-mmcu} option is specified or if
27768the MCU name is not recognized then no hardware multiply support is
27769assumed. @code{auto} is the default setting.
27770
27771Hardware multiplies are normally performed by calling a library
27772routine. This saves space in the generated code. When compiling at
27773@option{-O3} or higher however the hardware multiplier is invoked
27774inline. This makes for bigger, but faster code.
27775
27776The hardware multiply routines disable interrupts whilst running and
27777restore the previous interrupt state when they finish. This makes
27778them safe to use inside interrupt handlers as well as in normal code.
27779
27780@item -minrt
27781@opindex minrt
27782Enable the use of a minimum runtime environment - no static
27783initializers or constructors. This is intended for memory-constrained
27784devices. The compiler includes special symbols in some objects
27785that tell the linker and runtime which code fragments are required.
27786
27787@item -mtiny-printf
27788@opindex mtiny-printf
27789Enable reduced code size @code{printf} and @code{puts} library functions.
27790The @samp{tiny} implementations of these functions are not reentrant, so
27791must be used with caution in multi-threaded applications.
27792
27793Support for streams has been removed and the string to be printed will
27794always be sent to stdout via the @code{write} syscall. The string is not
27795buffered before it is sent to write.
27796
27797This option requires Newlib Nano IO, so GCC must be configured with
27798@samp{--enable-newlib-nano-formatted-io}.
27799
27800@item -mmax-inline-shift=
27801@opindex mmax-inline-shift=
27802This option takes an integer between 0 and 64 inclusive, and sets
27803the maximum number of inline shift instructions which should be emitted to
27804perform a shift operation by a constant amount. When this value needs to be
27805exceeded, an mspabi helper function is used instead. The default value is 4.
27806
27807This only affects cases where a shift by multiple positions cannot be
27808completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
27809
27810Shifts of a 32-bit value are at least twice as costly, so the value passed for
27811this option is divided by 2 and the resulting value used instead.
27812
27813@item -mcode-region=
27814@itemx -mdata-region=
27815@opindex mcode-region
27816@opindex mdata-region
27817These options tell the compiler where to place functions and data that
27818do not have one of the @code{lower}, @code{upper}, @code{either} or
27819@code{section} attributes. Possible values are @code{lower},
27820@code{upper}, @code{either} or @code{any}. The first three behave
27821like the corresponding attribute. The fourth possible value -
27822@code{any} - is the default. It leaves placement entirely up to the
27823linker script and how it assigns the standard sections
27824(@code{.text}, @code{.data}, etc) to the memory regions.
27825
27826@item -msilicon-errata=
27827@opindex msilicon-errata
27828This option passes on a request to assembler to enable the fixes for
27829the named silicon errata.
27830
27831@item -msilicon-errata-warn=
27832@opindex msilicon-errata-warn
27833This option passes on a request to the assembler to enable warning
27834messages when a silicon errata might need to be applied.
27835
27836@item -mwarn-devices-csv
27837@itemx -mno-warn-devices-csv
27838@opindex mwarn-devices-csv
27839@opindex mno-warn-devices-csv
27840Warn if @samp{devices.csv} is not found or there are problem parsing it
27841(default: on).
27842
27843@end table
27844
27845@node NDS32 Options
27846@subsection NDS32 Options
27847@cindex NDS32 Options
27848
27849These options are defined for NDS32 implementations:
27850
27851@table @gcctabopt
27852
27853@item -mbig-endian
27854@opindex mbig-endian
27855Generate code in big-endian mode.
27856
27857@item -mlittle-endian
27858@opindex mlittle-endian
27859Generate code in little-endian mode.
27860
27861@item -mreduced-regs
27862@opindex mreduced-regs
27863Use reduced-set registers for register allocation.
27864
27865@item -mfull-regs
27866@opindex mfull-regs
27867Use full-set registers for register allocation.
27868
27869@item -mcmov
27870@opindex mcmov
27871Generate conditional move instructions.
27872
27873@item -mno-cmov
27874@opindex mno-cmov
27875Do not generate conditional move instructions.
27876
27877@item -mext-perf
27878@opindex mext-perf
27879Generate performance extension instructions.
27880
27881@item -mno-ext-perf
27882@opindex mno-ext-perf
27883Do not generate performance extension instructions.
27884
27885@item -mext-perf2
27886@opindex mext-perf2
27887Generate performance extension 2 instructions.
27888
27889@item -mno-ext-perf2
27890@opindex mno-ext-perf2
27891Do not generate performance extension 2 instructions.
27892
27893@item -mext-string
27894@opindex mext-string
27895Generate string extension instructions.
27896
27897@item -mno-ext-string
27898@opindex mno-ext-string
27899Do not generate string extension instructions.
27900
27901@item -mv3push
27902@opindex mv3push
27903Generate v3 push25/pop25 instructions.
27904
27905@item -mno-v3push
27906@opindex mno-v3push
27907Do not generate v3 push25/pop25 instructions.
27908
27909@item -m16-bit
27910@opindex m16-bit
27911Generate 16-bit instructions.
27912
27913@item -mno-16-bit
27914@opindex mno-16-bit
27915Do not generate 16-bit instructions.
27916
27917@item -misr-vector-size=@var{num}
27918@opindex misr-vector-size
27919Specify the size of each interrupt vector, which must be 4 or 16.
27920
27921@item -mcache-block-size=@var{num}
27922@opindex mcache-block-size
27923Specify the size of each cache block,
27924which must be a power of 2 between 4 and 512.
27925
27926@item -march=@var{arch}
27927@opindex march
27928Specify the name of the target architecture.
27929
27930@item -mcmodel=@var{code-model}
27931@opindex mcmodel
27932Set the code model to one of
27933@table @asis
27934@item @samp{small}
27935All the data and read-only data segments must be within 512KB addressing space.
27936The text segment must be within 16MB addressing space.
27937@item @samp{medium}
27938The data segment must be within 512KB while the read-only data segment can be
27939within 4GB addressing space. The text segment should be still within 16MB
27940addressing space.
27941@item @samp{large}
27942All the text and data segments can be within 4GB addressing space.
27943@end table
27944
27945@item -mctor-dtor
27946@opindex mctor-dtor
27947Enable constructor/destructor feature.
27948
27949@item -mrelax
27950@opindex mrelax
27951Guide linker to relax instructions.
27952
27953@end table
27954
27955@node Nios II Options
27956@subsection Nios II Options
27957@cindex Nios II options
27958@cindex Altera Nios II options
27959
27960These are the options defined for the Altera Nios II processor.
27961
27962@table @gcctabopt
27963
27964@item -G @var{num}
27965@opindex G
27966@cindex smaller data references
27967Put global and static objects less than or equal to @var{num} bytes
27968into the small data or BSS sections instead of the normal data or BSS
27969sections. The default value of @var{num} is 8.
27970
27971@item -mgpopt=@var{option}
27972@itemx -mgpopt
27973@itemx -mno-gpopt
27974@opindex mgpopt
27975@opindex mno-gpopt
27976Generate (do not generate) GP-relative accesses. The following
27977@var{option} names are recognized:
27978
27979@table @samp
27980
27981@item none
27982Do not generate GP-relative accesses.
27983
27984@item local
27985Generate GP-relative accesses for small data objects that are not
27986external, weak, or uninitialized common symbols.
27987Also use GP-relative addressing for objects that
27988have been explicitly placed in a small data section via a @code{section}
27989attribute.
27990
27991@item global
27992As for @samp{local}, but also generate GP-relative accesses for
27993small data objects that are external, weak, or common. If you use this option,
27994you must ensure that all parts of your program (including libraries) are
27995compiled with the same @option{-G} setting.
27996
27997@item data
27998Generate GP-relative accesses for all data objects in the program. If you
27999use this option, the entire data and BSS segments
28000of your program must fit in 64K of memory and you must use an appropriate
28001linker script to allocate them within the addressable range of the
28002global pointer.
28003
28004@item all
28005Generate GP-relative addresses for function pointers as well as data
28006pointers. If you use this option, the entire text, data, and BSS segments
28007of your program must fit in 64K of memory and you must use an appropriate
28008linker script to allocate them within the addressable range of the
28009global pointer.
28010
28011@end table
28012
28013@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28014@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28015
28016The default is @option{-mgpopt} except when @option{-fpic} or
28017@option{-fPIC} is specified to generate position-independent code.
28018Note that the Nios II ABI does not permit GP-relative accesses from
28019shared libraries.
28020
28021You may need to specify @option{-mno-gpopt} explicitly when building
28022programs that include large amounts of small data, including large
28023GOT data sections. In this case, the 16-bit offset for GP-relative
28024addressing may not be large enough to allow access to the entire
28025small data section.
28026
28027@item -mgprel-sec=@var{regexp}
28028@opindex mgprel-sec
28029This option specifies additional section names that can be accessed via
28030GP-relative addressing. It is most useful in conjunction with
28031@code{section} attributes on variable declarations
28032(@pxref{Common Variable Attributes}) and a custom linker script.
28033The @var{regexp} is a POSIX Extended Regular Expression.
28034
28035This option does not affect the behavior of the @option{-G} option, and
28036the specified sections are in addition to the standard @code{.sdata}
28037and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28038
28039@item -mr0rel-sec=@var{regexp}
28040@opindex mr0rel-sec
28041This option specifies names of sections that can be accessed via a
2804216-bit offset from @code{r0}; that is, in the low 32K or high 32K
28043of the 32-bit address space. It is most useful in conjunction with
28044@code{section} attributes on variable declarations
28045(@pxref{Common Variable Attributes}) and a custom linker script.
28046The @var{regexp} is a POSIX Extended Regular Expression.
28047
28048In contrast to the use of GP-relative addressing for small data,
28049zero-based addressing is never generated by default and there are no
28050conventional section names used in standard linker scripts for sections
28051in the low or high areas of memory.
28052
28053@item -mel
28054@itemx -meb
28055@opindex mel
28056@opindex meb
28057Generate little-endian (default) or big-endian (experimental) code,
28058respectively.
28059
28060@item -march=@var{arch}
28061@opindex march
28062This specifies the name of the target Nios II architecture. GCC uses this
28063name to determine what kind of instructions it can emit when generating
28064assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28065
28066The preprocessor macro @code{__nios2_arch__} is available to programs,
28067with value 1 or 2, indicating the targeted ISA level.
28068
28069@item -mbypass-cache
28070@itemx -mno-bypass-cache
28071@opindex mno-bypass-cache
28072@opindex mbypass-cache
28073Force all load and store instructions to always bypass cache by
28074using I/O variants of the instructions. The default is not to
28075bypass the cache.
28076
28077@item -mno-cache-volatile
28078@itemx -mcache-volatile
28079@opindex mcache-volatile
28080@opindex mno-cache-volatile
28081Volatile memory access bypass the cache using the I/O variants of
28082the load and store instructions. The default is not to bypass the cache.
28083
28084@item -mno-fast-sw-div
28085@itemx -mfast-sw-div
28086@opindex mno-fast-sw-div
28087@opindex mfast-sw-div
28088Do not use table-based fast divide for small numbers. The default
28089is to use the fast divide at @option{-O3} and above.
28090
28091@item -mno-hw-mul
28092@itemx -mhw-mul
28093@itemx -mno-hw-mulx
28094@itemx -mhw-mulx
28095@itemx -mno-hw-div
28096@itemx -mhw-div
28097@opindex mno-hw-mul
28098@opindex mhw-mul
28099@opindex mno-hw-mulx
28100@opindex mhw-mulx
28101@opindex mno-hw-div
28102@opindex mhw-div
28103Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28104instructions by the compiler. The default is to emit @code{mul}
28105and not emit @code{div} and @code{mulx}.
28106
28107@item -mbmx
28108@itemx -mno-bmx
28109@itemx -mcdx
28110@itemx -mno-cdx
28111Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28112CDX (code density) instructions. Enabling these instructions also
28113requires @option{-march=r2}. Since these instructions are optional
28114extensions to the R2 architecture, the default is not to emit them.
28115
28116@item -mcustom-@var{insn}=@var{N}
28117@itemx -mno-custom-@var{insn}
28118@opindex mcustom-@var{insn}
28119@opindex mno-custom-@var{insn}
28120Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28121custom instruction with encoding @var{N} when generating code that uses
28122@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28123instruction 253 for single-precision floating-point add operations instead
28124of the default behavior of using a library call.
28125
28126The following values of @var{insn} are supported. Except as otherwise
28127noted, floating-point operations are expected to be implemented with
28128normal IEEE 754 semantics and correspond directly to the C operators or the
28129equivalent GCC built-in functions (@pxref{Other Builtins}).
28130
28131Single-precision floating point:
28132@table @asis
28133
28134@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28135Binary arithmetic operations.
28136
28137@item @samp{fnegs}
28138Unary negation.
28139
28140@item @samp{fabss}
28141Unary absolute value.
28142
28143@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28144Comparison operations.
28145
28146@item @samp{fmins}, @samp{fmaxs}
28147Floating-point minimum and maximum. These instructions are only
28148generated if @option{-ffinite-math-only} is specified.
28149
28150@item @samp{fsqrts}
28151Unary square root operation.
28152
28153@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28154Floating-point trigonometric and exponential functions. These instructions
28155are only generated if @option{-funsafe-math-optimizations} is also specified.
28156
28157@end table
28158
28159Double-precision floating point:
28160@table @asis
28161
28162@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28163Binary arithmetic operations.
28164
28165@item @samp{fnegd}
28166Unary negation.
28167
28168@item @samp{fabsd}
28169Unary absolute value.
28170
28171@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28172Comparison operations.
28173
28174@item @samp{fmind}, @samp{fmaxd}
28175Double-precision minimum and maximum. These instructions are only
28176generated if @option{-ffinite-math-only} is specified.
28177
28178@item @samp{fsqrtd}
28179Unary square root operation.
28180
28181@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28182Double-precision trigonometric and exponential functions. These instructions
28183are only generated if @option{-funsafe-math-optimizations} is also specified.
28184
28185@end table
28186
28187Conversions:
28188@table @asis
28189@item @samp{fextsd}
28190Conversion from single precision to double precision.
28191
28192@item @samp{ftruncds}
28193Conversion from double precision to single precision.
28194
28195@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28196Conversion from floating point to signed or unsigned integer types, with
28197truncation towards zero.
28198
28199@item @samp{round}
28200Conversion from single-precision floating point to signed integer,
28201rounding to the nearest integer and ties away from zero.
28202This corresponds to the @code{__builtin_lroundf} function when
28203@option{-fno-math-errno} is used.
28204
28205@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28206Conversion from signed or unsigned integer types to floating-point types.
28207
28208@end table
28209
28210In addition, all of the following transfer instructions for internal
28211registers X and Y must be provided to use any of the double-precision
28212floating-point instructions. Custom instructions taking two
28213double-precision source operands expect the first operand in the
2821464-bit register X. The other operand (or only operand of a unary
28215operation) is given to the custom arithmetic instruction with the
28216least significant half in source register @var{src1} and the most
28217significant half in @var{src2}. A custom instruction that returns a
28218double-precision result returns the most significant 32 bits in the
28219destination register and the other half in 32-bit register Y.
28220GCC automatically generates the necessary code sequences to write
28221register X and/or read register Y when double-precision floating-point
28222instructions are used.
28223
28224@table @asis
28225
28226@item @samp{fwrx}
28227Write @var{src1} into the least significant half of X and @var{src2} into
28228the most significant half of X.
28229
28230@item @samp{fwry}
28231Write @var{src1} into Y.
28232
28233@item @samp{frdxhi}, @samp{frdxlo}
28234Read the most or least (respectively) significant half of X and store it in
28235@var{dest}.
28236
28237@item @samp{frdy}
28238Read the value of Y and store it into @var{dest}.
28239@end table
28240
28241Note that you can gain more local control over generation of Nios II custom
28242instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28243and @code{target("no-custom-@var{insn}")} function attributes
28244(@pxref{Function Attributes})
28245or pragmas (@pxref{Function Specific Option Pragmas}).
28246
28247@item -mcustom-fpu-cfg=@var{name}
28248@opindex mcustom-fpu-cfg
28249
28250This option enables a predefined, named set of custom instruction encodings
28251(see @option{-mcustom-@var{insn}} above).
28252Currently, the following sets are defined:
28253
28254@option{-mcustom-fpu-cfg=60-1} is equivalent to:
28255@gccoptlist{-mcustom-fmuls=252 @gol
28256-mcustom-fadds=253 @gol
28257-mcustom-fsubs=254 @gol
28258-fsingle-precision-constant}
28259
28260@option{-mcustom-fpu-cfg=60-2} is equivalent to:
28261@gccoptlist{-mcustom-fmuls=252 @gol
28262-mcustom-fadds=253 @gol
28263-mcustom-fsubs=254 @gol
28264-mcustom-fdivs=255 @gol
28265-fsingle-precision-constant}
28266
28267@option{-mcustom-fpu-cfg=72-3} is equivalent to:
28268@gccoptlist{-mcustom-floatus=243 @gol
28269-mcustom-fixsi=244 @gol
28270-mcustom-floatis=245 @gol
28271-mcustom-fcmpgts=246 @gol
28272-mcustom-fcmples=249 @gol
28273-mcustom-fcmpeqs=250 @gol
28274-mcustom-fcmpnes=251 @gol
28275-mcustom-fmuls=252 @gol
28276-mcustom-fadds=253 @gol
28277-mcustom-fsubs=254 @gol
28278-mcustom-fdivs=255 @gol
28279-fsingle-precision-constant}
28280
28281@option{-mcustom-fpu-cfg=fph2} is equivalent to:
28282@gccoptlist{-mcustom-fabss=224 @gol
28283-mcustom-fnegs=225 @gol
28284-mcustom-fcmpnes=226 @gol
28285-mcustom-fcmpeqs=227 @gol
28286-mcustom-fcmpges=228 @gol
28287-mcustom-fcmpgts=229 @gol
28288-mcustom-fcmples=230 @gol
28289-mcustom-fcmplts=231 @gol
28290-mcustom-fmaxs=232 @gol
28291-mcustom-fmins=233 @gol
28292-mcustom-round=248 @gol
28293-mcustom-fixsi=249 @gol
28294-mcustom-floatis=250 @gol
28295-mcustom-fsqrts=251 @gol
28296-mcustom-fmuls=252 @gol
28297-mcustom-fadds=253 @gol
28298-mcustom-fsubs=254 @gol
28299-mcustom-fdivs=255 @gol}
28300
28301Custom instruction assignments given by individual
28302@option{-mcustom-@var{insn}=} options override those given by
28303@option{-mcustom-fpu-cfg=}, regardless of the
28304order of the options on the command line.
28305
28306Note that you can gain more local control over selection of a FPU
28307configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28308function attribute (@pxref{Function Attributes})
28309or pragma (@pxref{Function Specific Option Pragmas}).
28310
28311The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28312Hardware 2 Component}. Please note that the custom instructions enabled by
28313@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28314if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28315@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28316specified. In contrast to the other configurations,
28317@option{-fsingle-precision-constant} is not set.
28318
28319@end table
28320
28321These additional @samp{-m} options are available for the Altera Nios II
28322ELF (bare-metal) target:
28323
28324@table @gcctabopt
28325
28326@item -mhal
28327@opindex mhal
28328Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28329startup and termination code, and is typically used in conjunction with
28330@option{-msys-crt0=} to specify the location of the alternate startup code
28331provided by the HAL BSP.
28332
28333@item -msmallc
28334@opindex msmallc
28335Link with a limited version of the C library, @option{-lsmallc}, rather than
28336Newlib.
28337
28338@item -msys-crt0=@var{startfile}
28339@opindex msys-crt0
28340@var{startfile} is the file name of the startfile (crt0) to use
28341when linking. This option is only useful in conjunction with @option{-mhal}.
28342
28343@item -msys-lib=@var{systemlib}
28344@opindex msys-lib
28345@var{systemlib} is the library name of the library that provides
28346low-level system calls required by the C library,
28347e.g.@: @code{read} and @code{write}.
28348This option is typically used to link with a library provided by a HAL BSP.
28349
28350@end table
28351
28352@node Nvidia PTX Options
28353@subsection Nvidia PTX Options
28354@cindex Nvidia PTX options
28355@cindex nvptx options
28356
28357These options are defined for Nvidia PTX:
28358
28359@table @gcctabopt
28360
28361@item -m64
28362@opindex m64
28363Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28364supported.
28365
28366@item -march=@var{architecture-string}
28367@opindex march
28368Generate code for the specified PTX ISA target architecture
28369(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
28370@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
28371@samp{sm_80}.
28372The default depends on how the compiler has been configured, see
28373@option{--with-arch}.
28374
28375This option sets the value of the preprocessor macro
28376@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
28377@samp{350}.
28378
28379@item -misa=@var{architecture-string}
28380@opindex misa
28381Alias of @option{-march=}.
28382
28383@item -march-map=@var{architecture-string}
28384@opindex march
28385Select the closest available @option{-march=} value that is not more
28386capable. For instance, for @option{-march-map=sm_50} select
28387@option{-march=sm_35}, and for @option{-march-map=sm_53} select
28388@option{-march=sm_53}.
28389
28390@item -mptx=@var{version-string}
28391@opindex mptx
28392Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
28393Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
28394@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
28395version is required for specified PTX ISA target architecture via
28396option @option{-march=}.
28397
28398This option sets the values of the preprocessor macros
28399@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
28400for instance, for @samp{3.1} the macros have the values @samp{3} and
28401@samp{1}, respectively.
28402
28403@item -mmainkernel
28404@opindex mmainkernel
28405Link in code for a __main kernel. This is for stand-alone instead of
28406offloading execution.
28407
28408@item -moptimize
28409@opindex moptimize
28410Apply partitioned execution optimizations. This is the default when any
28411level of optimization is selected.
28412
28413@item -msoft-stack
28414@opindex msoft-stack
28415Generate code that does not use @code{.local} memory
28416directly for stack storage. Instead, a per-warp stack pointer is
28417maintained explicitly. This enables variable-length stack allocation (with
28418variable-length arrays or @code{alloca}), and when global memory is used for
28419underlying storage, makes it possible to access automatic variables from other
28420threads, or with atomic instructions. This code generation variant is used
28421for OpenMP offloading, but the option is exposed on its own for the purpose
28422of testing the compiler; to generate code suitable for linking into programs
28423using OpenMP offloading, use option @option{-mgomp}.
28424
28425@item -muniform-simt
28426@opindex muniform-simt
28427Switch to code generation variant that allows to execute all threads in each
28428warp, while maintaining memory state and side effects as if only one thread
28429in each warp was active outside of OpenMP SIMD regions. All atomic operations
28430and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
28431current lane index equals the master lane index), and the register being
28432assigned is copied via a shuffle instruction from the master lane. Outside of
28433SIMD regions lane 0 is the master; inside, each thread sees itself as the
28434master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
28435all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
28436regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
28437with current lane index to compute the master lane index.
28438
28439@item -mgomp
28440@opindex mgomp
28441Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
28442@option{-muniform-simt} options, and selects corresponding multilib variant.
28443
28444@end table
28445
28446@node OpenRISC Options
28447@subsection OpenRISC Options
28448@cindex OpenRISC Options
28449
28450These options are defined for OpenRISC:
28451
28452@table @gcctabopt
28453
28454@item -mboard=@var{name}
28455@opindex mboard
28456Configure a board specific runtime. This will be passed to the linker for
28457newlib board library linking. The default is @code{or1ksim}.
28458
28459@item -mnewlib
28460@opindex mnewlib
28461This option is ignored; it is for compatibility purposes only. This used to
28462select linker and preprocessor options for use with newlib.
28463
28464@item -msoft-div
28465@itemx -mhard-div
28466@opindex msoft-div
28467@opindex mhard-div
28468Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
28469This default is hardware divide.
28470
28471@item -msoft-mul
28472@itemx -mhard-mul
28473@opindex msoft-mul
28474@opindex mhard-mul
28475Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
28476This default is hardware multiply.
28477
28478@item -msoft-float
28479@itemx -mhard-float
28480@opindex msoft-float
28481@opindex mhard-float
28482Select software or hardware for floating point operations.
28483The default is software.
28484
28485@item -mdouble-float
28486@opindex mdouble-float
28487When @option{-mhard-float} is selected, enables generation of double-precision
28488floating point instructions. By default functions from @file{libgcc} are used
28489to perform double-precision floating point operations.
28490
28491@item -munordered-float
28492@opindex munordered-float
28493When @option{-mhard-float} is selected, enables generation of unordered
28494floating point compare and set flag (@code{lf.sfun*}) instructions. By default
28495functions from @file{libgcc} are used to perform unordered floating point
28496compare and set flag operations.
28497
28498@item -mcmov
28499@opindex mcmov
28500Enable generation of conditional move (@code{l.cmov}) instructions. By
28501default the equivalent will be generated using set and branch.
28502
28503@item -mror
28504@opindex mror
28505Enable generation of rotate right (@code{l.ror}) instructions. By default
28506functions from @file{libgcc} are used to perform rotate right operations.
28507
28508@item -mrori
28509@opindex mrori
28510Enable generation of rotate right with immediate (@code{l.rori}) instructions.
28511By default functions from @file{libgcc} are used to perform rotate right with
28512immediate operations.
28513
28514@item -msext
28515@opindex msext
28516Enable generation of sign extension (@code{l.ext*}) instructions. By default
28517memory loads are used to perform sign extension.
28518
28519@item -msfimm
28520@opindex msfimm
28521Enable generation of compare and set flag with immediate (@code{l.sf*i})
28522instructions. By default extra instructions will be generated to store the
28523immediate to a register first.
28524
28525@item -mshftimm
28526@opindex mshftimm
28527Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
28528@code{l.slli}) instructions. By default extra instructions will be generated
28529to store the immediate to a register first.
28530
28531@item -mcmodel=small
28532@opindex mcmodel=small
28533Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
28534the default model.
28535
28536@item -mcmodel=large
28537@opindex mcmodel=large
28538Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
28539
28540
28541@end table
28542
28543@node PDP-11 Options
28544@subsection PDP-11 Options
28545@cindex PDP-11 Options
28546
28547These options are defined for the PDP-11:
28548
28549@table @gcctabopt
28550@item -mfpu
28551@opindex mfpu
28552Use hardware FPP floating point. This is the default. (FIS floating
28553point on the PDP-11/40 is not supported.) Implies -m45.
28554
28555@item -msoft-float
28556@opindex msoft-float
28557Do not use hardware floating point.
28558
28559@item -mac0
28560@opindex mac0
28561Return floating-point results in ac0 (fr0 in Unix assembler syntax).
28562
28563@item -mno-ac0
28564@opindex mno-ac0
28565Return floating-point results in memory. This is the default.
28566
28567@item -m40
28568@opindex m40
28569Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
28570
28571@item -m45
28572@opindex m45
28573Generate code for a PDP-11/45. This is the default.
28574
28575@item -m10
28576@opindex m10
28577Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
28578
28579@item -mint16
28580@itemx -mno-int32
28581@opindex mint16
28582@opindex mno-int32
28583Use 16-bit @code{int}. This is the default.
28584
28585@item -mint32
28586@itemx -mno-int16
28587@opindex mint32
28588@opindex mno-int16
28589Use 32-bit @code{int}.
28590
28591@item -msplit
28592@opindex msplit
28593Target has split instruction and data space. Implies -m45.
28594
28595@item -munix-asm
28596@opindex munix-asm
28597Use Unix assembler syntax.
28598
28599@item -mdec-asm
28600@opindex mdec-asm
28601Use DEC assembler syntax.
28602
28603@item -mgnu-asm
28604@opindex mgnu-asm
28605Use GNU assembler syntax. This is the default.
28606
28607@item -mlra
28608@opindex mlra
28609Use the new LRA register allocator. By default, the old ``reload''
28610allocator is used.
28611@end table
28612
d77de738
ML
28613@node PowerPC Options
28614@subsection PowerPC Options
28615@cindex PowerPC options
28616
28617These are listed under @xref{RS/6000 and PowerPC Options}.
28618
28619@node PRU Options
28620@subsection PRU Options
28621@cindex PRU Options
28622
28623These command-line options are defined for PRU target:
28624
28625@table @gcctabopt
28626@item -minrt
28627@opindex minrt
28628Link with a minimum runtime environment, with no support for static
28629initializers and constructors. Using this option can significantly reduce
28630the size of the final ELF binary. Beware that the compiler could still
28631generate code with static initializers and constructors. It is up to the
28632programmer to ensure that the source program will not use those features.
28633
28634@item -mmcu=@var{mcu}
28635@opindex mmcu
28636Specify the PRU MCU variant to use. Check Newlib for the exact list of
28637supported MCUs.
28638
28639@item -mno-relax
28640@opindex mno-relax
28641Make GCC pass the @option{--no-relax} command-line option to the linker
28642instead of the @option{--relax} option.
28643
28644@item -mloop
28645@opindex mloop
28646Allow (or do not allow) GCC to use the LOOP instruction.
28647
28648@item -mabi=@var{variant}
28649@opindex mabi
28650Specify the ABI variant to output code for. @option{-mabi=ti} selects the
28651unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
28652more naturally with certain GCC assumptions. These are the differences:
28653
28654@table @samp
28655@item Function Pointer Size
28656TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
28657supports only 32-bit data and code pointers.
28658
28659@item Optional Return Value Pointer
28660Function return values larger than 64 bits are passed by using a hidden
28661pointer as the first argument of the function. TI ABI, though, mandates that
28662the pointer can be NULL in case the caller is not using the returned value.
28663GNU always passes and expects a valid return value pointer.
28664
28665@end table
28666
28667The current @option{-mabi=ti} implementation simply raises a compile error
28668when any of the above code constructs is detected. As a consequence
28669the standard C library cannot be built and it is omitted when linking with
28670@option{-mabi=ti}.
28671
28672Relaxation is a GNU feature and for safety reasons is disabled when using
28673@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
28674instructions, so the GNU linker cannot adjust them when shortening adjacent
28675LDI32 pseudo instructions.
28676
28677@end table
28678
28679@node RISC-V Options
28680@subsection RISC-V Options
28681@cindex RISC-V Options
28682
28683These command-line options are defined for RISC-V targets:
28684
28685@table @gcctabopt
28686@item -mbranch-cost=@var{n}
28687@opindex mbranch-cost
28688Set the cost of branches to roughly @var{n} instructions.
28689
28690@item -mplt
28691@itemx -mno-plt
28692@opindex plt
28693When generating PIC code, do or don't allow the use of PLTs. Ignored for
28694non-PIC. The default is @option{-mplt}.
28695
28696@item -mabi=@var{ABI-string}
28697@opindex mabi
28698Specify integer and floating-point calling convention. @var{ABI-string}
28699contains two parts: the size of integer types and the registers used for
28700floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
28701@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2870232-bit), and that floating-point values up to 64 bits wide are passed in F
28703registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
28704allows the compiler to generate code that uses the F and D extensions but only
28705allows floating-point values up to 32 bits long to be passed in registers; or
28706@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
28707passed in registers.
28708
28709The default for this argument is system dependent, users who want a specific
28710calling convention should specify one explicitly. The valid calling
28711conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
28712@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
28713implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
28714invalid because the ABI requires 64-bit values be passed in F registers, but F
28715registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
28716only be used with the @samp{rv32e} architecture. This ABI is not well
28717specified at present, and is subject to change.
28718
28719@item -mfdiv
28720@itemx -mno-fdiv
28721@opindex mfdiv
28722Do or don't use hardware floating-point divide and square root instructions.
28723This requires the F or D extensions for floating-point registers. The default
28724is to use them if the specified architecture has these instructions.
28725
28726@item -mdiv
28727@itemx -mno-div
28728@opindex mdiv
28729Do or don't use hardware instructions for integer division. This requires the
28730M extension. The default is to use them if the specified architecture has
28731these instructions.
28732
28733@item -misa-spec=@var{ISA-spec-string}
28734@opindex misa-spec
28735Specify the version of the RISC-V Unprivileged (formerly User-Level)
28736ISA specification to produce code conforming to. The possibilities
28737for @var{ISA-spec-string} are:
28738@table @code
28739@item 2.2
28740Produce code conforming to version 2.2.
28741@item 20190608
28742Produce code conforming to version 20190608.
28743@item 20191213
28744Produce code conforming to version 20191213.
28745@end table
28746The default is @option{-misa-spec=20191213} unless GCC has been configured
28747with @option{--with-isa-spec=} specifying a different default version.
28748
28749@item -march=@var{ISA-string}
28750@opindex march
28751Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
28752lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
28753@samp{rv32imaf}.
28754
28755When @option{-march=} is not specified, use the setting from @option{-mcpu}.
28756
28757If both @option{-march} and @option{-mcpu=} are not specified, the default for
28758this argument is system dependent, users who want a specific architecture
28759extensions should specify one explicitly.
28760
28761@item -mcpu=@var{processor-string}
28762@opindex mcpu
28763Use architecture of and optimize the output for the given processor, specified
28764by particular CPU name.
28765Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
28766@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
28767@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 28768@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738
ML
28769
28770@item -mtune=@var{processor-string}
28771@opindex mtune
28772Optimize the output for the given processor, specified by microarchitecture or
28773particular CPU name. Permissible values for this option are: @samp{rocket},
28774@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 28775@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
28776
28777When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
28778the default is @samp{rocket} if both are not specified.
28779
28780The @samp{size} choice is not intended for use by end-users. This is used
28781when @option{-Os} is specified. It overrides the instruction cost info
28782provided by @option{-mtune=}, but does not override the pipeline info. This
28783helps reduce code size while still giving good performance.
28784
28785@item -mpreferred-stack-boundary=@var{num}
28786@opindex mpreferred-stack-boundary
28787Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
28788byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
28789the default is 4 (16 bytes or 128-bits).
28790
28791@strong{Warning:} If you use this switch, then you must build all modules with
28792the same value, including any libraries. This includes the system libraries
28793and startup modules.
28794
28795@item -msmall-data-limit=@var{n}
28796@opindex msmall-data-limit
28797Put global and static data smaller than @var{n} bytes into a special section
28798(on some targets).
28799
28800@item -msave-restore
28801@itemx -mno-save-restore
28802@opindex msave-restore
28803Do or don't use smaller but slower prologue and epilogue code that uses
28804library function calls. The default is to use fast inline prologues and
28805epilogues.
28806
28807@item -mshorten-memrefs
28808@itemx -mno-shorten-memrefs
28809@opindex mshorten-memrefs
28810Do or do not attempt to make more use of compressed load/store instructions by
28811replacing a load/store of 'base register + large offset' with a new load/store
28812of 'new base + small offset'. If the new base gets stored in a compressed
28813register, then the new load/store can be compressed. Currently targets 32-bit
28814integer load/stores only.
28815
28816@item -mstrict-align
28817@itemx -mno-strict-align
28818@opindex mstrict-align
28819Do not or do generate unaligned memory accesses. The default is set depending
28820on whether the processor we are optimizing for supports fast unaligned access
28821or not.
28822
28823@item -mcmodel=medlow
28824@opindex mcmodel=medlow
28825Generate code for the medium-low code model. The program and its statically
28826defined symbols must lie within a single 2 GiB address range and must lie
28827between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
28828statically or dynamically linked. This is the default code model.
28829
28830@item -mcmodel=medany
28831@opindex mcmodel=medany
28832Generate code for the medium-any code model. The program and its statically
28833defined symbols must be within any single 2 GiB address range. Programs can be
28834statically or dynamically linked.
28835
28836The code generated by the medium-any code model is position-independent, but is
28837not guaranteed to function correctly when linked into position-independent
28838executables or libraries.
28839
28840@item -mexplicit-relocs
28841@itemx -mno-exlicit-relocs
28842Use or do not use assembler relocation operators when dealing with symbolic
28843addresses. The alternative is to use assembler macros instead, which may
28844limit optimization.
28845
28846@item -mrelax
28847@itemx -mno-relax
28848@opindex mrelax
28849Take advantage of linker relaxations to reduce the number of instructions
28850required to materialize symbol addresses. The default is to take advantage of
28851linker relaxations.
28852
28853@item -mriscv-attribute
28854@itemx -mno-riscv-attribute
28855@opindex mriscv-attribute
28856Emit (do not emit) RISC-V attribute to record extra information into ELF
28857objects. This feature requires at least binutils 2.32.
28858
28859@item -mcsr-check
28860@itemx -mno-csr-check
28861@opindex mcsr-check
28862Enables or disables the CSR checking.
28863
28864@item -malign-data=@var{type}
28865@opindex malign-data
28866Control how GCC aligns variables and constants of array, structure, or union
28867types. Supported values for @var{type} are @samp{xlen} which uses x register
28868width as the alignment value, and @samp{natural} which uses natural alignment.
28869@samp{xlen} is the default.
28870
28871@item -mbig-endian
28872@opindex mbig-endian
28873Generate big-endian code. This is the default when GCC is configured for a
28874@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
28875
28876@item -mlittle-endian
28877@opindex mlittle-endian
28878Generate little-endian code. This is the default when GCC is configured for a
28879@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
28880@samp{riscv32be-*-*} target.
28881
28882@item -mstack-protector-guard=@var{guard}
28883@itemx -mstack-protector-guard-reg=@var{reg}
28884@itemx -mstack-protector-guard-offset=@var{offset}
28885@opindex mstack-protector-guard
28886@opindex mstack-protector-guard-reg
28887@opindex mstack-protector-guard-offset
28888Generate stack protection code using canary at @var{guard}. Supported
28889locations are @samp{global} for a global canary or @samp{tls} for per-thread
28890canary in the TLS block.
28891
28892With the latter choice the options
28893@option{-mstack-protector-guard-reg=@var{reg}} and
28894@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
28895which register to use as base register for reading the canary,
28896and from what offset from that base register. There is no default
28897register or offset as this is entirely for use within the Linux
28898kernel.
28899@end table
28900
28901@node RL78 Options
28902@subsection RL78 Options
28903@cindex RL78 Options
28904
28905@table @gcctabopt
28906
28907@item -msim
28908@opindex msim
28909Links in additional target libraries to support operation within a
28910simulator.
28911
28912@item -mmul=none
28913@itemx -mmul=g10
28914@itemx -mmul=g13
28915@itemx -mmul=g14
28916@itemx -mmul=rl78
28917@opindex mmul
28918Specifies the type of hardware multiplication and division support to
28919be used. The simplest is @code{none}, which uses software for both
28920multiplication and division. This is the default. The @code{g13}
28921value is for the hardware multiply/divide peripheral found on the
28922RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
28923the multiplication and division instructions supported by the RL78/G14
28924(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
28925the value @code{mg10} is an alias for @code{none}.
28926
28927In addition a C preprocessor macro is defined, based upon the setting
28928of this option. Possible values are: @code{__RL78_MUL_NONE__},
28929@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
28930
28931@item -mcpu=g10
28932@itemx -mcpu=g13
28933@itemx -mcpu=g14
28934@itemx -mcpu=rl78
28935@opindex mcpu
28936Specifies the RL78 core to target. The default is the G14 core, also
28937known as an S3 core or just RL78. The G13 or S2 core does not have
28938multiply or divide instructions, instead it uses a hardware peripheral
28939for these operations. The G10 or S1 core does not have register
28940banks, so it uses a different calling convention.
28941
28942If this option is set it also selects the type of hardware multiply
28943support to use, unless this is overridden by an explicit
28944@option{-mmul=none} option on the command line. Thus specifying
28945@option{-mcpu=g13} enables the use of the G13 hardware multiply
28946peripheral and specifying @option{-mcpu=g10} disables the use of
28947hardware multiplications altogether.
28948
28949Note, although the RL78/G14 core is the default target, specifying
28950@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
28951change the behavior of the toolchain since it also enables G14
28952hardware multiply support. If these options are not specified on the
28953command line then software multiplication routines will be used even
28954though the code targets the RL78 core. This is for backwards
28955compatibility with older toolchains which did not have hardware
28956multiply and divide support.
28957
28958In addition a C preprocessor macro is defined, based upon the setting
28959of this option. Possible values are: @code{__RL78_G10__},
28960@code{__RL78_G13__} or @code{__RL78_G14__}.
28961
28962@item -mg10
28963@itemx -mg13
28964@itemx -mg14
28965@itemx -mrl78
28966@opindex mg10
28967@opindex mg13
28968@opindex mg14
28969@opindex mrl78
28970These are aliases for the corresponding @option{-mcpu=} option. They
28971are provided for backwards compatibility.
28972
28973@item -mallregs
28974@opindex mallregs
28975Allow the compiler to use all of the available registers. By default
28976registers @code{r24..r31} are reserved for use in interrupt handlers.
28977With this option enabled these registers can be used in ordinary
28978functions as well.
28979
28980@item -m64bit-doubles
28981@itemx -m32bit-doubles
28982@opindex m64bit-doubles
28983@opindex m32bit-doubles
28984Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
28985or 32 bits (@option{-m32bit-doubles}) in size. The default is
28986@option{-m32bit-doubles}.
28987
28988@item -msave-mduc-in-interrupts
28989@itemx -mno-save-mduc-in-interrupts
28990@opindex msave-mduc-in-interrupts
28991@opindex mno-save-mduc-in-interrupts
28992Specifies that interrupt handler functions should preserve the
28993MDUC registers. This is only necessary if normal code might use
28994the MDUC registers, for example because it performs multiplication
28995and division operations. The default is to ignore the MDUC registers
28996as this makes the interrupt handlers faster. The target option -mg13
28997needs to be passed for this to work as this feature is only available
28998on the G13 target (S2 core). The MDUC registers will only be saved
28999if the interrupt handler performs a multiplication or division
29000operation or it calls another function.
29001
29002@end table
29003
29004@node RS/6000 and PowerPC Options
29005@subsection IBM RS/6000 and PowerPC Options
29006@cindex RS/6000 and PowerPC Options
29007@cindex IBM RS/6000 and PowerPC Options
29008
29009These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29010@table @gcctabopt
29011@item -mpowerpc-gpopt
29012@itemx -mno-powerpc-gpopt
29013@itemx -mpowerpc-gfxopt
29014@itemx -mno-powerpc-gfxopt
29015@need 800
29016@itemx -mpowerpc64
29017@itemx -mno-powerpc64
29018@itemx -mmfcrf
29019@itemx -mno-mfcrf
29020@itemx -mpopcntb
29021@itemx -mno-popcntb
29022@itemx -mpopcntd
29023@itemx -mno-popcntd
29024@itemx -mfprnd
29025@itemx -mno-fprnd
29026@need 800
29027@itemx -mcmpb
29028@itemx -mno-cmpb
29029@itemx -mhard-dfp
29030@itemx -mno-hard-dfp
29031@opindex mpowerpc-gpopt
29032@opindex mno-powerpc-gpopt
29033@opindex mpowerpc-gfxopt
29034@opindex mno-powerpc-gfxopt
29035@opindex mpowerpc64
29036@opindex mno-powerpc64
29037@opindex mmfcrf
29038@opindex mno-mfcrf
29039@opindex mpopcntb
29040@opindex mno-popcntb
29041@opindex mpopcntd
29042@opindex mno-popcntd
29043@opindex mfprnd
29044@opindex mno-fprnd
29045@opindex mcmpb
29046@opindex mno-cmpb
29047@opindex mhard-dfp
29048@opindex mno-hard-dfp
29049You use these options to specify which instructions are available on the
29050processor you are using. The default value of these options is
29051determined when configuring GCC@. Specifying the
29052@option{-mcpu=@var{cpu_type}} overrides the specification of these
29053options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29054rather than the options listed above.
29055
29056Specifying @option{-mpowerpc-gpopt} allows
29057GCC to use the optional PowerPC architecture instructions in the
29058General Purpose group, including floating-point square root. Specifying
29059@option{-mpowerpc-gfxopt} allows GCC to
29060use the optional PowerPC architecture instructions in the Graphics
29061group, including floating-point select.
29062
29063The @option{-mmfcrf} option allows GCC to generate the move from
29064condition register field instruction implemented on the POWER4
29065processor and other processors that support the PowerPC V2.01
29066architecture.
29067The @option{-mpopcntb} option allows GCC to generate the popcount and
29068double-precision FP reciprocal estimate instruction implemented on the
29069POWER5 processor and other processors that support the PowerPC V2.02
29070architecture.
29071The @option{-mpopcntd} option allows GCC to generate the popcount
29072instruction implemented on the POWER7 processor and other processors
29073that support the PowerPC V2.06 architecture.
29074The @option{-mfprnd} option allows GCC to generate the FP round to
29075integer instructions implemented on the POWER5+ processor and other
29076processors that support the PowerPC V2.03 architecture.
29077The @option{-mcmpb} option allows GCC to generate the compare bytes
29078instruction implemented on the POWER6 processor and other processors
29079that support the PowerPC V2.05 architecture.
29080The @option{-mhard-dfp} option allows GCC to generate the decimal
29081floating-point instructions implemented on some POWER processors.
29082
29083The @option{-mpowerpc64} option allows GCC to generate the additional
2908464-bit instructions that are found in the full PowerPC64 architecture
29085and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29086@option{-mno-powerpc64}.
29087
29088@item -mcpu=@var{cpu_type}
29089@opindex mcpu
29090Set architecture type, register usage, and
29091instruction scheduling parameters for machine type @var{cpu_type}.
29092Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29093@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29094@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29095@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29096@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29097@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29098@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29099@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29100@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29101@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29102@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29103@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29104
29105@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29106@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29107endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29108architecture machine types, with an appropriate, generic processor
29109model assumed for scheduling purposes.
29110
29111Specifying @samp{native} as cpu type detects and selects the
29112architecture option that corresponds to the host processor of the
29113system performing the compilation.
29114@option{-mcpu=native} has no effect if GCC does not recognize the
29115processor.
29116
29117The other options specify a specific processor. Code generated under
29118those options runs best on that processor, and may not run at all on
29119others.
29120
29121The @option{-mcpu} options automatically enable or disable the
29122following options:
29123
29124@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
29125-mpopcntb -mpopcntd -mpowerpc64 @gol
29126-mpowerpc-gpopt -mpowerpc-gfxopt @gol
29127-mmulhw -mdlmzb -mmfpgpr -mvsx @gol
29128-mcrypto -mhtm -mpower8-fusion -mpower8-vector @gol
29129-mquad-memory -mquad-memory-atomic -mfloat128 @gol
29130-mfloat128-hardware -mprefixed -mpcrel -mmma @gol
29131-mrop-protect}
29132
29133The particular options set for any particular CPU varies between
29134compiler versions, depending on what setting seems to produce optimal
29135code for that CPU; it doesn't necessarily reflect the actual hardware's
29136capabilities. If you wish to set an individual option to a particular
29137value, you may specify it after the @option{-mcpu} option, like
29138@option{-mcpu=970 -mno-altivec}.
29139
29140On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29141not enabled or disabled by the @option{-mcpu} option at present because
29142AIX does not have full support for these options. You may still
29143enable or disable them individually if you're sure it'll work in your
29144environment.
29145
29146@item -mtune=@var{cpu_type}
29147@opindex mtune
29148Set the instruction scheduling parameters for machine type
29149@var{cpu_type}, but do not set the architecture type or register usage,
29150as @option{-mcpu=@var{cpu_type}} does. The same
29151values for @var{cpu_type} are used for @option{-mtune} as for
29152@option{-mcpu}. If both are specified, the code generated uses the
29153architecture and registers set by @option{-mcpu}, but the
29154scheduling parameters set by @option{-mtune}.
29155
29156@item -mcmodel=small
29157@opindex mcmodel=small
29158Generate PowerPC64 code for the small model: The TOC is limited to
2915964k.
29160
29161@item -mcmodel=medium
29162@opindex mcmodel=medium
29163Generate PowerPC64 code for the medium model: The TOC and other static
29164data may be up to a total of 4G in size. This is the default for 64-bit
29165Linux.
29166
29167@item -mcmodel=large
29168@opindex mcmodel=large
29169Generate PowerPC64 code for the large model: The TOC may be up to 4G
29170in size. Other data and code is only limited by the 64-bit address
29171space.
29172
29173@item -maltivec
29174@itemx -mno-altivec
29175@opindex maltivec
29176@opindex mno-altivec
29177Generate code that uses (does not use) AltiVec instructions, and also
29178enable the use of built-in functions that allow more direct access to
29179the AltiVec instruction set. You may also need to set
29180@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29181enhancements.
29182
29183When @option{-maltivec} is used, the element order for AltiVec intrinsics
29184such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29185match array element order corresponding to the endianness of the
29186target. That is, element zero identifies the leftmost element in a
29187vector register when targeting a big-endian platform, and identifies
29188the rightmost element in a vector register when targeting a
29189little-endian platform.
29190
29191@item -mvrsave
29192@itemx -mno-vrsave
29193@opindex mvrsave
29194@opindex mno-vrsave
29195Generate VRSAVE instructions when generating AltiVec code.
29196
29197@item -msecure-plt
29198@opindex msecure-plt
29199Generate code that allows @command{ld} and @command{ld.so}
29200to build executables and shared
29201libraries with non-executable @code{.plt} and @code{.got} sections.
29202This is a PowerPC
2920332-bit SYSV ABI option.
29204
29205@item -mbss-plt
29206@opindex mbss-plt
29207Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29208fills in, and
29209requires @code{.plt} and @code{.got}
29210sections that are both writable and executable.
29211This is a PowerPC 32-bit SYSV ABI option.
29212
29213@item -misel
29214@itemx -mno-isel
29215@opindex misel
29216@opindex mno-isel
29217This switch enables or disables the generation of ISEL instructions.
29218
29219@item -mvsx
29220@itemx -mno-vsx
29221@opindex mvsx
29222@opindex mno-vsx
29223Generate code that uses (does not use) vector/scalar (VSX)
29224instructions, and also enable the use of built-in functions that allow
29225more direct access to the VSX instruction set.
29226
29227@item -mcrypto
29228@itemx -mno-crypto
29229@opindex mcrypto
29230@opindex mno-crypto
29231Enable the use (disable) of the built-in functions that allow direct
29232access to the cryptographic instructions that were added in version
292332.07 of the PowerPC ISA.
29234
29235@item -mhtm
29236@itemx -mno-htm
29237@opindex mhtm
29238@opindex mno-htm
29239Enable (disable) the use of the built-in functions that allow direct
29240access to the Hardware Transactional Memory (HTM) instructions that
29241were added in version 2.07 of the PowerPC ISA.
29242
29243@item -mpower8-fusion
29244@itemx -mno-power8-fusion
29245@opindex mpower8-fusion
29246@opindex mno-power8-fusion
29247Generate code that keeps (does not keeps) some integer operations
29248adjacent so that the instructions can be fused together on power8 and
29249later processors.
29250
29251@item -mpower8-vector
29252@itemx -mno-power8-vector
29253@opindex mpower8-vector
29254@opindex mno-power8-vector
29255Generate code that uses (does not use) the vector and scalar
29256instructions that were added in version 2.07 of the PowerPC ISA. Also
29257enable the use of built-in functions that allow more direct access to
29258the vector instructions.
29259
29260@item -mquad-memory
29261@itemx -mno-quad-memory
29262@opindex mquad-memory
29263@opindex mno-quad-memory
29264Generate code that uses (does not use) the non-atomic quad word memory
29265instructions. The @option{-mquad-memory} option requires use of
2926664-bit mode.
29267
29268@item -mquad-memory-atomic
29269@itemx -mno-quad-memory-atomic
29270@opindex mquad-memory-atomic
29271@opindex mno-quad-memory-atomic
29272Generate code that uses (does not use) the atomic quad word memory
29273instructions. The @option{-mquad-memory-atomic} option requires use of
2927464-bit mode.
29275
29276@item -mfloat128
29277@itemx -mno-float128
29278@opindex mfloat128
29279@opindex mno-float128
29280Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29281and use either software emulation for IEEE 128-bit floating point or
29282hardware instructions.
29283
29284The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29285128-bit floating point support. The IEEE 128-bit floating point is only
29286supported on Linux.
29287
29288The default for @option{-mfloat128} is enabled on PowerPC Linux
29289systems using the VSX instruction set, and disabled on other systems.
29290
29291If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29292@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29293point support will also enable the generation of ISA 3.0 IEEE 128-bit
29294floating point instructions. Otherwise, if you do not specify to
29295generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29296system, IEEE 128-bit floating point will be done with software
29297emulation.
29298
29299@item -mfloat128-hardware
29300@itemx -mno-float128-hardware
29301@opindex mfloat128-hardware
29302@opindex mno-float128-hardware
29303Enable/disable using ISA 3.0 hardware instructions to support the
29304@var{__float128} data type.
29305
29306The default for @option{-mfloat128-hardware} is enabled on PowerPC
29307Linux systems using the ISA 3.0 instruction set, and disabled on other
29308systems.
29309
29310@item -m32
29311@itemx -m64
29312@opindex m32
29313@opindex m64
29314Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29315targets (including GNU/Linux). The 32-bit environment sets int, long
29316and pointer to 32 bits and generates code that runs on any PowerPC
29317variant. The 64-bit environment sets int to 32 bits and long and
29318pointer to 64 bits, and generates code for PowerPC64, as for
29319@option{-mpowerpc64}.
29320
29321@item -mfull-toc
29322@itemx -mno-fp-in-toc
29323@itemx -mno-sum-in-toc
29324@itemx -mminimal-toc
29325@opindex mfull-toc
29326@opindex mno-fp-in-toc
29327@opindex mno-sum-in-toc
29328@opindex mminimal-toc
29329Modify generation of the TOC (Table Of Contents), which is created for
29330every executable file. The @option{-mfull-toc} option is selected by
29331default. In that case, GCC allocates at least one TOC entry for
29332each unique non-automatic variable reference in your program. GCC
29333also places floating-point constants in the TOC@. However, only
2933416,384 entries are available in the TOC@.
29335
29336If you receive a linker error message that saying you have overflowed
29337the available TOC space, you can reduce the amount of TOC space used
29338with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
29339@option{-mno-fp-in-toc} prevents GCC from putting floating-point
29340constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
29341generate code to calculate the sum of an address and a constant at
29342run time instead of putting that sum into the TOC@. You may specify one
29343or both of these options. Each causes GCC to produce very slightly
29344slower and larger code at the expense of conserving TOC space.
29345
29346If you still run out of space in the TOC even when you specify both of
29347these options, specify @option{-mminimal-toc} instead. This option causes
29348GCC to make only one TOC entry for every file. When you specify this
29349option, GCC produces code that is slower and larger but which
29350uses extremely little TOC space. You may wish to use this option
29351only on files that contain less frequently-executed code.
29352
29353@item -maix64
29354@itemx -maix32
29355@opindex maix64
29356@opindex maix32
29357Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
29358@code{long} type, and the infrastructure needed to support them.
29359Specifying @option{-maix64} implies @option{-mpowerpc64},
29360while @option{-maix32} disables the 64-bit ABI and
29361implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
29362
29363@item -mxl-compat
29364@itemx -mno-xl-compat
29365@opindex mxl-compat
29366@opindex mno-xl-compat
29367Produce code that conforms more closely to IBM XL compiler semantics
29368when using AIX-compatible ABI@. Pass floating-point arguments to
29369prototyped functions beyond the register save area (RSA) on the stack
29370in addition to argument FPRs. Do not assume that most significant
29371double in 128-bit long double value is properly rounded when comparing
29372values and converting to double. Use XL symbol names for long double
29373support routines.
29374
29375The AIX calling convention was extended but not initially documented to
29376handle an obscure K&R C case of calling a function that takes the
29377address of its arguments with fewer arguments than declared. IBM XL
29378compilers access floating-point arguments that do not fit in the
29379RSA from the stack when a subroutine is compiled without
29380optimization. Because always storing floating-point arguments on the
29381stack is inefficient and rarely needed, this option is not enabled by
29382default and only is necessary when calling subroutines compiled by IBM
29383XL compilers without optimization.
29384
29385@item -mpe
29386@opindex mpe
29387Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
29388application written to use message passing with special startup code to
29389enable the application to run. The system must have PE installed in the
29390standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
29391must be overridden with the @option{-specs=} option to specify the
29392appropriate directory location. The Parallel Environment does not
29393support threads, so the @option{-mpe} option and the @option{-pthread}
29394option are incompatible.
29395
29396@item -malign-natural
29397@itemx -malign-power
29398@opindex malign-natural
29399@opindex malign-power
29400On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
29401@option{-malign-natural} overrides the ABI-defined alignment of larger
29402types, such as floating-point doubles, on their natural size-based boundary.
29403The option @option{-malign-power} instructs GCC to follow the ABI-specified
29404alignment rules. GCC defaults to the standard alignment defined in the ABI@.
29405
29406On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
29407is not supported.
29408
29409@item -msoft-float
29410@itemx -mhard-float
29411@opindex msoft-float
29412@opindex mhard-float
29413Generate code that does not use (uses) the floating-point register set.
29414Software floating-point emulation is provided if you use the
29415@option{-msoft-float} option, and pass the option to GCC when linking.
29416
29417@item -mmultiple
29418@itemx -mno-multiple
29419@opindex mmultiple
29420@opindex mno-multiple
29421Generate code that uses (does not use) the load multiple word
29422instructions and the store multiple word instructions. These
29423instructions are generated by default on POWER systems, and not
29424generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
29425PowerPC systems, since those instructions do not work when the
29426processor is in little-endian mode. The exceptions are PPC740 and
29427PPC750 which permit these instructions in little-endian mode.
29428
29429@item -mupdate
29430@itemx -mno-update
29431@opindex mupdate
29432@opindex mno-update
29433Generate code that uses (does not use) the load or store instructions
29434that update the base register to the address of the calculated memory
29435location. These instructions are generated by default. If you use
29436@option{-mno-update}, there is a small window between the time that the
29437stack pointer is updated and the address of the previous frame is
29438stored, which means code that walks the stack frame across interrupts or
29439signals may get corrupted data.
29440
29441@item -mavoid-indexed-addresses
29442@itemx -mno-avoid-indexed-addresses
29443@opindex mavoid-indexed-addresses
29444@opindex mno-avoid-indexed-addresses
29445Generate code that tries to avoid (not avoid) the use of indexed load
29446or store instructions. These instructions can incur a performance
29447penalty on Power6 processors in certain situations, such as when
29448stepping through large arrays that cross a 16M boundary. This option
29449is enabled by default when targeting Power6 and disabled otherwise.
29450
29451@item -mfused-madd
29452@itemx -mno-fused-madd
29453@opindex mfused-madd
29454@opindex mno-fused-madd
29455Generate code that uses (does not use) the floating-point multiply and
29456accumulate instructions. These instructions are generated by default
29457if hardware floating point is used. The machine-dependent
29458@option{-mfused-madd} option is now mapped to the machine-independent
29459@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29460mapped to @option{-ffp-contract=off}.
29461
29462@item -mmulhw
29463@itemx -mno-mulhw
29464@opindex mmulhw
29465@opindex mno-mulhw
29466Generate code that uses (does not use) the half-word multiply and
29467multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
29468These instructions are generated by default when targeting those
29469processors.
29470
29471@item -mdlmzb
29472@itemx -mno-dlmzb
29473@opindex mdlmzb
29474@opindex mno-dlmzb
29475Generate code that uses (does not use) the string-search @samp{dlmzb}
29476instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
29477generated by default when targeting those processors.
29478
29479@item -mno-bit-align
29480@itemx -mbit-align
29481@opindex mno-bit-align
29482@opindex mbit-align
29483On System V.4 and embedded PowerPC systems do not (do) force structures
29484and unions that contain bit-fields to be aligned to the base type of the
29485bit-field.
29486
29487For example, by default a structure containing nothing but 8
29488@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
29489boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
29490the structure is aligned to a 1-byte boundary and is 1 byte in
29491size.
29492
29493@item -mno-strict-align
29494@itemx -mstrict-align
29495@opindex mno-strict-align
29496@opindex mstrict-align
29497On System V.4 and embedded PowerPC systems do not (do) assume that
29498unaligned memory references are handled by the system.
29499
29500@item -mrelocatable
29501@itemx -mno-relocatable
29502@opindex mrelocatable
29503@opindex mno-relocatable
29504Generate code that allows (does not allow) a static executable to be
29505relocated to a different address at run time. A simple embedded
29506PowerPC system loader should relocate the entire contents of
29507@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
29508a table of 32-bit addresses generated by this option. For this to
29509work, all objects linked together must be compiled with
29510@option{-mrelocatable} or @option{-mrelocatable-lib}.
29511@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
29512
29513@item -mrelocatable-lib
29514@itemx -mno-relocatable-lib
29515@opindex mrelocatable-lib
29516@opindex mno-relocatable-lib
29517Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
29518@code{.fixup} section to allow static executables to be relocated at
29519run time, but @option{-mrelocatable-lib} does not use the smaller stack
29520alignment of @option{-mrelocatable}. Objects compiled with
29521@option{-mrelocatable-lib} may be linked with objects compiled with
29522any combination of the @option{-mrelocatable} options.
29523
29524@item -mno-toc
29525@itemx -mtoc
29526@opindex mno-toc
29527@opindex mtoc
29528On System V.4 and embedded PowerPC systems do not (do) assume that
29529register 2 contains a pointer to a global area pointing to the addresses
29530used in the program.
29531
29532@item -mlittle
29533@itemx -mlittle-endian
29534@opindex mlittle
29535@opindex mlittle-endian
29536On System V.4 and embedded PowerPC systems compile code for the
29537processor in little-endian mode. The @option{-mlittle-endian} option is
29538the same as @option{-mlittle}.
29539
29540@item -mbig
29541@itemx -mbig-endian
29542@opindex mbig
29543@opindex mbig-endian
29544On System V.4 and embedded PowerPC systems compile code for the
29545processor in big-endian mode. The @option{-mbig-endian} option is
29546the same as @option{-mbig}.
29547
29548@item -mdynamic-no-pic
29549@opindex mdynamic-no-pic
29550On Darwin and Mac OS X systems, compile code so that it is not
29551relocatable, but that its external references are relocatable. The
29552resulting code is suitable for applications, but not shared
29553libraries.
29554
29555@item -msingle-pic-base
29556@opindex msingle-pic-base
29557Treat the register used for PIC addressing as read-only, rather than
29558loading it in the prologue for each function. The runtime system is
29559responsible for initializing this register with an appropriate value
29560before execution begins.
29561
29562@item -mprioritize-restricted-insns=@var{priority}
29563@opindex mprioritize-restricted-insns
29564This option controls the priority that is assigned to
29565dispatch-slot restricted instructions during the second scheduling
29566pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
29567or @samp{2} to assign no, highest, or second-highest (respectively)
29568priority to dispatch-slot restricted
29569instructions.
29570
29571@item -msched-costly-dep=@var{dependence_type}
29572@opindex msched-costly-dep
29573This option controls which dependences are considered costly
29574by the target during instruction scheduling. The argument
29575@var{dependence_type} takes one of the following values:
29576
29577@table @asis
29578@item @samp{no}
29579No dependence is costly.
29580
29581@item @samp{all}
29582All dependences are costly.
29583
29584@item @samp{true_store_to_load}
29585A true dependence from store to load is costly.
29586
29587@item @samp{store_to_load}
29588Any dependence from store to load is costly.
29589
29590@item @var{number}
29591Any dependence for which the latency is greater than or equal to
29592@var{number} is costly.
29593@end table
29594
29595@item -minsert-sched-nops=@var{scheme}
29596@opindex minsert-sched-nops
29597This option controls which NOP insertion scheme is used during
29598the second scheduling pass. The argument @var{scheme} takes one of the
29599following values:
29600
29601@table @asis
29602@item @samp{no}
29603Don't insert NOPs.
29604
29605@item @samp{pad}
29606Pad with NOPs any dispatch group that has vacant issue slots,
29607according to the scheduler's grouping.
29608
29609@item @samp{regroup_exact}
29610Insert NOPs to force costly dependent insns into
29611separate groups. Insert exactly as many NOPs as needed to force an insn
29612to a new group, according to the estimated processor grouping.
29613
29614@item @var{number}
29615Insert NOPs to force costly dependent insns into
29616separate groups. Insert @var{number} NOPs to force an insn to a new group.
29617@end table
29618
29619@item -mcall-sysv
29620@opindex mcall-sysv
29621On System V.4 and embedded PowerPC systems compile code using calling
29622conventions that adhere to the March 1995 draft of the System V
29623Application Binary Interface, PowerPC processor supplement. This is the
29624default unless you configured GCC using @samp{powerpc-*-eabiaix}.
29625
29626@item -mcall-sysv-eabi
29627@itemx -mcall-eabi
29628@opindex mcall-sysv-eabi
29629@opindex mcall-eabi
29630Specify both @option{-mcall-sysv} and @option{-meabi} options.
29631
29632@item -mcall-sysv-noeabi
29633@opindex mcall-sysv-noeabi
29634Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
29635
29636@item -mcall-aixdesc
d7971cf7 29637@opindex mcall-aixdesc
d77de738
ML
29638On System V.4 and embedded PowerPC systems compile code for the AIX
29639operating system.
29640
29641@item -mcall-linux
29642@opindex mcall-linux
29643On System V.4 and embedded PowerPC systems compile code for the
29644Linux-based GNU system.
29645
29646@item -mcall-freebsd
29647@opindex mcall-freebsd
29648On System V.4 and embedded PowerPC systems compile code for the
29649FreeBSD operating system.
29650
29651@item -mcall-netbsd
29652@opindex mcall-netbsd
29653On System V.4 and embedded PowerPC systems compile code for the
29654NetBSD operating system.
29655
29656@item -mcall-openbsd
d7971cf7 29657@opindex mcall-openbsd
d77de738
ML
29658On System V.4 and embedded PowerPC systems compile code for the
29659OpenBSD operating system.
29660
29661@item -mtraceback=@var{traceback_type}
29662@opindex mtraceback
29663Select the type of traceback table. Valid values for @var{traceback_type}
29664are @samp{full}, @samp{part}, and @samp{no}.
29665
29666@item -maix-struct-return
29667@opindex maix-struct-return
29668Return all structures in memory (as specified by the AIX ABI)@.
29669
29670@item -msvr4-struct-return
29671@opindex msvr4-struct-return
29672Return structures smaller than 8 bytes in registers (as specified by the
29673SVR4 ABI)@.
29674
29675@item -mabi=@var{abi-type}
29676@opindex mabi
29677Extend the current ABI with a particular extension, or remove such extension.
29678Valid values are: @samp{altivec}, @samp{no-altivec},
29679@samp{ibmlongdouble}, @samp{ieeelongdouble},
29680@samp{elfv1}, @samp{elfv2},
29681and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
29682
29683@item -mabi=ibmlongdouble
29684@opindex mabi=ibmlongdouble
29685Change the current ABI to use IBM extended-precision long double.
29686This is not likely to work if your system defaults to using IEEE
29687extended-precision long double. If you change the long double type
29688from IEEE extended-precision, the compiler will issue a warning unless
29689you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29690to be enabled.
29691
29692@item -mabi=ieeelongdouble
29693@opindex mabi=ieeelongdouble
29694Change the current ABI to use IEEE extended-precision long double.
29695This is not likely to work if your system defaults to using IBM
29696extended-precision long double. If you change the long double type
29697from IBM extended-precision, the compiler will issue a warning unless
29698you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29699to be enabled.
29700
29701@item -mabi=elfv1
29702@opindex mabi=elfv1
29703Change the current ABI to use the ELFv1 ABI.
29704This is the default ABI for big-endian PowerPC 64-bit Linux.
29705Overriding the default ABI requires special system support and is
29706likely to fail in spectacular ways.
29707
29708@item -mabi=elfv2
29709@opindex mabi=elfv2
29710Change the current ABI to use the ELFv2 ABI.
29711This is the default ABI for little-endian PowerPC 64-bit Linux.
29712Overriding the default ABI requires special system support and is
29713likely to fail in spectacular ways.
29714
29715@item -mgnu-attribute
29716@itemx -mno-gnu-attribute
29717@opindex mgnu-attribute
29718@opindex mno-gnu-attribute
29719Emit .gnu_attribute assembly directives to set tag/value pairs in a
29720.gnu.attributes section that specify ABI variations in function
29721parameters or return values.
29722
29723@item -mprototype
29724@itemx -mno-prototype
29725@opindex mprototype
29726@opindex mno-prototype
29727On System V.4 and embedded PowerPC systems assume that all calls to
29728variable argument functions are properly prototyped. Otherwise, the
29729compiler must insert an instruction before every non-prototyped call to
29730set or clear bit 6 of the condition code register (@code{CR}) to
29731indicate whether floating-point values are passed in the floating-point
29732registers in case the function takes variable arguments. With
29733@option{-mprototype}, only calls to prototyped variable argument functions
29734set or clear the bit.
29735
29736@item -msim
29737@opindex msim
29738On embedded PowerPC systems, assume that the startup module is called
29739@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
29740@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
29741configurations.
29742
29743@item -mmvme
29744@opindex mmvme
29745On embedded PowerPC systems, assume that the startup module is called
29746@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
29747@file{libc.a}.
29748
29749@item -mads
29750@opindex mads
29751On embedded PowerPC systems, assume that the startup module is called
29752@file{crt0.o} and the standard C libraries are @file{libads.a} and
29753@file{libc.a}.
29754
29755@item -myellowknife
29756@opindex myellowknife
29757On embedded PowerPC systems, assume that the startup module is called
29758@file{crt0.o} and the standard C libraries are @file{libyk.a} and
29759@file{libc.a}.
29760
29761@item -mvxworks
29762@opindex mvxworks
29763On System V.4 and embedded PowerPC systems, specify that you are
29764compiling for a VxWorks system.
29765
29766@item -memb
29767@opindex memb
29768On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
29769header to indicate that @samp{eabi} extended relocations are used.
29770
29771@item -meabi
29772@itemx -mno-eabi
29773@opindex meabi
29774@opindex mno-eabi
29775On System V.4 and embedded PowerPC systems do (do not) adhere to the
29776Embedded Applications Binary Interface (EABI), which is a set of
29777modifications to the System V.4 specifications. Selecting @option{-meabi}
29778means that the stack is aligned to an 8-byte boundary, a function
29779@code{__eabi} is called from @code{main} to set up the EABI
29780environment, and the @option{-msdata} option can use both @code{r2} and
29781@code{r13} to point to two separate small data areas. Selecting
29782@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
29783no EABI initialization function is called from @code{main}, and the
29784@option{-msdata} option only uses @code{r13} to point to a single
29785small data area. The @option{-meabi} option is on by default if you
29786configured GCC using one of the @samp{powerpc*-*-eabi*} options.
29787
29788@item -msdata=eabi
29789@opindex msdata=eabi
29790On System V.4 and embedded PowerPC systems, put small initialized
29791@code{const} global and static data in the @code{.sdata2} section, which
29792is pointed to by register @code{r2}. Put small initialized
29793non-@code{const} global and static data in the @code{.sdata} section,
29794which is pointed to by register @code{r13}. Put small uninitialized
29795global and static data in the @code{.sbss} section, which is adjacent to
29796the @code{.sdata} section. The @option{-msdata=eabi} option is
29797incompatible with the @option{-mrelocatable} option. The
29798@option{-msdata=eabi} option also sets the @option{-memb} option.
29799
29800@item -msdata=sysv
29801@opindex msdata=sysv
29802On System V.4 and embedded PowerPC systems, put small global and static
29803data in the @code{.sdata} section, which is pointed to by register
29804@code{r13}. Put small uninitialized global and static data in the
29805@code{.sbss} section, which is adjacent to the @code{.sdata} section.
29806The @option{-msdata=sysv} option is incompatible with the
29807@option{-mrelocatable} option.
29808
29809@item -msdata=default
29810@itemx -msdata
29811@opindex msdata=default
29812@opindex msdata
29813On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
29814compile code the same as @option{-msdata=eabi}, otherwise compile code the
29815same as @option{-msdata=sysv}.
29816
29817@item -msdata=data
29818@opindex msdata=data
29819On System V.4 and embedded PowerPC systems, put small global
29820data in the @code{.sdata} section. Put small uninitialized global
29821data in the @code{.sbss} section. Do not use register @code{r13}
29822to address small data however. This is the default behavior unless
29823other @option{-msdata} options are used.
29824
29825@item -msdata=none
29826@itemx -mno-sdata
29827@opindex msdata=none
29828@opindex mno-sdata
29829On embedded PowerPC systems, put all initialized global and static data
29830in the @code{.data} section, and all uninitialized data in the
29831@code{.bss} section.
29832
29833@item -mreadonly-in-sdata
29834@opindex mreadonly-in-sdata
29835@opindex mno-readonly-in-sdata
29836Put read-only objects in the @code{.sdata} section as well. This is the
29837default.
29838
29839@item -mblock-move-inline-limit=@var{num}
29840@opindex mblock-move-inline-limit
29841Inline all block moves (such as calls to @code{memcpy} or structure
29842copies) less than or equal to @var{num} bytes. The minimum value for
29843@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
29844targets. The default value is target-specific.
29845
29846@item -mblock-compare-inline-limit=@var{num}
29847@opindex mblock-compare-inline-limit
29848Generate non-looping inline code for all block compares (such as calls
29849to @code{memcmp} or structure compares) less than or equal to @var{num}
29850bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
29851block compare is disabled. The default value is target-specific.
29852
29853@item -mblock-compare-inline-loop-limit=@var{num}
29854@opindex mblock-compare-inline-loop-limit
29855Generate an inline expansion using loop code for all block compares that
29856are less than or equal to @var{num} bytes, but greater than the limit
29857for non-loop inline block compare expansion. If the block length is not
29858constant, at most @var{num} bytes will be compared before @code{memcmp}
29859is called to compare the remainder of the block. The default value is
29860target-specific.
29861
29862@item -mstring-compare-inline-limit=@var{num}
29863@opindex mstring-compare-inline-limit
29864Compare at most @var{num} string bytes with inline code.
29865If the difference or end of string is not found at the
29866end of the inline compare a call to @code{strcmp} or @code{strncmp} will
29867take care of the rest of the comparison. The default is 64 bytes.
29868
29869@item -G @var{num}
29870@opindex G
29871@cindex smaller data references (PowerPC)
29872@cindex .sdata/.sdata2 references (PowerPC)
29873On embedded PowerPC systems, put global and static items less than or
29874equal to @var{num} bytes into the small data or BSS sections instead of
29875the normal data or BSS section. By default, @var{num} is 8. The
29876@option{-G @var{num}} switch is also passed to the linker.
29877All modules should be compiled with the same @option{-G @var{num}} value.
29878
29879@item -mregnames
29880@itemx -mno-regnames
29881@opindex mregnames
29882@opindex mno-regnames
29883On System V.4 and embedded PowerPC systems do (do not) emit register
29884names in the assembly language output using symbolic forms.
29885
29886@item -mlongcall
29887@itemx -mno-longcall
29888@opindex mlongcall
29889@opindex mno-longcall
29890By default assume that all calls are far away so that a longer and more
29891expensive calling sequence is required. This is required for calls
29892farther than 32 megabytes (33,554,432 bytes) from the current location.
29893A short call is generated if the compiler knows
29894the call cannot be that far away. This setting can be overridden by
29895the @code{shortcall} function attribute, or by @code{#pragma
29896longcall(0)}.
29897
29898Some linkers are capable of detecting out-of-range calls and generating
29899glue code on the fly. On these systems, long calls are unnecessary and
29900generate slower code. As of this writing, the AIX linker can do this,
29901as can the GNU linker for PowerPC/64. It is planned to add this feature
29902to the GNU linker for 32-bit PowerPC systems as well.
29903
29904On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
29905GCC can generate long calls using an inline PLT call sequence (see
29906@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
29907ELFv1 (big-endian) do not support inline PLT calls.
29908
29909On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
29910callee, L42}, plus a @dfn{branch island} (glue code). The two target
29911addresses represent the callee and the branch island. The
29912Darwin/PPC linker prefers the first address and generates a @code{bl
29913callee} if the PPC @code{bl} instruction reaches the callee directly;
29914otherwise, the linker generates @code{bl L42} to call the branch
29915island. The branch island is appended to the body of the
29916calling function; it computes the full 32-bit address of the callee
29917and jumps to it.
29918
29919On Mach-O (Darwin) systems, this option directs the compiler emit to
29920the glue for every direct call, and the Darwin linker decides whether
29921to use or discard it.
29922
29923In the future, GCC may ignore all longcall specifications
29924when the linker is known to generate glue.
29925
29926@item -mpltseq
29927@itemx -mno-pltseq
29928@opindex mpltseq
29929@opindex mno-pltseq
29930Implement (do not implement) -fno-plt and long calls using an inline
29931PLT call sequence that supports lazy linking and long calls to
29932functions in dlopen'd shared libraries. Inline PLT calls are only
29933supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
29934linkers, and are enabled by default if the support is detected when
29935configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
29936configured with @option{--enable-secureplt}. @option{-mpltseq} code
29937and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
29938linked together.
29939
29940@item -mtls-markers
29941@itemx -mno-tls-markers
29942@opindex mtls-markers
29943@opindex mno-tls-markers
29944Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
29945specifying the function argument. The relocation allows the linker to
29946reliably associate function call with argument setup instructions for
29947TLS optimization, which in turn allows GCC to better schedule the
29948sequence.
29949
29950@item -mrecip
29951@itemx -mno-recip
29952@opindex mrecip
29953This option enables use of the reciprocal estimate and
29954reciprocal square root estimate instructions with additional
29955Newton-Raphson steps to increase precision instead of doing a divide or
29956square root and divide for floating-point arguments. You should use
29957the @option{-ffast-math} option when using @option{-mrecip} (or at
29958least @option{-funsafe-math-optimizations},
29959@option{-ffinite-math-only}, @option{-freciprocal-math} and
29960@option{-fno-trapping-math}). Note that while the throughput of the
29961sequence is generally higher than the throughput of the non-reciprocal
29962instruction, the precision of the sequence can be decreased by up to 2
29963ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
29964roots.
29965
29966@item -mrecip=@var{opt}
29967@opindex mrecip=opt
29968This option controls which reciprocal estimate instructions
29969may be used. @var{opt} is a comma-separated list of options, which may
29970be preceded by a @code{!} to invert the option:
29971
29972@table @samp
29973
29974@item all
29975Enable all estimate instructions.
29976
29977@item default
29978Enable the default instructions, equivalent to @option{-mrecip}.
29979
29980@item none
29981Disable all estimate instructions, equivalent to @option{-mno-recip}.
29982
29983@item div
29984Enable the reciprocal approximation instructions for both
29985single and double precision.
29986
29987@item divf
29988Enable the single-precision reciprocal approximation instructions.
29989
29990@item divd
29991Enable the double-precision reciprocal approximation instructions.
29992
29993@item rsqrt
29994Enable the reciprocal square root approximation instructions for both
29995single and double precision.
29996
29997@item rsqrtf
29998Enable the single-precision reciprocal square root approximation instructions.
29999
30000@item rsqrtd
30001Enable the double-precision reciprocal square root approximation instructions.
30002
30003@end table
30004
30005So, for example, @option{-mrecip=all,!rsqrtd} enables
30006all of the reciprocal estimate instructions, except for the
30007@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30008which handle the double-precision reciprocal square root calculations.
30009
30010@item -mrecip-precision
30011@itemx -mno-recip-precision
30012@opindex mrecip-precision
30013Assume (do not assume) that the reciprocal estimate instructions
30014provide higher-precision estimates than is mandated by the PowerPC
30015ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30016@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30017The double-precision square root estimate instructions are not generated by
30018default on low-precision machines, since they do not provide an
30019estimate that converges after three steps.
30020
30021@item -mveclibabi=@var{type}
30022@opindex mveclibabi
30023Specifies the ABI type to use for vectorizing intrinsics using an
30024external library. The only type supported at present is @samp{mass},
30025which specifies to use IBM's Mathematical Acceleration Subsystem
30026(MASS) libraries for vectorizing intrinsics using external libraries.
30027GCC currently emits calls to @code{acosd2}, @code{acosf4},
30028@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30029@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30030@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30031@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30032@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30033@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30034@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30035@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30036@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30037@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30038@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30039@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30040@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30041for power7. Both @option{-ftree-vectorize} and
30042@option{-funsafe-math-optimizations} must also be enabled. The MASS
30043libraries must be specified at link time.
30044
30045@item -mfriz
30046@itemx -mno-friz
30047@opindex mfriz
30048Generate (do not generate) the @code{friz} instruction when the
30049@option{-funsafe-math-optimizations} option is used to optimize
30050rounding of floating-point values to 64-bit integer and back to floating
30051point. The @code{friz} instruction does not return the same value if
30052the floating-point number is too large to fit in an integer.
30053
30054@item -mpointers-to-nested-functions
30055@itemx -mno-pointers-to-nested-functions
30056@opindex mpointers-to-nested-functions
30057Generate (do not generate) code to load up the static chain register
30058(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30059systems where a function pointer points to a 3-word descriptor giving
30060the function address, TOC value to be loaded in register @code{r2}, and
30061static chain value to be loaded in register @code{r11}. The
30062@option{-mpointers-to-nested-functions} is on by default. You cannot
30063call through pointers to nested functions or pointers
30064to functions compiled in other languages that use the static chain if
30065you use @option{-mno-pointers-to-nested-functions}.
30066
30067@item -msave-toc-indirect
30068@itemx -mno-save-toc-indirect
30069@opindex msave-toc-indirect
30070Generate (do not generate) code to save the TOC value in the reserved
30071stack location in the function prologue if the function calls through
30072a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30073saved in the prologue, it is saved just before the call through the
30074pointer. The @option{-mno-save-toc-indirect} option is the default.
30075
30076@item -mcompat-align-parm
30077@itemx -mno-compat-align-parm
30078@opindex mcompat-align-parm
30079Generate (do not generate) code to pass structure parameters with a
30080maximum alignment of 64 bits, for compatibility with older versions
30081of GCC.
30082
30083Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30084structure parameter on a 128-bit boundary when that structure contained
30085a member requiring 128-bit alignment. This is corrected in more
30086recent versions of GCC. This option may be used to generate code
30087that is compatible with functions compiled with older versions of
30088GCC.
30089
30090The @option{-mno-compat-align-parm} option is the default.
30091
30092@item -mstack-protector-guard=@var{guard}
30093@itemx -mstack-protector-guard-reg=@var{reg}
30094@itemx -mstack-protector-guard-offset=@var{offset}
30095@itemx -mstack-protector-guard-symbol=@var{symbol}
30096@opindex mstack-protector-guard
30097@opindex mstack-protector-guard-reg
30098@opindex mstack-protector-guard-offset
30099@opindex mstack-protector-guard-symbol
30100Generate stack protection code using canary at @var{guard}. Supported
30101locations are @samp{global} for global canary or @samp{tls} for per-thread
30102canary in the TLS block (the default with GNU libc version 2.4 or later).
30103
30104With the latter choice the options
30105@option{-mstack-protector-guard-reg=@var{reg}} and
30106@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30107which register to use as base register for reading the canary, and from what
30108offset from that base register. The default for those is as specified in the
30109relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30110the offset with a symbol reference to a canary in the TLS block.
30111
30112@item -mpcrel
30113@itemx -mno-pcrel
30114@opindex mpcrel
30115@opindex mno-pcrel
30116Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30117option requires that the medium code model (@option{-mcmodel=medium})
30118and prefixed addressing (@option{-mprefixed}) options are enabled.
30119
30120@item -mprefixed
30121@itemx -mno-prefixed
30122@opindex mprefixed
30123@opindex mno-prefixed
30124Generate (do not generate) addressing modes using prefixed load and
30125store instructions. The @option{-mprefixed} option requires that
30126the option @option{-mcpu=power10} (or later) is enabled.
30127
30128@item -mmma
30129@itemx -mno-mma
30130@opindex mmma
30131@opindex mno-mma
30132Generate (do not generate) the MMA instructions. The @option{-mma}
30133option requires that the option @option{-mcpu=power10} (or later)
30134is enabled.
30135
30136@item -mrop-protect
30137@itemx -mno-rop-protect
30138@opindex mrop-protect
30139@opindex mno-rop-protect
30140Generate (do not generate) ROP protection instructions when the target
30141processor supports them. Currently this option disables the shrink-wrap
30142optimization (@option{-fshrink-wrap}).
30143
30144@item -mprivileged
30145@itemx -mno-privileged
30146@opindex mprivileged
30147@opindex mno-privileged
30148Generate (do not generate) code that will run in privileged state.
30149
30150@item -mblock-ops-unaligned-vsx
30151@itemx -mno-block-ops-unaligned-vsx
30152@opindex block-ops-unaligned-vsx
30153@opindex no-block-ops-unaligned-vsx
30154Generate (do not generate) unaligned vsx loads and stores for
30155inline expansion of @code{memcpy} and @code{memmove}.
30156
30157@item --param rs6000-vect-unroll-limit=
30158The vectorizer will check with target information to determine whether it
30159would be beneficial to unroll the main vectorized loop and by how much. This
30160parameter sets the upper bound of how much the vectorizer will unroll the main
30161loop. The default value is four.
30162
30163@end table
30164
30165@node RX Options
30166@subsection RX Options
30167@cindex RX Options
30168
30169These command-line options are defined for RX targets:
30170
30171@table @gcctabopt
30172@item -m64bit-doubles
30173@itemx -m32bit-doubles
30174@opindex m64bit-doubles
30175@opindex m32bit-doubles
30176Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30177or 32 bits (@option{-m32bit-doubles}) in size. The default is
30178@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30179works on 32-bit values, which is why the default is
30180@option{-m32bit-doubles}.
30181
30182@item -fpu
30183@itemx -nofpu
30184@opindex fpu
30185@opindex nofpu
30186Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30187floating-point hardware. The default is enabled for the RX600
30188series and disabled for the RX200 series.
30189
30190Floating-point instructions are only generated for 32-bit floating-point
30191values, however, so the FPU hardware is not used for doubles if the
30192@option{-m64bit-doubles} option is used.
30193
30194@emph{Note} If the @option{-fpu} option is enabled then
30195@option{-funsafe-math-optimizations} is also enabled automatically.
30196This is because the RX FPU instructions are themselves unsafe.
30197
30198@item -mcpu=@var{name}
30199@opindex mcpu
30200Selects the type of RX CPU to be targeted. Currently three types are
30201supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30202the specific @samp{RX610} CPU. The default is @samp{RX600}.
30203
30204The only difference between @samp{RX600} and @samp{RX610} is that the
30205@samp{RX610} does not support the @code{MVTIPL} instruction.
30206
30207The @samp{RX200} series does not have a hardware floating-point unit
30208and so @option{-nofpu} is enabled by default when this type is
30209selected.
30210
30211@item -mbig-endian-data
30212@itemx -mlittle-endian-data
30213@opindex mbig-endian-data
30214@opindex mlittle-endian-data
30215Store data (but not code) in the big-endian format. The default is
30216@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30217format.
30218
30219@item -msmall-data-limit=@var{N}
30220@opindex msmall-data-limit
30221Specifies the maximum size in bytes of global and static variables
30222which can be placed into the small data area. Using the small data
30223area can lead to smaller and faster code, but the size of area is
30224limited and it is up to the programmer to ensure that the area does
30225not overflow. Also when the small data area is used one of the RX's
30226registers (usually @code{r13}) is reserved for use pointing to this
30227area, so it is no longer available for use by the compiler. This
30228could result in slower and/or larger code if variables are pushed onto
30229the stack instead of being held in this register.
30230
30231Note, common variables (variables that have not been initialized) and
30232constants are not placed into the small data area as they are assigned
30233to other sections in the output executable.
30234
30235The default value is zero, which disables this feature. Note, this
30236feature is not enabled by default with higher optimization levels
30237(@option{-O2} etc) because of the potentially detrimental effects of
30238reserving a register. It is up to the programmer to experiment and
30239discover whether this feature is of benefit to their program. See the
30240description of the @option{-mpid} option for a description of how the
30241actual register to hold the small data area pointer is chosen.
30242
30243@item -msim
30244@itemx -mno-sim
30245@opindex msim
30246@opindex mno-sim
30247Use the simulator runtime. The default is to use the libgloss
30248board-specific runtime.
30249
30250@item -mas100-syntax
30251@itemx -mno-as100-syntax
30252@opindex mas100-syntax
30253@opindex mno-as100-syntax
30254When generating assembler output use a syntax that is compatible with
30255Renesas's AS100 assembler. This syntax can also be handled by the GAS
30256assembler, but it has some restrictions so it is not generated by default.
30257
30258@item -mmax-constant-size=@var{N}
30259@opindex mmax-constant-size
30260Specifies the maximum size, in bytes, of a constant that can be used as
30261an operand in a RX instruction. Although the RX instruction set does
30262allow constants of up to 4 bytes in length to be used in instructions,
30263a longer value equates to a longer instruction. Thus in some
30264circumstances it can be beneficial to restrict the size of constants
30265that are used in instructions. Constants that are too big are instead
30266placed into a constant pool and referenced via register indirection.
30267
30268The value @var{N} can be between 0 and 4. A value of 0 (the default)
30269or 4 means that constants of any size are allowed.
30270
30271@item -mrelax
30272@opindex mrelax
30273Enable linker relaxation. Linker relaxation is a process whereby the
30274linker attempts to reduce the size of a program by finding shorter
30275versions of various instructions. Disabled by default.
30276
30277@item -mint-register=@var{N}
30278@opindex mint-register
30279Specify the number of registers to reserve for fast interrupt handler
30280functions. The value @var{N} can be between 0 and 4. A value of 1
30281means that register @code{r13} is reserved for the exclusive use
30282of fast interrupt handlers. A value of 2 reserves @code{r13} and
30283@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30284@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30285A value of 0, the default, does not reserve any registers.
30286
30287@item -msave-acc-in-interrupts
30288@opindex msave-acc-in-interrupts
30289Specifies that interrupt handler functions should preserve the
30290accumulator register. This is only necessary if normal code might use
30291the accumulator register, for example because it performs 64-bit
30292multiplications. The default is to ignore the accumulator as this
30293makes the interrupt handlers faster.
30294
30295@item -mpid
30296@itemx -mno-pid
30297@opindex mpid
30298@opindex mno-pid
30299Enables the generation of position independent data. When enabled any
30300access to constant data is done via an offset from a base address
30301held in a register. This allows the location of constant data to be
30302determined at run time without requiring the executable to be
30303relocated, which is a benefit to embedded applications with tight
30304memory constraints. Data that can be modified is not affected by this
30305option.
30306
30307Note, using this feature reserves a register, usually @code{r13}, for
30308the constant data base address. This can result in slower and/or
30309larger code, especially in complicated functions.
30310
30311The actual register chosen to hold the constant data base address
30312depends upon whether the @option{-msmall-data-limit} and/or the
30313@option{-mint-register} command-line options are enabled. Starting
30314with register @code{r13} and proceeding downwards, registers are
30315allocated first to satisfy the requirements of @option{-mint-register},
30316then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30317is possible for the small data area register to be @code{r8} if both
30318@option{-mint-register=4} and @option{-mpid} are specified on the
30319command line.
30320
30321By default this feature is not enabled. The default can be restored
30322via the @option{-mno-pid} command-line option.
30323
30324@item -mno-warn-multiple-fast-interrupts
30325@itemx -mwarn-multiple-fast-interrupts
30326@opindex mno-warn-multiple-fast-interrupts
30327@opindex mwarn-multiple-fast-interrupts
30328Prevents GCC from issuing a warning message if it finds more than one
30329fast interrupt handler when it is compiling a file. The default is to
30330issue a warning for each extra fast interrupt handler found, as the RX
30331only supports one such interrupt.
30332
30333@item -mallow-string-insns
30334@itemx -mno-allow-string-insns
30335@opindex mallow-string-insns
30336@opindex mno-allow-string-insns
30337Enables or disables the use of the string manipulation instructions
30338@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
30339@code{SWHILE} and also the @code{RMPA} instruction. These
30340instructions may prefetch data, which is not safe to do if accessing
30341an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
30342for more information).
30343
30344The default is to allow these instructions, but it is not possible for
30345GCC to reliably detect all circumstances where a string instruction
30346might be used to access an I/O register, so their use cannot be
30347disabled automatically. Instead it is reliant upon the programmer to
30348use the @option{-mno-allow-string-insns} option if their program
30349accesses I/O space.
30350
30351When the instructions are enabled GCC defines the C preprocessor
30352symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
30353symbol @code{__RX_DISALLOW_STRING_INSNS__}.
30354
30355@item -mjsr
30356@itemx -mno-jsr
30357@opindex mjsr
30358@opindex mno-jsr
30359Use only (or not only) @code{JSR} instructions to access functions.
30360This option can be used when code size exceeds the range of @code{BSR}
30361instructions. Note that @option{-mno-jsr} does not mean to not use
30362@code{JSR} but instead means that any type of branch may be used.
30363@end table
30364
30365@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
30366has special significance to the RX port when used with the
30367@code{interrupt} function attribute. This attribute indicates a
30368function intended to process fast interrupts. GCC ensures
30369that it only uses the registers @code{r10}, @code{r11}, @code{r12}
30370and/or @code{r13} and only provided that the normal use of the
30371corresponding registers have been restricted via the
30372@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
30373options.
30374
30375@node S/390 and zSeries Options
30376@subsection S/390 and zSeries Options
30377@cindex S/390 and zSeries Options
30378
30379These are the @samp{-m} options defined for the S/390 and zSeries architecture.
30380
30381@table @gcctabopt
30382@item -mhard-float
30383@itemx -msoft-float
30384@opindex mhard-float
30385@opindex msoft-float
30386Use (do not use) the hardware floating-point instructions and registers
30387for floating-point operations. When @option{-msoft-float} is specified,
30388functions in @file{libgcc.a} are used to perform floating-point
30389operations. When @option{-mhard-float} is specified, the compiler
30390generates IEEE floating-point instructions. This is the default.
30391
30392@item -mhard-dfp
30393@itemx -mno-hard-dfp
30394@opindex mhard-dfp
30395@opindex mno-hard-dfp
30396Use (do not use) the hardware decimal-floating-point instructions for
30397decimal-floating-point operations. When @option{-mno-hard-dfp} is
30398specified, functions in @file{libgcc.a} are used to perform
30399decimal-floating-point operations. When @option{-mhard-dfp} is
30400specified, the compiler generates decimal-floating-point hardware
30401instructions. This is the default for @option{-march=z9-ec} or higher.
30402
30403@item -mlong-double-64
30404@itemx -mlong-double-128
30405@opindex mlong-double-64
30406@opindex mlong-double-128
30407These switches control the size of @code{long double} type. A size
30408of 64 bits makes the @code{long double} type equivalent to the @code{double}
30409type. This is the default.
30410
30411@item -mbackchain
30412@itemx -mno-backchain
30413@opindex mbackchain
30414@opindex mno-backchain
30415Store (do not store) the address of the caller's frame as backchain pointer
30416into the callee's stack frame.
30417A backchain may be needed to allow debugging using tools that do not understand
30418DWARF call frame information.
30419When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
30420at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
30421the backchain is placed into the topmost word of the 96/160 byte register
30422save area.
30423
30424In general, code compiled with @option{-mbackchain} is call-compatible with
30425code compiled with @option{-mno-backchain}; however, use of the backchain
30426for debugging purposes usually requires that the whole binary is built with
30427@option{-mbackchain}. Note that the combination of @option{-mbackchain},
30428@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30429to build a linux kernel use @option{-msoft-float}.
30430
30431The default is to not maintain the backchain.
30432
30433@item -mpacked-stack
30434@itemx -mno-packed-stack
30435@opindex mpacked-stack
30436@opindex mno-packed-stack
30437Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
30438specified, the compiler uses the all fields of the 96/160 byte register save
30439area only for their default purpose; unused fields still take up stack space.
30440When @option{-mpacked-stack} is specified, register save slots are densely
30441packed at the top of the register save area; unused space is reused for other
30442purposes, allowing for more efficient use of the available stack space.
30443However, when @option{-mbackchain} is also in effect, the topmost word of
30444the save area is always used to store the backchain, and the return address
30445register is always saved two words below the backchain.
30446
30447As long as the stack frame backchain is not used, code generated with
30448@option{-mpacked-stack} is call-compatible with code generated with
30449@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
30450S/390 or zSeries generated code that uses the stack frame backchain at run
30451time, not just for debugging purposes. Such code is not call-compatible
30452with code compiled with @option{-mpacked-stack}. Also, note that the
30453combination of @option{-mbackchain},
30454@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30455to build a linux kernel use @option{-msoft-float}.
30456
30457The default is to not use the packed stack layout.
30458
30459@item -msmall-exec
30460@itemx -mno-small-exec
30461@opindex msmall-exec
30462@opindex mno-small-exec
30463Generate (or do not generate) code using the @code{bras} instruction
30464to do subroutine calls.
30465This only works reliably if the total executable size does not
30466exceed 64k. The default is to use the @code{basr} instruction instead,
30467which does not have this limitation.
30468
30469@item -m64
30470@itemx -m31
30471@opindex m64
30472@opindex m31
30473When @option{-m31} is specified, generate code compliant to the
30474GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
30475code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
30476particular to generate 64-bit instructions. For the @samp{s390}
30477targets, the default is @option{-m31}, while the @samp{s390x}
30478targets default to @option{-m64}.
30479
30480@item -mzarch
30481@itemx -mesa
30482@opindex mzarch
30483@opindex mesa
30484When @option{-mzarch} is specified, generate code using the
30485instructions available on z/Architecture.
30486When @option{-mesa} is specified, generate code using the
30487instructions available on ESA/390. Note that @option{-mesa} is
30488not possible with @option{-m64}.
30489When generating code compliant to the GNU/Linux for S/390 ABI,
30490the default is @option{-mesa}. When generating code compliant
30491to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
30492
30493@item -mhtm
30494@itemx -mno-htm
30495@opindex mhtm
30496@opindex mno-htm
30497The @option{-mhtm} option enables a set of builtins making use of
30498instructions available with the transactional execution facility
30499introduced with the IBM zEnterprise EC12 machine generation
30500@ref{S/390 System z Built-in Functions}.
30501@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
30502
30503@item -mvx
30504@itemx -mno-vx
30505@opindex mvx
30506@opindex mno-vx
30507When @option{-mvx} is specified, generate code using the instructions
30508available with the vector extension facility introduced with the IBM
30509z13 machine generation.
30510This option changes the ABI for some vector type values with regard to
30511alignment and calling conventions. In case vector type values are
30512being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
30513command will be added to mark the resulting binary with the ABI used.
30514@option{-mvx} is enabled by default when using @option{-march=z13}.
30515
30516@item -mzvector
30517@itemx -mno-zvector
30518@opindex mzvector
30519@opindex mno-zvector
30520The @option{-mzvector} option enables vector language extensions and
30521builtins using instructions available with the vector extension
30522facility introduced with the IBM z13 machine generation.
30523This option adds support for @samp{vector} to be used as a keyword to
30524define vector type variables and arguments. @samp{vector} is only
30525available when GNU extensions are enabled. It will not be expanded
30526when requesting strict standard compliance e.g.@: with @option{-std=c99}.
30527In addition to the GCC low-level builtins @option{-mzvector} enables
30528a set of builtins added for compatibility with AltiVec-style
30529implementations like Power and Cell. In order to make use of these
30530builtins the header file @file{vecintrin.h} needs to be included.
30531@option{-mzvector} is disabled by default.
30532
30533@item -mmvcle
30534@itemx -mno-mvcle
30535@opindex mmvcle
30536@opindex mno-mvcle
30537Generate (or do not generate) code using the @code{mvcle} instruction
30538to perform block moves. When @option{-mno-mvcle} is specified,
30539use a @code{mvc} loop instead. This is the default unless optimizing for
30540size.
30541
30542@item -mdebug
30543@itemx -mno-debug
30544@opindex mdebug
30545@opindex mno-debug
30546Print (or do not print) additional debug information when compiling.
30547The default is to not print debug information.
30548
30549@item -march=@var{cpu-type}
30550@opindex march
30551Generate code that runs on @var{cpu-type}, which is the name of a
30552system representing a certain processor type. Possible values for
30553@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
30554@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
30555@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
30556@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
30557@samp{z16}/@samp{arch14}, and @samp{native}.
30558
30559The default is @option{-march=z900}.
30560
30561Specifying @samp{native} as cpu type can be used to select the best
30562architecture option for the host processor.
30563@option{-march=native} has no effect if GCC does not recognize the
30564processor.
30565
30566@item -mtune=@var{cpu-type}
30567@opindex mtune
30568Tune to @var{cpu-type} everything applicable about the generated code,
30569except for the ABI and the set of available instructions.
30570The list of @var{cpu-type} values is the same as for @option{-march}.
30571The default is the value used for @option{-march}.
30572
30573@item -mtpf-trace
30574@itemx -mno-tpf-trace
30575@opindex mtpf-trace
30576@opindex mno-tpf-trace
30577Generate code that adds (does not add) in TPF OS specific branches to trace
30578routines in the operating system. This option is off by default, even
30579when compiling for the TPF OS@.
30580
30581@item -mtpf-trace-skip
30582@itemx -mno-tpf-trace-skip
30583@opindex mtpf-trace-skip
30584@opindex mno-tpf-trace-skip
30585Generate code that changes (does not change) the default branch
30586targets enabled by @option{-mtpf-trace} to point to specialized trace
30587routines providing the ability of selectively skipping function trace
30588entries for the TPF OS. This option is off by default, even when
30589compiling for the TPF OS and specifying @option{-mtpf-trace}.
30590
30591@item -mfused-madd
30592@itemx -mno-fused-madd
30593@opindex mfused-madd
30594@opindex mno-fused-madd
30595Generate code that uses (does not use) the floating-point multiply and
30596accumulate instructions. These instructions are generated by default if
30597hardware floating point is used.
30598
30599@item -mwarn-framesize=@var{framesize}
30600@opindex mwarn-framesize
30601Emit a warning if the current function exceeds the given frame size. Because
30602this is a compile-time check it doesn't need to be a real problem when the program
30603runs. It is intended to identify functions that most probably cause
30604a stack overflow. It is useful to be used in an environment with limited stack
30605size e.g.@: the linux kernel.
30606
30607@item -mwarn-dynamicstack
30608@opindex mwarn-dynamicstack
30609Emit a warning if the function calls @code{alloca} or uses dynamically-sized
30610arrays. This is generally a bad idea with a limited stack size.
30611
30612@item -mstack-guard=@var{stack-guard}
30613@itemx -mstack-size=@var{stack-size}
30614@opindex mstack-guard
30615@opindex mstack-size
30616If these options are provided the S/390 back end emits additional instructions in
30617the function prologue that trigger a trap if the stack size is @var{stack-guard}
30618bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
30619If the @var{stack-guard} option is omitted the smallest power of 2 larger than
30620the frame size of the compiled function is chosen.
30621These options are intended to be used to help debugging stack overflow problems.
30622The additionally emitted code causes only little overhead and hence can also be
30623used in production-like systems without greater performance degradation. The given
30624values have to be exact powers of 2 and @var{stack-size} has to be greater than
30625@var{stack-guard} without exceeding 64k.
30626In order to be efficient the extra code makes the assumption that the stack starts
30627at an address aligned to the value given by @var{stack-size}.
30628The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
30629
30630@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
30631@opindex mhotpatch
30632If the hotpatch option is enabled, a ``hot-patching'' function
30633prologue is generated for all functions in the compilation unit.
30634The funtion label is prepended with the given number of two-byte
30635NOP instructions (@var{pre-halfwords}, maximum 1000000). After
30636the label, 2 * @var{post-halfwords} bytes are appended, using the
30637largest NOP like instructions the architecture allows (maximum
306381000000).
30639
30640If both arguments are zero, hotpatching is disabled.
30641
30642This option can be overridden for individual functions with the
30643@code{hotpatch} attribute.
30644@end table
30645
d77de738
ML
30646@node SH Options
30647@subsection SH Options
30648
30649These @samp{-m} options are defined for the SH implementations:
30650
30651@table @gcctabopt
30652@item -m1
30653@opindex m1
30654Generate code for the SH1.
30655
30656@item -m2
30657@opindex m2
30658Generate code for the SH2.
30659
30660@item -m2e
30661Generate code for the SH2e.
30662
30663@item -m2a-nofpu
30664@opindex m2a-nofpu
30665Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
30666that the floating-point unit is not used.
30667
30668@item -m2a-single-only
30669@opindex m2a-single-only
30670Generate code for the SH2a-FPU, in such a way that no double-precision
30671floating-point operations are used.
30672
30673@item -m2a-single
30674@opindex m2a-single
30675Generate code for the SH2a-FPU assuming the floating-point unit is in
30676single-precision mode by default.
30677
30678@item -m2a
30679@opindex m2a
30680Generate code for the SH2a-FPU assuming the floating-point unit is in
30681double-precision mode by default.
30682
30683@item -m3
30684@opindex m3
30685Generate code for the SH3.
30686
30687@item -m3e
30688@opindex m3e
30689Generate code for the SH3e.
30690
30691@item -m4-nofpu
30692@opindex m4-nofpu
30693Generate code for the SH4 without a floating-point unit.
30694
30695@item -m4-single-only
30696@opindex m4-single-only
30697Generate code for the SH4 with a floating-point unit that only
30698supports single-precision arithmetic.
30699
30700@item -m4-single
30701@opindex m4-single
30702Generate code for the SH4 assuming the floating-point unit is in
30703single-precision mode by default.
30704
30705@item -m4
30706@opindex m4
30707Generate code for the SH4.
30708
30709@item -m4-100
30710@opindex m4-100
30711Generate code for SH4-100.
30712
30713@item -m4-100-nofpu
30714@opindex m4-100-nofpu
30715Generate code for SH4-100 in such a way that the
30716floating-point unit is not used.
30717
30718@item -m4-100-single
30719@opindex m4-100-single
30720Generate code for SH4-100 assuming the floating-point unit is in
30721single-precision mode by default.
30722
30723@item -m4-100-single-only
30724@opindex m4-100-single-only
30725Generate code for SH4-100 in such a way that no double-precision
30726floating-point operations are used.
30727
30728@item -m4-200
30729@opindex m4-200
30730Generate code for SH4-200.
30731
30732@item -m4-200-nofpu
30733@opindex m4-200-nofpu
30734Generate code for SH4-200 without in such a way that the
30735floating-point unit is not used.
30736
30737@item -m4-200-single
30738@opindex m4-200-single
30739Generate code for SH4-200 assuming the floating-point unit is in
30740single-precision mode by default.
30741
30742@item -m4-200-single-only
30743@opindex m4-200-single-only
30744Generate code for SH4-200 in such a way that no double-precision
30745floating-point operations are used.
30746
30747@item -m4-300
30748@opindex m4-300
30749Generate code for SH4-300.
30750
30751@item -m4-300-nofpu
30752@opindex m4-300-nofpu
30753Generate code for SH4-300 without in such a way that the
30754floating-point unit is not used.
30755
30756@item -m4-300-single
30757@opindex m4-300-single
30758Generate code for SH4-300 in such a way that no double-precision
30759floating-point operations are used.
30760
30761@item -m4-300-single-only
30762@opindex m4-300-single-only
30763Generate code for SH4-300 in such a way that no double-precision
30764floating-point operations are used.
30765
30766@item -m4-340
30767@opindex m4-340
30768Generate code for SH4-340 (no MMU, no FPU).
30769
30770@item -m4-500
30771@opindex m4-500
30772Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
30773assembler.
30774
30775@item -m4a-nofpu
30776@opindex m4a-nofpu
30777Generate code for the SH4al-dsp, or for a SH4a in such a way that the
30778floating-point unit is not used.
30779
30780@item -m4a-single-only
30781@opindex m4a-single-only
30782Generate code for the SH4a, in such a way that no double-precision
30783floating-point operations are used.
30784
30785@item -m4a-single
30786@opindex m4a-single
30787Generate code for the SH4a assuming the floating-point unit is in
30788single-precision mode by default.
30789
30790@item -m4a
30791@opindex m4a
30792Generate code for the SH4a.
30793
30794@item -m4al
30795@opindex m4al
30796Same as @option{-m4a-nofpu}, except that it implicitly passes
30797@option{-dsp} to the assembler. GCC doesn't generate any DSP
30798instructions at the moment.
30799
30800@item -mb
30801@opindex mb
30802Compile code for the processor in big-endian mode.
30803
30804@item -ml
30805@opindex ml
30806Compile code for the processor in little-endian mode.
30807
30808@item -mdalign
30809@opindex mdalign
30810Align doubles at 64-bit boundaries. Note that this changes the calling
30811conventions, and thus some functions from the standard C library do
30812not work unless you recompile it first with @option{-mdalign}.
30813
30814@item -mrelax
30815@opindex mrelax
30816Shorten some address references at link time, when possible; uses the
30817linker option @option{-relax}.
30818
30819@item -mbigtable
30820@opindex mbigtable
30821Use 32-bit offsets in @code{switch} tables. The default is to use
3082216-bit offsets.
30823
30824@item -mbitops
30825@opindex mbitops
30826Enable the use of bit manipulation instructions on SH2A.
30827
30828@item -mfmovd
30829@opindex mfmovd
30830Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
30831alignment constraints.
30832
30833@item -mrenesas
30834@opindex mrenesas
30835Comply with the calling conventions defined by Renesas.
30836
30837@item -mno-renesas
30838@opindex mno-renesas
30839Comply with the calling conventions defined for GCC before the Renesas
30840conventions were available. This option is the default for all
30841targets of the SH toolchain.
30842
30843@item -mnomacsave
30844@opindex mnomacsave
30845Mark the @code{MAC} register as call-clobbered, even if
30846@option{-mrenesas} is given.
30847
30848@item -mieee
30849@itemx -mno-ieee
30850@opindex mieee
30851@opindex mno-ieee
30852Control the IEEE compliance of floating-point comparisons, which affects the
30853handling of cases where the result of a comparison is unordered. By default
30854@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
30855enabled @option{-mno-ieee} is implicitly set, which results in faster
30856floating-point greater-equal and less-equal comparisons. The implicit settings
30857can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
30858
30859@item -minline-ic_invalidate
30860@opindex minline-ic_invalidate
30861Inline code to invalidate instruction cache entries after setting up
30862nested function trampolines.
30863This option has no effect if @option{-musermode} is in effect and the selected
30864code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
30865instruction.
30866If the selected code generation option does not allow the use of the @code{icbi}
30867instruction, and @option{-musermode} is not in effect, the inlined code
30868manipulates the instruction cache address array directly with an associative
30869write. This not only requires privileged mode at run time, but it also
30870fails if the cache line had been mapped via the TLB and has become unmapped.
30871
30872@item -misize
30873@opindex misize
30874Dump instruction size and location in the assembly code.
30875
30876@item -mpadstruct
30877@opindex mpadstruct
30878This option is deprecated. It pads structures to multiple of 4 bytes,
30879which is incompatible with the SH ABI@.
30880
30881@item -matomic-model=@var{model}
30882@opindex matomic-model=@var{model}
30883Sets the model of atomic operations and additional parameters as a comma
30884separated list. For details on the atomic built-in functions see
30885@ref{__atomic Builtins}. The following models and parameters are supported:
30886
30887@table @samp
30888
30889@item none
30890Disable compiler generated atomic sequences and emit library calls for atomic
30891operations. This is the default if the target is not @code{sh*-*-linux*}.
30892
30893@item soft-gusa
30894Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
30895built-in functions. The generated atomic sequences require additional support
30896from the interrupt/exception handling code of the system and are only suitable
30897for SH3* and SH4* single-core systems. This option is enabled by default when
30898the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
30899this option also partially utilizes the hardware atomic instructions
30900@code{movli.l} and @code{movco.l} to create more efficient code, unless
30901@samp{strict} is specified.
30902
30903@item soft-tcb
30904Generate software atomic sequences that use a variable in the thread control
30905block. This is a variation of the gUSA sequences which can also be used on
30906SH1* and SH2* targets. The generated atomic sequences require additional
30907support from the interrupt/exception handling code of the system and are only
30908suitable for single-core systems. When using this model, the @samp{gbr-offset=}
30909parameter has to be specified as well.
30910
30911@item soft-imask
30912Generate software atomic sequences that temporarily disable interrupts by
30913setting @code{SR.IMASK = 1111}. This model works only when the program runs
30914in privileged mode and is only suitable for single-core systems. Additional
30915support from the interrupt/exception handling code of the system is not
30916required. This model is enabled by default when the target is
30917@code{sh*-*-linux*} and SH1* or SH2*.
30918
30919@item hard-llcs
30920Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
30921instructions only. This is only available on SH4A and is suitable for
30922multi-core systems. Since the hardware instructions support only 32 bit atomic
30923variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
30924Code compiled with this option is also compatible with other software
30925atomic model interrupt/exception handling systems if executed on an SH4A
30926system. Additional support from the interrupt/exception handling code of the
30927system is not required for this model.
30928
30929@item gbr-offset=
30930This parameter specifies the offset in bytes of the variable in the thread
30931control block structure that should be used by the generated atomic sequences
30932when the @samp{soft-tcb} model has been selected. For other models this
30933parameter is ignored. The specified value must be an integer multiple of four
30934and in the range 0-1020.
30935
30936@item strict
30937This parameter prevents mixed usage of multiple atomic models, even if they
30938are compatible, and makes the compiler generate atomic sequences of the
30939specified model only.
30940
30941@end table
30942
30943@item -mtas
30944@opindex mtas
30945Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
30946Notice that depending on the particular hardware and software configuration
30947this can degrade overall performance due to the operand cache line flushes
30948that are implied by the @code{tas.b} instruction. On multi-core SH4A
30949processors the @code{tas.b} instruction must be used with caution since it
30950can result in data corruption for certain cache configurations.
30951
30952@item -mprefergot
30953@opindex mprefergot
30954When generating position-independent code, emit function calls using
30955the Global Offset Table instead of the Procedure Linkage Table.
30956
30957@item -musermode
30958@itemx -mno-usermode
30959@opindex musermode
30960@opindex mno-usermode
30961Don't allow (allow) the compiler generating privileged mode code. Specifying
30962@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
30963inlined code would not work in user mode. @option{-musermode} is the default
30964when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
30965@option{-musermode} has no effect, since there is no user mode.
30966
30967@item -multcost=@var{number}
30968@opindex multcost=@var{number}
30969Set the cost to assume for a multiply insn.
30970
30971@item -mdiv=@var{strategy}
30972@opindex mdiv=@var{strategy}
30973Set the division strategy to be used for integer division operations.
30974@var{strategy} can be one of:
30975
30976@table @samp
30977
30978@item call-div1
30979Calls a library function that uses the single-step division instruction
30980@code{div1} to perform the operation. Division by zero calculates an
30981unspecified result and does not trap. This is the default except for SH4,
30982SH2A and SHcompact.
30983
30984@item call-fp
30985Calls a library function that performs the operation in double precision
30986floating point. Division by zero causes a floating-point exception. This is
30987the default for SHcompact with FPU. Specifying this for targets that do not
30988have a double precision FPU defaults to @code{call-div1}.
30989
30990@item call-table
30991Calls a library function that uses a lookup table for small divisors and
30992the @code{div1} instruction with case distinction for larger divisors. Division
30993by zero calculates an unspecified result and does not trap. This is the default
30994for SH4. Specifying this for targets that do not have dynamic shift
30995instructions defaults to @code{call-div1}.
30996
30997@end table
30998
30999When a division strategy has not been specified the default strategy is
31000selected based on the current target. For SH2A the default strategy is to
31001use the @code{divs} and @code{divu} instructions instead of library function
31002calls.
31003
31004@item -maccumulate-outgoing-args
31005@opindex maccumulate-outgoing-args
31006Reserve space once for outgoing arguments in the function prologue rather
31007than around each call. Generally beneficial for performance and size. Also
31008needed for unwinding to avoid changing the stack frame around conditional code.
31009
31010@item -mdivsi3_libfunc=@var{name}
31011@opindex mdivsi3_libfunc=@var{name}
31012Set the name of the library function used for 32-bit signed division to
31013@var{name}.
31014This only affects the name used in the @samp{call} division strategies, and
31015the compiler still expects the same sets of input/output/clobbered registers as
31016if this option were not present.
31017
31018@item -mfixed-range=@var{register-range}
31019@opindex mfixed-range
31020Generate code treating the given register range as fixed registers.
31021A fixed register is one that the register allocator cannot use. This is
31022useful when compiling kernel code. A register range is specified as
31023two registers separated by a dash. Multiple register ranges can be
31024specified separated by a comma.
31025
31026@item -mbranch-cost=@var{num}
31027@opindex mbranch-cost=@var{num}
31028Assume @var{num} to be the cost for a branch instruction. Higher numbers
31029make the compiler try to generate more branch-free code if possible.
31030If not specified the value is selected depending on the processor type that
31031is being compiled for.
31032
31033@item -mzdcbranch
31034@itemx -mno-zdcbranch
31035@opindex mzdcbranch
31036@opindex mno-zdcbranch
31037Assume (do not assume) that zero displacement conditional branch instructions
31038@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31039compiler prefers zero displacement branch code sequences. This is
31040enabled by default when generating code for SH4 and SH4A. It can be explicitly
31041disabled by specifying @option{-mno-zdcbranch}.
31042
31043@item -mcbranch-force-delay-slot
31044@opindex mcbranch-force-delay-slot
31045Force the usage of delay slots for conditional branches, which stuffs the delay
31046slot with a @code{nop} if a suitable instruction cannot be found. By default
31047this option is disabled. It can be enabled to work around hardware bugs as
31048found in the original SH7055.
31049
31050@item -mfused-madd
31051@itemx -mno-fused-madd
31052@opindex mfused-madd
31053@opindex mno-fused-madd
31054Generate code that uses (does not use) the floating-point multiply and
31055accumulate instructions. These instructions are generated by default
31056if hardware floating point is used. The machine-dependent
31057@option{-mfused-madd} option is now mapped to the machine-independent
31058@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31059mapped to @option{-ffp-contract=off}.
31060
31061@item -mfsca
31062@itemx -mno-fsca
31063@opindex mfsca
31064@opindex mno-fsca
31065Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31066and cosine approximations. The option @option{-mfsca} must be used in
31067combination with @option{-funsafe-math-optimizations}. It is enabled by default
31068when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31069approximations even if @option{-funsafe-math-optimizations} is in effect.
31070
31071@item -mfsrra
31072@itemx -mno-fsrra
31073@opindex mfsrra
31074@opindex mno-fsrra
31075Allow or disallow the compiler to emit the @code{fsrra} instruction for
31076reciprocal square root approximations. The option @option{-mfsrra} must be used
31077in combination with @option{-funsafe-math-optimizations} and
31078@option{-ffinite-math-only}. It is enabled by default when generating code for
31079SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31080even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31081in effect.
31082
31083@item -mpretend-cmove
31084@opindex mpretend-cmove
31085Prefer zero-displacement conditional branches for conditional move instruction
31086patterns. This can result in faster code on the SH4 processor.
31087
31088@item -mfdpic
31089@opindex fdpic
31090Generate code using the FDPIC ABI.
31091
31092@end table
31093
31094@node Solaris 2 Options
31095@subsection Solaris 2 Options
31096@cindex Solaris 2 options
31097
31098These @samp{-m} options are supported on Solaris 2:
31099
31100@table @gcctabopt
31101@item -mclear-hwcap
31102@opindex mclear-hwcap
31103@option{-mclear-hwcap} tells the compiler to remove the hardware
31104capabilities generated by the Solaris assembler. This is only necessary
31105when object files use ISA extensions not supported by the current
31106machine, but check at runtime whether or not to use them.
31107
31108@item -mimpure-text
31109@opindex mimpure-text
31110@option{-mimpure-text}, used in addition to @option{-shared}, tells
31111the compiler to not pass @option{-z text} to the linker when linking a
31112shared object. Using this option, you can link position-dependent
31113code into a shared object.
31114
31115@option{-mimpure-text} suppresses the ``relocations remain against
31116allocatable but non-writable sections'' linker error message.
31117However, the necessary relocations trigger copy-on-write, and the
31118shared object is not actually shared across processes. Instead of
31119using @option{-mimpure-text}, you should compile all source code with
31120@option{-fpic} or @option{-fPIC}.
31121
31122@end table
31123
31124These switches are supported in addition to the above on Solaris 2:
31125
31126@table @gcctabopt
31127@item -pthreads
31128@opindex pthreads
31129This is a synonym for @option{-pthread}.
31130@end table
31131
31132@node SPARC Options
31133@subsection SPARC Options
31134@cindex SPARC options
31135
31136These @samp{-m} options are supported on the SPARC:
31137
31138@table @gcctabopt
31139@item -mno-app-regs
31140@itemx -mapp-regs
31141@opindex mno-app-regs
31142@opindex mapp-regs
31143Specify @option{-mapp-regs} to generate output using the global registers
311442 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31145global register 1, each global register 2 through 4 is then treated as an
31146allocable register that is clobbered by function calls. This is the default.
31147
31148To be fully SVR4 ABI-compliant at the cost of some performance loss,
31149specify @option{-mno-app-regs}. You should compile libraries and system
31150software with this option.
31151
31152@item -mflat
31153@itemx -mno-flat
31154@opindex mflat
31155@opindex mno-flat
31156With @option{-mflat}, the compiler does not generate save/restore instructions
31157and uses a ``flat'' or single register window model. This model is compatible
31158with the regular register window model. The local registers and the input
31159registers (0--5) are still treated as ``call-saved'' registers and are
31160saved on the stack as needed.
31161
31162With @option{-mno-flat} (the default), the compiler generates save/restore
31163instructions (except for leaf functions). This is the normal operating mode.
31164
31165@item -mfpu
31166@itemx -mhard-float
31167@opindex mfpu
31168@opindex mhard-float
31169Generate output containing floating-point instructions. This is the
31170default.
31171
31172@item -mno-fpu
31173@itemx -msoft-float
31174@opindex mno-fpu
31175@opindex msoft-float
31176Generate output containing library calls for floating point.
31177@strong{Warning:} the requisite libraries are not available for all SPARC
31178targets. Normally the facilities of the machine's usual C compiler are
31179used, but this cannot be done directly in cross-compilation. You must make
31180your own arrangements to provide suitable library functions for
31181cross-compilation. The embedded targets @samp{sparc-*-aout} and
31182@samp{sparclite-*-*} do provide software floating-point support.
31183
31184@option{-msoft-float} changes the calling convention in the output file;
31185therefore, it is only useful if you compile @emph{all} of a program with
31186this option. In particular, you need to compile @file{libgcc.a}, the
31187library that comes with GCC, with @option{-msoft-float} in order for
31188this to work.
31189
31190@item -mhard-quad-float
31191@opindex mhard-quad-float
31192Generate output containing quad-word (long double) floating-point
31193instructions.
31194
31195@item -msoft-quad-float
31196@opindex msoft-quad-float
31197Generate output containing library calls for quad-word (long double)
31198floating-point instructions. The functions called are those specified
31199in the SPARC ABI@. This is the default.
31200
31201As of this writing, there are no SPARC implementations that have hardware
31202support for the quad-word floating-point instructions. They all invoke
31203a trap handler for one of these instructions, and then the trap handler
31204emulates the effect of the instruction. Because of the trap handler overhead,
31205this is much slower than calling the ABI library routines. Thus the
31206@option{-msoft-quad-float} option is the default.
31207
31208@item -mno-unaligned-doubles
31209@itemx -munaligned-doubles
31210@opindex mno-unaligned-doubles
31211@opindex munaligned-doubles
31212Assume that doubles have 8-byte alignment. This is the default.
31213
31214With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31215alignment only if they are contained in another type, or if they have an
31216absolute address. Otherwise, it assumes they have 4-byte alignment.
31217Specifying this option avoids some rare compatibility problems with code
31218generated by other compilers. It is not the default because it results
31219in a performance loss, especially for floating-point code.
31220
31221@item -muser-mode
31222@itemx -mno-user-mode
31223@opindex muser-mode
31224@opindex mno-user-mode
31225Do not generate code that can only run in supervisor mode. This is relevant
31226only for the @code{casa} instruction emitted for the LEON3 processor. This
31227is the default.
31228
31229@item -mfaster-structs
31230@itemx -mno-faster-structs
31231@opindex mfaster-structs
31232@opindex mno-faster-structs
31233With @option{-mfaster-structs}, the compiler assumes that structures
31234should have 8-byte alignment. This enables the use of pairs of
31235@code{ldd} and @code{std} instructions for copies in structure
31236assignment, in place of twice as many @code{ld} and @code{st} pairs.
31237However, the use of this changed alignment directly violates the SPARC
31238ABI@. Thus, it's intended only for use on targets where the developer
31239acknowledges that their resulting code is not directly in line with
31240the rules of the ABI@.
31241
31242@item -mstd-struct-return
31243@itemx -mno-std-struct-return
31244@opindex mstd-struct-return
31245@opindex mno-std-struct-return
31246With @option{-mstd-struct-return}, the compiler generates checking code
31247in functions returning structures or unions to detect size mismatches
31248between the two sides of function calls, as per the 32-bit ABI@.
31249
31250The default is @option{-mno-std-struct-return}. This option has no effect
31251in 64-bit mode.
31252
31253@item -mlra
31254@itemx -mno-lra
31255@opindex mlra
31256@opindex mno-lra
31257Enable Local Register Allocation. This is the default for SPARC since GCC 7
31258so @option{-mno-lra} needs to be passed to get old Reload.
31259
31260@item -mcpu=@var{cpu_type}
31261@opindex mcpu
31262Set the instruction set, register set, and instruction scheduling parameters
31263for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31264@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31265@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31266@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31267@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31268@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31269@samp{m8}.
31270
31271Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31272which selects the best architecture option for the host processor.
31273@option{-mcpu=native} has no effect if GCC does not recognize
31274the processor.
31275
31276Default instruction scheduling parameters are used for values that select
31277an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31278@samp{sparclite}, @samp{sparclet}, @samp{v9}.
31279
31280Here is a list of each supported architecture and their supported
31281implementations.
31282
31283@table @asis
31284@item v7
31285cypress, leon3v7
31286
31287@item v8
31288supersparc, hypersparc, leon, leon3, leon5
31289
31290@item sparclite
31291f930, f934, sparclite86x
31292
31293@item sparclet
31294tsc701
31295
31296@item v9
31297ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31298niagara7, m8
31299@end table
31300
31301By default (unless configured otherwise), GCC generates code for the V7
31302variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31303additionally optimizes it for the Cypress CY7C602 chip, as used in the
31304SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31305SPARCStation 1, 2, IPX etc.
31306
31307With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31308architecture. The only difference from V7 code is that the compiler emits
31309the integer multiply and integer divide instructions which exist in SPARC-V8
31310but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31311optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
313122000 series.
31313
31314With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31315the SPARC architecture. This adds the integer multiply, integer divide step
31316and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31317With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31318Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31319@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31320MB86934 chip, which is the more recent SPARClite with FPU@.
31321
31322With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31323the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31324integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31325but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31326optimizes it for the TEMIC SPARClet chip.
31327
31328With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31329architecture. This adds 64-bit integer and floating-point move instructions,
313303 additional floating-point condition code registers and conditional move
31331instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31332optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31333@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31334Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31335@option{-mcpu=niagara}, the compiler additionally optimizes it for
31336Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31337additionally optimizes it for Sun UltraSPARC T2 chips. With
31338@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
31339UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
31340additionally optimizes it for Sun UltraSPARC T4 chips. With
31341@option{-mcpu=niagara7}, the compiler additionally optimizes it for
31342Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
31343additionally optimizes it for Oracle M8 chips.
31344
31345@item -mtune=@var{cpu_type}
31346@opindex mtune
31347Set the instruction scheduling parameters for machine type
31348@var{cpu_type}, but do not set the instruction set or register set that the
31349option @option{-mcpu=@var{cpu_type}} does.
31350
31351The same values for @option{-mcpu=@var{cpu_type}} can be used for
31352@option{-mtune=@var{cpu_type}}, but the only useful values are those
31353that select a particular CPU implementation. Those are
31354@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
31355@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
31356@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
31357@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
31358@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
31359and GNU/Linux toolchains, @samp{native} can also be used.
31360
31361@item -mv8plus
31362@itemx -mno-v8plus
31363@opindex mv8plus
31364@opindex mno-v8plus
31365With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
31366difference from the V8 ABI is that the global and out registers are
31367considered 64 bits wide. This is enabled by default on Solaris in 32-bit
31368mode for all SPARC-V9 processors.
31369
31370@item -mvis
31371@itemx -mno-vis
31372@opindex mvis
31373@opindex mno-vis
31374With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
31375Visual Instruction Set extensions. The default is @option{-mno-vis}.
31376
31377@item -mvis2
31378@itemx -mno-vis2
31379@opindex mvis2
31380@opindex mno-vis2
31381With @option{-mvis2}, GCC generates code that takes advantage of
31382version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
31383default is @option{-mvis2} when targeting a cpu that supports such
31384instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
31385also sets @option{-mvis}.
31386
31387@item -mvis3
31388@itemx -mno-vis3
31389@opindex mvis3
31390@opindex mno-vis3
31391With @option{-mvis3}, GCC generates code that takes advantage of
31392version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
31393default is @option{-mvis3} when targeting a cpu that supports such
31394instructions, such as niagara-3 and later. Setting @option{-mvis3}
31395also sets @option{-mvis2} and @option{-mvis}.
31396
31397@item -mvis4
31398@itemx -mno-vis4
31399@opindex mvis4
31400@opindex mno-vis4
31401With @option{-mvis4}, GCC generates code that takes advantage of
31402version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
31403default is @option{-mvis4} when targeting a cpu that supports such
31404instructions, such as niagara-7 and later. Setting @option{-mvis4}
31405also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
31406
31407@item -mvis4b
31408@itemx -mno-vis4b
31409@opindex mvis4b
31410@opindex mno-vis4b
31411With @option{-mvis4b}, GCC generates code that takes advantage of
31412version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
31413the additional VIS instructions introduced in the Oracle SPARC
31414Architecture 2017. The default is @option{-mvis4b} when targeting a
31415cpu that supports such instructions, such as m8 and later. Setting
31416@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
31417@option{-mvis2} and @option{-mvis}.
31418
31419@item -mcbcond
31420@itemx -mno-cbcond
31421@opindex mcbcond
31422@opindex mno-cbcond
31423With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
31424Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
31425when targeting a CPU that supports such instructions, such as Niagara-4 and
31426later.
31427
31428@item -mfmaf
31429@itemx -mno-fmaf
31430@opindex mfmaf
31431@opindex mno-fmaf
31432With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
31433Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
31434when targeting a CPU that supports such instructions, such as Niagara-3 and
31435later.
31436
31437@item -mfsmuld
31438@itemx -mno-fsmuld
31439@opindex mfsmuld
31440@opindex mno-fsmuld
31441With @option{-mfsmuld}, GCC generates code that takes advantage of the
31442Floating-point Multiply Single to Double (FsMULd) instruction. The default is
31443@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
31444or V9 with FPU except @option{-mcpu=leon}.
31445
31446@item -mpopc
31447@itemx -mno-popc
31448@opindex mpopc
31449@opindex mno-popc
31450With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
31451Population Count instruction. The default is @option{-mpopc}
31452when targeting a CPU that supports such an instruction, such as Niagara-2 and
31453later.
31454
31455@item -msubxc
31456@itemx -mno-subxc
31457@opindex msubxc
31458@opindex mno-subxc
31459With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
31460Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
31461when targeting a CPU that supports such an instruction, such as Niagara-7 and
31462later.
31463
31464@item -mfix-at697f
31465@opindex mfix-at697f
31466Enable the documented workaround for the single erratum of the Atmel AT697F
31467processor (which corresponds to erratum #13 of the AT697E processor).
31468
31469@item -mfix-ut699
31470@opindex mfix-ut699
31471Enable the documented workarounds for the floating-point errata and the data
31472cache nullify errata of the UT699 processor.
31473
31474@item -mfix-ut700
31475@opindex mfix-ut700
31476Enable the documented workaround for the back-to-back store errata of
31477the UT699E/UT700 processor.
31478
31479@item -mfix-gr712rc
31480@opindex mfix-gr712rc
31481Enable the documented workaround for the back-to-back store errata of
31482the GR712RC processor.
31483@end table
31484
31485These @samp{-m} options are supported in addition to the above
31486on SPARC-V9 processors in 64-bit environments:
31487
31488@table @gcctabopt
31489@item -m32
31490@itemx -m64
31491@opindex m32
31492@opindex m64
31493Generate code for a 32-bit or 64-bit environment.
31494The 32-bit environment sets int, long and pointer to 32 bits.
31495The 64-bit environment sets int to 32 bits and long and pointer
31496to 64 bits.
31497
31498@item -mcmodel=@var{which}
31499@opindex mcmodel
31500Set the code model to one of
31501
31502@table @samp
31503@item medlow
31504The Medium/Low code model: 64-bit addresses, programs
31505must be linked in the low 32 bits of memory. Programs can be statically
31506or dynamically linked.
31507
31508@item medmid
31509The Medium/Middle code model: 64-bit addresses, programs
31510must be linked in the low 44 bits of memory, the text and data segments must
31511be less than 2GB in size and the data segment must be located within 2GB of
31512the text segment.
31513
31514@item medany
31515The Medium/Anywhere code model: 64-bit addresses, programs
31516may be linked anywhere in memory, the text and data segments must be less
31517than 2GB in size and the data segment must be located within 2GB of the
31518text segment.
31519
31520@item embmedany
31521The Medium/Anywhere code model for embedded systems:
3152264-bit addresses, the text and data segments must be less than 2GB in
31523size, both starting anywhere in memory (determined at link time). The
31524global register %g4 points to the base of the data segment. Programs
31525are statically linked and PIC is not supported.
31526@end table
31527
31528@item -mmemory-model=@var{mem-model}
31529@opindex mmemory-model
31530Set the memory model in force on the processor to one of
31531
31532@table @samp
31533@item default
31534The default memory model for the processor and operating system.
31535
31536@item rmo
31537Relaxed Memory Order
31538
31539@item pso
31540Partial Store Order
31541
31542@item tso
31543Total Store Order
31544
31545@item sc
31546Sequential Consistency
31547@end table
31548
31549These memory models are formally defined in Appendix D of the SPARC-V9
31550architecture manual, as set in the processor's @code{PSTATE.MM} field.
31551
31552@item -mstack-bias
31553@itemx -mno-stack-bias
31554@opindex mstack-bias
31555@opindex mno-stack-bias
31556With @option{-mstack-bias}, GCC assumes that the stack pointer, and
31557frame pointer if present, are offset by @minus{}2047 which must be added back
31558when making stack frame references. This is the default in 64-bit mode.
31559Otherwise, assume no such offset is present.
31560@end table
31561
31562@node System V Options
31563@subsection Options for System V
31564
31565These additional options are available on System V Release 4 for
31566compatibility with other compilers on those systems:
31567
31568@table @gcctabopt
31569@item -G
31570@opindex G
31571Create a shared object.
31572It is recommended that @option{-symbolic} or @option{-shared} be used instead.
31573
31574@item -Qy
31575@opindex Qy
31576Identify the versions of each tool used by the compiler, in a
31577@code{.ident} assembler directive in the output.
31578
31579@item -Qn
31580@opindex Qn
31581Refrain from adding @code{.ident} directives to the output file (this is
31582the default).
31583
31584@item -YP,@var{dirs}
31585@opindex YP
31586Search the directories @var{dirs}, and no others, for libraries
31587specified with @option{-l}.
31588
31589@item -Ym,@var{dir}
31590@opindex Ym
31591Look in the directory @var{dir} to find the M4 preprocessor.
31592The assembler uses this option.
31593@c This is supposed to go with a -Yd for predefined M4 macro files, but
31594@c the generic assembler that comes with Solaris takes just -Ym.
31595@end table
31596
31597@node V850 Options
31598@subsection V850 Options
31599@cindex V850 Options
31600
31601These @samp{-m} options are defined for V850 implementations:
31602
31603@table @gcctabopt
31604@item -mlong-calls
31605@itemx -mno-long-calls
31606@opindex mlong-calls
31607@opindex mno-long-calls
31608Treat all calls as being far away (near). If calls are assumed to be
31609far away, the compiler always loads the function's address into a
31610register, and calls indirect through the pointer.
31611
31612@item -mno-ep
31613@itemx -mep
31614@opindex mno-ep
31615@opindex mep
31616Do not optimize (do optimize) basic blocks that use the same index
31617pointer 4 or more times to copy pointer into the @code{ep} register, and
31618use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
31619option is on by default if you optimize.
31620
31621@item -mno-prolog-function
31622@itemx -mprolog-function
31623@opindex mno-prolog-function
31624@opindex mprolog-function
31625Do not use (do use) external functions to save and restore registers
31626at the prologue and epilogue of a function. The external functions
31627are slower, but use less code space if more than one function saves
31628the same number of registers. The @option{-mprolog-function} option
31629is on by default if you optimize.
31630
31631@item -mspace
31632@opindex mspace
31633Try to make the code as small as possible. At present, this just turns
31634on the @option{-mep} and @option{-mprolog-function} options.
31635
31636@item -mtda=@var{n}
31637@opindex mtda
31638Put static or global variables whose size is @var{n} bytes or less into
31639the tiny data area that register @code{ep} points to. The tiny data
31640area can hold up to 256 bytes in total (128 bytes for byte references).
31641
31642@item -msda=@var{n}
31643@opindex msda
31644Put static or global variables whose size is @var{n} bytes or less into
31645the small data area that register @code{gp} points to. The small data
31646area can hold up to 64 kilobytes.
31647
31648@item -mzda=@var{n}
31649@opindex mzda
31650Put static or global variables whose size is @var{n} bytes or less into
31651the first 32 kilobytes of memory.
31652
31653@item -mv850
31654@opindex mv850
31655Specify that the target processor is the V850.
31656
31657@item -mv850e3v5
31658@opindex mv850e3v5
31659Specify that the target processor is the V850E3V5. The preprocessor
31660constant @code{__v850e3v5__} is defined if this option is used.
31661
31662@item -mv850e2v4
31663@opindex mv850e2v4
31664Specify that the target processor is the V850E3V5. This is an alias for
31665the @option{-mv850e3v5} option.
31666
31667@item -mv850e2v3
31668@opindex mv850e2v3
31669Specify that the target processor is the V850E2V3. The preprocessor
31670constant @code{__v850e2v3__} is defined if this option is used.
31671
31672@item -mv850e2
31673@opindex mv850e2
31674Specify that the target processor is the V850E2. The preprocessor
31675constant @code{__v850e2__} is defined if this option is used.
31676
31677@item -mv850e1
31678@opindex mv850e1
31679Specify that the target processor is the V850E1. The preprocessor
31680constants @code{__v850e1__} and @code{__v850e__} are defined if
31681this option is used.
31682
31683@item -mv850es
31684@opindex mv850es
31685Specify that the target processor is the V850ES. This is an alias for
31686the @option{-mv850e1} option.
31687
31688@item -mv850e
31689@opindex mv850e
31690Specify that the target processor is the V850E@. The preprocessor
31691constant @code{__v850e__} is defined if this option is used.
31692
31693If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
31694nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
31695are defined then a default target processor is chosen and the
31696relevant @samp{__v850*__} preprocessor constant is defined.
31697
31698The preprocessor constants @code{__v850} and @code{__v851__} are always
31699defined, regardless of which processor variant is the target.
31700
31701@item -mdisable-callt
31702@itemx -mno-disable-callt
31703@opindex mdisable-callt
31704@opindex mno-disable-callt
31705This option suppresses generation of the @code{CALLT} instruction for the
31706v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
31707architecture.
31708
31709This option is enabled by default when the RH850 ABI is
31710in use (see @option{-mrh850-abi}), and disabled by default when the
31711GCC ABI is in use. If @code{CALLT} instructions are being generated
31712then the C preprocessor symbol @code{__V850_CALLT__} is defined.
31713
31714@item -mrelax
31715@itemx -mno-relax
31716@opindex mrelax
31717@opindex mno-relax
31718Pass on (or do not pass on) the @option{-mrelax} command-line option
31719to the assembler.
31720
31721@item -mlong-jumps
31722@itemx -mno-long-jumps
31723@opindex mlong-jumps
31724@opindex mno-long-jumps
31725Disable (or re-enable) the generation of PC-relative jump instructions.
31726
31727@item -msoft-float
31728@itemx -mhard-float
31729@opindex msoft-float
31730@opindex mhard-float
31731Disable (or re-enable) the generation of hardware floating point
31732instructions. This option is only significant when the target
31733architecture is @samp{V850E2V3} or higher. If hardware floating point
31734instructions are being generated then the C preprocessor symbol
31735@code{__FPU_OK__} is defined, otherwise the symbol
31736@code{__NO_FPU__} is defined.
31737
31738@item -mloop
31739@opindex mloop
31740Enables the use of the e3v5 LOOP instruction. The use of this
31741instruction is not enabled by default when the e3v5 architecture is
31742selected because its use is still experimental.
31743
31744@item -mrh850-abi
31745@itemx -mghs
31746@opindex mrh850-abi
31747@opindex mghs
31748Enables support for the RH850 version of the V850 ABI. This is the
31749default. With this version of the ABI the following rules apply:
31750
31751@itemize
31752@item
31753Integer sized structures and unions are returned via a memory pointer
31754rather than a register.
31755
31756@item
31757Large structures and unions (more than 8 bytes in size) are passed by
31758value.
31759
31760@item
31761Functions are aligned to 16-bit boundaries.
31762
31763@item
31764The @option{-m8byte-align} command-line option is supported.
31765
31766@item
31767The @option{-mdisable-callt} command-line option is enabled by
31768default. The @option{-mno-disable-callt} command-line option is not
31769supported.
31770@end itemize
31771
31772When this version of the ABI is enabled the C preprocessor symbol
31773@code{__V850_RH850_ABI__} is defined.
31774
31775@item -mgcc-abi
31776@opindex mgcc-abi
31777Enables support for the old GCC version of the V850 ABI. With this
31778version of the ABI the following rules apply:
31779
31780@itemize
31781@item
31782Integer sized structures and unions are returned in register @code{r10}.
31783
31784@item
31785Large structures and unions (more than 8 bytes in size) are passed by
31786reference.
31787
31788@item
31789Functions are aligned to 32-bit boundaries, unless optimizing for
31790size.
31791
31792@item
31793The @option{-m8byte-align} command-line option is not supported.
31794
31795@item
31796The @option{-mdisable-callt} command-line option is supported but not
31797enabled by default.
31798@end itemize
31799
31800When this version of the ABI is enabled the C preprocessor symbol
31801@code{__V850_GCC_ABI__} is defined.
31802
31803@item -m8byte-align
31804@itemx -mno-8byte-align
31805@opindex m8byte-align
31806@opindex mno-8byte-align
31807Enables support for @code{double} and @code{long long} types to be
31808aligned on 8-byte boundaries. The default is to restrict the
31809alignment of all objects to at most 4-bytes. When
31810@option{-m8byte-align} is in effect the C preprocessor symbol
31811@code{__V850_8BYTE_ALIGN__} is defined.
31812
31813@item -mbig-switch
31814@opindex mbig-switch
31815Generate code suitable for big switch tables. Use this option only if
31816the assembler/linker complain about out of range branches within a switch
31817table.
31818
31819@item -mapp-regs
31820@opindex mapp-regs
31821This option causes r2 and r5 to be used in the code generated by
31822the compiler. This setting is the default.
31823
31824@item -mno-app-regs
31825@opindex mno-app-regs
31826This option causes r2 and r5 to be treated as fixed registers.
31827
31828@end table
31829
31830@node VAX Options
31831@subsection VAX Options
31832@cindex VAX options
31833
31834These @samp{-m} options are defined for the VAX:
31835
31836@table @gcctabopt
31837@item -munix
31838@opindex munix
31839Do not output certain jump instructions (@code{aobleq} and so on)
31840that the Unix assembler for the VAX cannot handle across long
31841ranges.
31842
31843@item -mgnu
31844@opindex mgnu
31845Do output those jump instructions, on the assumption that the
31846GNU assembler is being used.
31847
31848@item -mg
31849@opindex mg
31850Output code for G-format floating-point numbers instead of D-format.
31851
31852@item -mlra
31853@itemx -mno-lra
31854@opindex mlra
31855@opindex mno-lra
31856Enable Local Register Allocation. This is still experimental for the VAX,
31857so by default the compiler uses standard reload.
31858@end table
31859
31860@node Visium Options
31861@subsection Visium Options
31862@cindex Visium options
31863
31864@table @gcctabopt
31865
31866@item -mdebug
31867@opindex mdebug
31868A program which performs file I/O and is destined to run on an MCM target
31869should be linked with this option. It causes the libraries libc.a and
31870libdebug.a to be linked. The program should be run on the target under
31871the control of the GDB remote debugging stub.
31872
31873@item -msim
31874@opindex msim
31875A program which performs file I/O and is destined to run on the simulator
31876should be linked with option. This causes libraries libc.a and libsim.a to
31877be linked.
31878
31879@item -mfpu
31880@itemx -mhard-float
31881@opindex mfpu
31882@opindex mhard-float
31883Generate code containing floating-point instructions. This is the
31884default.
31885
31886@item -mno-fpu
31887@itemx -msoft-float
31888@opindex mno-fpu
31889@opindex msoft-float
31890Generate code containing library calls for floating-point.
31891
31892@option{-msoft-float} changes the calling convention in the output file;
31893therefore, it is only useful if you compile @emph{all} of a program with
31894this option. In particular, you need to compile @file{libgcc.a}, the
31895library that comes with GCC, with @option{-msoft-float} in order for
31896this to work.
31897
31898@item -mcpu=@var{cpu_type}
31899@opindex mcpu
31900Set the instruction set, register set, and instruction scheduling parameters
31901for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31902@samp{mcm}, @samp{gr5} and @samp{gr6}.
31903
31904@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
31905
31906By default (unless configured otherwise), GCC generates code for the GR5
31907variant of the Visium architecture.
31908
31909With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
31910architecture. The only difference from GR5 code is that the compiler will
31911generate block move instructions.
31912
31913@item -mtune=@var{cpu_type}
31914@opindex mtune
31915Set the instruction scheduling parameters for machine type @var{cpu_type},
31916but do not set the instruction set or register set that the option
31917@option{-mcpu=@var{cpu_type}} would.
31918
31919@item -msv-mode
31920@opindex msv-mode
31921Generate code for the supervisor mode, where there are no restrictions on
31922the access to general registers. This is the default.
31923
31924@item -muser-mode
31925@opindex muser-mode
31926Generate code for the user mode, where the access to some general registers
31927is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
31928mode; on the GR6, only registers r29 to r31 are affected.
31929@end table
31930
31931@node VMS Options
31932@subsection VMS Options
31933
31934These @samp{-m} options are defined for the VMS implementations:
31935
31936@table @gcctabopt
31937@item -mvms-return-codes
31938@opindex mvms-return-codes
31939Return VMS condition codes from @code{main}. The default is to return POSIX-style
31940condition (e.g.@: error) codes.
31941
31942@item -mdebug-main=@var{prefix}
31943@opindex mdebug-main=@var{prefix}
31944Flag the first routine whose name starts with @var{prefix} as the main
31945routine for the debugger.
31946
31947@item -mmalloc64
31948@opindex mmalloc64
31949Default to 64-bit memory allocation routines.
31950
31951@item -mpointer-size=@var{size}
31952@opindex mpointer-size=@var{size}
31953Set the default size of pointers. Possible options for @var{size} are
31954@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
31955for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
31956The later option disables @code{pragma pointer_size}.
31957@end table
31958
31959@node VxWorks Options
31960@subsection VxWorks Options
31961@cindex VxWorks Options
31962
31963The options in this section are defined for all VxWorks targets.
31964Options specific to the target hardware are listed with the other
31965options for that target.
31966
31967@table @gcctabopt
31968@item -mrtp
31969@opindex mrtp
31970GCC can generate code for both VxWorks kernels and real time processes
31971(RTPs). This option switches from the former to the latter. It also
31972defines the preprocessor macro @code{__RTP__}.
31973
31974@item -non-static
31975@opindex non-static
31976Link an RTP executable against shared libraries rather than static
31977libraries. The options @option{-static} and @option{-shared} can
31978also be used for RTPs (@pxref{Link Options}); @option{-static}
31979is the default.
31980
31981@item -Bstatic
31982@itemx -Bdynamic
31983@opindex Bstatic
31984@opindex Bdynamic
31985These options are passed down to the linker. They are defined for
31986compatibility with Diab.
31987
31988@item -Xbind-lazy
31989@opindex Xbind-lazy
31990Enable lazy binding of function calls. This option is equivalent to
31991@option{-Wl,-z,now} and is defined for compatibility with Diab.
31992
31993@item -Xbind-now
31994@opindex Xbind-now
31995Disable lazy binding of function calls. This option is the default and
31996is defined for compatibility with Diab.
31997@end table
31998
31999@node x86 Options
32000@subsection x86 Options
32001@cindex x86 Options
32002
32003These @samp{-m} options are defined for the x86 family of computers.
32004
32005@table @gcctabopt
32006
32007@item -march=@var{cpu-type}
32008@opindex march
32009Generate instructions for the machine type @var{cpu-type}. In contrast to
32010@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32011for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32012to generate code that may not run at all on processors other than the one
32013indicated. Specifying @option{-march=@var{cpu-type}} implies
32014@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32015
32016The choices for @var{cpu-type} are:
32017
32018@table @samp
32019@item native
32020This selects the CPU to generate code for at compilation time by determining
32021the processor type of the compiling machine. Using @option{-march=native}
32022enables all instruction subsets supported by the local machine (hence
32023the result might not run on different machines). Using @option{-mtune=native}
32024produces code optimized for the local machine under the constraints
32025of the selected instruction set.
32026
32027@item x86-64
32028A generic CPU with 64-bit extensions.
32029
32030@item x86-64-v2
32031@itemx x86-64-v3
32032@itemx x86-64-v4
32033These choices for @var{cpu-type} select the corresponding
32034micro-architecture level from the x86-64 psABI. On ABIs other than
32035the x86-64 psABI they select the same CPU features as the x86-64 psABI
32036documents for the particular micro-architecture level.
32037
32038Since these @var{cpu-type} values do not have a corresponding
32039@option{-mtune} setting, using @option{-march} with these values enables
32040generic tuning. Specific tuning can be enabled using the
32041@option{-mtune=@var{other-cpu-type}} option with an appropriate
32042@var{other-cpu-type} value.
32043
32044@item i386
32045Original Intel i386 CPU@.
32046
32047@item i486
32048Intel i486 CPU@. (No scheduling is implemented for this chip.)
32049
32050@item i586
32051@itemx pentium
32052Intel Pentium CPU with no MMX support.
32053
32054@item lakemont
32055Intel Lakemont MCU, based on Intel Pentium CPU.
32056
32057@item pentium-mmx
32058Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32059
32060@item pentiumpro
32061Intel Pentium Pro CPU@.
32062
32063@item i686
32064When used with @option{-march}, the Pentium Pro
32065instruction set is used, so the code runs on all i686 family chips.
32066When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32067
32068@item pentium2
32069Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32070set support.
32071
32072@item pentium3
32073@itemx pentium3m
32074Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32075instruction set support.
32076
32077@item pentium-m
32078Intel Pentium M; low-power version of Intel Pentium III CPU
32079with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32080notebooks.
32081
32082@item pentium4
32083@itemx pentium4m
32084Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32085
32086@item prescott
32087Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32088instruction set support.
32089
32090@item nocona
32091Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32092SSE2, SSE3 and FXSR instruction set support.
32093
32094@item core2
32095Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32096SAHF and FXSR instruction set support.
32097
32098@item nehalem
32099Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32100SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32101
32102@item westmere
32103Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32104SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32105
32106@item sandybridge
32107Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32108SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32109support.
32110
32111@item ivybridge
32112Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32113SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32114and F16C instruction set support.
32115
32116@item haswell
32117Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32118SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32119F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32120
32121@item broadwell
32122Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32123SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32124F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32125instruction set support.
32126
32127@item skylake
32128Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32129SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32130F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32131CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32132
32133@item bonnell
32134Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32135instruction set support.
32136
32137@item silvermont
32138Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32139SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32140instruction set support.
32141
32142@item goldmont
32143Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32144SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32145RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32146set support.
32147
32148@item goldmont-plus
32149Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32150SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32151SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32152RDPID and SGX instruction set support.
32153
32154@item tremont
32155Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32156SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32157RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32158SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32159support.
32160
32161@item sierraforest
32162Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32163SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32164XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32165MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32166PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32167AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32168
32169@item grandridge
32170Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32171SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32172XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32173MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32174PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32175AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set
32176support.
32177
32178@item knl
32179Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32180SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32181RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32182AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32183
32184@item knm
32185Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32186SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32187RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32188AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32189AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32190
32191@item skylake-avx512
32192Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32193SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32194RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32195AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32196AVX512DQ and AVX512CD instruction set support.
32197
32198@item cannonlake
32199Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32200SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32201FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32202PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32203AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32204support.
32205
32206@item icelake-client
32207Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32208SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32209RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32210AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32211AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32212, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32213
32214@item icelake-server
32215Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32216SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32217RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32218AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32219AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32220, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32221instruction set support.
32222
32223@item cascadelake
32224Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32225SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32226F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32227CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32228AVX512CD and AVX512VNNI instruction set support.
32229
32230@item cooperlake
32231Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32232SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32233F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32234CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32235AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32236
32237@item tigerlake
32238Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32239SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32240F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32241CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32242PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32243VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32244AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32245
32246@item sapphirerapids
32247Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32248SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32249RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32250AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32251AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32252VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32253MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
32254UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16 and AVX512BF16
32255instruction set support.
32256
32257@item alderlake
32258Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32259SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32260XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32261CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32262VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32263support.
32264
32265@item rocketlake
32266Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32267, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32268F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32269CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32270PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32271VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32272
32273@item graniterapids
32274Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32275SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32276RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32277AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32278AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32279VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32280MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
32281SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16,
32282AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
32283
32284@item k6
32285AMD K6 CPU with MMX instruction set support.
32286
32287@item k6-2
32288@itemx k6-3
32289Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
32290
32291@item athlon
32292@itemx athlon-tbird
32293AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
32294support.
32295
32296@item athlon-4
32297@itemx athlon-xp
32298@itemx athlon-mp
32299Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
32300instruction set support.
32301
32302@item k8
32303@itemx opteron
32304@itemx athlon64
32305@itemx athlon-fx
32306Processors based on the AMD K8 core with x86-64 instruction set support,
32307including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
32308(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
32309instruction set extensions.)
32310
32311@item k8-sse3
32312@itemx opteron-sse3
32313@itemx athlon64-sse3
32314Improved versions of AMD K8 cores with SSE3 instruction set support.
32315
32316@item amdfam10
32317@itemx barcelona
32318CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
32319supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
32320instruction set extensions.)
32321
32322@item bdver1
32323CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
32324supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
32325SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
32326
32327@item bdver2
32328AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32329supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
32330SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
32331extensions.)
32332
32333@item bdver3
32334AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32335supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
32336PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3233764-bit instruction set extensions.)
32338
32339@item bdver4
32340AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32341supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
32342AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
32343SSE4.2, ABM and 64-bit instruction set extensions.)
32344
32345@item znver1
32346AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32347supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
32348SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
32349SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
32350instruction set extensions.)
32351
32352@item znver2
32353AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32354supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32355MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32356SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32357WBNOINVD, and 64-bit instruction set extensions.)
32358
32359@item znver3
32360AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32361supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32362MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32363SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32364WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
32365
32366@item znver4
32367AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32368supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32369MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32370SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32371WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
32372AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
32373AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
32374
32375@item btver1
32376CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
32377supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
32378instruction set extensions.)
32379
32380@item btver2
32381CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
32382includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
32383SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
32384
32385@item winchip-c6
32386IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
32387set support.
32388
32389@item winchip2
32390IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
32391instruction set support.
32392
32393@item c3
32394VIA C3 CPU with MMX and 3DNow!@: instruction set support.
32395(No scheduling is implemented for this chip.)
32396
32397@item c3-2
32398VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
32399(No scheduling is implemented for this chip.)
32400
32401@item c7
32402VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32403(No scheduling is implemented for this chip.)
32404
32405@item samuel-2
32406VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
32407(No scheduling is implemented for this chip.)
32408
32409@item nehemiah
32410VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
32411(No scheduling is implemented for this chip.)
32412
32413@item esther
32414VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32415(No scheduling is implemented for this chip.)
32416
32417@item eden-x2
32418VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
32419(No scheduling is implemented for this chip.)
32420
32421@item eden-x4
32422VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
32423AVX and AVX2 instruction set support.
32424(No scheduling is implemented for this chip.)
32425
32426@item nano
32427Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32428instruction set support.
32429(No scheduling is implemented for this chip.)
32430
32431@item nano-1000
32432VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32433instruction set support.
32434(No scheduling is implemented for this chip.)
32435
32436@item nano-2000
32437VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32438instruction set support.
32439(No scheduling is implemented for this chip.)
32440
32441@item nano-3000
32442VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32443instruction set support.
32444(No scheduling is implemented for this chip.)
32445
32446@item nano-x2
32447VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32448instruction set support.
32449(No scheduling is implemented for this chip.)
32450
32451@item nano-x4
32452VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32453instruction set support.
32454(No scheduling is implemented for this chip.)
32455
32456@item lujiazui
32457ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
32458SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
32459ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
32460
32461@item geode
32462AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
32463@end table
32464
32465@item -mtune=@var{cpu-type}
32466@opindex mtune
32467Tune to @var{cpu-type} everything applicable about the generated code, except
32468for the ABI and the set of available instructions.
32469While picking a specific @var{cpu-type} schedules things appropriately
32470for that particular chip, the compiler does not generate any code that
32471cannot run on the default machine type unless you use a
32472@option{-march=@var{cpu-type}} option.
32473For example, if GCC is configured for i686-pc-linux-gnu
32474then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
32475but still runs on i686 machines.
32476
32477The choices for @var{cpu-type} are the same as for @option{-march}.
32478In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
32479
32480@table @samp
32481@item generic
32482Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
32483If you know the CPU on which your code will run, then you should use
32484the corresponding @option{-mtune} or @option{-march} option instead of
32485@option{-mtune=generic}. But, if you do not know exactly what CPU users
32486of your application will have, then you should use this option.
32487
32488As new processors are deployed in the marketplace, the behavior of this
32489option will change. Therefore, if you upgrade to a newer version of
32490GCC, code generation controlled by this option will change to reflect
32491the processors
32492that are most common at the time that version of GCC is released.
32493
32494There is no @option{-march=generic} option because @option{-march}
32495indicates the instruction set the compiler can use, and there is no
32496generic instruction set applicable to all processors. In contrast,
32497@option{-mtune} indicates the processor (or, in this case, collection of
32498processors) for which the code is optimized.
32499
32500@item intel
32501Produce code optimized for the most current Intel processors, which are
32502Haswell and Silvermont for this version of GCC. If you know the CPU
32503on which your code will run, then you should use the corresponding
32504@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
32505But, if you want your application performs better on both Haswell and
32506Silvermont, then you should use this option.
32507
32508As new Intel processors are deployed in the marketplace, the behavior of
32509this option will change. Therefore, if you upgrade to a newer version of
32510GCC, code generation controlled by this option will change to reflect
32511the most current Intel processors at the time that version of GCC is
32512released.
32513
32514There is no @option{-march=intel} option because @option{-march} indicates
32515the instruction set the compiler can use, and there is no common
32516instruction set applicable to all processors. In contrast,
32517@option{-mtune} indicates the processor (or, in this case, collection of
32518processors) for which the code is optimized.
32519@end table
32520
32521@item -mcpu=@var{cpu-type}
32522@opindex mcpu
32523A deprecated synonym for @option{-mtune}.
32524
32525@item -mfpmath=@var{unit}
32526@opindex mfpmath
32527Generate floating-point arithmetic for selected unit @var{unit}. The choices
32528for @var{unit} are:
32529
32530@table @samp
32531@item 387
32532Use the standard 387 floating-point coprocessor present on the majority of chips and
32533emulated otherwise. Code compiled with this option runs almost everywhere.
32534The temporary results are computed in 80-bit precision instead of the precision
32535specified by the type, resulting in slightly different results compared to most
32536of other chips. See @option{-ffloat-store} for more detailed description.
32537
32538This is the default choice for non-Darwin x86-32 targets.
32539
32540@item sse
32541Use scalar floating-point instructions present in the SSE instruction set.
32542This instruction set is supported by Pentium III and newer chips,
32543and in the AMD line
32544by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
32545instruction set supports only single-precision arithmetic, thus the double and
32546extended-precision arithmetic are still done using 387. A later version, present
32547only in Pentium 4 and AMD x86-64 chips, supports double-precision
32548arithmetic too.
32549
32550For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
32551or @option{-msse2} switches to enable SSE extensions and make this option
32552effective. For the x86-64 compiler, these extensions are enabled by default.
32553
32554The resulting code should be considerably faster in the majority of cases and avoid
32555the numerical instability problems of 387 code, but may break some existing
32556code that expects temporaries to be 80 bits.
32557
32558This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
32559and the default choice for x86-32 targets with the SSE2 instruction set
32560when @option{-ffast-math} is enabled.
32561
32562@item sse,387
32563@itemx sse+387
32564@itemx both
32565Attempt to utilize both instruction sets at once. This effectively doubles the
32566amount of available registers, and on chips with separate execution units for
32567387 and SSE the execution resources too. Use this option with care, as it is
32568still experimental, because the GCC register allocator does not model separate
32569functional units well, resulting in unstable performance.
32570@end table
32571
32572@item -masm=@var{dialect}
32573@opindex masm=@var{dialect}
32574Output assembly instructions using selected @var{dialect}. Also affects
32575which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
32576extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
32577order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
32578not support @samp{intel}.
32579
32580@item -mieee-fp
32581@itemx -mno-ieee-fp
32582@opindex mieee-fp
32583@opindex mno-ieee-fp
32584Control whether or not the compiler uses IEEE floating-point
32585comparisons. These correctly handle the case where the result of a
32586comparison is unordered.
32587
32588@item -m80387
32589@itemx -mhard-float
30348d30 32590@opindex m80387
d77de738
ML
32591@opindex mhard-float
32592Generate output containing 80387 instructions for floating point.
32593
32594@item -mno-80387
32595@itemx -msoft-float
32596@opindex no-80387
32597@opindex msoft-float
32598Generate output containing library calls for floating point.
32599
32600@strong{Warning:} the requisite libraries are not part of GCC@.
32601Normally the facilities of the machine's usual C compiler are used, but
32602this cannot be done directly in cross-compilation. You must make your
32603own arrangements to provide suitable library functions for
32604cross-compilation.
32605
32606On machines where a function returns floating-point results in the 80387
32607register stack, some floating-point opcodes may be emitted even if
32608@option{-msoft-float} is used.
32609
32610@item -mno-fp-ret-in-387
32611@opindex mno-fp-ret-in-387
32612@opindex mfp-ret-in-387
32613Do not use the FPU registers for return values of functions.
32614
32615The usual calling convention has functions return values of types
32616@code{float} and @code{double} in an FPU register, even if there
32617is no FPU@. The idea is that the operating system should emulate
32618an FPU@.
32619
32620The option @option{-mno-fp-ret-in-387} causes such values to be returned
32621in ordinary CPU registers instead.
32622
32623@item -mno-fancy-math-387
32624@opindex mno-fancy-math-387
32625@opindex mfancy-math-387
32626Some 387 emulators do not support the @code{sin}, @code{cos} and
32627@code{sqrt} instructions for the 387. Specify this option to avoid
32628generating those instructions.
32629This option is overridden when @option{-march}
32630indicates that the target CPU always has an FPU and so the
32631instruction does not need emulation. These
32632instructions are not generated unless you also use the
32633@option{-funsafe-math-optimizations} switch.
32634
32635@item -malign-double
32636@itemx -mno-align-double
32637@opindex malign-double
32638@opindex mno-align-double
32639Control whether GCC aligns @code{double}, @code{long double}, and
32640@code{long long} variables on a two-word boundary or a one-word
32641boundary. Aligning @code{double} variables on a two-word boundary
32642produces code that runs somewhat faster on a Pentium at the
32643expense of more memory.
32644
32645On x86-64, @option{-malign-double} is enabled by default.
32646
32647@strong{Warning:} if you use the @option{-malign-double} switch,
32648structures containing the above types are aligned differently than
32649the published application binary interface specifications for the x86-32
32650and are not binary compatible with structures in code compiled
32651without that switch.
32652
32653@item -m96bit-long-double
32654@itemx -m128bit-long-double
32655@opindex m96bit-long-double
32656@opindex m128bit-long-double
32657These switches control the size of @code{long double} type. The x86-32
32658application binary interface specifies the size to be 96 bits,
32659so @option{-m96bit-long-double} is the default in 32-bit mode.
32660
32661Modern architectures (Pentium and newer) prefer @code{long double}
32662to be aligned to an 8- or 16-byte boundary. In arrays or structures
32663conforming to the ABI, this is not possible. So specifying
32664@option{-m128bit-long-double} aligns @code{long double}
32665to a 16-byte boundary by padding the @code{long double} with an additional
3266632-bit zero.
32667
32668In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
32669its ABI specifies that @code{long double} is aligned on 16-byte boundary.
32670
32671Notice that neither of these options enable any extra precision over the x87
32672standard of 80 bits for a @code{long double}.
32673
32674@strong{Warning:} if you override the default value for your target ABI, this
32675changes the size of
32676structures and arrays containing @code{long double} variables,
32677as well as modifying the function calling convention for functions taking
32678@code{long double}. Hence they are not binary-compatible
32679with code compiled without that switch.
32680
32681@item -mlong-double-64
32682@itemx -mlong-double-80
32683@itemx -mlong-double-128
32684@opindex mlong-double-64
32685@opindex mlong-double-80
32686@opindex mlong-double-128
32687These switches control the size of @code{long double} type. A size
32688of 64 bits makes the @code{long double} type equivalent to the @code{double}
32689type. This is the default for 32-bit Bionic C library. A size
32690of 128 bits makes the @code{long double} type equivalent to the
32691@code{__float128} type. This is the default for 64-bit Bionic C library.
32692
32693@strong{Warning:} if you override the default value for your target ABI, this
32694changes the size of
32695structures and arrays containing @code{long double} variables,
32696as well as modifying the function calling convention for functions taking
32697@code{long double}. Hence they are not binary-compatible
32698with code compiled without that switch.
32699
32700@item -malign-data=@var{type}
32701@opindex malign-data
32702Control how GCC aligns variables. Supported values for @var{type} are
32703@samp{compat} uses increased alignment value compatible uses GCC 4.8
32704and earlier, @samp{abi} uses alignment value as specified by the
32705psABI, and @samp{cacheline} uses increased alignment value to match
32706the cache line size. @samp{compat} is the default.
32707
32708@item -mlarge-data-threshold=@var{threshold}
32709@opindex mlarge-data-threshold
32710When @option{-mcmodel=medium} is specified, data objects larger than
32711@var{threshold} are placed in the large data section. This value must be the
32712same across all objects linked into the binary, and defaults to 65535.
32713
32714@item -mrtd
32715@opindex mrtd
32716Use a different function-calling convention, in which functions that
32717take a fixed number of arguments return with the @code{ret @var{num}}
32718instruction, which pops their arguments while returning. This saves one
32719instruction in the caller since there is no need to pop the arguments
32720there.
32721
32722You can specify that an individual function is called with this calling
32723sequence with the function attribute @code{stdcall}. You can also
32724override the @option{-mrtd} option by using the function attribute
32725@code{cdecl}. @xref{Function Attributes}.
32726
32727@strong{Warning:} this calling convention is incompatible with the one
32728normally used on Unix, so you cannot use it if you need to call
32729libraries compiled with the Unix compiler.
32730
32731Also, you must provide function prototypes for all functions that
32732take variable numbers of arguments (including @code{printf});
32733otherwise incorrect code is generated for calls to those
32734functions.
32735
32736In addition, seriously incorrect code results if you call a
32737function with too many arguments. (Normally, extra arguments are
32738harmlessly ignored.)
32739
32740@item -mregparm=@var{num}
32741@opindex mregparm
32742Control how many registers are used to pass integer arguments. By
32743default, no registers are used to pass arguments, and at most 3
32744registers can be used. You can control this behavior for a specific
32745function by using the function attribute @code{regparm}.
32746@xref{Function Attributes}.
32747
32748@strong{Warning:} if you use this switch, and
32749@var{num} is nonzero, then you must build all modules with the same
32750value, including any libraries. This includes the system libraries and
32751startup modules.
32752
32753@item -msseregparm
32754@opindex msseregparm
32755Use SSE register passing conventions for float and double arguments
32756and return values. You can control this behavior for a specific
32757function by using the function attribute @code{sseregparm}.
32758@xref{Function Attributes}.
32759
32760@strong{Warning:} if you use this switch then you must build all
32761modules with the same value, including any libraries. This includes
32762the system libraries and startup modules.
32763
32764@item -mvect8-ret-in-mem
32765@opindex mvect8-ret-in-mem
32766Return 8-byte vectors in memory instead of MMX registers. This is the
32767default on VxWorks to match the ABI of the Sun Studio compilers until
32768version 12. @emph{Only} use this option if you need to remain
32769compatible with existing code produced by those previous compiler
32770versions or older versions of GCC@.
32771
32772@item -mpc32
32773@itemx -mpc64
32774@itemx -mpc80
32775@opindex mpc32
32776@opindex mpc64
32777@opindex mpc80
32778
32779Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
32780is specified, the significands of results of floating-point operations are
32781rounded to 24 bits (single precision); @option{-mpc64} rounds the
32782significands of results of floating-point operations to 53 bits (double
32783precision) and @option{-mpc80} rounds the significands of results of
32784floating-point operations to 64 bits (extended double precision), which is
32785the default. When this option is used, floating-point operations in higher
32786precisions are not available to the programmer without setting the FPU
32787control word explicitly.
32788
32789Setting the rounding of floating-point operations to less than the default
3279080 bits can speed some programs by 2% or more. Note that some mathematical
32791libraries assume that extended-precision (80-bit) floating-point operations
32792are enabled by default; routines in such libraries could suffer significant
32793loss of accuracy, typically through so-called ``catastrophic cancellation'',
32794when this option is used to set the precision to less than extended precision.
32795
32796@item -mstackrealign
32797@opindex mstackrealign
32798Realign the stack at entry. On the x86, the @option{-mstackrealign}
32799option generates an alternate prologue and epilogue that realigns the
32800run-time stack if necessary. This supports mixing legacy codes that keep
328014-byte stack alignment with modern codes that keep 16-byte stack alignment for
32802SSE compatibility. See also the attribute @code{force_align_arg_pointer},
32803applicable to individual functions.
32804
32805@item -mpreferred-stack-boundary=@var{num}
32806@opindex mpreferred-stack-boundary
32807Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
32808byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
32809the default is 4 (16 bytes or 128 bits).
32810
32811@strong{Warning:} When generating code for the x86-64 architecture with
32812SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
32813used to keep the stack boundary aligned to 8 byte boundary. Since
32814x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
32815intended to be used in controlled environment where stack space is
32816important limitation. This option leads to wrong code when functions
32817compiled with 16 byte stack alignment (such as functions from a standard
32818library) are called with misaligned stack. In this case, SSE
32819instructions may lead to misaligned memory access traps. In addition,
32820variable arguments are handled incorrectly for 16 byte aligned
32821objects (including x87 long double and __int128), leading to wrong
32822results. You must build all modules with
32823@option{-mpreferred-stack-boundary=3}, including any libraries. This
32824includes the system libraries and startup modules.
32825
32826@item -mincoming-stack-boundary=@var{num}
32827@opindex mincoming-stack-boundary
32828Assume the incoming stack is aligned to a 2 raised to @var{num} byte
32829boundary. If @option{-mincoming-stack-boundary} is not specified,
32830the one specified by @option{-mpreferred-stack-boundary} is used.
32831
32832On Pentium and Pentium Pro, @code{double} and @code{long double} values
32833should be aligned to an 8-byte boundary (see @option{-malign-double}) or
32834suffer significant run time performance penalties. On Pentium III, the
32835Streaming SIMD Extension (SSE) data type @code{__m128} may not work
32836properly if it is not 16-byte aligned.
32837
32838To ensure proper alignment of this values on the stack, the stack boundary
32839must be as aligned as that required by any value stored on the stack.
32840Further, every function must be generated such that it keeps the stack
32841aligned. Thus calling a function compiled with a higher preferred
32842stack boundary from a function compiled with a lower preferred stack
32843boundary most likely misaligns the stack. It is recommended that
32844libraries that use callbacks always use the default setting.
32845
32846This extra alignment does consume extra stack space, and generally
32847increases code size. Code that is sensitive to stack space usage, such
32848as embedded systems and operating system kernels, may want to reduce the
32849preferred alignment to @option{-mpreferred-stack-boundary=2}.
32850
32851@need 200
32852@item -mmmx
32853@opindex mmmx
32854@need 200
32855@itemx -msse
32856@opindex msse
32857@need 200
32858@itemx -msse2
32859@opindex msse2
32860@need 200
32861@itemx -msse3
32862@opindex msse3
32863@need 200
32864@itemx -mssse3
32865@opindex mssse3
32866@need 200
32867@itemx -msse4
32868@opindex msse4
32869@need 200
32870@itemx -msse4a
32871@opindex msse4a
32872@need 200
32873@itemx -msse4.1
32874@opindex msse4.1
32875@need 200
32876@itemx -msse4.2
32877@opindex msse4.2
32878@need 200
32879@itemx -mavx
32880@opindex mavx
32881@need 200
32882@itemx -mavx2
32883@opindex mavx2
32884@need 200
32885@itemx -mavx512f
32886@opindex mavx512f
32887@need 200
32888@itemx -mavx512pf
32889@opindex mavx512pf
32890@need 200
32891@itemx -mavx512er
32892@opindex mavx512er
32893@need 200
32894@itemx -mavx512cd
32895@opindex mavx512cd
32896@need 200
32897@itemx -mavx512vl
32898@opindex mavx512vl
32899@need 200
32900@itemx -mavx512bw
32901@opindex mavx512bw
32902@need 200
32903@itemx -mavx512dq
32904@opindex mavx512dq
32905@need 200
32906@itemx -mavx512ifma
32907@opindex mavx512ifma
32908@need 200
32909@itemx -mavx512vbmi
32910@opindex mavx512vbmi
32911@need 200
32912@itemx -msha
32913@opindex msha
32914@need 200
32915@itemx -maes
32916@opindex maes
32917@need 200
32918@itemx -mpclmul
32919@opindex mpclmul
32920@need 200
32921@itemx -mclflushopt
32922@opindex mclflushopt
32923@need 200
32924@itemx -mclwb
32925@opindex mclwb
32926@need 200
32927@itemx -mfsgsbase
32928@opindex mfsgsbase
32929@need 200
32930@itemx -mptwrite
32931@opindex mptwrite
32932@need 200
32933@itemx -mrdrnd
32934@opindex mrdrnd
32935@need 200
32936@itemx -mf16c
32937@opindex mf16c
32938@need 200
32939@itemx -mfma
32940@opindex mfma
32941@need 200
32942@itemx -mpconfig
32943@opindex mpconfig
32944@need 200
32945@itemx -mwbnoinvd
32946@opindex mwbnoinvd
32947@need 200
32948@itemx -mfma4
32949@opindex mfma4
32950@need 200
32951@itemx -mprfchw
32952@opindex mprfchw
32953@need 200
32954@itemx -mrdpid
32955@opindex mrdpid
32956@need 200
32957@itemx -mprefetchwt1
32958@opindex mprefetchwt1
32959@need 200
32960@itemx -mrdseed
32961@opindex mrdseed
32962@need 200
32963@itemx -msgx
32964@opindex msgx
32965@need 200
32966@itemx -mxop
32967@opindex mxop
32968@need 200
32969@itemx -mlwp
32970@opindex mlwp
32971@need 200
32972@itemx -m3dnow
32973@opindex m3dnow
32974@need 200
32975@itemx -m3dnowa
32976@opindex m3dnowa
32977@need 200
32978@itemx -mpopcnt
32979@opindex mpopcnt
32980@need 200
32981@itemx -mabm
32982@opindex mabm
32983@need 200
32984@itemx -madx
32985@opindex madx
32986@need 200
32987@itemx -mbmi
32988@opindex mbmi
32989@need 200
32990@itemx -mbmi2
32991@opindex mbmi2
32992@need 200
32993@itemx -mlzcnt
32994@opindex mlzcnt
32995@need 200
32996@itemx -mfxsr
32997@opindex mfxsr
32998@need 200
32999@itemx -mxsave
33000@opindex mxsave
33001@need 200
33002@itemx -mxsaveopt
33003@opindex mxsaveopt
33004@need 200
33005@itemx -mxsavec
33006@opindex mxsavec
33007@need 200
33008@itemx -mxsaves
33009@opindex mxsaves
33010@need 200
33011@itemx -mrtm
33012@opindex mrtm
33013@need 200
33014@itemx -mhle
33015@opindex mhle
33016@need 200
33017@itemx -mtbm
33018@opindex mtbm
33019@need 200
33020@itemx -mmwaitx
33021@opindex mmwaitx
33022@need 200
33023@itemx -mclzero
33024@opindex mclzero
33025@need 200
33026@itemx -mpku
33027@opindex mpku
33028@need 200
33029@itemx -mavx512vbmi2
33030@opindex mavx512vbmi2
33031@need 200
33032@itemx -mavx512bf16
33033@opindex mavx512bf16
33034@need 200
33035@itemx -mavx512fp16
33036@opindex mavx512fp16
33037@need 200
33038@itemx -mgfni
33039@opindex mgfni
33040@need 200
33041@itemx -mvaes
33042@opindex mvaes
33043@need 200
33044@itemx -mwaitpkg
33045@opindex mwaitpkg
33046@need 200
33047@itemx -mvpclmulqdq
33048@opindex mvpclmulqdq
33049@need 200
33050@itemx -mavx512bitalg
33051@opindex mavx512bitalg
33052@need 200
33053@itemx -mmovdiri
33054@opindex mmovdiri
33055@need 200
33056@itemx -mmovdir64b
33057@opindex mmovdir64b
33058@need 200
33059@itemx -menqcmd
33060@opindex menqcmd
33061@itemx -muintr
33062@opindex muintr
33063@need 200
33064@itemx -mtsxldtrk
33065@opindex mtsxldtrk
33066@need 200
33067@itemx -mavx512vpopcntdq
33068@opindex mavx512vpopcntdq
33069@need 200
33070@itemx -mavx512vp2intersect
33071@opindex mavx512vp2intersect
33072@need 200
33073@itemx -mavx5124fmaps
33074@opindex mavx5124fmaps
33075@need 200
33076@itemx -mavx512vnni
33077@opindex mavx512vnni
33078@need 200
33079@itemx -mavxvnni
33080@opindex mavxvnni
33081@need 200
33082@itemx -mavx5124vnniw
33083@opindex mavx5124vnniw
33084@need 200
33085@itemx -mcldemote
33086@opindex mcldemote
33087@need 200
33088@itemx -mserialize
33089@opindex mserialize
33090@need 200
33091@itemx -mamx-tile
33092@opindex mamx-tile
33093@need 200
33094@itemx -mamx-int8
33095@opindex mamx-int8
33096@need 200
33097@itemx -mamx-bf16
33098@opindex mamx-bf16
33099@need 200
33100@itemx -mhreset
33101@opindex mhreset
33102@itemx -mkl
33103@opindex mkl
33104@need 200
33105@itemx -mwidekl
33106@opindex mwidekl
33107@need 200
33108@itemx -mavxifma
33109@opindex mavxifma
33110@need 200
33111@itemx -mavxvnniint8
33112@opindex mavxvnniint8
33113@need 200
33114@itemx -mavxneconvert
33115@opindex mavxneconvert
33116@need 200
33117@itemx -mcmpccxadd
33118@opindex mcmpccxadd
33119@need 200
33120@itemx -mamx-fp16
33121@opindex mamx-fp16
33122@need 200
33123@itemx -mprefetchi
33124@opindex mprefetchi
33125@need 200
33126@itemx -mraoint
33127@opindex mraoint
33128These switches enable the use of instructions in the MMX, SSE,
33129SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
33130AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33131AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33132WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
331333DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33134XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33135GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33136ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
33137UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512FP16,
33138AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT or
33139CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
33140option to disable use of these instructions.
33141
33142These extensions are also available as built-in functions: see
33143@ref{x86 Built-in Functions}, for details of the functions enabled and
33144disabled by these switches.
33145
33146To generate SSE/SSE2 instructions automatically from floating-point
33147code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33148
33149GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33150generates new AVX instructions or AVX equivalence for all SSEx instructions
33151when needed.
33152
33153These options enable GCC to use these extended instructions in
33154generated code, even without @option{-mfpmath=sse}. Applications that
33155perform run-time CPU detection must compile separate files for each
33156supported architecture, using the appropriate flags. In particular,
33157the file containing the CPU detection code should be compiled without
33158these options.
33159
33160@item -mdump-tune-features
33161@opindex mdump-tune-features
33162This option instructs GCC to dump the names of the x86 performance
33163tuning features and default settings. The names can be used in
33164@option{-mtune-ctrl=@var{feature-list}}.
33165
33166@item -mtune-ctrl=@var{feature-list}
33167@opindex mtune-ctrl=@var{feature-list}
33168This option is used to do fine grain control of x86 code generation features.
33169@var{feature-list} is a comma separated list of @var{feature} names. See also
33170@option{-mdump-tune-features}. When specified, the @var{feature} is turned
33171on if it is not preceded with @samp{^}, otherwise, it is turned off.
33172@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33173developers. Using it may lead to code paths not covered by testing and can
33174potentially result in compiler ICEs or runtime errors.
33175
33176@item -mno-default
33177@opindex mno-default
33178This option instructs GCC to turn off all tunable features. See also
33179@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33180
33181@item -mcld
33182@opindex mcld
33183This option instructs GCC to emit a @code{cld} instruction in the prologue
33184of functions that use string instructions. String instructions depend on
33185the DF flag to select between autoincrement or autodecrement mode. While the
33186ABI specifies the DF flag to be cleared on function entry, some operating
33187systems violate this specification by not clearing the DF flag in their
33188exception dispatchers. The exception handler can be invoked with the DF flag
33189set, which leads to wrong direction mode when string instructions are used.
33190This option can be enabled by default on 32-bit x86 targets by configuring
33191GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33192instructions can be suppressed with the @option{-mno-cld} compiler option
33193in this case.
33194
33195@item -mvzeroupper
33196@opindex mvzeroupper
33197This option instructs GCC to emit a @code{vzeroupper} instruction
33198before a transfer of control flow out of the function to minimize
33199the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33200intrinsics.
33201
33202@item -mprefer-avx128
33203@opindex mprefer-avx128
33204This option instructs GCC to use 128-bit AVX instructions instead of
33205256-bit AVX instructions in the auto-vectorizer.
33206
33207@item -mprefer-vector-width=@var{opt}
33208@opindex mprefer-vector-width
33209This option instructs GCC to use @var{opt}-bit vector width in instructions
33210instead of default on the selected platform.
33211
33212@item -mmove-max=@var{bits}
33213@opindex mmove-max
33214This option instructs GCC to set the maximum number of bits can be
33215moved from memory to memory efficiently to @var{bits}. The valid
33216@var{bits} are 128, 256 and 512.
33217
33218@item -mstore-max=@var{bits}
33219@opindex mstore-max
33220This option instructs GCC to set the maximum number of bits can be
33221stored to memory efficiently to @var{bits}. The valid @var{bits} are
33222128, 256 and 512.
33223
33224@table @samp
33225@item none
33226No extra limitations applied to GCC other than defined by the selected platform.
33227
33228@item 128
33229Prefer 128-bit vector width for instructions.
33230
33231@item 256
33232Prefer 256-bit vector width for instructions.
33233
33234@item 512
33235Prefer 512-bit vector width for instructions.
33236@end table
33237
33238@item -mcx16
33239@opindex mcx16
33240This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
33241code to implement compare-and-exchange operations on 16-byte aligned 128-bit
33242objects. This is useful for atomic updates of data structures exceeding one
33243machine word in size. The compiler uses this instruction to implement
33244@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
33245128-bit integers, a library call is always used.
33246
33247@item -msahf
33248@opindex msahf
33249This option enables generation of @code{SAHF} instructions in 64-bit code.
33250Early Intel Pentium 4 CPUs with Intel 64 support,
33251prior to the introduction of Pentium 4 G1 step in December 2005,
33252lacked the @code{LAHF} and @code{SAHF} instructions
33253which are supported by AMD64.
33254These are load and store instructions, respectively, for certain status flags.
33255In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
33256@code{drem}, and @code{remainder} built-in functions;
33257see @ref{Other Builtins} for details.
33258
33259@item -mmovbe
33260@opindex mmovbe
33261This option enables use of the @code{movbe} instruction to implement
33262@code{__builtin_bswap32} and @code{__builtin_bswap64}.
33263
33264@item -mshstk
33265@opindex mshstk
33266The @option{-mshstk} option enables shadow stack built-in functions
33267from x86 Control-flow Enforcement Technology (CET).
33268
33269@item -mcrc32
33270@opindex mcrc32
33271This option enables built-in functions @code{__builtin_ia32_crc32qi},
33272@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
33273@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
33274
33275@item -mmwait
33276@opindex mmwait
33277This option enables built-in functions @code{__builtin_ia32_monitor},
33278and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
33279@code{mwait} machine instructions.
33280
33281@item -mrecip
33282@opindex mrecip
33283This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
33284(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
33285with an additional Newton-Raphson step
33286to increase precision instead of @code{DIVSS} and @code{SQRTSS}
33287(and their vectorized
33288variants) for single-precision floating-point arguments. These instructions
33289are generated only when @option{-funsafe-math-optimizations} is enabled
33290together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
33291Note that while the throughput of the sequence is higher than the throughput
33292of the non-reciprocal instruction, the precision of the sequence can be
33293decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
33294
33295Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
33296(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
33297combination), and doesn't need @option{-mrecip}.
33298
33299Also note that GCC emits the above sequence with additional Newton-Raphson step
33300for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
33301already with @option{-ffast-math} (or the above option combination), and
33302doesn't need @option{-mrecip}.
33303
33304@item -mrecip=@var{opt}
33305@opindex mrecip=opt
33306This option controls which reciprocal estimate instructions
33307may be used. @var{opt} is a comma-separated list of options, which may
33308be preceded by a @samp{!} to invert the option:
33309
33310@table @samp
33311@item all
33312Enable all estimate instructions.
33313
33314@item default
33315Enable the default instructions, equivalent to @option{-mrecip}.
33316
33317@item none
33318Disable all estimate instructions, equivalent to @option{-mno-recip}.
33319
33320@item div
33321Enable the approximation for scalar division.
33322
33323@item vec-div
33324Enable the approximation for vectorized division.
33325
33326@item sqrt
33327Enable the approximation for scalar square root.
33328
33329@item vec-sqrt
33330Enable the approximation for vectorized square root.
33331@end table
33332
33333So, for example, @option{-mrecip=all,!sqrt} enables
33334all of the reciprocal approximations, except for square root.
33335
33336@item -mveclibabi=@var{type}
33337@opindex mveclibabi
33338Specifies the ABI type to use for vectorizing intrinsics using an
33339external library. Supported values for @var{type} are @samp{svml}
33340for the Intel short
33341vector math library and @samp{acml} for the AMD math core library.
33342To use this option, both @option{-ftree-vectorize} and
33343@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
33344ABI-compatible library must be specified at link time.
33345
33346GCC currently emits calls to @code{vmldExp2},
33347@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
33348@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
33349@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
33350@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
33351@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
33352@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
33353@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
33354@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
33355@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
33356function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
33357@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
33358@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
33359@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
33360@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
33361when @option{-mveclibabi=acml} is used.
33362
33363@item -mabi=@var{name}
33364@opindex mabi
33365Generate code for the specified calling convention. Permissible values
33366are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
33367@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
33368ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
33369You can control this behavior for specific functions by
33370using the function attributes @code{ms_abi} and @code{sysv_abi}.
33371@xref{Function Attributes}.
33372
33373@item -mforce-indirect-call
33374@opindex mforce-indirect-call
33375Force all calls to functions to be indirect. This is useful
33376when using Intel Processor Trace where it generates more precise timing
33377information for function calls.
33378
33379@item -mmanual-endbr
33380@opindex mmanual-endbr
33381Insert ENDBR instruction at function entry only via the @code{cf_check}
33382function attribute. This is useful when used with the option
33383@option{-fcf-protection=branch} to control ENDBR insertion at the
33384function entry.
33385
33386@item -mcet-switch
33387@opindex mcet-switch
33388By default, CET instrumentation is turned off on switch statements that
33389use a jump table and indirect branch track is disabled. Since jump
33390tables are stored in read-only memory, this does not result in a direct
33391loss of hardening. But if the jump table index is attacker-controlled,
33392the indirect jump may not be constrained by CET. This option turns on
33393CET instrumentation to enable indirect branch track for switch statements
33394with jump tables which leads to the jump targets reachable via any indirect
33395jumps.
33396
33397@item -mcall-ms2sysv-xlogues
33398@opindex mcall-ms2sysv-xlogues
33399@opindex mno-call-ms2sysv-xlogues
33400Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
33401System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
33402default, the code for saving and restoring these registers is emitted inline,
33403resulting in fairly lengthy prologues and epilogues. Using
33404@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
33405use stubs in the static portion of libgcc to perform these saves and restores,
33406thus reducing function size at the cost of a few extra instructions.
33407
33408@item -mtls-dialect=@var{type}
33409@opindex mtls-dialect
33410Generate code to access thread-local storage using the @samp{gnu} or
33411@samp{gnu2} conventions. @samp{gnu} is the conservative default;
33412@samp{gnu2} is more efficient, but it may add compile- and run-time
33413requirements that cannot be satisfied on all systems.
33414
33415@item -mpush-args
33416@itemx -mno-push-args
33417@opindex mpush-args
33418@opindex mno-push-args
33419Use PUSH operations to store outgoing parameters. This method is shorter
33420and usually equally fast as method using SUB/MOV operations and is enabled
33421by default. In some cases disabling it may improve performance because of
33422improved scheduling and reduced dependencies.
33423
33424@item -maccumulate-outgoing-args
33425@opindex maccumulate-outgoing-args
33426If enabled, the maximum amount of space required for outgoing arguments is
33427computed in the function prologue. This is faster on most modern CPUs
33428because of reduced dependencies, improved scheduling and reduced stack usage
33429when the preferred stack boundary is not equal to 2. The drawback is a notable
33430increase in code size. This switch implies @option{-mno-push-args}.
33431
33432@item -mthreads
33433@opindex mthreads
33434Support thread-safe exception handling on MinGW. Programs that rely
33435on thread-safe exception handling must compile and link all code with the
33436@option{-mthreads} option. When compiling, @option{-mthreads} defines
33437@option{-D_MT}; when linking, it links in a special thread helper library
33438@option{-lmingwthrd} which cleans up per-thread exception-handling data.
33439
33440@item -mms-bitfields
33441@itemx -mno-ms-bitfields
33442@opindex mms-bitfields
33443@opindex mno-ms-bitfields
33444
33445Enable/disable bit-field layout compatible with the native Microsoft
33446Windows compiler.
33447
33448If @code{packed} is used on a structure, or if bit-fields are used,
33449it may be that the Microsoft ABI lays out the structure differently
33450than the way GCC normally does. Particularly when moving packed
33451data between functions compiled with GCC and the native Microsoft compiler
33452(either via function call or as data in a file), it may be necessary to access
33453either format.
33454
33455This option is enabled by default for Microsoft Windows
33456targets. This behavior can also be controlled locally by use of variable
33457or type attributes. For more information, see @ref{x86 Variable Attributes}
33458and @ref{x86 Type Attributes}.
33459
33460The Microsoft structure layout algorithm is fairly simple with the exception
33461of the bit-field packing.
33462The padding and alignment of members of structures and whether a bit-field
33463can straddle a storage-unit boundary are determine by these rules:
33464
33465@enumerate
33466@item Structure members are stored sequentially in the order in which they are
33467declared: the first member has the lowest memory address and the last member
33468the highest.
33469
33470@item Every data object has an alignment requirement. The alignment requirement
33471for all data except structures, unions, and arrays is either the size of the
33472object or the current packing size (specified with either the
33473@code{aligned} attribute or the @code{pack} pragma),
33474whichever is less. For structures, unions, and arrays,
33475the alignment requirement is the largest alignment requirement of its members.
33476Every object is allocated an offset so that:
33477
33478@smallexample
33479offset % alignment_requirement == 0
33480@end smallexample
33481
33482@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
33483unit if the integral types are the same size and if the next bit-field fits
33484into the current allocation unit without crossing the boundary imposed by the
33485common alignment requirements of the bit-fields.
33486@end enumerate
33487
33488MSVC interprets zero-length bit-fields in the following ways:
33489
33490@enumerate
33491@item If a zero-length bit-field is inserted between two bit-fields that
33492are normally coalesced, the bit-fields are not coalesced.
33493
33494For example:
33495
33496@smallexample
33497struct
33498 @{
33499 unsigned long bf_1 : 12;
33500 unsigned long : 0;
33501 unsigned long bf_2 : 12;
33502 @} t1;
33503@end smallexample
33504
33505@noindent
33506The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
33507zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
33508
33509@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
33510alignment of the zero-length bit-field is greater than the member that follows it,
33511@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
33512
33513For example:
33514
33515@smallexample
33516struct
33517 @{
33518 char foo : 4;
33519 short : 0;
33520 char bar;
33521 @} t2;
33522
33523struct
33524 @{
33525 char foo : 4;
33526 short : 0;
33527 double bar;
33528 @} t3;
33529@end smallexample
33530
33531@noindent
33532For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
33533Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
33534bit-field does not affect the alignment of @code{bar} or, as a result, the size
33535of the structure.
33536
33537Taking this into account, it is important to note the following:
33538
33539@enumerate
33540@item If a zero-length bit-field follows a normal bit-field, the type of the
33541zero-length bit-field may affect the alignment of the structure as whole. For
33542example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
33543normal bit-field, and is of type short.
33544
33545@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
33546still affect the alignment of the structure:
33547
33548@smallexample
33549struct
33550 @{
33551 char foo : 6;
33552 long : 0;
33553 @} t4;
33554@end smallexample
33555
33556@noindent
33557Here, @code{t4} takes up 4 bytes.
33558@end enumerate
33559
33560@item Zero-length bit-fields following non-bit-field members are ignored:
33561
33562@smallexample
33563struct
33564 @{
33565 char foo;
33566 long : 0;
33567 char bar;
33568 @} t5;
33569@end smallexample
33570
33571@noindent
33572Here, @code{t5} takes up 2 bytes.
33573@end enumerate
33574
33575
33576@item -mno-align-stringops
33577@opindex mno-align-stringops
33578@opindex malign-stringops
33579Do not align the destination of inlined string operations. This switch reduces
33580code size and improves performance in case the destination is already aligned,
33581but GCC doesn't know about it.
33582
33583@item -minline-all-stringops
33584@opindex minline-all-stringops
33585By default GCC inlines string operations only when the destination is
33586known to be aligned to least a 4-byte boundary.
33587This enables more inlining and increases code
33588size, but may improve performance of code that depends on fast
33589@code{memcpy} and @code{memset} for short lengths.
33590The option enables inline expansion of @code{strlen} for all
33591pointer alignments.
33592
33593@item -minline-stringops-dynamically
33594@opindex minline-stringops-dynamically
33595For string operations of unknown size, use run-time checks with
33596inline code for small blocks and a library call for large blocks.
33597
33598@item -mstringop-strategy=@var{alg}
33599@opindex mstringop-strategy=@var{alg}
33600Override the internal decision heuristic for the particular algorithm to use
33601for inlining string operations. The allowed values for @var{alg} are:
33602
33603@table @samp
33604@item rep_byte
33605@itemx rep_4byte
33606@itemx rep_8byte
33607Expand using i386 @code{rep} prefix of the specified size.
33608
33609@item byte_loop
33610@itemx loop
33611@itemx unrolled_loop
33612Expand into an inline loop.
33613
33614@item libcall
33615Always use a library call.
33616@end table
33617
33618@item -mmemcpy-strategy=@var{strategy}
33619@opindex mmemcpy-strategy=@var{strategy}
33620Override the internal decision heuristic to decide if @code{__builtin_memcpy}
33621should be inlined and what inline algorithm to use when the expected size
33622of the copy operation is known. @var{strategy}
33623is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
33624@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
33625the max byte size with which inline algorithm @var{alg} is allowed. For the last
33626triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
33627in the list must be specified in increasing order. The minimal byte size for
33628@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
33629preceding range.
33630
33631@item -mmemset-strategy=@var{strategy}
33632@opindex mmemset-strategy=@var{strategy}
33633The option is similar to @option{-mmemcpy-strategy=} except that it is to control
33634@code{__builtin_memset} expansion.
33635
33636@item -momit-leaf-frame-pointer
33637@opindex momit-leaf-frame-pointer
33638Don't keep the frame pointer in a register for leaf functions. This
33639avoids the instructions to save, set up, and restore frame pointers and
33640makes an extra register available in leaf functions. The option
33641@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
33642which might make debugging harder.
33643
33644@item -mtls-direct-seg-refs
33645@itemx -mno-tls-direct-seg-refs
33646@opindex mtls-direct-seg-refs
33647Controls whether TLS variables may be accessed with offsets from the
33648TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
33649or whether the thread base pointer must be added. Whether or not this
33650is valid depends on the operating system, and whether it maps the
33651segment to cover the entire TLS area.
33652
33653For systems that use the GNU C Library, the default is on.
33654
33655@item -msse2avx
33656@itemx -mno-sse2avx
33657@opindex msse2avx
33658Specify that the assembler should encode SSE instructions with VEX
33659prefix. The option @option{-mavx} turns this on by default.
33660
33661@item -mfentry
33662@itemx -mno-fentry
33663@opindex mfentry
33664If profiling is active (@option{-pg}), put the profiling
33665counter call before the prologue.
33666Note: On x86 architectures the attribute @code{ms_hook_prologue}
33667isn't possible at the moment for @option{-mfentry} and @option{-pg}.
33668
33669@item -mrecord-mcount
33670@itemx -mno-record-mcount
33671@opindex mrecord-mcount
33672If profiling is active (@option{-pg}), generate a __mcount_loc section
33673that contains pointers to each profiling call. This is useful for
33674automatically patching and out calls.
33675
33676@item -mnop-mcount
33677@itemx -mno-nop-mcount
33678@opindex mnop-mcount
33679If profiling is active (@option{-pg}), generate the calls to
33680the profiling functions as NOPs. This is useful when they
33681should be patched in later dynamically. This is likely only
33682useful together with @option{-mrecord-mcount}.
33683
33684@item -minstrument-return=@var{type}
33685@opindex minstrument-return
33686Instrument function exit in -pg -mfentry instrumented functions with
33687call to specified function. This only instruments true returns ending
33688with ret, but not sibling calls ending with jump. Valid types
33689are @var{none} to not instrument, @var{call} to generate a call to __return__,
33690or @var{nop5} to generate a 5 byte nop.
33691
33692@item -mrecord-return
33693@itemx -mno-record-return
33694@opindex mrecord-return
33695Generate a __return_loc section pointing to all return instrumentation code.
33696
33697@item -mfentry-name=@var{name}
33698@opindex mfentry-name
33699Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
33700
33701@item -mfentry-section=@var{name}
33702@opindex mfentry-section
33703Set name of section to record -mrecord-mcount calls (default __mcount_loc).
33704
33705@item -mskip-rax-setup
33706@itemx -mno-skip-rax-setup
33707@opindex mskip-rax-setup
33708When generating code for the x86-64 architecture with SSE extensions
33709disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
33710register when there are no variable arguments passed in vector registers.
33711
33712@strong{Warning:} Since RAX register is used to avoid unnecessarily
33713saving vector registers on stack when passing variable arguments, the
33714impacts of this option are callees may waste some stack space,
33715misbehave or jump to a random location. GCC 4.4 or newer don't have
33716those issues, regardless the RAX register value.
33717
33718@item -m8bit-idiv
33719@itemx -mno-8bit-idiv
33720@opindex m8bit-idiv
33721On some processors, like Intel Atom, 8-bit unsigned integer divide is
33722much faster than 32-bit/64-bit integer divide. This option generates a
33723run-time check. If both dividend and divisor are within range of 0
33724to 255, 8-bit unsigned integer divide is used instead of
3372532-bit/64-bit integer divide.
33726
33727@item -mavx256-split-unaligned-load
33728@itemx -mavx256-split-unaligned-store
33729@opindex mavx256-split-unaligned-load
33730@opindex mavx256-split-unaligned-store
33731Split 32-byte AVX unaligned load and store.
33732
33733@item -mstack-protector-guard=@var{guard}
33734@itemx -mstack-protector-guard-reg=@var{reg}
33735@itemx -mstack-protector-guard-offset=@var{offset}
33736@opindex mstack-protector-guard
33737@opindex mstack-protector-guard-reg
33738@opindex mstack-protector-guard-offset
33739Generate stack protection code using canary at @var{guard}. Supported
33740locations are @samp{global} for global canary or @samp{tls} for per-thread
33741canary in the TLS block (the default). This option has effect only when
33742@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
33743
33744With the latter choice the options
33745@option{-mstack-protector-guard-reg=@var{reg}} and
33746@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
33747which segment register (@code{%fs} or @code{%gs}) to use as base register
33748for reading the canary, and from what offset from that base register.
33749The default for those is as specified in the relevant ABI.
33750
33751@item -mgeneral-regs-only
33752@opindex mgeneral-regs-only
33753Generate code that uses only the general-purpose registers. This
33754prevents the compiler from using floating-point, vector, mask and bound
33755registers.
33756
33757@item -mrelax-cmpxchg-loop
33758@opindex mrelax-cmpxchg-loop
85966f0d
AM
33759When emitting a compare-and-swap loop for @ref{__sync Builtins}
33760and @ref{__atomic Builtins} lacking a native instruction, optimize
33761for the highly contended case by issuing an atomic load before the
33762@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
33763to save CPU power when restarting the loop.
d77de738
ML
33764
33765@item -mindirect-branch=@var{choice}
33766@opindex mindirect-branch
33767Convert indirect call and jump with @var{choice}. The default is
33768@samp{keep}, which keeps indirect call and jump unmodified.
33769@samp{thunk} converts indirect call and jump to call and return thunk.
33770@samp{thunk-inline} converts indirect call and jump to inlined call
33771and return thunk. @samp{thunk-extern} converts indirect call and jump
33772to external call and return thunk provided in a separate object file.
33773You can control this behavior for a specific function by using the
33774function attribute @code{indirect_branch}. @xref{Function Attributes}.
33775
33776Note that @option{-mcmodel=large} is incompatible with
33777@option{-mindirect-branch=thunk} and
33778@option{-mindirect-branch=thunk-extern} since the thunk function may
33779not be reachable in the large code model.
33780
33781Note that @option{-mindirect-branch=thunk-extern} is compatible with
33782@option{-fcf-protection=branch} since the external thunk can be made
33783to enable control-flow check.
33784
33785@item -mfunction-return=@var{choice}
33786@opindex mfunction-return
33787Convert function return with @var{choice}. The default is @samp{keep},
33788which keeps function return unmodified. @samp{thunk} converts function
33789return to call and return thunk. @samp{thunk-inline} converts function
33790return to inlined call and return thunk. @samp{thunk-extern} converts
33791function return to external call and return thunk provided in a separate
33792object file. You can control this behavior for a specific function by
33793using the function attribute @code{function_return}.
33794@xref{Function Attributes}.
33795
33796Note that @option{-mindirect-return=thunk-extern} is compatible with
33797@option{-fcf-protection=branch} since the external thunk can be made
33798to enable control-flow check.
33799
33800Note that @option{-mcmodel=large} is incompatible with
33801@option{-mfunction-return=thunk} and
33802@option{-mfunction-return=thunk-extern} since the thunk function may
33803not be reachable in the large code model.
33804
33805
33806@item -mindirect-branch-register
33807@opindex mindirect-branch-register
33808Force indirect call and jump via register.
33809
33810@item -mharden-sls=@var{choice}
33811@opindex mharden-sls
33812Generate code to mitigate against straight line speculation (SLS) with
33813@var{choice}. The default is @samp{none} which disables all SLS
33814hardening. @samp{return} enables SLS hardening for function returns.
33815@samp{indirect-jmp} enables SLS hardening for indirect jumps.
33816@samp{all} enables all SLS hardening.
33817
33818@item -mindirect-branch-cs-prefix
33819@opindex mindirect-branch-cs-prefix
33820Add CS prefix to call and jmp to indirect thunk with branch target in
33821r8-r15 registers so that the call and jmp instruction length is 6 bytes
33822to allow them to be replaced with @samp{lfence; call *%r8-r15} or
33823@samp{lfence; jmp *%r8-r15} at run-time.
33824
33825@end table
33826
33827These @samp{-m} switches are supported in addition to the above
33828on x86-64 processors in 64-bit environments.
33829
33830@table @gcctabopt
33831@item -m32
33832@itemx -m64
33833@itemx -mx32
33834@itemx -m16
33835@itemx -miamcu
33836@opindex m32
33837@opindex m64
33838@opindex mx32
33839@opindex m16
33840@opindex miamcu
33841Generate code for a 16-bit, 32-bit or 64-bit environment.
33842The @option{-m32} option sets @code{int}, @code{long}, and pointer types
33843to 32 bits, and
33844generates code that runs on any i386 system.
33845
33846The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
33847types to 64 bits, and generates code for the x86-64 architecture.
33848For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
33849and @option{-mdynamic-no-pic} options.
33850
33851The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
33852to 32 bits, and
33853generates code for the x86-64 architecture.
33854
33855The @option{-m16} option is the same as @option{-m32}, except for that
33856it outputs the @code{.code16gcc} assembly directive at the beginning of
33857the assembly output so that the binary can run in 16-bit mode.
33858
33859The @option{-miamcu} option generates code which conforms to Intel MCU
33860psABI. It requires the @option{-m32} option to be turned on.
33861
33862@item -mno-red-zone
33863@opindex mno-red-zone
33864@opindex mred-zone
33865Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
33866by the x86-64 ABI; it is a 128-byte area beyond the location of the
33867stack pointer that is not modified by signal or interrupt handlers
33868and therefore can be used for temporary data without adjusting the stack
33869pointer. The flag @option{-mno-red-zone} disables this red zone.
33870
33871@item -mcmodel=small
33872@opindex mcmodel=small
33873Generate code for the small code model: the program and its symbols must
33874be linked in the lower 2 GB of the address space. Pointers are 64 bits.
33875Programs can be statically or dynamically linked. This is the default
33876code model.
33877
33878@item -mcmodel=kernel
33879@opindex mcmodel=kernel
33880Generate code for the kernel code model. The kernel runs in the
33881negative 2 GB of the address space.
33882This model has to be used for Linux kernel code.
33883
33884@item -mcmodel=medium
33885@opindex mcmodel=medium
33886Generate code for the medium model: the program is linked in the lower 2
33887GB of the address space. Small symbols are also placed there. Symbols
33888with sizes larger than @option{-mlarge-data-threshold} are put into
33889large data or BSS sections and can be located above 2GB. Programs can
33890be statically or dynamically linked.
33891
33892@item -mcmodel=large
33893@opindex mcmodel=large
33894Generate code for the large model. This model makes no assumptions
33895about addresses and sizes of sections.
33896
33897@item -maddress-mode=long
33898@opindex maddress-mode=long
33899Generate code for long address mode. This is only supported for 64-bit
33900and x32 environments. It is the default address mode for 64-bit
33901environments.
33902
33903@item -maddress-mode=short
33904@opindex maddress-mode=short
33905Generate code for short address mode. This is only supported for 32-bit
33906and x32 environments. It is the default address mode for 32-bit and
33907x32 environments.
33908
33909@item -mneeded
33910@itemx -mno-needed
33911@opindex mneeded
33912Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
33913indicate the micro-architecture ISA level required to execute the binary.
33914
33915@item -mno-direct-extern-access
33916@opindex mno-direct-extern-access
33917@opindex mdirect-extern-access
33918Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
33919to access external symbols. With @option{-fpic} or @option{-fPIC},
33920treat access to protected symbols as local symbols. The default is
33921@option{-mdirect-extern-access}.
33922
33923@strong{Warning:} shared libraries compiled with
33924@option{-mno-direct-extern-access} and executable compiled with
33925@option{-mdirect-extern-access} may not be binary compatible if
33926protected symbols are used in shared libraries and executable.
ce51e843
ML
33927
33928@item -munroll-only-small-loops
33929@opindex munroll-only-small-loops
33930@opindex mno-unroll-only-small-loops
33931Controls conservative small loop unrolling. It is default enabled by
33932O2, and unrolls loop with less than 4 insns by 1 time. Explicit
33933-f[no-]unroll-[all-]loops would disable this flag to avoid any
33934unintended unrolling behavior that user does not want.
bb576017 33935
33936@item -mlam=@var{choice}
33937@opindex mlam
33938LAM(linear-address masking) allows special bits in the pointer to be used
33939for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
33940positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
33941positions 62:57 can be used for metadata.
d77de738
ML
33942@end table
33943
33944@node x86 Windows Options
33945@subsection x86 Windows Options
33946@cindex x86 Windows Options
33947@cindex Windows Options for x86
33948
33949These additional options are available for Microsoft Windows targets:
33950
33951@table @gcctabopt
33952@item -mconsole
33953@opindex mconsole
33954This option
33955specifies that a console application is to be generated, by
33956instructing the linker to set the PE header subsystem type
33957required for console applications.
33958This option is available for Cygwin and MinGW targets and is
33959enabled by default on those targets.
33960
33961@item -mdll
33962@opindex mdll
33963This option is available for Cygwin and MinGW targets. It
33964specifies that a DLL---a dynamic link library---is to be
33965generated, enabling the selection of the required runtime
33966startup object and entry point.
33967
33968@item -mnop-fun-dllimport
33969@opindex mnop-fun-dllimport
33970This option is available for Cygwin and MinGW targets. It
33971specifies that the @code{dllimport} attribute should be ignored.
33972
33973@item -mthreads
33974@opindex mthreads
33975This option is available for MinGW targets. It specifies
33976that MinGW-specific thread support is to be used.
33977
33978@item -municode
33979@opindex municode
33980This option is available for MinGW-w64 targets. It causes
33981the @code{UNICODE} preprocessor macro to be predefined, and
33982chooses Unicode-capable runtime startup code.
33983
33984@item -mwin32
33985@opindex mwin32
33986This option is available for Cygwin and MinGW targets. It
33987specifies that the typical Microsoft Windows predefined macros are to
33988be set in the pre-processor, but does not influence the choice
33989of runtime library/startup code.
33990
33991@item -mwindows
33992@opindex mwindows
33993This option is available for Cygwin and MinGW targets. It
33994specifies that a GUI application is to be generated by
33995instructing the linker to set the PE header subsystem type
33996appropriately.
33997
33998@item -fno-set-stack-executable
33999@opindex fno-set-stack-executable
34000@opindex fset-stack-executable
34001This option is available for MinGW targets. It specifies that
34002the executable flag for the stack used by nested functions isn't
34003set. This is necessary for binaries running in kernel mode of
34004Microsoft Windows, as there the User32 API, which is used to set executable
34005privileges, isn't available.
34006
34007@item -fwritable-relocated-rdata
34008@opindex fno-writable-relocated-rdata
34009@opindex fwritable-relocated-rdata
34010This option is available for MinGW and Cygwin targets. It specifies
34011that relocated-data in read-only section is put into the @code{.data}
34012section. This is a necessary for older runtimes not supporting
34013modification of @code{.rdata} sections for pseudo-relocation.
34014
34015@item -mpe-aligned-commons
34016@opindex mpe-aligned-commons
34017This option is available for Cygwin and MinGW targets. It
34018specifies that the GNU extension to the PE file format that
34019permits the correct alignment of COMMON variables should be
34020used when generating code. It is enabled by default if
34021GCC detects that the target assembler found during configuration
34022supports the feature.
34023@end table
34024
34025See also under @ref{x86 Options} for standard options.
34026
34027@node Xstormy16 Options
34028@subsection Xstormy16 Options
34029@cindex Xstormy16 Options
34030
34031These options are defined for Xstormy16:
34032
34033@table @gcctabopt
34034@item -msim
34035@opindex msim
34036Choose startup files and linker script suitable for the simulator.
34037@end table
34038
34039@node Xtensa Options
34040@subsection Xtensa Options
34041@cindex Xtensa Options
34042
34043These options are supported for Xtensa targets:
34044
34045@table @gcctabopt
34046@item -mconst16
34047@itemx -mno-const16
34048@opindex mconst16
34049@opindex mno-const16
34050Enable or disable use of @code{CONST16} instructions for loading
34051constant values. The @code{CONST16} instruction is currently not a
34052standard option from Tensilica. When enabled, @code{CONST16}
34053instructions are always used in place of the standard @code{L32R}
34054instructions. The use of @code{CONST16} is enabled by default only if
34055the @code{L32R} instruction is not available.
34056
34057@item -mfused-madd
34058@itemx -mno-fused-madd
34059@opindex mfused-madd
34060@opindex mno-fused-madd
34061Enable or disable use of fused multiply/add and multiply/subtract
34062instructions in the floating-point option. This has no effect if the
34063floating-point option is not also enabled. Disabling fused multiply/add
34064and multiply/subtract instructions forces the compiler to use separate
34065instructions for the multiply and add/subtract operations. This may be
34066desirable in some cases where strict IEEE 754-compliant results are
34067required: the fused multiply add/subtract instructions do not round the
34068intermediate result, thereby producing results with @emph{more} bits of
34069precision than specified by the IEEE standard. Disabling fused multiply
34070add/subtract instructions also ensures that the program output is not
34071sensitive to the compiler's ability to combine multiply and add/subtract
34072operations.
34073
34074@item -mserialize-volatile
34075@itemx -mno-serialize-volatile
34076@opindex mserialize-volatile
34077@opindex mno-serialize-volatile
34078When this option is enabled, GCC inserts @code{MEMW} instructions before
34079@code{volatile} memory references to guarantee sequential consistency.
34080The default is @option{-mserialize-volatile}. Use
34081@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
34082
34083@item -mforce-no-pic
34084@opindex mforce-no-pic
34085For targets, like GNU/Linux, where all user-mode Xtensa code must be
34086position-independent code (PIC), this option disables PIC for compiling
34087kernel code.
34088
34089@item -mtext-section-literals
34090@itemx -mno-text-section-literals
34091@opindex mtext-section-literals
34092@opindex mno-text-section-literals
34093These options control the treatment of literal pools. The default is
34094@option{-mno-text-section-literals}, which places literals in a separate
34095section in the output file. This allows the literal pool to be placed
34096in a data RAM/ROM, and it also allows the linker to combine literal
34097pools from separate object files to remove redundant literals and
34098improve code size. With @option{-mtext-section-literals}, the literals
34099are interspersed in the text section in order to keep them as close as
34100possible to their references. This may be necessary for large assembly
34101files. Literals for each function are placed right before that function.
34102
34103@item -mauto-litpools
34104@itemx -mno-auto-litpools
34105@opindex mauto-litpools
34106@opindex mno-auto-litpools
34107These options control the treatment of literal pools. The default is
34108@option{-mno-auto-litpools}, which places literals in a separate
34109section in the output file unless @option{-mtext-section-literals} is
34110used. With @option{-mauto-litpools} the literals are interspersed in
34111the text section by the assembler. Compiler does not produce explicit
34112@code{.literal} directives and loads literals into registers with
34113@code{MOVI} instructions instead of @code{L32R} to let the assembler
34114do relaxation and place literals as necessary. This option allows
34115assembler to create several literal pools per function and assemble
34116very big functions, which may not be possible with
34117@option{-mtext-section-literals}.
34118
34119@item -mtarget-align
34120@itemx -mno-target-align
34121@opindex mtarget-align
34122@opindex mno-target-align
34123When this option is enabled, GCC instructs the assembler to
34124automatically align instructions to reduce branch penalties at the
34125expense of some code density. The assembler attempts to widen density
34126instructions to align branch targets and the instructions following call
34127instructions. If there are not enough preceding safe density
34128instructions to align a target, no widening is performed. The
34129default is @option{-mtarget-align}. These options do not affect the
34130treatment of auto-aligned instructions like @code{LOOP}, which the
34131assembler always aligns, either by widening density instructions or
34132by inserting NOP instructions.
34133
34134@item -mlongcalls
34135@itemx -mno-longcalls
34136@opindex mlongcalls
34137@opindex mno-longcalls
34138When this option is enabled, GCC instructs the assembler to translate
34139direct calls to indirect calls unless it can determine that the target
34140of a direct call is in the range allowed by the call instruction. This
34141translation typically occurs for calls to functions in other source
34142files. Specifically, the assembler translates a direct @code{CALL}
34143instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34144The default is @option{-mno-longcalls}. This option should be used in
34145programs where the call target can potentially be out of range. This
34146option is implemented in the assembler, not the compiler, so the
34147assembly code generated by GCC still shows direct call
34148instructions---look at the disassembled object code to see the actual
34149instructions. Note that the assembler uses an indirect call for
34150every cross-file call, not just those that really are out of range.
34151
34152@item -mabi=@var{name}
34153@opindex mabi
34154Generate code for the specified ABI@. Permissible values are: @samp{call0},
34155@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34156
34157@item -mabi=call0
34158@opindex mabi=call0
34159When this option is enabled function parameters are passed in registers
34160@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34161caller-saved, and register @code{a15} may be used as a frame pointer.
34162When this version of the ABI is enabled the C preprocessor symbol
34163@code{__XTENSA_CALL0_ABI__} is defined.
34164
34165@item -mabi=windowed
34166@opindex mabi=windowed
34167When this option is enabled function parameters are passed in registers
34168@code{a10} through @code{a15}, and called function rotates register window
34169by 8 registers on entry so that its arguments are found in registers
34170@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34171pointer. Register window is rotated 8 registers back upon return.
34172When this version of the ABI is enabled the C preprocessor symbol
34173@code{__XTENSA_WINDOWED_ABI__} is defined.
34174
34175@item -mextra-l32r-costs=@var{n}
34176@opindex mextra-l32r-costs
34177Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34178instructions, in clock cycles. This affects, when optimizing for speed,
34179whether loading a constant from literal pool using @code{L32R} or
34180synthesizing the constant from a small one with a couple of arithmetic
34181instructions. The default value is 0.
34182@end table
34183
34184@node zSeries Options
34185@subsection zSeries Options
34186@cindex zSeries options
34187
34188These are listed under @xref{S/390 and zSeries Options}.
34189
34190
34191@c man end
34192
34193@node Spec Files
34194@section Specifying Subprocesses and the Switches to Pass to Them
34195@cindex Spec Files
34196
34197@command{gcc} is a driver program. It performs its job by invoking a
34198sequence of other programs to do the work of compiling, assembling and
34199linking. GCC interprets its command-line parameters and uses these to
34200deduce which programs it should invoke, and which command-line options
34201it ought to place on their command lines. This behavior is controlled
34202by @dfn{spec strings}. In most cases there is one spec string for each
34203program that GCC can invoke, but a few programs have multiple spec
34204strings to control their behavior. The spec strings built into GCC can
34205be overridden by using the @option{-specs=} command-line switch to specify
34206a spec file.
34207
34208@dfn{Spec files} are plain-text files that are used to construct spec
34209strings. They consist of a sequence of directives separated by blank
34210lines. The type of directive is determined by the first non-whitespace
34211character on the line, which can be one of the following:
34212
34213@table @code
34214@item %@var{command}
34215Issues a @var{command} to the spec file processor. The commands that can
34216appear here are:
34217
34218@table @code
34219@item %include <@var{file}>
34220@cindex @code{%include}
34221Search for @var{file} and insert its text at the current point in the
34222specs file.
34223
34224@item %include_noerr <@var{file}>
34225@cindex @code{%include_noerr}
34226Just like @samp{%include}, but do not generate an error message if the include
34227file cannot be found.
34228
34229@item %rename @var{old_name} @var{new_name}
34230@cindex @code{%rename}
34231Rename the spec string @var{old_name} to @var{new_name}.
34232
34233@end table
34234
34235@item *[@var{spec_name}]:
34236This tells the compiler to create, override or delete the named spec
34237string. All lines after this directive up to the next directive or
34238blank line are considered to be the text for the spec string. If this
34239results in an empty string then the spec is deleted. (Or, if the
34240spec did not exist, then nothing happens.) Otherwise, if the spec
34241does not currently exist a new spec is created. If the spec does
34242exist then its contents are overridden by the text of this
34243directive, unless the first character of that text is the @samp{+}
34244character, in which case the text is appended to the spec.
34245
34246@item [@var{suffix}]:
34247Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
34248and up to the next directive or blank line are considered to make up the
34249spec string for the indicated suffix. When the compiler encounters an
34250input file with the named suffix, it processes the spec string in
34251order to work out how to compile that file. For example:
34252
34253@smallexample
34254.ZZ:
34255z-compile -input %i
34256@end smallexample
34257
34258This says that any input file whose name ends in @samp{.ZZ} should be
34259passed to the program @samp{z-compile}, which should be invoked with the
34260command-line switch @option{-input} and with the result of performing the
34261@samp{%i} substitution. (See below.)
34262
34263As an alternative to providing a spec string, the text following a
34264suffix directive can be one of the following:
34265
34266@table @code
34267@item @@@var{language}
34268This says that the suffix is an alias for a known @var{language}. This is
34269similar to using the @option{-x} command-line switch to GCC to specify a
34270language explicitly. For example:
34271
34272@smallexample
34273.ZZ:
34274@@c++
34275@end smallexample
34276
34277Says that .ZZ files are, in fact, C++ source files.
34278
34279@item #@var{name}
34280This causes an error messages saying:
34281
34282@smallexample
34283@var{name} compiler not installed on this system.
34284@end smallexample
34285@end table
34286
34287GCC already has an extensive list of suffixes built into it.
34288This directive adds an entry to the end of the list of suffixes, but
34289since the list is searched from the end backwards, it is effectively
34290possible to override earlier entries using this technique.
34291
34292@end table
34293
34294GCC has the following spec strings built into it. Spec files can
34295override these strings or create their own. Note that individual
34296targets can also add their own spec strings to this list.
34297
34298@smallexample
34299asm Options to pass to the assembler
34300asm_final Options to pass to the assembler post-processor
34301cpp Options to pass to the C preprocessor
34302cc1 Options to pass to the C compiler
34303cc1plus Options to pass to the C++ compiler
34304endfile Object files to include at the end of the link
34305link Options to pass to the linker
34306lib Libraries to include on the command line to the linker
34307libgcc Decides which GCC support library to pass to the linker
34308linker Sets the name of the linker
34309predefines Defines to be passed to the C preprocessor
34310signed_char Defines to pass to CPP to say whether @code{char} is signed
34311 by default
34312startfile Object files to include at the start of the link
34313@end smallexample
34314
34315Here is a small example of a spec file:
34316
34317@smallexample
34318%rename lib old_lib
34319
34320*lib:
34321--start-group -lgcc -lc -leval1 --end-group %(old_lib)
34322@end smallexample
34323
34324This example renames the spec called @samp{lib} to @samp{old_lib} and
34325then overrides the previous definition of @samp{lib} with a new one.
34326The new definition adds in some extra command-line options before
34327including the text of the old definition.
34328
34329@dfn{Spec strings} are a list of command-line options to be passed to their
34330corresponding program. In addition, the spec strings can contain
34331@samp{%}-prefixed sequences to substitute variable text or to
34332conditionally insert text into the command line. Using these constructs
34333it is possible to generate quite complex command lines.
34334
34335Here is a table of all defined @samp{%}-sequences for spec
34336strings. Note that spaces are not generated automatically around the
34337results of expanding these sequences. Therefore you can concatenate them
34338together or combine them with constant text in a single argument.
34339
34340@table @code
34341@item %%
34342Substitute one @samp{%} into the program name or argument.
34343
34344@item %"
34345Substitute an empty argument.
34346
34347@item %i
34348Substitute the name of the input file being processed.
34349
34350@item %b
34351Substitute the basename for outputs related with the input file being
34352processed. This is often the substring up to (and not including) the
34353last period and not including the directory but, unless %w is active, it
34354expands to the basename for auxiliary outputs, which may be influenced
34355by an explicit output name, and by various other options that control
34356how auxiliary outputs are named.
34357
34358@item %B
34359This is the same as @samp{%b}, but include the file suffix (text after
34360the last period). Without %w, it expands to the basename for dump
34361outputs.
34362
34363@item %d
34364Marks the argument containing or following the @samp{%d} as a
34365temporary file name, so that that file is deleted if GCC exits
34366successfully. Unlike @samp{%g}, this contributes no text to the
34367argument.
34368
34369@item %g@var{suffix}
34370Substitute a file name that has suffix @var{suffix} and is chosen
34371once per compilation, and mark the argument in the same way as
34372@samp{%d}. To reduce exposure to denial-of-service attacks, the file
34373name is now chosen in a way that is hard to predict even when previously
34374chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
34375might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
34376the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
34377treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
34378was simply substituted with a file name chosen once per compilation,
34379without regard to any appended suffix (which was therefore treated
34380just like ordinary text), making such attacks more likely to succeed.
34381
34382@item %u@var{suffix}
34383Like @samp{%g}, but generates a new temporary file name
34384each time it appears instead of once per compilation.
34385
34386@item %U@var{suffix}
34387Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
34388new one if there is no such last file name. In the absence of any
34389@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
34390the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
34391involves the generation of two distinct file names, one
34392for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
34393simply substituted with a file name chosen for the previous @samp{%u},
34394without regard to any appended suffix.
34395
34396@item %j@var{suffix}
34397Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
34398writable, and if @option{-save-temps} is not used;
34399otherwise, substitute the name
34400of a temporary file, just like @samp{%u}. This temporary file is not
34401meant for communication between processes, but rather as a junk
34402disposal mechanism.
34403
34404@item %|@var{suffix}
34405@itemx %m@var{suffix}
34406Like @samp{%g}, except if @option{-pipe} is in effect. In that case
34407@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
34408all. These are the two most common ways to instruct a program that it
34409should read from standard input or write to standard output. If you
34410need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
34411construct: see for example @file{gcc/fortran/lang-specs.h}.
34412
34413@item %.@var{SUFFIX}
34414Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
34415when it is subsequently output with @samp{%*}. @var{SUFFIX} is
34416terminated by the next space or %.
34417
34418@item %w
34419Marks the argument containing or following the @samp{%w} as the
34420designated output file of this compilation. This puts the argument
34421into the sequence of arguments that @samp{%o} substitutes.
34422
34423@item %V
34424Indicates that this compilation produces no output file.
34425
34426@item %o
34427Substitutes the names of all the output files, with spaces
34428automatically placed around them. You should write spaces
34429around the @samp{%o} as well or the results are undefined.
34430@samp{%o} is for use in the specs for running the linker.
34431Input files whose names have no recognized suffix are not compiled
34432at all, but they are included among the output files, so they are
34433linked.
34434
34435@item %O
34436Substitutes the suffix for object files. Note that this is
34437handled specially when it immediately follows @samp{%g, %u, or %U},
34438because of the need for those to form complete file names. The
34439handling is such that @samp{%O} is treated exactly as if it had already
34440been substituted, except that @samp{%g, %u, and %U} do not currently
34441support additional @var{suffix} characters following @samp{%O} as they do
34442following, for example, @samp{.o}.
34443
34444@item %I
34445Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
34446@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
34447@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
34448and @option{-imultilib} as necessary.
34449
34450@item %s
34451Current argument is the name of a library or startup file of some sort.
34452Search for that file in a standard list of directories and substitute
34453the full name found. The current working directory is included in the
34454list of directories scanned.
34455
34456@item %T
34457Current argument is the name of a linker script. Search for that file
34458in the current list of directories to scan for libraries. If the file
34459is located insert a @option{--script} option into the command line
34460followed by the full path name found. If the file is not found then
34461generate an error message. Note: the current working directory is not
34462searched.
34463
34464@item %e@var{str}
34465Print @var{str} as an error message. @var{str} is terminated by a newline.
34466Use this when inconsistent options are detected.
34467
34468@item %n@var{str}
34469Print @var{str} as a notice. @var{str} is terminated by a newline.
34470
34471@item %(@var{name})
34472Substitute the contents of spec string @var{name} at this point.
34473
34474@item %x@{@var{option}@}
34475Accumulate an option for @samp{%X}.
34476
34477@item %X
34478Output the accumulated linker options specified by a @samp{%x} spec string.
34479
34480@item %Y
34481Output the accumulated assembler options specified by @option{-Wa}.
34482
34483@item %Z
34484Output the accumulated preprocessor options specified by @option{-Wp}.
34485
34486@item %M
34487Output @code{multilib_os_dir}.
34488
34489@item %R
34490Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
34491
34492@item %a
34493Process the @code{asm} spec. This is used to compute the
34494switches to be passed to the assembler.
34495
34496@item %A
34497Process the @code{asm_final} spec. This is a spec string for
34498passing switches to an assembler post-processor, if such a program is
34499needed.
34500
34501@item %l
34502Process the @code{link} spec. This is the spec for computing the
34503command line passed to the linker. Typically it makes use of the
34504@samp{%L %G %S %D and %E} sequences.
34505
34506@item %D
34507Dump out a @option{-L} option for each directory that GCC believes might
34508contain startup files. If the target supports multilibs then the
34509current multilib directory is prepended to each of these paths.
34510
34511@item %L
34512Process the @code{lib} spec. This is a spec string for deciding which
34513libraries are included on the command line to the linker.
34514
34515@item %G
34516Process the @code{libgcc} spec. This is a spec string for deciding
34517which GCC support library is included on the command line to the linker.
34518
34519@item %S
34520Process the @code{startfile} spec. This is a spec for deciding which
34521object files are the first ones passed to the linker. Typically
34522this might be a file named @file{crt0.o}.
34523
34524@item %E
34525Process the @code{endfile} spec. This is a spec string that specifies
34526the last object files that are passed to the linker.
34527
34528@item %C
34529Process the @code{cpp} spec. This is used to construct the arguments
34530to be passed to the C preprocessor.
34531
34532@item %1
34533Process the @code{cc1} spec. This is used to construct the options to be
34534passed to the actual C compiler (@command{cc1}).
34535
34536@item %2
34537Process the @code{cc1plus} spec. This is used to construct the options to be
34538passed to the actual C++ compiler (@command{cc1plus}).
34539
34540@item %*
34541Substitute the variable part of a matched option. See below.
34542Note that each comma in the substituted string is replaced by
34543a single space.
34544
34545@item %<S
34546Remove all occurrences of @code{-S} from the command line. Note---this
34547command is position dependent. @samp{%} commands in the spec string
34548before this one see @code{-S}, @samp{%} commands in the spec string
34549after this one do not.
34550
34551@item %<S*
34552Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
34553
34554@item %>S
34555Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
34556
34557@item %:@var{function}(@var{args})
34558Call the named function @var{function}, passing it @var{args}.
34559@var{args} is first processed as a nested spec string, then split
34560into an argument vector in the usual fashion. The function returns
34561a string which is processed as if it had appeared literally as part
34562of the current spec.
34563
34564The following built-in spec functions are provided:
34565
34566@table @code
34567@item @code{getenv}
34568The @code{getenv} spec function takes two arguments: an environment
34569variable name and a string. If the environment variable is not
34570defined, a fatal error is issued. Otherwise, the return value is the
34571value of the environment variable concatenated with the string. For
34572example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
34573
34574@smallexample
34575%:getenv(TOPDIR /include)
34576@end smallexample
34577
34578expands to @file{/path/to/top/include}.
34579
34580@item @code{if-exists}
34581The @code{if-exists} spec function takes one argument, an absolute
34582pathname to a file. If the file exists, @code{if-exists} returns the
34583pathname. Here is a small example of its usage:
34584
34585@smallexample
34586*startfile:
34587crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
34588@end smallexample
34589
34590@item @code{if-exists-else}
34591The @code{if-exists-else} spec function is similar to the @code{if-exists}
34592spec function, except that it takes two arguments. The first argument is
34593an absolute pathname to a file. If the file exists, @code{if-exists-else}
34594returns the pathname. If it does not exist, it returns the second argument.
34595This way, @code{if-exists-else} can be used to select one file or another,
34596based on the existence of the first. Here is a small example of its usage:
34597
34598@smallexample
34599*startfile:
34600crt0%O%s %:if-exists(crti%O%s) \
34601%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
34602@end smallexample
34603
34604@item @code{if-exists-then-else}
34605The @code{if-exists-then-else} spec function takes at least two arguments
34606and an optional third one. The first argument is an absolute pathname to a
34607file. If the file exists, the function returns the second argument.
34608If the file does not exist, the function returns the third argument if there
34609is one, or NULL otherwise. This can be used to expand one text, or optionally
34610another, based on the existence of a file. Here is a small example of its
34611usage:
34612
34613@smallexample
34614-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
34615@end smallexample
34616
34617@item @code{sanitize}
34618The @code{sanitize} spec function takes no arguments. It returns non-NULL if
34619any address, thread or undefined behavior sanitizers are active.
34620
34621@smallexample
34622%@{%:sanitize(address):-funwind-tables@}
34623@end smallexample
34624
34625@item @code{replace-outfile}
34626The @code{replace-outfile} spec function takes two arguments. It looks for the
34627first argument in the outfiles array and replaces it with the second argument. Here
34628is a small example of its usage:
34629
34630@smallexample
34631%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
34632@end smallexample
34633
34634@item @code{remove-outfile}
34635The @code{remove-outfile} spec function takes one argument. It looks for the
34636first argument in the outfiles array and removes it. Here is a small example
34637its usage:
34638
34639@smallexample
34640%:remove-outfile(-lm)
34641@end smallexample
34642
34643@item @code{version-compare}
34644The @code{version-compare} spec function takes four or five arguments of the following
34645form:
34646
34647@smallexample
34648<comparison-op> <arg1> [<arg2>] <switch> <result>
34649@end smallexample
34650
34651It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
34652The supported @code{comparison-op} values are:
34653
34654@table @code
34655@item >=
34656True if @code{switch} is a later (or same) version than @code{arg1}
34657
34658@item !>
34659Opposite of @code{>=}
34660
34661@item <
34662True if @code{switch} is an earlier version than @code{arg1}
34663
34664@item !<
34665Opposite of @code{<}
34666
34667@item ><
34668True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
34669
34670@item <>
34671True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
34672@end table
34673
34674If the @code{switch} is not present at all, the condition is false unless the first character
34675of the @code{comparison-op} is @code{!}.
34676
34677@smallexample
34678%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
34679@end smallexample
34680
34681The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
34682passed.
34683
34684@item @code{include}
34685The @code{include} spec function behaves much like @code{%include}, with the advantage
34686that it can be nested inside a spec and thus be conditionalized. It takes one argument,
34687the filename, and looks for it in the startfile path. It always returns NULL.
34688
34689@smallexample
34690%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
34691@end smallexample
34692
34693@item @code{pass-through-libs}
34694The @code{pass-through-libs} spec function takes any number of arguments. It
34695finds any @option{-l} options and any non-options ending in @file{.a} (which it
34696assumes are the names of linker input library archive files) and returns a
34697result containing all the found arguments each prepended by
34698@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
34699intended to be passed to the LTO linker plugin.
34700
34701@smallexample
34702%:pass-through-libs(%G %L %G)
34703@end smallexample
34704
34705@item @code{print-asm-header}
34706The @code{print-asm-header} function takes no arguments and simply
34707prints a banner like:
34708
34709@smallexample
34710Assembler options
34711=================
34712
34713Use "-Wa,OPTION" to pass "OPTION" to the assembler.
34714@end smallexample
34715
34716It is used to separate compiler options from assembler options
34717in the @option{--target-help} output.
34718
34719@item @code{gt}
34720The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
34721empty string) if the second-to-last argument is greater than the last argument, and NULL
34722otherwise. The following example inserts the @code{link_gomp} spec if the last
34723@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
34724
34725@smallexample
34726%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
34727@end smallexample
34728
34729@item @code{debug-level-gt}
34730The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
34731empty string) if @code{debug_info_level} is greater than the specified number, and NULL
34732otherwise.
34733
34734@smallexample
34735%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
34736@end smallexample
34737@end table
34738
34739@item %@{S@}
34740Substitutes the @code{-S} switch, if that switch is given to GCC@.
34741If that switch is not specified, this substitutes nothing. Note that
34742the leading dash is omitted when specifying this option, and it is
34743automatically inserted if the substitution is performed. Thus the spec
34744string @samp{%@{foo@}} matches the command-line option @option{-foo}
34745and outputs the command-line option @option{-foo}.
34746
34747@item %W@{S@}
34748Like %@{@code{S}@} but mark last argument supplied within as a file to be
34749deleted on failure.
34750
34751@item %@@@{S@}
34752Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
34753@code{@@FILE} if an @code{@@file} argument has been supplied.
34754
34755@item %@{S*@}
34756Substitutes all the switches specified to GCC whose names start
34757with @code{-S}, but which also take an argument. This is used for
34758switches like @option{-o}, @option{-D}, @option{-I}, etc.
34759GCC considers @option{-o foo} as being
34760one switch whose name starts with @samp{o}. %@{o*@} substitutes this
34761text, including the space. Thus two arguments are generated.
34762
34763@item %@{S*&T*@}
34764Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
34765(the order of @code{S} and @code{T} in the spec is not significant).
34766There can be any number of ampersand-separated variables; for each the
34767wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
34768
34769@item %@{S:X@}
34770Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
34771
34772@item %@{!S:X@}
34773Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
34774
34775@item %@{S*:X@}
34776Substitutes @code{X} if one or more switches whose names start with
34777@code{-S} are specified to GCC@. Normally @code{X} is substituted only
34778once, no matter how many such switches appeared. However, if @code{%*}
34779appears somewhere in @code{X}, then @code{X} is substituted once
34780for each matching switch, with the @code{%*} replaced by the part of
34781that switch matching the @code{*}.
34782
34783If @code{%*} appears as the last part of a spec sequence then a space
34784is added after the end of the last substitution. If there is more
34785text in the sequence, however, then a space is not generated. This
34786allows the @code{%*} substitution to be used as part of a larger
34787string. For example, a spec string like this:
34788
34789@smallexample
34790%@{mcu=*:--script=%*/memory.ld@}
34791@end smallexample
34792
34793@noindent
34794when matching an option like @option{-mcu=newchip} produces:
34795
34796@smallexample
34797--script=newchip/memory.ld
34798@end smallexample
34799
34800@item %@{.S:X@}
34801Substitutes @code{X}, if processing a file with suffix @code{S}.
34802
34803@item %@{!.S:X@}
34804Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
34805
34806@item %@{,S:X@}
34807Substitutes @code{X}, if processing a file for language @code{S}.
34808
34809@item %@{!,S:X@}
34810Substitutes @code{X}, if not processing a file for language @code{S}.
34811
34812@item %@{S|P:X@}
34813Substitutes @code{X} if either @code{-S} or @code{-P} is given to
34814GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
34815@code{*} sequences as well, although they have a stronger binding than
34816the @samp{|}. If @code{%*} appears in @code{X}, all of the
34817alternatives must be starred, and only the first matching alternative
34818is substituted.
34819
34820For example, a spec string like this:
34821
34822@smallexample
34823%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
34824@end smallexample
34825
34826@noindent
34827outputs the following command-line options from the following input
34828command-line options:
34829
34830@smallexample
34831fred.c -foo -baz
34832jim.d -bar -boggle
34833-d fred.c -foo -baz -boggle
34834-d jim.d -bar -baz -boggle
34835@end smallexample
34836
34837@item %@{%:@var{function}(@var{args}):X@}
34838
34839Call function named @var{function} with args @var{args}. If the
34840function returns non-NULL, then @code{X} is substituted, if it returns
34841NULL, it isn't substituted.
34842
34843@item %@{S:X; T:Y; :D@}
34844
34845If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
34846given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
34847be as many clauses as you need. This may be combined with @code{.},
34848@code{,}, @code{!}, @code{|}, and @code{*} as needed.
34849
34850
34851@end table
34852
34853The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
34854or similar construct can use a backslash to ignore the special meaning
34855of the character following it, thus allowing literal matching of a
34856character that is otherwise specially treated. For example,
34857@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
34858@option{-std=iso9899:1999} option is given.
34859
34860The conditional text @code{X} in a @samp{%@{S:X@}} or similar
34861construct may contain other nested @samp{%} constructs or spaces, or
34862even newlines. They are processed as usual, as described above.
34863Trailing white space in @code{X} is ignored. White space may also
34864appear anywhere on the left side of the colon in these constructs,
34865except between @code{.} or @code{*} and the corresponding word.
34866
34867The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
34868handled specifically in these constructs. If another value of
34869@option{-O} or the negated form of a @option{-f}, @option{-m}, or
34870@option{-W} switch is found later in the command line, the earlier
34871switch value is ignored, except with @{@code{S}*@} where @code{S} is
34872just one letter, which passes all matching options.
34873
34874The character @samp{|} at the beginning of the predicate text is used to
34875indicate that a command should be piped to the following command, but
34876only if @option{-pipe} is specified.
34877
34878It is built into GCC which switches take arguments and which do not.
34879(You might think it would be useful to generalize this to allow each
34880compiler's spec to say which switches take arguments. But this cannot
34881be done in a consistent fashion. GCC cannot even decide which input
34882files have been specified without knowing which switches take arguments,
34883and it must know which input files to compile in order to tell which
34884compilers to run).
34885
34886GCC also knows implicitly that arguments starting in @option{-l} are to be
34887treated as compiler output files, and passed to the linker in their
34888proper position among the other output files.
34889
34890@node Environment Variables
34891@section Environment Variables Affecting GCC
34892@cindex environment variables
34893
34894@c man begin ENVIRONMENT
34895This section describes several environment variables that affect how GCC
34896operates. Some of them work by specifying directories or prefixes to use
34897when searching for various kinds of files. Some are used to specify other
34898aspects of the compilation environment.
34899
34900Note that you can also specify places to search using options such as
34901@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
34902take precedence over places specified using environment variables, which
34903in turn take precedence over those specified by the configuration of GCC@.
34904@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
34905GNU Compiler Collection (GCC) Internals}.
34906
34907@table @env
34908@item LANG
34909@itemx LC_CTYPE
34910@c @itemx LC_COLLATE
34911@itemx LC_MESSAGES
34912@c @itemx LC_MONETARY
34913@c @itemx LC_NUMERIC
34914@c @itemx LC_TIME
34915@itemx LC_ALL
34916@findex LANG
34917@findex LC_CTYPE
34918@c @findex LC_COLLATE
34919@findex LC_MESSAGES
34920@c @findex LC_MONETARY
34921@c @findex LC_NUMERIC
34922@c @findex LC_TIME
34923@findex LC_ALL
34924@cindex locale
34925These environment variables control the way that GCC uses
34926localization information which allows GCC to work with different
34927national conventions. GCC inspects the locale categories
34928@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
34929so. These locale categories can be set to any value supported by your
34930installation. A typical value is @samp{en_GB.UTF-8} for English in the United
34931Kingdom encoded in UTF-8.
34932
34933The @env{LC_CTYPE} environment variable specifies character
34934classification. GCC uses it to determine the character boundaries in
34935a string; this is needed for some multibyte encodings that contain quote
34936and escape characters that are otherwise interpreted as a string
34937end or escape.
34938
34939The @env{LC_MESSAGES} environment variable specifies the language to
34940use in diagnostic messages.
34941
34942If the @env{LC_ALL} environment variable is set, it overrides the value
34943of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
34944and @env{LC_MESSAGES} default to the value of the @env{LANG}
34945environment variable. If none of these variables are set, GCC
34946defaults to traditional C English behavior.
34947
34948@item TMPDIR
34949@findex TMPDIR
34950If @env{TMPDIR} is set, it specifies the directory to use for temporary
34951files. GCC uses temporary files to hold the output of one stage of
34952compilation which is to be used as input to the next stage: for example,
34953the output of the preprocessor, which is the input to the compiler
34954proper.
34955
34956@item GCC_COMPARE_DEBUG
34957@findex GCC_COMPARE_DEBUG
34958Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
34959@option{-fcompare-debug} to the compiler driver. See the documentation
34960of this option for more details.
34961
34962@item GCC_EXEC_PREFIX
34963@findex GCC_EXEC_PREFIX
34964If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
34965names of the subprograms executed by the compiler. No slash is added
34966when this prefix is combined with the name of a subprogram, but you can
34967specify a prefix that ends with a slash if you wish.
34968
34969If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
34970an appropriate prefix to use based on the pathname it is invoked with.
34971
34972If GCC cannot find the subprogram using the specified prefix, it
34973tries looking in the usual places for the subprogram.
34974
34975The default value of @env{GCC_EXEC_PREFIX} is
34976@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
34977the installed compiler. In many cases @var{prefix} is the value
34978of @code{prefix} when you ran the @file{configure} script.
34979
34980Other prefixes specified with @option{-B} take precedence over this prefix.
34981
34982This prefix is also used for finding files such as @file{crt0.o} that are
34983used for linking.
34984
34985In addition, the prefix is used in an unusual way in finding the
34986directories to search for header files. For each of the standard
34987directories whose name normally begins with @samp{/usr/local/lib/gcc}
34988(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
34989replacing that beginning with the specified prefix to produce an
34990alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
34991@file{foo/bar} just before it searches the standard directory
34992@file{/usr/local/lib/bar}.
34993If a standard directory begins with the configured
34994@var{prefix} then the value of @var{prefix} is replaced by
34995@env{GCC_EXEC_PREFIX} when looking for header files.
34996
34997@item COMPILER_PATH
34998@findex COMPILER_PATH
34999The value of @env{COMPILER_PATH} is a colon-separated list of
35000directories, much like @env{PATH}. GCC tries the directories thus
35001specified when searching for subprograms, if it cannot find the
35002subprograms using @env{GCC_EXEC_PREFIX}.
35003
35004@item LIBRARY_PATH
35005@findex LIBRARY_PATH
35006The value of @env{LIBRARY_PATH} is a colon-separated list of
35007directories, much like @env{PATH}. When configured as a native compiler,
35008GCC tries the directories thus specified when searching for special
35009linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35010using GCC also uses these directories when searching for ordinary
35011libraries for the @option{-l} option (but directories specified with
35012@option{-L} come first).
35013
35014@item LANG
35015@findex LANG
35016@cindex locale definition
35017This variable is used to pass locale information to the compiler. One way in
35018which this information is used is to determine the character set to be used
35019when character literals, string literals and comments are parsed in C and C++.
35020When the compiler is configured to allow multibyte characters,
35021the following values for @env{LANG} are recognized:
35022
35023@table @samp
35024@item C-JIS
35025Recognize JIS characters.
35026@item C-SJIS
35027Recognize SJIS characters.
35028@item C-EUCJP
35029Recognize EUCJP characters.
35030@end table
35031
35032If @env{LANG} is not defined, or if it has some other value, then the
35033compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35034recognize and translate multibyte characters.
35035
35036@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
35037@findex GCC_EXTRA_DIAGNOSTIC_OUTPUT
35038If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
35039then additional text will be emitted to stderr when fix-it hints are
35040emitted. @option{-fdiagnostics-parseable-fixits} and
35041@option{-fno-diagnostics-parseable-fixits} take precedence over this
35042environment variable.
35043
35044@table @samp
35045@item fixits-v1
35046Emit parseable fix-it hints, equivalent to
35047@option{-fdiagnostics-parseable-fixits}. In particular, columns are
35048expressed as a count of bytes, starting at byte 1 for the initial column.
35049
35050@item fixits-v2
35051As @code{fixits-v1}, but columns are expressed as display columns,
35052as per @option{-fdiagnostics-column-unit=display}.
35053@end table
35054
35055@end table
35056
35057@noindent
35058Some additional environment variables affect the behavior of the
35059preprocessor.
35060
35061@include cppenv.texi
35062
35063@c man end
35064
35065@node Precompiled Headers
35066@section Using Precompiled Headers
35067@cindex precompiled headers
35068@cindex speed of compilation
35069
35070Often large projects have many header files that are included in every
35071source file. The time the compiler takes to process these header files
35072over and over again can account for nearly all of the time required to
35073build the project. To make builds faster, GCC allows you to
35074@dfn{precompile} a header file.
35075
35076To create a precompiled header file, simply compile it as you would any
35077other file, if necessary using the @option{-x} option to make the driver
35078treat it as a C or C++ header file. You may want to use a
35079tool like @command{make} to keep the precompiled header up-to-date when
35080the headers it contains change.
35081
35082A precompiled header file is searched for when @code{#include} is
35083seen in the compilation. As it searches for the included file
35084(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
35085compiler looks for a precompiled header in each directory just before it
35086looks for the include file in that directory. The name searched for is
35087the name specified in the @code{#include} with @samp{.gch} appended. If
35088the precompiled header file cannot be used, it is ignored.
35089
35090For instance, if you have @code{#include "all.h"}, and you have
35091@file{all.h.gch} in the same directory as @file{all.h}, then the
35092precompiled header file is used if possible, and the original
35093header is used otherwise.
35094
35095Alternatively, you might decide to put the precompiled header file in a
35096directory and use @option{-I} to ensure that directory is searched
35097before (or instead of) the directory containing the original header.
35098Then, if you want to check that the precompiled header file is always
35099used, you can put a file of the same name as the original header in this
35100directory containing an @code{#error} command.
35101
35102This also works with @option{-include}. So yet another way to use
35103precompiled headers, good for projects not designed with precompiled
35104header files in mind, is to simply take most of the header files used by
35105a project, include them from another header file, precompile that header
35106file, and @option{-include} the precompiled header. If the header files
35107have guards against multiple inclusion, they are skipped because
35108they've already been included (in the precompiled header).
35109
35110If you need to precompile the same header file for different
35111languages, targets, or compiler options, you can instead make a
35112@emph{directory} named like @file{all.h.gch}, and put each precompiled
35113header in the directory, perhaps using @option{-o}. It doesn't matter
35114what you call the files in the directory; every precompiled header in
35115the directory is considered. The first precompiled header
35116encountered in the directory that is valid for this compilation is
35117used; they're searched in no particular order.
35118
35119There are many other possibilities, limited only by your imagination,
35120good sense, and the constraints of your build system.
35121
35122A precompiled header file can be used only when these conditions apply:
35123
35124@itemize
35125@item
35126Only one precompiled header can be used in a particular compilation.
35127
35128@item
35129A precompiled header cannot be used once the first C token is seen. You
35130can have preprocessor directives before a precompiled header; you cannot
35131include a precompiled header from inside another header.
35132
35133@item
35134The precompiled header file must be produced for the same language as
35135the current compilation. You cannot use a C precompiled header for a C++
35136compilation.
35137
35138@item
35139The precompiled header file must have been produced by the same compiler
35140binary as the current compilation is using.
35141
35142@item
35143Any macros defined before the precompiled header is included must
35144either be defined in the same way as when the precompiled header was
35145generated, or must not affect the precompiled header, which usually
35146means that they don't appear in the precompiled header at all.
35147
35148The @option{-D} option is one way to define a macro before a
35149precompiled header is included; using a @code{#define} can also do it.
35150There are also some options that define macros implicitly, like
35151@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35152defined this way.
35153
35154@item If debugging information is output when using the precompiled
35155header, using @option{-g} or similar, the same kind of debugging information
35156must have been output when building the precompiled header. However,
35157a precompiled header built using @option{-g} can be used in a compilation
35158when no debugging information is being output.
35159
35160@item The same @option{-m} options must generally be used when building
35161and using the precompiled header. @xref{Submodel Options},
35162for any cases where this rule is relaxed.
35163
35164@item Each of the following options must be the same when building and using
35165the precompiled header:
35166
35167@gccoptlist{-fexceptions}
35168
35169@item
35170Some other command-line options starting with @option{-f},
35171@option{-p}, or @option{-O} must be defined in the same way as when
35172the precompiled header was generated. At present, it's not clear
35173which options are safe to change and which are not; the safest choice
35174is to use exactly the same options when generating and using the
35175precompiled header. The following are known to be safe:
35176
35177@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock @gol
35178-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous @gol
35179-fsched-verbose=@var{number} -fschedule-insns -fvisibility= @gol
35180-pedantic-errors}
35181
35182@item Address space layout randomization (ASLR) can lead to not binary identical
35183PCH files. If you rely on stable PCH file contents disable ASLR when generating
35184PCH files.
35185
35186@end itemize
35187
35188For all of these except the last, the compiler automatically
35189ignores the precompiled header if the conditions aren't met. If you
35190find an option combination that doesn't work and doesn't cause the
35191precompiled header to be ignored, please consider filing a bug report,
35192see @ref{Bugs}.
35193
35194If you do use differing options when generating and using the
35195precompiled header, the actual behavior is a mixture of the
35196behavior for the options. For instance, if you use @option{-g} to
35197generate the precompiled header but not when using it, you may or may
35198not get debugging information for routines in the precompiled header.
35199
35200@node C++ Modules
35201@section C++ Modules
35202@cindex speed of compilation
35203
35204Modules are a C++20 language feature. As the name suggests, they
35205provides a modular compilation system, intending to provide both
35206faster builds and better library isolation. The ``Merging Modules''
35207paper @uref{https://wg21.link/p1103}, provides the easiest to read set
35208of changes to the standard, although it does not capture later
35209changes.
35210
35211@emph{G++'s modules support is not complete.} Other than bugs, the
35212known missing pieces are:
35213
35214@table @emph
35215
35216@item Private Module Fragment
35217The Private Module Fragment is recognized, but an error is emitted.
35218
35219@item Partition definition visibility rules
35220Entities may be defined in implementation partitions, and those
35221definitions are not available outside of the module. This is not
35222implemented, and the definitions are available to extra-module use.
35223
35224@item Textual merging of reachable GM entities
35225Entities may be multiply defined across different header-units.
35226These must be de-duplicated, and this is implemented across imports,
35227or when an import redefines a textually-defined entity. However the
35228reverse is not implemented---textually redefining an entity that has
35229been defined in an imported header-unit. A redefinition error is
35230emitted.
35231
35232@item Translation-Unit local referencing rules
35233Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
35234(@uref{https://wg21.link/p2003}) add limitations on which entities an
35235exported region may reference (for instance, the entities an exported
35236template definition may reference). These are not fully implemented.
35237
35238@item Standard Library Header Units
35239The Standard Library is not provided as importable header units. If
35240you want to import such units, you must explicitly build them first.
35241If you do not do this with care, you may have multiple declarations,
35242which the module machinery must merge---compiler resource usage can be
35243affected by how you partition header files into header units.
35244
35245@end table
35246
35247Modular compilation is @emph{not} enabled with just the
35248@option{-std=c++20} option. You must explicitly enable it with the
35249@option{-fmodules-ts} option. It is independent of the language
35250version selected, although in pre-C++20 versions, it is of course an
35251extension.
35252
35253No new source file suffixes are required or supported. If you wish to
35254use a non-standard suffix (@pxref{Overall Options}), you also need
35255to provide a @option{-x c++} option too.@footnote{Some users like to
35256distinguish module interface files with a new suffix, such as naming
35257the source @code{module.cppm}, which involves
35258teaching all tools about the new suffix. A different scheme, such as
35259naming @code{module-m.cpp} would be less invasive.}
35260
35261Compiling a module interface unit produces an additional output (to
35262the assembly or object file), called a Compiled Module Interface
35263(CMI). This encodes the exported declarations of the module.
35264Importing a module reads in the CMI. The import graph is a Directed
35265Acyclic Graph (DAG). You must build imports before the importer.
35266
35267Header files may themselves be compiled to header units, which are a
35268transitional ability aiming at faster compilation. The
35269@option{-fmodule-header} option is used to enable this, and implies
35270the @option{-fmodules-ts} option. These CMIs are named by the fully
35271resolved underlying header file, and thus may be a complete pathname
35272containing subdirectories. If the header file is found at an absolute
35273pathname, the CMI location is still relative to a CMI root directory.
35274
35275As header files often have no suffix, you commonly have to specify a
35276@option{-x} option to tell the compiler the source is a header file.
35277You may use @option{-x c++-header}, @option{-x c++-user-header} or
35278@option{-x c++-system-header}. When used in conjunction with
35279@option{-fmodules-ts}, these all imply an appropriate
35280@option{-fmodule-header} option. The latter two variants use the
35281user or system include path to search for the file specified. This
35282allows you to, for instance, compile standard library header files as
35283header units, without needing to know exactly where they are
35284installed. Specifying the language as one of these variants also
35285inhibits output of the object file, as header files have no associated
35286object file.
35287
35288The @option{-fmodule-only} option disables generation of the
35289associated object file for compiling a module interface. Only the CMI
35290is generated. This option is implied when using the
35291@option{-fmodule-header} option.
35292
35293The @option{-flang-info-include-translate} and
35294@option{-flang-info-include-translate-not} options notes whether
35295include translation occurs or not. With no argument, the first will
35296note all include translation. The second will note all
35297non-translations of include files not known to intentionally be
35298textual. With an argument, queries about include translation of a
35299header files with that particular trailing pathname are noted. You
35300may repeat this form to cover several different header files. This
35301option may be helpful in determining whether include translation is
35302happening---if it is working correctly, it behaves as if it isn't
35303there at all.
35304
35305The @option{-flang-info-module-cmi} option can be used to determine
35306where the compiler is reading a CMI from. Without the option, the
35307compiler is silent when such a read is successful. This option has an
35308optional argument, which will restrict the notification to just the
35309set of named modules or header units specified.
35310
35311The @option{-Winvalid-imported-macros} option causes all imported macros
35312to be resolved at the end of compilation. Without this, imported
35313macros are only resolved when expanded or (re)defined. This option
35314detects conflicting import definitions for all macros.
35315
35316For details of the @option{-fmodule-mapper} family of options,
35317@pxref{C++ Module Mapper}.
35318
35319@menu
35320* C++ Module Mapper:: Module Mapper
35321* C++ Module Preprocessing:: Module Preprocessing
35322* C++ Compiled Module Interface:: Compiled Module Interface
35323@end menu
35324
35325@node C++ Module Mapper
35326@subsection Module Mapper
35327@cindex C++ Module Mapper
35328
35329A module mapper provides a server or file that the compiler queries to
35330determine the mapping between module names and CMI files. It is also
35331used to build CMIs on demand. @emph{Mapper functionality is in its
35332infancy and is intended for experimentation with build system
35333interactions.}
35334
35335You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
35336option or @env{CXX_MODULE_MAPPER} environment variable. The value may
35337have one of the following forms:
35338
35339@table @gcctabopt
35340
35341@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
35342An optional hostname and a numeric port number to connect to. If the
35343hostname is omitted, the loopback address is used. If the hostname
35344corresponds to multiple IPV6 addresses, these are tried in turn, until
35345one is successful. If your host lacks IPv6, this form is
35346non-functional. If you must use IPv4 use
35347@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
35348
35349@item =@var{socket}@r{[}?@var{ident}@r{]}
35350A local domain socket. If your host lacks local domain sockets, this
35351form is non-functional.
35352
35353@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
35354A program to spawn, and communicate with on its stdin/stdout streams.
35355Your @var{PATH} environment variable is searched for the program.
35356Arguments are separated by space characters, (it is not possible for
35357one of the arguments delivered to the program to contain a space). An
35358exception is if @var{program} begins with @@. In that case
35359@var{program} (sans @@) is looked for in the compiler's internal
35360binary directory. Thus the sample mapper-server can be specified
35361with @code{@@g++-mapper-server}.
35362
35363@item <>@r{[}?@var{ident}@r{]}
35364@item <>@var{inout}@r{[}?@var{ident}@r{]}
35365@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
35366Named pipes or file descriptors to communicate over. The first form,
35367@option{<>}, communicates over stdin and stdout. The other forms
35368allow you to specify a file descriptor or name a pipe. A numeric value
35369is interpreted as a file descriptor, otherwise named pipe is opened.
35370The second form specifies a bidirectional pipe and the last form
35371allows specifying two independent pipes. Using file descriptors
35372directly in this manner is fragile in general, as it can require the
35373cooperation of intermediate processes. In particular using stdin &
35374stdout is fraught with danger as other compiler options might also
35375cause the compiler to read stdin or write stdout, and it can have
35376unfortunate interactions with signal delivery from the terminal.
35377
35378@item @var{file}@r{[}?@var{ident}@r{]}
35379A mapping file consisting of space-separated module-name, filename
35380pairs, one per line. Only the mappings for the direct imports and any
35381module export name need be provided. If other mappings are provided,
35382they override those stored in any imported CMI files. A repository
35383root may be specified in the mapping file by using @samp{$root} as the
35384module name in the first active line. Use of this option will disable
35385any default module->CMI name mapping.
35386
35387@end table
35388
35389As shown, an optional @var{ident} may suffix the first word of the
35390option, indicated by a @samp{?} prefix. The value is used in the
35391initial handshake with the module server, or to specify a prefix on
35392mapping file lines. In the server case, the main source file name is
35393used if no @var{ident} is specified. In the file case, all non-blank
35394lines are significant, unless a value is specified, in which case only
35395lines beginning with @var{ident} are significant. The @var{ident}
35396must be separated by whitespace from the module name. Be aware that
35397@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
35398significant to the shell, and therefore may need quoting.
35399
35400The mapper is connected to or loaded lazily, when the first module
35401mapping is required. The networking protocols are only supported on
35402hosts that provide networking. If no mapper is specified a default is
35403provided.
35404
35405A project-specific mapper is expected to be provided by the build
35406system that invokes the compiler. It is not expected that a
35407general-purpose server is provided for all compilations. As such, the
35408server will know the build configuration, the compiler it invoked, and
35409the environment (such as working directory) in which that is
35410operating. As it may parallelize builds, several compilations may
35411connect to the same socket.
35412
35413The default mapper generates CMI files in a @samp{gcm.cache}
35414directory. CMI files have a @samp{.gcm} suffix. The module unit name
35415is used directly to provide the basename. Header units construct a
35416relative path using the underlying header file name. If the path is
35417already relative, a @samp{,} directory is prepended. Internal
35418@samp{..} components are translated to @samp{,,}. No attempt is made
35419to canonicalize these filenames beyond that done by the preprocessor's
35420include search algorithm, as in general it is ambiguous when symbolic
35421links are present.
35422
35423The mapper protocol was published as ``A Module Mapper''
35424@uref{https://wg21.link/p1184}. The implementation is provided by
35425@command{libcody}, @uref{https://github.com/urnathan/libcody},
35426which specifies the canonical protocol definition. A proof of concept
35427server implementation embedded in @command{make} was described in
35428''Make Me A Module'', @uref{https://wg21.link/p1602}.
35429
35430@node C++ Module Preprocessing
35431@subsection Module Preprocessing
35432@cindex C++ Module Preprocessing
35433
35434Modules affect preprocessing because of header units and include
35435translation. Some uses of the preprocessor as a separate step either
35436do not produce a correct output, or require CMIs to be available.
35437
35438Header units import macros. These macros can affect later conditional
35439inclusion, which therefore can cascade to differing import sets. When
35440preprocessing, it is necessary to load the CMI. If a header unit is
35441unavailable, the preprocessor issues a warning and continue (when
35442not just preprocessing, an error is emitted). Detecting such imports
35443requires preprocessor tokenization of the input stream to phase 4
35444(macro expansion).
35445
35446Include translation converts @code{#include}, @code{#include_next} and
35447@code{#import} directives to internal @code{import} declarations.
35448Whether a particular directive is translated is controlled by the
35449module mapper. Header unit names are canonicalized during
35450preprocessing.
35451
35452Dependency information can be emitted for macro import, extending the
35453functionality of @option{-MD} and @option{-MMD} options. Detection of
35454import declarations also requires phase 4 preprocessing, and thus
35455requires full preprocessing (or compilation).
35456
35457The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
35458preprocessing before phase 4.
35459
35460The @option{-save-temps} option uses @option{-fdirectives-only} for
35461preprocessing, and preserve the macro definitions in the preprocessed
35462output. Usually you also want to use this option when explicitly
35463preprocessing a header-unit, or consuming such preprocessed output:
35464
35465@smallexample
35466g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
35467g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
35468@end smallexample
35469
35470@node C++ Compiled Module Interface
35471@subsection Compiled Module Interface
35472@cindex C++ Compiled Module Interface
35473
35474CMIs are an additional artifact when compiling named module
35475interfaces, partitions or header units. These are read when
35476importing. CMI contents are implementation-specific, and in GCC's
35477case tied to the compiler version. Consider them a rebuildable cache
35478artifact, not a distributable object.
35479
35480When creating an output CMI, any missing directory components are
35481created in a manner that is safe for concurrent builds creating
35482multiple, different, CMIs within a common subdirectory tree.
35483
35484CMI contents are written to a temporary file, which is then atomically
35485renamed. Observers either see old contents (if there is an
35486existing file), or complete new contents. They do not observe the
35487CMI during its creation. This is unlike object file writing, which
35488may be observed by an external process.
35489
35490CMIs are read in lazily, if the host OS provides @code{mmap}
35491functionality. Generally blocks are read when name lookup or template
35492instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
35493option may be used.
35494
35495The @option{--param lazy-modules=@var{n}} parameter controls the limit
35496on the number of concurrently open module files during lazy loading.
35497Should more modules be imported, an LRU algorithm is used to determine
35498which files to close---until that file is needed again. This limit
35499may be exceeded with deep module dependency hierarchies. With large
35500code bases there may be more imports than the process limit of file
35501descriptors. By default, the limit is a few less than the per-process
35502file descriptor hard limit, if that is determinable.@footnote{Where
35503applicable the soft limit is incremented as needed towards the hard limit.}
35504
35505GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
35506You may use @command{readelf} to inspect them, although section
35507contents are largely undecipherable. There is a section named
35508@code{.gnu.c++.README}, which contains human-readable text. Other
35509than the first line, each line consists of @code{@var{tag}: @code{value}}
35510tuples.
35511
35512@smallexample
35513> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
35514
35515String dump of section '.gnu.c++.README':
35516 [ 0] GNU C++ primary module interface
35517 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
35518 [ 6f] version: 2020/11/16-04:54
35519 [ 89] module: foo
35520 [ 95] source: c_b.ii
35521 [ a4] dialect: C++20/coroutines
35522 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
35523 [ ee] repository: gcm.cache
35524 [ 104] buildtime: 2020/11/16 15:03:21 UTC
35525 [ 127] localtime: 2020/11/16 07:03:21 PST
35526 [ 14a] export: foo:part1 foo-part1.gcm
35527@end smallexample
35528
35529Amongst other things, this lists the source that was built, C++
35530dialect used and imports of the module.@footnote{The precise contents
35531of this output may change.} The timestamp is the same value as that
35532provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
35533explicitly specified with the environment variable
35534@code{SOURCE_DATE_EPOCH}. For further details
35535@pxref{Environment Variables}.
35536
35537A set of related CMIs may be copied, provided the relative pathnames
35538are preserved.
35539
35540The @code{.gnu.c++.README} contents do not affect CMI integrity, and
35541it may be removed or altered. The section numbering of the sections
35542whose names do not begin with @code{.gnu.c++.}, or are not the string
35543section is significant and must not be altered.