]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/invoke.texi
Fix support for atomic loads and stores on hppa.
[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
74d5206f 11Copyright @copyright{} 1988-2023 Free Software Foundation, Inc.
d77de738
ML
12
13Permission is granted to copy, distribute and/or modify this document
14under the terms of the GNU Free Documentation License, Version 1.3 or
15any later version published by the Free Software Foundation; with the
16Invariant Sections being ``GNU General Public License'' and ``Funding
17Free Software'', the Front-Cover texts being (a) (see below), and with
18the Back-Cover Texts being (b) (see below). A copy of the license is
19included in the gfdl(7) man page.
20
21(a) The FSF's Front-Cover Text is:
22
23 A GNU Manual
24
25(b) The FSF's Back-Cover Text is:
26
27 You have freedom to copy and modify this GNU Manual, like GNU
28 software. Copies published by the Free Software Foundation raise
29 funds for GNU development.
30@c man end
31@c Set file name and title for the man page.
32@setfilename gcc
33@settitle GNU project C and C++ compiler
34@c man begin SYNOPSIS
35gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
36 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
37 [@option{-W}@var{warn}@dots{}] [@option{-Wpedantic}]
38 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
39 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
40 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
41 [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}
42
43Only the most useful options are listed here; see below for the
44remainder. @command{g++} accepts mostly the same options as @command{gcc}.
45@c man end
46@c man begin SEEALSO
47gpl(7), gfdl(7), fsf-funding(7),
48cpp(1), gcov(1), as(1), ld(1), gdb(1)
49and the Info entries for @file{gcc}, @file{cpp}, @file{as},
50@file{ld}, @file{binutils} and @file{gdb}.
51@c man end
52@c man begin BUGS
53For instructions on reporting bugs, see
54@w{@value{BUGURL}}.
55@c man end
56@c man begin AUTHOR
57See the Info entry for @command{gcc}, or
58@w{@uref{https://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
59for contributors to GCC@.
60@c man end
61@end ignore
62
63@node Invoking GCC
64@chapter GCC Command Options
65@cindex GCC command options
66@cindex command options
67@cindex options, GCC command
68
69@c man begin DESCRIPTION
70When you invoke GCC, it normally does preprocessing, compilation,
71assembly and linking. The ``overall options'' allow you to stop this
72process at an intermediate stage. For example, the @option{-c} option
73says not to run the linker. Then the output consists of object files
74output by the assembler.
75@xref{Overall Options,,Options Controlling the Kind of Output}.
76
77Other options are passed on to one or more stages of processing. Some options
78control the preprocessor and others the compiler itself. Yet other
79options control the assembler and linker; most of these are not
80documented here, since you rarely need to use any of them.
81
82@cindex C compilation options
83Most of the command-line options that you can use with GCC are useful
84for C programs; when an option is only useful with another language
85(usually C++), the explanation says so explicitly. If the description
86for a particular option does not mention a source language, you can use
87that option with all supported languages.
88
89@cindex cross compiling
90@cindex specifying machine version
91@cindex specifying compiler version and target machine
92@cindex compiler version, specifying
93@cindex target machine, specifying
94The usual way to run GCC is to run the executable called @command{gcc}, or
95@command{@var{machine}-gcc} when cross-compiling, or
96@command{@var{machine}-gcc-@var{version}} to run a specific version of GCC.
97When you compile C++ programs, you should invoke GCC as @command{g++}
98instead. @xref{Invoking G++,,Compiling C++ Programs},
99for information about the differences in behavior between @command{gcc}
100and @command{g++} when compiling C++ programs.
101
102@cindex grouping options
103@cindex options, grouping
104The @command{gcc} program accepts options and file names as operands. Many
105options have multi-letter names; therefore multiple single-letter options
106may @emph{not} be grouped: @option{-dv} is very different from @w{@samp{-d
107-v}}.
108
109@cindex order of options
110@cindex options, order
111You can mix options and other arguments. For the most part, the order
112you use doesn't matter. Order does matter when you use several
113options of the same kind; for example, if you specify @option{-L} more
114than once, the directories are searched in the order specified. Also,
115the placement of the @option{-l} option is significant.
116
117Many options have long names starting with @samp{-f} or with
118@samp{-W}---for example,
119@option{-fmove-loop-invariants}, @option{-Wformat} and so on. Most of
120these have both positive and negative forms; the negative form of
121@option{-ffoo} is @option{-fno-foo}. This manual documents
122only one of these two forms, whichever one is not the default.
123
124Some options take one or more arguments typically separated either
125by a space or by the equals sign (@samp{=}) from the option name.
126Unless documented otherwise, an argument can be either numeric or
127a string. Numeric arguments must typically be small unsigned decimal
128or hexadecimal integers. Hexadecimal arguments must begin with
129the @samp{0x} prefix. Arguments to options that specify a size
130threshold of some sort may be arbitrarily large decimal or hexadecimal
131integers followed by a byte size suffix designating a multiple of bytes
132such as @code{kB} and @code{KiB} for kilobyte and kibibyte, respectively,
133@code{MB} and @code{MiB} for megabyte and mebibyte, @code{GB} and
134@code{GiB} for gigabyte and gigibyte, and so on. Such arguments are
135designated by @var{byte-size} in the following text. Refer to the NIST,
136IEC, and other relevant national and international standards for the full
137listing and explanation of the binary and decimal byte size prefixes.
138
139@c man end
140
141@xref{Option Index}, for an index to GCC's options.
142
143@menu
144* Option Summary:: Brief list of all options, without explanations.
145* Overall Options:: Controlling the kind of output:
146 an executable, object files, assembler files,
147 or preprocessed source.
148* Invoking G++:: Compiling C++ programs.
149* C Dialect Options:: Controlling the variant of C language compiled.
150* C++ Dialect Options:: Variations on C++.
151* Objective-C and Objective-C++ Dialect Options:: Variations on Objective-C
152 and Objective-C++.
153* Diagnostic Message Formatting Options:: Controlling how diagnostics should
154 be formatted.
155* Warning Options:: How picky should the compiler be?
156* Static Analyzer Options:: More expensive warnings.
157* Debugging Options:: Producing debuggable code.
158* Optimize Options:: How much optimization?
159* Instrumentation Options:: Enabling profiling and extra run-time error checking.
160* Preprocessor Options:: Controlling header files and macro definitions.
161 Also, getting dependency information for Make.
162* Assembler Options:: Passing options to the assembler.
163* Link Options:: Specifying libraries and so on.
164* Directory Options:: Where to find header files and libraries.
165 Where to find the compiler executable files.
166* Code Gen Options:: Specifying conventions for function calls, data layout
167 and register usage.
168* Developer Options:: Printing GCC configuration info, statistics, and
169 debugging dumps.
170* Submodel Options:: Target-specific options, such as compiling for a
171 specific processor variant.
172* Spec Files:: How to pass switches to sub-processes.
173* Environment Variables:: Env vars that affect GCC.
174* Precompiled Headers:: Compiling a header once, and using it many times.
175* C++ Modules:: Experimental C++20 module system.
176@end menu
177
178@c man begin OPTIONS
179
180@node Option Summary
181@section Option Summary
182
183Here is a summary of all the options, grouped by type. Explanations are
184in the following sections.
185
186@table @emph
187@item Overall Options
188@xref{Overall Options,,Options Controlling the Kind of Output}.
189@gccoptlist{-c -S -E -o @var{file} @gol
190-dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf} @gol
191-dumpdir @var{dumppfx} -x @var{language} @gol
192-v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version @gol
193-pass-exit-codes -pipe -specs=@var{file} -wrapper @gol
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
cf467fb9 978-matomic-libcalls -mbig-switch @gol
d77de738 979-mcaller-copies -mdisable-fpregs -mdisable-indexing @gol
cf467fb9 980-mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
d77de738 981-mfixed-range=@var{register-range} @gol
cf467fb9
JDA
982-mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls @gol
983-mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs @gol
d77de738
ML
984-mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
985-mno-jump-in-delay -mno-long-load-store @gol
986-mno-portable-runtime -mno-soft-float @gol
987-mno-space-regs -msoft-float -mpa-risc-1-0 @gol
988-mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
cf467fb9 989-mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio @gol
d77de738
ML
990-munix=@var{unix-std} -nolibdld -static -threads}
991
992@emph{IA-64 Options}
993@gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
994-mvolatile-asm-stop -mregister-names -msdata -mno-sdata @gol
995-mconstant-gp -mauto-pic -mfused-madd @gol
996-minline-float-divide-min-latency @gol
997-minline-float-divide-max-throughput @gol
998-mno-inline-float-divide @gol
999-minline-int-divide-min-latency @gol
1000-minline-int-divide-max-throughput @gol
1001-mno-inline-int-divide @gol
1002-minline-sqrt-min-latency -minline-sqrt-max-throughput @gol
1003-mno-inline-sqrt @gol
1004-mdwarf2-asm -mearly-stop-bits @gol
1005-mfixed-range=@var{register-range} -mtls-size=@var{tls-size} @gol
1006-mtune=@var{cpu-type} -milp32 -mlp64 @gol
1007-msched-br-data-spec -msched-ar-data-spec -msched-control-spec @gol
1008-msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec @gol
1009-msched-spec-ldc -msched-spec-control-ldc @gol
1010-msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns @gol
1011-msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path @gol
1012-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost @gol
1013-msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}}
1014
1015@emph{LM32 Options}
1016@gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled @gol
1017-msign-extend-enabled -muser-enabled}
1018
1019@emph{LoongArch Options}
1020@gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} @gol
1021-mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float @gol
1022-mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division @gol
1023-mcond-move-int -mno-cond-move-int @gol
1024-mcond-move-float -mno-cond-move-float @gol
1025-memcpy -mno-memcpy -mstrict-align -mno-strict-align @gol
1026-mmax-inline-memcpy-size=@var{n} @gol
1027-mexplicit-relocs -mno-explicit-relocs @gol
1028-mdirect-extern-access -mno-direct-extern-access @gol
1029-mcmodel=@var{code-model}}
1030
1031@emph{M32R/D Options}
1032@gccoptlist{-m32r2 -m32rx -m32r @gol
1033-mdebug @gol
1034-malign-loops -mno-align-loops @gol
1035-missue-rate=@var{number} @gol
1036-mbranch-cost=@var{number} @gol
1037-mmodel=@var{code-size-model-type} @gol
1038-msdata=@var{sdata-type} @gol
1039-mno-flush-func -mflush-func=@var{name} @gol
1040-mno-flush-trap -mflush-trap=@var{number} @gol
1041-G @var{num}}
1042
1043@emph{M32C Options}
1044@gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}}
1045
1046@emph{M680x0 Options}
1047@gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} @gol
1048-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
1049-m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 @gol
1050-mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 @gol
1051-mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort @gol
1052-mno-short -mhard-float -m68881 -msoft-float -mpcrel @gol
1053-malign-int -mstrict-align -msep-data -mno-sep-data @gol
1054-mshared-library-id=n -mid-shared-library -mno-id-shared-library @gol
1055-mxgot -mno-xgot -mlong-jump-table-offsets}
1056
1057@emph{MCore Options}
1058@gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
1059-mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
1060-m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
1061-mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
1062-mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
1063
d77de738
ML
1064@emph{MicroBlaze Options}
1065@gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} @gol
1066-mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift @gol
1067-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss @gol
1068-mxl-multiply-high -mxl-float-convert -mxl-float-sqrt @gol
1069-mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} @gol
1070-mpic-data-is-text-relative}
1071
1072@emph{MIPS Options}
1073@gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
1074-mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 @gol
1075-mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 @gol
1076-mips16 -mno-mips16 -mflip-mips16 @gol
1077-minterlink-compressed -mno-interlink-compressed @gol
1078-minterlink-mips16 -mno-interlink-mips16 @gol
1079-mabi=@var{abi} -mabicalls -mno-abicalls @gol
1080-mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot @gol
1081-mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float @gol
1082-mno-float -msingle-float -mdouble-float @gol
1083-modd-spreg -mno-odd-spreg @gol
1084-mabs=@var{mode} -mnan=@var{encoding} @gol
1085-mdsp -mno-dsp -mdspr2 -mno-dspr2 @gol
1086-mmcu -mmno-mcu @gol
1087-meva -mno-eva @gol
1088-mvirt -mno-virt @gol
1089-mxpa -mno-xpa @gol
1090-mcrc -mno-crc @gol
1091-mginv -mno-ginv @gol
1092-mmicromips -mno-micromips @gol
1093-mmsa -mno-msa @gol
1094-mloongson-mmi -mno-loongson-mmi @gol
1095-mloongson-ext -mno-loongson-ext @gol
1096-mloongson-ext2 -mno-loongson-ext2 @gol
1097-mfpu=@var{fpu-type} @gol
1098-msmartmips -mno-smartmips @gol
1099-mpaired-single -mno-paired-single -mdmx -mno-mdmx @gol
1100-mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc @gol
1101-mlong64 -mlong32 -msym32 -mno-sym32 @gol
1102-G@var{num} -mlocal-sdata -mno-local-sdata @gol
1103-mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt @gol
1104-membedded-data -mno-embedded-data @gol
1105-muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
1106-mcode-readable=@var{setting} @gol
1107-msplit-addresses -mno-split-addresses @gol
1108-mexplicit-relocs -mno-explicit-relocs @gol
1109-mcheck-zero-division -mno-check-zero-division @gol
1110-mdivide-traps -mdivide-breaks @gol
1111-mload-store-pairs -mno-load-store-pairs @gol
1112-munaligned-access -mno-unaligned-access @gol
1113-mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
1114-mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp @gol
1115-mfix-24k -mno-fix-24k @gol
1116-mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
1117-mfix-r5900 -mno-fix-r5900 @gol
1118-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 @gol
1119-mfix-vr4120 -mno-fix-vr4120 @gol
1120-mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 @gol
1121-mflush-func=@var{func} -mno-flush-func @gol
1122-mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely @gol
1123-mcompact-branches=@var{policy} @gol
1124-mfp-exceptions -mno-fp-exceptions @gol
1125-mvr4130-align -mno-vr4130-align -msynci -mno-synci @gol
1126-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 @gol
1127-mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address @gol
1128-mframe-header-opt -mno-frame-header-opt}
1129
1130@emph{MMIX Options}
1131@gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
1132-mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
1133-melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
1134-mno-base-addresses -msingle-exit -mno-single-exit}
1135
1136@emph{MN10300 Options}
1137@gccoptlist{-mmult-bug -mno-mult-bug @gol
1138-mno-am33 -mam33 -mam33-2 -mam34 @gol
1139-mtune=@var{cpu-type} @gol
1140-mreturn-pointer-on-d0 @gol
1141-mno-crt0 -mrelax -mliw -msetlb}
1142
1143@emph{Moxie Options}
1144@gccoptlist{-meb -mel -mmul.x -mno-crt0}
1145
1146@emph{MSP430 Options}
1147@gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax @gol
1148-mwarn-mcu @gol
1149-mcode-region= -mdata-region= @gol
1150-msilicon-errata= -msilicon-errata-warn= @gol
1151-mhwmult= -minrt -mtiny-printf -mmax-inline-shift=}
1152
1153@emph{NDS32 Options}
1154@gccoptlist{-mbig-endian -mlittle-endian @gol
1155-mreduced-regs -mfull-regs @gol
1156-mcmov -mno-cmov @gol
1157-mext-perf -mno-ext-perf @gol
1158-mext-perf2 -mno-ext-perf2 @gol
1159-mext-string -mno-ext-string @gol
1160-mv3push -mno-v3push @gol
1161-m16bit -mno-16bit @gol
1162-misr-vector-size=@var{num} @gol
1163-mcache-block-size=@var{num} @gol
1164-march=@var{arch} @gol
1165-mcmodel=@var{code-model} @gol
1166-mctor-dtor -mrelax}
1167
1168@emph{Nios II Options}
1169@gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt @gol
1170-mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} @gol
1171-mel -meb @gol
1172-mno-bypass-cache -mbypass-cache @gol
1173-mno-cache-volatile -mcache-volatile @gol
1174-mno-fast-sw-div -mfast-sw-div @gol
1175-mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div @gol
1176-mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} @gol
1177-mcustom-fpu-cfg=@var{name} @gol
1178-mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} @gol
1179-march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx}
1180
1181@emph{Nvidia PTX Options}
1182@gccoptlist{-m64 -mmainkernel -moptimize}
1183
1184@emph{OpenRISC Options}
1185@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div @gol
1186-msoft-mul -msoft-div @gol
1187-msoft-float -mhard-float -mdouble-float -munordered-float @gol
1188-mcmov -mror -mrori -msext -msfimm -mshftimm @gol
1189-mcmodel=@var{code-model}}
1190
1191@emph{PDP-11 Options}
1192@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
1193-mint32 -mno-int16 -mint16 -mno-int32 @gol
1194-msplit -munix-asm -mdec-asm -mgnu-asm -mlra}
1195
d77de738
ML
1196@emph{PowerPC Options}
1197See RS/6000 and PowerPC Options.
1198
1199@emph{PRU Options}
1200@gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop @gol
f58e6d42 1201-mabi=@var{variant}}
d77de738
ML
1202
1203@emph{RISC-V Options}
1204@gccoptlist{-mbranch-cost=@var{N-instruction} @gol
1205-mplt -mno-plt @gol
1206-mabi=@var{ABI-string} @gol
1207-mfdiv -mno-fdiv @gol
1208-mdiv -mno-div @gol
1209-misa-spec=@var{ISA-spec-string} @gol
1210-march=@var{ISA-string} @gol
1211-mtune=@var{processor-string} @gol
1212-mpreferred-stack-boundary=@var{num} @gol
1213-msmall-data-limit=@var{N-bytes} @gol
1214-msave-restore -mno-save-restore @gol
1215-mshorten-memrefs -mno-shorten-memrefs @gol
1216-mstrict-align -mno-strict-align @gol
1217-mcmodel=medlow -mcmodel=medany @gol
1218-mexplicit-relocs -mno-explicit-relocs @gol
1219-mrelax -mno-relax @gol
1220-mriscv-attribute -mno-riscv-attribute @gol
1221-malign-data=@var{type} @gol
1222-mbig-endian -mlittle-endian @gol
1223-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
f58e6d42
CM
1224-mstack-protector-guard-offset=@var{offset} @gol
1225-mcsr-check -mno-csr-check}
d77de738
ML
1226
1227@emph{RL78 Options}
1228@gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs @gol
1229-mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 @gol
1230-m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts}
1231
1232@emph{RS/6000 and PowerPC Options}
1233@gccoptlist{-mcpu=@var{cpu-type} @gol
1234-mtune=@var{cpu-type} @gol
1235-mcmodel=@var{code-model} @gol
1236-mpowerpc64 @gol
1237-maltivec -mno-altivec @gol
1238-mpowerpc-gpopt -mno-powerpc-gpopt @gol
1239-mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
1240-mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd @gol
1241-mfprnd -mno-fprnd @gol
1242-mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp @gol
1243-mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
1244-m64 -m32 -mxl-compat -mno-xl-compat -mpe @gol
1245-malign-power -malign-natural @gol
1246-msoft-float -mhard-float -mmultiple -mno-multiple @gol
1247-mupdate -mno-update @gol
1248-mavoid-indexed-addresses -mno-avoid-indexed-addresses @gol
1249-mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
1250-mstrict-align -mno-strict-align -mrelocatable @gol
1251-mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
1252-mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
1253-mdynamic-no-pic -mswdiv -msingle-pic-base @gol
1254-mprioritize-restricted-insns=@var{priority} @gol
1255-msched-costly-dep=@var{dependence_type} @gol
1256-minsert-sched-nops=@var{scheme} @gol
1257-mcall-aixdesc -mcall-eabi -mcall-freebsd @gol
1258-mcall-linux -mcall-netbsd -mcall-openbsd @gol
1259-mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi @gol
1260-mtraceback=@var{traceback_type} @gol
1261-maix-struct-return -msvr4-struct-return @gol
1262-mabi=@var{abi-type} -msecure-plt -mbss-plt @gol
1263-mlongcall -mno-longcall -mpltseq -mno-pltseq @gol
1264-mblock-move-inline-limit=@var{num} @gol
1265-mblock-compare-inline-limit=@var{num} @gol
1266-mblock-compare-inline-loop-limit=@var{num} @gol
1267-mno-block-ops-unaligned-vsx @gol
1268-mstring-compare-inline-limit=@var{num} @gol
1269-misel -mno-isel @gol
1270-mvrsave -mno-vrsave @gol
1271-mmulhw -mno-mulhw @gol
1272-mdlmzb -mno-dlmzb @gol
1273-mprototype -mno-prototype @gol
1274-msim -mmvme -mads -myellowknife -memb -msdata @gol
1275-msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} @gol
1276-mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision @gol
1277-mno-recip-precision @gol
1278-mveclibabi=@var{type} -mfriz -mno-friz @gol
1279-mpointers-to-nested-functions -mno-pointers-to-nested-functions @gol
1280-msave-toc-indirect -mno-save-toc-indirect @gol
1281-mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
1282-mcrypto -mno-crypto -mhtm -mno-htm @gol
1283-mquad-memory -mno-quad-memory @gol
1284-mquad-memory-atomic -mno-quad-memory-atomic @gol
1285-mcompat-align-parm -mno-compat-align-parm @gol
1286-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware @gol
1287-mgnu-attribute -mno-gnu-attribute @gol
1288-mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol
1289-mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed @gol
1290-mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect @gol
1291-mprivileged -mno-privileged}
1292
1293@emph{RX Options}
1294@gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu@gol
1295-mcpu=@gol
1296-mbig-endian-data -mlittle-endian-data @gol
1297-msmall-data @gol
1298-msim -mno-sim@gol
1299-mas100-syntax -mno-as100-syntax@gol
1300-mrelax@gol
1301-mmax-constant-size=@gol
1302-mint-register=@gol
1303-mpid@gol
1304-mallow-string-insns -mno-allow-string-insns@gol
1305-mjsr@gol
1306-mno-warn-multiple-fast-interrupts@gol
1307-msave-acc-in-interrupts}
1308
1309@emph{S/390 and zSeries Options}
1310@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1311-mhard-float -msoft-float -mhard-dfp -mno-hard-dfp @gol
1312-mlong-double-64 -mlong-double-128 @gol
1313-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack @gol
1314-msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
1315-m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
1316-mhtm -mvx -mzvector @gol
1317-mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip @gol
1318-mfused-madd -mno-fused-madd @gol
1319-mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard @gol
1320-mhotpatch=@var{halfwords},@var{halfwords}}
1321
d77de738
ML
1322@emph{SH Options}
1323@gccoptlist{-m1 -m2 -m2e @gol
1324-m2a-nofpu -m2a-single-only -m2a-single -m2a @gol
1325-m3 -m3e @gol
1326-m4-nofpu -m4-single-only -m4-single -m4 @gol
1327-m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al @gol
1328-mb -ml -mdalign -mrelax @gol
1329-mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave @gol
1330-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct @gol
1331-mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} @gol
1332-mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol
1333-maccumulate-outgoing-args @gol
1334-matomic-model=@var{atomic-model} @gol
1335-mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch @gol
1336-mcbranch-force-delay-slot @gol
1337-mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra @gol
1338-mpretend-cmove -mtas}
1339
1340@emph{Solaris 2 Options}
1341@gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text @gol
1342-pthreads}
1343
1344@emph{SPARC Options}
1345@gccoptlist{-mcpu=@var{cpu-type} @gol
1346-mtune=@var{cpu-type} @gol
1347-mcmodel=@var{code-model} @gol
1348-mmemory-model=@var{mem-model} @gol
1349-m32 -m64 -mapp-regs -mno-app-regs @gol
1350-mfaster-structs -mno-faster-structs -mflat -mno-flat @gol
1351-mfpu -mno-fpu -mhard-float -msoft-float @gol
1352-mhard-quad-float -msoft-quad-float @gol
1353-mstack-bias -mno-stack-bias @gol
1354-mstd-struct-return -mno-std-struct-return @gol
1355-munaligned-doubles -mno-unaligned-doubles @gol
1356-muser-mode -mno-user-mode @gol
1357-mv8plus -mno-v8plus -mvis -mno-vis @gol
1358-mvis2 -mno-vis2 -mvis3 -mno-vis3 @gol
1359-mvis4 -mno-vis4 -mvis4b -mno-vis4b @gol
1360-mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld @gol
1361-mpopc -mno-popc -msubxc -mno-subxc @gol
1362-mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc @gol
1363-mlra -mno-lra}
1364
1365@emph{System V Options}
1366@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
1367
1368@emph{V850 Options}
1369@gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
1370-mprolog-function -mno-prolog-function -mspace @gol
1371-mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
1372-mapp-regs -mno-app-regs @gol
1373-mdisable-callt -mno-disable-callt @gol
1374-mv850e2v3 -mv850e2 -mv850e1 -mv850es @gol
1375-mv850e -mv850 -mv850e3v5 @gol
1376-mloop @gol
1377-mrelax @gol
1378-mlong-jumps @gol
1379-msoft-float @gol
1380-mhard-float @gol
1381-mgcc-abi @gol
1382-mrh850-abi @gol
1383-mbig-switch}
1384
1385@emph{VAX Options}
1386@gccoptlist{-mg -mgnu -munix -mlra}
1387
1388@emph{Visium Options}
1389@gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float @gol
1390-mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode}
1391
1392@emph{VMS Options}
1393@gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 @gol
1394-mpointer-size=@var{size}}
1395
1396@emph{VxWorks Options}
1397@gccoptlist{-mrtp -non-static -Bstatic -Bdynamic @gol
1398-Xbind-lazy -Xbind-now}
1399
1400@emph{x86 Options}
1401@gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
1402-mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default @gol
1403-mfpmath=@var{unit} @gol
1404-masm=@var{dialect} -mno-fancy-math-387 @gol
1405-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float @gol
1406-mno-wide-multiply -mrtd -malign-double @gol
1407-mpreferred-stack-boundary=@var{num} @gol
1408-mincoming-stack-boundary=@var{num} @gol
1409-mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait @gol
1410-mrecip -mrecip=@var{opt} @gol
1411-mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} @gol
1412-mmove-max=@var{bits} -mstore-max=@var{bits} @gol
1413-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
1414-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl @gol
1415-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes @gol
1416-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd @gol
1417-mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves @gol
1418-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol
1419-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp @gol
1420-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol
1421-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call @gol
1422-mavx512vbmi2 -mavx512bf16 -menqcmd @gol
1423-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol
1424-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid @gol
1425-mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk@gol
1426-mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni@gol
1427-mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 @gol
1428-mprefetchi -mraoint @gol
1429-mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops @gol
1430-minline-stringops-dynamically -mstringop-strategy=@var{alg} @gol
1431-mkl -mwidekl @gol
1432-mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} @gol
1433-mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
1434-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 @gol
1435-mregparm=@var{num} -msseregparm @gol
1436-mveclibabi=@var{type} -mvect8-ret-in-mem @gol
e54375d8 1437-mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign @gol
d77de738
ML
1438-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs @gol
1439-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
1440-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} @gol
1441-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv @gol
1442-minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} @gol
1443-mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
1444-malign-data=@var{type} -mstack-protector-guard=@var{guard} @gol
1445-mstack-protector-guard-reg=@var{reg} @gol
1446-mstack-protector-guard-offset=@var{offset} @gol
1447-mstack-protector-guard-symbol=@var{symbol} @gol
1448-mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop @gol
1449-mindirect-branch=@var{choice} -mfunction-return=@var{choice} @gol
1450-mindirect-branch-register -mharden-sls=@var{choice} @gol
ce51e843 1451-mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access @gol
bb576017 1452-munroll-only-small-loops -mlam=@var{choice}}
d77de738
ML
1453
1454@emph{x86 Windows Options}
1455@gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
1456-mnop-fun-dllimport -mthread @gol
1457-municode -mwin32 -mwindows -fno-set-stack-executable}
1458
1459@emph{Xstormy16 Options}
1460@gccoptlist{-msim}
1461
1462@emph{Xtensa Options}
1463@gccoptlist{-mconst16 -mno-const16 @gol
1464-mfused-madd -mno-fused-madd @gol
1465-mforce-no-pic @gol
1466-mserialize-volatile -mno-serialize-volatile @gol
1467-mtext-section-literals -mno-text-section-literals @gol
1468-mauto-litpools -mno-auto-litpools @gol
1469-mtarget-align -mno-target-align @gol
1470-mlongcalls -mno-longcalls @gol
1471-mabi=@var{abi-type} @gol
1472-mextra-l32r-costs=@var{cycles}}
1473
1474@emph{zSeries Options}
1475See S/390 and zSeries Options.
1476@end table
1477
1478
1479@node Overall Options
1480@section Options Controlling the Kind of Output
1481
1482Compilation can involve up to four stages: preprocessing, compilation
1483proper, assembly and linking, always in that order. GCC is capable of
1484preprocessing and compiling several files either into several
1485assembler input files, or into one assembler input file; then each
1486assembler input file produces an object file, and linking combines all
1487the object files (those newly compiled, and those specified as input)
1488into an executable file.
1489
1490@cindex file name suffix
1491For any given input file, the file name suffix determines what kind of
1492compilation is done:
1493
1494@table @gcctabopt
1495@item @var{file}.c
1496C source code that must be preprocessed.
1497
1498@item @var{file}.i
1499C source code that should not be preprocessed.
1500
1501@item @var{file}.ii
1502C++ source code that should not be preprocessed.
1503
1504@item @var{file}.m
1505Objective-C source code. Note that you must link with the @file{libobjc}
1506library to make an Objective-C program work.
1507
1508@item @var{file}.mi
1509Objective-C source code that should not be preprocessed.
1510
1511@item @var{file}.mm
1512@itemx @var{file}.M
1513Objective-C++ source code. Note that you must link with the @file{libobjc}
1514library to make an Objective-C++ program work. Note that @samp{.M} refers
1515to a literal capital M@.
1516
1517@item @var{file}.mii
1518Objective-C++ source code that should not be preprocessed.
1519
1520@item @var{file}.h
1521C, C++, Objective-C or Objective-C++ header file to be turned into a
1522precompiled header (default), or C, C++ header file to be turned into an
1523Ada spec (via the @option{-fdump-ada-spec} switch).
1524
1525@item @var{file}.cc
1526@itemx @var{file}.cp
1527@itemx @var{file}.cxx
1528@itemx @var{file}.cpp
1529@itemx @var{file}.CPP
1530@itemx @var{file}.c++
1531@itemx @var{file}.C
1532C++ source code that must be preprocessed. Note that in @samp{.cxx},
1533the last two letters must both be literally @samp{x}. Likewise,
1534@samp{.C} refers to a literal capital C@.
1535
1536@item @var{file}.mm
1537@itemx @var{file}.M
1538Objective-C++ source code that must be preprocessed.
1539
1540@item @var{file}.mii
1541Objective-C++ source code that should not be preprocessed.
1542
1543@item @var{file}.hh
1544@itemx @var{file}.H
1545@itemx @var{file}.hp
1546@itemx @var{file}.hxx
1547@itemx @var{file}.hpp
1548@itemx @var{file}.HPP
1549@itemx @var{file}.h++
1550@itemx @var{file}.tcc
1551C++ header file to be turned into a precompiled header or Ada spec.
1552
1553@item @var{file}.f
1554@itemx @var{file}.for
1555@itemx @var{file}.ftn
1556Fixed form Fortran source code that should not be preprocessed.
1557
1558@item @var{file}.F
1559@itemx @var{file}.FOR
1560@itemx @var{file}.fpp
1561@itemx @var{file}.FPP
1562@itemx @var{file}.FTN
1563Fixed form Fortran source code that must be preprocessed (with the traditional
1564preprocessor).
1565
1566@item @var{file}.f90
1567@itemx @var{file}.f95
1568@itemx @var{file}.f03
1569@itemx @var{file}.f08
1570Free form Fortran source code that should not be preprocessed.
1571
1572@item @var{file}.F90
1573@itemx @var{file}.F95
1574@itemx @var{file}.F03
1575@itemx @var{file}.F08
1576Free form Fortran source code that must be preprocessed (with the
1577traditional preprocessor).
1578
1579@item @var{file}.go
1580Go source code.
1581
1582@item @var{file}.d
1583D source code.
1584
1585@item @var{file}.di
1586D interface file.
1587
1588@item @var{file}.dd
1589D documentation code (Ddoc).
1590
1591@item @var{file}.ads
1592Ada source code file that contains a library unit declaration (a
1593declaration of a package, subprogram, or generic, or a generic
1594instantiation), or a library unit renaming declaration (a package,
1595generic, or subprogram renaming declaration). Such files are also
1596called @dfn{specs}.
1597
1598@item @var{file}.adb
1599Ada source code file containing a library unit body (a subprogram or
1600package body). Such files are also called @dfn{bodies}.
1601
1602@c GCC also knows about some suffixes for languages not yet included:
1603@c Ratfor:
1604@c @var{file}.r
1605
1606@item @var{file}.s
1607Assembler code.
1608
1609@item @var{file}.S
1610@itemx @var{file}.sx
1611Assembler code that must be preprocessed.
1612
1613@item @var{other}
1614An object file to be fed straight into linking.
1615Any file name with no recognized suffix is treated this way.
1616@end table
1617
1618@opindex x
1619You can specify the input language explicitly with the @option{-x} option:
1620
1621@table @gcctabopt
1622@item -x @var{language}
1623Specify explicitly the @var{language} for the following input files
1624(rather than letting the compiler choose a default based on the file
1625name suffix). This option applies to all following input files until
1626the next @option{-x} option. Possible values for @var{language} are:
1627@smallexample
1628c c-header cpp-output
1629c++ c++-header c++-system-header c++-user-header c++-cpp-output
1630objective-c objective-c-header objective-c-cpp-output
1631objective-c++ objective-c++-header objective-c++-cpp-output
1632assembler assembler-with-cpp
1633ada
1634d
1635f77 f77-cpp-input f95 f95-cpp-input
1636go
1637@end smallexample
1638
1639@item -x none
1640Turn off any specification of a language, so that subsequent files are
1641handled according to their file name suffixes (as they are if @option{-x}
1642has not been used at all).
1643@end table
1644
1645If you only want some of the stages of compilation, you can use
1646@option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
1647one of the options @option{-c}, @option{-S}, or @option{-E} to say where
1648@command{gcc} is to stop. Note that some combinations (for example,
1649@samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
1650
1651@table @gcctabopt
1652@item -c
1653@opindex c
1654Compile or assemble the source files, but do not link. The linking
1655stage simply is not done. The ultimate output is in the form of an
1656object file for each source file.
1657
1658By default, the object file name for a source file is made by replacing
1659the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
1660
1661Unrecognized input files, not requiring compilation or assembly, are
1662ignored.
1663
1664@item -S
1665@opindex S
1666Stop after the stage of compilation proper; do not assemble. The output
1667is in the form of an assembler code file for each non-assembler input
1668file specified.
1669
1670By default, the assembler file name for a source file is made by
1671replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
1672
1673Input files that don't require compilation are ignored.
1674
1675@item -E
1676@opindex E
1677Stop after the preprocessing stage; do not run the compiler proper. The
1678output is in the form of preprocessed source code, which is sent to the
1679standard output.
1680
1681Input files that don't require preprocessing are ignored.
1682
1683@cindex output file option
1684@item -o @var{file}
1685@opindex o
1686Place the primary output in file @var{file}. This applies to whatever
1687sort of output is being produced, whether it be an executable file, an
1688object file, an assembler file or preprocessed C code.
1689
1690If @option{-o} is not specified, the default is to put an executable
1691file in @file{a.out}, the object file for
1692@file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
1693assembler file in @file{@var{source}.s}, a precompiled header file in
1694@file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
1695standard output.
1696
1697Though @option{-o} names only the primary output, it also affects the
1698naming of auxiliary and dump outputs. See the examples below. Unless
1699overridden, both auxiliary outputs and dump outputs are placed in the
1700same directory as the primary output. In auxiliary outputs, the suffix
1701of the input file is replaced with that of the auxiliary output file
1702type; in dump outputs, the suffix of the dump file is appended to the
1703input file suffix. In compilation commands, the base name of both
1704auxiliary and dump outputs is that of the primary output; in compile and
1705link commands, the primary output name, minus the executable suffix, is
1706combined with the input file name. If both share the same base name,
1707disregarding the suffix, the result of the combination is that base
1708name, otherwise, they are concatenated, separated by a dash.
1709
1710@smallexample
1711gcc -c foo.c ...
1712@end smallexample
1713
1714will use @file{foo.o} as the primary output, and place aux outputs and
1715dumps next to it, e.g., aux file @file{foo.dwo} for
1716@option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for
1717@option{-fdump-rtl-final}.
1718
1719If a non-linker output file is explicitly specified, aux and dump files
1720by default take the same base name:
1721
1722@smallexample
1723gcc -c foo.c -o dir/foobar.o ...
1724@end smallexample
1725
1726will name aux outputs @file{dir/foobar.*} and dump outputs
1727@file{dir/foobar.c.*}.
1728
1729A linker output will instead prefix aux and dump outputs:
1730
1731@smallexample
1732gcc foo.c bar.c -o dir/foobar ...
1733@end smallexample
1734
1735will generally name aux outputs @file{dir/foobar-foo.*} and
1736@file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and
1737@file{dir/foobar-bar.c.*}.
1738
1739The one exception to the above is when the executable shares the base
1740name with the single input:
1741
1742@smallexample
1743gcc foo.c -o dir/foo ...
1744@end smallexample
1745
1746in which case aux outputs are named @file{dir/foo.*} and dump outputs
1747named @file{dir/foo.c.*}.
1748
1749The location and the names of auxiliary and dump outputs can be adjusted
1750by the options @option{-dumpbase}, @option{-dumpbase-ext},
1751@option{-dumpdir}, @option{-save-temps=cwd}, and
1752@option{-save-temps=obj}.
1753
1754
1755@item -dumpbase @var{dumpbase}
1756@opindex dumpbase
1757This option sets the base name for auxiliary and dump output files. It
1758does not affect the name of the primary output file. Intermediate
1759outputs, when preserved, are not regarded as primary outputs, but as
1760auxiliary outputs:
1761
1762@smallexample
1763gcc -save-temps -S foo.c
1764@end smallexample
1765
1766saves the (no longer) temporary preprocessed file in @file{foo.i}, and
1767then compiles to the (implied) output file @file{foo.s}, whereas:
1768
1769@smallexample
1770gcc -save-temps -dumpbase save-foo -c foo.c
1771@end smallexample
1772
1773preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now
1774an intermediate, thus auxiliary output), and then assembles to the
1775(implied) output file @file{foo.o}.
1776
1777Absent this option, dump and aux files take their names from the input
1778file, or from the (non-linker) output file, if one is explicitly
1779specified: dump output files (e.g. those requested by @option{-fdump-*}
1780options) with the input name suffix, and aux output files (those
1781requested by other non-dump options, e.g. @code{-save-temps},
1782@code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it.
1783
1784Similar suffix differentiation of dump and aux outputs can be attained
1785for explicitly-given @option{-dumpbase basename.suf} by also specifying
1786@option{-dumpbase-ext .suf}.
1787
1788If @var{dumpbase} is explicitly specified with any directory component,
1789any @var{dumppfx} specification (e.g. @option{-dumpdir} or
1790@option{-save-temps=*}) is ignored, and instead of appending to it,
1791@var{dumpbase} fully overrides it:
1792
1793@smallexample
1794gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
1795 -dumpdir pfx- -save-temps=cwd ...
1796@end smallexample
1797
1798creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding
1799@file{dir/} in @option{-o}, the @file{./} prefix implied by
1800@option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}.
1801
1802When @option{-dumpbase} is specified in a command that compiles multiple
1803inputs, or that compiles and then links, it may be combined with
1804@var{dumppfx}, as specified under @option{-dumpdir}. Then, each input
1805file is compiled using the combined @var{dumppfx}, and default values
1806for @var{dumpbase} and @var{auxdropsuf} are computed for each input
1807file:
1808
1809@smallexample
1810gcc foo.c bar.c -c -dumpbase main ...
1811@end smallexample
1812
1813creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids
1814overwriting the auxiliary and dump outputs by using the @var{dumpbase}
1815as a prefix, creating auxiliary and dump outputs named @file{main-foo.*}
1816and @file{main-bar.*}.
1817
1818An empty string specified as @var{dumpbase} avoids the influence of the
1819output basename in the naming of auxiliary and dump outputs during
1820compilation, computing default values :
1821
1822@smallexample
1823gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
1824@end smallexample
1825
1826will name aux outputs @file{dir/foo.*} and dump outputs
1827@file{dir/foo.c.*}. Note how their basenames are taken from the input
1828name, but the directory still defaults to that of the output.
1829
1830The empty-string dumpbase does not prevent the use of the output
1831basename for outputs during linking:
1832
1833@smallexample
1834gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
1835@end smallexample
1836
1837The compilation of the source files will name auxiliary outputs
1838@file{dir/foo.*} and @file{dir/bar.*}, and dump outputs
1839@file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during
1840linking will use @file{dir/foobar.} as the prefix for dumps and
1841auxiliary files.
1842
1843
1844@item -dumpbase-ext @var{auxdropsuf}
1845@opindex dumpbase-ext
1846When forming the name of an auxiliary (but not a dump) output file, drop
1847trailing @var{auxdropsuf} from @var{dumpbase} before appending any
1848suffixes. If not specified, this option defaults to the suffix of a
1849default @var{dumpbase}, i.e., the suffix of the input file when
1850@option{-dumpbase} is not present in the command line, or @var{dumpbase}
1851is combined with @var{dumppfx}.
1852
1853@smallexample
1854gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
1855@end smallexample
1856
1857creates @file{dir/foo.o} as the main output, and generates auxiliary
1858outputs in @file{dir/x-foo.*}, taking the location of the primary
1859output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump
1860outputs retain the suffix: @file{dir/x-foo.c.*}.
1861
1862This option is disregarded if it does not match the suffix of a
1863specified @var{dumpbase}, except as an alternative to the executable
1864suffix when appending the linker output base name to @var{dumppfx}, as
1865specified below:
1866
1867@smallexample
1868gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
1869@end smallexample
1870
1871creates @file{main.out} as the primary output, and avoids overwriting
1872the auxiliary and dump outputs by using the executable name minus
1873@var{auxdropsuf} as a prefix, creating auxiliary outputs named
1874@file{main-foo.*} and @file{main-bar.*} and dump outputs named
1875@file{main-foo.c.*} and @file{main-bar.c.*}.
1876
1877
1878@item -dumpdir @var{dumppfx}
1879@opindex dumpdir
1880When forming the name of an auxiliary or dump output file, use
1881@var{dumppfx} as a prefix:
1882
1883@smallexample
1884gcc -dumpdir pfx- -c foo.c ...
1885@end smallexample
1886
1887creates @file{foo.o} as the primary output, and auxiliary outputs named
1888@file{pfx-foo.*}, combining the given @var{dumppfx} with the default
1889@var{dumpbase} derived from the default primary output, derived in turn
1890from the input name. Dump outputs also take the input name suffix:
1891@file{pfx-foo.c.*}.
1892
1893If @var{dumppfx} is to be used as a directory name, it must end with a
1894directory separator:
1895
1896@smallexample
1897gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
1898@end smallexample
1899
1900creates @file{obj/bar.o} as the primary output, and auxiliary outputs
1901named @file{dir/bar.*}, combining the given @var{dumppfx} with the
1902default @var{dumpbase} derived from the primary output name. Dump
1903outputs also take the input name suffix: @file{dir/bar.c.*}.
1904
1905It defaults to the location of the output file, unless the output
1906file is a special file like @code{/dev/null}. Options
1907@option{-save-temps=cwd} and @option{-save-temps=obj} override this
1908default, just like an explicit @option{-dumpdir} option. In case
1909multiple such options are given, the last one prevails:
1910
1911@smallexample
1912gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
1913@end smallexample
1914
1915outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because
1916@option{-save-temps=*} overrides the @var{dumppfx} given by the earlier
1917@option{-dumpdir} option. It does not matter that @option{=obj} is the
1918default for @option{-save-temps}, nor that the output directory is
1919implicitly the current directory. Dump outputs are named
1920@file{foo.c.*}.
1921
1922When compiling from multiple input files, if @option{-dumpbase} is
1923specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash
1924are appended to (or override, if containing any directory components) an
1925explicit or defaulted @var{dumppfx}, so that each of the multiple
1926compilations gets differently-named aux and dump outputs.
1927
1928@smallexample
1929gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
1930@end smallexample
1931
1932outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and
1933@file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}.
1934Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*}
1935and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the
1936single-input compilation:
1937
1938@smallexample
1939gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
1940@end smallexample
1941
1942that, applying @option{-dumpbase} to a single source, does not compute
1943and append a separate @var{dumpbase} per input file. Its auxiliary and
1944dump outputs go in @file{dir/pfx-main.*}.
1945
1946When compiling and then linking from multiple input files, a defaulted
1947or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}-
1948transformation above (e.g. the compilation of @file{foo.c} and
1949@file{bar.c} above, but without @option{-c}). If neither
1950@option{-dumpdir} nor @option{-dumpbase} are given, the linker output
1951base name, minus @var{auxdropsuf}, if specified, or the executable
1952suffix otherwise, plus a dash is appended to the default @var{dumppfx}
1953instead. Note, however, that unlike earlier cases of linking:
1954
1955@smallexample
1956gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
1957@end smallexample
1958
1959does not append the output name @file{main} to @var{dumppfx}, because
1960@option{-dumpdir} is explicitly specified. The goal is that the
1961explicitly-specified @var{dumppfx} may contain the specified output name
1962as part of the prefix, if desired; only an explicitly-specified
1963@option{-dumpbase} would be combined with it, in order to avoid simply
1964discarding a meaningful option.
1965
1966When compiling and then linking from a single input file, the linker
1967output base name will only be appended to the default @var{dumppfx} as
1968above if it does not share the base name with the single input file
1969name. This has been covered in single-input linking cases above, but
1970not with an explicit @option{-dumpdir} that inhibits the combination,
1971even if overridden by @option{-save-temps=*}:
1972
1973@smallexample
1974gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
1975@end smallexample
1976
1977Auxiliary outputs are named @file{foo.*}, and dump outputs
1978@file{foo.c.*}, in the current working directory as ultimately requested
1979by @option{-save-temps=cwd}.
1980
1981Summing it all up for an intuitive though slightly imprecise data flow:
1982the primary output name is broken into a directory part and a basename
1983part; @var{dumppfx} is set to the former, unless overridden by
1984@option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set
1985to the latter, unless overriden by @option{-dumpbase}. If there are
1986multiple inputs or linking, this @var{dumpbase} may be combined with
1987@var{dumppfx} and taken from each input file. Auxiliary output names
1988for each input are formed by combining @var{dumppfx}, @var{dumpbase}
1989minus suffix, and the auxiliary output suffix; dump output names are
1990only different in that the suffix from @var{dumpbase} is retained.
1991
1992When it comes to auxiliary and dump outputs created during LTO
1993recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as
1994given or as derived from the linker output name but not from inputs,
1995even in cases in which this combination would not otherwise be used as
1996such, is passed down with a trailing period replacing the compiler-added
1997dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper};
1998being involved in linking, this program does not normally get any
1999@option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them.
2000
2001When running sub-compilers, @command{lto-wrapper} appends LTO stage
2002names to the received @var{dumppfx}, ensures it contains a directory
2003component so that it overrides any @option{-dumpdir}, and passes that as
2004@option{-dumpbase} to sub-compilers.
2005
2006@item -v
2007@opindex v
2008Print (on standard error output) the commands executed to run the stages
2009of compilation. Also print the version number of the compiler driver
2010program and of the preprocessor and the compiler proper.
2011
2012@item -###
2013@opindex ###
2014Like @option{-v} except the commands are not executed and arguments
2015are quoted unless they contain only alphanumeric characters or @code{./-_}.
2016This is useful for shell scripts to capture the driver-generated command lines.
2017
2018@item --help
2019@opindex help
2020Print (on the standard output) a description of the command-line options
2021understood by @command{gcc}. If the @option{-v} option is also specified
2022then @option{--help} is also passed on to the various processes
2023invoked by @command{gcc}, so that they can display the command-line options
2024they accept. If the @option{-Wextra} option has also been specified
2025(prior to the @option{--help} option), then command-line options that
2026have no documentation associated with them are also displayed.
2027
2028@item --target-help
2029@opindex target-help
2030Print (on the standard output) a description of target-specific command-line
2031options for each tool. For some targets extra target-specific
2032information may also be printed.
2033
2034@item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]}
2035Print (on the standard output) a description of the command-line
2036options understood by the compiler that fit into all specified classes
2037and qualifiers. These are the supported classes:
2038
2039@table @asis
2040@item @samp{optimizers}
2041Display all of the optimization options supported by the
2042compiler.
2043
2044@item @samp{warnings}
2045Display all of the options controlling warning messages
2046produced by the compiler.
2047
2048@item @samp{target}
2049Display target-specific options. Unlike the
2050@option{--target-help} option however, target-specific options of the
2051linker and assembler are not displayed. This is because those
2052tools do not currently support the extended @option{--help=} syntax.
2053
2054@item @samp{params}
2055Display the values recognized by the @option{--param}
2056option.
2057
2058@item @var{language}
2059Display the options supported for @var{language}, where
2060@var{language} is the name of one of the languages supported in this
2061version of GCC@. If an option is supported by all languages, one needs
2062to select @samp{common} class.
2063
2064@item @samp{common}
2065Display the options that are common to all languages.
2066@end table
2067
2068These are the supported qualifiers:
2069
2070@table @asis
2071@item @samp{undocumented}
2072Display only those options that are undocumented.
2073
2074@item @samp{joined}
2075Display options taking an argument that appears after an equal
2076sign in the same continuous piece of text, such as:
2077@samp{--help=target}.
2078
2079@item @samp{separate}
2080Display options taking an argument that appears as a separate word
2081following the original option, such as: @samp{-o output-file}.
2082@end table
2083
2084Thus for example to display all the undocumented target-specific
2085switches supported by the compiler, use:
2086
2087@smallexample
2088--help=target,undocumented
2089@end smallexample
2090
2091The sense of a qualifier can be inverted by prefixing it with the
2092@samp{^} character, so for example to display all binary warning
2093options (i.e., ones that are either on or off and that do not take an
2094argument) that have a description, use:
2095
2096@smallexample
2097--help=warnings,^joined,^undocumented
2098@end smallexample
2099
2100The argument to @option{--help=} should not consist solely of inverted
2101qualifiers.
2102
2103Combining several classes is possible, although this usually
2104restricts the output so much that there is nothing to display. One
2105case where it does work, however, is when one of the classes is
2106@var{target}. For example, to display all the target-specific
2107optimization options, use:
2108
2109@smallexample
2110--help=target,optimizers
2111@end smallexample
2112
2113The @option{--help=} option can be repeated on the command line. Each
2114successive use displays its requested class of options, skipping
2115those that have already been displayed. If @option{--help} is also
2116specified anywhere on the command line then this takes precedence
2117over any @option{--help=} option.
2118
2119If the @option{-Q} option appears on the command line before the
2120@option{--help=} option, then the descriptive text displayed by
2121@option{--help=} is changed. Instead of describing the displayed
2122options, an indication is given as to whether the option is enabled,
2123disabled or set to a specific value (assuming that the compiler
2124knows this at the point where the @option{--help=} option is used).
2125
2126Here is a truncated example from the ARM port of @command{gcc}:
2127
2128@smallexample
2129 % gcc -Q -mabi=2 --help=target -c
2130 The following options are target specific:
2131 -mabi= 2
2132 -mabort-on-noreturn [disabled]
2133 -mapcs [disabled]
2134@end smallexample
2135
2136The output is sensitive to the effects of previous command-line
2137options, so for example it is possible to find out which optimizations
2138are enabled at @option{-O2} by using:
2139
2140@smallexample
2141-Q -O2 --help=optimizers
2142@end smallexample
2143
2144Alternatively you can discover which binary optimizations are enabled
2145by @option{-O3} by using:
2146
2147@smallexample
2148gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
2149gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
2150diff /tmp/O2-opts /tmp/O3-opts | grep enabled
2151@end smallexample
2152
2153@item --version
2154@opindex version
2155Display the version number and copyrights of the invoked GCC@.
2156
2157@item -pass-exit-codes
2158@opindex pass-exit-codes
2159Normally the @command{gcc} program exits with the code of 1 if any
2160phase of the compiler returns a non-success return code. If you specify
2161@option{-pass-exit-codes}, the @command{gcc} program instead returns with
2162the numerically highest error produced by any phase returning an error
2163indication. The C, C++, and Fortran front ends return 4 if an internal
2164compiler error is encountered.
2165
2166@item -pipe
2167@opindex pipe
2168Use pipes rather than temporary files for communication between the
2169various stages of compilation. This fails to work on some systems where
2170the assembler is unable to read from a pipe; but the GNU assembler has
2171no trouble.
2172
2173@item -specs=@var{file}
2174@opindex specs
2175Process @var{file} after the compiler reads in the standard @file{specs}
2176file, in order to override the defaults which the @command{gcc} driver
2177program uses when determining what switches to pass to @command{cc1},
2178@command{cc1plus}, @command{as}, @command{ld}, etc. More than one
2179@option{-specs=@var{file}} can be specified on the command line, and they
2180are processed in order, from left to right. @xref{Spec Files}, for
2181information about the format of the @var{file}.
2182
2183@item -wrapper
2184@opindex wrapper
2185Invoke all subcommands under a wrapper program. The name of the
2186wrapper program and its parameters are passed as a comma separated
2187list.
2188
2189@smallexample
2190gcc -c t.c -wrapper gdb,--args
2191@end smallexample
2192
2193@noindent
2194This invokes all subprograms of @command{gcc} under
2195@samp{gdb --args}, thus the invocation of @command{cc1} is
2196@samp{gdb --args cc1 @dots{}}.
2197
2198@item -ffile-prefix-map=@var{old}=@var{new}
2199@opindex ffile-prefix-map
2200When compiling files residing in directory @file{@var{old}}, record
2201any references to them in the result of the compilation as if the
2202files resided in directory @file{@var{new}} instead. Specifying this
2203option is equivalent to specifying all the individual
2204@option{-f*-prefix-map} options. This can be used to make reproducible
11543b27
RP
2205builds that are location independent. Directories referenced by
2206directives are not affected by these options. See also
d77de738
ML
2207@option{-fmacro-prefix-map}, @option{-fdebug-prefix-map} and
2208@option{-fprofile-prefix-map}.
2209
2210@item -fplugin=@var{name}.so
2211@opindex fplugin
2212Load the plugin code in file @var{name}.so, assumed to be a
2213shared object to be dlopen'd by the compiler. The base name of
2214the shared object file is used to identify the plugin for the
2215purposes of argument parsing (See
2216@option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below).
2217Each plugin should define the callback functions specified in the
2218Plugins API.
2219
2220@item -fplugin-arg-@var{name}-@var{key}=@var{value}
2221@opindex fplugin-arg
2222Define an argument called @var{key} with a value of @var{value}
2223for the plugin called @var{name}.
2224
2225@item -fdump-ada-spec@r{[}-slim@r{]}
2226@opindex fdump-ada-spec
2227For C and C++ source and include files, generate corresponding Ada specs.
2228@xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn,
2229GNAT User's Guide}, which provides detailed documentation on this feature.
2230
2231@item -fada-spec-parent=@var{unit}
2232@opindex fada-spec-parent
2233In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate
2234Ada specs as child units of parent @var{unit}.
2235
2236@item -fdump-go-spec=@var{file}
2237@opindex fdump-go-spec
2238For input files in any language, generate corresponding Go
2239declarations in @var{file}. This generates Go @code{const},
2240@code{type}, @code{var}, and @code{func} declarations which may be a
2241useful way to start writing a Go interface to code written in some
2242other language.
2243
2244@include @value{srcdir}/../libiberty/at-file.texi
2245@end table
2246
2247@node Invoking G++
2248@section Compiling C++ Programs
2249
2250@cindex suffixes for C++ source
2251@cindex C++ source file suffixes
2252C++ source files conventionally use one of the suffixes @samp{.C},
2253@samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
2254@samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp},
2255@samp{.H}, or (for shared template code) @samp{.tcc}; and
2256preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
2257files with these names and compiles them as C++ programs even if you
2258call the compiler the same way as for compiling C programs (usually
2259with the name @command{gcc}).
2260
2261@findex g++
2262@findex c++
2263However, the use of @command{gcc} does not add the C++ library.
2264@command{g++} is a program that calls GCC and automatically specifies linking
2265against the C++ library. It treats @samp{.c},
2266@samp{.h} and @samp{.i} files as C++ source files instead of C source
2267files unless @option{-x} is used. This program is also useful when
2268precompiling a C header file with a @samp{.h} extension for use in C++
2269compilations. On many systems, @command{g++} is also installed with
2270the name @command{c++}.
2271
2272@cindex invoking @command{g++}
2273When you compile C++ programs, you may specify many of the same
2274command-line options that you use for compiling programs in any
2275language; or command-line options meaningful for C and related
2276languages; or options that are meaningful only for C++ programs.
2277@xref{C Dialect Options,,Options Controlling C Dialect}, for
2278explanations of options for languages related to C@.
2279@xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
2280explanations of options that are meaningful only for C++ programs.
2281
2282@node C Dialect Options
2283@section Options Controlling C Dialect
2284@cindex dialect options
2285@cindex language dialect options
2286@cindex options, dialect
2287
2288The following options control the dialect of C (or languages derived
2289from C, such as C++, Objective-C and Objective-C++) that the compiler
2290accepts:
2291
2292@table @gcctabopt
2293@cindex ANSI support
2294@cindex ISO support
2295@item -ansi
2296@opindex ansi
2297In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
2298equivalent to @option{-std=c++98}.
2299
2300This turns off certain features of GCC that are incompatible with ISO
2301C90 (when compiling C code), or of standard C++ (when compiling C++ code),
2302such as the @code{asm} and @code{typeof} keywords, and
2303predefined macros such as @code{unix} and @code{vax} that identify the
2304type of system you are using. It also enables the undesirable and
2305rarely used ISO trigraph feature. For the C compiler,
2306it disables recognition of C++ style @samp{//} comments as well as
2307the @code{inline} keyword.
2308
2309The alternate keywords @code{__asm__}, @code{__extension__},
2310@code{__inline__} and @code{__typeof__} continue to work despite
2311@option{-ansi}. You would not want to use them in an ISO C program, of
2312course, but it is useful to put them in header files that might be included
2313in compilations done with @option{-ansi}. Alternate predefined macros
2314such as @code{__unix__} and @code{__vax__} are also available, with or
2315without @option{-ansi}.
2316
2317The @option{-ansi} option does not cause non-ISO programs to be
2318rejected gratuitously. For that, @option{-Wpedantic} is required in
2319addition to @option{-ansi}. @xref{Warning Options}.
2320
2321The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
2322option is used. Some header files may notice this macro and refrain
2323from declaring certain functions or defining certain macros that the
2324ISO standard doesn't call for; this is to avoid interfering with any
2325programs that might use these names for other things.
2326
2327Functions that are normally built in but do not have semantics
2328defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
2329functions when @option{-ansi} is used. @xref{Other Builtins,,Other
2330built-in functions provided by GCC}, for details of the functions
2331affected.
2332
2333@item -std=
2334@opindex std
2335Determine the language standard. @xref{Standards,,Language Standards
2336Supported by GCC}, for details of these standard versions. This option
2337is currently only supported when compiling C or C++.
2338
2339The compiler can accept several base standards, such as @samp{c90} or
2340@samp{c++98}, and GNU dialects of those standards, such as
2341@samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the
2342compiler accepts all programs following that standard plus those
2343using GNU extensions that do not contradict it. For example,
2344@option{-std=c90} turns off certain features of GCC that are
2345incompatible with ISO C90, such as the @code{asm} and @code{typeof}
2346keywords, but not other GNU extensions that do not have a meaning in
2347ISO C90, such as omitting the middle term of a @code{?:}
2348expression. On the other hand, when a GNU dialect of a standard is
2349specified, all features supported by the compiler are enabled, even when
2350those features change the meaning of the base standard. As a result, some
2351strict-conforming programs may be rejected. The particular standard
2352is used by @option{-Wpedantic} to identify which features are GNU
2353extensions given that version of the standard. For example
2354@option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//}
2355comments, while @option{-std=gnu99 -Wpedantic} does not.
2356
2357A value for this option must be provided; possible values are
2358
2359@table @samp
2360@item c90
2361@itemx c89
2362@itemx iso9899:1990
2363Support all ISO C90 programs (certain GNU extensions that conflict
2364with ISO C90 are disabled). Same as @option{-ansi} for C code.
2365
2366@item iso9899:199409
2367ISO C90 as modified in amendment 1.
2368
2369@item c99
2370@itemx c9x
2371@itemx iso9899:1999
2372@itemx iso9899:199x
2373ISO C99. This standard is substantially completely supported, modulo
2374bugs and floating-point issues
2375(mainly but not entirely relating to optional C99 features from
2376Annexes F and G). See
2377@w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The
2378names @samp{c9x} and @samp{iso9899:199x} are deprecated.
2379
2380@item c11
2381@itemx c1x
2382@itemx iso9899:2011
2383ISO C11, the 2011 revision of the ISO C standard. This standard is
2384substantially completely supported, modulo bugs, floating-point issues
2385(mainly but not entirely relating to optional C11 features from
2386Annexes F and G) and the optional Annexes K (Bounds-checking
2387interfaces) and L (Analyzability). The name @samp{c1x} is deprecated.
2388
2389@item c17
2390@itemx c18
2391@itemx iso9899:2017
2392@itemx iso9899:2018
2393ISO C17, the 2017 revision of the ISO C standard
2394(published in 2018). This standard is
2395same as C11 except for corrections of defects (all of which are also
2396applied with @option{-std=c11}) and a new value of
2397@code{__STDC_VERSION__}, and so is supported to the same extent as C11.
2398
2399@item c2x
2400The next version of the ISO C standard, still under development. The
2401support for this version is experimental and incomplete.
2402
2403@item gnu90
2404@itemx gnu89
2405GNU dialect of ISO C90 (including some C99 features).
2406
2407@item gnu99
2408@itemx gnu9x
2409GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated.
2410
2411@item gnu11
2412@itemx gnu1x
2413GNU dialect of ISO C11.
2414The name @samp{gnu1x} is deprecated.
2415
2416@item gnu17
2417@itemx gnu18
2418GNU dialect of ISO C17. This is the default for C code.
2419
2420@item gnu2x
2421The next version of the ISO C standard, still under development, plus
2422GNU extensions. The support for this version is experimental and
2423incomplete.
2424
2425@item c++98
2426@itemx c++03
2427The 1998 ISO C++ standard plus the 2003 technical corrigendum and some
2428additional defect reports. Same as @option{-ansi} for C++ code.
2429
2430@item gnu++98
2431@itemx gnu++03
2432GNU dialect of @option{-std=c++98}.
2433
2434@item c++11
2435@itemx c++0x
2436The 2011 ISO C++ standard plus amendments.
2437The name @samp{c++0x} is deprecated.
2438
2439@item gnu++11
2440@itemx gnu++0x
2441GNU dialect of @option{-std=c++11}.
2442The name @samp{gnu++0x} is deprecated.
2443
2444@item c++14
2445@itemx c++1y
2446The 2014 ISO C++ standard plus amendments.
2447The name @samp{c++1y} is deprecated.
2448
2449@item gnu++14
2450@itemx gnu++1y
2451GNU dialect of @option{-std=c++14}.
2452The name @samp{gnu++1y} is deprecated.
2453
2454@item c++17
2455@itemx c++1z
2456The 2017 ISO C++ standard plus amendments.
2457The name @samp{c++1z} is deprecated.
2458
2459@item gnu++17
2460@itemx gnu++1z
2461GNU dialect of @option{-std=c++17}.
2462This is the default for C++ code.
2463The name @samp{gnu++1z} is deprecated.
2464
2465@item c++20
2466@itemx c++2a
2467The 2020 ISO C++ standard plus amendments.
2468Support is experimental, and could change in incompatible ways in
2469future releases.
2470The name @samp{c++2a} is deprecated.
2471
2472@item gnu++20
2473@itemx gnu++2a
2474GNU dialect of @option{-std=c++20}.
2475Support is experimental, and could change in incompatible ways in
2476future releases.
2477The name @samp{gnu++2a} is deprecated.
2478
2479@item c++2b
2480@itemx c++23
2481The next revision of the ISO C++ standard, planned for
24822023. Support is highly experimental, and will almost certainly
2483change in incompatible ways in future releases.
2484
2485@item gnu++2b
2486@itemx gnu++23
2487GNU dialect of @option{-std=c++2b}. Support is highly experimental,
2488and will almost certainly change in incompatible ways in future
2489releases.
2490@end table
2491
2492@item -aux-info @var{filename}
2493@opindex aux-info
2494Output to the given filename prototyped declarations for all functions
2495declared and/or defined in a translation unit, including those in header
2496files. This option is silently ignored in any language other than C@.
2497
2498Besides declarations, the file indicates, in comments, the origin of
2499each declaration (source file and line), whether the declaration was
2500implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
2501@samp{O} for old, respectively, in the first character after the line
2502number and the colon), and whether it came from a declaration or a
2503definition (@samp{C} or @samp{F}, respectively, in the following
2504character). In the case of function definitions, a K&R-style list of
2505arguments followed by their declarations is also provided, inside
2506comments, after the declaration.
2507
2508@item -fno-asm
2509@opindex fno-asm
2510@opindex fasm
2511Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
2512keyword, so that code can use these words as identifiers. You can use
2513the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
2514instead. In C, @option{-ansi} implies @option{-fno-asm}.
2515
2516In C++, @code{inline} is a standard keyword and is not affected by
2517this switch. You may want to use the @option{-fno-gnu-keywords} flag
2518instead, which disables @code{typeof} but not @code{asm} and
2519@code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}),
2520this switch only affects the @code{asm} and @code{typeof} keywords,
2521since @code{inline} is a standard keyword in ISO C99. In C2X mode
2522(@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects
2523the @code{asm} keyword, since @code{typeof} is a standard keyword in
2524ISO C2X.
2525
2526@item -fno-builtin
2527@itemx -fno-builtin-@var{function}
2528@opindex fno-builtin
2529@opindex fbuiltin
2530@cindex built-in functions
2531Don't recognize built-in functions that do not begin with
2532@samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
2533functions provided by GCC}, for details of the functions affected,
2534including those which are not built-in functions when @option{-ansi} or
2535@option{-std} options for strict ISO C conformance are used because they
2536do not have an ISO standard meaning.
2537
2538GCC normally generates special code to handle certain built-in functions
2539more efficiently; for instance, calls to @code{alloca} may become single
2540instructions which adjust the stack directly, and calls to @code{memcpy}
2541may become inline copy loops. The resulting code is often both smaller
2542and faster, but since the function calls no longer appear as such, you
2543cannot set a breakpoint on those calls, nor can you change the behavior
2544of the functions by linking with a different library. In addition,
2545when a function is recognized as a built-in function, GCC may use
2546information about that function to warn about problems with calls to
2547that function, or to generate more efficient code, even if the
2548resulting code still contains calls to that function. For example,
2549warnings are given with @option{-Wformat} for bad calls to
2550@code{printf} when @code{printf} is built in and @code{strlen} is
2551known not to modify global memory.
2552
2553With the @option{-fno-builtin-@var{function}} option
2554only the built-in function @var{function} is
2555disabled. @var{function} must not begin with @samp{__builtin_}. If a
2556function is named that is not built-in in this version of GCC, this
2557option is ignored. There is no corresponding
2558@option{-fbuiltin-@var{function}} option; if you wish to enable
2559built-in functions selectively when using @option{-fno-builtin} or
2560@option{-ffreestanding}, you may define macros such as:
2561
2562@smallexample
2563#define abs(n) __builtin_abs ((n))
2564#define strcpy(d, s) __builtin_strcpy ((d), (s))
2565@end smallexample
2566
2567@item -fcond-mismatch
2568@opindex fcond-mismatch
2569Allow conditional expressions with mismatched types in the second and
2570third arguments. The value of such an expression is void. This option
2571is not supported for C++.
2572
2573@item -ffreestanding
2574@opindex ffreestanding
2575@cindex hosted environment
2576
2577Assert that compilation targets a freestanding environment. This
2578implies @option{-fno-builtin}. A freestanding environment
2579is one in which the standard library may not exist, and program startup may
2580not necessarily be at @code{main}. The most obvious example is an OS kernel.
2581This is equivalent to @option{-fno-hosted}.
2582
2583@xref{Standards,,Language Standards Supported by GCC}, for details of
2584freestanding and hosted environments.
2585
2586@item -fgimple
2587@opindex fgimple
2588
2589Enable parsing of function definitions marked with @code{__GIMPLE}.
2590This is an experimental feature that allows unit testing of GIMPLE
2591passes.
2592
2593@item -fgnu-tm
2594@opindex fgnu-tm
2595When the option @option{-fgnu-tm} is specified, the compiler
2596generates code for the Linux variant of Intel's current Transactional
2597Memory ABI specification document (Revision 1.1, May 6 2009). This is
2598an experimental feature whose interface may change in future versions
2599of GCC, as the official specification changes. Please note that not
2600all architectures are supported for this feature.
2601
2602For more information on GCC's support for transactional memory,
2603@xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
2604Transactional Memory Library}.
2605
2606Note that the transactional memory feature is not supported with
2607non-call exceptions (@option{-fnon-call-exceptions}).
2608
2609@item -fgnu89-inline
2610@opindex fgnu89-inline
2611The option @option{-fgnu89-inline} tells GCC to use the traditional
2612GNU semantics for @code{inline} functions when in C99 mode.
2613@xref{Inline,,An Inline Function is As Fast As a Macro}.
2614Using this option is roughly equivalent to adding the
2615@code{gnu_inline} function attribute to all inline functions
2616(@pxref{Function Attributes}).
2617
2618The option @option{-fno-gnu89-inline} explicitly tells GCC to use the
2619C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it
2620specifies the default behavior).
2621This option is not supported in @option{-std=c90} or
2622@option{-std=gnu90} mode.
2623
2624The preprocessor macros @code{__GNUC_GNU_INLINE__} and
2625@code{__GNUC_STDC_INLINE__} may be used to check which semantics are
2626in effect for @code{inline} functions. @xref{Common Predefined
2627Macros,,,cpp,The C Preprocessor}.
2628
2629@item -fhosted
2630@opindex fhosted
2631@cindex hosted environment
2632
2633Assert that compilation targets a hosted environment. This implies
2634@option{-fbuiltin}. A hosted environment is one in which the
2635entire standard library is available, and in which @code{main} has a return
2636type of @code{int}. Examples are nearly everything except a kernel.
2637This is equivalent to @option{-fno-freestanding}.
2638
2639@item -flax-vector-conversions
2640@opindex flax-vector-conversions
2641Allow implicit conversions between vectors with differing numbers of
2642elements and/or incompatible element types. This option should not be
2643used for new code.
2644
2645@item -fms-extensions
2646@opindex fms-extensions
2647Accept some non-standard constructs used in Microsoft header files.
2648
2649In C++ code, this allows member names in structures to be similar
2650to previous types declarations.
2651
2652@smallexample
2653typedef int UOW;
2654struct ABC @{
2655 UOW UOW;
2656@};
2657@end smallexample
2658
2659Some cases of unnamed fields in structures and unions are only
2660accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union
2661fields within structs/unions}, for details.
2662
2663Note that this option is off for all targets except for x86
2664targets using ms-abi.
2665
2666@item -foffload=disable
2667@itemx -foffload=default
2668@itemx -foffload=@var{target-list}
2669@opindex foffload
2670@cindex Offloading targets
2671@cindex OpenACC offloading targets
2672@cindex OpenMP offloading targets
2673Specify for which OpenMP and OpenACC offload targets code should be generated.
2674The default behavior, equivalent to @option{-foffload=default}, is to generate
2675code for all supported offload targets. The @option{-foffload=disable} form
2676generates code only for the host fallback, while
2677@option{-foffload=@var{target-list}} generates code only for the specified
2678comma-separated list of offload targets.
2679
2680Offload targets are specified in GCC's internal target-triplet format. You can
2681run the compiler with @option{-v} to show the list of configured offload targets
2682under @code{OFFLOAD_TARGET_NAMES}.
2683
2684@item -foffload-options=@var{options}
2685@itemx -foffload-options=@var{target-triplet-list}=@var{options}
2686@opindex foffload-options
2687@cindex Offloading options
2688@cindex OpenACC offloading options
2689@cindex OpenMP offloading options
2690
2691With @option{-foffload-options=@var{options}}, GCC passes the specified
2692@var{options} to the compilers for all enabled offloading targets. You can
2693specify options that apply only to a specific target or targets by using
2694the @option{-foffload-options=@var{target-list}=@var{options}} form. The
2695@var{target-list} is a comma-separated list in the same format as for the
2696@option{-foffload=} option.
2697
2698Typical command lines are
2699
2700@smallexample
2701-foffload-options=-lgfortran -foffload-options=-lm
2702-foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic
2703-foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm
2704@end smallexample
2705
2706@item -fopenacc
2707@opindex fopenacc
2708@cindex OpenACC accelerator programming
2709Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and
2710@code{!$acc} in Fortran. When @option{-fopenacc} is specified, the
2711compiler generates accelerated code according to the OpenACC Application
2712Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option
2713implies @option{-pthread}, and thus is only supported on targets that
2714have support for @option{-pthread}.
2715
2716@item -fopenacc-dim=@var{geom}
2717@opindex fopenacc-dim
2718@cindex OpenACC accelerator programming
2719Specify default compute dimensions for parallel offload regions that do
2720not explicitly specify. The @var{geom} value is a triple of
2721':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size
2722can be omitted, to use a target-specific default value.
2723
2724@item -fopenmp
2725@opindex fopenmp
2726@cindex OpenMP parallel
2727Enable handling of OpenMP directives @code{#pragma omp} in C/C++,
2728@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and
2729@code{!$omp} in Fortran. When @option{-fopenmp} is specified, the
2730compiler generates parallel code according to the OpenMP Application
2731Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option
2732implies @option{-pthread}, and thus is only supported on targets that
2733have support for @option{-pthread}. @option{-fopenmp} implies
2734@option{-fopenmp-simd}.
2735
2736@item -fopenmp-simd
2737@opindex fopenmp-simd
2738@cindex OpenMP SIMD
2739@cindex SIMD
2740Enable handling of OpenMP's @code{simd}, @code{declare simd},
2741@code{declare reduction}, @code{assume}, @code{ordered}, @code{scan},
2742@code{loop} directives and combined or composite directives with
2743@code{simd} as constituent with @code{#pragma omp} in C/C++,
2744@code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++
2745and @code{!$omp} in Fortran. Other OpenMP directives are ignored.
2746
309e2d95
SL
2747@item -fopenmp-target-simd-clone
2748@item -fopenmp-target-simd-clone=@var{device-type}
2749@opindex fopenmp-target-simd-clone
2750@cindex OpenMP target SIMD clone
2751In addition to generating SIMD clones for functions marked with the
2752@code{declare simd} directive, GCC also generates clones
2753for functions marked with the OpenMP @code{declare target} directive
2754that are suitable for vectorization when this option is in effect. The
2755@var{device-type} may be one of @code{none}, @code{host}, @code{nohost},
2756and @code{any}, which correspond to keywords for the @code{device_type}
2757clause of the @code{declare target} directive; clones are generated for
2758the intersection of devices specified.
2759@option{-fopenmp-target-simd-clone} is equivalent to
2760@option{-fopenmp-target-simd-clone=any} and
2761@option{-fno-openmp-target-simd-clone} is equivalent to
2762@option{-fopenmp-target-simd-clone=none}.
2763
2764At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this
2765optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise
2766it is disabled by default.
2767
d77de738
ML
2768@item -fpermitted-flt-eval-methods=@var{style}
2769@opindex fpermitted-flt-eval-methods
2770@opindex fpermitted-flt-eval-methods=c11
2771@opindex fpermitted-flt-eval-methods=ts-18661-3
2772ISO/IEC TS 18661-3 defines new permissible values for
2773@code{FLT_EVAL_METHOD} that indicate that operations and constants with
2774a semantic type that is an interchange or extended format should be
2775evaluated to the precision and range of that type. These new values are
2776a superset of those permitted under C99/C11, which does not specify the
2777meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code
2778conforming to C11 may not have been written expecting the possibility of
2779the new values.
2780
2781@option{-fpermitted-flt-eval-methods} specifies whether the compiler
2782should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11,
2783or the extended set of values specified in ISO/IEC TS 18661-3.
2784
2785@var{style} is either @code{c11} or @code{ts-18661-3} as appropriate.
2786
2787The default when in a standards compliant mode (@option{-std=c11} or similar)
2788is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU
2789dialect (@option{-std=gnu11} or similar) is
2790@option{-fpermitted-flt-eval-methods=ts-18661-3}.
2791
2792@item -fplan9-extensions
2793@opindex fplan9-extensions
2794Accept some non-standard constructs used in Plan 9 code.
2795
2796This enables @option{-fms-extensions}, permits passing pointers to
2797structures with anonymous fields to functions that expect pointers to
2798elements of the type of the field, and permits referring to anonymous
2799fields declared using a typedef. @xref{Unnamed Fields,,Unnamed
2800struct/union fields within structs/unions}, for details. This is only
2801supported for C, not C++.
2802
2803@item -fsigned-bitfields
2804@itemx -funsigned-bitfields
2805@itemx -fno-signed-bitfields
2806@itemx -fno-unsigned-bitfields
2807@opindex fsigned-bitfields
2808@opindex funsigned-bitfields
2809@opindex fno-signed-bitfields
2810@opindex fno-unsigned-bitfields
2811These options control whether a bit-field is signed or unsigned, when the
2812declaration does not use either @code{signed} or @code{unsigned}. By
2813default, such a bit-field is signed, because this is consistent: the
2814basic integer types such as @code{int} are signed types.
2815
2816@item -fsigned-char
2817@opindex fsigned-char
2818Let the type @code{char} be signed, like @code{signed char}.
2819
2820Note that this is equivalent to @option{-fno-unsigned-char}, which is
2821the negative form of @option{-funsigned-char}. Likewise, the option
2822@option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
2823
2824@item -funsigned-char
2825@opindex funsigned-char
2826Let the type @code{char} be unsigned, like @code{unsigned char}.
2827
2828Each kind of machine has a default for what @code{char} should
2829be. It is either like @code{unsigned char} by default or like
2830@code{signed char} by default.
2831
2832Ideally, a portable program should always use @code{signed char} or
2833@code{unsigned char} when it depends on the signedness of an object.
2834But many programs have been written to use plain @code{char} and
2835expect it to be signed, or expect it to be unsigned, depending on the
2836machines they were written for. This option, and its inverse, let you
2837make such a program work with the opposite default.
2838
2839The type @code{char} is always a distinct type from each of
2840@code{signed char} or @code{unsigned char}, even though its behavior
2841is always just like one of those two.
2842
2843@item -fstrict-flex-arrays
2844@opindex fstrict-flex-arrays
2845@opindex fno-strict-flex-arrays
2846Control when to treat the trailing array of a structure as a flexible array
2847member for the purpose of accessing the elements of such an array.
2848The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the
2849strictest. A trailing array is treated as a flexible array member only when it
2850is declared as a flexible array member per C99 standard onwards.
2851The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the
2852least strict. All trailing arrays of structures are treated as flexible array
2853members.
2854
2855@item -fstrict-flex-arrays=@var{level}
2856@opindex fstrict-flex-arrays=@var{level}
2857Control when to treat the trailing array of a structure as a flexible array
2858member for the purpose of accessing the elements of such an array. The value
2859of @var{level} controls the level of strictness.
2860
2861The possible values of @var{level} are the same as for the
2862@code{strict_flex_array} attribute (@pxref{Variable Attributes}).
2863
2864You can control this behavior for a specific trailing array field of a
2865structure by using the variable attribute @code{strict_flex_array} attribute
2866(@pxref{Variable Attributes}).
2867
2868@item -fsso-struct=@var{endianness}
2869@opindex fsso-struct
2870Set the default scalar storage order of structures and unions to the
2871specified endianness. The accepted values are @samp{big-endian},
2872@samp{little-endian} and @samp{native} for the native endianness of
2873the target (the default). This option is not supported for C++.
2874
2875@strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate
2876code that is not binary compatible with code generated without it if the
2877specified endianness is not the native endianness of the target.
2878@end table
2879
2880@node C++ Dialect Options
2881@section Options Controlling C++ Dialect
2882
2883@cindex compiler options, C++
2884@cindex C++ options, command-line
2885@cindex options, C++
2886This section describes the command-line options that are only meaningful
2887for C++ programs. You can also use most of the GNU compiler options
2888regardless of what language your program is in. For example, you
2889might compile a file @file{firstClass.C} like this:
2890
2891@smallexample
2892g++ -g -fstrict-enums -O -c firstClass.C
2893@end smallexample
2894
2895@noindent
2896In this example, only @option{-fstrict-enums} is an option meant
2897only for C++ programs; you can use the other options with any
2898language supported by GCC@.
2899
2900Some options for compiling C programs, such as @option{-std}, are also
2901relevant for C++ programs.
2902@xref{C Dialect Options,,Options Controlling C Dialect}.
2903
2904Here is a list of options that are @emph{only} for compiling C++ programs:
2905
2906@table @gcctabopt
2907
2908@item -fabi-version=@var{n}
2909@opindex fabi-version
2910Use version @var{n} of the C++ ABI@. The default is version 0.
2911
2912Version 0 refers to the version conforming most closely to
2913the C++ ABI specification. Therefore, the ABI obtained using version 0
2914will change in different versions of G++ as ABI bugs are fixed.
2915
2916Version 1 is the version of the C++ ABI that first appeared in G++ 3.2.
2917
2918Version 2 is the version of the C++ ABI that first appeared in G++
29193.4, and was the default through G++ 4.9.
2920
2921Version 3 corrects an error in mangling a constant address as a
2922template argument.
2923
2924Version 4, which first appeared in G++ 4.5, implements a standard
2925mangling for vector types.
2926
2927Version 5, which first appeared in G++ 4.6, corrects the mangling of
2928attribute const/volatile on function pointer types, decltype of a
2929plain decl, and use of a function parameter in the declaration of
2930another parameter.
2931
2932Version 6, which first appeared in G++ 4.7, corrects the promotion
2933behavior of C++11 scoped enums and the mangling of template argument
2934packs, const/static_cast, prefix ++ and --, and a class scope function
2935used as a template argument.
2936
2937Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a
2938builtin type and corrects the mangling of lambdas in default argument
2939scope.
2940
2941Version 8, which first appeared in G++ 4.9, corrects the substitution
2942behavior of function types with function-cv-qualifiers.
2943
2944Version 9, which first appeared in G++ 5.2, corrects the alignment of
2945@code{nullptr_t}.
2946
2947Version 10, which first appeared in G++ 6.1, adds mangling of
2948attributes that affect type identity, such as ia32 calling convention
2949attributes (e.g.@: @samp{stdcall}).
2950
2951Version 11, which first appeared in G++ 7, corrects the mangling of
2952sizeof... expressions and operator names. For multiple entities with
2953the same name within a function, that are declared in different scopes,
2954the mangling now changes starting with the twelfth occurrence. It also
2955implies @option{-fnew-inheriting-ctors}.
2956
2957Version 12, which first appeared in G++ 8, corrects the calling
2958conventions for empty classes on the x86_64 target and for classes
2959with only deleted copy/move constructors. It accidentally changes the
2960calling convention for classes with a deleted copy constructor and a
2961trivial move constructor.
2962
2963Version 13, which first appeared in G++ 8.2, fixes the accidental
2964change in version 12.
2965
2966Version 14, which first appeared in G++ 10, corrects the mangling of
2967the nullptr expression.
2968
2969Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI
2970tag regression.
2971
2972Version 16, which first appeared in G++ 11, changes the mangling of
2973@code{__alignof__} to be distinct from that of @code{alignof}, and
2974dependent operator names.
2975
2976Version 17, which first appeared in G++ 12, fixes layout of classes
2977that inherit from aggregate classes with default member initializers
2978in C++14 and up.
2979
2980Version 18, which first appeard in G++ 13, fixes manglings of lambdas
2981that have additional context.
2982
2983See also @option{-Wabi}.
2984
2985@item -fabi-compat-version=@var{n}
2986@opindex fabi-compat-version
2987On targets that support strong aliases, G++
2988works around mangling changes by creating an alias with the correct
2989mangled name when defining a symbol with an incorrect mangled name.
2990This switch specifies which ABI version to use for the alias.
2991
2992With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2
2993compatibility). If another ABI version is explicitly selected, this
2994defaults to 0. For compatibility with GCC versions 3.2 through 4.9,
2995use @option{-fabi-compat-version=2}.
2996
2997If this option is not provided but @option{-Wabi=@var{n}} is, that
2998version is used for compatibility aliases. If this option is provided
2999along with @option{-Wabi} (without the version), the version from this
3000option is used for the warning.
3001
3002@item -fno-access-control
3003@opindex fno-access-control
3004@opindex faccess-control
3005Turn off all access checking. This switch is mainly useful for working
3006around bugs in the access control code.
3007
3008@item -faligned-new
3009@opindex faligned-new
3010Enable support for C++17 @code{new} of types that require more
3011alignment than @code{void* ::operator new(std::size_t)} provides. A
3012numeric argument such as @code{-faligned-new=32} can be used to
3013specify how much alignment (in bytes) is provided by that function,
3014but few users will need to override the default of
3015@code{alignof(std::max_align_t)}.
3016
3017This flag is enabled by default for @option{-std=c++17}.
3018
3019@item -fchar8_t
3020@itemx -fno-char8_t
3021@opindex fchar8_t
3022@opindex fno-char8_t
3023Enable support for @code{char8_t} as adopted for C++20. This includes
3024the addition of a new @code{char8_t} fundamental type, changes to the
3025types of UTF-8 string and character literals, new signatures for
3026user-defined literals, associated standard library updates, and new
3027@code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros.
3028
3029This option enables functions to be overloaded for ordinary and UTF-8
3030strings:
3031
3032@smallexample
3033int f(const char *); // #1
3034int f(const char8_t *); // #2
3035int v1 = f("text"); // Calls #1
3036int v2 = f(u8"text"); // Calls #2
3037@end smallexample
3038
3039@noindent
3040and introduces new signatures for user-defined literals:
3041
3042@smallexample
3043int operator""_udl1(char8_t);
3044int v3 = u8'x'_udl1;
3045int operator""_udl2(const char8_t*, std::size_t);
3046int v4 = u8"text"_udl2;
3047template<typename T, T...> int operator""_udl3();
3048int v5 = u8"text"_udl3;
3049@end smallexample
3050
3051@noindent
3052The change to the types of UTF-8 string and character literals introduces
3053incompatibilities with ISO C++11 and later standards. For example, the
3054following code is well-formed under ISO C++11, but is ill-formed when
3055@option{-fchar8_t} is specified.
3056
3057@smallexample
3058char ca[] = u8"xx"; // error: char-array initialized from wide
3059 // string
3060const char *cp = u8"xx";// error: invalid conversion from
3061 // `const char8_t*' to `const char*'
3062int f(const char*);
3063auto v = f(u8"xx"); // error: invalid conversion from
3064 // `const char8_t*' to `const char*'
3065std::string s@{u8"xx"@}; // error: no matching function for call to
3066 // `std::basic_string<char>::basic_string()'
3067using namespace std::literals;
3068s = u8"xx"s; // error: conversion from
3069 // `basic_string<char8_t>' to non-scalar
3070 // type `basic_string<char>' requested
3071@end smallexample
3072
3073@item -fcheck-new
3074@opindex fcheck-new
3075Check that the pointer returned by @code{operator new} is non-null
3076before attempting to modify the storage allocated. This check is
3077normally unnecessary because the C++ standard specifies that
3078@code{operator new} only returns @code{0} if it is declared
3079@code{throw()}, in which case the compiler always checks the
3080return value even without this option. In all other cases, when
3081@code{operator new} has a non-empty exception specification, memory
3082exhaustion is signalled by throwing @code{std::bad_alloc}. See also
3083@samp{new (nothrow)}.
3084
3085@item -fconcepts
3086@itemx -fconcepts-ts
3087@opindex fconcepts
3088@opindex fconcepts-ts
3089Enable support for the C++ Concepts feature for constraining template
3090arguments. With @option{-std=c++20} and above, Concepts are part of
3091the language standard, so @option{-fconcepts} defaults to on.
3092
3093Some constructs that were allowed by the earlier C++ Extensions for
3094Concepts Technical Specification, ISO 19217 (2015), but didn't make it
3095into the standard, can additionally be enabled by
3096@option{-fconcepts-ts}.
3097
3098@item -fconstexpr-depth=@var{n}
3099@opindex fconstexpr-depth
3100Set the maximum nested evaluation depth for C++11 constexpr functions
3101to @var{n}. A limit is needed to detect endless recursion during
3102constant expression evaluation. The minimum specified by the standard
3103is 512.
3104
3105@item -fconstexpr-cache-depth=@var{n}
3106@opindex fconstexpr-cache-depth
3107Set the maximum level of nested evaluation depth for C++11 constexpr
3108functions that will be cached to @var{n}. This is a heuristic that
3109trades off compilation speed (when the cache avoids repeated
3110calculations) against memory consumption (when the cache grows very
3111large from highly recursive evaluations). The default is 8. Very few
3112users are likely to want to adjust it, but if your code does heavy
3113constexpr calculations you might want to experiment to find which
3114value works best for you.
3115
3116@item -fconstexpr-fp-except
3117@opindex fconstexpr-fp-except
3118Annex F of the C standard specifies that IEC559 floating point
3119exceptions encountered at compile time should not stop compilation.
3120C++ compilers have historically not followed this guidance, instead
3121treating floating point division by zero as non-constant even though
3122it has a well defined value. This flag tells the compiler to give
3123Annex F priority over other rules saying that a particular operation
3124is undefined.
3125
3126@smallexample
3127constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except
3128@end smallexample
3129
3130@item -fconstexpr-loop-limit=@var{n}
3131@opindex fconstexpr-loop-limit
3132Set the maximum number of iterations for a loop in C++14 constexpr functions
3133to @var{n}. A limit is needed to detect infinite loops during
3134constant expression evaluation. The default is 262144 (1<<18).
3135
3136@item -fconstexpr-ops-limit=@var{n}
3137@opindex fconstexpr-ops-limit
3138Set the maximum number of operations during a single constexpr evaluation.
3139Even when number of iterations of a single loop is limited with the above limit,
3140if there are several nested loops and each of them has many iterations but still
3141smaller than the above limit, or if in a body of some loop or even outside
3142of a loop too many expressions need to be evaluated, the resulting constexpr
3143evaluation might take too long.
3144The default is 33554432 (1<<25).
3145
2efb237f
JCI
3146@item -fcontracts
3147@opindex fcontracts
3148Enable experimental support for the C++ Contracts feature, as briefly
3149added to and then removed from the C++20 working paper (N4820). The
3150implementation also includes proposed enhancements from papers P1290,
3151P1332, and P1429. This functionality is intended mostly for those
3152interested in experimentation towards refining the feature to get it
3153into shape for a future C++ standard.
3154
3155On violation of a checked contract, the violation handler is called.
3156Users can replace the violation handler by defining
3157@smallexample
3158void handle_contract_violation (const std::experimental::contract_violation&);
3159@end smallexample
3160
3161There are different sets of additional flags that can be used together
3162to specify which contracts will be checked and how, for N4820
3163contracts, P1332 contracts, or P1429 contracts; these sets cannot be
3164used together.
3165
3166@table @gcctabopt
3167@item -fcontract-mode=[on|off]
3168@opindex fcontract-mode
3169Control whether any contracts have any semantics at all. Defaults to on.
3170
3171@item -fcontract-assumption-mode=[on|off]
3172@opindex fcontract-assumption-mode
3173[N4820] Control whether contracts with level @samp{axiom}
3174should have the assume semantic. Defaults to on.
3175
3176@item -fcontract-build-level=[off|default|audit]
3177@opindex fcontract-build-level
3178[N4820] Specify which level of contracts to generate checks
3179for. Defaults to @samp{default}.
3180
3181@item -fcontract-continuation-mode=[on|off]
3182@opindex fcontract-continuation-mode
3183[N4820] Control whether to allow the program to continue executing
3184after a contract violation. That is, do checked contracts have the
3185@samp{maybe} semantic described below rather than the @samp{never}
3186semantic. Defaults to off.
3187
3188@item -fcontract-role=<name>:<default>,<audit>,<axiom>
3189@opindex fcontract-role
3190[P1332] Specify the concrete semantics for each contract level
3191of a particular contract role.
3192
3193@item -fcontract-semantic=[default|audit|axiom]:<semantic>
3194[P1429] Specify the concrete semantic for a particular
3195contract level.
3196
3197@item -fcontract-strict-declarations=[on|off]
3198@opindex fcontract-strict-declarations
3199Control whether to reject adding contracts to a function after its
3200first declaration. Defaults to off.
3201@end table
3202
3203The possible concrete semantics for that can be specified with
3204@samp{-fcontract-role} or @samp{-fcontract-semantic} are:
3205
3206@table @code
3207@item ignore
3208This contract has no effect.
3209
3210@item assume
3211This contract is treated like C++23 @code{[[assume]]}.
3212
3213@item check_never_continue
3214@itemx never
3215@itemx abort
3216This contract is checked. If it fails, the violation handler is
3217called. If the handler returns, @code{std::terminate} is called.
3218
3219@item check_maybe_continue
3220@itemx maybe
3221This contract is checked. If it fails, the violation handler is
3222called. If the handler returns, execution continues normally.
3223@end table
3224
d77de738
ML
3225@item -fcoroutines
3226@opindex fcoroutines
3227Enable support for the C++ coroutines extension (experimental).
3228
3229@item -fno-elide-constructors
3230@opindex fno-elide-constructors
3231@opindex felide-constructors
3232The C++ standard allows an implementation to omit creating a temporary
3233that is only used to initialize another object of the same type.
3234Specifying this option disables that optimization, and forces G++ to
3235call the copy constructor in all cases. This option also causes G++
3236to call trivial member functions which otherwise would be expanded inline.
3237
3238In C++17, the compiler is required to omit these temporaries, but this
3239option still affects trivial member functions.
3240
3241@item -fno-enforce-eh-specs
3242@opindex fno-enforce-eh-specs
3243@opindex fenforce-eh-specs
3244Don't generate code to check for violation of exception specifications
3245at run time. This option violates the C++ standard, but may be useful
3246for reducing code size in production builds, much like defining
3247@code{NDEBUG}. This does not give user code permission to throw
3248exceptions in violation of the exception specifications; the compiler
3249still optimizes based on the specifications, so throwing an
3250unexpected exception results in undefined behavior at run time.
3251
3252@item -fextern-tls-init
3253@itemx -fno-extern-tls-init
3254@opindex fextern-tls-init
3255@opindex fno-extern-tls-init
3256The C++11 and OpenMP standards allow @code{thread_local} and
3257@code{threadprivate} variables to have dynamic (runtime)
3258initialization. To support this, any use of such a variable goes
3259through a wrapper function that performs any necessary initialization.
3260When the use and definition of the variable are in the same
3261translation unit, this overhead can be optimized away, but when the
3262use is in a different translation unit there is significant overhead
3263even if the variable doesn't actually need dynamic initialization. If
3264the programmer can be sure that no use of the variable in a
3265non-defining TU needs to trigger dynamic initialization (either
3266because the variable is statically initialized, or a use of the
3267variable in the defining TU will be executed before any uses in
3268another TU), they can avoid this overhead with the
3269@option{-fno-extern-tls-init} option.
3270
3271On targets that support symbol aliases, the default is
3272@option{-fextern-tls-init}. On targets that do not support symbol
3273aliases, the default is @option{-fno-extern-tls-init}.
3274
3275@item -ffold-simple-inlines
3276@itemx -fno-fold-simple-inlines
3277@opindex ffold-simple-inlines
3278@opindex fno-fold-simple-inlines
3279Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward},
3280@code{std::addressof} and @code{std::as_const}. In contrast to inlining, this
3281means no debug information will be generated for such calls. Since these
3282functions are rarely interesting to debug, this flag is enabled by default
3283unless @option{-fno-inline} is active.
3284
3285@item -fno-gnu-keywords
3286@opindex fno-gnu-keywords
3287@opindex fgnu-keywords
3288Do not recognize @code{typeof} as a keyword, so that code can use this
3289word as an identifier. You can use the keyword @code{__typeof__} instead.
3290This option is implied by the strict ISO C++ dialects: @option{-ansi},
3291@option{-std=c++98}, @option{-std=c++11}, etc.
3292
3293@item -fimplicit-constexpr
3294@opindex fimplicit-constexpr
3295Make inline functions implicitly constexpr, if they satisfy the
3296requirements for a constexpr function. This option can be used in
3297C++14 mode or later. This can result in initialization changing from
3298dynamic to static and other optimizations.
3299
3300@item -fno-implicit-templates
3301@opindex fno-implicit-templates
3302@opindex fimplicit-templates
3303Never emit code for non-inline templates that are instantiated
3304implicitly (i.e.@: by use); only emit code for explicit instantiations.
3305If you use this option, you must take care to structure your code to
3306include all the necessary explicit instantiations to avoid getting
3307undefined symbols at link time.
3308@xref{Template Instantiation}, for more information.
3309
3310@item -fno-implicit-inline-templates
3311@opindex fno-implicit-inline-templates
3312@opindex fimplicit-inline-templates
3313Don't emit code for implicit instantiations of inline templates, either.
3314The default is to handle inlines differently so that compiles with and
3315without optimization need the same set of explicit instantiations.
3316
3317@item -fno-implement-inlines
3318@opindex fno-implement-inlines
3319@opindex fimplement-inlines
3320To save space, do not emit out-of-line copies of inline functions
3321controlled by @code{#pragma implementation}. This causes linker
3322errors if these functions are not inlined everywhere they are called.
3323
3324@item -fmodules-ts
3325@itemx -fno-modules-ts
3326@opindex fmodules-ts
3327@opindex fno-modules-ts
3328Enable support for C++20 modules (@pxref{C++ Modules}). The
3329@option{-fno-modules-ts} is usually not needed, as that is the
3330default. Even though this is a C++20 feature, it is not currently
3331implicitly enabled by selecting that standard version.
3332
3333@item -fmodule-header
3334@itemx -fmodule-header=user
3335@itemx -fmodule-header=system
3336@opindex fmodule-header
3337Compile a header file to create an importable header unit.
3338
3339@item -fmodule-implicit-inline
3340@opindex fmodule-implicit-inline
3341Member functions defined in their class definitions are not implicitly
3342inline for modular code. This is different to traditional C++
3343behavior, for good reasons. However, it may result in a difficulty
3344during code porting. This option makes such function definitions
3345implicitly inline. It does however generate an ABI incompatibility,
3346so you must use it everywhere or nowhere. (Such definitions outside
3347of a named module remain implicitly inline, regardless.)
3348
3349@item -fno-module-lazy
3350@opindex fno-module-lazy
3351@opindex fmodule-lazy
3352Disable lazy module importing and module mapper creation.
3353
3354@item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
3355@itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...}
3356@itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]}
3357@itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]}
3358@itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]}
3359@itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]}
3360@vindex CXX_MODULE_MAPPER @r{environment variable}
3361@opindex fmodule-mapper
3362An oracle to query for module name to filename mappings. If
3363unspecified the @env{CXX_MODULE_MAPPER} environment variable is used,
3364and if that is unset, an in-process default is provided.
3365
3366@item -fmodule-only
3367@opindex fmodule-only
3368Only emit the Compiled Module Interface, inhibiting any object file.
3369
3370@item -fms-extensions
3371@opindex fms-extensions
3372Disable Wpedantic warnings about constructs used in MFC, such as implicit
3373int and getting a pointer to member function via non-standard syntax.
3374
3375@item -fnew-inheriting-ctors
3376@opindex fnew-inheriting-ctors
3377Enable the P0136 adjustment to the semantics of C++11 constructor
3378inheritance. This is part of C++17 but also considered to be a Defect
3379Report against C++11 and C++14. This flag is enabled by default
3380unless @option{-fabi-version=10} or lower is specified.
3381
3382@item -fnew-ttp-matching
3383@opindex fnew-ttp-matching
3384Enable the P0522 resolution to Core issue 150, template template
3385parameters and default arguments: this allows a template with default
3386template arguments as an argument for a template template parameter
3387with fewer template parameters. This flag is enabled by default for
3388@option{-std=c++17}.
3389
3390@item -fno-nonansi-builtins
3391@opindex fno-nonansi-builtins
3392@opindex fnonansi-builtins
3393Disable built-in declarations of functions that are not mandated by
3394ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
3395@code{index}, @code{bzero}, @code{conjf}, and other related functions.
3396
3397@item -fnothrow-opt
3398@opindex fnothrow-opt
3399Treat a @code{throw()} exception specification as if it were a
3400@code{noexcept} specification to reduce or eliminate the text size
3401overhead relative to a function with no exception specification. If
3402the function has local variables of types with non-trivial
3403destructors, the exception specification actually makes the
3404function smaller because the EH cleanups for those variables can be
3405optimized away. The semantic effect is that an exception thrown out of
3406a function with such an exception specification results in a call
3407to @code{terminate} rather than @code{unexpected}.
3408
3409@item -fno-operator-names
3410@opindex fno-operator-names
3411@opindex foperator-names
3412Do not treat the operator name keywords @code{and}, @code{bitand},
3413@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
3414synonyms as keywords.
3415
3416@item -fno-optional-diags
3417@opindex fno-optional-diags
3418@opindex foptional-diags
3419Disable diagnostics that the standard says a compiler does not need to
3420issue. Currently, the only such diagnostic issued by G++ is the one for
3421a name having multiple meanings within a class.
3422
3423@item -fpermissive
3424@opindex fpermissive
3425Downgrade some diagnostics about nonconformant code from errors to
3426warnings. Thus, using @option{-fpermissive} allows some
3427nonconforming code to compile.
3428
3429@item -fno-pretty-templates
3430@opindex fno-pretty-templates
3431@opindex fpretty-templates
3432When an error message refers to a specialization of a function
3433template, the compiler normally prints the signature of the
3434template followed by the template arguments and any typedefs or
3435typenames in the signature (e.g.@: @code{void f(T) [with T = int]}
3436rather than @code{void f(int)}) so that it's clear which template is
3437involved. When an error message refers to a specialization of a class
3438template, the compiler omits any template arguments that match
3439the default template arguments for that template. If either of these
3440behaviors make it harder to understand the error message rather than
3441easier, you can use @option{-fno-pretty-templates} to disable them.
3442
3443@item -fno-rtti
3444@opindex fno-rtti
3445@opindex frtti
3446Disable generation of information about every class with virtual
3447functions for use by the C++ run-time type identification features
3448(@code{dynamic_cast} and @code{typeid}). If you don't use those parts
3449of the language, you can save some space by using this flag. Note that
3450exception handling uses the same information, but G++ generates it as
3451needed. The @code{dynamic_cast} operator can still be used for casts that
3452do not require run-time type information, i.e.@: casts to @code{void *} or to
3453unambiguous base classes.
3454
3455Mixing code compiled with @option{-frtti} with that compiled with
3456@option{-fno-rtti} may not work. For example, programs may
3457fail to link if a class compiled with @option{-fno-rtti} is used as a base
3458for a class compiled with @option{-frtti}.
3459
3460@item -fsized-deallocation
3461@opindex fsized-deallocation
3462Enable the built-in global declarations
3463@smallexample
3464void operator delete (void *, std::size_t) noexcept;
3465void operator delete[] (void *, std::size_t) noexcept;
3466@end smallexample
3467as introduced in C++14. This is useful for user-defined replacement
3468deallocation functions that, for example, use the size of the object
3469to make deallocation faster. Enabled by default under
3470@option{-std=c++14} and above. The flag @option{-Wsized-deallocation}
3471warns about places that might want to add a definition.
3472
3473@item -fstrict-enums
3474@opindex fstrict-enums
3475Allow the compiler to optimize using the assumption that a value of
3476enumerated type can only be one of the values of the enumeration (as
3477defined in the C++ standard; basically, a value that can be
3478represented in the minimum number of bits needed to represent all the
3479enumerators). This assumption may not be valid if the program uses a
3480cast to convert an arbitrary integer value to the enumerated type.
3481
3482@item -fstrong-eval-order
3483@opindex fstrong-eval-order
3484Evaluate member access, array subscripting, and shift expressions in
3485left-to-right order, and evaluate assignment in right-to-left order,
3486as adopted for C++17. Enabled by default with @option{-std=c++17}.
3487@option{-fstrong-eval-order=some} enables just the ordering of member
3488access and shift expressions, and is the default without
3489@option{-std=c++17}.
3490
3491@item -ftemplate-backtrace-limit=@var{n}
3492@opindex ftemplate-backtrace-limit
3493Set the maximum number of template instantiation notes for a single
3494warning or error to @var{n}. The default value is 10.
3495
3496@item -ftemplate-depth=@var{n}
3497@opindex ftemplate-depth
3498Set the maximum instantiation depth for template classes to @var{n}.
3499A limit on the template instantiation depth is needed to detect
3500endless recursions during template class instantiation. ANSI/ISO C++
3501conforming programs must not rely on a maximum depth greater than 17
3502(changed to 1024 in C++11). The default value is 900, as the compiler
3503can run out of stack space before hitting 1024 in some situations.
3504
3505@item -fno-threadsafe-statics
3506@opindex fno-threadsafe-statics
3507@opindex fthreadsafe-statics
3508Do not emit the extra code to use the routines specified in the C++
3509ABI for thread-safe initialization of local statics. You can use this
3510option to reduce code size slightly in code that doesn't need to be
3511thread-safe.
3512
3513@item -fuse-cxa-atexit
3514@opindex fuse-cxa-atexit
3515Register destructors for objects with static storage duration with the
3516@code{__cxa_atexit} function rather than the @code{atexit} function.
3517This option is required for fully standards-compliant handling of static
3518destructors, but only works if your C library supports
3519@code{__cxa_atexit}.
3520
3521@item -fno-use-cxa-get-exception-ptr
3522@opindex fno-use-cxa-get-exception-ptr
3523@opindex fuse-cxa-get-exception-ptr
3524Don't use the @code{__cxa_get_exception_ptr} runtime routine. This
3525causes @code{std::uncaught_exception} to be incorrect, but is necessary
3526if the runtime routine is not available.
3527
3528@item -fvisibility-inlines-hidden
3529@opindex fvisibility-inlines-hidden
3530This switch declares that the user does not attempt to compare
3531pointers to inline functions or methods where the addresses of the two functions
3532are taken in different shared objects.
3533
3534The effect of this is that GCC may, effectively, mark inline methods with
3535@code{__attribute__ ((visibility ("hidden")))} so that they do not
3536appear in the export table of a DSO and do not require a PLT indirection
3537when used within the DSO@. Enabling this option can have a dramatic effect
3538on load and link times of a DSO as it massively reduces the size of the
3539dynamic export table when the library makes heavy use of templates.
3540
3541The behavior of this switch is not quite the same as marking the
3542methods as hidden directly, because it does not affect static variables
3543local to the function or cause the compiler to deduce that
3544the function is defined in only one shared object.
3545
3546You may mark a method as having a visibility explicitly to negate the
3547effect of the switch for that method. For example, if you do want to
3548compare pointers to a particular inline method, you might mark it as
3549having default visibility. Marking the enclosing class with explicit
3550visibility has no effect.
3551
3552Explicitly instantiated inline methods are unaffected by this option
3553as their linkage might otherwise cross a shared library boundary.
3554@xref{Template Instantiation}.
3555
3556@item -fvisibility-ms-compat
3557@opindex fvisibility-ms-compat
3558This flag attempts to use visibility settings to make GCC's C++
3559linkage model compatible with that of Microsoft Visual Studio.
3560
3561The flag makes these changes to GCC's linkage model:
3562
3563@enumerate
3564@item
3565It sets the default visibility to @code{hidden}, like
3566@option{-fvisibility=hidden}.
3567
3568@item
3569Types, but not their members, are not hidden by default.
3570
3571@item
3572The One Definition Rule is relaxed for types without explicit
3573visibility specifications that are defined in more than one
3574shared object: those declarations are permitted if they are
3575permitted when this option is not used.
3576@end enumerate
3577
3578In new code it is better to use @option{-fvisibility=hidden} and
3579export those classes that are intended to be externally visible.
3580Unfortunately it is possible for code to rely, perhaps accidentally,
3581on the Visual Studio behavior.
3582
3583Among the consequences of these changes are that static data members
3584of the same type with the same name but defined in different shared
3585objects are different, so changing one does not change the other;
3586and that pointers to function members defined in different shared
3587objects may not compare equal. When this flag is given, it is a
3588violation of the ODR to define types with the same name differently.
3589
3590@item -fno-weak
3591@opindex fno-weak
3592@opindex fweak
3593Do not use weak symbol support, even if it is provided by the linker.
3594By default, G++ uses weak symbols if they are available. This
3595option exists only for testing, and should not be used by end-users;
3596it results in inferior code and has no benefits. This option may
3597be removed in a future release of G++.
3598
3599@item -fext-numeric-literals @r{(C++ and Objective-C++ only)}
3600@opindex fext-numeric-literals
3601@opindex fno-ext-numeric-literals
3602Accept imaginary, fixed-point, or machine-defined
3603literal number suffixes as GNU extensions.
3604When this option is turned off these suffixes are treated
3605as C++11 user-defined literal numeric suffixes.
3606This is on by default for all pre-C++11 dialects and all GNU dialects:
3607@option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11},
3608@option{-std=gnu++14}.
3609This option is off by default
3610for ISO C++11 onwards (@option{-std=c++11}, ...).
3611
3612@item -nostdinc++
3613@opindex nostdinc++
3614Do not search for header files in the standard directories specific to
3615C++, but do still search the other standard directories. (This option
3616is used when building the C++ library.)
3617
3618@item -flang-info-include-translate
3619@itemx -flang-info-include-translate-not
3620@itemx -flang-info-include-translate=@var{header}
3621@opindex flang-info-include-translate
3622@opindex flang-info-include-translate-not
3623Inform of include translation events. The first will note accepted
3624include translations, the second will note declined include
3625translations. The @var{header} form will inform of include
3626translations relating to that specific header. If @var{header} is of
3627the form @code{"user"} or @code{<system>} it will be resolved to a
3628specific user or system header using the include path.
3629
3630@item -flang-info-module-cmi
3631@itemx -flang-info-module-cmi=@var{module}
3632@opindex flang-info-module-cmi
3633Inform of Compiled Module Interface pathnames. The first will note
3634all read CMI pathnames. The @var{module} form will not reading a
3635specific module's CMI. @var{module} may be a named module or a
3636header-unit (the latter indicated by either being a pathname containing
3637directory separators or enclosed in @code{<>} or @code{""}).
3638
3639@item -stdlib=@var{libstdc++,libc++}
3640@opindex stdlib
3641When G++ is configured to support this option, it allows specification of
3642alternate C++ runtime libraries. Two options are available: @var{libstdc++}
3643(the default, native C++ runtime for G++) and @var{libc++} which is the
3644C++ runtime installed on some operating systems (e.g. Darwin versions from
3645Darwin11 onwards). The option switches G++ to use the headers from the
3646specified library and to emit @code{-lstdc++} or @code{-lc++} respectively,
3647when a C++ runtime is required for linking.
3648@end table
3649
3650In addition, these warning options have meanings only for C++ programs:
3651
3652@table @gcctabopt
3653@item -Wabi-tag @r{(C++ and Objective-C++ only)}
3654@opindex Wabi-tag
3655Warn when a type with an ABI tag is used in a context that does not
3656have that ABI tag. See @ref{C++ Attributes} for more information
3657about ABI tags.
3658
3659@item -Wcomma-subscript @r{(C++ and Objective-C++ only)}
3660@opindex Wcomma-subscript
3661@opindex Wno-comma-subscript
3662Warn about uses of a comma expression within a subscripting expression.
3663This usage was deprecated in C++20 and is going to be removed in C++23.
3664However, a comma expression wrapped in @code{( )} is not deprecated. Example:
3665
3666@smallexample
3667@group
3668void f(int *a, int b, int c) @{
3669 a[b,c]; // deprecated in C++20, invalid in C++23
3670 a[(b,c)]; // OK
3671@}
3672@end group
3673@end smallexample
3674
3675In C++23 it is valid to have comma separated expressions in a subscript
3676when an overloaded subscript operator is found and supports the right
3677number and types of arguments. G++ will accept the formerly valid syntax
3678for code that is not valid in C++23 but used to be valid but deprecated
3679in C++20 with a pedantic warning that can be disabled with
3680@option{-Wno-comma-subscript}.
3681
3682Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated},
3683and with @option{-std=c++23} regardless of @option{-Wno-deprecated}.
3684
3685@item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)}
3686@opindex Wctad-maybe-unsupported
3687@opindex Wno-ctad-maybe-unsupported
3688Warn when performing class template argument deduction (CTAD) on a type with
3689no explicitly written deduction guides. This warning will point out cases
3690where CTAD succeeded only because the compiler synthesized the implicit
3691deduction guides, which might not be what the programmer intended. Certain
3692style guides allow CTAD only on types that specifically "opt-in"; i.e., on
3693types that are designed to support CTAD. This warning can be suppressed with
3694the following pattern:
3695
3696@smallexample
3697struct allow_ctad_t; // any name works
3698template <typename T> struct S @{
3699 S(T) @{ @}
3700@};
3701S(allow_ctad_t) -> S<void>; // guide with incomplete parameter type will never be considered
3702@end smallexample
3703
3704@item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)}
3705@opindex Wctor-dtor-privacy
3706@opindex Wno-ctor-dtor-privacy
3707Warn when a class seems unusable because all the constructors or
3708destructors in that class are private, and it has neither friends nor
3709public static member functions. Also warn if there are no non-private
3710methods, and there's at least one private member function that isn't
3711a constructor or destructor.
3712
3713@item -Wdangling-reference @r{(C++ and Objective-C++ only)}
3714@opindex Wdangling-reference
3715@opindex Wno-dangling-reference
3716Warn when a reference is bound to a temporary whose lifetime has ended.
3717For example:
3718
3719@smallexample
3720int n = 1;
3721const int& r = std::max(n - 1, n + 1); // r is dangling
3722@end smallexample
3723
3724In the example above, two temporaries are created, one for each
3725argument, and a reference to one of the temporaries is returned.
3726However, both temporaries are destroyed at the end of the full
3727expression, so the reference @code{r} is dangling. This warning
3728also detects dangling references in member initializer lists:
3729
3730@smallexample
3731const int& f(const int& i) @{ return i; @}
3732struct S @{
3733 const int &r; // r is dangling
3734 S() : r(f(10)) @{ @}
3735@};
3736@end smallexample
3737
3738Member functions are checked as well, but only their object argument:
3739
3740@smallexample
3741struct S @{
3742 const S& self () @{ return *this; @}
3743@};
3744const S& s = S().self(); // s is dangling
3745@end smallexample
3746
3747Certain functions are safe in this respect, for example @code{std::use_facet}:
3748they take and return a reference, but they don't return one of its arguments,
3749which can fool the warning. Such functions can be excluded from the warning
3750by wrapping them in a @code{#pragma}:
3751
3752@smallexample
3753#pragma GCC diagnostic push
3754#pragma GCC diagnostic ignored "-Wdangling-reference"
3755const T& foo (const T&) @{ @dots{} @}
3756#pragma GCC diagnostic pop
3757@end smallexample
3758
ce51e843
ML
3759@option{-Wdangling-reference} also warns about code like
3760
3761@smallexample
3762auto p = std::minmax(1, 2);
3763@end smallexample
3764
3765where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and
3766both references dangle after the end of the full expression that contains
3767the call to @code{std::minmax}.
3768
d77de738
ML
3769This warning is enabled by @option{-Wall}.
3770
3771@item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)}
3772@opindex Wdelete-non-virtual-dtor
3773@opindex Wno-delete-non-virtual-dtor
3774Warn when @code{delete} is used to destroy an instance of a class that
3775has virtual functions and non-virtual destructor. It is unsafe to delete
3776an instance of a derived class through a pointer to a base class if the
3777base class does not have a virtual destructor. This warning is enabled
3778by @option{-Wall}.
3779
3780@item -Wdeprecated-copy @r{(C++ and Objective-C++ only)}
3781@opindex Wdeprecated-copy
3782@opindex Wno-deprecated-copy
3783Warn that the implicit declaration of a copy constructor or copy
3784assignment operator is deprecated if the class has a user-provided
3785copy constructor or copy assignment operator, in C++11 and up. This
3786warning is enabled by @option{-Wextra}. With
3787@option{-Wdeprecated-copy-dtor}, also deprecate if the class has a
3788user-provided destructor.
3789
3790@item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)}
3791@opindex Wdeprecated-enum-enum-conversion
3792@opindex Wno-deprecated-enum-enum-conversion
3793Disable the warning about the case when the usual arithmetic conversions
3794are applied on operands where one is of enumeration type and the other is
3795of a different enumeration type. This conversion was deprecated in C++20.
3796For example:
3797
3798@smallexample
3799enum E1 @{ e @};
3800enum E2 @{ f @};
3801int k = f - e;
3802@end smallexample
3803
3804@option{-Wdeprecated-enum-enum-conversion} is enabled by default with
3805@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3806by @option{-Wenum-conversion}.
3807
3808@item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)}
3809@opindex Wdeprecated-enum-float-conversion
3810@opindex Wno-deprecated-enum-float-conversion
3811Disable the warning about the case when the usual arithmetic conversions
3812are applied on operands where one is of enumeration type and the other is
3813of a floating-point type. This conversion was deprecated in C++20. For
3814example:
3815
3816@smallexample
3817enum E1 @{ e @};
3818enum E2 @{ f @};
3819bool b = e <= 3.7;
3820@end smallexample
3821
3822@option{-Wdeprecated-enum-float-conversion} is enabled by default with
3823@option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled
3824by @option{-Wenum-conversion}.
3825
3826@item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)}
3827@opindex Winit-list-lifetime
3828@opindex Wno-init-list-lifetime
3829Do not warn about uses of @code{std::initializer_list} that are likely
3830to result in dangling pointers. Since the underlying array for an
3831@code{initializer_list} is handled like a normal C++ temporary object,
3832it is easy to inadvertently keep a pointer to the array past the end
3833of the array's lifetime. For example:
3834
3835@itemize @bullet
3836@item
3837If a function returns a temporary @code{initializer_list}, or a local
3838@code{initializer_list} variable, the array's lifetime ends at the end
3839of the return statement, so the value returned has a dangling pointer.
3840
3841@item
3842If a new-expression creates an @code{initializer_list}, the array only
3843lives until the end of the enclosing full-expression, so the
3844@code{initializer_list} in the heap has a dangling pointer.
3845
3846@item
3847When an @code{initializer_list} variable is assigned from a
3848brace-enclosed initializer list, the temporary array created for the
3849right side of the assignment only lives until the end of the
3850full-expression, so at the next statement the @code{initializer_list}
3851variable has a dangling pointer.
3852
3853@smallexample
3854// li's initial underlying array lives as long as li
3855std::initializer_list<int> li = @{ 1,2,3 @};
3856// assignment changes li to point to a temporary array
3857li = @{ 4, 5 @};
3858// now the temporary is gone and li has a dangling pointer
3859int i = li.begin()[0] // undefined behavior
3860@end smallexample
3861
3862@item
3863When a list constructor stores the @code{begin} pointer from the
3864@code{initializer_list} argument, this doesn't extend the lifetime of
3865the array, so if a class variable is constructed from a temporary
3866@code{initializer_list}, the pointer is left dangling by the end of
3867the variable declaration statement.
3868
3869@end itemize
3870
c85f8dbb
MP
3871@item -Winvalid-constexpr
3872@opindex Winvalid-constexpr
3873@opindex Wno-invalid-constexpr
3874
3875Warn when a function never produces a constant expression. In C++20
3876and earlier, for every @code{constexpr} function and function template,
3877there must be at least one set of function arguments in at least one
3878instantiation such that an invocation of the function or constructor
3879could be an evaluated subexpression of a core constant expression.
3880C++23 removed this restriction, so it's possible to have a function
3881or a function template marked @code{constexpr} for which no invocation
3882satisfies the requirements of a core constant expression.
3883
3884This warning is enabled as a pedantic warning by default in C++20 and
3885earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in
3886which case it will be an ordinary warning. For example:
3887
3888@smallexample
3889void f (int& i);
3890constexpr void
3891g (int& i)
3892@{
3893 f(i); // warns by default in C++20, in C++23 only with -Winvalid-constexpr
3894@}
3895@end smallexample
3896
d77de738
ML
3897@item -Winvalid-imported-macros
3898@opindex Winvalid-imported-macros
3899@opindex Wno-invalid-imported-macros
3900Verify all imported macro definitions are valid at the end of
3901compilation. This is not enabled by default, as it requires
3902additional processing to determine. It may be useful when preparing
3903sets of header-units to ensure consistent macros.
3904
3905@item -Wno-literal-suffix @r{(C++ and Objective-C++ only)}
3906@opindex Wliteral-suffix
3907@opindex Wno-literal-suffix
3908Do not warn when a string or character literal is followed by a
3909ud-suffix which does not begin with an underscore. As a conforming
3910extension, GCC treats such suffixes as separate preprocessing tokens
3911in order to maintain backwards compatibility with code that uses
3912formatting macros from @code{<inttypes.h>}. For example:
3913
3914@smallexample
3915#define __STDC_FORMAT_MACROS
3916#include <inttypes.h>
3917#include <stdio.h>
3918
3919int main() @{
3920 int64_t i64 = 123;
3921 printf("My int64: %" PRId64"\n", i64);
3922@}
3923@end smallexample
3924
3925In this case, @code{PRId64} is treated as a separate preprocessing token.
3926
3927This option also controls warnings when a user-defined literal
3928operator is declared with a literal suffix identifier that doesn't
3929begin with an underscore. Literal suffix identifiers that don't begin
3930with an underscore are reserved for future standardization.
3931
3932These warnings are enabled by default.
3933
3934@item -Wno-narrowing @r{(C++ and Objective-C++ only)}
3935@opindex Wnarrowing
3936@opindex Wno-narrowing
3937For C++11 and later standards, narrowing conversions are diagnosed by default,
3938as required by the standard. A narrowing conversion from a constant produces
3939an error, and a narrowing conversion from a non-constant produces a warning,
3940but @option{-Wno-narrowing} suppresses the diagnostic.
3941Note that this does not affect the meaning of well-formed code;
3942narrowing conversions are still considered ill-formed in SFINAE contexts.
3943
3944With @option{-Wnarrowing} in C++98, warn when a narrowing
3945conversion prohibited by C++11 occurs within
3946@samp{@{ @}}, e.g.
3947
3948@smallexample
3949int i = @{ 2.2 @}; // error: narrowing from double to int
3950@end smallexample
3951
3952This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
3953
3954@item -Wnoexcept @r{(C++ and Objective-C++ only)}
3955@opindex Wnoexcept
3956@opindex Wno-noexcept
3957Warn when a noexcept-expression evaluates to false because of a call
3958to a function that does not have a non-throwing exception
3959specification (i.e. @code{throw()} or @code{noexcept}) but is known by
3960the compiler to never throw an exception.
3961
3962@item -Wnoexcept-type @r{(C++ and Objective-C++ only)}
3963@opindex Wnoexcept-type
3964@opindex Wno-noexcept-type
3965Warn if the C++17 feature making @code{noexcept} part of a function
3966type changes the mangled name of a symbol relative to C++14. Enabled
3967by @option{-Wabi} and @option{-Wc++17-compat}.
3968
3969As an example:
3970
3971@smallexample
3972template <class T> void f(T t) @{ t(); @};
3973void g() noexcept;
3974void h() @{ f(g); @}
3975@end smallexample
3976
3977@noindent
3978In C++14, @code{f} calls @code{f<void(*)()>}, but in
3979C++17 it calls @code{f<void(*)()noexcept>}.
3980
3981@item -Wclass-memaccess @r{(C++ and Objective-C++ only)}
3982@opindex Wclass-memaccess
3983@opindex Wno-class-memaccess
3984Warn when the destination of a call to a raw memory function such as
3985@code{memset} or @code{memcpy} is an object of class type, and when writing
3986into such an object might bypass the class non-trivial or deleted constructor
3987or copy assignment, violate const-correctness or encapsulation, or corrupt
3988virtual table pointers. Modifying the representation of such objects may
3989violate invariants maintained by member functions of the class. For example,
3990the call to @code{memset} below is undefined because it modifies a non-trivial
3991class object and is, therefore, diagnosed. The safe way to either initialize
3992or clear the storage of objects of such types is by using the appropriate
3993constructor or assignment operator, if one is available.
3994@smallexample
3995std::string str = "abc";
3996memset (&str, 0, sizeof str);
3997@end smallexample
3998The @option{-Wclass-memaccess} option is enabled by @option{-Wall}.
3999Explicitly casting the pointer to the class object to @code{void *} or
4000to a type that can be safely accessed by the raw memory function suppresses
4001the warning.
4002
4003@item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)}
4004@opindex Wnon-virtual-dtor
4005@opindex Wno-non-virtual-dtor
4006Warn when a class has virtual functions and an accessible non-virtual
4007destructor itself or in an accessible polymorphic base class, in which
4008case it is possible but unsafe to delete an instance of a derived
4009class through a pointer to the class itself or base class. This
4010warning is automatically enabled if @option{-Weffc++} is specified.
51f28e3a
JW
4011The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall})
4012should be preferred because it warns about the unsafe cases without false
4013positives.
d77de738
ML
4014
4015@item -Wregister @r{(C++ and Objective-C++ only)}
4016@opindex Wregister
4017@opindex Wno-register
4018Warn on uses of the @code{register} storage class specifier, except
4019when it is part of the GNU @ref{Explicit Register Variables} extension.
4020The use of the @code{register} keyword as storage class specifier has
4021been deprecated in C++11 and removed in C++17.
4022Enabled by default with @option{-std=c++17}.
4023
4024@item -Wreorder @r{(C++ and Objective-C++ only)}
4025@opindex Wreorder
4026@opindex Wno-reorder
4027@cindex reordering, warning
4028@cindex warning for reordering of member initializers
4029Warn when the order of member initializers given in the code does not
4030match the order in which they must be executed. For instance:
4031
4032@smallexample
4033struct A @{
4034 int i;
4035 int j;
4036 A(): j (0), i (1) @{ @}
4037@};
4038@end smallexample
4039
4040@noindent
4041The compiler rearranges the member initializers for @code{i}
4042and @code{j} to match the declaration order of the members, emitting
4043a warning to that effect. This warning is enabled by @option{-Wall}.
4044
4045@item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)}
4046@opindex Wpessimizing-move
4047@opindex Wno-pessimizing-move
4048This warning warns when a call to @code{std::move} prevents copy
4049elision. A typical scenario when copy elision can occur is when returning in
4050a function with a class return type, when the expression being returned is the
4051name of a non-volatile automatic object, and is not a function parameter, and
4052has the same type as the function return type.
4053
4054@smallexample
4055struct T @{
4056@dots{}
4057@};
4058T fn()
4059@{
4060 T t;
4061 @dots{}
4062 return std::move (t);
4063@}
4064@end smallexample
4065
4066But in this example, the @code{std::move} call prevents copy elision.
4067
4068This warning is enabled by @option{-Wall}.
4069
4070@item -Wno-redundant-move @r{(C++ and Objective-C++ only)}
4071@opindex Wredundant-move
4072@opindex Wno-redundant-move
4073This warning warns about redundant calls to @code{std::move}; that is, when
4074a move operation would have been performed even without the @code{std::move}
4075call. This happens because the compiler is forced to treat the object as if
4076it were an rvalue in certain situations such as returning a local variable,
4077where copy elision isn't applicable. Consider:
4078
4079@smallexample
4080struct T @{
4081@dots{}
4082@};
4083T fn(T t)
4084@{
4085 @dots{}
4086 return std::move (t);
4087@}
4088@end smallexample
4089
4090Here, the @code{std::move} call is redundant. Because G++ implements Core
4091Issue 1579, another example is:
4092
4093@smallexample
4094struct T @{ // convertible to U
4095@dots{}
4096@};
4097struct U @{
4098@dots{}
4099@};
4100U fn()
4101@{
4102 T t;
4103 @dots{}
4104 return std::move (t);
4105@}
4106@end smallexample
4107In this example, copy elision isn't applicable because the type of the
4108expression being returned and the function return type differ, yet G++
4109treats the return value as if it were designated by an rvalue.
4110
4111This warning is enabled by @option{-Wextra}.
4112
4113@item -Wrange-loop-construct @r{(C++ and Objective-C++ only)}
4114@opindex Wrange-loop-construct
4115@opindex Wno-range-loop-construct
4116This warning warns when a C++ range-based for-loop is creating an unnecessary
4117copy. This can happen when the range declaration is not a reference, but
4118probably should be. For example:
4119
4120@smallexample
4121struct S @{ char arr[128]; @};
4122void fn () @{
4123 S arr[5];
4124 for (const auto x : arr) @{ @dots{} @}
4125@}
4126@end smallexample
4127
4128It does not warn when the type being copied is a trivially-copyable type whose
4129size is less than 64 bytes.
4130
4131This warning also warns when a loop variable in a range-based for-loop is
4132initialized with a value of a different type resulting in a copy. For example:
4133
4134@smallexample
4135void fn() @{
4136 int arr[10];
4137 for (const double &x : arr) @{ @dots{} @}
4138@}
4139@end smallexample
4140
4141In the example above, in every iteration of the loop a temporary value of
4142type @code{double} is created and destroyed, to which the reference
4143@code{const double &} is bound.
4144
4145This warning is enabled by @option{-Wall}.
4146
4147@item -Wredundant-tags @r{(C++ and Objective-C++ only)}
4148@opindex Wredundant-tags
4149@opindex Wno-redundant-tags
4150Warn about redundant class-key and enum-key in references to class types
4151and enumerated types in contexts where the key can be eliminated without
4152causing an ambiguity. For example:
4153
4154@smallexample
4155struct foo;
4156struct foo *p; // warn that keyword struct can be eliminated
4157@end smallexample
4158
4159@noindent
4160On the other hand, in this example there is no warning:
4161
4162@smallexample
4163struct foo;
4164void foo (); // "hides" struct foo
4165void bar (struct foo&); // no warning, keyword struct is necessary
4166@end smallexample
4167
4168@item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)}
4169@opindex Wsubobject-linkage
4170@opindex Wno-subobject-linkage
4171Do not warn
4172if a class type has a base or a field whose type uses the anonymous
4173namespace or depends on a type with no linkage. If a type A depends on
4174a type B with no or internal linkage, defining it in multiple
4175translation units would be an ODR violation because the meaning of B
4176is different in each translation unit. If A only appears in a single
4177translation unit, the best way to silence the warning is to give it
4178internal linkage by putting it in an anonymous namespace as well. The
4179compiler doesn't give this warning for types defined in the main .C
4180file, as those are unlikely to have multiple definitions.
4181@option{-Wsubobject-linkage} is enabled by default.
4182
4183@item -Weffc++ @r{(C++ and Objective-C++ only)}
4184@opindex Weffc++
4185@opindex Wno-effc++
4186Warn about violations of the following style guidelines from Scott Meyers'
4187@cite{Effective C++} series of books:
4188
4189@itemize @bullet
4190@item
4191Define a copy constructor and an assignment operator for classes
4192with dynamically-allocated memory.
4193
4194@item
4195Prefer initialization to assignment in constructors.
4196
4197@item
4198Have @code{operator=} return a reference to @code{*this}.
4199
4200@item
4201Don't try to return a reference when you must return an object.
4202
4203@item
4204Distinguish between prefix and postfix forms of increment and
4205decrement operators.
4206
4207@item
4208Never overload @code{&&}, @code{||}, or @code{,}.
4209
4210@end itemize
4211
4212This option also enables @option{-Wnon-virtual-dtor}, which is also
4213one of the effective C++ recommendations. However, the check is
4214extended to warn about the lack of virtual destructor in accessible
4215non-polymorphic bases classes too.
4216
4217When selecting this option, be aware that the standard library
4218headers do not obey all of these guidelines; use @samp{grep -v}
4219to filter out those warnings.
4220
4221@item -Wno-exceptions @r{(C++ and Objective-C++ only)}
4222@opindex Wexceptions
4223@opindex Wno-exceptions
4224Disable the warning about the case when an exception handler is shadowed by
4225another handler, which can point out a wrong ordering of exception handlers.
4226
4227@item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)}
4228@opindex Wstrict-null-sentinel
4229@opindex Wno-strict-null-sentinel
4230Warn about the use of an uncasted @code{NULL} as sentinel. When
4231compiling only with GCC this is a valid sentinel, as @code{NULL} is defined
4232to @code{__null}. Although it is a null pointer constant rather than a
4233null pointer, it is guaranteed to be of the same size as a pointer.
4234But this use is not portable across different compilers.
4235
4236@item -Wno-non-template-friend @r{(C++ and Objective-C++ only)}
4237@opindex Wno-non-template-friend
4238@opindex Wnon-template-friend
4239Disable warnings when non-template friend functions are declared
4240within a template. In very old versions of GCC that predate implementation
4241of the ISO standard, declarations such as
4242@samp{friend int foo(int)}, where the name of the friend is an unqualified-id,
4243could be interpreted as a particular specialization of a template
4244function; the warning exists to diagnose compatibility problems,
4245and is enabled by default.
4246
4247@item -Wold-style-cast @r{(C++ and Objective-C++ only)}
4248@opindex Wold-style-cast
4249@opindex Wno-old-style-cast
4250Warn if an old-style (C-style) cast to a non-void type is used within
4251a C++ program. The new-style casts (@code{dynamic_cast},
4252@code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are
4253less vulnerable to unintended effects and much easier to search for.
4254
4255@item -Woverloaded-virtual @r{(C++ and Objective-C++ only)}
4256@itemx -Woverloaded-virtual=@var{n}
4257@opindex Woverloaded-virtual
4258@opindex Wno-overloaded-virtual
4259@cindex overloaded virtual function, warning
4260@cindex warning for overloaded virtual function
4261Warn when a function declaration hides virtual functions from a
4262base class. For example, in:
4263
4264@smallexample
4265struct A @{
4266 virtual void f();
4267@};
4268
4269struct B: public A @{
4270 void f(int); // does not override
4271@};
4272@end smallexample
4273
4274the @code{A} class version of @code{f} is hidden in @code{B}, and code
4275like:
4276
4277@smallexample
4278B* b;
4279b->f();
4280@end smallexample
4281
4282@noindent
4283fails to compile.
4284
4285The optional level suffix controls the behavior when all the
4286declarations in the derived class override virtual functions in the
4287base class, even if not all of the base functions are overridden:
4288
4289@smallexample
4290struct C @{
4291 virtual void f();
4292 virtual void f(int);
4293@};
4294
4295struct D: public C @{
4296 void f(int); // does override
4297@}
4298@end smallexample
4299
4300This pattern is less likely to be a mistake; if D is only used
4301virtually, the user might have decided that the base class semantics
4302for some of the overloads are fine.
4303
4304At level 1, this case does not warn; at level 2, it does.
4305@option{-Woverloaded-virtual} by itself selects level 2. Level 1 is
4306included in @option{-Wall}.
4307
4308@item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)}
4309@opindex Wno-pmf-conversions
4310@opindex Wpmf-conversions
4311Disable the diagnostic for converting a bound pointer to member function
4312to a plain pointer.
4313
4314@item -Wsign-promo @r{(C++ and Objective-C++ only)}
4315@opindex Wsign-promo
4316@opindex Wno-sign-promo
4317Warn when overload resolution chooses a promotion from unsigned or
4318enumerated type to a signed type, over a conversion to an unsigned type of
4319the same size. Previous versions of G++ tried to preserve
4320unsignedness, but the standard mandates the current behavior.
4321
4322@item -Wtemplates @r{(C++ and Objective-C++ only)}
4323@opindex Wtemplates
4324@opindex Wno-templates
4325Warn when a primary template declaration is encountered. Some coding
4326rules disallow templates, and this may be used to enforce that rule.
4327The warning is inactive inside a system header file, such as the STL, so
4328one can still use the STL. One may also instantiate or specialize
4329templates.
4330
4331@item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)}
4332@opindex Wmismatched-new-delete
4333@opindex Wno-mismatched-new-delete
4334Warn for mismatches between calls to @code{operator new} or @code{operator
4335delete} and the corresponding call to the allocation or deallocation function.
4336This includes invocations of C++ @code{operator delete} with pointers
4337returned from either mismatched forms of @code{operator new}, or from other
4338functions that allocate objects for which the @code{operator delete} isn't
4339a suitable deallocator, as well as calls to other deallocation functions
4340with pointers returned from @code{operator new} for which the deallocation
4341function isn't suitable.
4342
4343For example, the @code{delete} expression in the function below is diagnosed
4344because it doesn't match the array form of the @code{new} expression
4345the pointer argument was returned from. Similarly, the call to @code{free}
4346is also diagnosed.
4347
4348@smallexample
4349void f ()
4350@{
4351 int *a = new int[n];
4352 delete a; // warning: mismatch in array forms of expressions
4353
4354 char *p = new char[n];
4355 free (p); // warning: mismatch between new and free
4356@}
4357@end smallexample
4358
4359The related option @option{-Wmismatched-dealloc} diagnoses mismatches
4360involving allocation and deallocation functions other than @code{operator
4361new} and @code{operator delete}.
4362
4363@option{-Wmismatched-new-delete} is included in @option{-Wall}.
4364
4365@item -Wmismatched-tags @r{(C++ and Objective-C++ only)}
4366@opindex Wmismatched-tags
4367@opindex Wno-mismatched-tags
4368Warn for declarations of structs, classes, and class templates and their
4369specializations with a class-key that does not match either the definition
4370or the first declaration if no definition is provided.
4371
4372For example, the declaration of @code{struct Object} in the argument list
4373of @code{draw} triggers the warning. To avoid it, either remove the redundant
4374class-key @code{struct} or replace it with @code{class} to match its definition.
4375@smallexample
4376class Object @{
4377public:
4378 virtual ~Object () = 0;
4379@};
4380void draw (struct Object*);
4381@end smallexample
4382
4383It is not wrong to declare a class with the class-key @code{struct} as
4384the example above shows. The @option{-Wmismatched-tags} option is intended
4385to help achieve a consistent style of class declarations. In code that is
4386intended to be portable to Windows-based compilers the warning helps prevent
4387unresolved references due to the difference in the mangling of symbols
4388declared with different class-keys. The option can be used either on its
4389own or in conjunction with @option{-Wredundant-tags}.
4390
4391@item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)}
4392@opindex Wmultiple-inheritance
4393@opindex Wno-multiple-inheritance
4394Warn when a class is defined with multiple direct base classes. Some
4395coding rules disallow multiple inheritance, and this may be used to
4396enforce that rule. The warning is inactive inside a system header file,
4397such as the STL, so one can still use the STL. One may also define
4398classes that indirectly use multiple inheritance.
4399
4400@item -Wvirtual-inheritance
4401@opindex Wvirtual-inheritance
4402@opindex Wno-virtual-inheritance
4403Warn when a class is defined with a virtual direct base class. Some
4404coding rules disallow multiple inheritance, and this may be used to
4405enforce that rule. The warning is inactive inside a system header file,
4406such as the STL, so one can still use the STL. One may also define
4407classes that indirectly use virtual inheritance.
4408
4409@item -Wno-virtual-move-assign
4410@opindex Wvirtual-move-assign
4411@opindex Wno-virtual-move-assign
4412Suppress warnings about inheriting from a virtual base with a
4413non-trivial C++11 move assignment operator. This is dangerous because
4414if the virtual base is reachable along more than one path, it is
4415moved multiple times, which can mean both objects end up in the
4416moved-from state. If the move assignment operator is written to avoid
4417moving from a moved-from object, this warning can be disabled.
4418
4419@item -Wnamespaces
4420@opindex Wnamespaces
4421@opindex Wno-namespaces
4422Warn when a namespace definition is opened. Some coding rules disallow
4423namespaces, and this may be used to enforce that rule. The warning is
4424inactive inside a system header file, such as the STL, so one can still
4425use the STL. One may also use using directives and qualified names.
4426
4427@item -Wno-terminate @r{(C++ and Objective-C++ only)}
4428@opindex Wterminate
4429@opindex Wno-terminate
4430Disable the warning about a throw-expression that will immediately
4431result in a call to @code{terminate}.
4432
4433@item -Wno-vexing-parse @r{(C++ and Objective-C++ only)}
4434@opindex Wvexing-parse
4435@opindex Wno-vexing-parse
4436Warn about the most vexing parse syntactic ambiguity. This warns about
4437the cases when a declaration looks like a variable definition, but the
4438C++ language requires it to be interpreted as a function declaration.
4439For instance:
4440
4441@smallexample
4442void f(double a) @{
4443 int i(); // extern int i (void);
4444 int n(int(a)); // extern int n (int);
4445@}
4446@end smallexample
4447
4448Another example:
4449
4450@smallexample
4451struct S @{ S(int); @};
4452void f(double a) @{
4453 S x(int(a)); // extern struct S x (int);
4454 S y(int()); // extern struct S y (int (*) (void));
4455 S z(); // extern struct S z (void);
4456@}
4457@end smallexample
4458
4459The warning will suggest options how to deal with such an ambiguity; e.g.,
4460it can suggest removing the parentheses or using braces instead.
4461
4462This warning is enabled by default.
4463
4464@item -Wno-class-conversion @r{(C++ and Objective-C++ only)}
4465@opindex Wno-class-conversion
4466@opindex Wclass-conversion
4467Do not warn when a conversion function converts an
4468object to the same type, to a base class of that type, or to void; such
4469a conversion function will never be called.
4470
4471@item -Wvolatile @r{(C++ and Objective-C++ only)}
4472@opindex Wvolatile
4473@opindex Wno-volatile
4474Warn about deprecated uses of the @code{volatile} qualifier. This includes
4475postfix and prefix @code{++} and @code{--} expressions of
4476@code{volatile}-qualified types, using simple assignments where the left
4477operand is a @code{volatile}-qualified non-class type for their value,
4478compound assignments where the left operand is a @code{volatile}-qualified
4479non-class type, @code{volatile}-qualified function return type,
4480@code{volatile}-qualified parameter type, and structured bindings of a
4481@code{volatile}-qualified type. This usage was deprecated in C++20.
4482
4483Enabled by default with @option{-std=c++20}.
4484
4485@item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)}
4486@opindex Wzero-as-null-pointer-constant
4487@opindex Wno-zero-as-null-pointer-constant
4488Warn when a literal @samp{0} is used as null pointer constant. This can
4489be useful to facilitate the conversion to @code{nullptr} in C++11.
4490
4491@item -Waligned-new
4492@opindex Waligned-new
4493@opindex Wno-aligned-new
4494Warn about a new-expression of a type that requires greater alignment
4495than the @code{alignof(std::max_align_t)} but uses an allocation
4496function without an explicit alignment parameter. This option is
4497enabled by @option{-Wall}.
4498
4499Normally this only warns about global allocation functions, but
4500@option{-Waligned-new=all} also warns about class member allocation
4501functions.
4502
4503@item -Wno-placement-new
4504@itemx -Wplacement-new=@var{n}
4505@opindex Wplacement-new
4506@opindex Wno-placement-new
4507Warn about placement new expressions with undefined behavior, such as
4508constructing an object in a buffer that is smaller than the type of
4509the object. For example, the placement new expression below is diagnosed
4510because it attempts to construct an array of 64 integers in a buffer only
451164 bytes large.
4512@smallexample
4513char buf [64];
4514new (buf) int[64];
4515@end smallexample
4516This warning is enabled by default.
4517
4518@table @gcctabopt
4519@item -Wplacement-new=1
4520This is the default warning level of @option{-Wplacement-new}. At this
4521level the warning is not issued for some strictly undefined constructs that
4522GCC allows as extensions for compatibility with legacy code. For example,
4523the following @code{new} expression is not diagnosed at this level even
4524though it has undefined behavior according to the C++ standard because
4525it writes past the end of the one-element array.
4526@smallexample
4527struct S @{ int n, a[1]; @};
4528S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]);
4529new (s->a)int [32]();
4530@end smallexample
4531
4532@item -Wplacement-new=2
4533At this level, in addition to diagnosing all the same constructs as at level
45341, a diagnostic is also issued for placement new expressions that construct
4535an object in the last member of structure whose type is an array of a single
4536element and whose size is less than the size of the object being constructed.
4537While the previous example would be diagnosed, the following construct makes
4538use of the flexible member array extension to avoid the warning at level 2.
4539@smallexample
4540struct S @{ int n, a[]; @};
4541S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]);
4542new (s->a)int [32]();
4543@end smallexample
4544
4545@end table
4546
4547@item -Wcatch-value
4548@itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)}
4549@opindex Wcatch-value
4550@opindex Wno-catch-value
4551Warn about catch handlers that do not catch via reference.
4552With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short)
4553warn about polymorphic class types that are caught by value.
4554With @option{-Wcatch-value=2} warn about all class types that are caught
4555by value. With @option{-Wcatch-value=3} warn about all types that are
4556not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}.
4557
4558@item -Wconditionally-supported @r{(C++ and Objective-C++ only)}
4559@opindex Wconditionally-supported
4560@opindex Wno-conditionally-supported
4561Warn for conditionally-supported (C++11 [intro.defs]) constructs.
4562
4563@item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)}
4564@opindex Wdelete-incomplete
4565@opindex Wno-delete-incomplete
4566Do not warn when deleting a pointer to incomplete type, which may cause
4567undefined behavior at runtime. This warning is enabled by default.
4568
4569@item -Wextra-semi @r{(C++, Objective-C++ only)}
4570@opindex Wextra-semi
4571@opindex Wno-extra-semi
4572Warn about redundant semicolons after in-class function definitions.
4573
4574@item -Wno-inaccessible-base @r{(C++, Objective-C++ only)}
4575@opindex Winaccessible-base
4576@opindex Wno-inaccessible-base
4577This option controls warnings
4578when a base class is inaccessible in a class derived from it due to
4579ambiguity. The warning is enabled by default.
4580Note that the warning for ambiguous virtual
4581bases is enabled by the @option{-Wextra} option.
4582@smallexample
4583@group
4584struct A @{ int a; @};
4585
4586struct B : A @{ @};
4587
4588struct C : B, A @{ @};
4589@end group
4590@end smallexample
4591
4592@item -Wno-inherited-variadic-ctor
4593@opindex Winherited-variadic-ctor
4594@opindex Wno-inherited-variadic-ctor
4595Suppress warnings about use of C++11 inheriting constructors when the
4596base class inherited from has a C variadic constructor; the warning is
4597on by default because the ellipsis is not inherited.
4598
4599@item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)}
4600@opindex Wno-invalid-offsetof
4601@opindex Winvalid-offsetof
4602Suppress warnings from applying the @code{offsetof} macro to a non-POD
4603type. According to the 2014 ISO C++ standard, applying @code{offsetof}
4604to a non-standard-layout type is undefined. In existing C++ implementations,
4605however, @code{offsetof} typically gives meaningful results.
4606This flag is for users who are aware that they are
4607writing nonportable code and who have deliberately chosen to ignore the
4608warning about it.
4609
4610The restrictions on @code{offsetof} may be relaxed in a future version
4611of the C++ standard.
4612
4613@item -Wsized-deallocation @r{(C++ and Objective-C++ only)}
4614@opindex Wsized-deallocation
4615@opindex Wno-sized-deallocation
4616Warn about a definition of an unsized deallocation function
4617@smallexample
4618void operator delete (void *) noexcept;
4619void operator delete[] (void *) noexcept;
4620@end smallexample
4621without a definition of the corresponding sized deallocation function
4622@smallexample
4623void operator delete (void *, std::size_t) noexcept;
4624void operator delete[] (void *, std::size_t) noexcept;
4625@end smallexample
4626or vice versa. Enabled by @option{-Wextra} along with
4627@option{-fsized-deallocation}.
4628
4629@item -Wsuggest-final-types
4630@opindex Wno-suggest-final-types
4631@opindex Wsuggest-final-types
4632Warn about types with virtual methods where code quality would be improved
4633if the type were declared with the C++11 @code{final} specifier,
4634or, if possible,
4635declared in an anonymous namespace. This allows GCC to more aggressively
4636devirtualize the polymorphic calls. This warning is more effective with
4637link-time optimization,
4638where the information about the class hierarchy graph is
4639more complete.
4640
4641@item -Wsuggest-final-methods
4642@opindex Wno-suggest-final-methods
4643@opindex Wsuggest-final-methods
4644Warn about virtual methods where code quality would be improved if the method
4645were declared with the C++11 @code{final} specifier,
4646or, if possible, its type were
4647declared in an anonymous namespace or with the @code{final} specifier.
4648This warning is
4649more effective with link-time optimization, where the information about the
4650class hierarchy graph is more complete. It is recommended to first consider
4651suggestions of @option{-Wsuggest-final-types} and then rebuild with new
4652annotations.
4653
4654@item -Wsuggest-override
4655@opindex Wsuggest-override
4656@opindex Wno-suggest-override
4657Warn about overriding virtual functions that are not marked with the
4658@code{override} keyword.
4659
4660@item -Wuse-after-free
4661@itemx -Wuse-after-free=@var{n}
4662@opindex Wuse-after-free
4663@opindex Wno-use-after-free
4664Warn about uses of pointers to dynamically allocated objects that have
4665been rendered indeterminate by a call to a deallocation function.
4666The warning is enabled at all optimization levels but may yield different
4667results with optimization than without.
4668
4669@table @gcctabopt
4670@item -Wuse-after-free=1
4671At level 1 the warning attempts to diagnose only unconditional uses
4672of pointers made indeterminate by a deallocation call or a successful
4673call to @code{realloc}, regardless of whether or not the call resulted
4674in an actual reallocatio of memory. This includes double-@code{free}
4675calls as well as uses in arithmetic and relational expressions. Although
4676undefined, uses of indeterminate pointers in equality (or inequality)
4677expressions are not diagnosed at this level.
4678@item -Wuse-after-free=2
4679At level 2, in addition to unconditional uses, the warning also diagnoses
4680conditional uses of pointers made indeterminate by a deallocation call.
4681As at level 2, uses in equality (or inequality) expressions are not
4682diagnosed. For example, the second call to @code{free} in the following
4683function is diagnosed at this level:
4684@smallexample
4685struct A @{ int refcount; void *data; @};
4686
4687void release (struct A *p)
4688@{
4689 int refcount = --p->refcount;
4690 free (p);
4691 if (refcount == 0)
4692 free (p->data); // warning: p may be used after free
4693@}
4694@end smallexample
4695@item -Wuse-after-free=3
4696At level 3, the warning also diagnoses uses of indeterminate pointers in
4697equality expressions. All uses of indeterminate pointers are undefined
4698but equality tests sometimes appear after calls to @code{realloc} as
4699an attempt to determine whether the call resulted in relocating the object
4700to a different address. They are diagnosed at a separate level to aid
4701legacy code gradually transition to safe alternatives. For example,
4702the equality test in the function below is diagnosed at this level:
4703@smallexample
4704void adjust_pointers (int**, int);
4705
4706void grow (int **p, int n)
4707@{
4708 int **q = (int**)realloc (p, n *= 2);
4709 if (q == p)
4710 return;
4711 adjust_pointers ((int**)q, n);
4712@}
4713@end smallexample
4714To avoid the warning at this level, store offsets into allocated memory
4715instead of pointers. This approach obviates needing to adjust the stored
4716pointers after reallocation.
4717@end table
4718
4719@option{-Wuse-after-free=2} is included in @option{-Wall}.
4720
4721@item -Wuseless-cast @r{(C++ and Objective-C++ only)}
4722@opindex Wuseless-cast
4723@opindex Wno-useless-cast
4724Warn when an expression is cast to its own type. This warning does not
4725occur when a class object is converted to a non-reference type as that
4726is a way to create a temporary:
4727
4728@smallexample
4729struct S @{ @};
4730void g (S&&);
4731void f (S&& arg)
4732@{
4733 g (S(arg)); // make arg prvalue so that it can bind to S&&
4734@}
4735@end smallexample
4736
4737@item -Wno-conversion-null @r{(C++ and Objective-C++ only)}
4738@opindex Wconversion-null
4739@opindex Wno-conversion-null
4740Do not warn for conversions between @code{NULL} and non-pointer
4741types. @option{-Wconversion-null} is enabled by default.
4742
4743@end table
4744
4745@node Objective-C and Objective-C++ Dialect Options
4746@section Options Controlling Objective-C and Objective-C++ Dialects
4747
4748@cindex compiler options, Objective-C and Objective-C++
4749@cindex Objective-C and Objective-C++ options, command-line
4750@cindex options, Objective-C and Objective-C++
4751(NOTE: This manual does not describe the Objective-C and Objective-C++
4752languages themselves. @xref{Standards,,Language Standards
4753Supported by GCC}, for references.)
4754
4755This section describes the command-line options that are only meaningful
4756for Objective-C and Objective-C++ programs. You can also use most of
4757the language-independent GNU compiler options.
4758For example, you might compile a file @file{some_class.m} like this:
4759
4760@smallexample
4761gcc -g -fgnu-runtime -O -c some_class.m
4762@end smallexample
4763
4764@noindent
4765In this example, @option{-fgnu-runtime} is an option meant only for
4766Objective-C and Objective-C++ programs; you can use the other options with
4767any language supported by GCC@.
4768
4769Note that since Objective-C is an extension of the C language, Objective-C
4770compilations may also use options specific to the C front-end (e.g.,
4771@option{-Wtraditional}). Similarly, Objective-C++ compilations may use
4772C++-specific options (e.g., @option{-Wabi}).
4773
4774Here is a list of options that are @emph{only} for compiling Objective-C
4775and Objective-C++ programs:
4776
4777@table @gcctabopt
4778@item -fconstant-string-class=@var{class-name}
4779@opindex fconstant-string-class
4780Use @var{class-name} as the name of the class to instantiate for each
4781literal string specified with the syntax @code{@@"@dots{}"}. The default
4782class name is @code{NXConstantString} if the GNU runtime is being used, and
4783@code{NSConstantString} if the NeXT runtime is being used (see below). The
4784@option{-fconstant-cfstrings} option, if also present, overrides the
4785@option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
4786to be laid out as constant CoreFoundation strings.
4787
4788@item -fgnu-runtime
4789@opindex fgnu-runtime
4790Generate object code compatible with the standard GNU Objective-C
4791runtime. This is the default for most types of systems.
4792
4793@item -fnext-runtime
4794@opindex fnext-runtime
4795Generate output compatible with the NeXT runtime. This is the default
4796for NeXT-based systems, including Darwin and Mac OS X@. The macro
4797@code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
4798used.
4799
4800@item -fno-nil-receivers
4801@opindex fno-nil-receivers
4802@opindex fnil-receivers
4803Assume that all Objective-C message dispatches (@code{[receiver
4804message:arg]}) in this translation unit ensure that the receiver is
4805not @code{nil}. This allows for more efficient entry points in the
4806runtime to be used. This option is only available in conjunction with
4807the NeXT runtime and ABI version 0 or 1.
4808
4809@item -fobjc-abi-version=@var{n}
4810@opindex fobjc-abi-version
4811Use version @var{n} of the Objective-C ABI for the selected runtime.
4812This option is currently supported only for the NeXT runtime. In that
4813case, Version 0 is the traditional (32-bit) ABI without support for
4814properties and other Objective-C 2.0 additions. Version 1 is the
4815traditional (32-bit) ABI with support for properties and other
4816Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
4817nothing is specified, the default is Version 0 on 32-bit target
4818machines, and Version 2 on 64-bit target machines.
4819
4820@item -fobjc-call-cxx-cdtors
4821@opindex fobjc-call-cxx-cdtors
4822For each Objective-C class, check if any of its instance variables is a
4823C++ object with a non-trivial default constructor. If so, synthesize a
4824special @code{- (id) .cxx_construct} instance method which runs
4825non-trivial default constructors on any such instance variables, in order,
4826and then return @code{self}. Similarly, check if any instance variable
4827is a C++ object with a non-trivial destructor, and if so, synthesize a
4828special @code{- (void) .cxx_destruct} method which runs
4829all such default destructors, in reverse order.
4830
4831The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct}
4832methods thusly generated only operate on instance variables
4833declared in the current Objective-C class, and not those inherited
4834from superclasses. It is the responsibility of the Objective-C
4835runtime to invoke all such methods in an object's inheritance
4836hierarchy. The @code{- (id) .cxx_construct} methods are invoked
4837by the runtime immediately after a new object instance is allocated;
4838the @code{- (void) .cxx_destruct} methods are invoked immediately
4839before the runtime deallocates an object instance.
4840
4841As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
4842support for invoking the @code{- (id) .cxx_construct} and
4843@code{- (void) .cxx_destruct} methods.
4844
4845@item -fobjc-direct-dispatch
4846@opindex fobjc-direct-dispatch
4847Allow fast jumps to the message dispatcher. On Darwin this is
4848accomplished via the comm page.
4849
4850@item -fobjc-exceptions
4851@opindex fobjc-exceptions
4852Enable syntactic support for structured exception handling in
4853Objective-C, similar to what is offered by C++. This option
4854is required to use the Objective-C keywords @code{@@try},
4855@code{@@throw}, @code{@@catch}, @code{@@finally} and
4856@code{@@synchronized}. This option is available with both the GNU
4857runtime and the NeXT runtime (but not available in conjunction with
4858the NeXT runtime on Mac OS X 10.2 and earlier).
4859
4860@item -fobjc-gc
4861@opindex fobjc-gc
4862Enable garbage collection (GC) in Objective-C and Objective-C++
4863programs. This option is only available with the NeXT runtime; the
4864GNU runtime has a different garbage collection implementation that
4865does not require special compiler flags.
4866
4867@item -fobjc-nilcheck
4868@opindex fobjc-nilcheck
4869For the NeXT runtime with version 2 of the ABI, check for a nil
4870receiver in method invocations before doing the actual method call.
4871This is the default and can be disabled using
4872@option{-fno-objc-nilcheck}. Class methods and super calls are never
4873checked for nil in this way no matter what this flag is set to.
4874Currently this flag does nothing when the GNU runtime, or an older
4875version of the NeXT runtime ABI, is used.
4876
4877@item -fobjc-std=objc1
4878@opindex fobjc-std
4879Conform to the language syntax of Objective-C 1.0, the language
4880recognized by GCC 4.0. This only affects the Objective-C additions to
4881the C/C++ language; it does not affect conformance to C/C++ standards,
4882which is controlled by the separate C/C++ dialect option flags. When
4883this option is used with the Objective-C or Objective-C++ compiler,
4884any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
4885This is useful if you need to make sure that your Objective-C code can
4886be compiled with older versions of GCC@.
4887
4888@item -freplace-objc-classes
4889@opindex freplace-objc-classes
4890Emit a special marker instructing @command{ld(1)} not to statically link in
4891the resulting object file, and allow @command{dyld(1)} to load it in at
4892run time instead. This is used in conjunction with the Fix-and-Continue
4893debugging mode, where the object file in question may be recompiled and
4894dynamically reloaded in the course of program execution, without the need
4895to restart the program itself. Currently, Fix-and-Continue functionality
4896is only available in conjunction with the NeXT runtime on Mac OS X 10.3
4897and later.
4898
4899@item -fzero-link
4900@opindex fzero-link
4901When compiling for the NeXT runtime, the compiler ordinarily replaces calls
4902to @code{objc_getClass("@dots{}")} (when the name of the class is known at
4903compile time) with static class references that get initialized at load time,
4904which improves run-time performance. Specifying the @option{-fzero-link} flag
4905suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
4906to be retained. This is useful in Zero-Link debugging mode, since it allows
4907for individual class implementations to be modified during program execution.
4908The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")}
4909regardless of command-line options.
4910
4911@item -fno-local-ivars
4912@opindex fno-local-ivars
4913@opindex flocal-ivars
4914By default instance variables in Objective-C can be accessed as if
4915they were local variables from within the methods of the class they're
4916declared in. This can lead to shadowing between instance variables
4917and other variables declared either locally inside a class method or
4918globally with the same name. Specifying the @option{-fno-local-ivars}
4919flag disables this behavior thus avoiding variable shadowing issues.
4920
4921@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
4922@opindex fivar-visibility
4923Set the default instance variable visibility to the specified option
4924so that instance variables declared outside the scope of any access
4925modifier directives default to the specified visibility.
4926
4927@item -gen-decls
4928@opindex gen-decls
4929Dump interface declarations for all classes seen in the source file to a
4930file named @file{@var{sourcename}.decl}.
4931
4932@item -Wassign-intercept @r{(Objective-C and Objective-C++ only)}
4933@opindex Wassign-intercept
4934@opindex Wno-assign-intercept
4935Warn whenever an Objective-C assignment is being intercepted by the
4936garbage collector.
4937
4938@item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)}
4939@opindex Wproperty-assign-default
4940@opindex Wno-property-assign-default
4941Do not warn if a property for an Objective-C object has no assign
4942semantics specified.
4943
4944@item -Wno-protocol @r{(Objective-C and Objective-C++ only)}
4945@opindex Wno-protocol
4946@opindex Wprotocol
4947If a class is declared to implement a protocol, a warning is issued for
4948every method in the protocol that is not implemented by the class. The
4949default behavior is to issue a warning for every method not explicitly
4950implemented in the class, even if a method implementation is inherited
4951from the superclass. If you use the @option{-Wno-protocol} option, then
4952methods inherited from the superclass are considered to be implemented,
4953and no warning is issued for them.
4954
4955@item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)}
4956@opindex Wobjc-root-class
4957Warn if a class interface lacks a superclass. Most classes will inherit
4958from @code{NSObject} (or @code{Object}) for example. When declaring
4959classes intended to be root classes, the warning can be suppressed by
4960marking their interfaces with @code{__attribute__((objc_root_class))}.
4961
4962@item -Wselector @r{(Objective-C and Objective-C++ only)}
4963@opindex Wselector
4964@opindex Wno-selector
4965Warn if multiple methods of different types for the same selector are
4966found during compilation. The check is performed on the list of methods
4967in the final stage of compilation. Additionally, a check is performed
4968for each selector appearing in a @code{@@selector(@dots{})}
4969expression, and a corresponding method for that selector has been found
4970during compilation. Because these checks scan the method table only at
4971the end of compilation, these warnings are not produced if the final
4972stage of compilation is not reached, for example because an error is
4973found during compilation, or because the @option{-fsyntax-only} option is
4974being used.
4975
4976@item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)}
4977@opindex Wstrict-selector-match
4978@opindex Wno-strict-selector-match
4979Warn if multiple methods with differing argument and/or return types are
4980found for a given selector when attempting to send a message using this
4981selector to a receiver of type @code{id} or @code{Class}. When this flag
4982is off (which is the default behavior), the compiler omits such warnings
4983if any differences found are confined to types that share the same size
4984and alignment.
4985
4986@item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)}
4987@opindex Wundeclared-selector
4988@opindex Wno-undeclared-selector
4989Warn if a @code{@@selector(@dots{})} expression referring to an
4990undeclared selector is found. A selector is considered undeclared if no
4991method with that name has been declared before the
4992@code{@@selector(@dots{})} expression, either explicitly in an
4993@code{@@interface} or @code{@@protocol} declaration, or implicitly in
4994an @code{@@implementation} section. This option always performs its
4995checks as soon as a @code{@@selector(@dots{})} expression is found,
4996while @option{-Wselector} only performs its checks in the final stage of
4997compilation. This also enforces the coding style convention
4998that methods and selectors must be declared before being used.
4999
5000@item -print-objc-runtime-info
5001@opindex print-objc-runtime-info
5002Generate C header describing the largest structure that is passed by
5003value, if any.
5004
5005@end table
5006
5007@node Diagnostic Message Formatting Options
5008@section Options to Control Diagnostic Messages Formatting
5009@cindex options to control diagnostics formatting
5010@cindex diagnostic messages
5011@cindex message formatting
5012
5013Traditionally, diagnostic messages have been formatted irrespective of
5014the output device's aspect (e.g.@: its width, @dots{}). You can use the
5015options described below
5016to control the formatting algorithm for diagnostic messages,
5017e.g.@: how many characters per line, how often source location
5018information should be reported. Note that some language front ends may not
5019honor these options.
5020
5021@table @gcctabopt
5022@item -fmessage-length=@var{n}
5023@opindex fmessage-length
5024Try to format error messages so that they fit on lines of about
5025@var{n} characters. If @var{n} is zero, then no line-wrapping is
5026done; each error message appears on a single line. This is the
5027default for all front ends.
5028
5029Note - this option also affects the display of the @samp{#error} and
5030@samp{#warning} pre-processor directives, and the @samp{deprecated}
5031function/type/variable attribute. It does not however affect the
5032@samp{pragma GCC warning} and @samp{pragma GCC error} pragmas.
5033
5034@item -fdiagnostics-plain-output
5035This option requests that diagnostic output look as plain as possible, which
5036may be useful when running @command{dejagnu} or other utilities that need to
5037parse diagnostics output and prefer that it remain more stable over time.
5038@option{-fdiagnostics-plain-output} is currently equivalent to the following
5039options:
5040@gccoptlist{-fno-diagnostics-show-caret @gol
5041-fno-diagnostics-show-line-numbers @gol
5042-fdiagnostics-color=never @gol
5043-fdiagnostics-urls=never @gol
5044-fdiagnostics-path-format=separate-events}
5045In the future, if GCC changes the default appearance of its diagnostics, the
5046corresponding option to disable the new behavior will be added to this list.
5047
5048@item -fdiagnostics-show-location=once
5049@opindex fdiagnostics-show-location
5050Only meaningful in line-wrapping mode. Instructs the diagnostic messages
5051reporter to emit source location information @emph{once}; that is, in
5052case the message is too long to fit on a single physical line and has to
5053be wrapped, the source location won't be emitted (as prefix) again,
5054over and over, in subsequent continuation lines. This is the default
5055behavior.
5056
5057@item -fdiagnostics-show-location=every-line
5058Only meaningful in line-wrapping mode. Instructs the diagnostic
5059messages reporter to emit the same source location information (as
5060prefix) for physical lines that result from the process of breaking
5061a message which is too long to fit on a single line.
5062
5063@item -fdiagnostics-color[=@var{WHEN}]
5064@itemx -fno-diagnostics-color
5065@opindex fdiagnostics-color
5066@cindex highlight, color
5067@vindex GCC_COLORS @r{environment variable}
5068Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always},
5069or @samp{auto}. The default depends on how the compiler has been configured,
5070it can be any of the above @var{WHEN} options or also @samp{never}
5071if @env{GCC_COLORS} environment variable isn't present in the environment,
5072and @samp{auto} otherwise.
5073@samp{auto} makes GCC use color only when the standard error is a terminal,
5074and when not executing in an emacs shell.
5075The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are
5076aliases for @option{-fdiagnostics-color=always} and
5077@option{-fdiagnostics-color=never}, respectively.
5078
5079The colors are defined by the environment variable @env{GCC_COLORS}.
5080Its value is a colon-separated list of capabilities and Select Graphic
5081Rendition (SGR) substrings. SGR commands are interpreted by the
5082terminal or terminal emulator. (See the section in the documentation
5083of your text terminal for permitted values and their meanings as
5084character attributes.) These substring values are integers in decimal
5085representation and can be concatenated with semicolons.
5086Common values to concatenate include
5087@samp{1} for bold,
5088@samp{4} for underline,
5089@samp{5} for blink,
5090@samp{7} for inverse,
5091@samp{39} for default foreground color,
5092@samp{30} to @samp{37} for foreground colors,
5093@samp{90} to @samp{97} for 16-color mode foreground colors,
5094@samp{38;5;0} to @samp{38;5;255}
5095for 88-color and 256-color modes foreground colors,
5096@samp{49} for default background color,
5097@samp{40} to @samp{47} for background colors,
5098@samp{100} to @samp{107} for 16-color mode background colors,
5099and @samp{48;5;0} to @samp{48;5;255}
5100for 88-color and 256-color modes background colors.
5101
5102The default @env{GCC_COLORS} is
5103@smallexample
5104error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\
5105quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\
5106diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\
5107type-diff=01;32:fnname=01;32:targs=35
5108@end smallexample
5109@noindent
5110where @samp{01;31} is bold red, @samp{01;35} is bold magenta,
5111@samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue,
5112@samp{01} is bold, and @samp{31} is red.
5113Setting @env{GCC_COLORS} to the empty string disables colors.
5114Supported capabilities are as follows.
5115
5116@table @code
5117@item error=
5118@vindex error GCC_COLORS @r{capability}
5119SGR substring for error: markers.
5120
5121@item warning=
5122@vindex warning GCC_COLORS @r{capability}
5123SGR substring for warning: markers.
5124
5125@item note=
5126@vindex note GCC_COLORS @r{capability}
5127SGR substring for note: markers.
5128
5129@item path=
5130@vindex path GCC_COLORS @r{capability}
5131SGR substring for colorizing paths of control-flow events as printed
5132via @option{-fdiagnostics-path-format=}, such as the identifiers of
5133individual events and lines indicating interprocedural calls and returns.
5134
5135@item range1=
5136@vindex range1 GCC_COLORS @r{capability}
5137SGR substring for first additional range.
5138
5139@item range2=
5140@vindex range2 GCC_COLORS @r{capability}
5141SGR substring for second additional range.
5142
5143@item locus=
5144@vindex locus GCC_COLORS @r{capability}
5145SGR substring for location information, @samp{file:line} or
5146@samp{file:line:column} etc.
5147
5148@item quote=
5149@vindex quote GCC_COLORS @r{capability}
5150SGR substring for information printed within quotes.
5151
5152@item fnname=
5153@vindex fnname GCC_COLORS @r{capability}
5154SGR substring for names of C++ functions.
5155
5156@item targs=
5157@vindex targs GCC_COLORS @r{capability}
5158SGR substring for C++ function template parameter bindings.
5159
5160@item fixit-insert=
5161@vindex fixit-insert GCC_COLORS @r{capability}
5162SGR substring for fix-it hints suggesting text to
5163be inserted or replaced.
5164
5165@item fixit-delete=
5166@vindex fixit-delete GCC_COLORS @r{capability}
5167SGR substring for fix-it hints suggesting text to
5168be deleted.
5169
5170@item diff-filename=
5171@vindex diff-filename GCC_COLORS @r{capability}
5172SGR substring for filename headers within generated patches.
5173
5174@item diff-hunk=
5175@vindex diff-hunk GCC_COLORS @r{capability}
5176SGR substring for the starts of hunks within generated patches.
5177
5178@item diff-delete=
5179@vindex diff-delete GCC_COLORS @r{capability}
5180SGR substring for deleted lines within generated patches.
5181
5182@item diff-insert=
5183@vindex diff-insert GCC_COLORS @r{capability}
5184SGR substring for inserted lines within generated patches.
5185
5186@item type-diff=
5187@vindex type-diff GCC_COLORS @r{capability}
5188SGR substring for highlighting mismatching types within template
5189arguments in the C++ frontend.
5190@end table
5191
5192@item -fdiagnostics-urls[=@var{WHEN}]
5193@opindex fdiagnostics-urls
5194@cindex urls
5195@vindex GCC_URLS @r{environment variable}
5196@vindex TERM_URLS @r{environment variable}
5197Use escape sequences to embed URLs in diagnostics. For example, when
5198@option{-fdiagnostics-show-option} emits text showing the command-line
5199option controlling a diagnostic, embed a URL for documentation of that
5200option.
5201
5202@var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}.
5203@samp{auto} makes GCC use URL escape sequences only when the standard error
5204is a terminal, and when not executing in an emacs shell or any graphical
5205terminal which is known to be incompatible with this feature, see below.
5206
5207The default depends on how the compiler has been configured.
5208It can be any of the above @var{WHEN} options.
5209
5210GCC can also be configured (via the
5211@option{--with-diagnostics-urls=auto-if-env} configure-time option)
5212so that the default is affected by environment variables.
5213Under such a configuration, GCC defaults to using @samp{auto}
5214if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are
5215present and non-empty in the environment of the compiler, or @samp{never}
5216if neither are.
5217
5218However, even with @option{-fdiagnostics-urls=always} the behavior is
5219dependent on those environment variables:
5220If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in
5221diagnostics. If set to @samp{st}, URLs use ST escape sequences.
5222If set to @samp{bel}, the default, URLs use BEL escape sequences.
5223Any other non-empty value enables the feature.
5224If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback.
5225Note: ST is an ANSI escape sequence, string terminator @samp{ESC \},
5226BEL is an ASCII character, CTRL-G that usually sounds like a beep.
5227
5228At this time GCC tries to detect also a few terminals that are known to
5229not implement the URL feature, and have bugs or at least had bugs in
5230some versions that are still in use, where the URL escapes are likely
5231to misbehave, i.e. print garbage on the screen.
5232That list is currently xfce4-terminal, certain known to be buggy
5233gnome-terminal versions, the linux console, and mingw.
5234This check can be skipped with the @option{-fdiagnostics-urls=always}.
5235
5236@item -fno-diagnostics-show-option
5237@opindex fno-diagnostics-show-option
5238@opindex fdiagnostics-show-option
5239By default, each diagnostic emitted includes text indicating the
5240command-line option that directly controls the diagnostic (if such an
5241option is known to the diagnostic machinery). Specifying the
5242@option{-fno-diagnostics-show-option} flag suppresses that behavior.
5243
5244@item -fno-diagnostics-show-caret
5245@opindex fno-diagnostics-show-caret
5246@opindex fdiagnostics-show-caret
5247By default, each diagnostic emitted includes the original source line
5248and a caret @samp{^} indicating the column. This option suppresses this
5249information. The source line is truncated to @var{n} characters, if
5250the @option{-fmessage-length=n} option is given. When the output is done
5251to the terminal, the width is limited to the width given by the
5252@env{COLUMNS} environment variable or, if not set, to the terminal width.
5253
5254@item -fno-diagnostics-show-labels
5255@opindex fno-diagnostics-show-labels
5256@opindex fdiagnostics-show-labels
5257By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5258diagnostics can label ranges of source code with pertinent information, such
5259as the types of expressions:
5260
5261@smallexample
5262 printf ("foo %s bar", long_i + long_j);
5263 ~^ ~~~~~~~~~~~~~~~
5264 | |
5265 char * long int
5266@end smallexample
5267
5268This option suppresses the printing of these labels (in the example above,
5269the vertical bars and the ``char *'' and ``long int'' text).
5270
5271@item -fno-diagnostics-show-cwe
5272@opindex fno-diagnostics-show-cwe
5273@opindex fdiagnostics-show-cwe
5274Diagnostic messages can optionally have an associated
5275@uref{https://cwe.mitre.org/index.html, CWE} identifier.
5276GCC itself only provides such metadata for some of the @option{-fanalyzer}
5277diagnostics. GCC plugins may also provide diagnostics with such metadata.
5278By default, if this information is present, it will be printed with
5279the diagnostic. This option suppresses the printing of this metadata.
5280
5281@item -fno-diagnostics-show-rules
5282@opindex fno-diagnostics-show-rules
5283@opindex fdiagnostics-show-rules
5284Diagnostic messages can optionally have rules associated with them, such
5285as from a coding standard, or a specification.
5286GCC itself does not do this for any of its diagnostics, but plugins may do so.
5287By default, if this information is present, it will be printed with
5288the diagnostic. This option suppresses the printing of this metadata.
5289
5290@item -fno-diagnostics-show-line-numbers
5291@opindex fno-diagnostics-show-line-numbers
5292@opindex fdiagnostics-show-line-numbers
5293By default, when printing source code (via @option{-fdiagnostics-show-caret}),
5294a left margin is printed, showing line numbers. This option suppresses this
5295left margin.
5296
5297@item -fdiagnostics-minimum-margin-width=@var{width}
5298@opindex fdiagnostics-minimum-margin-width
5299This option controls the minimum width of the left margin printed by
5300@option{-fdiagnostics-show-line-numbers}. It defaults to 6.
5301
5302@item -fdiagnostics-parseable-fixits
5303@opindex fdiagnostics-parseable-fixits
5304Emit fix-it hints in a machine-parseable format, suitable for consumption
5305by IDEs. For each fix-it, a line will be printed after the relevant
5306diagnostic, starting with the string ``fix-it:''. For example:
5307
5308@smallexample
5309fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all"
5310@end smallexample
5311
5312The location is expressed as a half-open range, expressed as a count of
5313bytes, starting at byte 1 for the initial column. In the above example,
5314bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the
5315given string:
5316
5317@smallexample
531800000000011111111112222222222
531912345678901234567890123456789
5320 gtk_widget_showall (dlg);
5321 ^^^^^^^^^^^^^^^^^^
5322 gtk_widget_show_all
5323@end smallexample
5324
5325The filename and replacement string escape backslash as ``\\", tab as ``\t'',
5326newline as ``\n'', double quotes as ``\"'', non-printable characters as octal
5327(e.g. vertical tab as ``\013'').
5328
5329An empty replacement string indicates that the given range is to be removed.
5330An empty range (e.g. ``45:3-45:3'') indicates that the string is to
5331be inserted at the given position.
5332
5333@item -fdiagnostics-generate-patch
5334@opindex fdiagnostics-generate-patch
5335Print fix-it hints to stderr in unified diff format, after any diagnostics
5336are printed. For example:
5337
5338@smallexample
5339--- test.c
5340+++ test.c
5341@@ -42,5 +42,5 @@
5342
5343 void show_cb(GtkDialog *dlg)
5344 @{
5345- gtk_widget_showall(dlg);
5346+ gtk_widget_show_all(dlg);
5347 @}
5348
5349@end smallexample
5350
5351The diff may or may not be colorized, following the same rules
5352as for diagnostics (see @option{-fdiagnostics-color}).
5353
5354@item -fdiagnostics-show-template-tree
5355@opindex fdiagnostics-show-template-tree
5356
5357In the C++ frontend, when printing diagnostics showing mismatching
5358template types, such as:
5359
5360@smallexample
5361 could not convert 'std::map<int, std::vector<double> >()'
5362 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5363@end smallexample
5364
5365the @option{-fdiagnostics-show-template-tree} flag enables printing a
5366tree-like structure showing the common and differing parts of the types,
5367such as:
5368
5369@smallexample
5370 map<
5371 [...],
5372 vector<
5373 [double != float]>>
5374@end smallexample
5375
5376The parts that differ are highlighted with color (``double'' and
5377``float'' in this case).
5378
5379@item -fno-elide-type
5380@opindex fno-elide-type
5381@opindex felide-type
5382By default when the C++ frontend prints diagnostics showing mismatching
5383template types, common parts of the types are printed as ``[...]'' to
5384simplify the error message. For example:
5385
5386@smallexample
5387 could not convert 'std::map<int, std::vector<double> >()'
5388 from 'map<[...],vector<double>>' to 'map<[...],vector<float>>
5389@end smallexample
5390
5391Specifying the @option{-fno-elide-type} flag suppresses that behavior.
5392This flag also affects the output of the
5393@option{-fdiagnostics-show-template-tree} flag.
5394
5395@item -fdiagnostics-path-format=@var{KIND}
5396@opindex fdiagnostics-path-format
5397Specify how to print paths of control-flow events for diagnostics that
5398have such a path associated with them.
5399
5400@var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events},
5401the default.
5402
5403@samp{none} means to not print diagnostic paths.
5404
5405@samp{separate-events} means to print a separate ``note'' diagnostic for
5406each event within the diagnostic. For example:
5407
5408@smallexample
5409test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter
5410test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL
5411test.c:27:3: note: (2) when 'i < count'
5412test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5413@end smallexample
5414
5415@samp{inline-events} means to print the events ``inline'' within the source
5416code. This view attempts to consolidate the events into runs of
5417sufficiently-close events, printing them as labelled ranges within the source.
5418
5419For example, the same events as above might be printed as:
5420
5421@smallexample
5422 'test': events 1-3
5423 |
5424 | 25 | list = PyList_New(0);
5425 | | ^~~~~~~~~~~~~
5426 | | |
5427 | | (1) when 'PyList_New' fails, returning NULL
5428 | 26 |
5429 | 27 | for (i = 0; i < count; i++) @{
5430 | | ~~~
5431 | | |
5432 | | (2) when 'i < count'
5433 | 28 | item = PyLong_FromLong(random());
5434 | 29 | PyList_Append(list, item);
5435 | | ~~~~~~~~~~~~~~~~~~~~~~~~~
5436 | | |
5437 | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1
5438 |
5439@end smallexample
5440
5441Interprocedural control flow is shown by grouping the events by stack frame,
5442and using indentation to show how stack frames are nested, pushed, and popped.
5443
5444For example:
5445
5446@smallexample
5447 'test': events 1-2
5448 |
5449 | 133 | @{
5450 | | ^
5451 | | |
5452 | | (1) entering 'test'
5453 | 134 | boxed_int *obj = make_boxed_int (i);
5454 | | ~~~~~~~~~~~~~~~~~~
5455 | | |
5456 | | (2) calling 'make_boxed_int'
5457 |
5458 +--> 'make_boxed_int': events 3-4
5459 |
5460 | 120 | @{
5461 | | ^
5462 | | |
5463 | | (3) entering 'make_boxed_int'
5464 | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
5465 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5466 | | |
5467 | | (4) calling 'wrapped_malloc'
5468 |
5469 +--> 'wrapped_malloc': events 5-6
5470 |
5471 | 7 | @{
5472 | | ^
5473 | | |
5474 | | (5) entering 'wrapped_malloc'
5475 | 8 | return malloc (size);
5476 | | ~~~~~~~~~~~~~
5477 | | |
5478 | | (6) calling 'malloc'
5479 |
5480 <-------------+
5481 |
5482 'test': event 7
5483 |
5484 | 138 | free_boxed_int (obj);
5485 | | ^~~~~~~~~~~~~~~~~~~~
5486 | | |
5487 | | (7) calling 'free_boxed_int'
5488 |
5489(etc)
5490@end smallexample
5491
5492@item -fdiagnostics-show-path-depths
5493@opindex fdiagnostics-show-path-depths
5494This option provides additional information when printing control-flow paths
5495associated with a diagnostic.
5496
5497If this is option is provided then the stack depth will be printed for
5498each run of events within @option{-fdiagnostics-path-format=inline-events}.
5499If provided with @option{-fdiagnostics-path-format=separate-events}, then
5500the stack depth and function declaration will be appended when printing
5501each event.
5502
5503This is intended for use by GCC developers and plugin developers when
5504debugging diagnostics that report interprocedural control flow.
5505
5506@item -fno-show-column
5507@opindex fno-show-column
5508@opindex fshow-column
5509Do not print column numbers in diagnostics. This may be necessary if
5510diagnostics are being scanned by a program that does not understand the
5511column numbers, such as @command{dejagnu}.
5512
5513@item -fdiagnostics-column-unit=@var{UNIT}
5514@opindex fdiagnostics-column-unit
5515Select the units for the column number. This affects traditional diagnostics
5516(in the absence of @option{-fno-show-column}), as well as JSON format
5517diagnostics if requested.
5518
5519The default @var{UNIT}, @samp{display}, considers the number of display
5520columns occupied by each character. This may be larger than the number
5521of bytes required to encode the character, in the case of tab
5522characters, or it may be smaller, in the case of multibyte characters.
5523For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one
5524display column, and its UTF-8 encoding requires two bytes; the character
5525``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and
5526its UTF-8 encoding requires four bytes.
5527
5528Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte
5529count in all cases, as was traditionally output by GCC prior to version 11.1.0.
5530
5531@item -fdiagnostics-column-origin=@var{ORIGIN}
5532@opindex fdiagnostics-column-origin
5533Select the origin for column numbers, i.e. the column number assigned to the
5534first column. The default value of 1 corresponds to traditional GCC
5535behavior and to the GNU style guide. Some utilities may perform better with an
5536origin of 0; any non-negative value may be specified.
5537
5538@item -fdiagnostics-escape-format=@var{FORMAT}
5539@opindex fdiagnostics-escape-format
5540When GCC prints pertinent source lines for a diagnostic it normally attempts
5541to print the source bytes directly. However, some diagnostics relate to encoding
5542issues in the source file, such as malformed UTF-8, or issues with Unicode
5543normalization. These diagnostics are flagged so that GCC will escape bytes
5544that are not printable ASCII when printing their pertinent source lines.
5545
5546This option controls how such bytes should be escaped.
5547
5548The default @var{FORMAT}, @samp{unicode} displays Unicode characters that
5549are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not
5550correspond to a Unicode character validly-encoded in UTF-8-encoded will be
5551displayed as hexadecimal in the form @samp{<XX>}.
5552
5553For example, a source line containing the string @samp{before} followed by the
5554Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding
55550xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by
5556the string @samp{after} will be printed for such a diagnostic as:
5557
5558@smallexample
5559 before<U+03C0><BF>after
5560@end smallexample
5561
5562Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes
5563in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII
5564Unicode characters. For the example above, the following will be printed:
5565
5566@smallexample
5567 before<CF><80><BF>after
5568@end smallexample
5569
5570@item -fdiagnostics-format=@var{FORMAT}
5571@opindex fdiagnostics-format
5572Select a different format for printing diagnostics.
5573@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
5574@samp{json}, @samp{json-stderr}, or @samp{json-file}.
5575
5576The default is @samp{text}.
5577
5578The @samp{sarif-stderr} and @samp{sarif-file} formats both emit
5579diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file
5580named @file{@var{source}.sarif}, respectively.
5581
5582The @samp{json} format is a synonym for @samp{json-stderr}.
5583The @samp{json-stderr} and @samp{json-file} formats are identical, apart from
5584where the JSON is emitted to - with the former, the JSON is emitted to stderr,
5585whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}.
5586
5587The emitted JSON consists of a top-level JSON array containing JSON objects
5588representing the diagnostics. The JSON is emitted as one line, without
5589formatting; the examples below have been formatted for clarity.
5590
5591Diagnostics can have child diagnostics. For example, this error and note:
5592
5593@smallexample
5594misleading-indentation.c:15:3: warning: this 'if' clause does not
5595 guard... [-Wmisleading-indentation]
5596 15 | if (flag)
5597 | ^~
5598misleading-indentation.c:17:5: note: ...this statement, but the latter
5599 is misleadingly indented as if it were guarded by the 'if'
5600 17 | y = 2;
5601 | ^
5602@end smallexample
5603
5604@noindent
5605might be printed in JSON form (after formatting) like this:
5606
5607@smallexample
5608[
5609 @{
5610 "kind": "warning",
5611 "locations": [
5612 @{
5613 "caret": @{
5614 "display-column": 3,
5615 "byte-column": 3,
5616 "column": 3,
5617 "file": "misleading-indentation.c",
5618 "line": 15
5619 @},
5620 "finish": @{
5621 "display-column": 4,
5622 "byte-column": 4,
5623 "column": 4,
5624 "file": "misleading-indentation.c",
5625 "line": 15
5626 @}
5627 @}
5628 ],
5629 "message": "this \u2018if\u2019 clause does not guard...",
5630 "option": "-Wmisleading-indentation",
5631 "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation",
5632 "children": [
5633 @{
5634 "kind": "note",
5635 "locations": [
5636 @{
5637 "caret": @{
5638 "display-column": 5,
5639 "byte-column": 5,
5640 "column": 5,
5641 "file": "misleading-indentation.c",
5642 "line": 17
5643 @}
5644 @}
5645 ],
5646 "escape-source": false,
5647 "message": "...this statement, but the latter is @dots{}"
5648 @}
5649 ]
5650 "escape-source": false,
5651 "column-origin": 1,
5652 @}
5653]
5654@end smallexample
5655
5656@noindent
5657where the @code{note} is a child of the @code{warning}.
5658
5659A diagnostic has a @code{kind}. If this is @code{warning}, then there is
5660an @code{option} key describing the command-line option controlling the
5661warning.
5662
5663A diagnostic can contain zero or more locations. Each location has an
5664optional @code{label} string and up to three positions within it: a
5665@code{caret} position and optional @code{start} and @code{finish} positions.
5666A position is described by a @code{file} name, a @code{line} number, and
5667three numbers indicating a column position:
5668@itemize @bullet
5669
5670@item
5671@code{display-column} counts display columns, accounting for tabs and
5672multibyte characters.
5673
5674@item
5675@code{byte-column} counts raw bytes.
5676
5677@item
5678@code{column} is equal to one of
5679the previous two, as dictated by the @option{-fdiagnostics-column-unit}
5680option.
5681
5682@end itemize
5683All three columns are relative to the origin specified by
5684@option{-fdiagnostics-column-origin}, which is typically equal to 1 but may
5685be set, for instance, to 0 for compatibility with other utilities that
5686number columns from 0. The column origin is recorded in the JSON output in
5687the @code{column-origin} tag. In the remaining examples below, the extra
5688column number outputs have been omitted for brevity.
5689
5690For example, this error:
5691
5692@smallexample
5693bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka
5694 'struct s'@} and 'T' @{aka 'struct t'@})
5695 64 | return callee_4a () + callee_4b ();
5696 | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~
5697 | | |
5698 | | T @{aka struct t@}
5699 | S @{aka struct s@}
5700@end smallexample
5701
5702@noindent
5703has three locations. Its primary location is at the ``+'' token at column
570423. It has two secondary locations, describing the left and right-hand sides
5705of the expression, which have labels. It might be printed in JSON form as:
5706
5707@smallexample
5708 @{
5709 "children": [],
5710 "kind": "error",
5711 "locations": [
5712 @{
5713 "caret": @{
5714 "column": 23, "file": "bad-binary-ops.c", "line": 64
5715 @}
5716 @},
5717 @{
5718 "caret": @{
5719 "column": 10, "file": "bad-binary-ops.c", "line": 64
5720 @},
5721 "finish": @{
5722 "column": 21, "file": "bad-binary-ops.c", "line": 64
5723 @},
5724 "label": "S @{aka struct s@}"
5725 @},
5726 @{
5727 "caret": @{
5728 "column": 25, "file": "bad-binary-ops.c", "line": 64
5729 @},
5730 "finish": @{
5731 "column": 36, "file": "bad-binary-ops.c", "line": 64
5732 @},
5733 "label": "T @{aka struct t@}"
5734 @}
5735 ],
5736 "escape-source": false,
5737 "message": "invalid operands to binary + @dots{}"
5738 @}
5739@end smallexample
5740
5741If a diagnostic contains fix-it hints, it has a @code{fixits} array,
5742consisting of half-open intervals, similar to the output of
5743@option{-fdiagnostics-parseable-fixits}. For example, this diagnostic
5744with a replacement fix-it hint:
5745
5746@smallexample
5747demo.c:8:15: error: 'struct s' has no member named 'colour'; did you
5748 mean 'color'?
5749 8 | return ptr->colour;
5750 | ^~~~~~
5751 | color
5752@end smallexample
5753
5754@noindent
5755might be printed in JSON form as:
5756
5757@smallexample
5758 @{
5759 "children": [],
5760 "fixits": [
5761 @{
5762 "next": @{
5763 "column": 21,
5764 "file": "demo.c",
5765 "line": 8
5766 @},
5767 "start": @{
5768 "column": 15,
5769 "file": "demo.c",
5770 "line": 8
5771 @},
5772 "string": "color"
5773 @}
5774 ],
5775 "kind": "error",
5776 "locations": [
5777 @{
5778 "caret": @{
5779 "column": 15,
5780 "file": "demo.c",
5781 "line": 8
5782 @},
5783 "finish": @{
5784 "column": 20,
5785 "file": "demo.c",
5786 "line": 8
5787 @}
5788 @}
5789 ],
5790 "escape-source": false,
5791 "message": "\u2018struct s\u2019 has no member named @dots{}"
5792 @}
5793@end smallexample
5794
5795@noindent
5796where the fix-it hint suggests replacing the text from @code{start} up
5797to but not including @code{next} with @code{string}'s value. Deletions
5798are expressed via an empty value for @code{string}, insertions by
5799having @code{start} equal @code{next}.
5800
5801If the diagnostic has a path of control-flow events associated with it,
5802it has a @code{path} array of objects representing the events. Each
5803event object has a @code{description} string, a @code{location} object,
5804along with a @code{function} string and a @code{depth} number for
5805representing interprocedural paths. The @code{function} represents the
5806current function at that event, and the @code{depth} represents the
5807stack depth relative to some baseline: the higher, the more frames are
5808within the stack.
5809
5810For example, the intraprocedural example shown for
5811@option{-fdiagnostics-path-format=} might have this JSON for its path:
5812
5813@smallexample
5814 "path": [
5815 @{
5816 "depth": 0,
5817 "description": "when 'PyList_New' fails, returning NULL",
5818 "function": "test",
5819 "location": @{
5820 "column": 10,
5821 "file": "test.c",
5822 "line": 25
5823 @}
5824 @},
5825 @{
5826 "depth": 0,
5827 "description": "when 'i < count'",
5828 "function": "test",
5829 "location": @{
5830 "column": 3,
5831 "file": "test.c",
5832 "line": 27
5833 @}
5834 @},
5835 @{
5836 "depth": 0,
5837 "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1",
5838 "function": "test",
5839 "location": @{
5840 "column": 5,
5841 "file": "test.c",
5842 "line": 29
5843 @}
5844 @}
5845 ]
5846@end smallexample
5847
5848Diagnostics have a boolean attribute @code{escape-source}, hinting whether
5849non-ASCII bytes should be escaped when printing the pertinent lines of
5850source code (@code{true} for diagnostics involving source encoding issues).
5851
5852@end table
5853
5854@node Warning Options
5855@section Options to Request or Suppress Warnings
5856@cindex options to control warnings
5857@cindex warning messages
5858@cindex messages, warning
5859@cindex suppressing warnings
5860
5861Warnings are diagnostic messages that report constructions that
5862are not inherently erroneous but that are risky or suggest there
5863may have been an error.
5864
5865The following language-independent options do not enable specific
5866warnings but control the kinds of diagnostics produced by GCC@.
5867
5868@table @gcctabopt
5869@cindex syntax checking
5870@item -fsyntax-only
5871@opindex fsyntax-only
5872Check the code for syntax errors, but don't do anything beyond that.
5873
5874@item -fmax-errors=@var{n}
5875@opindex fmax-errors
5876Limits the maximum number of error messages to @var{n}, at which point
5877GCC bails out rather than attempting to continue processing the source
5878code. If @var{n} is 0 (the default), there is no limit on the number
5879of error messages produced. If @option{-Wfatal-errors} is also
5880specified, then @option{-Wfatal-errors} takes precedence over this
5881option.
5882
5883@item -w
5884@opindex w
5885Inhibit all warning messages.
5886
5887@item -Werror
5888@opindex Werror
5889@opindex Wno-error
5890Make all warnings into errors.
5891
5892@item -Werror=
5893@opindex Werror=
5894@opindex Wno-error=
5895Make the specified warning into an error. The specifier for a warning
5896is appended; for example @option{-Werror=switch} turns the warnings
5897controlled by @option{-Wswitch} into errors. This switch takes a
5898negative form, to be used to negate @option{-Werror} for specific
5899warnings; for example @option{-Wno-error=switch} makes
5900@option{-Wswitch} warnings not be errors, even when @option{-Werror}
5901is in effect.
5902
5903The warning message for each controllable warning includes the
5904option that controls the warning. That option can then be used with
5905@option{-Werror=} and @option{-Wno-error=} as described above.
5906(Printing of the option in the warning message can be disabled using the
5907@option{-fno-diagnostics-show-option} flag.)
5908
5909Note that specifying @option{-Werror=}@var{foo} automatically implies
5910@option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not
5911imply anything.
5912
5913@item -Wfatal-errors
5914@opindex Wfatal-errors
5915@opindex Wno-fatal-errors
5916This option causes the compiler to abort compilation on the first error
5917occurred rather than trying to keep going and printing further error
5918messages.
5919
5920@end table
5921
5922You can request many specific warnings with options beginning with
5923@samp{-W}, for example @option{-Wimplicit} to request warnings on
5924implicit declarations. Each of these specific warning options also
5925has a negative form beginning @samp{-Wno-} to turn off warnings; for
5926example, @option{-Wno-implicit}. This manual lists only one of the
5927two forms, whichever is not the default. For further
5928language-specific options also refer to @ref{C++ Dialect Options} and
5929@ref{Objective-C and Objective-C++ Dialect Options}.
5930Additional warnings can be produced by enabling the static analyzer;
5931@xref{Static Analyzer Options}.
5932
5933Some options, such as @option{-Wall} and @option{-Wextra}, turn on other
5934options, such as @option{-Wunused}, which may turn on further options,
5935such as @option{-Wunused-value}. The combined effect of positive and
5936negative forms is that more specific options have priority over less
5937specific ones, independently of their position in the command-line. For
5938options of the same specificity, the last one takes effect. Options
5939enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect
5940as if they appeared at the end of the command-line.
5941
5942When an unrecognized warning option is requested (e.g.,
5943@option{-Wunknown-warning}), GCC emits a diagnostic stating
5944that the option is not recognized. However, if the @option{-Wno-} form
5945is used, the behavior is slightly different: no diagnostic is
5946produced for @option{-Wno-unknown-warning} unless other diagnostics
5947are being produced. This allows the use of new @option{-Wno-} options
5948with old compilers, but if something goes wrong, the compiler
5949warns that an unrecognized option is present.
5950
5951The effectiveness of some warnings depends on optimizations also being
5952enabled. For example @option{-Wsuggest-final-types} is more effective
5953with link-time optimization and some instances of other warnings may
5954not be issued at all unless optimization is enabled. While optimization
5955in general improves the efficacy of control and data flow sensitive
5956warnings, in some cases it may also cause false positives.
5957
5958@table @gcctabopt
5959@item -Wpedantic
5960@itemx -pedantic
5961@opindex pedantic
5962@opindex Wpedantic
5963@opindex Wno-pedantic
5964Issue all the warnings demanded by strict ISO C and ISO C++;
5965reject all programs that use forbidden extensions, and some other
5966programs that do not follow ISO C and ISO C++. For ISO C, follows the
5967version of the ISO C standard specified by any @option{-std} option used.
5968
5969Valid ISO C and ISO C++ programs should compile properly with or without
5970this option (though a rare few require @option{-ansi} or a
5971@option{-std} option specifying the required version of ISO C)@. However,
5972without this option, certain GNU extensions and traditional C and C++
5973features are supported as well. With this option, they are rejected.
5974
5975@option{-Wpedantic} does not cause warning messages for use of the
5976alternate keywords whose names begin and end with @samp{__}. This alternate
5977format can also be used to disable warnings for non-ISO @samp{__intN} types,
5978i.e. @samp{__intN__}.
5979Pedantic warnings are also disabled in the expression that follows
5980@code{__extension__}. However, only system header files should use
5981these escape routes; application programs should avoid them.
5982@xref{Alternate Keywords}.
5983
5984Some users try to use @option{-Wpedantic} to check programs for strict ISO
5985C conformance. They soon find that it does not do quite what they want:
5986it finds some non-ISO practices, but not all---only those for which
5987ISO C @emph{requires} a diagnostic, and some others for which
5988diagnostics have been added.
5989
5990A feature to report any failure to conform to ISO C might be useful in
5991some instances, but would require considerable additional work and would
5992be quite different from @option{-Wpedantic}. We don't have plans to
5993support such a feature in the near future.
5994
5995Where the standard specified with @option{-std} represents a GNU
5996extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a
5997corresponding @dfn{base standard}, the version of ISO C on which the GNU
5998extended dialect is based. Warnings from @option{-Wpedantic} are given
5999where they are required by the base standard. (It does not make sense
6000for such warnings to be given only for features not in the specified GNU
6001C dialect, since by definition the GNU dialects of C include all
6002features the compiler supports with the given option, and there would be
6003nothing to warn about.)
6004
6005@item -pedantic-errors
6006@opindex pedantic-errors
6007Give an error whenever the @dfn{base standard} (see @option{-Wpedantic})
6008requires a diagnostic, in some cases where there is undefined behavior
6009at compile-time and in some other cases that do not prevent compilation
6010of programs that are valid according to the standard. This is not
6011equivalent to @option{-Werror=pedantic}, since there are errors enabled
6012by this option and not enabled by the latter and vice versa.
6013
6014@item -Wall
6015@opindex Wall
6016@opindex Wno-all
6017This enables all the warnings about constructions that some users
6018consider questionable, and that are easy to avoid (or modify to
6019prevent the warning), even in conjunction with macros. This also
6020enables some language-specific warnings described in @ref{C++ Dialect
6021Options} and @ref{Objective-C and Objective-C++ Dialect Options}.
6022
6023@option{-Wall} turns on the following warning flags:
6024
6025@gccoptlist{-Waddress @gol
6026-Warray-bounds=1 @r{(only with} @option{-O2}@r{)} @gol
6027-Warray-compare @gol
6028-Warray-parameter=2 @r{(C and Objective-C only)} @gol
6029-Wbool-compare @gol
6030-Wbool-operation @gol
6031-Wc++11-compat -Wc++14-compat @gol
6032-Wcatch-value @r{(C++ and Objective-C++ only)} @gol
6033-Wchar-subscripts @gol
6034-Wcomment @gol
6035-Wdangling-pointer=2 @gol
6036-Wduplicate-decl-specifier @r{(C and Objective-C only)} @gol
6037-Wenum-compare @r{(in C/ObjC; this is on by default in C++)} @gol
6038-Wenum-int-mismatch @r{(C and Objective-C only)} @gol
6039-Wformat @gol
6040-Wformat-overflow @gol
6041-Wformat-truncation @gol
6042-Wint-in-bool-context @gol
6043-Wimplicit @r{(C and Objective-C only)} @gol
6044-Wimplicit-int @r{(C and Objective-C only)} @gol
6045-Wimplicit-function-declaration @r{(C and Objective-C only)} @gol
6046-Winit-self @r{(only for C++)} @gol
6047-Wlogical-not-parentheses @gol
6048-Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} @gol
6049-Wmaybe-uninitialized @gol
6050-Wmemset-elt-size @gol
6051-Wmemset-transposed-args @gol
6052-Wmisleading-indentation @r{(only for C/C++)} @gol
6053-Wmismatched-dealloc @gol
6054-Wmismatched-new-delete @r{(only for C/C++)} @gol
6055-Wmissing-attributes @gol
6056-Wmissing-braces @r{(only for C/ObjC)} @gol
6057-Wmultistatement-macros @gol
6058-Wnarrowing @r{(only for C++)} @gol
6059-Wnonnull @gol
6060-Wnonnull-compare @gol
6061-Wopenmp-simd @gol
6062-Wparentheses @gol
6063-Wpessimizing-move @r{(only for C++)} @gol
6064-Wpointer-sign @gol
6065-Wrange-loop-construct @r{(only for C++)} @gol
6066-Wreorder @gol
6067-Wrestrict @gol
6068-Wreturn-type @gol
6069-Wself-move @r{(only for C++)} @gol
6070-Wsequence-point @gol
6071-Wsign-compare @r{(only in C++)} @gol
6072-Wsizeof-array-div @gol
6073-Wsizeof-pointer-div @gol
6074-Wsizeof-pointer-memaccess @gol
6075-Wstrict-aliasing @gol
6076-Wstrict-overflow=1 @gol
6077-Wswitch @gol
6078-Wtautological-compare @gol
6079-Wtrigraphs @gol
6080-Wuninitialized @gol
6081-Wunknown-pragmas @gol
6082-Wunused-function @gol
6083-Wunused-label @gol
6084-Wunused-value @gol
6085-Wunused-variable @gol
6086-Wuse-after-free=3 @gol
6087-Wvla-parameter @r{(C and Objective-C only)} @gol
6088-Wvolatile-register-var @gol
6089-Wzero-length-bounds}
6090
6091Note that some warning flags are not implied by @option{-Wall}. Some of
6092them warn about constructions that users generally do not consider
6093questionable, but which occasionally you might wish to check for;
6094others warn about constructions that are necessary or hard to avoid in
6095some cases, and there is no simple way to modify the code to suppress
6096the warning. Some of them are enabled by @option{-Wextra} but many of
6097them must be enabled individually.
6098
6099@item -Wextra
6100@opindex W
6101@opindex Wextra
6102@opindex Wno-extra
6103This enables some extra warning flags that are not enabled by
6104@option{-Wall}. (This option used to be called @option{-W}. The older
6105name is still supported, but the newer name is more descriptive.)
6106
6107@gccoptlist{-Wclobbered @gol
6108-Wcast-function-type @gol
6109-Wdeprecated-copy @r{(C++ only)} @gol
6110-Wempty-body @gol
6111-Wenum-conversion @r{(C only)} @gol
6112-Wignored-qualifiers @gol
6113-Wimplicit-fallthrough=3 @gol
6114-Wmissing-field-initializers @gol
6115-Wmissing-parameter-type @r{(C only)} @gol
6116-Wold-style-declaration @r{(C only)} @gol
6117-Woverride-init @gol
6118-Wsign-compare @r{(C only)} @gol
6119-Wstring-compare @gol
6120-Wredundant-move @r{(only for C++)} @gol
6121-Wtype-limits @gol
6122-Wuninitialized @gol
6123-Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} @gol
6124-Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} @gol
6125-Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}}
6126
6127
6128The option @option{-Wextra} also prints warning messages for the
6129following cases:
6130
6131@itemize @bullet
6132
6133@item
6134A pointer is compared against integer zero with @code{<}, @code{<=},
6135@code{>}, or @code{>=}.
6136
6137@item
6138(C++ only) An enumerator and a non-enumerator both appear in a
6139conditional expression.
6140
6141@item
6142(C++ only) Ambiguous virtual bases.
6143
6144@item
6145(C++ only) Subscripting an array that has been declared @code{register}.
6146
6147@item
6148(C++ only) Taking the address of a variable that has been declared
6149@code{register}.
6150
6151@item
6152(C++ only) A base class is not initialized in the copy constructor
6153of a derived class.
6154
6155@end itemize
6156
6157@item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)}
6158@opindex Wabi
6159@opindex Wno-abi
6160
6161Warn about code affected by ABI changes. This includes code that may
6162not be compatible with the vendor-neutral C++ ABI as well as the psABI
6163for the particular target.
6164
6165Since G++ now defaults to updating the ABI with each major release,
6166normally @option{-Wabi} warns only about C++ ABI compatibility
6167problems if there is a check added later in a release series for an
6168ABI issue discovered since the initial release. @option{-Wabi} warns
6169about more things if an older ABI version is selected (with
6170@option{-fabi-version=@var{n}}).
6171
6172@option{-Wabi} can also be used with an explicit version number to
6173warn about C++ ABI compatibility with a particular @option{-fabi-version}
6174level, e.g.@: @option{-Wabi=2} to warn about changes relative to
6175@option{-fabi-version=2}.
6176
6177If an explicit version number is provided and
6178@option{-fabi-compat-version} is not specified, the version number
6179from this option is used for compatibility aliases. If no explicit
6180version number is provided with this option, but
6181@option{-fabi-compat-version} is specified, that version number is
6182used for C++ ABI warnings.
6183
6184Although an effort has been made to warn about
6185all such cases, there are probably some cases that are not warned about,
6186even though G++ is generating incompatible code. There may also be
6187cases where warnings are emitted even though the code that is generated
6188is compatible.
6189
6190You should rewrite your code to avoid these warnings if you are
6191concerned about the fact that code generated by G++ may not be binary
6192compatible with code generated by other compilers.
6193
6194Known incompatibilities in @option{-fabi-version=2} (which was the
6195default from GCC 3.4 to 4.9) include:
6196
6197@itemize @bullet
6198
6199@item
6200A template with a non-type template parameter of reference type was
6201mangled incorrectly:
6202@smallexample
6203extern int N;
6204template <int &> struct S @{@};
6205void n (S<N>) @{2@}
6206@end smallexample
6207
6208This was fixed in @option{-fabi-version=3}.
6209
6210@item
6211SIMD vector types declared using @code{__attribute ((vector_size))} were
6212mangled in a non-standard way that does not allow for overloading of
6213functions taking vectors of different sizes.
6214
6215The mangling was changed in @option{-fabi-version=4}.
6216
6217@item
6218@code{__attribute ((const))} and @code{noreturn} were mangled as type
6219qualifiers, and @code{decltype} of a plain declaration was folded away.
6220
6221These mangling issues were fixed in @option{-fabi-version=5}.
6222
6223@item
6224Scoped enumerators passed as arguments to a variadic function are
6225promoted like unscoped enumerators, causing @code{va_arg} to complain.
6226On most targets this does not actually affect the parameter passing
6227ABI, as there is no way to pass an argument smaller than @code{int}.
6228
6229Also, the ABI changed the mangling of template argument packs,
6230@code{const_cast}, @code{static_cast}, prefix increment/decrement, and
6231a class scope function used as a template argument.
6232
6233These issues were corrected in @option{-fabi-version=6}.
6234
6235@item
6236Lambdas in default argument scope were mangled incorrectly, and the
6237ABI changed the mangling of @code{nullptr_t}.
6238
6239These issues were corrected in @option{-fabi-version=7}.
6240
6241@item
6242When mangling a function type with function-cv-qualifiers, the
6243un-qualified function type was incorrectly treated as a substitution
6244candidate.
6245
6246This was fixed in @option{-fabi-version=8}, the default for GCC 5.1.
6247
6248@item
6249@code{decltype(nullptr)} incorrectly had an alignment of 1, leading to
6250unaligned accesses. Note that this did not affect the ABI of a
6251function with a @code{nullptr_t} parameter, as parameters have a
6252minimum alignment.
6253
6254This was fixed in @option{-fabi-version=9}, the default for GCC 5.2.
6255
6256@item
6257Target-specific attributes that affect the identity of a type, such as
6258ia32 calling conventions on a function type (stdcall, regparm, etc.),
6259did not affect the mangled name, leading to name collisions when
6260function pointers were used as template arguments.
6261
6262This was fixed in @option{-fabi-version=10}, the default for GCC 6.1.
6263
6264@end itemize
6265
6266This option also enables warnings about psABI-related changes.
6267The known psABI changes at this point include:
6268
6269@itemize @bullet
6270
6271@item
6272For SysV/x86-64, unions with @code{long double} members are
6273passed in memory as specified in psABI. Prior to GCC 4.4, this was not
6274the case. For example:
6275
6276@smallexample
6277union U @{
6278 long double ld;
6279 int i;
6280@};
6281@end smallexample
6282
6283@noindent
6284@code{union U} is now always passed in memory.
6285
6286@end itemize
6287
6288@item -Wchar-subscripts
6289@opindex Wchar-subscripts
6290@opindex Wno-char-subscripts
6291Warn if an array subscript has type @code{char}. This is a common cause
6292of error, as programmers often forget that this type is signed on some
6293machines.
6294This warning is enabled by @option{-Wall}.
6295
6296@item -Wno-coverage-mismatch
6297@opindex Wno-coverage-mismatch
6298@opindex Wcoverage-mismatch
6299Warn if feedback profiles do not match when using the
6300@option{-fprofile-use} option.
6301If a source file is changed between compiling with @option{-fprofile-generate}
6302and with @option{-fprofile-use}, the files with the profile feedback can fail
6303to match the source file and GCC cannot use the profile feedback
6304information. By default, this warning is enabled and is treated as an
6305error. @option{-Wno-coverage-mismatch} can be used to disable the
6306warning or @option{-Wno-error=coverage-mismatch} can be used to
6307disable the error. Disabling the error for this warning can result in
6308poorly optimized code and is useful only in the
6309case of very minor changes such as bug fixes to an existing code-base.
6310Completely disabling the warning is not recommended.
6311
6312@item -Wno-coverage-invalid-line-number
6313@opindex Wno-coverage-invalid-line-number
6314@opindex Wcoverage-invalid-line-number
6315Warn in case a function ends earlier than it begins due
6316to an invalid linenum macros. The warning is emitted only
6317with @option{--coverage} enabled.
6318
6319By default, this warning is enabled and is treated as an
6320error. @option{-Wno-coverage-invalid-line-number} can be used to disable the
6321warning or @option{-Wno-error=coverage-invalid-line-number} can be used to
6322disable the error.
6323
6324@item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)}
6325@opindex Wno-cpp
6326@opindex Wcpp
6327Suppress warning messages emitted by @code{#warning} directives.
6328
6329@item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)}
6330@opindex Wdouble-promotion
6331@opindex Wno-double-promotion
6332Give a warning when a value of type @code{float} is implicitly
6333promoted to @code{double}. CPUs with a 32-bit ``single-precision''
6334floating-point unit implement @code{float} in hardware, but emulate
6335@code{double} in software. On such a machine, doing computations
6336using @code{double} values is much more expensive because of the
6337overhead required for software emulation.
6338
6339It is easy to accidentally do computations with @code{double} because
6340floating-point literals are implicitly of type @code{double}. For
6341example, in:
6342@smallexample
6343@group
6344float area(float radius)
6345@{
6346 return 3.14159 * radius * radius;
6347@}
6348@end group
6349@end smallexample
6350the compiler performs the entire computation with @code{double}
6351because the floating-point literal is a @code{double}.
6352
6353@item -Wduplicate-decl-specifier @r{(C and Objective-C only)}
6354@opindex Wduplicate-decl-specifier
6355@opindex Wno-duplicate-decl-specifier
6356Warn if a declaration has duplicate @code{const}, @code{volatile},
6357@code{restrict} or @code{_Atomic} specifier. This warning is enabled by
6358@option{-Wall}.
6359
6360@item -Wformat
6361@itemx -Wformat=@var{n}
6362@opindex Wformat
6363@opindex Wno-format
6364@opindex ffreestanding
6365@opindex fno-builtin
6366@opindex Wformat=
6367Check calls to @code{printf} and @code{scanf}, etc., to make sure that
6368the arguments supplied have types appropriate to the format string
6369specified, and that the conversions specified in the format string make
6370sense. This includes standard functions, and others specified by format
6371attributes (@pxref{Function Attributes}), in the @code{printf},
6372@code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
6373not in the C standard) families (or other target-specific families).
6374Which functions are checked without format attributes having been
6375specified depends on the standard version selected, and such checks of
6376functions without the attribute specified are disabled by
6377@option{-ffreestanding} or @option{-fno-builtin}.
6378
6379The formats are checked against the format features supported by GNU
6380libc version 2.2. These include all ISO C90 and C99 features, as well
6381as features from the Single Unix Specification and some BSD and GNU
6382extensions. Other library implementations may not support all these
6383features; GCC does not support warning about features that go beyond a
6384particular library's limitations. However, if @option{-Wpedantic} is used
6385with @option{-Wformat}, warnings are given about format features not
6386in the selected standard version (but not for @code{strfmon} formats,
6387since those are not in any version of the C standard). @xref{C Dialect
6388Options,,Options Controlling C Dialect}.
6389
6390@table @gcctabopt
6391@item -Wformat=1
6392@itemx -Wformat
6393@opindex Wformat
6394@opindex Wformat=1
6395Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and
6396@option{-Wno-format} is equivalent to @option{-Wformat=0}. Since
6397@option{-Wformat} also checks for null format arguments for several
6398functions, @option{-Wformat} also implies @option{-Wnonnull}. Some
6399aspects of this level of format checking can be disabled by the
6400options: @option{-Wno-format-contains-nul},
6401@option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}.
6402@option{-Wformat} is enabled by @option{-Wall}.
6403
6404@item -Wformat=2
6405@opindex Wformat=2
6406Enable @option{-Wformat} plus additional format checks. Currently
6407equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security
6408-Wformat-y2k}.
6409@end table
6410
6411@item -Wno-format-contains-nul
6412@opindex Wno-format-contains-nul
6413@opindex Wformat-contains-nul
6414If @option{-Wformat} is specified, do not warn about format strings that
6415contain NUL bytes.
6416
6417@item -Wno-format-extra-args
6418@opindex Wno-format-extra-args
6419@opindex Wformat-extra-args
6420If @option{-Wformat} is specified, do not warn about excess arguments to a
6421@code{printf} or @code{scanf} format function. The C standard specifies
6422that such arguments are ignored.
6423
6424Where the unused arguments lie between used arguments that are
6425specified with @samp{$} operand number specifications, normally
6426warnings are still given, since the implementation could not know what
6427type to pass to @code{va_arg} to skip the unused arguments. However,
6428in the case of @code{scanf} formats, this option suppresses the
6429warning if the unused arguments are all pointers, since the Single
6430Unix Specification says that such unused arguments are allowed.
6431
6432@item -Wformat-overflow
6433@itemx -Wformat-overflow=@var{level}
6434@opindex Wformat-overflow
6435@opindex Wno-format-overflow
6436Warn about calls to formatted input/output functions such as @code{sprintf}
6437and @code{vsprintf} that might overflow the destination buffer. When the
6438exact number of bytes written by a format directive cannot be determined
6439at compile-time it is estimated based on heuristics that depend on the
6440@var{level} argument and on optimization. While enabling optimization
6441will in most cases improve the accuracy of the warning, it may also
6442result in false positives.
6443
6444@table @gcctabopt
6445@item -Wformat-overflow
6446@itemx -Wformat-overflow=1
6447@opindex Wformat-overflow
6448@opindex Wno-format-overflow
6449Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat}
6450employs a conservative approach that warns only about calls that most
6451likely overflow the buffer. At this level, numeric arguments to format
6452directives with unknown values are assumed to have the value of one, and
6453strings of unknown length to be empty. Numeric arguments that are known
6454to be bounded to a subrange of their type, or string arguments whose output
6455is bounded either by their directive's precision or by a finite set of
6456string literals, are assumed to take on the value within the range that
6457results in the most bytes on output. For example, the call to @code{sprintf}
6458below is diagnosed because even with both @var{a} and @var{b} equal to zero,
6459the terminating NUL character (@code{'\0'}) appended by the function
6460to the destination buffer will be written past its end. Increasing
6461the size of the buffer by a single byte is sufficient to avoid the
6462warning, though it may not be sufficient to avoid the overflow.
6463
6464@smallexample
6465void f (int a, int b)
6466@{
6467 char buf [13];
6468 sprintf (buf, "a = %i, b = %i\n", a, b);
6469@}
6470@end smallexample
6471
6472@item -Wformat-overflow=2
6473Level @var{2} warns also about calls that might overflow the destination
6474buffer given an argument of sufficient length or magnitude. At level
6475@var{2}, unknown numeric arguments are assumed to have the minimum
6476representable value for signed types with a precision greater than 1, and
6477the maximum representable value otherwise. Unknown string arguments whose
6478length cannot be assumed to be bounded either by the directive's precision,
6479or by a finite set of string literals they may evaluate to, or the character
6480array they may point to, are assumed to be 1 character long.
6481
6482At level @var{2}, the call in the example above is again diagnosed, but
6483this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first
6484@code{%i} directive will write some of its digits beyond the end of
6485the destination buffer. To make the call safe regardless of the values
6486of the two variables, the size of the destination buffer must be increased
6487to at least 34 bytes. GCC includes the minimum size of the buffer in
6488an informational note following the warning.
6489
6490An alternative to increasing the size of the destination buffer is to
6491constrain the range of formatted values. The maximum length of string
6492arguments can be bounded by specifying the precision in the format
6493directive. When numeric arguments of format directives can be assumed
6494to be bounded by less than the precision of their type, choosing
6495an appropriate length modifier to the format specifier will reduce
6496the required buffer size. For example, if @var{a} and @var{b} in the
6497example above can be assumed to be within the precision of
6498the @code{short int} type then using either the @code{%hi} format
6499directive or casting the argument to @code{short} reduces the maximum
6500required size of the buffer to 24 bytes.
6501
6502@smallexample
6503void f (int a, int b)
6504@{
6505 char buf [23];
6506 sprintf (buf, "a = %hi, b = %i\n", a, (short)b);
6507@}
6508@end smallexample
6509@end table
6510
6511@item -Wno-format-zero-length
6512@opindex Wno-format-zero-length
6513@opindex Wformat-zero-length
6514If @option{-Wformat} is specified, do not warn about zero-length formats.
6515The C standard specifies that zero-length formats are allowed.
6516
6517@item -Wformat-nonliteral
6518@opindex Wformat-nonliteral
6519@opindex Wno-format-nonliteral
6520If @option{-Wformat} is specified, also warn if the format string is not a
6521string literal and so cannot be checked, unless the format function
6522takes its format arguments as a @code{va_list}.
6523
6524@item -Wformat-security
6525@opindex Wformat-security
6526@opindex Wno-format-security
6527If @option{-Wformat} is specified, also warn about uses of format
6528functions that represent possible security problems. At present, this
6529warns about calls to @code{printf} and @code{scanf} functions where the
6530format string is not a string literal and there are no format arguments,
6531as in @code{printf (foo);}. This may be a security hole if the format
6532string came from untrusted input and contains @samp{%n}. (This is
6533currently a subset of what @option{-Wformat-nonliteral} warns about, but
6534in future warnings may be added to @option{-Wformat-security} that are not
6535included in @option{-Wformat-nonliteral}.)
6536
6537@item -Wformat-signedness
6538@opindex Wformat-signedness
6539@opindex Wno-format-signedness
6540If @option{-Wformat} is specified, also warn if the format string
6541requires an unsigned argument and the argument is signed and vice versa.
6542
6543@item -Wformat-truncation
6544@itemx -Wformat-truncation=@var{level}
6545@opindex Wformat-truncation
6546@opindex Wno-format-truncation
6547Warn about calls to formatted input/output functions such as @code{snprintf}
6548and @code{vsnprintf} that might result in output truncation. When the exact
6549number of bytes written by a format directive cannot be determined at
6550compile-time it is estimated based on heuristics that depend on
6551the @var{level} argument and on optimization. While enabling optimization
6552will in most cases improve the accuracy of the warning, it may also result
6553in false positives. Except as noted otherwise, the option uses the same
6554logic @option{-Wformat-overflow}.
6555
6556@table @gcctabopt
6557@item -Wformat-truncation
6558@itemx -Wformat-truncation=1
6559@opindex Wformat-truncation
6560@opindex Wno-format-truncation
6561Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat}
6562employs a conservative approach that warns only about calls to bounded
6563functions whose return value is unused and that will most likely result
6564in output truncation.
6565
6566@item -Wformat-truncation=2
6567Level @var{2} warns also about calls to bounded functions whose return
6568value is used and that might result in truncation given an argument of
6569sufficient length or magnitude.
6570@end table
6571
6572@item -Wformat-y2k
6573@opindex Wformat-y2k
6574@opindex Wno-format-y2k
6575If @option{-Wformat} is specified, also warn about @code{strftime}
6576formats that may yield only a two-digit year.
6577
6578@item -Wnonnull
6579@opindex Wnonnull
6580@opindex Wno-nonnull
6581Warn about passing a null pointer for arguments marked as
6582requiring a non-null value by the @code{nonnull} function attribute.
6583
6584@option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
6585can be disabled with the @option{-Wno-nonnull} option.
6586
6587@item -Wnonnull-compare
6588@opindex Wnonnull-compare
6589@opindex Wno-nonnull-compare
6590Warn when comparing an argument marked with the @code{nonnull}
6591function attribute against null inside the function.
6592
6593@option{-Wnonnull-compare} is included in @option{-Wall}. It
6594can be disabled with the @option{-Wno-nonnull-compare} option.
6595
6596@item -Wnull-dereference
6597@opindex Wnull-dereference
6598@opindex Wno-null-dereference
6599Warn if the compiler detects paths that trigger erroneous or
6600undefined behavior due to dereferencing a null pointer. This option
6601is only active when @option{-fdelete-null-pointer-checks} is active,
6602which is enabled by optimizations in most targets. The precision of
6603the warnings depends on the optimization options used.
6604
6605@item -Winfinite-recursion
6606@opindex Winfinite-recursion
6607@opindex Wno-infinite-recursion
6608Warn about infinitely recursive calls. The warning is effective at all
6609optimization levels but requires optimization in order to detect infinite
6610recursion in calls between two or more functions.
6611@option{-Winfinite-recursion} is included in @option{-Wall}.
6612
ce51e843
ML
6613Compare with @option{-Wanalyzer-infinite-recursion} which provides a
6614similar diagnostic, but is implemented in a different way (as part of
6615@option{-fanalyzer}).
6616
d77de738
ML
6617@item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
6618@opindex Winit-self
6619@opindex Wno-init-self
6620Warn about uninitialized variables that are initialized with themselves.
6621Note this option can only be used with the @option{-Wuninitialized} option.
6622
6623For example, GCC warns about @code{i} being uninitialized in the
6624following snippet only when @option{-Winit-self} has been specified:
6625@smallexample
6626@group
6627int f()
6628@{
6629 int i = i;
6630 return i;
6631@}
6632@end group
6633@end smallexample
6634
6635This warning is enabled by @option{-Wall} in C++.
6636
6637@item -Wno-implicit-int @r{(C and Objective-C only)}
6638@opindex Wimplicit-int
6639@opindex Wno-implicit-int
6640This option controls warnings when a declaration does not specify a type.
6641This warning is enabled by default in C99 and later dialects of C,
6642and also by @option{-Wall}.
6643
6644@item -Wno-implicit-function-declaration @r{(C and Objective-C only)}
6645@opindex Wimplicit-function-declaration
6646@opindex Wno-implicit-function-declaration
6647This option controls warnings when a function is used before being declared.
6648This warning is enabled by default in C99 and later dialects of C,
6649and also by @option{-Wall}.
6650The warning is made into an error by @option{-pedantic-errors}.
6651
6652@item -Wimplicit @r{(C and Objective-C only)}
6653@opindex Wimplicit
6654@opindex Wno-implicit
6655Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
6656This warning is enabled by @option{-Wall}.
6657
6658@item -Wimplicit-fallthrough
6659@opindex Wimplicit-fallthrough
6660@opindex Wno-implicit-fallthrough
6661@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
6662and @option{-Wno-implicit-fallthrough} is the same as
6663@option{-Wimplicit-fallthrough=0}.
6664
6665@item -Wimplicit-fallthrough=@var{n}
6666@opindex Wimplicit-fallthrough=
6667Warn when a switch case falls through. For example:
6668
6669@smallexample
6670@group
6671switch (cond)
6672 @{
6673 case 1:
6674 a = 1;
6675 break;
6676 case 2:
6677 a = 2;
6678 case 3:
6679 a = 3;
6680 break;
6681 @}
6682@end group
6683@end smallexample
6684
6685This warning does not warn when the last statement of a case cannot
6686fall through, e.g. when there is a return statement or a call to function
6687declared with the noreturn attribute. @option{-Wimplicit-fallthrough=}
6688also takes into account control flow statements, such as ifs, and only
6689warns when appropriate. E.g.@:
6690
6691@smallexample
6692@group
6693switch (cond)
6694 @{
6695 case 1:
6696 if (i > 3) @{
6697 bar (5);
6698 break;
6699 @} else if (i < 1) @{
6700 bar (0);
6701 @} else
6702 return;
6703 default:
6704 @dots{}
6705 @}
6706@end group
6707@end smallexample
6708
6709Since there are occasions where a switch case fall through is desirable,
6710GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is
6711to be used along with a null statement to suppress this warning that
6712would normally occur:
6713
6714@smallexample
6715@group
6716switch (cond)
6717 @{
6718 case 1:
6719 bar (0);
6720 __attribute__ ((fallthrough));
6721 default:
6722 @dots{}
6723 @}
6724@end group
6725@end smallexample
6726
6727C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough}
6728warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11
6729or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension.
6730Instead of these attributes, it is also possible to add a fallthrough comment
6731to silence the warning. The whole body of the C or C++ style comment should
6732match the given regular expressions listed below. The option argument @var{n}
6733specifies what kind of comments are accepted:
6734
6735@itemize @bullet
6736
6737@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
6738
6739@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular
6740expression, any comment is used as fallthrough comment.
6741
6742@item @option{-Wimplicit-fallthrough=2} case insensitively matches
6743@code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
6744
6745@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the
6746following regular expressions:
6747
6748@itemize @bullet
6749
6750@item @code{-fallthrough}
6751
6752@item @code{@@fallthrough@@}
6753
6754@item @code{lint -fallthrough[ \t]*}
6755
6756@item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?}
6757
6758@item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6759
6760@item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?}
6761
6762@end itemize
6763
6764@item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the
6765following regular expressions:
6766
6767@itemize @bullet
6768
6769@item @code{-fallthrough}
6770
6771@item @code{@@fallthrough@@}
6772
6773@item @code{lint -fallthrough[ \t]*}
6774
6775@item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*}
6776
6777@end itemize
6778
6779@item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as
6780fallthrough comments, only attributes disable the warning.
6781
6782@end itemize
6783
6784The comment needs to be followed after optional whitespace and other comments
6785by @code{case} or @code{default} keywords or by a user label that precedes some
6786@code{case} or @code{default} label.
6787
6788@smallexample
6789@group
6790switch (cond)
6791 @{
6792 case 1:
6793 bar (0);
6794 /* FALLTHRU */
6795 default:
6796 @dots{}
6797 @}
6798@end group
6799@end smallexample
6800
6801The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}.
6802
6803@item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
6804@opindex Wif-not-aligned
6805@opindex Wno-if-not-aligned
6806Control if warnings triggered by the @code{warn_if_not_aligned} attribute
6807should be issued. These warnings are enabled by default.
6808
6809@item -Wignored-qualifiers @r{(C and C++ only)}
6810@opindex Wignored-qualifiers
6811@opindex Wno-ignored-qualifiers
6812Warn if the return type of a function has a type qualifier
6813such as @code{const}. For ISO C such a type qualifier has no effect,
6814since the value returned by a function is not an lvalue.
6815For C++, the warning is only emitted for scalar types or @code{void}.
6816ISO C prohibits qualified @code{void} return types on function
6817definitions, so such return types always receive a warning
6818even without this option.
6819
6820This warning is also enabled by @option{-Wextra}.
6821
6822@item -Wno-ignored-attributes @r{(C and C++ only)}
6823@opindex Wignored-attributes
6824@opindex Wno-ignored-attributes
6825This option controls warnings when an attribute is ignored.
6826This is different from the
6827@option{-Wattributes} option in that it warns whenever the compiler decides
6828to drop an attribute, not that the attribute is either unknown, used in a
6829wrong place, etc. This warning is enabled by default.
6830
6831@item -Wmain
6832@opindex Wmain
6833@opindex Wno-main
6834Warn if the type of @code{main} is suspicious. @code{main} should be
6835a function with external linkage, returning int, taking either zero
6836arguments, two, or three arguments of appropriate types. This warning
6837is enabled by default in C++ and is enabled by either @option{-Wall}
6838or @option{-Wpedantic}.
6839
6840@item -Wmisleading-indentation @r{(C and C++ only)}
6841@opindex Wmisleading-indentation
6842@opindex Wno-misleading-indentation
6843Warn when the indentation of the code does not reflect the block structure.
6844Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and
6845@code{for} clauses with a guarded statement that does not use braces,
6846followed by an unguarded statement with the same indentation.
6847
6848In the following example, the call to ``bar'' is misleadingly indented as
6849if it were guarded by the ``if'' conditional.
6850
6851@smallexample
6852 if (some_condition ())
6853 foo ();
6854 bar (); /* Gotcha: this is not guarded by the "if". */
6855@end smallexample
6856
6857In the case of mixed tabs and spaces, the warning uses the
6858@option{-ftabstop=} option to determine if the statements line up
6859(defaulting to 8).
6860
6861The warning is not issued for code involving multiline preprocessor logic
6862such as the following example.
6863
6864@smallexample
6865 if (flagA)
6866 foo (0);
6867#if SOME_CONDITION_THAT_DOES_NOT_HOLD
6868 if (flagB)
6869#endif
6870 foo (1);
6871@end smallexample
6872
6873The warning is not issued after a @code{#line} directive, since this
6874typically indicates autogenerated code, and no assumptions can be made
6875about the layout of the file that the directive references.
6876
6877This warning is enabled by @option{-Wall} in C and C++.
6878
6879@item -Wmissing-attributes
6880@opindex Wmissing-attributes
6881@opindex Wno-missing-attributes
6882Warn when a declaration of a function is missing one or more attributes
6883that a related function is declared with and whose absence may adversely
6884affect the correctness or efficiency of generated code. For example,
6885the warning is issued for declarations of aliases that use attributes
6886to specify less restrictive requirements than those of their targets.
6887This typically represents a potential optimization opportunity.
6888By contrast, the @option{-Wattribute-alias=2} option controls warnings
6889issued when the alias is more restrictive than the target, which could
6890lead to incorrect code generation.
6891Attributes considered include @code{alloc_align}, @code{alloc_size},
6892@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
6893@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
6894@code{returns_nonnull}, and @code{returns_twice}.
6895
6896In C++, the warning is issued when an explicit specialization of a primary
6897template declared with attribute @code{alloc_align}, @code{alloc_size},
6898@code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc},
6899or @code{nonnull} is declared without it. Attributes @code{deprecated},
6900@code{error}, and @code{warning} suppress the warning.
6901(@pxref{Function Attributes}).
6902
6903You can use the @code{copy} attribute to apply the same
6904set of attributes to a declaration as that on another declaration without
6905explicitly enumerating the attributes. This attribute can be applied
6906to declarations of functions (@pxref{Common Function Attributes}),
6907variables (@pxref{Common Variable Attributes}), or types
6908(@pxref{Common Type Attributes}).
6909
6910@option{-Wmissing-attributes} is enabled by @option{-Wall}.
6911
6912For example, since the declaration of the primary function template
6913below makes use of both attribute @code{malloc} and @code{alloc_size}
6914the declaration of the explicit specialization of the template is
6915diagnosed because it is missing one of the attributes.
6916
6917@smallexample
6918template <class T>
6919T* __attribute__ ((malloc, alloc_size (1)))
6920allocate (size_t);
6921
6922template <>
6923void* __attribute__ ((malloc)) // missing alloc_size
6924allocate<void> (size_t);
6925@end smallexample
6926
6927@item -Wmissing-braces
6928@opindex Wmissing-braces
6929@opindex Wno-missing-braces
6930Warn if an aggregate or union initializer is not fully bracketed. In
6931the following example, the initializer for @code{a} is not fully
6932bracketed, but that for @code{b} is fully bracketed.
6933
6934@smallexample
6935int a[2][2] = @{ 0, 1, 2, 3 @};
6936int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
6937@end smallexample
6938
6939This warning is enabled by @option{-Wall}.
6940
6941@item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)}
6942@opindex Wmissing-include-dirs
6943@opindex Wno-missing-include-dirs
6944Warn if a user-supplied include directory does not exist. This opions is disabled
6945by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially
6946enabled by default by warning for -I and -J, only.
6947
6948@item -Wno-missing-profile
6949@opindex Wmissing-profile
6950@opindex Wno-missing-profile
6951This option controls warnings if feedback profiles are missing when using the
6952@option{-fprofile-use} option.
6953This option diagnoses those cases where a new function or a new file is added
6954between compiling with @option{-fprofile-generate} and with
6955@option{-fprofile-use}, without regenerating the profiles.
6956In these cases, the profile feedback data files do not contain any
6957profile feedback information for
6958the newly added function or file respectively. Also, in the case when profile
6959count data (.gcda) files are removed, GCC cannot use any profile feedback
6960information. In all these cases, warnings are issued to inform you that a
6961profile generation step is due.
6962Ignoring the warning can result in poorly optimized code.
6963@option{-Wno-missing-profile} can be used to
6964disable the warning, but this is not recommended and should be done only
6965when non-existent profile data is justified.
6966
6967@item -Wmismatched-dealloc
6968@opindex Wmismatched-dealloc
6969@opindex Wno-mismatched-dealloc
6970
6971Warn for calls to deallocation functions with pointer arguments returned
6972from from allocations functions for which the former isn't a suitable
6973deallocator. A pair of functions can be associated as matching allocators
6974and deallocators by use of attribute @code{malloc}. Unless disabled by
6975the @option{-fno-builtin} option the standard functions @code{calloc},
6976@code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding
6977forms of C++ @code{operator new} and @code{operator delete} are implicitly
6978associated as matching allocators and deallocators. In the following
6979example @code{mydealloc} is the deallocator for pointers returned from
6980@code{myalloc}.
6981
6982@smallexample
6983void mydealloc (void*);
6984
6985__attribute__ ((malloc (mydealloc, 1))) void*
6986myalloc (size_t);
6987
6988void f (void)
6989@{
6990 void *p = myalloc (32);
6991 // @dots{}use p@dots{}
6992 free (p); // warning: not a matching deallocator for myalloc
6993 mydealloc (p); // ok
6994@}
6995@end smallexample
6996
6997In C++, the related option @option{-Wmismatched-new-delete} diagnoses
6998mismatches involving either @code{operator new} or @code{operator delete}.
6999
7000Option @option{-Wmismatched-dealloc} is included in @option{-Wall}.
7001
7002@item -Wmultistatement-macros
7003@opindex Wmultistatement-macros
7004@opindex Wno-multistatement-macros
7005Warn about unsafe multiple statement macros that appear to be guarded
7006by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or
7007@code{while}, in which only the first statement is actually guarded after
7008the macro is expanded.
7009
7010For example:
7011
7012@smallexample
7013#define DOIT x++; y++
7014if (c)
7015 DOIT;
7016@end smallexample
7017
7018will increment @code{y} unconditionally, not just when @code{c} holds.
7019The can usually be fixed by wrapping the macro in a do-while loop:
7020@smallexample
7021#define DOIT do @{ x++; y++; @} while (0)
7022if (c)
7023 DOIT;
7024@end smallexample
7025
7026This warning is enabled by @option{-Wall} in C and C++.
7027
7028@item -Wparentheses
7029@opindex Wparentheses
7030@opindex Wno-parentheses
7031Warn if parentheses are omitted in certain contexts, such
7032as when there is an assignment in a context where a truth value
7033is expected, or when operators are nested whose precedence people
7034often get confused about.
7035
7036Also warn if a comparison like @code{x<=y<=z} appears; this is
7037equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different
7038interpretation from that of ordinary mathematical notation.
7039
7040Also warn for dangerous uses of the GNU extension to
7041@code{?:} with omitted middle operand. When the condition
7042in the @code{?}: operator is a boolean expression, the omitted value is
7043always 1. Often programmers expect it to be a value computed
7044inside the conditional expression instead.
7045
7046For C++ this also warns for some cases of unnecessary parentheses in
7047declarations, which can indicate an attempt at a function call instead
7048of a declaration:
7049@smallexample
7050@{
7051 // Declares a local variable called mymutex.
7052 std::unique_lock<std::mutex> (mymutex);
7053 // User meant std::unique_lock<std::mutex> lock (mymutex);
7054@}
7055@end smallexample
7056
7057This warning is enabled by @option{-Wall}.
7058
7059@item -Wno-self-move @r{(C++ and Objective-C++ only)}
7060@opindex Wself-move
7061@opindex Wno-self-move
7062This warning warns when a value is moved to itself with @code{std::move}.
7063Such a @code{std::move} typically has no effect.
7064
7065@smallexample
7066struct T @{
7067@dots{}
7068@};
7069void fn()
7070@{
7071 T t;
7072 @dots{}
7073 t = std::move (t);
7074@}
7075@end smallexample
7076
7077This warning is enabled by @option{-Wall}.
7078
7079@item -Wsequence-point
7080@opindex Wsequence-point
7081@opindex Wno-sequence-point
7082Warn about code that may have undefined semantics because of violations
7083of sequence point rules in the C and C++ standards.
7084
7085The C and C++ standards define the order in which expressions in a C/C++
7086program are evaluated in terms of @dfn{sequence points}, which represent
7087a partial ordering between the execution of parts of the program: those
7088executed before the sequence point, and those executed after it. These
7089occur after the evaluation of a full expression (one which is not part
7090of a larger expression), after the evaluation of the first operand of a
7091@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
7092function is called (but after the evaluation of its arguments and the
7093expression denoting the called function), and in certain other places.
7094Other than as expressed by the sequence point rules, the order of
7095evaluation of subexpressions of an expression is not specified. All
7096these rules describe only a partial order rather than a total order,
7097since, for example, if two functions are called within one expression
7098with no sequence point between them, the order in which the functions
7099are called is not specified. However, the standards committee have
7100ruled that function calls do not overlap.
7101
7102It is not specified when between sequence points modifications to the
7103values of objects take effect. Programs whose behavior depends on this
7104have undefined behavior; the C and C++ standards specify that ``Between
7105the previous and next sequence point an object shall have its stored
7106value modified at most once by the evaluation of an expression.
7107Furthermore, the prior value shall be read only to determine the value
7108to be stored.''. If a program breaks these rules, the results on any
7109particular implementation are entirely unpredictable.
7110
7111Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
7112= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
7113diagnosed by this option, and it may give an occasional false positive
7114result, but in general it has been found fairly effective at detecting
7115this sort of problem in programs.
7116
7117The C++17 standard will define the order of evaluation of operands in
7118more cases: in particular it requires that the right-hand side of an
7119assignment be evaluated before the left-hand side, so the above
7120examples are no longer undefined. But this option will still warn
7121about them, to help people avoid writing code that is undefined in C
7122and earlier revisions of C++.
7123
7124The standard is worded confusingly, therefore there is some debate
7125over the precise meaning of the sequence point rules in subtle cases.
7126Links to discussions of the problem, including proposed formal
7127definitions, may be found on the GCC readings page, at
7128@uref{https://gcc.gnu.org/@/readings.html}.
7129
7130This warning is enabled by @option{-Wall} for C and C++.
7131
7132@item -Wno-return-local-addr
7133@opindex Wno-return-local-addr
7134@opindex Wreturn-local-addr
7135Do not warn about returning a pointer (or in C++, a reference) to a
7136variable that goes out of scope after the function returns.
7137
7138@item -Wreturn-type
7139@opindex Wreturn-type
7140@opindex Wno-return-type
7141Warn whenever a function is defined with a return type that defaults
7142to @code{int}. Also warn about any @code{return} statement with no
7143return value in a function whose return type is not @code{void}
7144(falling off the end of the function body is considered returning
7145without a value).
7146
7147For C only, warn about a @code{return} statement with an expression in a
7148function whose return type is @code{void}, unless the expression type is
7149also @code{void}. As a GNU extension, the latter case is accepted
7150without a warning unless @option{-Wpedantic} is used. Attempting
7151to use the return value of a non-@code{void} function other than @code{main}
7152that flows off the end by reaching the closing curly brace that terminates
7153the function is undefined.
7154
7155Unlike in C, in C++, flowing off the end of a non-@code{void} function other
7156than @code{main} results in undefined behavior even when the value of
7157the function is not used.
7158
7159This warning is enabled by default in C++ and by @option{-Wall} otherwise.
7160
7161@item -Wno-shift-count-negative
7162@opindex Wshift-count-negative
7163@opindex Wno-shift-count-negative
7164Controls warnings if a shift count is negative.
7165This warning is enabled by default.
7166
7167@item -Wno-shift-count-overflow
7168@opindex Wshift-count-overflow
7169@opindex Wno-shift-count-overflow
7170Controls warnings if a shift count is greater than or equal to the bit width
7171of the type. This warning is enabled by default.
7172
7173@item -Wshift-negative-value
7174@opindex Wshift-negative-value
7175@opindex Wno-shift-negative-value
7176Warn if left shifting a negative value. This warning is enabled by
7177@option{-Wextra} in C99 (and newer) and C++11 to C++17 modes.
7178
7179@item -Wno-shift-overflow
7180@itemx -Wshift-overflow=@var{n}
7181@opindex Wshift-overflow
7182@opindex Wno-shift-overflow
7183These options control warnings about left shift overflows.
7184
7185@table @gcctabopt
7186@item -Wshift-overflow=1
7187This is the warning level of @option{-Wshift-overflow} and is enabled
7188by default in C99 and C++11 modes (and newer). This warning level does
7189not warn about left-shifting 1 into the sign bit. (However, in C, such
7190an overflow is still rejected in contexts where an integer constant expression
7191is required.) No warning is emitted in C++20 mode (and newer), as signed left
7192shifts always wrap.
7193
7194@item -Wshift-overflow=2
7195This warning level also warns about left-shifting 1 into the sign bit,
7196unless C++14 mode (or newer) is active.
7197@end table
7198
7199@item -Wswitch
7200@opindex Wswitch
7201@opindex Wno-switch
7202Warn whenever a @code{switch} statement has an index of enumerated type
7203and lacks a @code{case} for one or more of the named codes of that
7204enumeration. (The presence of a @code{default} label prevents this
7205warning.) @code{case} labels outside the enumeration range also
7206provoke warnings when this option is used (even if there is a
7207@code{default} label).
7208This warning is enabled by @option{-Wall}.
7209
7210@item -Wswitch-default
7211@opindex Wswitch-default
7212@opindex Wno-switch-default
7213Warn whenever a @code{switch} statement does not have a @code{default}
7214case.
7215
7216@item -Wswitch-enum
7217@opindex Wswitch-enum
7218@opindex Wno-switch-enum
7219Warn whenever a @code{switch} statement has an index of enumerated type
7220and lacks a @code{case} for one or more of the named codes of that
7221enumeration. @code{case} labels outside the enumeration range also
7222provoke warnings when this option is used. The only difference
7223between @option{-Wswitch} and this option is that this option gives a
7224warning about an omitted enumeration code even if there is a
7225@code{default} label.
7226
7227@item -Wno-switch-bool
7228@opindex Wswitch-bool
7229@opindex Wno-switch-bool
7230Do not warn when a @code{switch} statement has an index of boolean type
7231and the case values are outside the range of a boolean type.
7232It is possible to suppress this warning by casting the controlling
7233expression to a type other than @code{bool}. For example:
7234@smallexample
7235@group
7236switch ((int) (a == 4))
7237 @{
7238 @dots{}
7239 @}
7240@end group
7241@end smallexample
7242This warning is enabled by default for C and C++ programs.
7243
7244@item -Wno-switch-outside-range
7245@opindex Wswitch-outside-range
7246@opindex Wno-switch-outside-range
7247This option controls warnings when a @code{switch} case has a value
7248that is outside of its
7249respective type range. This warning is enabled by default for
7250C and C++ programs.
7251
7252@item -Wno-switch-unreachable
7253@opindex Wswitch-unreachable
7254@opindex Wno-switch-unreachable
7255Do not warn when a @code{switch} statement contains statements between the
7256controlling expression and the first case label, which will never be
7257executed. For example:
7258@smallexample
7259@group
7260switch (cond)
7261 @{
7262 i = 15;
7263 @dots{}
7264 case 5:
7265 @dots{}
7266 @}
7267@end group
7268@end smallexample
7269@option{-Wswitch-unreachable} does not warn if the statement between the
7270controlling expression and the first case label is just a declaration:
7271@smallexample
7272@group
7273switch (cond)
7274 @{
7275 int i;
7276 @dots{}
7277 case 5:
7278 i = 5;
7279 @dots{}
7280 @}
7281@end group
7282@end smallexample
7283This warning is enabled by default for C and C++ programs.
7284
7285@item -Wsync-nand @r{(C and C++ only)}
7286@opindex Wsync-nand
7287@opindex Wno-sync-nand
7288Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch}
7289built-in functions are used. These functions changed semantics in GCC 4.4.
7290
7291@item -Wtrivial-auto-var-init
7292@opindex Wtrivial-auto-var-init
7293@opindex Wno-trivial-auto-var-init
7294Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic
7295variable. A common situation is an automatic variable that is declared
7296between the controlling expression and the first case label of a @code{switch}
7297statement.
7298
7299@item -Wunused-but-set-parameter
7300@opindex Wunused-but-set-parameter
7301@opindex Wno-unused-but-set-parameter
7302Warn whenever a function parameter is assigned to, but otherwise unused
7303(aside from its declaration).
7304
7305To suppress this warning use the @code{unused} attribute
7306(@pxref{Variable Attributes}).
7307
7308This warning is also enabled by @option{-Wunused} together with
7309@option{-Wextra}.
7310
7311@item -Wunused-but-set-variable
7312@opindex Wunused-but-set-variable
7313@opindex Wno-unused-but-set-variable
7314Warn whenever a local variable is assigned to, but otherwise unused
7315(aside from its declaration).
7316This warning is enabled by @option{-Wall}.
7317
7318To suppress this warning use the @code{unused} attribute
7319(@pxref{Variable Attributes}).
7320
7321This warning is also enabled by @option{-Wunused}, which is enabled
7322by @option{-Wall}.
7323
7324@item -Wunused-function
7325@opindex Wunused-function
7326@opindex Wno-unused-function
7327Warn whenever a static function is declared but not defined or a
7328non-inline static function is unused.
7329This warning is enabled by @option{-Wall}.
7330
7331@item -Wunused-label
7332@opindex Wunused-label
7333@opindex Wno-unused-label
7334Warn whenever a label is declared but not used.
7335This warning is enabled by @option{-Wall}.
7336
7337To suppress this warning use the @code{unused} attribute
7338(@pxref{Variable Attributes}).
7339
7340@item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)}
7341@opindex Wunused-local-typedefs
7342@opindex Wno-unused-local-typedefs
7343Warn when a typedef locally defined in a function is not used.
7344This warning is enabled by @option{-Wall}.
7345
7346@item -Wunused-parameter
7347@opindex Wunused-parameter
7348@opindex Wno-unused-parameter
7349Warn whenever a function parameter is unused aside from its declaration.
7350
7351To suppress this warning use the @code{unused} attribute
7352(@pxref{Variable Attributes}).
7353
7354@item -Wno-unused-result
7355@opindex Wunused-result
7356@opindex Wno-unused-result
7357Do not warn if a caller of a function marked with attribute
7358@code{warn_unused_result} (@pxref{Function Attributes}) does not use
7359its return value. The default is @option{-Wunused-result}.
7360
7361@item -Wunused-variable
7362@opindex Wunused-variable
7363@opindex Wno-unused-variable
7364Warn whenever a local or static variable is unused aside from its
7365declaration. This option implies @option{-Wunused-const-variable=1} for C,
7366but not for C++. This warning is enabled by @option{-Wall}.
7367
7368To suppress this warning use the @code{unused} attribute
7369(@pxref{Variable Attributes}).
7370
7371@item -Wunused-const-variable
7372@itemx -Wunused-const-variable=@var{n}
7373@opindex Wunused-const-variable
7374@opindex Wno-unused-const-variable
7375Warn whenever a constant static variable is unused aside from its declaration.
7376@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable}
7377for C, but not for C++. In C this declares variable storage, but in C++ this
7378is not an error since const variables take the place of @code{#define}s.
7379
7380To suppress this warning use the @code{unused} attribute
7381(@pxref{Variable Attributes}).
7382
7383@table @gcctabopt
7384@item -Wunused-const-variable=1
7385This is the warning level that is enabled by @option{-Wunused-variable} for
7386C. It warns only about unused static const variables defined in the main
7387compilation unit, but not about static const variables declared in any
7388header included.
7389
7390@item -Wunused-const-variable=2
7391This warning level also warns for unused constant static variables in
7392headers (excluding system headers). This is the warning level of
7393@option{-Wunused-const-variable} and must be explicitly requested since
7394in C++ this isn't an error and in C it might be harder to clean up all
7395headers included.
7396@end table
7397
7398@item -Wunused-value
7399@opindex Wunused-value
7400@opindex Wno-unused-value
7401Warn whenever a statement computes a result that is explicitly not
7402used. To suppress this warning cast the unused expression to
7403@code{void}. This includes an expression-statement or the left-hand
7404side of a comma expression that contains no side effects. For example,
7405an expression such as @code{x[i,j]} causes a warning, while
7406@code{x[(void)i,j]} does not.
7407
7408This warning is enabled by @option{-Wall}.
7409
7410@item -Wunused
7411@opindex Wunused
7412@opindex Wno-unused
7413All the above @option{-Wunused} options combined.
7414
7415In order to get a warning about an unused function parameter, you must
7416either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies
7417@option{-Wunused}), or separately specify @option{-Wunused-parameter}.
7418
7419@item -Wuninitialized
7420@opindex Wuninitialized
7421@opindex Wno-uninitialized
7422Warn if an object with automatic or allocated storage duration is used
7423without having been initialized. In C++, also warn if a non-static
7424reference or non-static @code{const} member appears in a class without
7425constructors.
7426
7427In addition, passing a pointer (or in C++, a reference) to an uninitialized
7428object to a @code{const}-qualified argument of a built-in function known to
7429read the object is also diagnosed by this warning.
7430(@option{-Wmaybe-uninitialized} is issued for ordinary functions.)
7431
7432If you want to warn about code that uses the uninitialized value of the
7433variable in its own initializer, use the @option{-Winit-self} option.
7434
7435These warnings occur for individual uninitialized elements of
7436structure, union or array variables as well as for variables that are
7437uninitialized as a whole. They do not occur for variables or elements
7438declared @code{volatile}. Because these warnings depend on
7439optimization, the exact variables or elements for which there are
7440warnings depend on the precise optimization options and version of GCC
7441used.
7442
7443Note that there may be no warning about a variable that is used only
7444to compute a value that itself is never used, because such
7445computations may be deleted by data flow analysis before the warnings
7446are printed.
7447
7448In C++, this warning also warns about using uninitialized objects in
7449member-initializer-lists. For example, GCC warns about @code{b} being
7450uninitialized in the following snippet:
7451
7452@smallexample
7453struct A @{
7454 int a;
7455 int b;
7456 A() : a(b) @{ @}
7457@};
7458@end smallexample
7459
7460@item -Wno-invalid-memory-model
7461@opindex Winvalid-memory-model
7462@opindex Wno-invalid-memory-model
7463This option controls warnings
7464for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins},
7465and the C11 atomic generic functions with a memory consistency argument
7466that is either invalid for the operation or outside the range of values
7467of the @code{memory_order} enumeration. For example, since the
7468@code{__atomic_store} and @code{__atomic_store_n} built-ins are only
7469defined for the relaxed, release, and sequentially consistent memory
7470orders the following code is diagnosed:
7471
7472@smallexample
7473void store (int *i)
7474@{
7475 __atomic_store_n (i, 0, memory_order_consume);
7476@}
7477@end smallexample
7478
7479@option{-Winvalid-memory-model} is enabled by default.
7480
7481@item -Wmaybe-uninitialized
7482@opindex Wmaybe-uninitialized
7483@opindex Wno-maybe-uninitialized
7484For an object with automatic or allocated storage duration, if there exists
7485a path from the function entry to a use of the object that is initialized,
7486but there exist some other paths for which the object is not initialized,
7487the compiler emits a warning if it cannot prove the uninitialized paths
7488are not executed at run time.
7489
7490In addition, passing a pointer (or in C++, a reference) to an uninitialized
7491object to a @code{const}-qualified function argument is also diagnosed by
7492this warning. (@option{-Wuninitialized} is issued for built-in functions
7493known to read the object.) Annotating the function with attribute
7494@code{access (none)} indicates that the argument isn't used to access
7495the object and avoids the warning (@pxref{Common Function Attributes}).
7496
7497These warnings are only possible in optimizing compilation, because otherwise
7498GCC does not keep track of the state of variables.
7499
7500These warnings are made optional because GCC may not be able to determine when
7501the code is correct in spite of appearing to have an error. Here is one
7502example of how this can happen:
7503
7504@smallexample
7505@group
7506@{
7507 int x;
7508 switch (y)
7509 @{
7510 case 1: x = 1;
7511 break;
7512 case 2: x = 4;
7513 break;
7514 case 3: x = 5;
7515 @}
7516 foo (x);
7517@}
7518@end group
7519@end smallexample
7520
7521@noindent
7522If the value of @code{y} is always 1, 2 or 3, then @code{x} is
7523always initialized, but GCC doesn't know this. To suppress the
7524warning, you need to provide a default case with assert(0) or
7525similar code.
7526
7527@cindex @code{longjmp} warnings
7528This option also warns when a non-volatile automatic variable might be
7529changed by a call to @code{longjmp}.
7530The compiler sees only the calls to @code{setjmp}. It cannot know
7531where @code{longjmp} will be called; in fact, a signal handler could
7532call it at any point in the code. As a result, you may get a warning
7533even when there is in fact no problem because @code{longjmp} cannot
7534in fact be called at the place that would cause a problem.
7535
7536Some spurious warnings can be avoided if you declare all the functions
7537you use that never return as @code{noreturn}. @xref{Function
7538Attributes}.
7539
7540This warning is enabled by @option{-Wall} or @option{-Wextra}.
7541
7542@item -Wunknown-pragmas
7543@opindex Wunknown-pragmas
7544@opindex Wno-unknown-pragmas
7545@cindex warning for unknown pragmas
7546@cindex unknown pragmas, warning
7547@cindex pragmas, warning of unknown
7548Warn when a @code{#pragma} directive is encountered that is not understood by
7549GCC@. If this command-line option is used, warnings are even issued
7550for unknown pragmas in system header files. This is not the case if
7551the warnings are only enabled by the @option{-Wall} command-line option.
7552
7553@item -Wno-pragmas
7554@opindex Wno-pragmas
7555@opindex Wpragmas
7556Do not warn about misuses of pragmas, such as incorrect parameters,
7557invalid syntax, or conflicts between pragmas. See also
7558@option{-Wunknown-pragmas}.
7559
7560@item -Wno-prio-ctor-dtor
7561@opindex Wno-prio-ctor-dtor
7562@opindex Wprio-ctor-dtor
7563Do not warn if a priority from 0 to 100 is used for constructor or destructor.
7564The use of constructor and destructor attributes allow you to assign a
7565priority to the constructor/destructor to control its order of execution
7566before @code{main} is called or after it returns. The priority values must be
7567greater than 100 as the compiler reserves priority values between 0--100 for
7568the implementation.
7569
7570@item -Wstrict-aliasing
7571@opindex Wstrict-aliasing
7572@opindex Wno-strict-aliasing
7573This option is only active when @option{-fstrict-aliasing} is active.
7574It warns about code that might break the strict aliasing rules that the
7575compiler is using for optimization. The warning does not catch all
7576cases, but does attempt to catch the more common pitfalls. It is
7577included in @option{-Wall}.
7578It is equivalent to @option{-Wstrict-aliasing=3}
7579
7580@item -Wstrict-aliasing=n
7581@opindex Wstrict-aliasing=n
7582This option is only active when @option{-fstrict-aliasing} is active.
7583It warns about code that might break the strict aliasing rules that the
7584compiler is using for optimization.
7585Higher levels correspond to higher accuracy (fewer false positives).
7586Higher levels also correspond to more effort, similar to the way @option{-O}
7587works.
7588@option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}.
7589
7590Level 1: Most aggressive, quick, least accurate.
7591Possibly useful when higher levels
7592do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few
7593false negatives. However, it has many false positives.
7594Warns for all pointer conversions between possibly incompatible types,
7595even if never dereferenced. Runs in the front end only.
7596
7597Level 2: Aggressive, quick, not too precise.
7598May still have many false positives (not as many as level 1 though),
7599and few false negatives (but possibly more than level 1).
7600Unlike level 1, it only warns when an address is taken. Warns about
7601incomplete types. Runs in the front end only.
7602
7603Level 3 (default for @option{-Wstrict-aliasing}):
7604Should have very few false positives and few false
7605negatives. Slightly slower than levels 1 or 2 when optimization is enabled.
7606Takes care of the common pun+dereference pattern in the front end:
7607@code{*(int*)&some_float}.
7608If optimization is enabled, it also runs in the back end, where it deals
7609with multiple statement cases using flow-sensitive points-to information.
7610Only warns when the converted pointer is dereferenced.
7611Does not warn about incomplete types.
7612
7613@item -Wstrict-overflow
7614@itemx -Wstrict-overflow=@var{n}
7615@opindex Wstrict-overflow
7616@opindex Wno-strict-overflow
7617This option is only active when signed overflow is undefined.
7618It warns about cases where the compiler optimizes based on the
7619assumption that signed overflow does not occur. Note that it does not
7620warn about all cases where the code might overflow: it only warns
7621about cases where the compiler implements some optimization. Thus
7622this warning depends on the optimization level.
7623
7624An optimization that assumes that signed overflow does not occur is
7625perfectly safe if the values of the variables involved are such that
7626overflow never does, in fact, occur. Therefore this warning can
7627easily give a false positive: a warning about code that is not
7628actually a problem. To help focus on important issues, several
7629warning levels are defined. No warnings are issued for the use of
7630undefined signed overflow when estimating how many iterations a loop
7631requires, in particular when determining whether a loop will be
7632executed at all.
7633
7634@table @gcctabopt
7635@item -Wstrict-overflow=1
7636Warn about cases that are both questionable and easy to avoid. For
7637example the compiler simplifies
7638@code{x + 1 > x} to @code{1}. This level of
7639@option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels
7640are not, and must be explicitly requested.
7641
7642@item -Wstrict-overflow=2
7643Also warn about other cases where a comparison is simplified to a
7644constant. For example: @code{abs (x) >= 0}. This can only be
7645simplified when signed integer overflow is undefined, because
7646@code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than
7647zero. @option{-Wstrict-overflow} (with no level) is the same as
7648@option{-Wstrict-overflow=2}.
7649
7650@item -Wstrict-overflow=3
7651Also warn about other cases where a comparison is simplified. For
7652example: @code{x + 1 > 1} is simplified to @code{x > 0}.
7653
7654@item -Wstrict-overflow=4
7655Also warn about other simplifications not covered by the above cases.
7656For example: @code{(x * 10) / 5} is simplified to @code{x * 2}.
7657
7658@item -Wstrict-overflow=5
7659Also warn about cases where the compiler reduces the magnitude of a
7660constant involved in a comparison. For example: @code{x + 2 > y} is
7661simplified to @code{x + 1 >= y}. This is reported only at the
7662highest warning level because this simplification applies to many
7663comparisons, so this warning level gives a very large number of
7664false positives.
7665@end table
7666
7667@item -Wstring-compare
7668@opindex Wstring-compare
7669@opindex Wno-string-compare
7670Warn for calls to @code{strcmp} and @code{strncmp} whose result is
7671determined to be either zero or non-zero in tests for such equality
7672owing to the length of one argument being greater than the size of
7673the array the other argument is stored in (or the bound in the case
7674of @code{strncmp}). Such calls could be mistakes. For example,
7675the call to @code{strcmp} below is diagnosed because its result is
7676necessarily non-zero irrespective of the contents of the array @code{a}.
7677
7678@smallexample
7679extern char a[4];
7680void f (char *d)
7681@{
7682 strcpy (d, "string");
7683 @dots{}
7684 if (0 == strcmp (a, d)) // cannot be true
7685 puts ("a and d are the same");
7686@}
7687@end smallexample
7688
7689@option{-Wstring-compare} is enabled by @option{-Wextra}.
7690
7691@item -Wno-stringop-overflow
7692@item -Wstringop-overflow
7693@itemx -Wstringop-overflow=@var{type}
7694@opindex Wstringop-overflow
7695@opindex Wno-stringop-overflow
7696Warn for calls to string manipulation functions such as @code{memcpy} and
7697@code{strcpy} that are determined to overflow the destination buffer. The
7698optional argument is one greater than the type of Object Size Checking to
7699perform to determine the size of the destination. @xref{Object Size Checking}.
7700The argument is meaningful only for functions that operate on character arrays
7701but not for raw memory functions like @code{memcpy} which always make use
7702of Object Size type-0. The option also warns for calls that specify a size
7703in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes.
7704The option produces the best results with optimization enabled but can detect
7705a small subset of simple buffer overflows even without optimization in
7706calls to the GCC built-in functions like @code{__builtin_memcpy} that
7707correspond to the standard functions. In any case, the option warns about
7708just a subset of buffer overflows detected by the corresponding overflow
7709checking built-ins. For example, the option issues a warning for
7710the @code{strcpy} call below because it copies at least 5 characters
7711(the string @code{"blue"} including the terminating NUL) into the buffer
7712of size 4.
7713
7714@smallexample
7715enum Color @{ blue, purple, yellow @};
7716const char* f (enum Color clr)
7717@{
7718 static char buf [4];
7719 const char *str;
7720 switch (clr)
7721 @{
7722 case blue: str = "blue"; break;
7723 case purple: str = "purple"; break;
7724 case yellow: str = "yellow"; break;
7725 @}
7726
7727 return strcpy (buf, str); // warning here
7728@}
7729@end smallexample
7730
7731Option @option{-Wstringop-overflow=2} is enabled by default.
7732
7733@table @gcctabopt
7734@item -Wstringop-overflow
7735@itemx -Wstringop-overflow=1
7736@opindex Wstringop-overflow
7737@opindex Wno-stringop-overflow
7738The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking
7739to determine the sizes of destination objects. At this setting the option
7740does not warn for writes past the end of subobjects of larger objects accessed
7741by pointers unless the size of the largest surrounding object is known. When
7742the destination may be one of several objects it is assumed to be the largest
7743one of them. On Linux systems, when optimization is enabled at this setting
7744the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro
7745is defined to a non-zero value.
7746
7747@item -Wstringop-overflow=2
7748The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking
7749to determine the sizes of destination objects. At this setting the option
7750warns about overflows when writing to members of the largest complete
7751objects whose exact size is known. However, it does not warn for excessive
7752writes to the same members of unknown objects referenced by pointers since
7753they may point to arrays containing unknown numbers of elements. This is
7754the default setting of the option.
7755
7756@item -Wstringop-overflow=3
7757The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking
7758to determine the sizes of destination objects. At this setting the option
7759warns about overflowing the smallest object or data member. This is the
7760most restrictive setting of the option that may result in warnings for safe
7761code.
7762
7763@item -Wstringop-overflow=4
7764The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking
7765to determine the sizes of destination objects. At this setting the option
7766warns about overflowing any data members, and when the destination is
7767one of several objects it uses the size of the largest of them to decide
7768whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this
7769setting of the option may result in warnings for benign code.
7770@end table
7771
7772@item -Wno-stringop-overread
7773@opindex Wstringop-overread
7774@opindex Wno-stringop-overread
7775Warn for calls to string manipulation functions such as @code{memchr}, or
7776@code{strcpy} that are determined to read past the end of the source
7777sequence.
7778
7779Option @option{-Wstringop-overread} is enabled by default.
7780
7781@item -Wno-stringop-truncation
7782@opindex Wstringop-truncation
7783@opindex Wno-stringop-truncation
7784Do not warn for calls to bounded string manipulation functions
7785such as @code{strncat},
7786@code{strncpy}, and @code{stpncpy} that may either truncate the copied string
7787or leave the destination unchanged.
7788
7789In the following example, the call to @code{strncat} specifies a bound that
7790is less than the length of the source string. As a result, the copy of
7791the source will be truncated and so the call is diagnosed. To avoid the
7792warning use @code{bufsize - strlen (buf) - 1)} as the bound.
7793
7794@smallexample
7795void append (char *buf, size_t bufsize)
7796@{
7797 strncat (buf, ".txt", 3);
7798@}
7799@end smallexample
7800
7801As another example, the following call to @code{strncpy} results in copying
7802to @code{d} just the characters preceding the terminating NUL, without
7803appending the NUL to the end. Assuming the result of @code{strncpy} is
7804necessarily a NUL-terminated string is a common mistake, and so the call
7805is diagnosed. To avoid the warning when the result is not expected to be
7806NUL-terminated, call @code{memcpy} instead.
7807
7808@smallexample
7809void copy (char *d, const char *s)
7810@{
7811 strncpy (d, s, strlen (s));
7812@}
7813@end smallexample
7814
7815In the following example, the call to @code{strncpy} specifies the size
7816of the destination buffer as the bound. If the length of the source
7817string is equal to or greater than this size the result of the copy will
7818not be NUL-terminated. Therefore, the call is also diagnosed. To avoid
7819the warning, specify @code{sizeof buf - 1} as the bound and set the last
7820element of the buffer to @code{NUL}.
7821
7822@smallexample
7823void copy (const char *s)
7824@{
7825 char buf[80];
7826 strncpy (buf, s, sizeof buf);
7827 @dots{}
7828@}
7829@end smallexample
7830
7831In situations where a character array is intended to store a sequence
7832of bytes with no terminating @code{NUL} such an array may be annotated
7833with attribute @code{nonstring} to avoid this warning. Such arrays,
7834however, are not suitable arguments to functions that expect
7835@code{NUL}-terminated strings. To help detect accidental misuses of
7836such arrays GCC issues warnings unless it can prove that the use is
7837safe. @xref{Common Variable Attributes}.
7838
2a27ae32
QZ
7839@item -Wstrict-flex-arrays
7840@opindex Wstrict-flex-arrays
7841@opindex Wno-strict-flex-arrays
7842Warn about inproper usages of flexible array members
7843according to the @var{level} of the @code{strict_flex_array (@var{level})}
7844attribute attached to the trailing array field of a structure if it's
7845available, otherwise according to the @var{level} of the option
7846@option{-fstrict-flex-arrays=@var{level}}.
7847
7848This option is effective only when @var{level} is bigger than 0. Otherwise,
7849it will be ignored with a warning.
7850
7851when @var{level}=1, warnings will be issued for a trailing array reference
7852of a structure that have 2 or more elements if the trailing array is referenced
7853as a flexible array member.
7854
7855when @var{level}=2, in addition to @var{level}=1, additional warnings will be
7856issued for a trailing one-element array reference of a structure
7857if the array is referenced as a flexible array member.
7858
7859when @var{level}=3, in addition to @var{level}=2, additional warnings will be
7860issued for a trailing zero-length array reference of a structure
7861if the array is referenced as a flexible array member.
7862
7863
d77de738
ML
7864@item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]}
7865@opindex Wsuggest-attribute=
7866@opindex Wno-suggest-attribute=
7867Warn for cases where adding an attribute may be beneficial. The
7868attributes currently supported are listed below.
7869
7870@table @gcctabopt
7871@item -Wsuggest-attribute=pure
7872@itemx -Wsuggest-attribute=const
7873@itemx -Wsuggest-attribute=noreturn
7874@itemx -Wmissing-noreturn
7875@itemx -Wsuggest-attribute=malloc
7876@opindex Wsuggest-attribute=pure
7877@opindex Wno-suggest-attribute=pure
7878@opindex Wsuggest-attribute=const
7879@opindex Wno-suggest-attribute=const
7880@opindex Wsuggest-attribute=noreturn
7881@opindex Wno-suggest-attribute=noreturn
7882@opindex Wmissing-noreturn
7883@opindex Wno-missing-noreturn
7884@opindex Wsuggest-attribute=malloc
7885@opindex Wno-suggest-attribute=malloc
7886
7887Warn about functions that might be candidates for attributes
7888@code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler
7889only warns for functions visible in other compilation units or (in the case of
7890@code{pure} and @code{const}) if it cannot prove that the function returns
7891normally. A function returns normally if it doesn't contain an infinite loop or
7892return abnormally by throwing, calling @code{abort} or trapping. This analysis
7893requires option @option{-fipa-pure-const}, which is enabled by default at
7894@option{-O} and higher. Higher optimization levels improve the accuracy
7895of the analysis.
7896
7897@item -Wsuggest-attribute=format
7898@itemx -Wmissing-format-attribute
7899@opindex Wsuggest-attribute=format
7900@opindex Wmissing-format-attribute
7901@opindex Wno-suggest-attribute=format
7902@opindex Wno-missing-format-attribute
7903@opindex Wformat
7904@opindex Wno-format
7905
7906Warn about function pointers that might be candidates for @code{format}
7907attributes. Note these are only possible candidates, not absolute ones.
7908GCC guesses that function pointers with @code{format} attributes that
7909are used in assignment, initialization, parameter passing or return
7910statements should have a corresponding @code{format} attribute in the
7911resulting type. I.e.@: the left-hand side of the assignment or
7912initialization, the type of the parameter variable, or the return type
7913of the containing function respectively should also have a @code{format}
7914attribute to avoid the warning.
7915
7916GCC also warns about function definitions that might be
7917candidates for @code{format} attributes. Again, these are only
7918possible candidates. GCC guesses that @code{format} attributes
7919might be appropriate for any function that calls a function like
7920@code{vprintf} or @code{vscanf}, but this might not always be the
7921case, and some functions for which @code{format} attributes are
7922appropriate may not be detected.
7923
7924@item -Wsuggest-attribute=cold
7925@opindex Wsuggest-attribute=cold
7926@opindex Wno-suggest-attribute=cold
7927
7928Warn about functions that might be candidates for @code{cold} attribute. This
7929is based on static detection and generally only warns about functions which
7930always leads to a call to another @code{cold} function such as wrappers of
7931C++ @code{throw} or fatal error reporting functions leading to @code{abort}.
7932@end table
7933
7934@item -Walloc-zero
7935@opindex Wno-alloc-zero
7936@opindex Walloc-zero
7937Warn about calls to allocation functions decorated with attribute
7938@code{alloc_size} that specify zero bytes, including those to the built-in
7939forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc},
7940@code{malloc}, and @code{realloc}. Because the behavior of these functions
7941when called with a zero size differs among implementations (and in the case
7942of @code{realloc} has been deprecated) relying on it may result in subtle
7943portability bugs and should be avoided.
7944
7945@item -Walloc-size-larger-than=@var{byte-size}
7946@opindex Walloc-size-larger-than=
7947@opindex Wno-alloc-size-larger-than
7948Warn about calls to functions decorated with attribute @code{alloc_size}
7949that attempt to allocate objects larger than the specified number of bytes,
7950or where the result of the size computation in an integer type with infinite
7951precision would exceed the value of @samp{PTRDIFF_MAX} on the target.
7952@option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
7953Warnings controlled by the option can be disabled either by specifying
7954@var{byte-size} of @samp{SIZE_MAX} or more or by
7955@option{-Wno-alloc-size-larger-than}.
7956@xref{Function Attributes}.
7957
7958@item -Wno-alloc-size-larger-than
7959@opindex Wno-alloc-size-larger-than
7960Disable @option{-Walloc-size-larger-than=} warnings. The option is
7961equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or
7962larger.
7963
7964@item -Walloca
7965@opindex Wno-alloca
7966@opindex Walloca
7967This option warns on all uses of @code{alloca} in the source.
7968
7969@item -Walloca-larger-than=@var{byte-size}
7970@opindex Walloca-larger-than=
7971@opindex Wno-alloca-larger-than
7972This option warns on calls to @code{alloca} with an integer argument whose
7973value is either zero, or that is not bounded by a controlling predicate
7974that limits its value to at most @var{byte-size}. It also warns for calls
7975to @code{alloca} where the bound value is unknown. Arguments of non-integer
7976types are considered unbounded even if they appear to be constrained to
7977the expected range.
7978
7979For example, a bounded case of @code{alloca} could be:
7980
7981@smallexample
7982void func (size_t n)
7983@{
7984 void *p;
7985 if (n <= 1000)
7986 p = alloca (n);
7987 else
7988 p = malloc (n);
7989 f (p);
7990@}
7991@end smallexample
7992
7993In the above example, passing @code{-Walloca-larger-than=1000} would not
7994issue a warning because the call to @code{alloca} is known to be at most
79951000 bytes. However, if @code{-Walloca-larger-than=500} were passed,
7996the compiler would emit a warning.
7997
7998Unbounded uses, on the other hand, are uses of @code{alloca} with no
7999controlling predicate constraining its integer argument. For example:
8000
8001@smallexample
8002void func ()
8003@{
8004 void *p = alloca (n);
8005 f (p);
8006@}
8007@end smallexample
8008
8009If @code{-Walloca-larger-than=500} were passed, the above would trigger
8010a warning, but this time because of the lack of bounds checking.
8011
8012Note, that even seemingly correct code involving signed integers could
8013cause a warning:
8014
8015@smallexample
8016void func (signed int n)
8017@{
8018 if (n < 500)
8019 @{
8020 p = alloca (n);
8021 f (p);
8022 @}
8023@}
8024@end smallexample
8025
8026In the above example, @var{n} could be negative, causing a larger than
8027expected argument to be implicitly cast into the @code{alloca} call.
8028
8029This option also warns when @code{alloca} is used in a loop.
8030
8031@option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default
8032but is usually only effective when @option{-ftree-vrp} is active (default
8033for @option{-O2} and above).
8034
8035See also @option{-Wvla-larger-than=}@samp{byte-size}.
8036
8037@item -Wno-alloca-larger-than
8038@opindex Wno-alloca-larger-than
8039Disable @option{-Walloca-larger-than=} warnings. The option is
8040equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger.
8041
8042@item -Warith-conversion
8043@opindex Warith-conversion
8044@opindex Wno-arith-conversion
8045Do warn about implicit conversions from arithmetic operations even
8046when conversion of the operands to the same type cannot change their
8047values. This affects warnings from @option{-Wconversion},
8048@option{-Wfloat-conversion}, and @option{-Wsign-conversion}.
8049
8050@smallexample
8051@group
8052void f (char c, int i)
8053@{
8054 c = c + i; // warns with @option{-Wconversion}
8055 c = c + 1; // only warns with @option{-Warith-conversion}
8056@}
8057@end group
8058@end smallexample
8059
8060@item -Warray-bounds
8061@itemx -Warray-bounds=@var{n}
8062@opindex Wno-array-bounds
8063@opindex Warray-bounds
8064Warn about out of bounds subscripts or offsets into arrays. This warning
8065is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp}
8066is active (the default for @option{-O2} and above) but a subset of instances
8067are issued even without optimization.
8068
710c9676
QZ
8069By default, the trailing array of a structure will be treated as a flexible
8070array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}}
8071if it is declared as either a flexible array member per C99 standard onwards
8072(@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element
8073array (@samp{[1]}). As a result, out of bounds subscripts or offsets into
8074zero-length arrays or one-element arrays are not warned by default.
8075
8076You can add the option @option{-fstrict-flex-arrays} or
8077@option{-fstrict-flex-arrays=@var{level}} to control how this
8078option treat trailing array of a structure as a flexible array member:
8079
8080when @var{level}<=1, no change to the default behavior.
8081
8082when @var{level}=2, additional warnings will be issued for out of bounds
8083subscripts or offsets into one-element arrays;
8084
8085when @var{level}=3, in addition to @var{level}=2, additional warnings will be
8086issued for out of bounds subscripts or offsets into zero-length arrays.
8087
d77de738
ML
8088@table @gcctabopt
8089@item -Warray-bounds=1
8090This is the default warning level of @option{-Warray-bounds} and is enabled
8091by @option{-Wall}; higher levels are not, and must be explicitly requested.
8092
8093@item -Warray-bounds=2
710c9676
QZ
8094This warning level also warns about the intermediate results of pointer
8095arithmetic that may yield out of bounds values. This warning level may
8096give a larger number of false positives and is deactivated by default.
d77de738
ML
8097@end table
8098
8099@item -Warray-compare
8100@opindex Warray-compare
8101@opindex Wno-array-compare
8102Warn about equality and relational comparisons between two operands of array
8103type. This comparison was deprecated in C++20. For example:
8104
8105@smallexample
8106int arr1[5];
8107int arr2[5];
8108bool same = arr1 == arr2;
8109@end smallexample
8110
8111@option{-Warray-compare} is enabled by @option{-Wall}.
8112
8113@item -Warray-parameter
8114@itemx -Warray-parameter=@var{n}
8115@opindex Wno-array-parameter
8116Warn about redeclarations of functions involving arguments of array or
8117pointer types of inconsistent kinds or forms, and enable the detection
8118of out-of-bounds accesses to such parameters by warnings such as
8119@option{-Warray-bounds}.
8120
8121If the first function declaration uses the array form the bound specified
8122in the array is assumed to be the minimum number of elements expected to
8123be provided in calls to the function and the maximum number of elements
8124accessed by it. Failing to provide arguments of sufficient size or accessing
8125more than the maximum number of elements may be diagnosed by warnings such
8126as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies
8127involving array parameters declared using the @code{T[static N]} form.
8128
8129For example, the warning triggers for the following redeclarations because
8130the first one allows an array of any size to be passed to @code{f} while
8131the second one with the keyword @code{static} specifies that the array
8132argument must have at least four elements.
8133
8134@smallexample
8135void f (int[static 4]);
8136void f (int[]); // warning (inconsistent array form)
8137
8138void g (void)
8139@{
8140 int *p = (int *)malloc (4);
8141 f (p); // warning (array too small)
8142 @dots{}
8143@}
8144@end smallexample
8145
8146At level 2 the warning also triggers for redeclarations involving any other
8147inconsistency in array or pointer argument forms denoting array sizes.
8148Pointers and arrays of unspecified bound are considered equivalent and do
8149not trigger a warning.
8150
8151@smallexample
8152void g (int*);
8153void g (int[]); // no warning
8154void g (int[8]); // warning (inconsistent array bound)
8155@end smallexample
8156
8157@option{-Warray-parameter=2} is included in @option{-Wall}. The
8158@option{-Wvla-parameter} option triggers warnings for similar inconsistencies
8159involving Variable Length Array arguments.
8160
8161@item -Wattribute-alias=@var{n}
8162@itemx -Wno-attribute-alias
8163@opindex Wattribute-alias
8164@opindex Wno-attribute-alias
8165Warn about declarations using the @code{alias} and similar attributes whose
8166target is incompatible with the type of the alias.
8167@xref{Function Attributes,,Declaring Attributes of Functions}.
8168
8169@table @gcctabopt
8170@item -Wattribute-alias=1
8171The default warning level of the @option{-Wattribute-alias} option diagnoses
8172incompatibilities between the type of the alias declaration and that of its
8173target. Such incompatibilities are typically indicative of bugs.
8174
8175@item -Wattribute-alias=2
8176
8177At this level @option{-Wattribute-alias} also diagnoses cases where
8178the attributes of the alias declaration are more restrictive than the
8179attributes applied to its target. These mismatches can potentially
8180result in incorrect code generation. In other cases they may be
8181benign and could be resolved simply by adding the missing attribute to
8182the target. For comparison, see the @option{-Wmissing-attributes}
8183option, which controls diagnostics when the alias declaration is less
8184restrictive than the target, rather than more restrictive.
8185
8186Attributes considered include @code{alloc_align}, @code{alloc_size},
8187@code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc},
8188@code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure},
8189@code{returns_nonnull}, and @code{returns_twice}.
8190@end table
8191
8192@option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}.
8193This is the default. You can disable these warnings with either
8194@option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}.
8195
8196@item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]}
8197@opindex Wbidi-chars=
8198@opindex Wbidi-chars
8199@opindex Wno-bidi-chars
8200Warn about possibly misleading UTF-8 bidirectional control characters in
8201comments, string literals, character constants, and identifiers. Such
8202characters can change left-to-right writing direction into right-to-left
8203(and vice versa), which can cause confusion between the logical order and
8204visual order. This may be dangerous; for instance, it may seem that a piece
8205of code is not commented out, whereas it in fact is.
8206
8207There are three levels of warning supported by GCC@. The default is
8208@option{-Wbidi-chars=unpaired}, which warns about improperly terminated
8209bidi contexts. @option{-Wbidi-chars=none} turns the warning off.
8210@option{-Wbidi-chars=any} warns about any use of bidirectional control
8211characters.
8212
8213By default, this warning does not warn about UCNs. It is, however, possible
8214to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or
8215@option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid,
8216and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous
8217@option{-Wbidi-chars=any} was specified.
8218
8219@item -Wbool-compare
8220@opindex Wno-bool-compare
8221@opindex Wbool-compare
8222Warn about boolean expression compared with an integer value different from
8223@code{true}/@code{false}. For instance, the following comparison is
8224always false:
8225@smallexample
8226int n = 5;
8227@dots{}
8228if ((n > 1) == 2) @{ @dots{} @}
8229@end smallexample
8230This warning is enabled by @option{-Wall}.
8231
8232@item -Wbool-operation
8233@opindex Wno-bool-operation
8234@opindex Wbool-operation
8235Warn about suspicious operations on expressions of a boolean type. For
8236instance, bitwise negation of a boolean is very likely a bug in the program.
8237For C, this warning also warns about incrementing or decrementing a boolean,
8238which rarely makes sense. (In C++, decrementing a boolean is always invalid.
8239Incrementing a boolean is invalid in C++17, and deprecated otherwise.)
8240
8241This warning is enabled by @option{-Wall}.
8242
8243@item -Wduplicated-branches
8244@opindex Wno-duplicated-branches
8245@opindex Wduplicated-branches
8246Warn when an if-else has identical branches. This warning detects cases like
8247@smallexample
8248if (p != NULL)
8249 return 0;
8250else
8251 return 0;
8252@end smallexample
8253It doesn't warn when both branches contain just a null statement. This warning
8254also warn for conditional operators:
8255@smallexample
8256 int i = x ? *p : *p;
8257@end smallexample
8258
8259@item -Wduplicated-cond
8260@opindex Wno-duplicated-cond
8261@opindex Wduplicated-cond
8262Warn about duplicated conditions in an if-else-if chain. For instance,
8263warn for the following code:
8264@smallexample
8265if (p->q != NULL) @{ @dots{} @}
8266else if (p->q != NULL) @{ @dots{} @}
8267@end smallexample
8268
8269@item -Wframe-address
8270@opindex Wno-frame-address
8271@opindex Wframe-address
8272Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address}
8273is called with an argument greater than 0. Such calls may return indeterminate
8274values or crash the program. The warning is included in @option{-Wall}.
8275
8276@item -Wno-discarded-qualifiers @r{(C and Objective-C only)}
8277@opindex Wno-discarded-qualifiers
8278@opindex Wdiscarded-qualifiers
8279Do not warn if type qualifiers on pointers are being discarded.
8280Typically, the compiler warns if a @code{const char *} variable is
8281passed to a function that takes a @code{char *} parameter. This option
8282can be used to suppress such a warning.
8283
8284@item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)}
8285@opindex Wno-discarded-array-qualifiers
8286@opindex Wdiscarded-array-qualifiers
8287Do not warn if type qualifiers on arrays which are pointer targets
8288are being discarded. Typically, the compiler warns if a
8289@code{const int (*)[]} variable is passed to a function that
8290takes a @code{int (*)[]} parameter. This option can be used to
8291suppress such a warning.
8292
8293@item -Wno-incompatible-pointer-types @r{(C and Objective-C only)}
8294@opindex Wno-incompatible-pointer-types
8295@opindex Wincompatible-pointer-types
8296Do not warn when there is a conversion between pointers that have incompatible
8297types. This warning is for cases not covered by @option{-Wno-pointer-sign},
8298which warns for pointer argument passing or assignment with different
8299signedness.
8300
8301@item -Wno-int-conversion @r{(C and Objective-C only)}
8302@opindex Wno-int-conversion
8303@opindex Wint-conversion
8304Do not warn about incompatible integer to pointer and pointer to integer
8305conversions. This warning is about implicit conversions; for explicit
8306conversions the warnings @option{-Wno-int-to-pointer-cast} and
8307@option{-Wno-pointer-to-int-cast} may be used.
8308
8309@item -Wzero-length-bounds
8310@opindex Wzero-length-bounds
8311@opindex Wzero-length-bounds
8312Warn about accesses to elements of zero-length array members that might
8313overlap other members of the same object. Declaring interior zero-length
8314arrays is discouraged because accesses to them are undefined. See
8315@xref{Zero Length}.
8316
8317For example, the first two stores in function @code{bad} are diagnosed
8318because the array elements overlap the subsequent members @code{b} and
8319@code{c}. The third store is diagnosed by @option{-Warray-bounds}
8320because it is beyond the bounds of the enclosing object.
8321
8322@smallexample
8323struct X @{ int a[0]; int b, c; @};
8324struct X x;
8325
8326void bad (void)
8327@{
8328 x.a[0] = 0; // -Wzero-length-bounds
8329 x.a[1] = 1; // -Wzero-length-bounds
8330 x.a[2] = 2; // -Warray-bounds
8331@}
8332@end smallexample
8333
8334Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}.
8335
8336@item -Wno-div-by-zero
8337@opindex Wno-div-by-zero
8338@opindex Wdiv-by-zero
8339Do not warn about compile-time integer division by zero. Floating-point
8340division by zero is not warned about, as it can be a legitimate way of
8341obtaining infinities and NaNs.
8342
8343@item -Wsystem-headers
8344@opindex Wsystem-headers
8345@opindex Wno-system-headers
8346@cindex warnings from system headers
8347@cindex system headers, warnings from
8348Print warning messages for constructs found in system header files.
8349Warnings from system headers are normally suppressed, on the assumption
8350that they usually do not indicate real problems and would only make the
8351compiler output harder to read. Using this command-line option tells
8352GCC to emit warnings from system headers as if they occurred in user
8353code. However, note that using @option{-Wall} in conjunction with this
8354option does @emph{not} warn about unknown pragmas in system
8355headers---for that, @option{-Wunknown-pragmas} must also be used.
8356
8357@item -Wtautological-compare
8358@opindex Wtautological-compare
8359@opindex Wno-tautological-compare
8360Warn if a self-comparison always evaluates to true or false. This
8361warning detects various mistakes such as:
8362@smallexample
8363int i = 1;
8364@dots{}
8365if (i > i) @{ @dots{} @}
8366@end smallexample
8367
8368This warning also warns about bitwise comparisons that always evaluate
8369to true or false, for instance:
8370@smallexample
8371if ((a & 16) == 10) @{ @dots{} @}
8372@end smallexample
8373will always be false.
8374
8375This warning is enabled by @option{-Wall}.
8376
8377@item -Wtrampolines
8378@opindex Wtrampolines
8379@opindex Wno-trampolines
8380Warn about trampolines generated for pointers to nested functions.
8381A trampoline is a small piece of data or code that is created at run
8382time on the stack when the address of a nested function is taken, and is
8383used to call the nested function indirectly. For some targets, it is
8384made up of data only and thus requires no special treatment. But, for
8385most targets, it is made up of code and thus requires the stack to be
8386made executable in order for the program to work properly.
8387
8388@item -Wfloat-equal
8389@opindex Wfloat-equal
8390@opindex Wno-float-equal
8391Warn if floating-point values are used in equality comparisons.
8392
8393The idea behind this is that sometimes it is convenient (for the
8394programmer) to consider floating-point values as approximations to
8395infinitely precise real numbers. If you are doing this, then you need
8396to compute (by analyzing the code, or in some other way) the maximum or
8397likely maximum error that the computation introduces, and allow for it
8398when performing comparisons (and when producing output, but that's a
8399different problem). In particular, instead of testing for equality, you
8400should check to see whether the two values have ranges that overlap; and
8401this is done with the relational operators, so equality comparisons are
8402probably mistaken.
8403
8404@item -Wtraditional @r{(C and Objective-C only)}
8405@opindex Wtraditional
8406@opindex Wno-traditional
8407Warn about certain constructs that behave differently in traditional and
8408ISO C@. Also warn about ISO C constructs that have no traditional C
8409equivalent, and/or problematic constructs that should be avoided.
8410
8411@itemize @bullet
8412@item
8413Macro parameters that appear within string literals in the macro body.
8414In traditional C macro replacement takes place within string literals,
8415but in ISO C it does not.
8416
8417@item
8418In traditional C, some preprocessor directives did not exist.
8419Traditional preprocessors only considered a line to be a directive
8420if the @samp{#} appeared in column 1 on the line. Therefore
8421@option{-Wtraditional} warns about directives that traditional C
8422understands but ignores because the @samp{#} does not appear as the
8423first character on the line. It also suggests you hide directives like
8424@code{#pragma} not understood by traditional C by indenting them. Some
8425traditional implementations do not recognize @code{#elif}, so this option
8426suggests avoiding it altogether.
8427
8428@item
8429A function-like macro that appears without arguments.
8430
8431@item
8432The unary plus operator.
8433
8434@item
8435The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point
8436constant suffixes. (Traditional C does support the @samp{L} suffix on integer
8437constants.) Note, these suffixes appear in macros defined in the system
8438headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
8439Use of these macros in user code might normally lead to spurious
8440warnings, however GCC's integrated preprocessor has enough context to
8441avoid warning in these cases.
8442
8443@item
8444A function declared external in one block and then used after the end of
8445the block.
8446
8447@item
8448A @code{switch} statement has an operand of type @code{long}.
8449
8450@item
8451A non-@code{static} function declaration follows a @code{static} one.
8452This construct is not accepted by some traditional C compilers.
8453
8454@item
8455The ISO type of an integer constant has a different width or
8456signedness from its traditional type. This warning is only issued if
8457the base of the constant is ten. I.e.@: hexadecimal or octal values, which
8458typically represent bit patterns, are not warned about.
8459
8460@item
8461Usage of ISO string concatenation is detected.
8462
8463@item
8464Initialization of automatic aggregates.
8465
8466@item
8467Identifier conflicts with labels. Traditional C lacks a separate
8468namespace for labels.
8469
8470@item
8471Initialization of unions. If the initializer is zero, the warning is
8472omitted. This is done under the assumption that the zero initializer in
8473user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
8474initializer warnings and relies on default initialization to zero in the
8475traditional C case.
8476
8477@item
8478Conversions by prototypes between fixed/floating-point values and vice
8479versa. The absence of these prototypes when compiling with traditional
8480C causes serious problems. This is a subset of the possible
8481conversion warnings; for the full set use @option{-Wtraditional-conversion}.
8482
8483@item
8484Use of ISO C style function definitions. This warning intentionally is
8485@emph{not} issued for prototype declarations or variadic functions
8486because these ISO C features appear in your code when using
8487libiberty's traditional C compatibility macros, @code{PARAMS} and
8488@code{VPARAMS}. This warning is also bypassed for nested functions
8489because that feature is already a GCC extension and thus not relevant to
8490traditional C compatibility.
8491@end itemize
8492
8493@item -Wtraditional-conversion @r{(C and Objective-C only)}
8494@opindex Wtraditional-conversion
8495@opindex Wno-traditional-conversion
8496Warn if a prototype causes a type conversion that is different from what
8497would happen to the same argument in the absence of a prototype. This
8498includes conversions of fixed point to floating and vice versa, and
8499conversions changing the width or signedness of a fixed-point argument
8500except when the same as the default promotion.
8501
8502@item -Wdeclaration-after-statement @r{(C and Objective-C only)}
8503@opindex Wdeclaration-after-statement
8504@opindex Wno-declaration-after-statement
8505Warn when a declaration is found after a statement in a block. This
8506construct, known from C++, was introduced with ISO C99 and is by default
8507allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}.
8508
8509@item -Wshadow
8510@opindex Wshadow
8511@opindex Wno-shadow
8512Warn whenever a local variable or type declaration shadows another
8513variable, parameter, type, class member (in C++), or instance variable
8514(in Objective-C) or whenever a built-in function is shadowed. Note
8515that in C++, the compiler warns if a local variable shadows an
8516explicit typedef, but not if it shadows a struct/class/enum.
8517If this warning is enabled, it includes also all instances of
8518local shadowing. This means that @option{-Wno-shadow=local}
8519and @option{-Wno-shadow=compatible-local} are ignored when
8520@option{-Wshadow} is used.
8521Same as @option{-Wshadow=global}.
8522
8523@item -Wno-shadow-ivar @r{(Objective-C only)}
8524@opindex Wno-shadow-ivar
8525@opindex Wshadow-ivar
8526Do not warn whenever a local variable shadows an instance variable in an
8527Objective-C method.
8528
8529@item -Wshadow=global
8530@opindex Wshadow=global
8531Warn for any shadowing.
8532Same as @option{-Wshadow}.
8533
8534@item -Wshadow=local
8535@opindex Wshadow=local
8536Warn when a local variable shadows another local variable or parameter.
8537
8538@item -Wshadow=compatible-local
8539@opindex Wshadow=compatible-local
8540Warn when a local variable shadows another local variable or parameter
8541whose type is compatible with that of the shadowing variable. In C++,
8542type compatibility here means the type of the shadowing variable can be
8543converted to that of the shadowed variable. The creation of this flag
8544(in addition to @option{-Wshadow=local}) is based on the idea that when
8545a local variable shadows another one of incompatible type, it is most
8546likely intentional, not a bug or typo, as shown in the following example:
8547
8548@smallexample
8549@group
8550for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i)
8551@{
8552 for (int i = 0; i < N; ++i)
8553 @{
8554 ...
8555 @}
8556 ...
8557@}
8558@end group
8559@end smallexample
8560
8561Since the two variable @code{i} in the example above have incompatible types,
8562enabling only @option{-Wshadow=compatible-local} does not emit a warning.
8563Because their types are incompatible, if a programmer accidentally uses one
8564in place of the other, type checking is expected to catch that and emit an
8565error or warning. Use of this flag instead of @option{-Wshadow=local} can
8566possibly reduce the number of warnings triggered by intentional shadowing.
8567Note that this also means that shadowing @code{const char *i} by
8568@code{char *i} does not emit a warning.
8569
8570This warning is also enabled by @option{-Wshadow=local}.
8571
8572@item -Wlarger-than=@var{byte-size}
8573@opindex Wlarger-than=
8574@opindex Wlarger-than-@var{byte-size}
8575Warn whenever an object is defined whose size exceeds @var{byte-size}.
8576@option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8577Warnings controlled by the option can be disabled either by specifying
8578@var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}.
8579
8580Also warn for calls to bounded functions such as @code{memchr} or
8581@code{strnlen} that specify a bound greater than the largest possible
8582object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings
8583can only be disabled by @option{-Wno-larger-than}.
8584
8585@item -Wno-larger-than
8586@opindex Wno-larger-than
8587Disable @option{-Wlarger-than=} warnings. The option is equivalent
8588to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger.
8589
8590@item -Wframe-larger-than=@var{byte-size}
8591@opindex Wframe-larger-than=
8592@opindex Wno-frame-larger-than
8593Warn if the size of a function frame exceeds @var{byte-size}.
8594The computation done to determine the stack frame size is approximate
8595and not conservative.
8596The actual requirements may be somewhat greater than @var{byte-size}
8597even if you do not get a warning. In addition, any space allocated
8598via @code{alloca}, variable-length arrays, or related constructs
8599is not included by the compiler when determining
8600whether or not to issue a warning.
8601@option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default.
8602Warnings controlled by the option can be disabled either by specifying
8603@var{byte-size} of @samp{SIZE_MAX} or more or by
8604@option{-Wno-frame-larger-than}.
8605
8606@item -Wno-frame-larger-than
8607@opindex Wno-frame-larger-than
8608Disable @option{-Wframe-larger-than=} warnings. The option is equivalent
8609to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger.
8610
8611@item -Wfree-nonheap-object
8612@opindex Wfree-nonheap-object
8613@opindex Wno-free-nonheap-object
8614Warn when attempting to deallocate an object that was either not allocated
8615on the heap, or by using a pointer that was not returned from a prior call
8616to the corresponding allocation function. For example, because the call
8617to @code{stpcpy} returns a pointer to the terminating nul character and
8618not to the beginning of the object, the call to @code{free} below is
8619diagnosed.
8620
8621@smallexample
8622void f (char *p)
8623@{
8624 p = stpcpy (p, "abc");
8625 // ...
8626 free (p); // warning
8627@}
8628@end smallexample
8629
8630@option{-Wfree-nonheap-object} is included in @option{-Wall}.
8631
8632@item -Wstack-usage=@var{byte-size}
8633@opindex Wstack-usage
8634@opindex Wno-stack-usage
8635Warn if the stack usage of a function might exceed @var{byte-size}.
8636The computation done to determine the stack usage is conservative.
8637Any space allocated via @code{alloca}, variable-length arrays, or related
8638constructs is included by the compiler when determining whether or not to
8639issue a warning.
8640
8641The message is in keeping with the output of @option{-fstack-usage}.
8642
8643@itemize
8644@item
8645If the stack usage is fully static but exceeds the specified amount, it's:
8646
8647@smallexample
8648 warning: stack usage is 1120 bytes
8649@end smallexample
8650@item
8651If the stack usage is (partly) dynamic but bounded, it's:
8652
8653@smallexample
8654 warning: stack usage might be 1648 bytes
8655@end smallexample
8656@item
8657If the stack usage is (partly) dynamic and not bounded, it's:
8658
8659@smallexample
8660 warning: stack usage might be unbounded
8661@end smallexample
8662@end itemize
8663
8664@option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default.
8665Warnings controlled by the option can be disabled either by specifying
8666@var{byte-size} of @samp{SIZE_MAX} or more or by
8667@option{-Wno-stack-usage}.
8668
8669@item -Wno-stack-usage
8670@opindex Wno-stack-usage
8671Disable @option{-Wstack-usage=} warnings. The option is equivalent
8672to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger.
8673
8674@item -Wunsafe-loop-optimizations
8675@opindex Wunsafe-loop-optimizations
8676@opindex Wno-unsafe-loop-optimizations
8677Warn if the loop cannot be optimized because the compiler cannot
8678assume anything on the bounds of the loop indices. With
8679@option{-funsafe-loop-optimizations} warn if the compiler makes
8680such assumptions.
8681
8682@item -Wno-pedantic-ms-format @r{(MinGW targets only)}
8683@opindex Wno-pedantic-ms-format
8684@opindex Wpedantic-ms-format
8685When used in combination with @option{-Wformat}
8686and @option{-pedantic} without GNU extensions, this option
8687disables the warnings about non-ISO @code{printf} / @code{scanf} format
8688width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets,
8689which depend on the MS runtime.
8690
8691@item -Wpointer-arith
8692@opindex Wpointer-arith
8693@opindex Wno-pointer-arith
8694Warn about anything that depends on the ``size of'' a function type or
8695of @code{void}. GNU C assigns these types a size of 1, for
8696convenience in calculations with @code{void *} pointers and pointers
8697to functions. In C++, warn also when an arithmetic operation involves
8698@code{NULL}. This warning is also enabled by @option{-Wpedantic}.
8699
8700@item -Wno-pointer-compare
8701@opindex Wpointer-compare
8702@opindex Wno-pointer-compare
8703Do not warn if a pointer is compared with a zero character constant.
8704This usually
8705means that the pointer was meant to be dereferenced. For example:
8706
8707@smallexample
8708const char *p = foo ();
8709if (p == '\0')
8710 return 42;
8711@end smallexample
8712
8713Note that the code above is invalid in C++11.
8714
8715This warning is enabled by default.
8716
8717@item -Wtsan
8718@opindex Wtsan
8719@opindex Wno-tsan
8720Warn about unsupported features in ThreadSanitizer.
8721
8722ThreadSanitizer does not support @code{std::atomic_thread_fence} and
8723can report false positives.
8724
8725This warning is enabled by default.
8726
8727@item -Wtype-limits
8728@opindex Wtype-limits
8729@opindex Wno-type-limits
8730Warn if a comparison is always true or always false due to the limited
8731range of the data type, but do not warn for constant expressions. For
8732example, warn if an unsigned variable is compared against zero with
8733@code{<} or @code{>=}. This warning is also enabled by
8734@option{-Wextra}.
8735
8736@item -Wabsolute-value @r{(C and Objective-C only)}
8737@opindex Wabsolute-value
8738@opindex Wno-absolute-value
8739Warn for calls to standard functions that compute the absolute value
8740of an argument when a more appropriate standard function is available.
8741For example, calling @code{abs(3.14)} triggers the warning because the
8742appropriate function to call to compute the absolute value of a double
8743argument is @code{fabs}. The option also triggers warnings when the
8744argument in a call to such a function has an unsigned type. This
8745warning can be suppressed with an explicit type cast and it is also
8746enabled by @option{-Wextra}.
8747
8748@include cppwarnopts.texi
8749
8750@item -Wbad-function-cast @r{(C and Objective-C only)}
8751@opindex Wbad-function-cast
8752@opindex Wno-bad-function-cast
8753Warn when a function call is cast to a non-matching type.
8754For example, warn if a call to a function returning an integer type
8755is cast to a pointer type.
8756
8757@item -Wc90-c99-compat @r{(C and Objective-C only)}
8758@opindex Wc90-c99-compat
8759@opindex Wno-c90-c99-compat
8760Warn about features not present in ISO C90, but present in ISO C99.
8761For instance, warn about use of variable length arrays, @code{long long}
8762type, @code{bool} type, compound literals, designated initializers, and so
8763on. This option is independent of the standards mode. Warnings are disabled
8764in the expression that follows @code{__extension__}.
8765
8766@item -Wc99-c11-compat @r{(C and Objective-C only)}
8767@opindex Wc99-c11-compat
8768@opindex Wno-c99-c11-compat
8769Warn about features not present in ISO C99, but present in ISO C11.
8770For instance, warn about use of anonymous structures and unions,
8771@code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier,
8772@code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword,
8773and so on. This option is independent of the standards mode. Warnings are
8774disabled in the expression that follows @code{__extension__}.
8775
8776@item -Wc11-c2x-compat @r{(C and Objective-C only)}
8777@opindex Wc11-c2x-compat
8778@opindex Wno-c11-c2x-compat
8779Warn about features not present in ISO C11, but present in ISO C2X.
8780For instance, warn about omitting the string in @code{_Static_assert},
8781use of @samp{[[]]} syntax for attributes, use of decimal
8782floating-point types, and so on. This option is independent of the
8783standards mode. Warnings are disabled in the expression that follows
8784@code{__extension__}.
8785
8786@item -Wc++-compat @r{(C and Objective-C only)}
8787@opindex Wc++-compat
8788@opindex Wno-c++-compat
8789Warn about ISO C constructs that are outside of the common subset of
8790ISO C and ISO C++, e.g.@: request for implicit conversion from
8791@code{void *} to a pointer to non-@code{void} type.
8792
8793@item -Wc++11-compat @r{(C++ and Objective-C++ only)}
8794@opindex Wc++11-compat
8795@opindex Wno-c++11-compat
8796Warn about C++ constructs whose meaning differs between ISO C++ 1998
8797and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords
8798in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is
8799enabled by @option{-Wall}.
8800
8801@item -Wc++14-compat @r{(C++ and Objective-C++ only)}
8802@opindex Wc++14-compat
8803@opindex Wno-c++14-compat
8804Warn about C++ constructs whose meaning differs between ISO C++ 2011
8805and ISO C++ 2014. This warning is enabled by @option{-Wall}.
8806
8807@item -Wc++17-compat @r{(C++ and Objective-C++ only)}
8808@opindex Wc++17-compat
8809@opindex Wno-c++17-compat
8810Warn about C++ constructs whose meaning differs between ISO C++ 2014
8811and ISO C++ 2017. This warning is enabled by @option{-Wall}.
8812
8813@item -Wc++20-compat @r{(C++ and Objective-C++ only)}
8814@opindex Wc++20-compat
8815@opindex Wno-c++20-compat
8816Warn about C++ constructs whose meaning differs between ISO C++ 2017
8817and ISO C++ 2020. This warning is enabled by @option{-Wall}.
8818
8819@item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)}
8820@opindex Wc++11-extensions
8821@opindex Wno-c++11-extensions
8822Do not warn about C++11 constructs in code being compiled using
8823an older C++ standard. Even without this option, some C++11 constructs
8824will only be diagnosed if @option{-Wpedantic} is used.
8825
8826@item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)}
8827@opindex Wc++14-extensions
8828@opindex Wno-c++14-extensions
8829Do not warn about C++14 constructs in code being compiled using
8830an older C++ standard. Even without this option, some C++14 constructs
8831will only be diagnosed if @option{-Wpedantic} is used.
8832
8833@item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)}
8834@opindex Wc++17-extensions
8835@opindex Wno-c++17-extensions
8836Do not warn about C++17 constructs in code being compiled using
8837an older C++ standard. Even without this option, some C++17 constructs
8838will only be diagnosed if @option{-Wpedantic} is used.
8839
8840@item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)}
8841@opindex Wc++20-extensions
8842@opindex Wno-c++20-extensions
8843Do not warn about C++20 constructs in code being compiled using
8844an older C++ standard. Even without this option, some C++20 constructs
8845will only be diagnosed if @option{-Wpedantic} is used.
8846
8847@item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)}
8848@opindex Wc++23-extensions
8849@opindex Wno-c++23-extensions
8850Do not warn about C++23 constructs in code being compiled using
8851an older C++ standard. Even without this option, some C++23 constructs
8852will only be diagnosed if @option{-Wpedantic} is used.
8853
8854@item -Wcast-qual
8855@opindex Wcast-qual
8856@opindex Wno-cast-qual
8857Warn whenever a pointer is cast so as to remove a type qualifier from
8858the target type. For example, warn if a @code{const char *} is cast
8859to an ordinary @code{char *}.
8860
8861Also warn when making a cast that introduces a type qualifier in an
8862unsafe way. For example, casting @code{char **} to @code{const char **}
8863is unsafe, as in this example:
8864
8865@smallexample
8866 /* p is char ** value. */
8867 const char **q = (const char **) p;
8868 /* Assignment of readonly string to const char * is OK. */
8869 *q = "string";
8870 /* Now char** pointer points to read-only memory. */
8871 **p = 'b';
8872@end smallexample
8873
8874@item -Wcast-align
8875@opindex Wcast-align
8876@opindex Wno-cast-align
8877Warn whenever a pointer is cast such that the required alignment of the
8878target is increased. For example, warn if a @code{char *} is cast to
8879an @code{int *} on machines where integers can only be accessed at
8880two- or four-byte boundaries.
8881
8882@item -Wcast-align=strict
8883@opindex Wcast-align=strict
8884Warn whenever a pointer is cast such that the required alignment of the
8885target is increased. For example, warn if a @code{char *} is cast to
8886an @code{int *} regardless of the target machine.
8887
8888@item -Wcast-function-type
8889@opindex Wcast-function-type
8890@opindex Wno-cast-function-type
8891Warn when a function pointer is cast to an incompatible function pointer.
8892In a cast involving function types with a variable argument list only
8893the types of initial arguments that are provided are considered.
8894Any parameter of pointer-type matches any other pointer-type. Any benign
8895differences in integral types are ignored, like @code{int} vs.@: @code{long}
8896on ILP32 targets. Likewise type qualifiers are ignored. The function
8897type @code{void (*) (void)} is special and matches everything, which can
8898be used to suppress this warning.
8899In a cast involving pointer to member types this warning warns whenever
8900the type cast is changing the pointer to member type.
8901This warning is enabled by @option{-Wextra}.
8902
8903@item -Wwrite-strings
8904@opindex Wwrite-strings
8905@opindex Wno-write-strings
8906When compiling C, give string constants the type @code{const
8907char[@var{length}]} so that copying the address of one into a
8908non-@code{const} @code{char *} pointer produces a warning. These
8909warnings help you find at compile time code that can try to write
8910into a string constant, but only if you have been very careful about
8911using @code{const} in declarations and prototypes. Otherwise, it is
8912just a nuisance. This is why we did not make @option{-Wall} request
8913these warnings.
8914
8915When compiling C++, warn about the deprecated conversion from string
8916literals to @code{char *}. This warning is enabled by default for C++
8917programs.
8918
8919@item -Wclobbered
8920@opindex Wclobbered
8921@opindex Wno-clobbered
8922Warn for variables that might be changed by @code{longjmp} or
8923@code{vfork}. This warning is also enabled by @option{-Wextra}.
8924
8925@item -Wconversion
8926@opindex Wconversion
8927@opindex Wno-conversion
8928Warn for implicit conversions that may alter a value. This includes
8929conversions between real and integer, like @code{abs (x)} when
8930@code{x} is @code{double}; conversions between signed and unsigned,
8931like @code{unsigned ui = -1}; and conversions to smaller types, like
8932@code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs
8933((int) x)} and @code{ui = (unsigned) -1}, or if the value is not
8934changed by the conversion like in @code{abs (2.0)}. Warnings about
8935conversions between signed and unsigned integers can be disabled by
8936using @option{-Wno-sign-conversion}.
8937
8938For C++, also warn for confusing overload resolution for user-defined
8939conversions; and conversions that never use a type conversion
8940operator: conversions to @code{void}, the same type, a base class or a
8941reference to them. Warnings about conversions between signed and
8942unsigned integers are disabled by default in C++ unless
8943@option{-Wsign-conversion} is explicitly enabled.
8944
8945Warnings about conversion from arithmetic on a small type back to that
8946type are only given with @option{-Warith-conversion}.
8947
8948@item -Wdangling-else
8949@opindex Wdangling-else
8950@opindex Wno-dangling-else
8951Warn about constructions where there may be confusion to which
8952@code{if} statement an @code{else} branch belongs. Here is an example of
8953such a case:
8954
8955@smallexample
8956@group
8957@{
8958 if (a)
8959 if (b)
8960 foo ();
8961 else
8962 bar ();
8963@}
8964@end group
8965@end smallexample
8966
8967In C/C++, every @code{else} branch belongs to the innermost possible
8968@code{if} statement, which in this example is @code{if (b)}. This is
8969often not what the programmer expected, as illustrated in the above
8970example by indentation the programmer chose. When there is the
8971potential for this confusion, GCC issues a warning when this flag
8972is specified. To eliminate the warning, add explicit braces around
8973the innermost @code{if} statement so there is no way the @code{else}
8974can belong to the enclosing @code{if}. The resulting code
8975looks like this:
8976
8977@smallexample
8978@group
8979@{
8980 if (a)
8981 @{
8982 if (b)
8983 foo ();
8984 else
8985 bar ();
8986 @}
8987@}
8988@end group
8989@end smallexample
8990
8991This warning is enabled by @option{-Wparentheses}.
8992
8993@item -Wdangling-pointer
8994@itemx -Wdangling-pointer=@var{n}
8995@opindex Wdangling-pointer
8996@opindex Wno-dangling-pointer
8997Warn about uses of pointers (or C++ references) to objects with automatic
8998storage duration after their lifetime has ended. This includes local
8999variables declared in nested blocks, compound literals and other unnamed
9000temporary objects. In addition, warn about storing the address of such
9001objects in escaped pointers. The warning is enabled at all optimization
9002levels but may yield different results with optimization than without.
9003
9004@table @gcctabopt
9005@item -Wdangling-pointer=1
9006At level 1 the warning diagnoses only unconditional uses of dangling pointers.
9007For example
9008@smallexample
9009int f (int c1, int c2, x)
9010@{
9011 char *p = strchr ((char[])@{ c1, c2 @}, c3);
9012 return p ? *p : 'x'; // warning: dangling pointer to a compound literal
9013@}
9014@end smallexample
9015In the following function the store of the address of the local variable
9016@code{x} in the escaped pointer @code{*p} also triggers the warning.
9017@smallexample
9018void g (int **p)
9019@{
9020 int x = 7;
9021 *p = &x; // warning: storing the address of a local variable in *p
9022@}
9023@end smallexample
9024
9025@item -Wdangling-pointer=2
9026At level 2, in addition to unconditional uses the warning also diagnoses
9027conditional uses of dangling pointers.
9028
9029For example, because the array @var{a} in the following function is out of
9030scope when the pointer @var{s} that was set to point is used, the warning
9031triggers at this level.
9032
9033@smallexample
9034void f (char *s)
9035@{
9036 if (!s)
9037 @{
9038 char a[12] = "tmpname";
9039 s = a;
9040 @}
9041 strcat (s, ".tmp"); // warning: dangling pointer to a may be used
9042 ...
9043@}
9044@end smallexample
9045@end table
9046
9047@option{-Wdangling-pointer=2} is included in @option{-Wall}.
9048
9049@item -Wdate-time
9050@opindex Wdate-time
9051@opindex Wno-date-time
9052Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__}
9053are encountered as they might prevent bit-wise-identical reproducible
9054compilations.
9055
9056@item -Wempty-body
9057@opindex Wempty-body
9058@opindex Wno-empty-body
9059Warn if an empty body occurs in an @code{if}, @code{else} or @code{do
9060while} statement. This warning is also enabled by @option{-Wextra}.
9061
9062@item -Wno-endif-labels
9063@opindex Wendif-labels
9064@opindex Wno-endif-labels
9065Do not warn about stray tokens after @code{#else} and @code{#endif}.
9066
9067@item -Wenum-compare
9068@opindex Wenum-compare
9069@opindex Wno-enum-compare
9070Warn about a comparison between values of different enumerated types.
9071In C++ enumerated type mismatches in conditional expressions are also
9072diagnosed and the warning is enabled by default. In C this warning is
9073enabled by @option{-Wall}.
9074
9075@item -Wenum-conversion
9076@opindex Wenum-conversion
9077@opindex Wno-enum-conversion
9078Warn when a value of enumerated type is implicitly converted to a
9079different enumerated type. This warning is enabled by @option{-Wextra}
9080in C@.
9081
9082@item -Wenum-int-mismatch @r{(C and Objective-C only)}
9083@opindex Wenum-int-mismatch
9084@opindex Wno-enum-int-mismatch
9085Warn about mismatches between an enumerated type and an integer type in
9086declarations. For example:
9087
9088@smallexample
9089enum E @{ l = -1, z = 0, g = 1 @};
9090int foo(void);
9091enum E foo(void);
9092@end smallexample
9093
9094In C, an enumerated type is compatible with @code{char}, a signed
9095integer type, or an unsigned integer type. However, since the choice
9096of the underlying type of an enumerated type is implementation-defined,
9097such mismatches may cause portability issues. In C++, such mismatches
9098are an error. In C, this warning is enabled by @option{-Wall} and
9099@option{-Wc++-compat}.
9100
9101@item -Wjump-misses-init @r{(C, Objective-C only)}
9102@opindex Wjump-misses-init
9103@opindex Wno-jump-misses-init
9104Warn if a @code{goto} statement or a @code{switch} statement jumps
9105forward across the initialization of a variable, or jumps backward to a
9106label after the variable has been initialized. This only warns about
9107variables that are initialized when they are declared. This warning is
9108only supported for C and Objective-C; in C++ this sort of branch is an
9109error in any case.
9110
9111@option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It
9112can be disabled with the @option{-Wno-jump-misses-init} option.
9113
9114@item -Wsign-compare
9115@opindex Wsign-compare
9116@opindex Wno-sign-compare
9117@cindex warning for comparison of signed and unsigned values
9118@cindex comparison of signed and unsigned values, warning
9119@cindex signed and unsigned values, comparison warning
9120Warn when a comparison between signed and unsigned values could produce
9121an incorrect result when the signed value is converted to unsigned.
9122In C++, this warning is also enabled by @option{-Wall}. In C, it is
9123also enabled by @option{-Wextra}.
9124
9125@item -Wsign-conversion
9126@opindex Wsign-conversion
9127@opindex Wno-sign-conversion
9128Warn for implicit conversions that may change the sign of an integer
9129value, like assigning a signed integer expression to an unsigned
9130integer variable. An explicit cast silences the warning. In C, this
9131option is enabled also by @option{-Wconversion}.
9132
9133@item -Wfloat-conversion
9134@opindex Wfloat-conversion
9135@opindex Wno-float-conversion
9136Warn for implicit conversions that reduce the precision of a real value.
9137This includes conversions from real to integer, and from higher precision
9138real to lower precision real values. This option is also enabled by
9139@option{-Wconversion}.
9140
9141@item -Wno-scalar-storage-order
9142@opindex Wno-scalar-storage-order
9143@opindex Wscalar-storage-order
9144Do not warn on suspicious constructs involving reverse scalar storage order.
9145
9146@item -Wsizeof-array-div
9147@opindex Wsizeof-array-div
9148@opindex Wno-sizeof-array-div
9149Warn about divisions of two sizeof operators when the first one is applied
9150to an array and the divisor does not equal the size of the array element.
9151In such a case, the computation will not yield the number of elements in the
9152array, which is likely what the user intended. This warning warns e.g. about
9153@smallexample
9154int fn ()
9155@{
9156 int arr[10];
9157 return sizeof (arr) / sizeof (short);
9158@}
9159@end smallexample
9160
9161This warning is enabled by @option{-Wall}.
9162
9163@item -Wsizeof-pointer-div
9164@opindex Wsizeof-pointer-div
9165@opindex Wno-sizeof-pointer-div
9166Warn for suspicious divisions of two sizeof expressions that divide
9167the pointer size by the element size, which is the usual way to compute
9168the array size but won't work out correctly with pointers. This warning
9169warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is
9170not an array, but a pointer. This warning is enabled by @option{-Wall}.
9171
9172@item -Wsizeof-pointer-memaccess
9173@opindex Wsizeof-pointer-memaccess
9174@opindex Wno-sizeof-pointer-memaccess
9175Warn for suspicious length parameters to certain string and memory built-in
9176functions if the argument uses @code{sizeof}. This warning triggers for
9177example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not
9178an array, but a pointer, and suggests a possible fix, or about
9179@code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess}
9180also warns about calls to bounded string copy functions like @code{strncat}
9181or @code{strncpy} that specify as the bound a @code{sizeof} expression of
9182the source array. For example, in the following function the call to
9183@code{strncat} specifies the size of the source string as the bound. That
9184is almost certainly a mistake and so the call is diagnosed.
9185@smallexample
9186void make_file (const char *name)
9187@{
9188 char path[PATH_MAX];
9189 strncpy (path, name, sizeof path - 1);
9190 strncat (path, ".text", sizeof ".text");
9191 @dots{}
9192@}
9193@end smallexample
9194
9195The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}.
9196
9197@item -Wno-sizeof-array-argument
9198@opindex Wsizeof-array-argument
9199@opindex Wno-sizeof-array-argument
9200Do not warn when the @code{sizeof} operator is applied to a parameter that is
9201declared as an array in a function definition. This warning is enabled by
9202default for C and C++ programs.
9203
9204@item -Wmemset-elt-size
9205@opindex Wmemset-elt-size
9206@opindex Wno-memset-elt-size
9207Warn for suspicious calls to the @code{memset} built-in function, if the
9208first argument references an array, and the third argument is a number
9209equal to the number of elements, but not equal to the size of the array
9210in memory. This indicates that the user has omitted a multiplication by
9211the element size. This warning is enabled by @option{-Wall}.
9212
9213@item -Wmemset-transposed-args
9214@opindex Wmemset-transposed-args
9215@opindex Wno-memset-transposed-args
9216Warn for suspicious calls to the @code{memset} built-in function where
9217the second argument is not zero and the third argument is zero. For
9218example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because
9219@code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic
9220is only emitted if the third argument is a literal zero. Otherwise, if
9221it is an expression that is folded to zero, or a cast of zero to some
9222type, it is far less likely that the arguments have been mistakenly
9223transposed and no warning is emitted. This warning is enabled
9224by @option{-Wall}.
9225
9226@item -Waddress
9227@opindex Waddress
9228@opindex Wno-address
9229Warn about suspicious uses of address expressions. These include comparing
9230the address of a function or a declared object to the null pointer constant
9231such as in
9232@smallexample
9233void f (void);
9234void g (void)
9235@{
9236 if (!f) // warning: expression evaluates to false
9237 abort ();
9238@}
9239@end smallexample
9240comparisons of a pointer to a string literal, such as in
9241@smallexample
9242void f (const char *x)
9243@{
9244 if (x == "abc") // warning: expression evaluates to false
9245 puts ("equal");
9246@}
9247@end smallexample
9248and tests of the results of pointer addition or subtraction for equality
9249to null, such as in
9250@smallexample
9251void f (const int *p, int i)
9252@{
9253 return p + i == NULL;
9254@}
9255@end smallexample
9256Such uses typically indicate a programmer error: the address of most
9257functions and objects necessarily evaluates to true (the exception are
9258weak symbols), so their use in a conditional might indicate missing
9259parentheses in a function call or a missing dereference in an array
9260expression. The subset of the warning for object pointers can be
9261suppressed by casting the pointer operand to an integer type such
9262as @code{intptr_t} or @code{uintptr_t}.
9263Comparisons against string literals result in unspecified behavior
9264and are not portable, and suggest the intent was to call @code{strcmp}.
9265The warning is suppressed if the suspicious expression is the result
9266of macro expansion.
9267@option{-Waddress} warning is enabled by @option{-Wall}.
9268
9269@item -Wno-address-of-packed-member
9270@opindex Waddress-of-packed-member
9271@opindex Wno-address-of-packed-member
9272Do not warn when the address of packed member of struct or union is taken,
9273which usually results in an unaligned pointer value. This is
9274enabled by default.
9275
9276@item -Wlogical-op
9277@opindex Wlogical-op
9278@opindex Wno-logical-op
9279Warn about suspicious uses of logical operators in expressions.
9280This includes using logical operators in contexts where a
9281bit-wise operator is likely to be expected. Also warns when
9282the operands of a logical operator are the same:
9283@smallexample
9284extern int a;
9285if (a < 0 && a < 0) @{ @dots{} @}
9286@end smallexample
9287
9288@item -Wlogical-not-parentheses
9289@opindex Wlogical-not-parentheses
9290@opindex Wno-logical-not-parentheses
9291Warn about logical not used on the left hand side operand of a comparison.
9292This option does not warn if the right operand is considered to be a boolean
9293expression. Its purpose is to detect suspicious code like the following:
9294@smallexample
9295int a;
9296@dots{}
9297if (!a > 1) @{ @dots{} @}
9298@end smallexample
9299
9300It is possible to suppress the warning by wrapping the LHS into
9301parentheses:
9302@smallexample
9303if ((!a) > 1) @{ @dots{} @}
9304@end smallexample
9305
9306This warning is enabled by @option{-Wall}.
9307
9308@item -Waggregate-return
9309@opindex Waggregate-return
9310@opindex Wno-aggregate-return
9311Warn if any functions that return structures or unions are defined or
9312called. (In languages where you can return an array, this also elicits
9313a warning.)
9314
9315@item -Wno-aggressive-loop-optimizations
9316@opindex Wno-aggressive-loop-optimizations
9317@opindex Waggressive-loop-optimizations
9318Warn if in a loop with constant number of iterations the compiler detects
9319undefined behavior in some statement during one or more of the iterations.
9320
9321@item -Wno-attributes
9322@opindex Wno-attributes
9323@opindex Wattributes
9324Do not warn if an unexpected @code{__attribute__} is used, such as
9325unrecognized attributes, function attributes applied to variables,
9326etc. This does not stop errors for incorrect use of supported
9327attributes.
9328
9329Additionally, using @option{-Wno-attributes=}, it is possible to suppress
9330warnings about unknown scoped attributes (in C++11 and C2X). For example,
9331@option{-Wno-attributes=vendor::attr} disables warning about the following
9332declaration:
9333
9334@smallexample
9335[[vendor::attr]] void f();
9336@end smallexample
9337
9338It is also possible to disable warning about all attributes in a namespace
9339using @option{-Wno-attributes=vendor::} which prevents warning about both
9340of these declarations:
9341
9342@smallexample
9343[[vendor::safe]] void f();
9344[[vendor::unsafe]] void f2();
9345@end smallexample
9346
9347Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}.
9348
9349@item -Wno-builtin-declaration-mismatch
9350@opindex Wno-builtin-declaration-mismatch
9351@opindex Wbuiltin-declaration-mismatch
9352Warn if a built-in function is declared with an incompatible signature
9353or as a non-function, or when a built-in function declared with a type
9354that does not include a prototype is called with arguments whose promoted
9355types do not match those expected by the function. When @option{-Wextra}
9356is specified, also warn when a built-in function that takes arguments is
9357declared without a prototype. The @option{-Wbuiltin-declaration-mismatch}
9358warning is enabled by default. To avoid the warning include the appropriate
9359header to bring the prototypes of built-in functions into scope.
9360
9361For example, the call to @code{memset} below is diagnosed by the warning
9362because the function expects a value of type @code{size_t} as its argument
9363but the type of @code{32} is @code{int}. With @option{-Wextra},
9364the declaration of the function is diagnosed as well.
9365@smallexample
9366extern void* memset ();
9367void f (void *d)
9368@{
9369 memset (d, '\0', 32);
9370@}
9371@end smallexample
9372
9373@item -Wno-builtin-macro-redefined
9374@opindex Wno-builtin-macro-redefined
9375@opindex Wbuiltin-macro-redefined
9376Do not warn if certain built-in macros are redefined. This suppresses
9377warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__},
9378@code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}.
9379
9380@item -Wstrict-prototypes @r{(C and Objective-C only)}
9381@opindex Wstrict-prototypes
9382@opindex Wno-strict-prototypes
9383Warn if a function is declared or defined without specifying the
9384argument types. (An old-style function definition is permitted without
9385a warning if preceded by a declaration that specifies the argument
9386types.)
9387
9388@item -Wold-style-declaration @r{(C and Objective-C only)}
9389@opindex Wold-style-declaration
9390@opindex Wno-old-style-declaration
9391Warn for obsolescent usages, according to the C Standard, in a
9392declaration. For example, warn if storage-class specifiers like
9393@code{static} are not the first things in a declaration. This warning
9394is also enabled by @option{-Wextra}.
9395
9396@item -Wold-style-definition @r{(C and Objective-C only)}
9397@opindex Wold-style-definition
9398@opindex Wno-old-style-definition
9399Warn if an old-style function definition is used. A warning is given
9400even if there is a previous prototype. A definition using @samp{()}
9401is not considered an old-style definition in C2X mode, because it is
9402equivalent to @samp{(void)} in that case, but is considered an
9403old-style definition for older standards.
9404
9405@item -Wmissing-parameter-type @r{(C and Objective-C only)}
9406@opindex Wmissing-parameter-type
9407@opindex Wno-missing-parameter-type
9408A function parameter is declared without a type specifier in K&R-style
9409functions:
9410
9411@smallexample
9412void foo(bar) @{ @}
9413@end smallexample
9414
9415This warning is also enabled by @option{-Wextra}.
9416
9417@item -Wmissing-prototypes @r{(C and Objective-C only)}
9418@opindex Wmissing-prototypes
9419@opindex Wno-missing-prototypes
9420Warn if a global function is defined without a previous prototype
9421declaration. This warning is issued even if the definition itself
9422provides a prototype. Use this option to detect global functions
9423that do not have a matching prototype declaration in a header file.
9424This option is not valid for C++ because all function declarations
9425provide prototypes and a non-matching declaration declares an
9426overload rather than conflict with an earlier declaration.
9427Use @option{-Wmissing-declarations} to detect missing declarations in C++.
9428
9429@item -Wmissing-declarations
9430@opindex Wmissing-declarations
9431@opindex Wno-missing-declarations
9432Warn if a global function is defined without a previous declaration.
9433Do so even if the definition itself provides a prototype.
9434Use this option to detect global functions that are not declared in
9435header files. In C, no warnings are issued for functions with previous
9436non-prototype declarations; use @option{-Wmissing-prototypes} to detect
9437missing prototypes. In C++, no warnings are issued for function templates,
9438or for inline functions, or for functions in anonymous namespaces.
9439
9440@item -Wmissing-field-initializers
9441@opindex Wmissing-field-initializers
9442@opindex Wno-missing-field-initializers
9443@opindex W
9444@opindex Wextra
9445@opindex Wno-extra
9446Warn if a structure's initializer has some fields missing. For
9447example, the following code causes such a warning, because
9448@code{x.h} is implicitly zero:
9449
9450@smallexample
9451struct s @{ int f, g, h; @};
9452struct s x = @{ 3, 4 @};
9453@end smallexample
9454
9455This option does not warn about designated initializers, so the following
9456modification does not trigger a warning:
9457
9458@smallexample
9459struct s @{ int f, g, h; @};
9460struct s x = @{ .f = 3, .g = 4 @};
9461@end smallexample
9462
9463In C this option does not warn about the universal zero initializer
9464@samp{@{ 0 @}}:
9465
9466@smallexample
9467struct s @{ int f, g, h; @};
9468struct s x = @{ 0 @};
9469@end smallexample
9470
9471Likewise, in C++ this option does not warn about the empty @{ @}
9472initializer, for example:
9473
9474@smallexample
9475struct s @{ int f, g, h; @};
9476s x = @{ @};
9477@end smallexample
9478
9479This warning is included in @option{-Wextra}. To get other @option{-Wextra}
9480warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}.
9481
9482@item -Wno-missing-requires
9483@opindex Wmissing-requires
9484@opindex Wno-missing-requires
9485
9486By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement:
9487
9488@smallexample
9489bool satisfied = requires @{ C<T> @};
9490@end smallexample
9491
9492Here @samp{satisfied} will be true if @samp{C<T>} is a valid
9493expression, which it is for all T. Presumably the user meant to write
9494
9495@smallexample
9496bool satisfied = requires @{ requires C<T> @};
9497@end smallexample
9498
9499so @samp{satisfied} is only true if concept @samp{C} is satisfied for
9500type @samp{T}.
9501
9502This warning can be disabled with @option{-Wno-missing-requires}.
9503
9504@item -Wno-missing-template-keyword
9505@opindex Wmissing-template-keyword
9506@opindex Wno-missing-template-keyword
9507
9508The member access tokens ., -> and :: must be followed by the @code{template}
9509keyword if the parent object is dependent and the member being named is a
9510template.
9511
9512@smallexample
9513template <class X>
9514void DoStuff (X x)
9515@{
9516 x.template DoSomeOtherStuff<X>(); // Good.
9517 x.DoMoreStuff<X>(); // Warning, x is dependent.
9518@}
9519@end smallexample
9520
9521In rare cases it is possible to get false positives. To silence this, wrap
9522the expression in parentheses. For example, the following is treated as a
9523template, even where m and N are integers:
9524
9525@smallexample
9526void NotATemplate (my_class t)
9527@{
9528 int N = 5;
9529
9530 bool test = t.m < N > (0); // Treated as a template.
9531 test = (t.m < N) > (0); // Same meaning, but not treated as a template.
9532@}
9533@end smallexample
9534
9535This warning can be disabled with @option{-Wno-missing-template-keyword}.
9536
9537@item -Wno-multichar
9538@opindex Wno-multichar
9539@opindex Wmultichar
9540Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
9541Usually they indicate a typo in the user's code, as they have
9542implementation-defined values, and should not be used in portable code.
9543
9544@item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]}
9545@opindex Wnormalized=
9546@opindex Wnormalized
9547@opindex Wno-normalized
9548@cindex NFC
9549@cindex NFKC
9550@cindex character set, input normalization
9551In ISO C and ISO C++, two identifiers are different if they are
9552different sequences of characters. However, sometimes when characters
9553outside the basic ASCII character set are used, you can have two
9554different character sequences that look the same. To avoid confusion,
9555the ISO 10646 standard sets out some @dfn{normalization rules} which
9556when applied ensure that two sequences that look the same are turned into
9557the same sequence. GCC can warn you if you are using identifiers that
9558have not been normalized; this option controls that warning.
9559
9560There are four levels of warning supported by GCC@. The default is
9561@option{-Wnormalized=nfc}, which warns about any identifier that is
9562not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the
9563recommended form for most uses. It is equivalent to
9564@option{-Wnormalized}.
9565
9566Unfortunately, there are some characters allowed in identifiers by
9567ISO C and ISO C++ that, when turned into NFC, are not allowed in
9568identifiers. That is, there's no way to use these symbols in portable
9569ISO C or C++ and have all your identifiers in NFC@.
9570@option{-Wnormalized=id} suppresses the warning for these characters.
9571It is hoped that future versions of the standards involved will correct
9572this, which is why this option is not the default.
9573
9574You can switch the warning off for all characters by writing
9575@option{-Wnormalized=none} or @option{-Wno-normalized}. You should
9576only do this if you are using some other normalization scheme (like
9577``D''), because otherwise you can easily create bugs that are
9578literally impossible to see.
9579
9580Some characters in ISO 10646 have distinct meanings but look identical
9581in some fonts or display methodologies, especially once formatting has
9582been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL
9583LETTER N'', displays just like a regular @code{n} that has been
9584placed in a superscript. ISO 10646 defines the @dfn{NFKC}
9585normalization scheme to convert all these into a standard form as
9586well, and GCC warns if your code is not in NFKC if you use
9587@option{-Wnormalized=nfkc}. This warning is comparable to warning
9588about every identifier that contains the letter O because it might be
9589confused with the digit 0, and so is not the default, but may be
9590useful as a local coding convention if the programming environment
9591cannot be fixed to display these characters distinctly.
9592
9593@item -Wno-attribute-warning
9594@opindex Wno-attribute-warning
9595@opindex Wattribute-warning
9596Do not warn about usage of functions (@pxref{Function Attributes})
9597declared with @code{warning} attribute. By default, this warning is
9598enabled. @option{-Wno-attribute-warning} can be used to disable the
9599warning or @option{-Wno-error=attribute-warning} can be used to
9600disable the error when compiled with @option{-Werror} flag.
9601
9602@item -Wno-deprecated
9603@opindex Wno-deprecated
9604@opindex Wdeprecated
9605Do not warn about usage of deprecated features. @xref{Deprecated Features}.
9606
9607@item -Wno-deprecated-declarations
9608@opindex Wno-deprecated-declarations
9609@opindex Wdeprecated-declarations
9610Do not warn about uses of functions (@pxref{Function Attributes}),
9611variables (@pxref{Variable Attributes}), and types (@pxref{Type
9612Attributes}) marked as deprecated by using the @code{deprecated}
9613attribute.
9614
9615@item -Wno-overflow
9616@opindex Wno-overflow
9617@opindex Woverflow
9618Do not warn about compile-time overflow in constant expressions.
9619
9620@item -Wno-odr
9621@opindex Wno-odr
9622@opindex Wodr
9623Warn about One Definition Rule violations during link-time optimization.
9624Enabled by default.
9625
9626@item -Wopenacc-parallelism
9627@opindex Wopenacc-parallelism
9628@opindex Wno-openacc-parallelism
9629@cindex OpenACC accelerator programming
9630Warn about potentially suboptimal choices related to OpenACC parallelism.
9631
9632@item -Wopenmp-simd
9633@opindex Wopenmp-simd
9634@opindex Wno-openmp-simd
9635Warn if the vectorizer cost model overrides the OpenMP
9636simd directive set by user. The @option{-fsimd-cost-model=unlimited}
9637option can be used to relax the cost model.
9638
9639@item -Woverride-init @r{(C and Objective-C only)}
9640@opindex Woverride-init
9641@opindex Wno-override-init
9642@opindex W
9643@opindex Wextra
9644@opindex Wno-extra
9645Warn if an initialized field without side effects is overridden when
9646using designated initializers (@pxref{Designated Inits, , Designated
9647Initializers}).
9648
9649This warning is included in @option{-Wextra}. To get other
9650@option{-Wextra} warnings without this one, use @option{-Wextra
9651-Wno-override-init}.
9652
9653@item -Wno-override-init-side-effects @r{(C and Objective-C only)}
9654@opindex Woverride-init-side-effects
9655@opindex Wno-override-init-side-effects
9656Do not warn if an initialized field with side effects is overridden when
9657using designated initializers (@pxref{Designated Inits, , Designated
9658Initializers}). This warning is enabled by default.
9659
9660@item -Wpacked
9661@opindex Wpacked
9662@opindex Wno-packed
9663Warn if a structure is given the packed attribute, but the packed
9664attribute has no effect on the layout or size of the structure.
9665Such structures may be mis-aligned for little benefit. For
9666instance, in this code, the variable @code{f.x} in @code{struct bar}
9667is misaligned even though @code{struct bar} does not itself
9668have the packed attribute:
9669
9670@smallexample
9671@group
9672struct foo @{
9673 int x;
9674 char a, b, c, d;
9675@} __attribute__((packed));
9676struct bar @{
9677 char z;
9678 struct foo f;
9679@};
9680@end group
9681@end smallexample
9682
9683@item -Wnopacked-bitfield-compat
9684@opindex Wpacked-bitfield-compat
9685@opindex Wno-packed-bitfield-compat
9686The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute
9687on bit-fields of type @code{char}. This was fixed in GCC 4.4 but
9688the change can lead to differences in the structure layout. GCC
9689informs you when the offset of such a field has changed in GCC 4.4.
9690For example there is no longer a 4-bit padding between field @code{a}
9691and @code{b} in this structure:
9692
9693@smallexample
9694struct foo
9695@{
9696 char a:4;
9697 char b:8;
9698@} __attribute__ ((packed));
9699@end smallexample
9700
9701This warning is enabled by default. Use
9702@option{-Wno-packed-bitfield-compat} to disable this warning.
9703
9704@item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)}
9705@opindex Wpacked-not-aligned
9706@opindex Wno-packed-not-aligned
9707Warn if a structure field with explicitly specified alignment in a
9708packed struct or union is misaligned. For example, a warning will
9709be issued on @code{struct S}, like, @code{warning: alignment 1 of
9710'struct S' is less than 8}, in this code:
9711
9712@smallexample
9713@group
9714struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @};
9715struct __attribute__ ((packed)) S @{
9716 struct S8 s8;
9717@};
9718@end group
9719@end smallexample
9720
9721This warning is enabled by @option{-Wall}.
9722
9723@item -Wpadded
9724@opindex Wpadded
9725@opindex Wno-padded
9726Warn if padding is included in a structure, either to align an element
9727of the structure or to align the whole structure. Sometimes when this
9728happens it is possible to rearrange the fields of the structure to
9729reduce the padding and so make the structure smaller.
9730
9731@item -Wredundant-decls
9732@opindex Wredundant-decls
9733@opindex Wno-redundant-decls
9734Warn if anything is declared more than once in the same scope, even in
9735cases where multiple declaration is valid and changes nothing.
9736
9737@item -Wrestrict
9738@opindex Wrestrict
9739@opindex Wno-restrict
9740Warn when an object referenced by a @code{restrict}-qualified parameter
9741(or, in C++, a @code{__restrict}-qualified parameter) is aliased by another
9742argument, or when copies between such objects overlap. For example,
9743the call to the @code{strcpy} function below attempts to truncate the string
9744by replacing its initial characters with the last four. However, because
9745the call writes the terminating NUL into @code{a[4]}, the copies overlap and
9746the call is diagnosed.
9747
9748@smallexample
9749void foo (void)
9750@{
9751 char a[] = "abcd1234";
9752 strcpy (a, a + 4);
9753 @dots{}
9754@}
9755@end smallexample
9756The @option{-Wrestrict} option detects some instances of simple overlap
9757even without optimization but works best at @option{-O2} and above. It
9758is included in @option{-Wall}.
9759
9760@item -Wnested-externs @r{(C and Objective-C only)}
9761@opindex Wnested-externs
9762@opindex Wno-nested-externs
9763Warn if an @code{extern} declaration is encountered within a function.
9764
9765@item -Winline
9766@opindex Winline
9767@opindex Wno-inline
9768Warn if a function that is declared as inline cannot be inlined.
9769Even with this option, the compiler does not warn about failures to
9770inline functions declared in system headers.
9771
9772The compiler uses a variety of heuristics to determine whether or not
9773to inline a function. For example, the compiler takes into account
9774the size of the function being inlined and the amount of inlining
9775that has already been done in the current function. Therefore,
9776seemingly insignificant changes in the source program can cause the
9777warnings produced by @option{-Winline} to appear or disappear.
9778
9779@item -Winterference-size
9780@opindex Winterference-size
9781Warn about use of C++17 @code{std::hardware_destructive_interference_size}
9782without specifying its value with @option{--param destructive-interference-size}.
9783Also warn about questionable values for that option.
9784
9785This variable is intended to be used for controlling class layout, to
9786avoid false sharing in concurrent code:
9787
9788@smallexample
9789struct independent_fields @{
9790 alignas(std::hardware_destructive_interference_size) std::atomic<int> one;
9791 alignas(std::hardware_destructive_interference_size) std::atomic<int> two;
9792@};
9793@end smallexample
9794
9795Here @samp{one} and @samp{two} are intended to be far enough apart
9796that stores to one won't require accesses to the other to reload the
9797cache line.
9798
9799By default, @option{--param destructive-interference-size} and
9800@option{--param constructive-interference-size} are set based on the
9801current @option{-mtune} option, typically to the L1 cache line size
9802for the particular target CPU, sometimes to a range if tuning for a
9803generic target. So all translation units that depend on ABI
9804compatibility for the use of these variables must be compiled with
9805the same @option{-mtune} (or @option{-mcpu}).
9806
9807If ABI stability is important, such as if the use is in a header for a
9808library, you should probably not use the hardware interference size
9809variables at all. Alternatively, you can force a particular value
9810with @option{--param}.
9811
9812If you are confident that your use of the variable does not affect ABI
9813outside a single build of your project, you can turn off the warning
9814with @option{-Wno-interference-size}.
9815
9816@item -Wint-in-bool-context
9817@opindex Wint-in-bool-context
9818@opindex Wno-int-in-bool-context
9819Warn for suspicious use of integer values where boolean values are expected,
9820such as conditional expressions (?:) using non-boolean integer constants in
9821boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed
9822integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise
9823for all kinds of multiplications regardless of the data type.
9824This warning is enabled by @option{-Wall}.
9825
9826@item -Wno-int-to-pointer-cast
9827@opindex Wno-int-to-pointer-cast
9828@opindex Wint-to-pointer-cast
9829Suppress warnings from casts to pointer type of an integer of a
9830different size. In C++, casting to a pointer type of smaller size is
9831an error. @option{Wint-to-pointer-cast} is enabled by default.
9832
9833
9834@item -Wno-pointer-to-int-cast @r{(C and Objective-C only)}
9835@opindex Wno-pointer-to-int-cast
9836@opindex Wpointer-to-int-cast
9837Suppress warnings from casts from a pointer to an integer type of a
9838different size.
9839
9840@item -Winvalid-pch
9841@opindex Winvalid-pch
9842@opindex Wno-invalid-pch
9843Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
9844the search path but cannot be used.
9845
9846@item -Winvalid-utf8
9847@opindex Winvalid-utf8
9848@opindex Wno-invalid-utf8
9849Warn if an invalid UTF-8 character is found.
9850This warning is on by default for C++23 if @option{-finput-charset=UTF-8}
9851is used and turned into error with @option{-pedantic-errors}.
9852
9853@item -Wno-unicode
9854@opindex Wunicode
9855@opindex Wno-unicode
9856Don't diagnose invalid forms of delimited or named escape sequences which are
9857treated as separate tokens. @option{Wunicode} is enabled by default.
9858
9859@item -Wlong-long
9860@opindex Wlong-long
9861@opindex Wno-long-long
9862Warn if @code{long long} type is used. This is enabled by either
9863@option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98
9864modes. To inhibit the warning messages, use @option{-Wno-long-long}.
9865
9866@item -Wvariadic-macros
9867@opindex Wvariadic-macros
9868@opindex Wno-variadic-macros
9869Warn if variadic macros are used in ISO C90 mode, or if the GNU
9870alternate syntax is used in ISO C99 mode. This is enabled by either
9871@option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning
9872messages, use @option{-Wno-variadic-macros}.
9873
9874@item -Wno-varargs
9875@opindex Wvarargs
9876@opindex Wno-varargs
9877Do not warn upon questionable usage of the macros used to handle variable
9878arguments like @code{va_start}. These warnings are enabled by default.
9879
9880@item -Wvector-operation-performance
9881@opindex Wvector-operation-performance
9882@opindex Wno-vector-operation-performance
9883Warn if vector operation is not implemented via SIMD capabilities of the
9884architecture. Mainly useful for the performance tuning.
9885Vector operation can be implemented @code{piecewise}, which means that the
9886scalar operation is performed on every vector element;
9887@code{in parallel}, which means that the vector operation is implemented
9888using scalars of wider type, which normally is more performance efficient;
9889and @code{as a single scalar}, which means that vector fits into a
9890scalar type.
9891
9892@item -Wvla
9893@opindex Wvla
9894@opindex Wno-vla
9895Warn if a variable-length array is used in the code.
9896@option{-Wno-vla} prevents the @option{-Wpedantic} warning of
9897the variable-length array.
9898
9899@item -Wvla-larger-than=@var{byte-size}
9900@opindex Wvla-larger-than=
9901@opindex Wno-vla-larger-than
9902If this option is used, the compiler warns for declarations of
9903variable-length arrays whose size is either unbounded, or bounded
9904by an argument that allows the array size to exceed @var{byte-size}
9905bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size}
9906works, but with variable-length arrays.
9907
9908Note that GCC may optimize small variable-length arrays of a known
9909value into plain arrays, so this warning may not get triggered for
9910such arrays.
9911
9912@option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but
9913is typically only effective when @option{-ftree-vrp} is active (default
9914for @option{-O2} and above).
9915
9916See also @option{-Walloca-larger-than=@var{byte-size}}.
9917
9918@item -Wno-vla-larger-than
9919@opindex Wno-vla-larger-than
9920Disable @option{-Wvla-larger-than=} warnings. The option is equivalent
9921to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger.
9922
9923@item -Wvla-parameter
9924@opindex Wno-vla-parameter
9925Warn about redeclarations of functions involving arguments of Variable
9926Length Array types of inconsistent kinds or forms, and enable the detection
9927of out-of-bounds accesses to such parameters by warnings such as
9928@option{-Warray-bounds}.
9929
9930If the first function declaration uses the VLA form the bound specified
9931in the array is assumed to be the minimum number of elements expected to
9932be provided in calls to the function and the maximum number of elements
9933accessed by it. Failing to provide arguments of sufficient size or
9934accessing more than the maximum number of elements may be diagnosed.
9935
9936For example, the warning triggers for the following redeclarations because
9937the first one allows an array of any size to be passed to @code{f} while
9938the second one specifies that the array argument must have at least @code{n}
9939elements. In addition, calling @code{f} with the associated VLA bound
9940parameter in excess of the actual VLA bound triggers a warning as well.
9941
9942@smallexample
9943void f (int n, int[n]);
9944void f (int, int[]); // warning: argument 2 previously declared as a VLA
9945
9946void g (int n)
9947@{
9948 if (n > 4)
9949 return;
9950 int a[n];
9951 f (sizeof a, a); // warning: access to a by f may be out of bounds
9952 @dots{}
9953@}
9954
9955@end smallexample
9956
9957@option{-Wvla-parameter} is included in @option{-Wall}. The
9958@option{-Warray-parameter} option triggers warnings for similar problems
9959involving ordinary array arguments.
9960
9961@item -Wvolatile-register-var
9962@opindex Wvolatile-register-var
9963@opindex Wno-volatile-register-var
9964Warn if a register variable is declared volatile. The volatile
9965modifier does not inhibit all optimizations that may eliminate reads
9966and/or writes to register variables. This warning is enabled by
9967@option{-Wall}.
9968
9969@item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)}
9970@opindex Wxor-used-as-pow
9971@opindex Wno-xor-used-as-pow
9972Warn about uses of @code{^}, the exclusive or operator, where it appears
9973the user meant exponentiation. Specifically, the warning occurs when the
9974left-hand side is the decimal constant 2 or 10 and the right-hand side
9975is also a decimal constant.
9976
9977In C and C++, @code{^} means exclusive or, whereas in some other languages
9978(e.g. TeX and some versions of BASIC) it means exponentiation.
9979
9980This warning is enabled by default. It can be silenced by converting one
9981of the operands to hexadecimal.
9982
9983@item -Wdisabled-optimization
9984@opindex Wdisabled-optimization
9985@opindex Wno-disabled-optimization
9986Warn if a requested optimization pass is disabled. This warning does
9987not generally indicate that there is anything wrong with your code; it
9988merely indicates that GCC's optimizers are unable to handle the code
9989effectively. Often, the problem is that your code is too big or too
9990complex; GCC refuses to optimize programs when the optimization
9991itself is likely to take inordinate amounts of time.
9992
9993@item -Wpointer-sign @r{(C and Objective-C only)}
9994@opindex Wpointer-sign
9995@opindex Wno-pointer-sign
9996Warn for pointer argument passing or assignment with different signedness.
9997This option is only supported for C and Objective-C@. It is implied by
9998@option{-Wall} and by @option{-Wpedantic}, which can be disabled with
9999@option{-Wno-pointer-sign}.
10000
10001@item -Wstack-protector
10002@opindex Wstack-protector
10003@opindex Wno-stack-protector
10004This option is only active when @option{-fstack-protector} is active. It
10005warns about functions that are not protected against stack smashing.
10006
10007@item -Woverlength-strings
10008@opindex Woverlength-strings
10009@opindex Wno-overlength-strings
10010Warn about string constants that are longer than the ``minimum
10011maximum'' length specified in the C standard. Modern compilers
10012generally allow string constants that are much longer than the
10013standard's minimum limit, but very portable programs should avoid
10014using longer strings.
10015
10016The limit applies @emph{after} string constant concatenation, and does
10017not count the trailing NUL@. In C90, the limit was 509 characters; in
10018C99, it was raised to 4095. C++98 does not specify a normative
10019minimum maximum, so we do not diagnose overlength strings in C++@.
10020
10021This option is implied by @option{-Wpedantic}, and can be disabled with
10022@option{-Wno-overlength-strings}.
10023
10024@item -Wunsuffixed-float-constants @r{(C and Objective-C only)}
10025@opindex Wunsuffixed-float-constants
10026@opindex Wno-unsuffixed-float-constants
10027
10028Issue a warning for any floating constant that does not have
10029a suffix. When used together with @option{-Wsystem-headers} it
10030warns about such constants in system header files. This can be useful
10031when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma
10032from the decimal floating-point extension to C99.
10033
10034@item -Wno-lto-type-mismatch
10035@opindex Wlto-type-mismatch
10036@opindex Wno-lto-type-mismatch
10037
10038During the link-time optimization, do not warn about type mismatches in
10039global declarations from different compilation units.
10040Requires @option{-flto} to be enabled. Enabled by default.
10041
10042@item -Wno-designated-init @r{(C and Objective-C only)}
10043@opindex Wdesignated-init
10044@opindex Wno-designated-init
10045Suppress warnings when a positional initializer is used to initialize
10046a structure that has been marked with the @code{designated_init}
10047attribute.
10048
10049@end table
10050
10051@node Static Analyzer Options
10052@section Options That Control Static Analysis
10053
10054@table @gcctabopt
10055@item -fanalyzer
10056@opindex analyzer
10057@opindex fanalyzer
10058@opindex fno-analyzer
10059This option enables an static analysis of program flow which looks
10060for ``interesting'' interprocedural paths through the
10061code, and issues warnings for problems found on them.
10062
10063This analysis is much more expensive than other GCC warnings.
10064
10065Enabling this option effectively enables the following warnings:
10066
10067@gccoptlist{ @gol
10068-Wanalyzer-allocation-size @gol
ce51e843 10069-Wanalyzer-deref-before-check @gol
d77de738
ML
10070-Wanalyzer-double-fclose @gol
10071-Wanalyzer-double-free @gol
10072-Wanalyzer-exposure-through-output-file @gol
10073-Wanalyzer-exposure-through-uninit-copy @gol
10074-Wanalyzer-fd-access-mode-mismatch @gol
10075-Wanalyzer-fd-double-close @gol
10076-Wanalyzer-fd-leak @gol
86a90006
DM
10077-Wanalyzer-fd-phase-mismatch @gol
10078-Wanalyzer-fd-type-mismatch @gol
d77de738
ML
10079-Wanalyzer-fd-use-after-close @gol
10080-Wanalyzer-fd-use-without-check @gol
10081-Wanalyzer-file-leak @gol
10082-Wanalyzer-free-of-non-heap @gol
10083-Wanalyzer-imprecise-fp-arithmetic @gol
ce51e843 10084-Wanalyzer-infinite-recursion @gol
d77de738
ML
10085-Wanalyzer-jump-through-null @gol
10086-Wanalyzer-malloc-leak @gol
10087-Wanalyzer-mismatching-deallocation @gol
10088-Wanalyzer-null-argument @gol
10089-Wanalyzer-null-dereference @gol
10090-Wanalyzer-out-of-bounds @gol
10091-Wanalyzer-possible-null-argument @gol
10092-Wanalyzer-possible-null-dereference @gol
10093-Wanalyzer-putenv-of-auto-var @gol
10094-Wanalyzer-shift-count-negative @gol
10095-Wanalyzer-shift-count-overflow @gol
10096-Wanalyzer-stale-setjmp-buffer @gol
10097-Wanalyzer-unsafe-call-within-signal-handler @gol
10098-Wanalyzer-use-after-free @gol
10099-Wanalyzer-use-of-pointer-in-stale-stack-frame @gol
10100-Wanalyzer-use-of-uninitialized-value @gol
10101-Wanalyzer-va-arg-type-mismatch @gol
10102-Wanalyzer-va-list-exhausted @gol
10103-Wanalyzer-va-list-leak @gol
10104-Wanalyzer-va-list-use-after-va-end @gol
10105-Wanalyzer-write-to-const @gol
10106-Wanalyzer-write-to-string-literal @gol
10107}
10108@ignore
10109-Wanalyzer-tainted-allocation-size @gol
10110-Wanalyzer-tainted-array-index @gol
10111-Wanalyzer-tainted-divisor @gol
10112-Wanalyzer-tainted-offset @gol
10113-Wanalyzer-tainted-size @gol
10114@end ignore
10115
10116This option is only available if GCC was configured with analyzer
10117support enabled.
10118
10119@item -Wanalyzer-too-complex
10120@opindex Wanalyzer-too-complex
10121@opindex Wno-analyzer-too-complex
10122If @option{-fanalyzer} is enabled, the analyzer uses various heuristics
10123to attempt to explore the control flow and data flow in the program,
10124but these can be defeated by sufficiently complicated code.
10125
10126By default, the analysis silently stops if the code is too
10127complicated for the analyzer to fully explore and it reaches an internal
10128limit. The @option{-Wanalyzer-too-complex} option warns if this occurs.
10129
10130@item -Wno-analyzer-allocation-size
10131@opindex Wanalyzer-allocation-size
10132@opindex Wno-analyzer-allocation-size
10133This warning requires @option{-fanalyzer}, which enables it; use
10134@option{-Wno-analyzer-allocation-size}
10135to disable it.
10136
10137This diagnostic warns for paths through the code in which a pointer to
10138a buffer is assigned to point at a buffer with a size that is not a
10139multiple of @code{sizeof (*pointer)}.
10140
10141See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}.
10142
ce51e843
ML
10143@item -Wno-analyzer-deref-before-check
10144@opindex Wanalyzer-deref-before-check
10145@opindex Wno-analyzer-deref-before-check
10146This warning requires @option{-fanalyzer}, which enables it; use
10147@option{-Wno-analyzer-deref-before-check}
10148to disable it.
10149
10150This diagnostic warns for paths through the code in which a pointer
10151is checked for @code{NULL} *after* it has already been
10152dereferenced, suggesting that the pointer could have been NULL.
10153Such cases suggest that the check for NULL is either redundant,
10154or that it needs to be moved to before the pointer is dereferenced.
10155
10156This diagnostic also considers values passed to a function argument
10157marked with @code{__attribute__((nonnull))} as requiring a non-NULL
10158value, and thus will complain if such values are checked for @code{NULL}
10159after returning from such a function call.
10160
10161This diagnostic is unlikely to be reported when any level of optimization
10162is enabled, as GCC's optimization logic will typically consider such
10163checks for NULL as being redundant, and optimize them away before the
10164analyzer "sees" them. Hence optimization should be disabled when
10165attempting to trigger this diagnostic.
10166
d77de738
ML
10167@item -Wno-analyzer-double-fclose
10168@opindex Wanalyzer-double-fclose
10169@opindex Wno-analyzer-double-fclose
10170This warning requires @option{-fanalyzer}, which enables it; use
10171@option{-Wno-analyzer-double-fclose} to disable it.
10172
10173This diagnostic warns for paths through the code in which a @code{FILE *}
10174can have @code{fclose} called on it more than once.
10175
10176See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10177
10178@item -Wno-analyzer-double-free
10179@opindex Wanalyzer-double-free
10180@opindex Wno-analyzer-double-free
10181This warning requires @option{-fanalyzer}, which enables it; use
10182@option{-Wno-analyzer-double-free} to disable it.
10183
10184This diagnostic warns for paths through the code in which a pointer
10185can have a deallocator called on it more than once, either @code{free},
10186or a deallocator referenced by attribute @code{malloc}.
10187
10188See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}.
10189
10190@item -Wno-analyzer-exposure-through-output-file
10191@opindex Wanalyzer-exposure-through-output-file
10192@opindex Wno-analyzer-exposure-through-output-file
10193This warning requires @option{-fanalyzer}, which enables it; use
10194@option{-Wno-analyzer-exposure-through-output-file}
10195to disable it.
10196
10197This diagnostic warns for paths through the code in which a
10198security-sensitive value is written to an output file
10199(such as writing a password to a log file).
10200
10201See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}.
10202
10203@item -Wanalyzer-exposure-through-uninit-copy
10204@opindex Wanalyzer-exposure-through-uninit-copy
10205@opindex Wno-analyzer-exposure-through-uninit-copy
10206This warning requires both @option{-fanalyzer} and the use of a plugin
10207to specify a function that copies across a ``trust boundary''. Use
10208@option{-Wno-analyzer-exposure-through-uninit-copy} to disable it.
10209
10210This diagnostic warns for ``infoleaks'' - paths through the code in which
10211uninitialized values are copied across a security boundary
10212(such as code within an OS kernel that copies a partially-initialized
10213struct on the stack to user space).
10214
10215See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}.
10216
10217@item -Wno-analyzer-fd-access-mode-mismatch
10218@opindex Wanalyzer-fd-access-mode-mismatch
10219@opindex Wno-analyzer-fd-access-mode-mismatch
10220This warning requires @option{-fanalyzer}, which enables it; use
10221@option{-Wno-analyzer-fd-access-mode-mismatch}
10222to disable it.
10223
10224This diagnostic warns for paths through code in which a
10225@code{read} on a write-only file descriptor is attempted, or vice versa.
10226
10227This diagnostic also warns for code paths in a which a function with attribute
10228@code{fd_arg_read (N)} is called with a file descriptor opened with
10229@code{O_WRONLY} at referenced argument @code{N} or a function with attribute
10230@code{fd_arg_write (N)} is called with a file descriptor opened with
10231@code{O_RDONLY} at referenced argument @var{N}.
10232
10233@item -Wno-analyzer-fd-double-close
10234@opindex Wanalyzer-fd-double-close
10235@opindex Wno-analyzer-fd-double-close
10236This warning requires @option{-fanalyzer}, which enables it; use
10237@option{-Wno-analyzer-fd-double-close}
10238to disable it.
10239
10240This diagnostic warns for paths through code in which a
10241file descriptor can be closed more than once.
10242
10243See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}.
10244
10245@item -Wno-analyzer-fd-leak
10246@opindex Wanalyzer-fd-leak
10247@opindex Wno-analyzer-fd-leak
10248This warning requires @option{-fanalyzer}, which enables it; use
10249@option{-Wno-analyzer-fd-leak}
10250to disable it.
10251
10252This diagnostic warns for paths through code in which an
10253open file descriptor is leaked.
10254
10255See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10256
86a90006
DM
10257@item -Wno-analyzer-fd-phase-mismatch
10258@opindex Wanalyzer-fd-phase-mismatch
10259@opindex Wno-analyzer-fd-phase-mismatch
10260This warning requires @option{-fanalyzer}, which enables it; use
10261@option{-Wno-analyzer-fd-phase-mismatch}
10262to disable it.
10263
10264This diagnostic warns for paths through code in which an operation is
10265attempted in the wrong phase of a file descriptor's lifetime.
10266For example, it will warn on attempts to call @code{accept} on a stream
10267socket that has not yet had @code{listen} successfully called on it.
10268
10269See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}.
10270
10271@item -Wno-analyzer-fd-type-mismatch
10272@opindex Wanalyzer-fd-type-mismatch
10273@opindex Wno-analyzer-fd-type-mismatch
10274This warning requires @option{-fanalyzer}, which enables it; use
10275@option{-Wno-analyzer-fd-type-mismatch}
10276to disable it.
10277
10278This diagnostic warns for paths through code in which an
10279operation is attempted on the wrong type of file descriptor.
10280For example, it will warn on attempts to use socket operations
10281on a file descriptor obtained via @code{open}, or when attempting
10282to use a stream socket operation on a datagram socket.
10283
d77de738
ML
10284@item -Wno-analyzer-fd-use-after-close
10285@opindex Wanalyzer-fd-use-after-close
10286@opindex Wno-analyzer-fd-use-after-close
10287This warning requires @option{-fanalyzer}, which enables it; use
10288@option{-Wno-analyzer-fd-use-after-close}
10289to disable it.
10290
10291This diagnostic warns for paths through code in which a
10292read or write is called on a closed file descriptor.
10293
10294This diagnostic also warns for paths through code in which
10295a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10296or @code{fd_arg_write (N)} is called with a closed file descriptor at
10297referenced argument @code{N}.
10298
10299@item -Wno-analyzer-fd-use-without-check
10300@opindex Wanalyzer-fd-use-without-check
10301@opindex Wno-analyzer-fd-use-without-check
10302This warning requires @option{-fanalyzer}, which enables it; use
10303@option{-Wno-analyzer-fd-use-without-check}
10304to disable it.
10305
10306This diagnostic warns for paths through code in which a
10307file descriptor is used without being checked for validity.
10308
10309This diagnostic also warns for paths through code in which
10310a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
10311or @code{fd_arg_write (N)} is called with a file descriptor, at referenced
10312argument @code{N}, without being checked for validity.
10313
10314@item -Wno-analyzer-file-leak
10315@opindex Wanalyzer-file-leak
10316@opindex Wno-analyzer-file-leak
10317This warning requires @option{-fanalyzer}, which enables it; use
10318@option{-Wno-analyzer-file-leak}
10319to disable it.
10320
10321This diagnostic warns for paths through the code in which a
10322@code{<stdio.h>} @code{FILE *} stream object is leaked.
10323
10324See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}.
10325
10326@item -Wno-analyzer-free-of-non-heap
10327@opindex Wanalyzer-free-of-non-heap
10328@opindex Wno-analyzer-free-of-non-heap
10329This warning requires @option{-fanalyzer}, which enables it; use
10330@option{-Wno-analyzer-free-of-non-heap}
10331to disable it.
10332
10333This diagnostic warns for paths through the code in which @code{free}
10334is called on a non-heap pointer (e.g. an on-stack buffer, or a global).
10335
10336See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}.
10337
10338@item -Wno-analyzer-imprecise-fp-arithmetic
10339@opindex Wanalyzer-imprecise-fp-arithmetic
10340@opindex Wno-analyzer-imprecise-fp-arithmetic
10341This warning requires @option{-fanalyzer}, which enables it; use
10342@option{-Wno-analyzer-imprecise-fp-arithmetic}
10343to disable it.
10344
10345This diagnostic warns for paths through the code in which floating-point
10346arithmetic is used in locations where precise computation is needed. This
10347diagnostic only warns on use of floating-point operands inside the
10348calculation of an allocation size at the moment.
10349
ce51e843
ML
10350@item -Wno-analyzer-infinite-recursion
10351@opindex Wanalyzer-infinite-recursion
10352@opindex Wno-analyzer-infinite-recursion
10353This warning requires @option{-fanalyzer}, which enables it; use
10354@option{-Wno-analyzer-infinite-recursion} to disable it.
10355
10356This diagnostics warns for paths through the code which appear to
10357lead to infinite recursion.
10358
10359Specifically, when the analyzer "sees" a recursive call, it will compare
10360the state of memory at the entry to the new frame with that at the entry
10361to the previous frame of that function on the stack. The warning is
10362issued if nothing in memory appears to be changing; any changes observed
10363to parameters or globals are assumed to lead to termination of the
10364recursion and thus suppress the warning.
10365
10366This diagnostic is likely to miss cases of infinite recursion that
10367are convered to iteration by the optimizer before the analyzer "sees"
10368them. Hence optimization should be disabled when attempting to trigger
10369this diagnostic.
10370
10371Compare with @option{-Winfinite-recursion}, which provides a similar
10372diagnostic, but is implemented in a different way.
10373
d77de738
ML
10374@item -Wno-analyzer-jump-through-null
10375@opindex Wanalyzer-jump-through-null
10376@opindex Wno-analyzer-jump-through-null
10377This warning requires @option{-fanalyzer}, which enables it; use
10378@option{-Wno-analyzer-jump-through-null}
10379to disable it.
10380
10381This diagnostic warns for paths through the code in which a @code{NULL}
10382function pointer is called.
10383
10384@item -Wno-analyzer-malloc-leak
10385@opindex Wanalyzer-malloc-leak
10386@opindex Wno-analyzer-malloc-leak
10387This warning requires @option{-fanalyzer}, which enables it; use
10388@option{-Wno-analyzer-malloc-leak}
10389to disable it.
10390
10391This diagnostic warns for paths through the code in which a
10392pointer allocated via an allocator is leaked: either @code{malloc},
10393or a function marked with attribute @code{malloc}.
10394
10395See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}.
10396
10397@item -Wno-analyzer-mismatching-deallocation
10398@opindex Wanalyzer-mismatching-deallocation
10399@opindex Wno-analyzer-mismatching-deallocation
10400This warning requires @option{-fanalyzer}, which enables it; use
10401@option{-Wno-analyzer-mismatching-deallocation}
10402to disable it.
10403
10404This diagnostic warns for paths through the code in which the
10405wrong deallocation function is called on a pointer value, based on
10406which function was used to allocate the pointer value. The diagnostic
10407will warn about mismatches between @code{free}, scalar @code{delete}
10408and vector @code{delete[]}, and those marked as allocator/deallocator
10409pairs using attribute @code{malloc}.
10410
10411See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}.
10412
10413@item -Wno-analyzer-out-of-bounds
10414@opindex Wanalyzer-out-of-bounds
10415@opindex Wno-analyzer-out-of-bounds
10416This warning requires @option{-fanalyzer} to enable it; use
10417@option{-Wno-analyzer-out-of-bounds} to disable it.
10418
10419This diagnostic warns for path through the code in which a buffer is
10420definitely read or written out-of-bounds. The diagnostic applies for
10421cases where the analyzer is able to determine a constant offset and for
10422accesses past the end of a buffer, also a constant capacity. Further,
10423the diagnostic does limited checking for accesses past the end when the
10424offset as well as the capacity is symbolic.
10425
10426See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}.
10427
10428@item -Wno-analyzer-possible-null-argument
10429@opindex Wanalyzer-possible-null-argument
10430@opindex Wno-analyzer-possible-null-argument
10431This warning requires @option{-fanalyzer}, which enables it; use
10432@option{-Wno-analyzer-possible-null-argument} to disable it.
10433
10434This diagnostic warns for paths through the code in which a
10435possibly-NULL value is passed to a function argument marked
10436with @code{__attribute__((nonnull))} as requiring a non-NULL
10437value.
10438
10439See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10440
10441@item -Wno-analyzer-possible-null-dereference
10442@opindex Wanalyzer-possible-null-dereference
10443@opindex Wno-analyzer-possible-null-dereference
10444This warning requires @option{-fanalyzer}, which enables it; use
10445@option{-Wno-analyzer-possible-null-dereference} to disable it.
10446
10447This diagnostic warns for paths through the code in which a
10448possibly-NULL value is dereferenced.
10449
10450See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}.
10451
10452@item -Wno-analyzer-null-argument
10453@opindex Wanalyzer-null-argument
10454@opindex Wno-analyzer-null-argument
10455This warning requires @option{-fanalyzer}, which enables it; use
10456@option{-Wno-analyzer-null-argument} to disable it.
10457
10458This diagnostic warns for paths through the code in which a
10459value known to be NULL is passed to a function argument marked
10460with @code{__attribute__((nonnull))} as requiring a non-NULL
10461value.
10462
10463See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10464
10465@item -Wno-analyzer-null-dereference
10466@opindex Wanalyzer-null-dereference
10467@opindex Wno-analyzer-null-dereference
10468This warning requires @option{-fanalyzer}, which enables it; use
10469@option{-Wno-analyzer-null-dereference} to disable it.
10470
10471This diagnostic warns for paths through the code in which a
10472value known to be NULL is dereferenced.
10473
10474See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}.
10475
10476@item -Wno-analyzer-putenv-of-auto-var
10477@opindex Wanalyzer-putenv-of-auto-var
10478@opindex Wno-analyzer-putenv-of-auto-var
10479This warning requires @option{-fanalyzer}, which enables it; use
10480@option{-Wno-analyzer-putenv-of-auto-var} to disable it.
10481
10482This diagnostic warns for paths through the code in which a
10483call to @code{putenv} is passed a pointer to an automatic variable
10484or an on-stack buffer.
10485
10486See @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}.
10487
10488@item -Wno-analyzer-shift-count-negative
10489@opindex Wanalyzer-shift-count-negative
10490@opindex Wno-analyzer-shift-count-negative
10491This warning requires @option{-fanalyzer}, which enables it; use
10492@option{-Wno-analyzer-shift-count-negative} to disable it.
10493
10494This diagnostic warns for paths through the code in which a
10495shift is attempted with a negative count. It is analogous to
10496the @option{-Wshift-count-negative} diagnostic implemented in
10497the C/C++ front ends, but is implemented based on analyzing
10498interprocedural paths, rather than merely parsing the syntax tree.
10499However, the analyzer does not prioritize detection of such paths, so
10500false negatives are more likely relative to other warnings.
10501
10502@item -Wno-analyzer-shift-count-overflow
10503@opindex Wanalyzer-shift-count-overflow
10504@opindex Wno-analyzer-shift-count-overflow
10505This warning requires @option{-fanalyzer}, which enables it; use
10506@option{-Wno-analyzer-shift-count-overflow} to disable it.
10507
10508This diagnostic warns for paths through the code in which a
10509shift is attempted with a count greater than or equal to the
10510precision of the operand's type. It is analogous to
10511the @option{-Wshift-count-overflow} diagnostic implemented in
10512the C/C++ front ends, but is implemented based on analyzing
10513interprocedural paths, rather than merely parsing the syntax tree.
10514However, the analyzer does not prioritize detection of such paths, so
10515false negatives are more likely relative to other warnings.
10516
10517@item -Wno-analyzer-stale-setjmp-buffer
10518@opindex Wanalyzer-stale-setjmp-buffer
10519@opindex Wno-analyzer-stale-setjmp-buffer
10520This warning requires @option{-fanalyzer}, which enables it; use
10521@option{-Wno-analyzer-stale-setjmp-buffer} to disable it.
10522
10523This diagnostic warns for paths through the code in which
10524@code{longjmp} is called to rewind to a @code{jmp_buf} relating
10525to a @code{setjmp} call in a function that has returned.
10526
10527When @code{setjmp} is called on a @code{jmp_buf} to record a rewind
10528location, it records the stack frame. The stack frame becomes invalid
10529when the function containing the @code{setjmp} call returns. Attempting
10530to rewind to it via @code{longjmp} would reference a stack frame that
10531no longer exists, and likely lead to a crash (or worse).
10532
10533@item -Wno-analyzer-tainted-allocation-size
10534@opindex Wanalyzer-tainted-allocation-size
10535@opindex Wno-analyzer-tainted-allocation-size
10536This warning requires both @option{-fanalyzer} and
10537@option{-fanalyzer-checker=taint} to enable it;
10538use @option{-Wno-analyzer-tainted-allocation-size} to disable it.
10539
10540This diagnostic warns for paths through the code in which a value
10541that could be under an attacker's control is used as the size
10542of an allocation without being sanitized, so that an attacker could
10543inject an excessively large allocation and potentially cause a denial
10544of service attack.
10545
10546See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}.
10547
ce51e843
ML
10548@item -Wno-analyzer-tainted-assertion
10549@opindex Wanalyzer-tainted-assertion
10550@opindex Wno-analyzer-tainted-assertion
10551
10552This warning requires both @option{-fanalyzer} and
10553@option{-fanalyzer-checker=taint} to enable it;
10554use @option{-Wno-analyzer-tainted-assertion} to disable it.
10555
10556This diagnostic warns for paths through the code in which a value
10557that could be under an attacker's control is used as part of a
10558condition without being first sanitized, and that condition guards a
10559call to a function marked with attribute @code{noreturn}
10560(such as the function @code{__builtin_unreachable}). Such functions
10561typically indicate abnormal termination of the program, such as for
10562assertion failure handlers. For example:
10563
10564@smallexample
10565assert (some_tainted_value < SOME_LIMIT);
10566@end smallexample
10567
10568In such cases:
10569
10570@itemize
10571@item
10572when assertion-checking is enabled: an attacker could trigger
10573a denial of service by injecting an assertion failure
10574
10575@item
10576when assertion-checking is disabled, such as by defining @code{NDEBUG},
10577an attacker could inject data that subverts the process, since it
10578presumably violates a precondition that is being assumed by the code.
10579
10580@end itemize
10581
10582Note that when assertion-checking is disabled, the assertions are
10583typically removed by the preprocessor before the analyzer has a chance
10584to "see" them, so this diagnostic can only generate warnings on builds
10585in which assertion-checking is enabled.
10586
10587For the purpose of this warning, any function marked with attribute
10588@code{noreturn} is considered as a possible assertion failure
10589handler, including @code{__builtin_unreachable}. Note that these functions
10590are sometimes removed by the optimizer before the analyzer "sees" them.
10591Hence optimization should be disabled when attempting to trigger this
10592diagnostic.
10593
10594See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}.
10595
10596The warning can also report problematic constructions such as
10597
10598@smallexample
10599switch (some_tainted_value) @{
10600case 0:
10601 /* [...etc; various valid cases omitted...] */
10602 break;
10603
10604default:
10605 __builtin_unreachable (); /* BUG: attacker can trigger this */
10606@}
10607@end smallexample
10608
10609despite the above not being an assertion failure, strictly speaking.
10610
d77de738
ML
10611@item -Wno-analyzer-tainted-array-index
10612@opindex Wanalyzer-tainted-array-index
10613@opindex Wno-analyzer-tainted-array-index
10614This warning requires both @option{-fanalyzer} and
10615@option{-fanalyzer-checker=taint} to enable it;
10616use @option{-Wno-analyzer-tainted-array-index} to disable it.
10617
10618This diagnostic warns for paths through the code in which a value
10619that could be under an attacker's control is used as the index
10620of an array access without being sanitized, so that an attacker
10621could inject an out-of-bounds access.
10622
10623See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10624
10625@item -Wno-analyzer-tainted-divisor
10626@opindex Wanalyzer-tainted-divisor
10627@opindex Wno-analyzer-tainted-divisor
10628This warning requires both @option{-fanalyzer} and
10629@option{-fanalyzer-checker=taint} to enable it;
10630use @option{-Wno-analyzer-tainted-divisor} to disable it.
10631
10632This diagnostic warns for paths through the code in which a value
10633that could be under an attacker's control is used as the divisor
10634in a division or modulus operation without being sanitized, so that
10635an attacker could inject a division-by-zero.
10636
10637See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}.
10638
10639@item -Wno-analyzer-tainted-offset
10640@opindex Wanalyzer-tainted-offset
10641@opindex Wno-analyzer-tainted-offset
10642This warning requires both @option{-fanalyzer} and
10643@option{-fanalyzer-checker=taint} to enable it;
10644use @option{-Wno-analyzer-tainted-offset} to disable it.
10645
10646This diagnostic warns for paths through the code in which a value
10647that could be under an attacker's control is used as a pointer offset
10648without being sanitized, so that an attacker could inject an out-of-bounds
10649access.
10650
10651See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}.
10652
10653@item -Wno-analyzer-tainted-size
10654@opindex Wanalyzer-tainted-size
10655@opindex Wno-analyzer-tainted-size
10656This warning requires both @option{-fanalyzer} and
10657@option{-fanalyzer-checker=taint} to enable it;
10658use @option{-Wno-analyzer-tainted-size} to disable it.
10659
10660This diagnostic warns for paths through the code in which a value
10661that could be under an attacker's control is used as the size of
10662an operation such as @code{memset} without being sanitized, so that an
10663attacker could inject an out-of-bounds access.
10664
10665See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}.
10666
10667@item -Wno-analyzer-unsafe-call-within-signal-handler
10668@opindex Wanalyzer-unsafe-call-within-signal-handler
10669@opindex Wno-analyzer-unsafe-call-within-signal-handler
10670This warning requires @option{-fanalyzer}, which enables it; use
10671@option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it.
10672
10673This diagnostic warns for paths through the code in which a
10674function known to be async-signal-unsafe (such as @code{fprintf}) is
10675called from a signal handler.
10676
10677See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}.
10678
10679@item -Wno-analyzer-use-after-free
10680@opindex Wanalyzer-use-after-free
10681@opindex Wno-analyzer-use-after-free
10682This warning requires @option{-fanalyzer}, which enables it; use
10683@option{-Wno-analyzer-use-after-free} to disable it.
10684
10685This diagnostic warns for paths through the code in which a
10686pointer is used after a deallocator is called on it: either @code{free},
10687or a deallocator referenced by attribute @code{malloc}.
10688
10689See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}.
10690
10691@item -Wno-analyzer-use-of-pointer-in-stale-stack-frame
10692@opindex Wanalyzer-use-of-pointer-in-stale-stack-frame
10693@opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame
10694This warning requires @option{-fanalyzer}, which enables it; use
10695@option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame}
10696to disable it.
10697
10698This diagnostic warns for paths through the code in which a pointer
10699is dereferenced that points to a variable in a stale stack frame.
10700
10701@item -Wno-analyzer-va-arg-type-mismatch
10702@opindex Wanalyzer-va-arg-type-mismatch
10703@opindex Wno-analyzer-va-arg-type-mismatch
10704This warning requires @option{-fanalyzer}, which enables it; use
10705@option{-Wno-analyzer-va-arg-type-mismatch}
10706to disable it.
10707
10708This diagnostic warns for interprocedural paths through the code for which
10709the analyzer detects an attempt to use @code{va_arg} to extract a value
10710passed to a variadic call, but uses a type that does not match that of
10711the expression passed to the call.
10712
10713See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}.
10714
10715@item -Wno-analyzer-va-list-exhausted
10716@opindex Wanalyzer-va-list-exhausted
10717@opindex Wno-analyzer-va-list-exhausted
10718This warning requires @option{-fanalyzer}, which enables it; use
10719@option{-Wno-analyzer-va-list-exhausted}
10720to disable it.
10721
10722This diagnostic warns for interprocedural paths through the code for which
10723the analyzer detects an attempt to use @code{va_arg} to access the next
10724value passed to a variadic call, but all of the values in the
10725@code{va_list} have already been consumed.
10726
10727See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}.
10728
10729@item -Wno-analyzer-va-list-leak
10730@opindex Wanalyzer-va-list-leak
10731@opindex Wno-analyzer-va-list-leak
10732This warning requires @option{-fanalyzer}, which enables it; use
10733@option{-Wno-analyzer-va-list-leak}
10734to disable it.
10735
10736This diagnostic warns for interprocedural paths through the code for which
10737the analyzer detects that @code{va_start} or @code{va_copy} has been called
10738on a @code{va_list} without a corresponding call to @code{va_end}.
10739
10740@item -Wno-analyzer-va-list-use-after-va-end
10741@opindex Wanalyzer-va-list-use-after-va-end
10742@opindex Wno-analyzer-va-list-use-after-va-end
10743This warning requires @option{-fanalyzer}, which enables it; use
10744@option{-Wno-analyzer-va-list-use-after-va-end}
10745to disable it.
10746
10747This diagnostic warns for interprocedural paths through the code for which
10748the analyzer detects an attempt to use a @code{va_list} after
10749@code{va_end} has been called on it.
10750@code{va_list}.
10751
10752@item -Wno-analyzer-write-to-const
10753@opindex Wanalyzer-write-to-const
10754@opindex Wno-analyzer-write-to-const
10755This warning requires @option{-fanalyzer}, which enables it; use
10756@option{-Wno-analyzer-write-to-const}
10757to disable it.
10758
10759This diagnostic warns for paths through the code in which the analyzer
10760detects an attempt to write through a pointer to a @code{const} object.
10761However, the analyzer does not prioritize detection of such paths, so
10762false negatives are more likely relative to other warnings.
10763
10764@item -Wno-analyzer-write-to-string-literal
10765@opindex Wanalyzer-write-to-string-literal
10766@opindex Wno-analyzer-write-to-string-literal
10767This warning requires @option{-fanalyzer}, which enables it; use
10768@option{-Wno-analyzer-write-to-string-literal}
10769to disable it.
10770
10771This diagnostic warns for paths through the code in which the analyzer
10772detects an attempt to write through a pointer to a string literal.
10773However, the analyzer does not prioritize detection of such paths, so
10774false negatives are more likely relative to other warnings.
10775
10776@item -Wno-analyzer-use-of-uninitialized-value
10777@opindex Wanalyzer-use-of-uninitialized-value
10778@opindex Wno-analyzer-use-of-uninitialized-value
10779This warning requires @option{-fanalyzer}, which enables it; use
10780@option{-Wno-analyzer-use-of-uninitialized-value} to disable it.
10781
10782This diagnostic warns for paths through the code in which an uninitialized
10783value is used.
10784
10785See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}.
10786
10787@end table
10788
10789The analyzer has hardcoded knowledge about the behavior of the following
10790memory-management functions:
10791
10792@itemize @bullet
10793@item @code{alloca}
10794@item The built-in functions @code{__builtin_alloc},
10795@code{__builtin_alloc_with_align}, @item @code{__builtin_calloc},
10796@code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy},
10797@code{__builtin_memcpy_chk}, @code{__builtin_memset},
10798@code{__builtin_memset_chk}, @code{__builtin_realloc},
10799@code{__builtin_stack_restore}, and @code{__builtin_stack_save}
10800@item @code{calloc}
10801@item @code{free}
10802@item @code{malloc}
10803@item @code{memset}
10804@item @code{operator delete}
10805@item @code{operator delete []}
10806@item @code{operator new}
10807@item @code{operator new []}
10808@item @code{realloc}
10809@item @code{strdup}
10810@item @code{strndup}
10811@end itemize
10812
10813of the following functions for working with file descriptors:
10814
10815@itemize @bullet
10816@item @code{open}
10817@item @code{close}
10818@item @code{creat}
10819@item @code{dup}, @code{dup2} and @code{dup3}
78a17f44 10820@item @code{isatty}
d77de738
ML
10821@item @code{pipe}, and @code{pipe2}
10822@item @code{read}
10823@item @code{write}
86a90006 10824@item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect}
d77de738
ML
10825@end itemize
10826
10827of the following functions for working with @code{<stdio.h>} streams:
10828@itemize @bullet
10829@item The built-in functions @code{__builtin_fprintf},
10830@code{__builtin_fprintf_unlocked}, @code{__builtin_fputc},
10831@code{__builtin_fputc_unlocked}, @code{__builtin_fputs},
10832@code{__builtin_fputs_unlocked}, @code{__builtin_fwrite},
10833@code{__builtin_fwrite_unlocked}, @code{__builtin_printf},
10834@code{__builtin_printf_unlocked}, @code{__builtin_putc},
10835@code{__builtin_putchar}, @code{__builtin_putchar_unlocked},
10836@code{__builtin_putc_unlocked}, @code{__builtin_puts},
10837@code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and
10838@code{__builtin_vprintf}
10839@item @code{fopen}
10840@item @code{fclose}
78a17f44 10841@item @code{ferror}
d77de738
ML
10842@item @code{fgets}
10843@item @code{fgets_unlocked}
78a17f44 10844@item @code{fileno}
d77de738 10845@item @code{fread}
78a17f44 10846@item @code{getc}
d77de738
ML
10847@item @code{getchar}
10848@item @code{fprintf}
10849@item @code{printf}
10850@item @code{fwrite}
10851@end itemize
10852
10853and of the following functions:
10854
10855@itemize @bullet
10856@item The built-in functions @code{__builtin_expect},
10857@code{__builtin_expect_with_probability}, @code{__builtin_strchr},
10858@code{__builtin_strcpy}, @code{__builtin_strcpy_chk},
10859@code{__builtin_strlen}, @code{__builtin_va_copy}, and
10860@code{__builtin_va_start}
10861@item The GNU extensions @code{error} and @code{error_at_line}
10862@item @code{getpass}
10863@item @code{longjmp}
10864@item @code{putenv}
10865@item @code{setjmp}
10866@item @code{siglongjmp}
10867@item @code{signal}
10868@item @code{sigsetjmp}
10869@item @code{strchr}
10870@item @code{strlen}
10871@end itemize
10872
10873In addition, various functions with an @code{__analyzer_} prefix have
10874special meaning to the analyzer, described in the GCC Internals manual.
10875
10876Pertinent parameters for controlling the exploration are:
10877@option{--param analyzer-bb-explosion-factor=@var{value}},
10878@option{--param analyzer-max-enodes-per-program-point=@var{value}},
10879@option{--param analyzer-max-recursion-depth=@var{value}}, and
10880@option{--param analyzer-min-snodes-for-call-summary=@var{value}}.
10881
10882The following options control the analyzer.
10883
10884@table @gcctabopt
10885
10886@item -fanalyzer-call-summaries
10887@opindex fanalyzer-call-summaries
10888@opindex fno-analyzer-call-summaries
10889Simplify interprocedural analysis by computing the effect of certain calls,
10890rather than exploring all paths through the function from callsite to each
10891possible return.
10892
10893If enabled, call summaries are only used for functions with more than one
10894call site, and that are sufficiently complicated (as per
10895@option{--param analyzer-min-snodes-for-call-summary=@var{value}}).
10896
10897@item -fanalyzer-checker=@var{name}
10898@opindex fanalyzer-checker
10899Restrict the analyzer to run just the named checker, and enable it.
10900
10901Some checkers are disabled by default (even with @option{-fanalyzer}),
10902such as the @code{taint} checker that implements
10903@option{-Wanalyzer-tainted-array-index}, and this option is required
10904to enable them.
10905
10906@emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the
10907following warnings from @option{-fanalyzer}:
10908
10909@gccoptlist{ @gol
ce51e843 10910-Wanalyzer-deref-before-check @gol
d77de738
ML
10911-Wanalyzer-double-fclose @gol
10912-Wanalyzer-double-free @gol
10913-Wanalyzer-exposure-through-output-file @gol
10914-Wanalyzer-fd-access-mode-mismatch @gol
10915-Wanalyzer-fd-double-close @gol
10916-Wanalyzer-fd-leak @gol
10917-Wanalyzer-fd-use-after-close @gol
10918-Wanalyzer-fd-use-without-check @gol
10919-Wanalyzer-file-leak @gol
10920-Wanalyzer-free-of-non-heap @gol
10921-Wanalyzer-malloc-leak @gol
10922-Wanalyzer-mismatching-deallocation @gol
10923-Wanalyzer-null-argument @gol
10924-Wanalyzer-null-dereference @gol
10925-Wanalyzer-possible-null-argument @gol
10926-Wanalyzer-possible-null-dereference @gol
10927-Wanalyzer-unsafe-call-within-signal-handler @gol
10928-Wanalyzer-use-after-free @gol
10929-Wanalyzer-va-list-leak @gol
10930-Wanalyzer-va-list-use-after-va-end @gol
10931}
10932
10933@item -fno-analyzer-feasibility
10934@opindex fanalyzer-feasibility
10935@opindex fno-analyzer-feasibility
10936This option is intended for analyzer developers.
10937
10938By default the analyzer verifies that there is a feasible control flow path
10939for each diagnostic it emits: that the conditions that hold are not mutually
10940exclusive. Diagnostics for which no feasible path can be found are rejected.
10941This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for
10942debugging issues in this code.
10943
10944@item -fanalyzer-fine-grained
10945@opindex fanalyzer-fine-grained
10946@opindex fno-analyzer-fine-grained
10947This option is intended for analyzer developers.
10948
10949Internally the analyzer builds an ``exploded graph'' that combines
10950control flow graphs with data flow information.
10951
10952By default, an edge in this graph can contain the effects of a run
10953of multiple statements within a basic block. With
10954@option{-fanalyzer-fine-grained}, each statement gets its own edge.
10955
10956@item -fanalyzer-show-duplicate-count
10957@opindex fanalyzer-show-duplicate-count
10958@opindex fno-analyzer-show-duplicate-count
10959This option is intended for analyzer developers: if multiple diagnostics
10960have been detected as being duplicates of each other, it emits a note when
10961reporting the best diagnostic, giving the number of additional diagnostics
10962that were suppressed by the deduplication logic.
10963
10964@item -fno-analyzer-state-merge
10965@opindex fanalyzer-state-merge
10966@opindex fno-analyzer-state-merge
10967This option is intended for analyzer developers.
10968
10969By default the analyzer attempts to simplify analysis by merging
10970sufficiently similar states at each program point as it builds its
10971``exploded graph''. With @option{-fno-analyzer-state-merge} this
10972merging can be suppressed, for debugging state-handling issues.
10973
10974@item -fno-analyzer-state-purge
10975@opindex fanalyzer-state-purge
10976@opindex fno-analyzer-state-purge
10977This option is intended for analyzer developers.
10978
10979By default the analyzer attempts to simplify analysis by purging
10980aspects of state at a program point that appear to no longer be relevant
10981e.g. the values of locals that aren't accessed later in the function
10982and which aren't relevant to leak analysis.
10983
10984With @option{-fno-analyzer-state-purge} this purging of state can
10985be suppressed, for debugging state-handling issues.
10986
10987@item -fanalyzer-transitivity
10988@opindex fanalyzer-transitivity
10989@opindex fno-analyzer-transitivity
10990This option enables transitivity of constraints within the analyzer.
10991
10992@item -fno-analyzer-undo-inlining
10993@opindex fanalyzer-undo-inlining
10994@opindex fno-analyzer-undo-inlining
10995This option is intended for analyzer developers.
10996
10997@option{-fanalyzer} runs relatively late compared to other code analysis
10998tools, and some optimizations have already been applied to the code. In
10999particular function inlining may have occurred, leading to the
11000interprocedural execution paths emitted by the analyzer containing
11001function frames that don't correspond to those in the original source
11002code.
11003
11004By default the analyzer attempts to reconstruct the original function
11005frames, and to emit events showing the inlined calls.
11006
11007With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct
11008the original frame information can be be disabled, which may be of help
11009when debugging issues in the analyzer.
11010
11011@item -fanalyzer-verbose-edges
11012This option is intended for analyzer developers. It enables more
11013verbose, lower-level detail in the descriptions of control flow
11014within diagnostic paths.
11015
11016@item -fanalyzer-verbose-state-changes
11017This option is intended for analyzer developers. It enables more
11018verbose, lower-level detail in the descriptions of events relating
11019to state machines within diagnostic paths.
11020
11021@item -fanalyzer-verbosity=@var{level}
11022This option controls the complexity of the control flow paths that are
11023emitted for analyzer diagnostics.
11024
11025The @var{level} can be one of:
11026
11027@table @samp
11028@item 0
11029At this level, interprocedural call and return events are displayed,
11030along with the most pertinent state-change events relating to
11031a diagnostic. For example, for a double-@code{free} diagnostic,
11032both calls to @code{free} will be shown.
11033
11034@item 1
11035As per the previous level, but also show events for the entry
11036to each function.
11037
11038@item 2
11039As per the previous level, but also show events relating to
11040control flow that are significant to triggering the issue
11041(e.g. ``true path taken'' at a conditional).
11042
11043This level is the default.
11044
11045@item 3
11046As per the previous level, but show all control flow events, not
11047just significant ones.
11048
11049@item 4
11050This level is intended for analyzer developers; it adds various
11051other events intended for debugging the analyzer.
11052
11053@end table
11054
11055@item -fdump-analyzer
11056@opindex fdump-analyzer
11057Dump internal details about what the analyzer is doing to
11058@file{@var{file}.analyzer.txt}.
11059This option is overridden by @option{-fdump-analyzer-stderr}.
11060
11061@item -fdump-analyzer-stderr
11062@opindex fdump-analyzer-stderr
11063Dump internal details about what the analyzer is doing to stderr.
11064This option overrides @option{-fdump-analyzer}.
11065
11066@item -fdump-analyzer-callgraph
11067@opindex fdump-analyzer-callgraph
11068Dump a representation of the call graph suitable for viewing with
11069GraphViz to @file{@var{file}.callgraph.dot}.
11070
11071@item -fdump-analyzer-exploded-graph
11072@opindex fdump-analyzer-exploded-graph
11073Dump a representation of the ``exploded graph'' suitable for viewing with
11074GraphViz to @file{@var{file}.eg.dot}.
11075Nodes are color-coded based on state-machine states to emphasize
11076state changes.
11077
11078@item -fdump-analyzer-exploded-nodes
11079@opindex dump-analyzer-exploded-nodes
11080Emit diagnostics showing where nodes in the ``exploded graph'' are
11081in relation to the program source.
11082
11083@item -fdump-analyzer-exploded-nodes-2
11084@opindex dump-analyzer-exploded-nodes-2
11085Dump a textual representation of the ``exploded graph'' to
11086@file{@var{file}.eg.txt}.
11087
11088@item -fdump-analyzer-exploded-nodes-3
11089@opindex dump-analyzer-exploded-nodes-3
11090Dump a textual representation of the ``exploded graph'' to
11091one dump file per node, to @file{@var{file}.eg-@var{id}.txt}.
11092This is typically a large number of dump files.
11093
11094@item -fdump-analyzer-exploded-paths
11095@opindex fdump-analyzer-exploded-paths
11096Dump a textual representation of the ``exploded path'' for each
11097diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}.
11098
11099@item -fdump-analyzer-feasibility
11100@opindex dump-analyzer-feasibility
11101Dump internal details about the analyzer's search for feasible paths.
11102The details are written in a form suitable for viewing with GraphViz
11103to filenames of the form @file{@var{file}.*.fg.dot},
11104@file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}.
11105
11106@item -fdump-analyzer-json
11107@opindex fdump-analyzer-json
11108Dump a compressed JSON representation of analyzer internals to
11109@file{@var{file}.analyzer.json.gz}. The precise format is subject
11110to change.
11111
11112@item -fdump-analyzer-state-purge
11113@opindex fdump-analyzer-state-purge
11114As per @option{-fdump-analyzer-supergraph}, dump a representation of the
11115``supergraph'' suitable for viewing with GraphViz, but annotate the
11116graph with information on what state will be purged at each node.
11117The graph is written to @file{@var{file}.state-purge.dot}.
11118
11119@item -fdump-analyzer-supergraph
11120@opindex fdump-analyzer-supergraph
11121Dump representations of the ``supergraph'' suitable for viewing with
11122GraphViz to @file{@var{file}.supergraph.dot} and to
11123@file{@var{file}.supergraph-eg.dot}. These show all of the
11124control flow graphs in the program, with interprocedural edges for
11125calls and returns. The second dump contains annotations showing nodes
11126in the ``exploded graph'' and diagnostics associated with them.
11127
11128@item -fdump-analyzer-untracked
11129@opindex fdump-analyzer-untracked
11130Emit custom warnings with internal details intended for analyzer developers.
11131
11132@end table
11133
11134@node Debugging Options
11135@section Options for Debugging Your Program
11136@cindex options, debugging
11137@cindex debugging information options
11138
11139To tell GCC to emit extra information for use by a debugger, in almost
11140all cases you need only to add @option{-g} to your other options. Some debug
11141formats can co-exist (like DWARF with CTF) when each of them is enabled
11142explicitly by adding the respective command line option to your other options.
11143
11144GCC allows you to use @option{-g} with
11145@option{-O}. The shortcuts taken by optimized code may occasionally
11146be surprising: some variables you declared may not exist
11147at all; flow of control may briefly move where you did not expect it;
11148some statements may not be executed because they compute constant
11149results or their values are already at hand; some statements may
11150execute in different places because they have been moved out of loops.
11151Nevertheless it is possible to debug optimized output. This makes
11152it reasonable to use the optimizer for programs that might have bugs.
11153
11154If you are not using some other optimization option, consider
11155using @option{-Og} (@pxref{Optimize Options}) with @option{-g}.
11156With no @option{-O} option at all, some compiler passes that collect
11157information useful for debugging do not run at all, so that
11158@option{-Og} may result in a better debugging experience.
11159
11160@table @gcctabopt
11161@item -g
11162@opindex g
11163Produce debugging information in the operating system's native format
11164(stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
11165information.
11166
11167On most systems that use stabs format, @option{-g} enables use of extra
11168debugging information that only GDB can use; this extra information
11169makes debugging work better in GDB but probably makes other debuggers
11170crash or refuse to read the program. If you want to control for certain whether
11171to generate the extra information, use @option{-gvms} (see below).
11172
11173@item -ggdb
11174@opindex ggdb
11175Produce debugging information for use by GDB@. This means to use the
11176most expressive format available (DWARF, stabs, or the native format
11177if neither of those are supported), including GDB extensions if at all
11178possible.
11179
11180@item -gdwarf
11181@itemx -gdwarf-@var{version}
11182@opindex gdwarf
11183Produce debugging information in DWARF format (if that is supported).
11184The value of @var{version} may be either 2, 3, 4 or 5; the default
11185version for most targets is 5 (with the exception of VxWorks, TPF and
11186Darwin/Mac OS X, which default to version 2, and AIX, which defaults
11187to version 4).
11188
11189Note that with DWARF Version 2, some ports require and always
11190use some non-conflicting DWARF 3 extensions in the unwind tables.
11191
11192Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments}
11193for maximum benefit. Version 5 requires GDB 8.0 or higher.
11194
11195GCC no longer supports DWARF Version 1, which is substantially
11196different than Version 2 and later. For historical reasons, some
11197other DWARF-related options such as
11198@option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2
11199in their names, but apply to all currently-supported versions of DWARF.
11200
11201@item -gbtf
11202@opindex gbtf
11203Request BTF debug information. BTF is the default debugging format for the
11204eBPF target. On other targets, like x86, BTF debug information can be
11205generated along with DWARF debug information when both of the debug formats are
11206enabled explicitly via their respective command line options.
11207
11208@item -gctf
11209@itemx -gctf@var{level}
11210@opindex gctf
11211Request CTF debug information and use level to specify how much CTF debug
11212information should be produced. If @option{-gctf} is specified
11213without a value for level, the default level of CTF debug information is 2.
11214
11215CTF debug information can be generated along with DWARF debug information when
11216both of the debug formats are enabled explicitly via their respective command
11217line options.
11218
11219Level 0 produces no CTF debug information at all. Thus, @option{-gctf0}
11220negates @option{-gctf}.
11221
11222Level 1 produces CTF information for tracebacks only. This includes callsite
11223information, but does not include type information.
11224
11225Level 2 produces type information for entities (functions, data objects etc.)
11226at file-scope or global-scope only.
11227
11228@item -gvms
11229@opindex gvms
11230Produce debugging information in Alpha/VMS debug format (if that is
11231supported). This is the format used by DEBUG on Alpha/VMS systems.
11232
11233@item -g@var{level}
11234@itemx -ggdb@var{level}
11235@itemx -gvms@var{level}
11236Request debugging information and also use @var{level} to specify how
11237much information. The default level is 2.
11238
11239Level 0 produces no debug information at all. Thus, @option{-g0} negates
11240@option{-g}.
11241
11242Level 1 produces minimal information, enough for making backtraces in
11243parts of the program that you don't plan to debug. This includes
11244descriptions of functions and external variables, and line number
11245tables, but no information about local variables.
11246
11247Level 3 includes extra information, such as all the macro definitions
11248present in the program. Some debuggers support macro expansion when
11249you use @option{-g3}.
11250
11251If you use multiple @option{-g} options, with or without level numbers,
11252the last such option is the one that is effective.
11253
11254@option{-gdwarf} does not accept a concatenated debug level, to avoid
11255confusion with @option{-gdwarf-@var{level}}.
11256Instead use an additional @option{-g@var{level}} option to change the
11257debug level for DWARF.
11258
11259@item -fno-eliminate-unused-debug-symbols
11260@opindex feliminate-unused-debug-symbols
11261@opindex fno-eliminate-unused-debug-symbols
11262By default, no debug information is produced for symbols that are not actually
11263used. Use this option if you want debug information for all symbols.
11264
11265@item -femit-class-debug-always
11266@opindex femit-class-debug-always
11267Instead of emitting debugging information for a C++ class in only one
11268object file, emit it in all object files using the class. This option
11269should be used only with debuggers that are unable to handle the way GCC
11270normally emits debugging information for classes because using this
11271option increases the size of debugging information by as much as a
11272factor of two.
11273
11274@item -fno-merge-debug-strings
11275@opindex fmerge-debug-strings
11276@opindex fno-merge-debug-strings
11277Direct the linker to not merge together strings in the debugging
11278information that are identical in different object files. Merging is
11279not supported by all assemblers or linkers. Merging decreases the size
11280of the debug information in the output file at the cost of increasing
11281link processing time. Merging is enabled by default.
11282
11283@item -fdebug-prefix-map=@var{old}=@var{new}
11284@opindex fdebug-prefix-map
11285When compiling files residing in directory @file{@var{old}}, record
11286debugging information describing them as if the files resided in
11287directory @file{@var{new}} instead. This can be used to replace a
11288build-time path with an install-time path in the debug info. It can
11289also be used to change an absolute path to a relative path by using
11290@file{.} for @var{new}. This can give more reproducible builds, which
11291are location independent, but may require an extra command to tell GDB
11292where to find the source files. See also @option{-ffile-prefix-map}.
11293
11294@item -fvar-tracking
11295@opindex fvar-tracking
11296Run variable tracking pass. It computes where variables are stored at each
11297position in code. Better debugging information is then generated
11298(if the debugging information format supports this information).
11299
11300It is enabled by default when compiling with optimization (@option{-Os},
11301@option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and
11302the debug info format supports it.
11303
11304@item -fvar-tracking-assignments
11305@opindex fvar-tracking-assignments
11306@opindex fno-var-tracking-assignments
11307Annotate assignments to user variables early in the compilation and
11308attempt to carry the annotations over throughout the compilation all the
11309way to the end, in an attempt to improve debug information while
11310optimizing. Use of @option{-gdwarf-4} is recommended along with it.
11311
11312It can be enabled even if var-tracking is disabled, in which case
11313annotations are created and maintained, but discarded at the end.
11314By default, this flag is enabled together with @option{-fvar-tracking},
11315except when selective scheduling is enabled.
11316
11317@item -gsplit-dwarf
11318@opindex gsplit-dwarf
11319If DWARF debugging information is enabled, separate as much debugging
11320information as possible into a separate output file with the extension
11321@file{.dwo}. This option allows the build system to avoid linking files with
11322debug information. To be useful, this option requires a debugger capable of
11323reading @file{.dwo} files.
11324
11325@item -gdwarf32
11326@itemx -gdwarf64
11327@opindex gdwarf32
11328@opindex gdwarf64
11329If DWARF debugging information is enabled, the @option{-gdwarf32} selects
11330the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit
11331DWARF format. The default is target specific, on most targets it is
11332@option{-gdwarf32} though. The 32-bit DWARF format is smaller, but
11333can't support more than 2GiB of debug information in any of the DWARF
11334debug information sections. The 64-bit DWARF format allows larger debug
11335information and might not be well supported by all consumers yet.
11336
11337@item -gdescribe-dies
11338@opindex gdescribe-dies
11339Add description attributes to some DWARF DIEs that have no name attribute,
11340such as artificial variables, external references and call site
11341parameter DIEs.
11342
11343@item -gpubnames
11344@opindex gpubnames
11345Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections.
11346
11347@item -ggnu-pubnames
11348@opindex ggnu-pubnames
11349Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format
11350suitable for conversion into a GDB@ index. This option is only useful
11351with a linker that can produce GDB@ index version 7.
11352
11353@item -fdebug-types-section
11354@opindex fdebug-types-section
11355@opindex fno-debug-types-section
11356When using DWARF Version 4 or higher, type DIEs can be put into
11357their own @code{.debug_types} section instead of making them part of the
11358@code{.debug_info} section. It is more efficient to put them in a separate
11359comdat section since the linker can then remove duplicates.
11360But not all DWARF consumers support @code{.debug_types} sections yet
11361and on some objects @code{.debug_types} produces larger instead of smaller
11362debugging information.
11363
11364@item -grecord-gcc-switches
11365@itemx -gno-record-gcc-switches
11366@opindex grecord-gcc-switches
11367@opindex gno-record-gcc-switches
11368This switch causes the command-line options used to invoke the
11369compiler that may affect code generation to be appended to the
11370DW_AT_producer attribute in DWARF debugging information. The options
11371are concatenated with spaces separating them from each other and from
11372the compiler version.
11373It is enabled by default.
11374See also @option{-frecord-gcc-switches} for another
11375way of storing compiler options into the object file.
11376
11377@item -gstrict-dwarf
11378@opindex gstrict-dwarf
11379Disallow using extensions of later DWARF standard version than selected
11380with @option{-gdwarf-@var{version}}. On most targets using non-conflicting
11381DWARF extensions from later standard versions is allowed.
11382
11383@item -gno-strict-dwarf
11384@opindex gno-strict-dwarf
11385Allow using extensions of later DWARF standard version than selected with
11386@option{-gdwarf-@var{version}}.
11387
11388@item -gas-loc-support
11389@opindex gas-loc-support
11390Inform the compiler that the assembler supports @code{.loc} directives.
11391It may then use them for the assembler to generate DWARF2+ line number
11392tables.
11393
11394This is generally desirable, because assembler-generated line-number
11395tables are a lot more compact than those the compiler can generate
11396itself.
11397
11398This option will be enabled by default if, at GCC configure time, the
11399assembler was found to support such directives.
11400
11401@item -gno-as-loc-support
11402@opindex gno-as-loc-support
11403Force GCC to generate DWARF2+ line number tables internally, if DWARF2+
11404line number tables are to be generated.
11405
11406@item -gas-locview-support
11407@opindex gas-locview-support
11408Inform the compiler that the assembler supports @code{view} assignment
11409and reset assertion checking in @code{.loc} directives.
11410
11411This option will be enabled by default if, at GCC configure time, the
11412assembler was found to support them.
11413
11414@item -gno-as-locview-support
11415Force GCC to assign view numbers internally, if
11416@option{-gvariable-location-views} are explicitly requested.
11417
11418@item -gcolumn-info
11419@itemx -gno-column-info
11420@opindex gcolumn-info
11421@opindex gno-column-info
11422Emit location column information into DWARF debugging information, rather
11423than just file and line.
11424This option is enabled by default.
11425
11426@item -gstatement-frontiers
11427@itemx -gno-statement-frontiers
11428@opindex gstatement-frontiers
11429@opindex gno-statement-frontiers
11430This option causes GCC to create markers in the internal representation
11431at the beginning of statements, and to keep them roughly in place
11432throughout compilation, using them to guide the output of @code{is_stmt}
11433markers in the line number table. This is enabled by default when
11434compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2},
11435@dots{}), and outputting DWARF 2 debug information at the normal level.
11436
11437@item -gvariable-location-views
11438@itemx -gvariable-location-views=incompat5
11439@itemx -gno-variable-location-views
11440@opindex gvariable-location-views
11441@opindex gvariable-location-views=incompat5
11442@opindex gno-variable-location-views
11443Augment variable location lists with progressive view numbers implied
11444from the line number table. This enables debug information consumers to
11445inspect state at certain points of the program, even if no instructions
11446associated with the corresponding source locations are present at that
11447point. If the assembler lacks support for view numbers in line number
11448tables, this will cause the compiler to emit the line number table,
11449which generally makes them somewhat less compact. The augmented line
11450number tables and location lists are fully backward-compatible, so they
11451can be consumed by debug information consumers that are not aware of
11452these augmentations, but they won't derive any benefit from them either.
11453
11454This is enabled by default when outputting DWARF 2 debug information at
11455the normal level, as long as there is assembler support,
11456@option{-fvar-tracking-assignments} is enabled and
11457@option{-gstrict-dwarf} is not. When assembler support is not
11458available, this may still be enabled, but it will force GCC to output
11459internal line number tables, and if
11460@option{-ginternal-reset-location-views} is not enabled, that will most
11461certainly lead to silently mismatching location views.
11462
11463There is a proposed representation for view numbers that is not backward
11464compatible with the location list format introduced in DWARF 5, that can
11465be enabled with @option{-gvariable-location-views=incompat5}. This
11466option may be removed in the future, is only provided as a reference
11467implementation of the proposed representation. Debug information
11468consumers are not expected to support this extended format, and they
11469would be rendered unable to decode location lists using it.
11470
11471@item -ginternal-reset-location-views
11472@itemx -gno-internal-reset-location-views
11473@opindex ginternal-reset-location-views
11474@opindex gno-internal-reset-location-views
11475Attempt to determine location views that can be omitted from location
11476view lists. This requires the compiler to have very accurate insn
11477length estimates, which isn't always the case, and it may cause
11478incorrect view lists to be generated silently when using an assembler
11479that does not support location view lists. The GNU assembler will flag
11480any such error as a @code{view number mismatch}. This is only enabled
11481on ports that define a reliable estimation function.
11482
11483@item -ginline-points
11484@itemx -gno-inline-points
11485@opindex ginline-points
11486@opindex gno-inline-points
11487Generate extended debug information for inlined functions. Location
11488view tracking markers are inserted at inlined entry points, so that
11489address and view numbers can be computed and output in debug
11490information. This can be enabled independently of location views, in
11491which case the view numbers won't be output, but it can only be enabled
11492along with statement frontiers, and it is only enabled by default if
11493location views are enabled.
11494
11495@item -gz@r{[}=@var{type}@r{]}
11496@opindex gz
11497Produce compressed debug sections in DWARF format, if that is supported.
11498If @var{type} is not given, the default type depends on the capabilities
11499of the assembler and linker used. @var{type} may be one of
11500@samp{none} (don't compress debug sections), or @samp{zlib} (use zlib
11501compression in ELF gABI format). If the linker doesn't support writing
11502compressed debug sections, the option is rejected. Otherwise, if the
11503assembler does not support them, @option{-gz} is silently ignored when
11504producing object files.
11505
11506@item -femit-struct-debug-baseonly
11507@opindex femit-struct-debug-baseonly
11508Emit debug information for struct-like types
11509only when the base name of the compilation source file
11510matches the base name of file in which the struct is defined.
11511
11512This option substantially reduces the size of debugging information,
11513but at significant potential loss in type information to the debugger.
11514See @option{-femit-struct-debug-reduced} for a less aggressive option.
11515See @option{-femit-struct-debug-detailed} for more detailed control.
11516
11517This option works only with DWARF debug output.
11518
11519@item -femit-struct-debug-reduced
11520@opindex femit-struct-debug-reduced
11521Emit debug information for struct-like types
11522only when the base name of the compilation source file
11523matches the base name of file in which the type is defined,
11524unless the struct is a template or defined in a system header.
11525
11526This option significantly reduces the size of debugging information,
11527with some potential loss in type information to the debugger.
11528See @option{-femit-struct-debug-baseonly} for a more aggressive option.
11529See @option{-femit-struct-debug-detailed} for more detailed control.
11530
11531This option works only with DWARF debug output.
11532
11533@item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]}
11534@opindex femit-struct-debug-detailed
11535Specify the struct-like types
11536for which the compiler generates debug information.
11537The intent is to reduce duplicate struct debug information
11538between different object files within the same program.
11539
11540This option is a detailed version of
11541@option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly},
11542which serves for most needs.
11543
11544A specification has the syntax@*
11545[@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none})
11546
11547The optional first word limits the specification to
11548structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}).
11549A struct type is used directly when it is the type of a variable, member.
11550Indirect uses arise through pointers to structs.
11551That is, when use of an incomplete struct is valid, the use is indirect.
11552An example is
11553@samp{struct one direct; struct two * indirect;}.
11554
11555The optional second word limits the specification to
11556ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}).
11557Generic structs are a bit complicated to explain.
11558For C++, these are non-explicit specializations of template classes,
11559or non-template classes within the above.
11560Other programming languages have generics,
11561but @option{-femit-struct-debug-detailed} does not yet implement them.
11562
11563The third word specifies the source files for those
11564structs for which the compiler should emit debug information.
11565The values @samp{none} and @samp{any} have the normal meaning.
11566The value @samp{base} means that
11567the base of name of the file in which the type declaration appears
11568must match the base of the name of the main compilation file.
11569In practice, this means that when compiling @file{foo.c}, debug information
11570is generated for types declared in that file and @file{foo.h},
11571but not other header files.
11572The value @samp{sys} means those types satisfying @samp{base}
11573or declared in system or compiler headers.
11574
11575You may need to experiment to determine the best settings for your application.
11576
11577The default is @option{-femit-struct-debug-detailed=all}.
11578
11579This option works only with DWARF debug output.
11580
11581@item -fno-dwarf2-cfi-asm
11582@opindex fdwarf2-cfi-asm
11583@opindex fno-dwarf2-cfi-asm
11584Emit DWARF unwind info as compiler generated @code{.eh_frame} section
11585instead of using GAS @code{.cfi_*} directives.
11586
11587@item -fno-eliminate-unused-debug-types
11588@opindex feliminate-unused-debug-types
11589@opindex fno-eliminate-unused-debug-types
11590Normally, when producing DWARF output, GCC avoids producing debug symbol
11591output for types that are nowhere used in the source file being compiled.
11592Sometimes it is useful to have GCC emit debugging
11593information for all types declared in a compilation
11594unit, regardless of whether or not they are actually used
11595in that compilation unit, for example
11596if, in the debugger, you want to cast a value to a type that is
11597not actually used in your program (but is declared). More often,
11598however, this results in a significant amount of wasted space.
11599@end table
11600
11601@node Optimize Options
11602@section Options That Control Optimization
11603@cindex optimize options
11604@cindex options, optimization
11605
11606These options control various sorts of optimizations.
11607
11608Without any optimization option, the compiler's goal is to reduce the
11609cost of compilation and to make debugging produce the expected
11610results. Statements are independent: if you stop the program with a
11611breakpoint between statements, you can then assign a new value to any
11612variable or change the program counter to any other statement in the
11613function and get exactly the results you expect from the source
11614code.
11615
11616Turning on optimization flags makes the compiler attempt to improve
11617the performance and/or code size at the expense of compilation time
11618and possibly the ability to debug the program.
11619
11620The compiler performs optimization based on the knowledge it has of the
11621program. Compiling multiple files at once to a single output file mode allows
11622the compiler to use information gained from all of the files when compiling
11623each of them.
11624
11625Not all optimizations are controlled directly by a flag. Only
11626optimizations that have a flag are listed in this section.
11627
11628Most optimizations are completely disabled at @option{-O0} or if an
11629@option{-O} level is not set on the command line, even if individual
11630optimization flags are specified. Similarly, @option{-Og} suppresses
11631many optimization passes.
11632
11633Depending on the target and how GCC was configured, a slightly different
11634set of optimizations may be enabled at each @option{-O} level than
11635those listed here. You can invoke GCC with @option{-Q --help=optimizers}
11636to find out the exact set of optimizations that are enabled at each level.
11637@xref{Overall Options}, for examples.
11638
11639@table @gcctabopt
11640@item -O
11641@itemx -O1
11642@opindex O
11643@opindex O1
11644Optimize. Optimizing compilation takes somewhat more time, and a lot
11645more memory for a large function.
11646
11647With @option{-O}, the compiler tries to reduce code size and execution
11648time, without performing any optimizations that take a great deal of
11649compilation time.
11650
11651@c Note that in addition to the default_options_table list in opts.cc,
11652@c several optimization flags default to true but control optimization
11653@c passes that are explicitly disabled at -O0.
11654
11655@option{-O} turns on the following optimization flags:
11656
11657@c Please keep the following list alphabetized.
11658@gccoptlist{-fauto-inc-dec @gol
11659-fbranch-count-reg @gol
11660-fcombine-stack-adjustments @gol
11661-fcompare-elim @gol
11662-fcprop-registers @gol
11663-fdce @gol
11664-fdefer-pop @gol
11665-fdelayed-branch @gol
11666-fdse @gol
11667-fforward-propagate @gol
11668-fguess-branch-probability @gol
11669-fif-conversion @gol
11670-fif-conversion2 @gol
11671-finline-functions-called-once @gol
11672-fipa-modref @gol
11673-fipa-profile @gol
11674-fipa-pure-const @gol
11675-fipa-reference @gol
11676-fipa-reference-addressable @gol
11677-fmerge-constants @gol
11678-fmove-loop-invariants @gol
11679-fmove-loop-stores@gol
11680-fomit-frame-pointer @gol
11681-freorder-blocks @gol
11682-fshrink-wrap @gol
11683-fshrink-wrap-separate @gol
11684-fsplit-wide-types @gol
11685-fssa-backprop @gol
11686-fssa-phiopt @gol
11687-ftree-bit-ccp @gol
11688-ftree-ccp @gol
11689-ftree-ch @gol
11690-ftree-coalesce-vars @gol
11691-ftree-copy-prop @gol
11692-ftree-dce @gol
11693-ftree-dominator-opts @gol
11694-ftree-dse @gol
11695-ftree-forwprop @gol
11696-ftree-fre @gol
11697-ftree-phiprop @gol
11698-ftree-pta @gol
11699-ftree-scev-cprop @gol
11700-ftree-sink @gol
11701-ftree-slsr @gol
11702-ftree-sra @gol
11703-ftree-ter @gol
11704-funit-at-a-time}
11705
11706@item -O2
11707@opindex O2
11708Optimize even more. GCC performs nearly all supported optimizations
11709that do not involve a space-speed tradeoff.
11710As compared to @option{-O}, this option increases both compilation time
11711and the performance of the generated code.
11712
11713@option{-O2} turns on all optimization flags specified by @option{-O1}. It
11714also turns on the following optimization flags:
11715
11716@c Please keep the following list alphabetized!
11717@gccoptlist{-falign-functions -falign-jumps @gol
11718-falign-labels -falign-loops @gol
11719-fcaller-saves @gol
11720-fcode-hoisting @gol
11721-fcrossjumping @gol
11722-fcse-follow-jumps -fcse-skip-blocks @gol
11723-fdelete-null-pointer-checks @gol
11724-fdevirtualize -fdevirtualize-speculatively @gol
11725-fexpensive-optimizations @gol
11726-ffinite-loops @gol
11727-fgcse -fgcse-lm @gol
11728-fhoist-adjacent-loads @gol
11729-finline-functions @gol
11730-finline-small-functions @gol
11731-findirect-inlining @gol
11732-fipa-bit-cp -fipa-cp -fipa-icf @gol
11733-fipa-ra -fipa-sra -fipa-vrp @gol
11734-fisolate-erroneous-paths-dereference @gol
11735-flra-remat @gol
11736-foptimize-sibling-calls @gol
11737-foptimize-strlen @gol
11738-fpartial-inlining @gol
11739-fpeephole2 @gol
11740-freorder-blocks-algorithm=stc @gol
11741-freorder-blocks-and-partition -freorder-functions @gol
11742-frerun-cse-after-loop @gol
11743-fschedule-insns -fschedule-insns2 @gol
11744-fsched-interblock -fsched-spec @gol
11745-fstore-merging @gol
11746-fstrict-aliasing @gol
11747-fthread-jumps @gol
11748-ftree-builtin-call-dce @gol
11749-ftree-loop-vectorize @gol
11750-ftree-pre @gol
11751-ftree-slp-vectorize @gol
11752-ftree-switch-conversion -ftree-tail-merge @gol
11753-ftree-vrp @gol
11754-fvect-cost-model=very-cheap}
11755
11756Please note the warning under @option{-fgcse} about
11757invoking @option{-O2} on programs that use computed gotos.
11758
11759@item -O3
11760@opindex O3
11761Optimize yet more. @option{-O3} turns on all optimizations specified
11762by @option{-O2} and also turns on the following optimization flags:
11763
11764@c Please keep the following list alphabetized!
11765@gccoptlist{-fgcse-after-reload @gol
11766-fipa-cp-clone
11767-floop-interchange @gol
11768-floop-unroll-and-jam @gol
11769-fpeel-loops @gol
11770-fpredictive-commoning @gol
11771-fsplit-loops @gol
11772-fsplit-paths @gol
11773-ftree-loop-distribution @gol
11774-ftree-partial-pre @gol
11775-funswitch-loops @gol
11776-fvect-cost-model=dynamic @gol
11777-fversion-loops-for-strides}
11778
11779@item -O0
11780@opindex O0
11781Reduce compilation time and make debugging produce the expected
11782results. This is the default.
11783
11784@item -Os
11785@opindex Os
11786Optimize for size. @option{-Os} enables all @option{-O2} optimizations
11787except those that often increase code size:
11788
11789@gccoptlist{-falign-functions -falign-jumps @gol
11790-falign-labels -falign-loops @gol
11791-fprefetch-loop-arrays -freorder-blocks-algorithm=stc}
11792
11793It also enables @option{-finline-functions}, causes the compiler to tune for
11794code size rather than execution speed, and performs further optimizations
11795designed to reduce code size.
11796
11797@item -Ofast
11798@opindex Ofast
11799Disregard strict standards compliance. @option{-Ofast} enables all
11800@option{-O3} optimizations. It also enables optimizations that are not
11801valid for all standard-compliant programs.
11802It turns on @option{-ffast-math}, @option{-fallow-store-data-races}
11803and the Fortran-specific @option{-fstack-arrays}, unless
11804@option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}.
11805It turns off @option{-fsemantic-interposition}.
11806
11807@item -Og
11808@opindex Og
11809Optimize debugging experience. @option{-Og} should be the optimization
11810level of choice for the standard edit-compile-debug cycle, offering
11811a reasonable level of optimization while maintaining fast compilation
11812and a good debugging experience. It is a better choice than @option{-O0}
11813for producing debuggable code because some compiler passes
11814that collect debug information are disabled at @option{-O0}.
11815
11816Like @option{-O0}, @option{-Og} completely disables a number of
11817optimization passes so that individual options controlling them have
11818no effect. Otherwise @option{-Og} enables all @option{-O1}
11819optimization flags except for those that may interfere with debugging:
11820
11821@gccoptlist{-fbranch-count-reg -fdelayed-branch @gol
11822-fdse -fif-conversion -fif-conversion2 @gol
11823-finline-functions-called-once @gol
11824-fmove-loop-invariants -fmove-loop-stores -fssa-phiopt @gol
11825-ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra}
11826
11827@item -Oz
11828@opindex Oz
11829Optimize aggressively for size rather than speed. This may increase
11830the number of instructions executed if those instructions require
11831fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os}
11832including enabling most @option{-O2} optimizations.
11833
11834@end table
11835
11836If you use multiple @option{-O} options, with or without level numbers,
11837the last such option is the one that is effective.
11838
11839Options of the form @option{-f@var{flag}} specify machine-independent
11840flags. Most flags have both positive and negative forms; the negative
11841form of @option{-ffoo} is @option{-fno-foo}. In the table
11842below, only one of the forms is listed---the one you typically
11843use. You can figure out the other form by either removing @samp{no-}
11844or adding it.
11845
11846The following options control specific optimizations. They are either
11847activated by @option{-O} options or are related to ones that are. You
11848can use the following flags in the rare cases when ``fine-tuning'' of
11849optimizations to be performed is desired.
11850
11851@table @gcctabopt
11852@item -fno-defer-pop
11853@opindex fno-defer-pop
11854@opindex fdefer-pop
11855For machines that must pop arguments after a function call, always pop
11856the arguments as soon as each function returns.
11857At levels @option{-O1} and higher, @option{-fdefer-pop} is the default;
11858this allows the compiler to let arguments accumulate on the stack for several
11859function calls and pop them all at once.
11860
11861@item -fforward-propagate
11862@opindex fforward-propagate
11863Perform a forward propagation pass on RTL@. The pass tries to combine two
11864instructions and checks if the result can be simplified. If loop unrolling
11865is active, two passes are performed and the second is scheduled after
11866loop unrolling.
11867
11868This option is enabled by default at optimization levels @option{-O1},
11869@option{-O2}, @option{-O3}, @option{-Os}.
11870
11871@item -ffp-contract=@var{style}
11872@opindex ffp-contract
11873@option{-ffp-contract=off} disables floating-point expression contraction.
11874@option{-ffp-contract=fast} enables floating-point expression contraction
11875such as forming of fused multiply-add operations if the target has
11876native support for them.
11877@option{-ffp-contract=on} enables floating-point expression contraction
11878if allowed by the language standard. This is currently not implemented
11879and treated equal to @option{-ffp-contract=off}.
11880
11881The default is @option{-ffp-contract=fast}.
11882
11883@item -fomit-frame-pointer
11884@opindex fomit-frame-pointer
11885Omit the frame pointer in functions that don't need one. This avoids the
11886instructions to save, set up and restore the frame pointer; on many targets
11887it also makes an extra register available.
11888
11889On some targets this flag has no effect because the standard calling sequence
11890always uses a frame pointer, so it cannot be omitted.
11891
11892Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer
11893is used in all functions. Several targets always omit the frame pointer in
11894leaf functions.
11895
11896Enabled by default at @option{-O1} and higher.
11897
11898@item -foptimize-sibling-calls
11899@opindex foptimize-sibling-calls
11900Optimize sibling and tail recursive calls.
11901
11902Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11903
11904@item -foptimize-strlen
11905@opindex foptimize-strlen
11906Optimize various standard C string functions (e.g.@: @code{strlen},
11907@code{strchr} or @code{strcpy}) and
11908their @code{_FORTIFY_SOURCE} counterparts into faster alternatives.
11909
11910Enabled at levels @option{-O2}, @option{-O3}.
11911
11912@item -fno-inline
11913@opindex fno-inline
11914@opindex finline
11915Do not expand any functions inline apart from those marked with
11916the @code{always_inline} attribute. This is the default when not
11917optimizing.
11918
11919Single functions can be exempted from inlining by marking them
11920with the @code{noinline} attribute.
11921
11922@item -finline-small-functions
11923@opindex finline-small-functions
11924Integrate functions into their callers when their body is smaller than expected
11925function call code (so overall size of program gets smaller). The compiler
11926heuristically decides which functions are simple enough to be worth integrating
11927in this way. This inlining applies to all functions, even those not declared
11928inline.
11929
11930Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11931
11932@item -findirect-inlining
11933@opindex findirect-inlining
11934Inline also indirect calls that are discovered to be known at compile
11935time thanks to previous inlining. This option has any effect only
11936when inlining itself is turned on by the @option{-finline-functions}
11937or @option{-finline-small-functions} options.
11938
11939Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
11940
11941@item -finline-functions
11942@opindex finline-functions
11943Consider all functions for inlining, even if they are not declared inline.
11944The compiler heuristically decides which functions are worth integrating
11945in this way.
11946
11947If all calls to a given function are integrated, and the function is
11948declared @code{static}, then the function is normally not output as
11949assembler code in its own right.
11950
11951Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled
11952by @option{-fprofile-use} and @option{-fauto-profile}.
11953
11954@item -finline-functions-called-once
11955@opindex finline-functions-called-once
11956Consider all @code{static} functions called once for inlining into their
11957caller even if they are not marked @code{inline}. If a call to a given
11958function is integrated, then the function is not output as assembler code
11959in its own right.
11960
11961Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os},
11962but not @option{-Og}.
11963
11964@item -fearly-inlining
11965@opindex fearly-inlining
11966Inline functions marked by @code{always_inline} and functions whose body seems
11967smaller than the function call overhead early before doing
11968@option{-fprofile-generate} instrumentation and real inlining pass. Doing so
11969makes profiling significantly cheaper and usually inlining faster on programs
11970having large chains of nested wrapper functions.
11971
11972Enabled by default.
11973
11974@item -fipa-sra
11975@opindex fipa-sra
11976Perform interprocedural scalar replacement of aggregates, removal of
11977unused parameters and replacement of parameters passed by reference
11978by parameters passed by value.
11979
11980Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}.
11981
11982@item -finline-limit=@var{n}
11983@opindex finline-limit
11984By default, GCC limits the size of functions that can be inlined. This flag
11985allows coarse control of this limit. @var{n} is the size of functions that
11986can be inlined in number of pseudo instructions.
11987
11988Inlining is actually controlled by a number of parameters, which may be
11989specified individually by using @option{--param @var{name}=@var{value}}.
11990The @option{-finline-limit=@var{n}} option sets some of these parameters
11991as follows:
11992
11993@table @gcctabopt
11994@item max-inline-insns-single
11995is set to @var{n}/2.
11996@item max-inline-insns-auto
11997is set to @var{n}/2.
11998@end table
11999
12000See below for a documentation of the individual
12001parameters controlling inlining and for the defaults of these parameters.
12002
12003@emph{Note:} there may be no value to @option{-finline-limit} that results
12004in default behavior.
12005
12006@emph{Note:} pseudo instruction represents, in this particular context, an
12007abstract measurement of function's size. In no way does it represent a count
12008of assembly instructions and as such its exact meaning might change from one
12009release to an another.
12010
12011@item -fno-keep-inline-dllexport
12012@opindex fno-keep-inline-dllexport
12013@opindex fkeep-inline-dllexport
12014This is a more fine-grained version of @option{-fkeep-inline-functions},
12015which applies only to functions that are declared using the @code{dllexport}
12016attribute or declspec. @xref{Function Attributes,,Declaring Attributes of
12017Functions}.
12018
12019@item -fkeep-inline-functions
12020@opindex fkeep-inline-functions
12021In C, emit @code{static} functions that are declared @code{inline}
12022into the object file, even if the function has been inlined into all
12023of its callers. This switch does not affect functions using the
12024@code{extern inline} extension in GNU C90@. In C++, emit any and all
12025inline functions into the object file.
12026
12027@item -fkeep-static-functions
12028@opindex fkeep-static-functions
12029Emit @code{static} functions into the object file, even if the function
12030is never used.
12031
12032@item -fkeep-static-consts
12033@opindex fkeep-static-consts
12034Emit variables declared @code{static const} when optimization isn't turned
12035on, even if the variables aren't referenced.
12036
12037GCC enables this option by default. If you want to force the compiler to
12038check if a variable is referenced, regardless of whether or not
12039optimization is turned on, use the @option{-fno-keep-static-consts} option.
12040
12041@item -fmerge-constants
12042@opindex fmerge-constants
12043Attempt to merge identical constants (string constants and floating-point
12044constants) across compilation units.
12045
12046This option is the default for optimized compilation if the assembler and
12047linker support it. Use @option{-fno-merge-constants} to inhibit this
12048behavior.
12049
12050Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12051
12052@item -fmerge-all-constants
12053@opindex fmerge-all-constants
12054Attempt to merge identical constants and identical variables.
12055
12056This option implies @option{-fmerge-constants}. In addition to
12057@option{-fmerge-constants} this considers e.g.@: even constant initialized
12058arrays or initialized constant variables with integral or floating-point
12059types. Languages like C or C++ require each variable, including multiple
12060instances of the same variable in recursive calls, to have distinct locations,
12061so using this option results in non-conforming
12062behavior.
12063
12064@item -fmodulo-sched
12065@opindex fmodulo-sched
12066Perform swing modulo scheduling immediately before the first scheduling
12067pass. This pass looks at innermost loops and reorders their
12068instructions by overlapping different iterations.
12069
12070@item -fmodulo-sched-allow-regmoves
12071@opindex fmodulo-sched-allow-regmoves
12072Perform more aggressive SMS-based modulo scheduling with register moves
12073allowed. By setting this flag certain anti-dependences edges are
12074deleted, which triggers the generation of reg-moves based on the
12075life-range analysis. This option is effective only with
12076@option{-fmodulo-sched} enabled.
12077
12078@item -fno-branch-count-reg
12079@opindex fno-branch-count-reg
12080@opindex fbranch-count-reg
12081Disable the optimization pass that scans for opportunities to use
12082``decrement and branch'' instructions on a count register instead of
12083instruction sequences that decrement a register, compare it against zero, and
12084then branch based upon the result. This option is only meaningful on
12085architectures that support such instructions, which include x86, PowerPC,
12086IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option
12087doesn't remove the decrement and branch instructions from the generated
12088instruction stream introduced by other optimization passes.
12089
12090The default is @option{-fbranch-count-reg} at @option{-O1} and higher,
12091except for @option{-Og}.
12092
12093@item -fno-function-cse
12094@opindex fno-function-cse
12095@opindex ffunction-cse
12096Do not put function addresses in registers; make each instruction that
12097calls a constant function contain the function's address explicitly.
12098
12099This option results in less efficient code, but some strange hacks
12100that alter the assembler output may be confused by the optimizations
12101performed when this option is not used.
12102
12103The default is @option{-ffunction-cse}
12104
12105@item -fno-zero-initialized-in-bss
12106@opindex fno-zero-initialized-in-bss
12107@opindex fzero-initialized-in-bss
12108If the target supports a BSS section, GCC by default puts variables that
12109are initialized to zero into BSS@. This can save space in the resulting
12110code.
12111
12112This option turns off this behavior because some programs explicitly
12113rely on variables going to the data section---e.g., so that the
12114resulting executable can find the beginning of that section and/or make
12115assumptions based on that.
12116
12117The default is @option{-fzero-initialized-in-bss}.
12118
12119@item -fthread-jumps
12120@opindex fthread-jumps
12121Perform optimizations that check to see if a jump branches to a
12122location where another comparison subsumed by the first is found. If
12123so, the first branch is redirected to either the destination of the
12124second branch or a point immediately following it, depending on whether
12125the condition is known to be true or false.
12126
12127Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
12128
12129@item -fsplit-wide-types
12130@opindex fsplit-wide-types
12131When using a type that occupies multiple registers, such as @code{long
12132long} on a 32-bit system, split the registers apart and allocate them
12133independently. This normally generates better code for those types,
12134but may make debugging more difficult.
12135
12136Enabled at levels @option{-O1}, @option{-O2}, @option{-O3},
12137@option{-Os}.
12138
12139@item -fsplit-wide-types-early
12140@opindex fsplit-wide-types-early
12141Fully split wide types early, instead of very late.
12142This option has no effect unless @option{-fsplit-wide-types} is turned on.
12143
12144This is the default on some targets.
12145
12146@item -fcse-follow-jumps
12147@opindex fcse-follow-jumps
12148In common subexpression elimination (CSE), scan through jump instructions
12149when the target of the jump is not reached by any other path. For
12150example, when CSE encounters an @code{if} statement with an
12151@code{else} clause, CSE follows the jump when the condition
12152tested is false.
12153
12154Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12155
12156@item -fcse-skip-blocks
12157@opindex fcse-skip-blocks
12158This is similar to @option{-fcse-follow-jumps}, but causes CSE to
12159follow jumps that conditionally skip over blocks. When CSE
12160encounters a simple @code{if} statement with no else clause,
12161@option{-fcse-skip-blocks} causes CSE to follow the jump around the
12162body of the @code{if}.
12163
12164Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12165
12166@item -frerun-cse-after-loop
12167@opindex frerun-cse-after-loop
12168Re-run common subexpression elimination after loop optimizations are
12169performed.
12170
12171Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12172
12173@item -fgcse
12174@opindex fgcse
12175Perform a global common subexpression elimination pass.
12176This pass also performs global constant and copy propagation.
12177
12178@emph{Note:} When compiling a program using computed gotos, a GCC
12179extension, you may get better run-time performance if you disable
12180the global common subexpression elimination pass by adding
12181@option{-fno-gcse} to the command line.
12182
12183Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12184
12185@item -fgcse-lm
12186@opindex fgcse-lm
12187When @option{-fgcse-lm} is enabled, global common subexpression elimination
12188attempts to move loads that are only killed by stores into themselves. This
12189allows a loop containing a load/store sequence to be changed to a load outside
12190the loop, and a copy/store within the loop.
12191
12192Enabled by default when @option{-fgcse} is enabled.
12193
12194@item -fgcse-sm
12195@opindex fgcse-sm
12196When @option{-fgcse-sm} is enabled, a store motion pass is run after
12197global common subexpression elimination. This pass attempts to move
12198stores out of loops. When used in conjunction with @option{-fgcse-lm},
12199loops containing a load/store sequence can be changed to a load before
12200the loop and a store after the loop.
12201
12202Not enabled at any optimization level.
12203
12204@item -fgcse-las
12205@opindex fgcse-las
12206When @option{-fgcse-las} is enabled, the global common subexpression
12207elimination pass eliminates redundant loads that come after stores to the
12208same memory location (both partial and full redundancies).
12209
12210Not enabled at any optimization level.
12211
12212@item -fgcse-after-reload
12213@opindex fgcse-after-reload
12214When @option{-fgcse-after-reload} is enabled, a redundant load elimination
12215pass is performed after reload. The purpose of this pass is to clean up
12216redundant spilling.
12217
12218Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}.
12219
12220@item -faggressive-loop-optimizations
12221@opindex faggressive-loop-optimizations
12222This option tells the loop optimizer to use language constraints to
12223derive bounds for the number of iterations of a loop. This assumes that
12224loop code does not invoke undefined behavior by for example causing signed
12225integer overflows or out-of-bound array accesses. The bounds for the
12226number of iterations of a loop are used to guide loop unrolling and peeling
12227and loop exit test optimizations.
12228This option is enabled by default.
12229
12230@item -funconstrained-commons
12231@opindex funconstrained-commons
12232This option tells the compiler that variables declared in common blocks
12233(e.g.@: Fortran) may later be overridden with longer trailing arrays. This
12234prevents certain optimizations that depend on knowing the array bounds.
12235
12236@item -fcrossjumping
12237@opindex fcrossjumping
12238Perform cross-jumping transformation.
12239This transformation unifies equivalent code and saves code size. The
12240resulting code may or may not perform better than without cross-jumping.
12241
12242Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12243
12244@item -fauto-inc-dec
12245@opindex fauto-inc-dec
12246Combine increments or decrements of addresses with memory accesses.
12247This pass is always skipped on architectures that do not have
12248instructions to support this. Enabled by default at @option{-O1} and
12249higher on architectures that support this.
12250
12251@item -fdce
12252@opindex fdce
12253Perform dead code elimination (DCE) on RTL@.
12254Enabled by default at @option{-O1} and higher.
12255
12256@item -fdse
12257@opindex fdse
12258Perform dead store elimination (DSE) on RTL@.
12259Enabled by default at @option{-O1} and higher.
12260
12261@item -fif-conversion
12262@opindex fif-conversion
12263Attempt to transform conditional jumps into branch-less equivalents. This
12264includes use of conditional moves, min, max, set flags and abs instructions, and
12265some tricks doable by standard arithmetics. The use of conditional execution
12266on chips where it is available is controlled by @option{-fif-conversion2}.
12267
12268Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12269not with @option{-Og}.
12270
12271@item -fif-conversion2
12272@opindex fif-conversion2
12273Use conditional execution (where available) to transform conditional jumps into
12274branch-less equivalents.
12275
12276Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but
12277not with @option{-Og}.
12278
12279@item -fdeclone-ctor-dtor
12280@opindex fdeclone-ctor-dtor
12281The C++ ABI requires multiple entry points for constructors and
12282destructors: one for a base subobject, one for a complete object, and
12283one for a virtual destructor that calls operator delete afterwards.
12284For a hierarchy with virtual bases, the base and complete variants are
12285clones, which means two copies of the function. With this option, the
12286base and complete variants are changed to be thunks that call a common
12287implementation.
12288
12289Enabled by @option{-Os}.
12290
12291@item -fdelete-null-pointer-checks
12292@opindex fdelete-null-pointer-checks
12293Assume that programs cannot safely dereference null pointers, and that
12294no code or data element resides at address zero.
12295This option enables simple constant
12296folding optimizations at all optimization levels. In addition, other
12297optimization passes in GCC use this flag to control global dataflow
12298analyses that eliminate useless checks for null pointers; these assume
12299that a memory access to address zero always results in a trap, so
12300that if a pointer is checked after it has already been dereferenced,
12301it cannot be null.
12302
12303Note however that in some environments this assumption is not true.
12304Use @option{-fno-delete-null-pointer-checks} to disable this optimization
12305for programs that depend on that behavior.
12306
12307This option is enabled by default on most targets. On Nios II ELF, it
12308defaults to off. On AVR and MSP430, this option is completely disabled.
12309
12310Passes that use the dataflow information
12311are enabled independently at different optimization levels.
12312
12313@item -fdevirtualize
12314@opindex fdevirtualize
12315Attempt to convert calls to virtual functions to direct calls. This
12316is done both within a procedure and interprocedurally as part of
12317indirect inlining (@option{-findirect-inlining}) and interprocedural constant
12318propagation (@option{-fipa-cp}).
12319Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12320
12321@item -fdevirtualize-speculatively
12322@opindex fdevirtualize-speculatively
12323Attempt to convert calls to virtual functions to speculative direct calls.
12324Based on the analysis of the type inheritance graph, determine for a given call
12325the set of likely targets. If the set is small, preferably of size 1, change
12326the call into a conditional deciding between direct and indirect calls. The
12327speculative calls enable more optimizations, such as inlining. When they seem
12328useless after further optimization, they are converted back into original form.
12329
12330@item -fdevirtualize-at-ltrans
12331@opindex fdevirtualize-at-ltrans
12332Stream extra information needed for aggressive devirtualization when running
12333the link-time optimizer in local transformation mode.
12334This option enables more devirtualization but
12335significantly increases the size of streamed data. For this reason it is
12336disabled by default.
12337
12338@item -fexpensive-optimizations
12339@opindex fexpensive-optimizations
12340Perform a number of minor optimizations that are relatively expensive.
12341
12342Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12343
12344@item -free
12345@opindex free
12346Attempt to remove redundant extension instructions. This is especially
12347helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit
12348registers after writing to their lower 32-bit half.
12349
12350Enabled for Alpha, AArch64 and x86 at levels @option{-O2},
12351@option{-O3}, @option{-Os}.
12352
12353@item -fno-lifetime-dse
12354@opindex fno-lifetime-dse
12355@opindex flifetime-dse
12356In C++ the value of an object is only affected by changes within its
12357lifetime: when the constructor begins, the object has an indeterminate
12358value, and any changes during the lifetime of the object are dead when
12359the object is destroyed. Normally dead store elimination will take
12360advantage of this; if your code relies on the value of the object
12361storage persisting beyond the lifetime of the object, you can use this
12362flag to disable this optimization. To preserve stores before the
12363constructor starts (e.g.@: because your operator new clears the object
12364storage) but still treat the object as dead after the destructor, you
12365can use @option{-flifetime-dse=1}. The default behavior can be
12366explicitly selected with @option{-flifetime-dse=2}.
12367@option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}.
12368
12369@item -flive-range-shrinkage
12370@opindex flive-range-shrinkage
12371Attempt to decrease register pressure through register live range
12372shrinkage. This is helpful for fast processors with small or moderate
12373size register sets.
12374
12375@item -fira-algorithm=@var{algorithm}
12376@opindex fira-algorithm
12377Use the specified coloring algorithm for the integrated register
12378allocator. The @var{algorithm} argument can be @samp{priority}, which
12379specifies Chow's priority coloring, or @samp{CB}, which specifies
12380Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented
12381for all architectures, but for those targets that do support it, it is
12382the default because it generates better code.
12383
12384@item -fira-region=@var{region}
12385@opindex fira-region
12386Use specified regions for the integrated register allocator. The
12387@var{region} argument should be one of the following:
12388
12389@table @samp
12390
12391@item all
12392Use all loops as register allocation regions.
12393This can give the best results for machines with a small and/or
12394irregular register set.
12395
12396@item mixed
12397Use all loops except for loops with small register pressure
12398as the regions. This value usually gives
12399the best results in most cases and for most architectures,
12400and is enabled by default when compiling with optimization for speed
12401(@option{-O}, @option{-O2}, @dots{}).
12402
12403@item one
12404Use all functions as a single region.
12405This typically results in the smallest code size, and is enabled by default for
12406@option{-Os} or @option{-O0}.
12407
12408@end table
12409
12410@item -fira-hoist-pressure
12411@opindex fira-hoist-pressure
12412Use IRA to evaluate register pressure in the code hoisting pass for
12413decisions to hoist expressions. This option usually results in smaller
12414code, but it can slow the compiler down.
12415
12416This option is enabled at level @option{-Os} for all targets.
12417
12418@item -fira-loop-pressure
12419@opindex fira-loop-pressure
12420Use IRA to evaluate register pressure in loops for decisions to move
12421loop invariants. This option usually results in generation
12422of faster and smaller code on machines with large register files (>= 32
12423registers), but it can slow the compiler down.
12424
12425This option is enabled at level @option{-O3} for some targets.
12426
12427@item -fno-ira-share-save-slots
12428@opindex fno-ira-share-save-slots
12429@opindex fira-share-save-slots
12430Disable sharing of stack slots used for saving call-used hard
12431registers living through a call. Each hard register gets a
12432separate stack slot, and as a result function stack frames are
12433larger.
12434
12435@item -fno-ira-share-spill-slots
12436@opindex fno-ira-share-spill-slots
12437@opindex fira-share-spill-slots
12438Disable sharing of stack slots allocated for pseudo-registers. Each
12439pseudo-register that does not get a hard register gets a separate
12440stack slot, and as a result function stack frames are larger.
12441
12442@item -flra-remat
12443@opindex flra-remat
12444Enable CFG-sensitive rematerialization in LRA. Instead of loading
12445values of spilled pseudos, LRA tries to rematerialize (recalculate)
12446values if it is profitable.
12447
12448Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12449
12450@item -fdelayed-branch
12451@opindex fdelayed-branch
12452If supported for the target machine, attempt to reorder instructions
12453to exploit instruction slots available after delayed branch
12454instructions.
12455
12456Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os},
12457but not at @option{-Og}.
12458
12459@item -fschedule-insns
12460@opindex fschedule-insns
12461If supported for the target machine, attempt to reorder instructions to
12462eliminate execution stalls due to required data being unavailable. This
12463helps machines that have slow floating point or memory load instructions
12464by allowing other instructions to be issued until the result of the load
12465or floating-point instruction is required.
12466
12467Enabled at levels @option{-O2}, @option{-O3}.
12468
12469@item -fschedule-insns2
12470@opindex fschedule-insns2
12471Similar to @option{-fschedule-insns}, but requests an additional pass of
12472instruction scheduling after register allocation has been done. This is
12473especially useful on machines with a relatively small number of
12474registers and where memory load instructions take more than one cycle.
12475
12476Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12477
12478@item -fno-sched-interblock
12479@opindex fno-sched-interblock
12480@opindex fsched-interblock
12481Disable instruction scheduling across basic blocks, which
12482is normally enabled when scheduling before register allocation, i.e.@:
12483with @option{-fschedule-insns} or at @option{-O2} or higher.
12484
12485@item -fno-sched-spec
12486@opindex fno-sched-spec
12487@opindex fsched-spec
12488Disable speculative motion of non-load instructions, which
12489is normally enabled when scheduling before register allocation, i.e.@:
12490with @option{-fschedule-insns} or at @option{-O2} or higher.
12491
12492@item -fsched-pressure
12493@opindex fsched-pressure
12494Enable register pressure sensitive insn scheduling before register
12495allocation. This only makes sense when scheduling before register
12496allocation is enabled, i.e.@: with @option{-fschedule-insns} or at
12497@option{-O2} or higher. Usage of this option can improve the
12498generated code and decrease its size by preventing register pressure
12499increase above the number of available hard registers and subsequent
12500spills in register allocation.
12501
12502@item -fsched-spec-load
12503@opindex fsched-spec-load
12504Allow speculative motion of some load instructions. This only makes
12505sense when scheduling before register allocation, i.e.@: with
12506@option{-fschedule-insns} or at @option{-O2} or higher.
12507
12508@item -fsched-spec-load-dangerous
12509@opindex fsched-spec-load-dangerous
12510Allow speculative motion of more load instructions. This only makes
12511sense when scheduling before register allocation, i.e.@: with
12512@option{-fschedule-insns} or at @option{-O2} or higher.
12513
12514@item -fsched-stalled-insns
12515@itemx -fsched-stalled-insns=@var{n}
12516@opindex fsched-stalled-insns
12517Define how many insns (if any) can be moved prematurely from the queue
12518of stalled insns into the ready list during the second scheduling pass.
12519@option{-fno-sched-stalled-insns} means that no insns are moved
12520prematurely, @option{-fsched-stalled-insns=0} means there is no limit
12521on how many queued insns can be moved prematurely.
12522@option{-fsched-stalled-insns} without a value is equivalent to
12523@option{-fsched-stalled-insns=1}.
12524
12525@item -fsched-stalled-insns-dep
12526@itemx -fsched-stalled-insns-dep=@var{n}
12527@opindex fsched-stalled-insns-dep
12528Define how many insn groups (cycles) are examined for a dependency
12529on a stalled insn that is a candidate for premature removal from the queue
12530of stalled insns. This has an effect only during the second scheduling pass,
12531and only if @option{-fsched-stalled-insns} is used.
12532@option{-fno-sched-stalled-insns-dep} is equivalent to
12533@option{-fsched-stalled-insns-dep=0}.
12534@option{-fsched-stalled-insns-dep} without a value is equivalent to
12535@option{-fsched-stalled-insns-dep=1}.
12536
12537@item -fsched2-use-superblocks
12538@opindex fsched2-use-superblocks
12539When scheduling after register allocation, use superblock scheduling.
12540This allows motion across basic block boundaries,
12541resulting in faster schedules. This option is experimental, as not all machine
12542descriptions used by GCC model the CPU closely enough to avoid unreliable
12543results from the algorithm.
12544
12545This only makes sense when scheduling after register allocation, i.e.@: with
12546@option{-fschedule-insns2} or at @option{-O2} or higher.
12547
12548@item -fsched-group-heuristic
12549@opindex fsched-group-heuristic
12550Enable the group heuristic in the scheduler. This heuristic favors
12551the instruction that belongs to a schedule group. This is enabled
12552by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12553or @option{-fschedule-insns2} or at @option{-O2} or higher.
12554
12555@item -fsched-critical-path-heuristic
12556@opindex fsched-critical-path-heuristic
12557Enable the critical-path heuristic in the scheduler. This heuristic favors
12558instructions on the critical path. This is enabled by default when
12559scheduling is enabled, i.e.@: with @option{-fschedule-insns}
12560or @option{-fschedule-insns2} or at @option{-O2} or higher.
12561
12562@item -fsched-spec-insn-heuristic
12563@opindex fsched-spec-insn-heuristic
12564Enable the speculative instruction heuristic in the scheduler. This
12565heuristic favors speculative instructions with greater dependency weakness.
12566This is enabled by default when scheduling is enabled, i.e.@:
12567with @option{-fschedule-insns} or @option{-fschedule-insns2}
12568or at @option{-O2} or higher.
12569
12570@item -fsched-rank-heuristic
12571@opindex fsched-rank-heuristic
12572Enable the rank heuristic in the scheduler. This heuristic favors
12573the instruction belonging to a basic block with greater size or frequency.
12574This is enabled by default when scheduling is enabled, i.e.@:
12575with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12576at @option{-O2} or higher.
12577
12578@item -fsched-last-insn-heuristic
12579@opindex fsched-last-insn-heuristic
12580Enable the last-instruction heuristic in the scheduler. This heuristic
12581favors the instruction that is less dependent on the last instruction
12582scheduled. This is enabled by default when scheduling is enabled,
12583i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12584at @option{-O2} or higher.
12585
12586@item -fsched-dep-count-heuristic
12587@opindex fsched-dep-count-heuristic
12588Enable the dependent-count heuristic in the scheduler. This heuristic
12589favors the instruction that has more instructions depending on it.
12590This is enabled by default when scheduling is enabled, i.e.@:
12591with @option{-fschedule-insns} or @option{-fschedule-insns2} or
12592at @option{-O2} or higher.
12593
12594@item -freschedule-modulo-scheduled-loops
12595@opindex freschedule-modulo-scheduled-loops
12596Modulo scheduling is performed before traditional scheduling. If a loop
12597is modulo scheduled, later scheduling passes may change its schedule.
12598Use this option to control that behavior.
12599
12600@item -fselective-scheduling
12601@opindex fselective-scheduling
12602Schedule instructions using selective scheduling algorithm. Selective
12603scheduling runs instead of the first scheduler pass.
12604
12605@item -fselective-scheduling2
12606@opindex fselective-scheduling2
12607Schedule instructions using selective scheduling algorithm. Selective
12608scheduling runs instead of the second scheduler pass.
12609
12610@item -fsel-sched-pipelining
12611@opindex fsel-sched-pipelining
12612Enable software pipelining of innermost loops during selective scheduling.
12613This option has no effect unless one of @option{-fselective-scheduling} or
12614@option{-fselective-scheduling2} is turned on.
12615
12616@item -fsel-sched-pipelining-outer-loops
12617@opindex fsel-sched-pipelining-outer-loops
12618When pipelining loops during selective scheduling, also pipeline outer loops.
12619This option has no effect unless @option{-fsel-sched-pipelining} is turned on.
12620
12621@item -fsemantic-interposition
12622@opindex fsemantic-interposition
12623Some object formats, like ELF, allow interposing of symbols by the
12624dynamic linker.
12625This means that for symbols exported from the DSO, the compiler cannot perform
12626interprocedural propagation, inlining and other optimizations in anticipation
12627that the function or variable in question may change. While this feature is
12628useful, for example, to rewrite memory allocation functions by a debugging
12629implementation, it is expensive in the terms of code quality.
12630With @option{-fno-semantic-interposition} the compiler assumes that
12631if interposition happens for functions the overwriting function will have
12632precisely the same semantics (and side effects).
12633Similarly if interposition happens
12634for variables, the constructor of the variable will be the same. The flag
12635has no effect for functions explicitly declared inline
12636(where it is never allowed for interposition to change semantics)
12637and for symbols explicitly declared weak.
12638
12639@item -fshrink-wrap
12640@opindex fshrink-wrap
12641Emit function prologues only before parts of the function that need it,
12642rather than at the top of the function. This flag is enabled by default at
12643@option{-O} and higher.
12644
12645@item -fshrink-wrap-separate
12646@opindex fshrink-wrap-separate
12647Shrink-wrap separate parts of the prologue and epilogue separately, so that
12648those parts are only executed when needed.
12649This option is on by default, but has no effect unless @option{-fshrink-wrap}
12650is also turned on and the target supports this.
12651
12652@item -fcaller-saves
12653@opindex fcaller-saves
12654Enable allocation of values to registers that are clobbered by
12655function calls, by emitting extra instructions to save and restore the
12656registers around such calls. Such allocation is done only when it
12657seems to result in better code.
12658
12659This option is always enabled by default on certain machines, usually
12660those which have no call-preserved registers to use instead.
12661
12662Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
12663
12664@item -fcombine-stack-adjustments
12665@opindex fcombine-stack-adjustments
12666Tracks stack adjustments (pushes and pops) and stack memory references
12667and then tries to find ways to combine them.
12668
12669Enabled by default at @option{-O1} and higher.
12670
12671@item -fipa-ra
12672@opindex fipa-ra
12673Use caller save registers for allocation if those registers are not used by
12674any called function. In that case it is not necessary to save and restore
12675them around calls. This is only possible if called functions are part of
12676same compilation unit as current function and they are compiled before it.
12677
12678Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option
12679is disabled if generated code will be instrumented for profiling
12680(@option{-p}, or @option{-pg}) or if callee's register usage cannot be known
12681exactly (this happens on targets that do not expose prologues
12682and epilogues in RTL).
12683
12684@item -fconserve-stack
12685@opindex fconserve-stack
12686Attempt to minimize stack usage. The compiler attempts to use less
12687stack space, even if that makes the program slower. This option
12688implies setting the @option{large-stack-frame} parameter to 100
12689and the @option{large-stack-frame-growth} parameter to 400.
12690
12691@item -ftree-reassoc
12692@opindex ftree-reassoc
12693Perform reassociation on trees. This flag is enabled by default
12694at @option{-O1} and higher.
12695
12696@item -fcode-hoisting
12697@opindex fcode-hoisting
12698Perform code hoisting. Code hoisting tries to move the
12699evaluation of expressions executed on all paths to the function exit
12700as early as possible. This is especially useful as a code size
12701optimization, but it often helps for code speed as well.
12702This flag is enabled by default at @option{-O2} and higher.
12703
12704@item -ftree-pre
12705@opindex ftree-pre
12706Perform partial redundancy elimination (PRE) on trees. This flag is
12707enabled by default at @option{-O2} and @option{-O3}.
12708
12709@item -ftree-partial-pre
12710@opindex ftree-partial-pre
12711Make partial redundancy elimination (PRE) more aggressive. This flag is
12712enabled by default at @option{-O3}.
12713
12714@item -ftree-forwprop
12715@opindex ftree-forwprop
12716Perform forward propagation on trees. This flag is enabled by default
12717at @option{-O1} and higher.
12718
12719@item -ftree-fre
12720@opindex ftree-fre
12721Perform full redundancy elimination (FRE) on trees. The difference
12722between FRE and PRE is that FRE only considers expressions
12723that are computed on all paths leading to the redundant computation.
12724This analysis is faster than PRE, though it exposes fewer redundancies.
12725This flag is enabled by default at @option{-O1} and higher.
12726
12727@item -ftree-phiprop
12728@opindex ftree-phiprop
12729Perform hoisting of loads from conditional pointers on trees. This
12730pass is enabled by default at @option{-O1} and higher.
12731
12732@item -fhoist-adjacent-loads
12733@opindex fhoist-adjacent-loads
12734Speculatively hoist loads from both branches of an if-then-else if the
12735loads are from adjacent locations in the same structure and the target
12736architecture has a conditional move instruction. This flag is enabled
12737by default at @option{-O2} and higher.
12738
12739@item -ftree-copy-prop
12740@opindex ftree-copy-prop
12741Perform copy propagation on trees. This pass eliminates unnecessary
12742copy operations. This flag is enabled by default at @option{-O1} and
12743higher.
12744
12745@item -fipa-pure-const
12746@opindex fipa-pure-const
12747Discover which functions are pure or constant.
12748Enabled by default at @option{-O1} and higher.
12749
12750@item -fipa-reference
12751@opindex fipa-reference
12752Discover which static variables do not escape the
12753compilation unit.
12754Enabled by default at @option{-O1} and higher.
12755
12756@item -fipa-reference-addressable
12757@opindex fipa-reference-addressable
12758Discover read-only, write-only and non-addressable static variables.
12759Enabled by default at @option{-O1} and higher.
12760
12761@item -fipa-stack-alignment
12762@opindex fipa-stack-alignment
12763Reduce stack alignment on call sites if possible.
12764Enabled by default.
12765
12766@item -fipa-pta
12767@opindex fipa-pta
12768Perform interprocedural pointer analysis and interprocedural modification
12769and reference analysis. This option can cause excessive memory and
12770compile-time usage on large compilation units. It is not enabled by
12771default at any optimization level.
12772
12773@item -fipa-profile
12774@opindex fipa-profile
12775Perform interprocedural profile propagation. The functions called only from
12776cold functions are marked as cold. Also functions executed once (such as
12777@code{cold}, @code{noreturn}, static constructors or destructors) are
12778identified. Cold functions and loop less parts of functions executed once are
12779then optimized for size.
12780Enabled by default at @option{-O1} and higher.
12781
12782@item -fipa-modref
12783@opindex fipa-modref
12784Perform interprocedural mod/ref analysis. This optimization analyzes the side
12785effects of functions (memory locations that are modified or referenced) and
12786enables better optimization across the function call boundary. This flag is
12787enabled by default at @option{-O1} and higher.
12788
12789@item -fipa-cp
12790@opindex fipa-cp
12791Perform interprocedural constant propagation.
12792This optimization analyzes the program to determine when values passed
12793to functions are constants and then optimizes accordingly.
12794This optimization can substantially increase performance
12795if the application has constants passed to functions.
12796This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}.
12797It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12798
12799@item -fipa-cp-clone
12800@opindex fipa-cp-clone
12801Perform function cloning to make interprocedural constant propagation stronger.
12802When enabled, interprocedural constant propagation performs function cloning
12803when externally visible function can be called with constant arguments.
12804Because this optimization can create multiple copies of functions,
12805it may significantly increase code size
12806(see @option{--param ipa-cp-unit-growth=@var{value}}).
12807This flag is enabled by default at @option{-O3}.
12808It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
12809
12810@item -fipa-bit-cp
12811@opindex fipa-bit-cp
12812When enabled, perform interprocedural bitwise constant
12813propagation. This flag is enabled by default at @option{-O2} and
12814by @option{-fprofile-use} and @option{-fauto-profile}.
12815It requires that @option{-fipa-cp} is enabled.
12816
12817@item -fipa-vrp
12818@opindex fipa-vrp
12819When enabled, perform interprocedural propagation of value
12820ranges. This flag is enabled by default at @option{-O2}. It requires
12821that @option{-fipa-cp} is enabled.
12822
12823@item -fipa-icf
12824@opindex fipa-icf
12825Perform Identical Code Folding for functions and read-only variables.
12826The optimization reduces code size and may disturb unwind stacks by replacing
12827a function by equivalent one with a different name. The optimization works
12828more effectively with link-time optimization enabled.
12829
12830Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF
12831works on different levels and thus the optimizations are not same - there are
12832equivalences that are found only by GCC and equivalences found only by Gold.
12833
12834This flag is enabled by default at @option{-O2} and @option{-Os}.
12835
12836@item -flive-patching=@var{level}
12837@opindex flive-patching
12838Control GCC's optimizations to produce output suitable for live-patching.
12839
12840If the compiler's optimization uses a function's body or information extracted
12841from its body to optimize/change another function, the latter is called an
12842impacted function of the former. If a function is patched, its impacted
12843functions should be patched too.
12844
12845The impacted functions are determined by the compiler's interprocedural
12846optimizations. For example, a caller is impacted when inlining a function
12847into its caller,
12848cloning a function and changing its caller to call this new clone,
12849or extracting a function's pureness/constness information to optimize
12850its direct or indirect callers, etc.
12851
12852Usually, the more IPA optimizations enabled, the larger the number of
12853impacted functions for each function. In order to control the number of
12854impacted functions and more easily compute the list of impacted function,
12855IPA optimizations can be partially enabled at two different levels.
12856
12857The @var{level} argument should be one of the following:
12858
12859@table @samp
12860
12861@item inline-clone
12862
12863Only enable inlining and cloning optimizations, which includes inlining,
12864cloning, interprocedural scalar replacement of aggregates and partial inlining.
12865As a result, when patching a function, all its callers and its clones'
12866callers are impacted, therefore need to be patched as well.
12867
12868@option{-flive-patching=inline-clone} disables the following optimization flags:
12869@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra @gol
12870-fipa-icf -fipa-icf-functions -fipa-icf-variables @gol
12871-fipa-bit-cp -fipa-vrp -fipa-pure-const -fipa-reference-addressable @gol
12872-fipa-stack-alignment -fipa-modref}
12873
12874@item inline-only-static
12875
12876Only enable inlining of static functions.
12877As a result, when patching a static function, all its callers are impacted
12878and so need to be patched as well.
12879
12880In addition to all the flags that @option{-flive-patching=inline-clone}
12881disables,
12882@option{-flive-patching=inline-only-static} disables the following additional
12883optimization flags:
12884@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp}
12885
12886@end table
12887
12888When @option{-flive-patching} is specified without any value, the default value
12889is @var{inline-clone}.
12890
12891This flag is disabled by default.
12892
12893Note that @option{-flive-patching} is not supported with link-time optimization
12894(@option{-flto}).
12895
12896@item -fisolate-erroneous-paths-dereference
12897@opindex fisolate-erroneous-paths-dereference
12898Detect paths that trigger erroneous or undefined behavior due to
12899dereferencing a null pointer. Isolate those paths from the main control
12900flow and turn the statement with erroneous or undefined behavior into a trap.
12901This flag is enabled by default at @option{-O2} and higher and depends on
12902@option{-fdelete-null-pointer-checks} also being enabled.
12903
12904@item -fisolate-erroneous-paths-attribute
12905@opindex fisolate-erroneous-paths-attribute
12906Detect paths that trigger erroneous or undefined behavior due to a null value
12907being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull}
12908attribute. Isolate those paths from the main control flow and turn the
12909statement with erroneous or undefined behavior into a trap. This is not
12910currently enabled, but may be enabled by @option{-O2} in the future.
12911
12912@item -ftree-sink
12913@opindex ftree-sink
12914Perform forward store motion on trees. This flag is
12915enabled by default at @option{-O1} and higher.
12916
12917@item -ftree-bit-ccp
12918@opindex ftree-bit-ccp
12919Perform sparse conditional bit constant propagation on trees and propagate
12920pointer alignment information.
12921This pass only operates on local scalar variables and is enabled by default
12922at @option{-O1} and higher, except for @option{-Og}.
12923It requires that @option{-ftree-ccp} is enabled.
12924
12925@item -ftree-ccp
12926@opindex ftree-ccp
12927Perform sparse conditional constant propagation (CCP) on trees. This
12928pass only operates on local scalar variables and is enabled by default
12929at @option{-O1} and higher.
12930
12931@item -fssa-backprop
12932@opindex fssa-backprop
12933Propagate information about uses of a value up the definition chain
12934in order to simplify the definitions. For example, this pass strips
12935sign operations if the sign of a value never matters. The flag is
12936enabled by default at @option{-O1} and higher.
12937
12938@item -fssa-phiopt
12939@opindex fssa-phiopt
12940Perform pattern matching on SSA PHI nodes to optimize conditional
12941code. This pass is enabled by default at @option{-O1} and higher,
12942except for @option{-Og}.
12943
12944@item -ftree-switch-conversion
12945@opindex ftree-switch-conversion
12946Perform conversion of simple initializations in a switch to
12947initializations from a scalar array. This flag is enabled by default
12948at @option{-O2} and higher.
12949
12950@item -ftree-tail-merge
12951@opindex ftree-tail-merge
12952Look for identical code sequences. When found, replace one with a jump to the
12953other. This optimization is known as tail merging or cross jumping. This flag
12954is enabled by default at @option{-O2} and higher. The compilation time
12955in this pass can
12956be limited using @option{max-tail-merge-comparisons} parameter and
12957@option{max-tail-merge-iterations} parameter.
12958
12959@item -ftree-dce
12960@opindex ftree-dce
12961Perform dead code elimination (DCE) on trees. This flag is enabled by
12962default at @option{-O1} and higher.
12963
12964@item -ftree-builtin-call-dce
12965@opindex ftree-builtin-call-dce
12966Perform conditional dead code elimination (DCE) for calls to built-in functions
12967that may set @code{errno} but are otherwise free of side effects. This flag is
12968enabled by default at @option{-O2} and higher if @option{-Os} is not also
12969specified.
12970
12971@item -ffinite-loops
12972@opindex ffinite-loops
12973@opindex fno-finite-loops
12974Assume that a loop with an exit will eventually take the exit and not loop
12975indefinitely. This allows the compiler to remove loops that otherwise have
12976no side-effects, not considering eventual endless looping as such.
12977
12978This option is enabled by default at @option{-O2} for C++ with -std=c++11
12979or higher.
12980
12981@item -ftree-dominator-opts
12982@opindex ftree-dominator-opts
12983Perform a variety of simple scalar cleanups (constant/copy
12984propagation, redundancy elimination, range propagation and expression
12985simplification) based on a dominator tree traversal. This also
12986performs jump threading (to reduce jumps to jumps). This flag is
12987enabled by default at @option{-O1} and higher.
12988
12989@item -ftree-dse
12990@opindex ftree-dse
12991Perform dead store elimination (DSE) on trees. A dead store is a store into
12992a memory location that is later overwritten by another store without
12993any intervening loads. In this case the earlier store can be deleted. This
12994flag is enabled by default at @option{-O1} and higher.
12995
12996@item -ftree-ch
12997@opindex ftree-ch
12998Perform loop header copying on trees. This is beneficial since it increases
12999effectiveness of code motion optimizations. It also saves one jump. This flag
13000is enabled by default at @option{-O1} and higher. It is not enabled
13001for @option{-Os}, since it usually increases code size.
13002
13003@item -ftree-loop-optimize
13004@opindex ftree-loop-optimize
13005Perform loop optimizations on trees. This flag is enabled by default
13006at @option{-O1} and higher.
13007
13008@item -ftree-loop-linear
13009@itemx -floop-strip-mine
13010@itemx -floop-block
13011@opindex ftree-loop-linear
13012@opindex floop-strip-mine
13013@opindex floop-block
13014Perform loop nest optimizations. Same as
13015@option{-floop-nest-optimize}. To use this code transformation, GCC has
13016to be configured with @option{--with-isl} to enable the Graphite loop
13017transformation infrastructure.
13018
13019@item -fgraphite-identity
13020@opindex fgraphite-identity
13021Enable the identity transformation for graphite. For every SCoP we generate
13022the polyhedral representation and transform it back to gimple. Using
13023@option{-fgraphite-identity} we can check the costs or benefits of the
13024GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations
13025are also performed by the code generator isl, like index splitting and
13026dead code elimination in loops.
13027
13028@item -floop-nest-optimize
13029@opindex floop-nest-optimize
13030Enable the isl based loop nest optimizer. This is a generic loop nest
13031optimizer based on the Pluto optimization algorithms. It calculates a loop
13032structure optimized for data-locality and parallelism. This option
13033is experimental.
13034
13035@item -floop-parallelize-all
13036@opindex floop-parallelize-all
13037Use the Graphite data dependence analysis to identify loops that can
13038be parallelized. Parallelize all the loops that can be analyzed to
13039not contain loop carried dependences without checking that it is
13040profitable to parallelize the loops.
13041
13042@item -ftree-coalesce-vars
13043@opindex ftree-coalesce-vars
13044While transforming the program out of the SSA representation, attempt to
13045reduce copying by coalescing versions of different user-defined
13046variables, instead of just compiler temporaries. This may severely
13047limit the ability to debug an optimized program compiled with
13048@option{-fno-var-tracking-assignments}. In the negated form, this flag
13049prevents SSA coalescing of user variables. This option is enabled by
13050default if optimization is enabled, and it does very little otherwise.
13051
13052@item -ftree-loop-if-convert
13053@opindex ftree-loop-if-convert
13054Attempt to transform conditional jumps in the innermost loops to
13055branch-less equivalents. The intent is to remove control-flow from
13056the innermost loops in order to improve the ability of the
13057vectorization pass to handle these loops. This is enabled by default
13058if vectorization is enabled.
13059
13060@item -ftree-loop-distribution
13061@opindex ftree-loop-distribution
13062Perform loop distribution. This flag can improve cache performance on
13063big loop bodies and allow further loop optimizations, like
13064parallelization or vectorization, to take place. For example, the loop
13065@smallexample
13066DO I = 1, N
13067 A(I) = B(I) + C
13068 D(I) = E(I) * F
13069ENDDO
13070@end smallexample
13071is transformed to
13072@smallexample
13073DO I = 1, N
13074 A(I) = B(I) + C
13075ENDDO
13076DO I = 1, N
13077 D(I) = E(I) * F
13078ENDDO
13079@end smallexample
13080This flag is enabled by default at @option{-O3}.
13081It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13082
13083@item -ftree-loop-distribute-patterns
13084@opindex ftree-loop-distribute-patterns
13085Perform loop distribution of patterns that can be code generated with
13086calls to a library. This flag is enabled by default at @option{-O2} and
13087higher, and by @option{-fprofile-use} and @option{-fauto-profile}.
13088
13089This pass distributes the initialization loops and generates a call to
13090memset zero. For example, the loop
13091@smallexample
13092DO I = 1, N
13093 A(I) = 0
13094 B(I) = A(I) + I
13095ENDDO
13096@end smallexample
13097is transformed to
13098@smallexample
13099DO I = 1, N
13100 A(I) = 0
13101ENDDO
13102DO I = 1, N
13103 B(I) = A(I) + I
13104ENDDO
13105@end smallexample
13106and the initialization loop is transformed into a call to memset zero.
13107This flag is enabled by default at @option{-O3}.
13108It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13109
13110@item -floop-interchange
13111@opindex floop-interchange
13112Perform loop interchange outside of graphite. This flag can improve cache
13113performance on loop nest and allow further loop optimizations, like
13114vectorization, to take place. For example, the loop
13115@smallexample
13116for (int i = 0; i < N; i++)
13117 for (int j = 0; j < N; j++)
13118 for (int k = 0; k < N; k++)
13119 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13120@end smallexample
13121is transformed to
13122@smallexample
13123for (int i = 0; i < N; i++)
13124 for (int k = 0; k < N; k++)
13125 for (int j = 0; j < N; j++)
13126 c[i][j] = c[i][j] + a[i][k]*b[k][j];
13127@end smallexample
13128This flag is enabled by default at @option{-O3}.
13129It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13130
13131@item -floop-unroll-and-jam
13132@opindex floop-unroll-and-jam
13133Apply unroll and jam transformations on feasible loops. In a loop
13134nest this unrolls the outer loop by some factor and fuses the resulting
13135multiple inner loops. This flag is enabled by default at @option{-O3}.
13136It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13137
13138@item -ftree-loop-im
13139@opindex ftree-loop-im
13140Perform loop invariant motion on trees. This pass moves only invariants that
13141are hard to handle at RTL level (function calls, operations that expand to
13142nontrivial sequences of insns). With @option{-funswitch-loops} it also moves
13143operands of conditions that are invariant out of the loop, so that we can use
13144just trivial invariantness analysis in loop unswitching. The pass also includes
13145store motion.
13146
13147@item -ftree-loop-ivcanon
13148@opindex ftree-loop-ivcanon
13149Create a canonical counter for number of iterations in loops for which
13150determining number of iterations requires complicated analysis. Later
13151optimizations then may determine the number easily. Useful especially
13152in connection with unrolling.
13153
13154@item -ftree-scev-cprop
13155@opindex ftree-scev-cprop
13156Perform final value replacement. If a variable is modified in a loop
13157in such a way that its value when exiting the loop can be determined using
13158only its initial value and the number of loop iterations, replace uses of
13159the final value by such a computation, provided it is sufficiently cheap.
13160This reduces data dependencies and may allow further simplifications.
13161Enabled by default at @option{-O1} and higher.
13162
13163@item -fivopts
13164@opindex fivopts
13165Perform induction variable optimizations (strength reduction, induction
13166variable merging and induction variable elimination) on trees.
13167
13168@item -ftree-parallelize-loops=n
13169@opindex ftree-parallelize-loops
13170Parallelize loops, i.e., split their iteration space to run in n threads.
13171This is only possible for loops whose iterations are independent
13172and can be arbitrarily reordered. The optimization is only
13173profitable on multiprocessor machines, for loops that are CPU-intensive,
13174rather than constrained e.g.@: by memory bandwidth. This option
13175implies @option{-pthread}, and thus is only supported on targets
13176that have support for @option{-pthread}.
13177
13178@item -ftree-pta
13179@opindex ftree-pta
13180Perform function-local points-to analysis on trees. This flag is
13181enabled by default at @option{-O1} and higher, except for @option{-Og}.
13182
13183@item -ftree-sra
13184@opindex ftree-sra
13185Perform scalar replacement of aggregates. This pass replaces structure
13186references with scalars to prevent committing structures to memory too
13187early. This flag is enabled by default at @option{-O1} and higher,
13188except for @option{-Og}.
13189
13190@item -fstore-merging
13191@opindex fstore-merging
13192Perform merging of narrow stores to consecutive memory addresses. This pass
13193merges contiguous stores of immediate values narrower than a word into fewer
13194wider stores to reduce the number of instructions. This is enabled by default
13195at @option{-O2} and higher as well as @option{-Os}.
13196
13197@item -ftree-ter
13198@opindex ftree-ter
13199Perform temporary expression replacement during the SSA->normal phase. Single
13200use/single def temporaries are replaced at their use location with their
13201defining expression. This results in non-GIMPLE code, but gives the expanders
13202much more complex trees to work on resulting in better RTL generation. This is
13203enabled by default at @option{-O1} and higher.
13204
13205@item -ftree-slsr
13206@opindex ftree-slsr
13207Perform straight-line strength reduction on trees. This recognizes related
13208expressions involving multiplications and replaces them by less expensive
13209calculations when possible. This is enabled by default at @option{-O1} and
13210higher.
13211
13212@item -ftree-vectorize
13213@opindex ftree-vectorize
13214Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize}
13215and @option{-ftree-slp-vectorize} if not explicitly specified.
13216
13217@item -ftree-loop-vectorize
13218@opindex ftree-loop-vectorize
13219Perform loop vectorization on trees. This flag is enabled by default at
13220@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13221and @option{-fauto-profile}.
13222
13223@item -ftree-slp-vectorize
13224@opindex ftree-slp-vectorize
13225Perform basic block vectorization on trees. This flag is enabled by default at
13226@option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use},
13227and @option{-fauto-profile}.
13228
13229@item -ftrivial-auto-var-init=@var{choice}
13230@opindex ftrivial-auto-var-init
13231Initialize automatic variables with either a pattern or with zeroes to increase
13232the security and predictability of a program by preventing uninitialized memory
13233disclosure and use.
13234GCC still considers an automatic variable that doesn't have an explicit
13235initializer as uninitialized, @option{-Wuninitialized} and
13236@option{-Wanalyzer-use-of-uninitialized-value} will still report
8f4634fb
RB
13237warning messages on such automatic variables and the compiler will
13238perform optimization as if the variable were uninitialized.
d77de738
ML
13239With this option, GCC will also initialize any padding of automatic variables
13240that have structure or union types to zeroes.
13241However, the current implementation cannot initialize automatic variables that
13242are declared between the controlling expression and the first case of a
13243@code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all
13244such cases.
13245
13246The three values of @var{choice} are:
13247
13248@itemize @bullet
13249@item
13250@samp{uninitialized} doesn't initialize any automatic variables.
13251This is C and C++'s default.
13252
13253@item
13254@samp{pattern} Initialize automatic variables with values which will likely
13255transform logic bugs into crashes down the line, are easily recognized in a
13256crash dump and without being values that programmers can rely on for useful
13257program semantics.
13258The current value is byte-repeatable pattern with byte "0xFE".
13259The values used for pattern initialization might be changed in the future.
13260
13261@item
13262@samp{zero} Initialize automatic variables with zeroes.
13263@end itemize
13264
13265The default is @samp{uninitialized}.
13266
13267You can control this behavior for a specific variable by using the variable
13268attribute @code{uninitialized} (@pxref{Variable Attributes}).
13269
13270@item -fvect-cost-model=@var{model}
13271@opindex fvect-cost-model
13272Alter the cost model used for vectorization. The @var{model} argument
13273should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or
13274@samp{very-cheap}.
13275With the @samp{unlimited} model the vectorized code-path is assumed
13276to be profitable while with the @samp{dynamic} model a runtime check
13277guards the vectorized code-path to enable it only for iteration
13278counts that will likely execute faster than when executing the original
13279scalar loop. The @samp{cheap} model disables vectorization of
13280loops where doing so would be cost prohibitive for example due to
13281required runtime checks for data dependence or alignment but otherwise
13282is equal to the @samp{dynamic} model. The @samp{very-cheap} model only
13283allows vectorization if the vector code would entirely replace the
13284scalar code that is being vectorized. For example, if each iteration
13285of a vectorized loop would only be able to handle exactly four iterations
13286of the scalar loop, the @samp{very-cheap} model would only allow
13287vectorization if the scalar iteration count is known to be a multiple
13288of four.
13289
13290The default cost model depends on other optimization flags and is
13291either @samp{dynamic} or @samp{cheap}.
13292
13293@item -fsimd-cost-model=@var{model}
13294@opindex fsimd-cost-model
13295Alter the cost model used for vectorization of loops marked with the OpenMP
13296simd directive. The @var{model} argument should be one of
13297@samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model}
13298have the same meaning as described in @option{-fvect-cost-model} and by
13299default a cost model defined with @option{-fvect-cost-model} is used.
13300
13301@item -ftree-vrp
13302@opindex ftree-vrp
13303Perform Value Range Propagation on trees. This is similar to the
13304constant propagation pass, but instead of values, ranges of values are
13305propagated. This allows the optimizers to remove unnecessary range
13306checks like array bound checks and null pointer checks. This is
13307enabled by default at @option{-O2} and higher. Null pointer check
13308elimination is only done if @option{-fdelete-null-pointer-checks} is
13309enabled.
13310
13311@item -fsplit-paths
13312@opindex fsplit-paths
13313Split paths leading to loop backedges. This can improve dead code
13314elimination and common subexpression elimination. This is enabled by
13315default at @option{-O3} and above.
13316
13317@item -fsplit-ivs-in-unroller
13318@opindex fsplit-ivs-in-unroller
13319Enables expression of values of induction variables in later iterations
13320of the unrolled loop using the value in the first iteration. This breaks
13321long dependency chains, thus improving efficiency of the scheduling passes.
13322
13323A combination of @option{-fweb} and CSE is often sufficient to obtain the
13324same effect. However, that is not reliable in cases where the loop body
13325is more complicated than a single basic block. It also does not work at all
13326on some architectures due to restrictions in the CSE pass.
13327
13328This optimization is enabled by default.
13329
13330@item -fvariable-expansion-in-unroller
13331@opindex fvariable-expansion-in-unroller
13332With this option, the compiler creates multiple copies of some
13333local variables when unrolling a loop, which can result in superior code.
13334
13335This optimization is enabled by default for PowerPC targets, but disabled
13336by default otherwise.
13337
13338@item -fpartial-inlining
13339@opindex fpartial-inlining
13340Inline parts of functions. This option has any effect only
13341when inlining itself is turned on by the @option{-finline-functions}
13342or @option{-finline-small-functions} options.
13343
13344Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13345
13346@item -fpredictive-commoning
13347@opindex fpredictive-commoning
13348Perform predictive commoning optimization, i.e., reusing computations
13349(especially memory loads and stores) performed in previous
13350iterations of loops.
13351
13352This option is enabled at level @option{-O3}.
13353It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
13354
13355@item -fprefetch-loop-arrays
13356@opindex fprefetch-loop-arrays
13357If supported by the target machine, generate instructions to prefetch
13358memory to improve the performance of loops that access large arrays.
13359
13360This option may generate better or worse code; results are highly
13361dependent on the structure of loops within the source code.
13362
13363Disabled at level @option{-Os}.
13364
13365@item -fno-printf-return-value
13366@opindex fno-printf-return-value
13367@opindex fprintf-return-value
13368Do not substitute constants for known return value of formatted output
13369functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and
13370@code{vsnprintf} (but not @code{printf} of @code{fprintf}). This
13371transformation allows GCC to optimize or even eliminate branches based
13372on the known return value of these functions called with arguments that
13373are either constant, or whose values are known to be in a range that
13374makes determining the exact return value possible. For example, when
13375@option{-fprintf-return-value} is in effect, both the branch and the
13376body of the @code{if} statement (but not the call to @code{snprint})
13377can be optimized away when @code{i} is a 32-bit or smaller integer
13378because the return value is guaranteed to be at most 8.
13379
13380@smallexample
13381char buf[9];
13382if (snprintf (buf, "%08x", i) >= sizeof buf)
13383 @dots{}
13384@end smallexample
13385
13386The @option{-fprintf-return-value} option relies on other optimizations
13387and yields best results with @option{-O2} and above. It works in tandem
13388with the @option{-Wformat-overflow} and @option{-Wformat-truncation}
13389options. The @option{-fprintf-return-value} option is enabled by default.
13390
13391@item -fno-peephole
13392@itemx -fno-peephole2
13393@opindex fno-peephole
13394@opindex fpeephole
13395@opindex fno-peephole2
13396@opindex fpeephole2
13397Disable any machine-specific peephole optimizations. The difference
13398between @option{-fno-peephole} and @option{-fno-peephole2} is in how they
13399are implemented in the compiler; some targets use one, some use the
13400other, a few use both.
13401
13402@option{-fpeephole} is enabled by default.
13403@option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13404
13405@item -fno-guess-branch-probability
13406@opindex fno-guess-branch-probability
13407@opindex fguess-branch-probability
13408Do not guess branch probabilities using heuristics.
13409
13410GCC uses heuristics to guess branch probabilities if they are
13411not provided by profiling feedback (@option{-fprofile-arcs}). These
13412heuristics are based on the control flow graph. If some branch probabilities
13413are specified by @code{__builtin_expect}, then the heuristics are
13414used to guess branch probabilities for the rest of the control flow graph,
13415taking the @code{__builtin_expect} info into account. The interactions
13416between the heuristics and @code{__builtin_expect} can be complex, and in
13417some cases, it may be useful to disable the heuristics so that the effects
13418of @code{__builtin_expect} are easier to understand.
13419
13420It is also possible to specify expected probability of the expression
13421with @code{__builtin_expect_with_probability} built-in function.
13422
13423The default is @option{-fguess-branch-probability} at levels
13424@option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
13425
13426@item -freorder-blocks
13427@opindex freorder-blocks
13428Reorder basic blocks in the compiled function in order to reduce number of
13429taken branches and improve code locality.
13430
13431Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
13432
13433@item -freorder-blocks-algorithm=@var{algorithm}
13434@opindex freorder-blocks-algorithm
13435Use the specified algorithm for basic block reordering. The
13436@var{algorithm} argument can be @samp{simple}, which does not increase
13437code size (except sometimes due to secondary effects like alignment),
13438or @samp{stc}, the ``software trace cache'' algorithm, which tries to
13439put all often executed code together, minimizing the number of branches
13440executed by making extra copies of code.
13441
13442The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and
13443@samp{stc} at levels @option{-O2}, @option{-O3}.
13444
13445@item -freorder-blocks-and-partition
13446@opindex freorder-blocks-and-partition
13447In addition to reordering basic blocks in the compiled function, in order
13448to reduce number of taken branches, partitions hot and cold basic blocks
13449into separate sections of the assembly and @file{.o} files, to improve
13450paging and cache locality performance.
13451
13452This optimization is automatically turned off in the presence of
13453exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined
13454section attribute and on any architecture that does not support named
13455sections. When @option{-fsplit-stack} is used this option is not
13456enabled by default (to avoid linker errors), but may be enabled
13457explicitly (if using a working linker).
13458
13459Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}.
13460
13461@item -freorder-functions
13462@opindex freorder-functions
13463Reorder functions in the object file in order to
13464improve code locality. This is implemented by using special
13465subsections @code{.text.hot} for most frequently executed functions and
13466@code{.text.unlikely} for unlikely executed functions. Reordering is done by
13467the linker so object file format must support named sections and linker must
13468place them in a reasonable way.
13469
13470This option isn't effective unless you either provide profile feedback
13471(see @option{-fprofile-arcs} for details) or manually annotate functions with
13472@code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}).
13473
13474Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
13475
13476@item -fstrict-aliasing
13477@opindex fstrict-aliasing
13478Allow the compiler to assume the strictest aliasing rules applicable to
13479the language being compiled. For C (and C++), this activates
13480optimizations based on the type of expressions. In particular, an
13481object of one type is assumed never to reside at the same address as an
13482object of a different type, unless the types are almost the same. For
13483example, an @code{unsigned int} can alias an @code{int}, but not a
13484@code{void*} or a @code{double}. A character type may alias any other
13485type.
13486
13487@anchor{Type-punning}Pay special attention to code like this:
13488@smallexample
13489union a_union @{
13490 int i;
13491 double d;
13492@};
13493
13494int f() @{
13495 union a_union t;
13496 t.d = 3.0;
13497 return t.i;
13498@}
13499@end smallexample
13500The practice of reading from a different union member than the one most
13501recently written to (called ``type-punning'') is common. Even with
13502@option{-fstrict-aliasing}, type-punning is allowed, provided the memory
13503is accessed through the union type. So, the code above works as
13504expected. @xref{Structures unions enumerations and bit-fields
13505implementation}. However, this code might not:
13506@smallexample
13507int f() @{
13508 union a_union t;
13509 int* ip;
13510 t.d = 3.0;
13511 ip = &t.i;
13512 return *ip;
13513@}
13514@end smallexample
13515
13516Similarly, access by taking the address, casting the resulting pointer
13517and dereferencing the result has undefined behavior, even if the cast
13518uses a union type, e.g.:
13519@smallexample
13520int f() @{
13521 double d = 3.0;
13522 return ((union a_union *) &d)->i;
13523@}
13524@end smallexample
13525
13526The @option{-fstrict-aliasing} option is enabled at levels
13527@option{-O2}, @option{-O3}, @option{-Os}.
13528
13529@item -fipa-strict-aliasing
13530@opindex fipa-strict-aliasing
13531Controls whether rules of @option{-fstrict-aliasing} are applied across
13532function boundaries. Note that if multiple functions gets inlined into a
13533single function the memory accesses are no longer considered to be crossing a
13534function boundary.
13535
13536The @option{-fipa-strict-aliasing} option is enabled by default and is
13537effective only in combination with @option{-fstrict-aliasing}.
13538
13539@item -falign-functions
13540@itemx -falign-functions=@var{n}
13541@itemx -falign-functions=@var{n}:@var{m}
13542@itemx -falign-functions=@var{n}:@var{m}:@var{n2}
13543@itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2}
13544@opindex falign-functions
13545Align the start of functions to the next power-of-two greater than or
13546equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at
13547least the first @var{m} bytes of the function can be fetched by the CPU
13548without crossing an @var{n}-byte alignment boundary.
13549
13550If @var{m} is not specified, it defaults to @var{n}.
13551
13552Examples: @option{-falign-functions=32} aligns functions to the next
1355332-byte boundary, @option{-falign-functions=24} aligns to the next
1355432-byte boundary only if this can be done by skipping 23 bytes or less,
13555@option{-falign-functions=32:7} aligns to the next
1355632-byte boundary only if this can be done by skipping 6 bytes or less.
13557
13558The second pair of @var{n2}:@var{m2} values allows you to specify
13559a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to
13560the next 64-byte boundary if this can be done by skipping 6 bytes or less,
13561otherwise aligns to the next 32-byte boundary if this can be done
13562by skipping 2 bytes or less.
13563If @var{m2} is not specified, it defaults to @var{n2}.
13564
13565Some assemblers only support this flag when @var{n} is a power of two;
13566in that case, it is rounded up.
13567
13568@option{-fno-align-functions} and @option{-falign-functions=1} are
13569equivalent and mean that functions are not aligned.
13570
13571If @var{n} is not specified or is zero, use a machine-dependent default.
13572The maximum allowed @var{n} option value is 65536.
13573
13574Enabled at levels @option{-O2}, @option{-O3}.
13575
13576@item -flimit-function-alignment
13577If this option is enabled, the compiler tries to avoid unnecessarily
13578overaligning functions. It attempts to instruct the assembler to align
13579by the amount specified by @option{-falign-functions}, but not to
13580skip more bytes than the size of the function.
13581
13582@item -falign-labels
13583@itemx -falign-labels=@var{n}
13584@itemx -falign-labels=@var{n}:@var{m}
13585@itemx -falign-labels=@var{n}:@var{m}:@var{n2}
13586@itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2}
13587@opindex falign-labels
13588Align all branch targets to a power-of-two boundary.
13589
13590Parameters of this option are analogous to the @option{-falign-functions} option.
13591@option{-fno-align-labels} and @option{-falign-labels=1} are
13592equivalent and mean that labels are not aligned.
13593
13594If @option{-falign-loops} or @option{-falign-jumps} are applicable and
13595are greater than this value, then their values are used instead.
13596
13597If @var{n} is not specified or is zero, use a machine-dependent default
13598which is very likely to be @samp{1}, meaning no alignment.
13599The maximum allowed @var{n} option value is 65536.
13600
13601Enabled at levels @option{-O2}, @option{-O3}.
13602
13603@item -falign-loops
13604@itemx -falign-loops=@var{n}
13605@itemx -falign-loops=@var{n}:@var{m}
13606@itemx -falign-loops=@var{n}:@var{m}:@var{n2}
13607@itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2}
13608@opindex falign-loops
13609Align loops to a power-of-two boundary. If the loops are executed
13610many times, this makes up for any execution of the dummy padding
13611instructions.
13612
13613If @option{-falign-labels} is greater than this value, then its value
13614is used instead.
13615
13616Parameters of this option are analogous to the @option{-falign-functions} option.
13617@option{-fno-align-loops} and @option{-falign-loops=1} are
13618equivalent and mean that loops are not aligned.
13619The maximum allowed @var{n} option value is 65536.
13620
13621If @var{n} is not specified or is zero, use a machine-dependent default.
13622
13623Enabled at levels @option{-O2}, @option{-O3}.
13624
13625@item -falign-jumps
13626@itemx -falign-jumps=@var{n}
13627@itemx -falign-jumps=@var{n}:@var{m}
13628@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}
13629@itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2}
13630@opindex falign-jumps
13631Align branch targets to a power-of-two boundary, for branch targets
13632where the targets can only be reached by jumping. In this case,
13633no dummy operations need be executed.
13634
13635If @option{-falign-labels} is greater than this value, then its value
13636is used instead.
13637
13638Parameters of this option are analogous to the @option{-falign-functions} option.
13639@option{-fno-align-jumps} and @option{-falign-jumps=1} are
13640equivalent and mean that loops are not aligned.
13641
13642If @var{n} is not specified or is zero, use a machine-dependent default.
13643The maximum allowed @var{n} option value is 65536.
13644
13645Enabled at levels @option{-O2}, @option{-O3}.
13646
13647@item -fno-allocation-dce
13648@opindex fno-allocation-dce
13649Do not remove unused C++ allocations in dead code elimination.
13650
13651@item -fallow-store-data-races
13652@opindex fallow-store-data-races
13653Allow the compiler to perform optimizations that may introduce new data races
13654on stores, without proving that the variable cannot be concurrently accessed
13655by other threads. Does not affect optimization of local data. It is safe to
13656use this option if it is known that global data will not be accessed by
13657multiple threads.
13658
13659Examples of optimizations enabled by @option{-fallow-store-data-races} include
13660hoisting or if-conversions that may cause a value that was already in memory
13661to be re-written with that same value. Such re-writing is safe in a single
13662threaded context but may be unsafe in a multi-threaded context. Note that on
13663some processors, if-conversions may be required in order to enable
13664vectorization.
13665
13666Enabled at level @option{-Ofast}.
13667
13668@item -funit-at-a-time
13669@opindex funit-at-a-time
13670This option is left for compatibility reasons. @option{-funit-at-a-time}
13671has no effect, while @option{-fno-unit-at-a-time} implies
13672@option{-fno-toplevel-reorder} and @option{-fno-section-anchors}.
13673
13674Enabled by default.
13675
13676@item -fno-toplevel-reorder
13677@opindex fno-toplevel-reorder
13678@opindex ftoplevel-reorder
13679Do not reorder top-level functions, variables, and @code{asm}
13680statements. Output them in the same order that they appear in the
13681input file. When this option is used, unreferenced static variables
13682are not removed. This option is intended to support existing code
13683that relies on a particular ordering. For new code, it is better to
13684use attributes when possible.
13685
13686@option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and
13687also at @option{-O0} if @option{-fsection-anchors} is explicitly requested.
13688Additionally @option{-fno-toplevel-reorder} implies
13689@option{-fno-section-anchors}.
13690
13691@item -funreachable-traps
13692@opindex funreachable-traps
13693With this option, the compiler turns calls to
13694@code{__builtin_unreachable} into traps, instead of using them for
13695optimization. This also affects any such calls implicitly generated
13696by the compiler.
13697
13698This option has the same effect as @option{-fsanitize=unreachable
13699-fsanitize-trap=unreachable}, but does not affect the values of those
13700options. If @option{-fsanitize=unreachable} is enabled, that option
13701takes priority over this one.
13702
13703This option is enabled by default at @option{-O0} and @option{-Og}.
13704
13705@item -fweb
13706@opindex fweb
13707Constructs webs as commonly used for register allocation purposes and assign
13708each web individual pseudo register. This allows the register allocation pass
13709to operate on pseudos directly, but also strengthens several other optimization
13710passes, such as CSE, loop optimizer and trivial dead code remover. It can,
13711however, make debugging impossible, since variables no longer stay in a
13712``home register''.
13713
13714Enabled by default with @option{-funroll-loops}.
13715
13716@item -fwhole-program
13717@opindex fwhole-program
13718Assume that the current compilation unit represents the whole program being
13719compiled. All public functions and variables with the exception of @code{main}
13720and those merged by attribute @code{externally_visible} become static functions
13721and in effect are optimized more aggressively by interprocedural optimizers.
13722
39ebd3a9
JH
13723With @option{-flto} this option has a limited use. In most cases the
13724precise list of symbols used or exported from the binary is known the
13725resolution info passed to the link-time optimizer by the linker plugin. It is
13726still useful if no linker plugin is used or during incremental link step when
13727final code is produced (with @option{-flto}
13728@option{-flinker-output=nolto-rel}).
d77de738
ML
13729
13730@item -flto[=@var{n}]
13731@opindex flto
13732This option runs the standard link-time optimizer. When invoked
13733with source code, it generates GIMPLE (one of GCC's internal
13734representations) and writes it to special ELF sections in the object
13735file. When the object files are linked together, all the function
13736bodies are read from these ELF sections and instantiated as if they
13737had been part of the same translation unit.
13738
13739To use the link-time optimizer, @option{-flto} and optimization
13740options should be specified at compile time and during the final link.
13741It is recommended that you compile all the files participating in the
13742same link with the same options and also specify those options at
13743link time.
13744For example:
13745
13746@smallexample
13747gcc -c -O2 -flto foo.c
13748gcc -c -O2 -flto bar.c
13749gcc -o myprog -flto -O2 foo.o bar.o
13750@end smallexample
13751
13752The first two invocations to GCC save a bytecode representation
13753of GIMPLE into special ELF sections inside @file{foo.o} and
13754@file{bar.o}. The final invocation reads the GIMPLE bytecode from
13755@file{foo.o} and @file{bar.o}, merges the two files into a single
13756internal image, and compiles the result as usual. Since both
13757@file{foo.o} and @file{bar.o} are merged into a single image, this
13758causes all the interprocedural analyses and optimizations in GCC to
13759work across the two files as if they were a single one. This means,
13760for example, that the inliner is able to inline functions in
13761@file{bar.o} into functions in @file{foo.o} and vice-versa.
13762
13763Another (simpler) way to enable link-time optimization is:
13764
13765@smallexample
13766gcc -o myprog -flto -O2 foo.c bar.c
13767@end smallexample
13768
13769The above generates bytecode for @file{foo.c} and @file{bar.c},
13770merges them together into a single GIMPLE representation and optimizes
13771them as usual to produce @file{myprog}.
13772
13773The important thing to keep in mind is that to enable link-time
13774optimizations you need to use the GCC driver to perform the link step.
13775GCC automatically performs link-time optimization if any of the
13776objects involved were compiled with the @option{-flto} command-line option.
13777You can always override
13778the automatic decision to do link-time optimization
13779by passing @option{-fno-lto} to the link command.
13780
13781To make whole program optimization effective, it is necessary to make
13782certain whole program assumptions. The compiler needs to know
13783what functions and variables can be accessed by libraries and runtime
13784outside of the link-time optimized unit. When supported by the linker,
13785the linker plugin (see @option{-fuse-linker-plugin}) passes information
13786to the compiler about used and externally visible symbols. When
13787the linker plugin is not available, @option{-fwhole-program} should be
13788used to allow the compiler to make these assumptions, which leads
13789to more aggressive optimization decisions.
13790
13791When a file is compiled with @option{-flto} without
13792@option{-fuse-linker-plugin}, the generated object file is larger than
13793a regular object file because it contains GIMPLE bytecodes and the usual
13794final code (see @option{-ffat-lto-objects}). This means that
13795object files with LTO information can be linked as normal object
13796files; if @option{-fno-lto} is passed to the linker, no
13797interprocedural optimizations are applied. Note that when
13798@option{-fno-fat-lto-objects} is enabled the compile stage is faster
13799but you cannot perform a regular, non-LTO link on them.
13800
13801When producing the final binary, GCC only
13802applies link-time optimizations to those files that contain bytecode.
13803Therefore, you can mix and match object files and libraries with
13804GIMPLE bytecodes and final object code. GCC automatically selects
13805which files to optimize in LTO mode and which files to link without
13806further processing.
13807
13808Generally, options specified at link time override those
13809specified at compile time, although in some cases GCC attempts to infer
13810link-time options from the settings used to compile the input files.
13811
13812If you do not specify an optimization level option @option{-O} at
13813link time, then GCC uses the highest optimization level
13814used when compiling the object files. Note that it is generally
13815ineffective to specify an optimization level option only at link time and
13816not at compile time, for two reasons. First, compiling without
13817optimization suppresses compiler passes that gather information
13818needed for effective optimization at link time. Second, some early
13819optimization passes can be performed only at compile time and
13820not at link time.
13821
13822There are some code generation flags preserved by GCC when
13823generating bytecodes, as they need to be used during the final link.
13824Currently, the following options and their settings are taken from
13825the first object file that explicitly specifies them:
13826@option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions},
13827@option{-fgnu-tm} and all the @option{-m} target flags.
13828
13829The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and
13830@option{-fPIE} are combined based on the following scheme:
13831
13832@smallexample
13833@option{-fPIC} + @option{-fpic} = @option{-fpic}
13834@option{-fPIC} + @option{-fno-pic} = @option{-fno-pic}
13835@option{-fpic/-fPIC} + (no option) = (no option)
13836@option{-fPIC} + @option{-fPIE} = @option{-fPIE}
13837@option{-fpic} + @option{-fPIE} = @option{-fpie}
13838@option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie}
13839@end smallexample
13840
13841Certain ABI-changing flags are required to match in all compilation units,
13842and trying to override this at link time with a conflicting value
13843is ignored. This includes options such as @option{-freg-struct-return}
13844and @option{-fpcc-struct-return}.
13845
13846Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow},
13847@option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing}
13848are passed through to the link stage and merged conservatively for
13849conflicting translation units. Specifically
13850@option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take
13851precedence; and for example @option{-ffp-contract=off} takes precedence
13852over @option{-ffp-contract=fast}. You can override them at link time.
13853
13854Diagnostic options such as @option{-Wstringop-overflow} are passed
13855through to the link stage and their setting matches that of the
13856compile-step at function granularity. Note that this matters only
13857for diagnostics emitted during optimization. Note that code
13858transforms such as inlining can lead to warnings being enabled
13859or disabled for regions if code not consistent with the setting
13860at compile time.
13861
13862When you need to pass options to the assembler via @option{-Wa} or
13863@option{-Xassembler} make sure to either compile such translation
13864units with @option{-fno-lto} or consistently use the same assembler
13865options on all translation units. You can alternatively also
13866specify assembler options at LTO link time.
13867
13868To enable debug info generation you need to supply @option{-g} at
13869compile time. If any of the input files at link time were built
13870with debug info generation enabled the link will enable debug info
13871generation as well. Any elaborate debug info settings
13872like the dwarf level @option{-gdwarf-5} need to be explicitly repeated
13873at the linker command line and mixing different settings in different
13874translation units is discouraged.
13875
13876If LTO encounters objects with C linkage declared with incompatible
13877types in separate translation units to be linked together (undefined
13878behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be
13879issued. The behavior is still undefined at run time. Similar
13880diagnostics may be raised for other languages.
13881
13882Another feature of LTO is that it is possible to apply interprocedural
13883optimizations on files written in different languages:
13884
13885@smallexample
13886gcc -c -flto foo.c
13887g++ -c -flto bar.cc
13888gfortran -c -flto baz.f90
13889g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran
13890@end smallexample
13891
13892Notice that the final link is done with @command{g++} to get the C++
13893runtime libraries and @option{-lgfortran} is added to get the Fortran
13894runtime libraries. In general, when mixing languages in LTO mode, you
13895should use the same link command options as when mixing languages in a
13896regular (non-LTO) compilation.
13897
13898If object files containing GIMPLE bytecode are stored in a library archive, say
13899@file{libfoo.a}, it is possible to extract and use them in an LTO link if you
13900are using a linker with plugin support. To create static libraries suitable
13901for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar}
13902and @command{ranlib};
13903to show the symbols of object files with GIMPLE bytecode, use
13904@command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib}
13905and @command{nm} have been compiled with plugin support. At link time, use the
13906flag @option{-fuse-linker-plugin} to ensure that the library participates in
13907the LTO optimization process:
13908
13909@smallexample
13910gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo
13911@end smallexample
13912
13913With the linker plugin enabled, the linker extracts the needed
13914GIMPLE files from @file{libfoo.a} and passes them on to the running GCC
13915to make them part of the aggregated GIMPLE image to be optimized.
13916
13917If you are not using a linker with plugin support and/or do not
13918enable the linker plugin, then the objects inside @file{libfoo.a}
13919are extracted and linked as usual, but they do not participate
13920in the LTO optimization process. In order to make a static library suitable
13921for both LTO optimization and usual linkage, compile its object files with
13922@option{-flto} @option{-ffat-lto-objects}.
13923
13924Link-time optimizations do not require the presence of the whole program to
13925operate. If the program does not require any symbols to be exported, it is
13926possible to combine @option{-flto} and @option{-fwhole-program} to allow
13927the interprocedural optimizers to use more aggressive assumptions which may
13928lead to improved optimization opportunities.
13929Use of @option{-fwhole-program} is not needed when linker plugin is
13930active (see @option{-fuse-linker-plugin}).
13931
13932The current implementation of LTO makes no
13933attempt to generate bytecode that is portable between different
13934types of hosts. The bytecode files are versioned and there is a
13935strict version check, so bytecode files generated in one version of
13936GCC do not work with an older or newer version of GCC.
13937
13938Link-time optimization does not work well with generation of debugging
13939information on systems other than those using a combination of ELF and
13940DWARF.
13941
13942If you specify the optional @var{n}, the optimization and code
13943generation done at link time is executed in parallel using @var{n}
13944parallel jobs by utilizing an installed @command{make} program. The
13945environment variable @env{MAKE} may be used to override the program
13946used.
13947
13948You can also specify @option{-flto=jobserver} to use GNU make's
13949job server mode to determine the number of parallel jobs. This
13950is useful when the Makefile calling GCC is already executing in parallel.
13951You must prepend a @samp{+} to the command recipe in the parent Makefile
13952for this to work. This option likely only works if @env{MAKE} is
13953GNU make. Even without the option value, GCC tries to automatically
13954detect a running GNU make's job server.
13955
13956Use @option{-flto=auto} to use GNU make's job server, if available,
13957or otherwise fall back to autodetection of the number of CPU threads
13958present in your system.
13959
13960@item -flto-partition=@var{alg}
13961@opindex flto-partition
13962Specify the partitioning algorithm used by the link-time optimizer.
13963The value is either @samp{1to1} to specify a partitioning mirroring
13964the original source files or @samp{balanced} to specify partitioning
13965into equally sized chunks (whenever possible) or @samp{max} to create
13966new partition for every symbol where possible. Specifying @samp{none}
13967as an algorithm disables partitioning and streaming completely.
13968The default value is @samp{balanced}. While @samp{1to1} can be used
13969as an workaround for various code ordering issues, the @samp{max}
13970partitioning is intended for internal testing only.
13971The value @samp{one} specifies that exactly one partition should be
13972used while the value @samp{none} bypasses partitioning and executes
13973the link-time optimization step directly from the WPA phase.
13974
13975@item -flto-compression-level=@var{n}
13976@opindex flto-compression-level
13977This option specifies the level of compression used for intermediate
13978language written to LTO object files, and is only meaningful in
13979conjunction with LTO mode (@option{-flto}). GCC currently supports two
13980LTO compression algorithms. For zstd, valid values are 0 (no compression)
13981to 19 (maximum compression), while zlib supports values from 0 to 9.
13982Values outside this range are clamped to either minimum or maximum
13983of the supported values. If the option is not given,
13984a default balanced compression setting is used.
13985
13986@item -fuse-linker-plugin
13987@opindex fuse-linker-plugin
13988Enables the use of a linker plugin during link-time optimization. This
13989option relies on plugin support in the linker, which is available in gold
13990or in GNU ld 2.21 or newer.
13991
13992This option enables the extraction of object files with GIMPLE bytecode out
13993of library archives. This improves the quality of optimization by exposing
13994more code to the link-time optimizer. This information specifies what
13995symbols can be accessed externally (by non-LTO object or during dynamic
13996linking). Resulting code quality improvements on binaries (and shared
13997libraries that use hidden visibility) are similar to @option{-fwhole-program}.
13998See @option{-flto} for a description of the effect of this flag and how to
13999use it.
14000
14001This option is enabled by default when LTO support in GCC is enabled
14002and GCC was configured for use with
14003a linker supporting plugins (GNU ld 2.21 or newer or gold).
14004
14005@item -ffat-lto-objects
14006@opindex ffat-lto-objects
14007Fat LTO objects are object files that contain both the intermediate language
14008and the object code. This makes them usable for both LTO linking and normal
14009linking. This option is effective only when compiling with @option{-flto}
14010and is ignored at link time.
14011
14012@option{-fno-fat-lto-objects} improves compilation time over plain LTO, but
14013requires the complete toolchain to be aware of LTO. It requires a linker with
14014linker plugin support for basic functionality. Additionally,
14015@command{nm}, @command{ar} and @command{ranlib}
14016need to support linker plugins to allow a full-featured build environment
14017(capable of building static libraries etc). GCC provides the @command{gcc-ar},
14018@command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options
14019to these tools. With non fat LTO makefiles need to be modified to use them.
14020
14021Note that modern binutils provide plugin auto-load mechanism.
14022Installing the linker plugin into @file{$libdir/bfd-plugins} has the same
14023effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and
14024@command{gcc-ranlib}).
14025
14026The default is @option{-fno-fat-lto-objects} on targets with linker plugin
14027support.
14028
14029@item -fcompare-elim
14030@opindex fcompare-elim
14031After register allocation and post-register allocation instruction splitting,
14032identify arithmetic instructions that compute processor flags similar to a
14033comparison operation based on that arithmetic. If possible, eliminate the
14034explicit comparison operation.
14035
14036This pass only applies to certain targets that cannot explicitly represent
14037the comparison operation before register allocation is complete.
14038
14039Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14040
14041@item -fcprop-registers
14042@opindex fcprop-registers
14043After register allocation and post-register allocation instruction splitting,
14044perform a copy-propagation pass to try to reduce scheduling dependencies
14045and occasionally eliminate the copy.
14046
14047Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}.
14048
14049@item -fprofile-correction
14050@opindex fprofile-correction
14051Profiles collected using an instrumented binary for multi-threaded programs may
14052be inconsistent due to missed counter updates. When this option is specified,
14053GCC uses heuristics to correct or smooth out such inconsistencies. By
14054default, GCC emits an error message when an inconsistent profile is detected.
14055
14056This option is enabled by @option{-fauto-profile}.
14057
14058@item -fprofile-partial-training
14059@opindex fprofile-partial-training
14060With @code{-fprofile-use} all portions of programs not executed during train
14061run are optimized agressively for size rather than speed. In some cases it is
14062not practical to train all possible hot paths in the program. (For
14063example, program may contain functions specific for a given hardware and
14064trianing may not cover all hardware configurations program is run on.) With
14065@code{-fprofile-partial-training} profile feedback will be ignored for all
14066functions not executed during the train run leading them to be optimized as if
14067they were compiled without profile feedback. This leads to better performance
14068when train run is not representative but also leads to significantly bigger
14069code.
14070
14071@item -fprofile-use
14072@itemx -fprofile-use=@var{path}
14073@opindex fprofile-use
14074Enable profile feedback-directed optimizations,
14075and the following optimizations, many of which
14076are generally profitable only with profile feedback available:
14077
14078@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14079-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14080-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14081-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14082-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14083-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14084-fprofile-reorder-functions}
14085
14086Before you can use this option, you must first generate profiling information.
14087@xref{Instrumentation Options}, for information about the
14088@option{-fprofile-generate} option.
14089
14090By default, GCC emits an error message if the feedback profiles do not
14091match the source code. This error can be turned into a warning by using
14092@option{-Wno-error=coverage-mismatch}. Note this may result in poorly
14093optimized code. Additionally, by default, GCC also emits a warning message if
14094the feedback profiles do not exist (see @option{-Wmissing-profile}).
14095
14096If @var{path} is specified, GCC looks at the @var{path} to find
14097the profile feedback data files. See @option{-fprofile-dir}.
14098
14099@item -fauto-profile
14100@itemx -fauto-profile=@var{path}
14101@opindex fauto-profile
14102Enable sampling-based feedback-directed optimizations,
14103and the following optimizations,
14104many of which are generally profitable only with profile feedback available:
14105
14106@gccoptlist{-fbranch-probabilities -fprofile-values @gol
14107-funroll-loops -fpeel-loops -ftracer -fvpt @gol
14108-finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp @gol
14109-fpredictive-commoning -fsplit-loops -funswitch-loops @gol
14110-fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize @gol
14111-fvect-cost-model=dynamic -ftree-loop-distribute-patterns @gol
14112-fprofile-correction}
14113
14114@var{path} is the name of a file containing AutoFDO profile information.
14115If omitted, it defaults to @file{fbdata.afdo} in the current directory.
14116
14117Producing an AutoFDO profile data file requires running your program
14118with the @command{perf} utility on a supported GNU/Linux target system.
14119For more information, see @uref{https://perf.wiki.kernel.org/}.
14120
14121E.g.
14122@smallexample
14123perf record -e br_inst_retired:near_taken -b -o perf.data \
14124 -- your_program
14125@end smallexample
14126
14127Then use the @command{create_gcov} tool to convert the raw profile data
14128to a format that can be used by GCC.@ You must also supply the
14129unstripped binary for your program to this tool.
14130See @uref{https://github.com/google/autofdo}.
14131
14132E.g.
14133@smallexample
14134create_gcov --binary=your_program.unstripped --profile=perf.data \
14135 --gcov=profile.afdo
14136@end smallexample
14137@end table
14138
14139The following options control compiler behavior regarding floating-point
14140arithmetic. These options trade off between speed and
14141correctness. All must be specifically enabled.
14142
14143@table @gcctabopt
14144@item -ffloat-store
14145@opindex ffloat-store
14146Do not store floating-point variables in registers, and inhibit other
14147options that might change whether a floating-point value is taken from a
14148register or memory.
14149
14150@cindex floating-point precision
14151This option prevents undesirable excess precision on machines such as
14152the 68000 where the floating registers (of the 68881) keep more
14153precision than a @code{double} is supposed to have. Similarly for the
14154x86 architecture. For most programs, the excess precision does only
14155good, but a few programs rely on the precise definition of IEEE floating
14156point. Use @option{-ffloat-store} for such programs, after modifying
14157them to store all pertinent intermediate computations into variables.
14158
14159@item -fexcess-precision=@var{style}
14160@opindex fexcess-precision
14161This option allows further control over excess precision on machines
14162where floating-point operations occur in a format with more precision or
14163range than the IEEE standard and interchange floating-point types. By
14164default, @option{-fexcess-precision=fast} is in effect; this means that
14165operations may be carried out in a wider precision than the types specified
14166in the source if that would result in faster code, and it is unpredictable
14167when rounding to the types specified in the source code takes place.
14168When compiling C or C++, if @option{-fexcess-precision=standard} is specified
14169then excess precision follows the rules specified in ISO C99 or C++; in particular,
14170both casts and assignments cause values to be rounded to their
14171semantic types (whereas @option{-ffloat-store} only affects
14172assignments). This option is enabled by default for C or C++ if a strict
14173conformance option such as @option{-std=c99} or @option{-std=c++17} is used.
14174@option{-ffast-math} enables @option{-fexcess-precision=fast} by default
14175regardless of whether a strict conformance option is used.
14176
14177@opindex mfpmath
14178@option{-fexcess-precision=standard} is not implemented for languages
14179other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse}
14180or @option{-mfpmath=sse+387} is specified; in the former case, IEEE
14181semantics apply without excess precision, and in the latter, rounding
14182is unpredictable.
14183
14184@item -ffast-math
14185@opindex ffast-math
14186Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations},
14187@option{-ffinite-math-only}, @option{-fno-rounding-math},
14188@option{-fno-signaling-nans}, @option{-fcx-limited-range} and
14189@option{-fexcess-precision=fast}.
14190
14191This option causes the preprocessor macro @code{__FAST_MATH__} to be defined.
14192
14193This option is not turned on by any @option{-O} option besides
14194@option{-Ofast} since it can result in incorrect output for programs
14195that depend on an exact implementation of IEEE or ISO rules/specifications
14196for math functions. It may, however, yield faster code for programs
14197that do not require the guarantees of these specifications.
14198
14199@item -fno-math-errno
14200@opindex fno-math-errno
14201@opindex fmath-errno
14202Do not set @code{errno} after calling math functions that are executed
14203with a single instruction, e.g., @code{sqrt}. A program that relies on
14204IEEE exceptions for math error handling may want to use this flag
14205for speed while maintaining IEEE arithmetic compatibility.
14206
14207This option is not turned on by any @option{-O} option since
14208it can result in incorrect output for programs that depend on
14209an exact implementation of IEEE or ISO rules/specifications for
14210math functions. It may, however, yield faster code for programs
14211that do not require the guarantees of these specifications.
14212
14213The default is @option{-fmath-errno}.
14214
14215On Darwin systems, the math library never sets @code{errno}. There is
14216therefore no reason for the compiler to consider the possibility that
14217it might, and @option{-fno-math-errno} is the default.
14218
14219@item -funsafe-math-optimizations
14220@opindex funsafe-math-optimizations
14221
14222Allow optimizations for floating-point arithmetic that (a) assume
14223that arguments and results are valid and (b) may violate IEEE or
14224ANSI standards. When used at link time, it may include libraries
14225or startup files that change the default FPU control word or other
14226similar optimizations.
14227
14228This option is not turned on by any @option{-O} option since
14229it can result in incorrect output for programs that depend on
14230an exact implementation of IEEE or ISO rules/specifications for
14231math functions. It may, however, yield faster code for programs
14232that do not require the guarantees of these specifications.
14233Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math},
14234@option{-fassociative-math} and @option{-freciprocal-math}.
14235
14236The default is @option{-fno-unsafe-math-optimizations}.
14237
14238@item -fassociative-math
14239@opindex fassociative-math
14240
14241Allow re-association of operands in series of floating-point operations.
14242This violates the ISO C and C++ language standard by possibly changing
14243computation result. NOTE: re-ordering may change the sign of zero as
14244well as ignore NaNs and inhibit or create underflow or overflow (and
14245thus cannot be used on code that relies on rounding behavior like
14246@code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons
14247and thus may not be used when ordered comparisons are required.
14248This option requires that both @option{-fno-signed-zeros} and
14249@option{-fno-trapping-math} be in effect. Moreover, it doesn't make
14250much sense with @option{-frounding-math}. For Fortran the option
14251is automatically enabled when both @option{-fno-signed-zeros} and
14252@option{-fno-trapping-math} are in effect.
14253
14254The default is @option{-fno-associative-math}.
14255
14256@item -freciprocal-math
14257@opindex freciprocal-math
14258
14259Allow the reciprocal of a value to be used instead of dividing by
14260the value if this enables optimizations. For example @code{x / y}
14261can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)}
14262is subject to common subexpression elimination. Note that this loses
14263precision and increases the number of flops operating on the value.
14264
14265The default is @option{-fno-reciprocal-math}.
14266
14267@item -ffinite-math-only
14268@opindex ffinite-math-only
14269Allow optimizations for floating-point arithmetic that assume
14270that arguments and results are not NaNs or +-Infs.
14271
14272This option is not turned on by any @option{-O} option since
14273it can result in incorrect output for programs that depend on
14274an exact implementation of IEEE or ISO rules/specifications for
14275math functions. It may, however, yield faster code for programs
14276that do not require the guarantees of these specifications.
14277
14278The default is @option{-fno-finite-math-only}.
14279
14280@item -fno-signed-zeros
14281@opindex fno-signed-zeros
14282@opindex fsigned-zeros
14283Allow optimizations for floating-point arithmetic that ignore the
14284signedness of zero. IEEE arithmetic specifies the behavior of
14285distinct +0.0 and @minus{}0.0 values, which then prohibits simplification
14286of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}).
14287This option implies that the sign of a zero result isn't significant.
14288
14289The default is @option{-fsigned-zeros}.
14290
14291@item -fno-trapping-math
14292@opindex fno-trapping-math
14293@opindex ftrapping-math
14294Compile code assuming that floating-point operations cannot generate
14295user-visible traps. These traps include division by zero, overflow,
14296underflow, inexact result and invalid operation. This option requires
14297that @option{-fno-signaling-nans} be in effect. Setting this option may
14298allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example.
14299
14300This option should never be turned on by any @option{-O} option since
14301it can result in incorrect output for programs that depend on
14302an exact implementation of IEEE or ISO rules/specifications for
14303math functions.
14304
14305The default is @option{-ftrapping-math}.
14306
14307Future versions of GCC may provide finer control of this setting
14308using C99's @code{FENV_ACCESS} pragma. This command-line option
14309will be used along with @option{-frounding-math} to specify the
14310default state for @code{FENV_ACCESS}.
14311
14312@item -frounding-math
14313@opindex frounding-math
14314Disable transformations and optimizations that assume default floating-point
14315rounding behavior. This is round-to-zero for all floating point
14316to integer conversions, and round-to-nearest for all other arithmetic
14317truncations. This option should be specified for programs that change
14318the FP rounding mode dynamically, or that may be executed with a
14319non-default rounding mode. This option disables constant folding of
14320floating-point expressions at compile time (which may be affected by
14321rounding mode) and arithmetic transformations that are unsafe in the
14322presence of sign-dependent rounding modes.
14323
14324The default is @option{-fno-rounding-math}.
14325
14326This option is experimental and does not currently guarantee to
14327disable all GCC optimizations that are affected by rounding mode.
14328Future versions of GCC may provide finer control of this setting
14329using C99's @code{FENV_ACCESS} pragma. This command-line option
14330will be used along with @option{-ftrapping-math} to specify the
14331default state for @code{FENV_ACCESS}.
14332
14333@item -fsignaling-nans
14334@opindex fsignaling-nans
14335Compile code assuming that IEEE signaling NaNs may generate user-visible
14336traps during floating-point operations. Setting this option disables
14337optimizations that may change the number of exceptions visible with
14338signaling NaNs. This option implies @option{-ftrapping-math}.
14339
14340This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to
14341be defined.
14342
14343The default is @option{-fno-signaling-nans}.
14344
14345This option is experimental and does not currently guarantee to
14346disable all GCC optimizations that affect signaling NaN behavior.
14347
14348@item -fno-fp-int-builtin-inexact
14349@opindex fno-fp-int-builtin-inexact
14350@opindex ffp-int-builtin-inexact
14351Do not allow the built-in functions @code{ceil}, @code{floor},
14352@code{round} and @code{trunc}, and their @code{float} and @code{long
14353double} variants, to generate code that raises the ``inexact''
14354floating-point exception for noninteger arguments. ISO C99 and C11
14355allow these functions to raise the ``inexact'' exception, but ISO/IEC
14356TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into
14357ISO C2X, does not allow these functions to do so.
14358
14359The default is @option{-ffp-int-builtin-inexact}, allowing the
14360exception to be raised, unless C2X or a later C standard is selected.
14361This option does nothing unless @option{-ftrapping-math} is in effect.
14362
14363Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions
14364generate a call to a library function then the ``inexact'' exception
14365may be raised if the library implementation does not follow TS 18661.
14366
14367@item -fsingle-precision-constant
14368@opindex fsingle-precision-constant
14369Treat floating-point constants as single precision instead of
14370implicitly converting them to double-precision constants.
14371
14372@item -fcx-limited-range
14373@opindex fcx-limited-range
14374When enabled, this option states that a range reduction step is not
14375needed when performing complex division. Also, there is no checking
14376whether the result of a complex multiplication or division is @code{NaN
14377+ I*NaN}, with an attempt to rescue the situation in that case. The
14378default is @option{-fno-cx-limited-range}, but is enabled by
14379@option{-ffast-math}.
14380
14381This option controls the default setting of the ISO C99
14382@code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to
14383all languages.
14384
14385@item -fcx-fortran-rules
14386@opindex fcx-fortran-rules
14387Complex multiplication and division follow Fortran rules. Range
14388reduction is done as part of complex division, but there is no checking
14389whether the result of a complex multiplication or division is @code{NaN
14390+ I*NaN}, with an attempt to rescue the situation in that case.
14391
14392The default is @option{-fno-cx-fortran-rules}.
14393
14394@end table
14395
14396The following options control optimizations that may improve
14397performance, but are not enabled by any @option{-O} options. This
14398section includes experimental options that may produce broken code.
14399
14400@table @gcctabopt
14401@item -fbranch-probabilities
14402@opindex fbranch-probabilities
14403After running a program compiled with @option{-fprofile-arcs}
14404(@pxref{Instrumentation Options}),
14405you can compile it a second time using
14406@option{-fbranch-probabilities}, to improve optimizations based on
14407the number of times each branch was taken. When a program
14408compiled with @option{-fprofile-arcs} exits, it saves arc execution
14409counts to a file called @file{@var{sourcename}.gcda} for each source
14410file. The information in this data file is very dependent on the
14411structure of the generated code, so you must use the same source code
14412and the same optimization options for both compilations.
14413See details about the file naming in @option{-fprofile-arcs}.
14414
14415With @option{-fbranch-probabilities}, GCC puts a
14416@samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}.
14417These can be used to improve optimization. Currently, they are only
14418used in one place: in @file{reorg.cc}, instead of guessing which path a
14419branch is most likely to take, the @samp{REG_BR_PROB} values are used to
14420exactly determine which path is taken more often.
14421
14422Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14423
14424@item -fprofile-values
14425@opindex fprofile-values
14426If combined with @option{-fprofile-arcs}, it adds code so that some
14427data about values of expressions in the program is gathered.
14428
14429With @option{-fbranch-probabilities}, it reads back the data gathered
14430from profiling values of expressions for usage in optimizations.
14431
14432Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and
14433@option{-fauto-profile}.
14434
14435@item -fprofile-reorder-functions
14436@opindex fprofile-reorder-functions
14437Function reordering based on profile instrumentation collects
14438first time of execution of a function and orders these functions
14439in ascending order.
14440
14441Enabled with @option{-fprofile-use}.
14442
14443@item -fvpt
14444@opindex fvpt
14445If combined with @option{-fprofile-arcs}, this option instructs the compiler
14446to add code to gather information about values of expressions.
14447
14448With @option{-fbranch-probabilities}, it reads back the data gathered
14449and actually performs the optimizations based on them.
14450Currently the optimizations include specialization of division operations
14451using the knowledge about the value of the denominator.
14452
14453Enabled with @option{-fprofile-use} and @option{-fauto-profile}.
14454
14455@item -frename-registers
14456@opindex frename-registers
14457Attempt to avoid false dependencies in scheduled code by making use
14458of registers left over after register allocation. This optimization
14459most benefits processors with lots of registers. Depending on the
14460debug information format adopted by the target, however, it can
14461make debugging impossible, since variables no longer stay in
14462a ``home register''.
14463
14464Enabled by default with @option{-funroll-loops}.
14465
14466@item -fschedule-fusion
14467@opindex fschedule-fusion
14468Performs a target dependent pass over the instruction stream to schedule
14469instructions of same type together because target machine can execute them
14470more efficiently if they are adjacent to each other in the instruction flow.
14471
14472Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
14473
14474@item -ftracer
14475@opindex ftracer
14476Perform tail duplication to enlarge superblock size. This transformation
14477simplifies the control flow of the function allowing other optimizations to do
14478a better job.
14479
14480Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14481
14482@item -funroll-loops
14483@opindex funroll-loops
14484Unroll loops whose number of iterations can be determined at compile time or
14485upon entry to the loop. @option{-funroll-loops} implies
14486@option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}.
14487It also turns on complete loop peeling (i.e.@: complete removal of loops with
14488a small constant number of iterations). This option makes code larger, and may
14489or may not make it run faster.
14490
14491Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14492
14493@item -funroll-all-loops
14494@opindex funroll-all-loops
14495Unroll all loops, even if their number of iterations is uncertain when
14496the loop is entered. This usually makes programs run more slowly.
14497@option{-funroll-all-loops} implies the same options as
14498@option{-funroll-loops}.
14499
14500@item -fpeel-loops
14501@opindex fpeel-loops
14502Peels loops for which there is enough information that they do not
14503roll much (from profile feedback or static analysis). It also turns on
14504complete loop peeling (i.e.@: complete removal of loops with small constant
14505number of iterations).
14506
14507Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}.
14508
14509@item -fmove-loop-invariants
14510@opindex fmove-loop-invariants
14511Enables the loop invariant motion pass in the RTL loop optimizer. Enabled
14512at level @option{-O1} and higher, except for @option{-Og}.
14513
14514@item -fmove-loop-stores
14515@opindex fmove-loop-stores
14516Enables the loop store motion pass in the GIMPLE loop optimizer. This
14517moves invariant stores to after the end of the loop in exchange for
14518carrying the stored value in a register across the iteration.
14519Note for this option to have an effect @option{-ftree-loop-im} has to
14520be enabled as well. Enabled at level @option{-O1} and higher, except
14521for @option{-Og}.
14522
14523@item -fsplit-loops
14524@opindex fsplit-loops
14525Split a loop into two if it contains a condition that's always true
14526for one side of the iteration space and false for the other.
14527
14528Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14529
14530@item -funswitch-loops
14531@opindex funswitch-loops
14532Move branches with loop invariant conditions out of the loop, with duplicates
14533of the loop on both branches (modified according to result of the condition).
14534
14535Enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14536
14537@item -fversion-loops-for-strides
14538@opindex fversion-loops-for-strides
14539If a loop iterates over an array with a variable stride, create another
14540version of the loop that assumes the stride is always one. For example:
14541
14542@smallexample
14543for (int i = 0; i < n; ++i)
14544 x[i * stride] = @dots{};
14545@end smallexample
14546
14547becomes:
14548
14549@smallexample
14550if (stride == 1)
14551 for (int i = 0; i < n; ++i)
14552 x[i] = @dots{};
14553else
14554 for (int i = 0; i < n; ++i)
14555 x[i * stride] = @dots{};
14556@end smallexample
14557
14558This is particularly useful for assumed-shape arrays in Fortran where
14559(for example) it allows better vectorization assuming contiguous accesses.
14560This flag is enabled by default at @option{-O3}.
14561It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}.
14562
14563@item -ffunction-sections
14564@itemx -fdata-sections
14565@opindex ffunction-sections
14566@opindex fdata-sections
14567Place each function or data item into its own section in the output
14568file if the target supports arbitrary sections. The name of the
14569function or the name of the data item determines the section's name
14570in the output file.
14571
14572Use these options on systems where the linker can perform optimizations to
14573improve locality of reference in the instruction space. Most systems using the
14574ELF object format have linkers with such optimizations. On AIX, the linker
14575rearranges sections (CSECTs) based on the call graph. The performance impact
14576varies.
14577
14578Together with a linker garbage collection (linker @option{--gc-sections}
14579option) these options may lead to smaller statically-linked executables (after
14580stripping).
14581
14582On ELF/DWARF systems these options do not degenerate the quality of the debug
14583information. There could be issues with other object files/debug info formats.
14584
14585Only use these options when there are significant benefits from doing so. When
14586you specify these options, the assembler and linker create larger object and
14587executable files and are also slower. These options affect code generation.
14588They prevent optimizations by the compiler and assembler using relative
14589locations inside a translation unit since the locations are unknown until
14590link time. An example of such an optimization is relaxing calls to short call
14591instructions.
14592
14593@item -fstdarg-opt
14594@opindex fstdarg-opt
14595Optimize the prologue of variadic argument functions with respect to usage of
14596those arguments.
14597
14598@item -fsection-anchors
14599@opindex fsection-anchors
14600Try to reduce the number of symbolic address calculations by using
14601shared ``anchor'' symbols to address nearby objects. This transformation
14602can help to reduce the number of GOT entries and GOT accesses on some
14603targets.
14604
14605For example, the implementation of the following function @code{foo}:
14606
14607@smallexample
14608static int a, b, c;
14609int foo (void) @{ return a + b + c; @}
14610@end smallexample
14611
14612@noindent
14613usually calculates the addresses of all three variables, but if you
14614compile it with @option{-fsection-anchors}, it accesses the variables
14615from a common anchor point instead. The effect is similar to the
14616following pseudocode (which isn't valid C):
14617
14618@smallexample
14619int foo (void)
14620@{
14621 register int *xr = &x;
14622 return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];
14623@}
14624@end smallexample
14625
14626Not all targets support this option.
14627
14628@item -fzero-call-used-regs=@var{choice}
14629@opindex fzero-call-used-regs
14630Zero call-used registers at function return to increase program
14631security by either mitigating Return-Oriented Programming (ROP)
14632attacks or preventing information leakage through registers.
14633
14634The possible values of @var{choice} are the same as for the
14635@code{zero_call_used_regs} attribute (@pxref{Function Attributes}).
14636The default is @samp{skip}.
14637
14638You can control this behavior for a specific function by using the function
14639attribute @code{zero_call_used_regs} (@pxref{Function Attributes}).
14640
14641@item --param @var{name}=@var{value}
14642@opindex param
14643In some places, GCC uses various constants to control the amount of
14644optimization that is done. For example, GCC does not inline functions
14645that contain more than a certain number of instructions. You can
14646control some of these constants on the command line using the
14647@option{--param} option.
14648
14649The names of specific parameters, and the meaning of the values, are
14650tied to the internals of the compiler, and are subject to change
14651without notice in future releases.
14652
14653In order to get minimal, maximal and default value of a parameter,
14654one can use @option{--help=param -Q} options.
14655
14656In each case, the @var{value} is an integer. The following choices
14657of @var{name} are recognized for all targets:
14658
14659@table @gcctabopt
14660@item predictable-branch-outcome
14661When branch is predicted to be taken with probability lower than this threshold
14662(in percent), then it is considered well predictable.
14663
14664@item max-rtl-if-conversion-insns
14665RTL if-conversion tries to remove conditional branches around a block and
14666replace them with conditionally executed instructions. This parameter
14667gives the maximum number of instructions in a block which should be
14668considered for if-conversion. The compiler will
14669also use other heuristics to decide whether if-conversion is likely to be
14670profitable.
14671
14672@item max-rtl-if-conversion-predictable-cost
14673RTL if-conversion will try to remove conditional branches around a block
14674and replace them with conditionally executed instructions. These parameters
14675give the maximum permissible cost for the sequence that would be generated
14676by if-conversion depending on whether the branch is statically determined
14677to be predictable or not. The units for this parameter are the same as
14678those for the GCC internal seq_cost metric. The compiler will try to
14679provide a reasonable default for this parameter using the BRANCH_COST
14680target macro.
14681
14682@item max-crossjump-edges
14683The maximum number of incoming edges to consider for cross-jumping.
14684The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in
14685the number of edges incoming to each block. Increasing values mean
14686more aggressive optimization, making the compilation time increase with
14687probably small improvement in executable size.
14688
14689@item min-crossjump-insns
14690The minimum number of instructions that must be matched at the end
14691of two blocks before cross-jumping is performed on them. This
14692value is ignored in the case where all instructions in the block being
14693cross-jumped from are matched.
14694
14695@item max-grow-copy-bb-insns
14696The maximum code size expansion factor when copying basic blocks
14697instead of jumping. The expansion is relative to a jump instruction.
14698
14699@item max-goto-duplication-insns
14700The maximum number of instructions to duplicate to a block that jumps
14701to a computed goto. To avoid @math{O(N^2)} behavior in a number of
14702passes, GCC factors computed gotos early in the compilation process,
14703and unfactors them as late as possible. Only computed jumps at the
14704end of a basic blocks with no more than max-goto-duplication-insns are
14705unfactored.
14706
14707@item max-delay-slot-insn-search
14708The maximum number of instructions to consider when looking for an
14709instruction to fill a delay slot. If more than this arbitrary number of
14710instructions are searched, the time savings from filling the delay slot
14711are minimal, so stop searching. Increasing values mean more
14712aggressive optimization, making the compilation time increase with probably
14713small improvement in execution time.
14714
14715@item max-delay-slot-live-search
14716When trying to fill delay slots, the maximum number of instructions to
14717consider when searching for a block with valid live register
14718information. Increasing this arbitrarily chosen value means more
14719aggressive optimization, increasing the compilation time. This parameter
14720should be removed when the delay slot code is rewritten to maintain the
14721control-flow graph.
14722
14723@item max-gcse-memory
14724The approximate maximum amount of memory in @code{kB} that can be allocated in
14725order to perform the global common subexpression elimination
14726optimization. If more memory than specified is required, the
14727optimization is not done.
14728
14729@item max-gcse-insertion-ratio
14730If the ratio of expression insertions to deletions is larger than this value
14731for any expression, then RTL PRE inserts or removes the expression and thus
14732leaves partially redundant computations in the instruction stream.
14733
14734@item max-pending-list-length
14735The maximum number of pending dependencies scheduling allows
14736before flushing the current state and starting over. Large functions
14737with few branches or calls can create excessively large lists which
14738needlessly consume memory and resources.
14739
14740@item max-modulo-backtrack-attempts
14741The maximum number of backtrack attempts the scheduler should make
14742when modulo scheduling a loop. Larger values can exponentially increase
14743compilation time.
14744
14745@item max-inline-functions-called-once-loop-depth
14746Maximal loop depth of a call considered by inline heuristics that tries to
14747inline all functions called once.
14748
14749@item max-inline-functions-called-once-insns
14750Maximal estimated size of functions produced while inlining functions called
14751once.
14752
14753@item max-inline-insns-single
14754Several parameters control the tree inliner used in GCC@. This number sets the
14755maximum number of instructions (counted in GCC's internal representation) in a
14756single function that the tree inliner considers for inlining. This only
14757affects functions declared inline and methods implemented in a class
14758declaration (C++).
14759
14760
14761@item max-inline-insns-auto
14762When you use @option{-finline-functions} (included in @option{-O3}),
14763a lot of functions that would otherwise not be considered for inlining
14764by the compiler are investigated. To those functions, a different
14765(more restrictive) limit compared to functions declared inline can
14766be applied (@option{--param max-inline-insns-auto}).
14767
14768@item max-inline-insns-small
14769This is bound applied to calls which are considered relevant with
14770@option{-finline-small-functions}.
14771
14772@item max-inline-insns-size
14773This is bound applied to calls which are optimized for size. Small growth
14774may be desirable to anticipate optimization oppurtunities exposed by inlining.
14775
14776@item uninlined-function-insns
14777Number of instructions accounted by inliner for function overhead such as
14778function prologue and epilogue.
14779
14780@item uninlined-function-time
14781Extra time accounted by inliner for function overhead such as time needed to
14782execute function prologue and epilogue.
14783
14784@item inline-heuristics-hint-percent
14785The scale (in percents) applied to @option{inline-insns-single},
14786@option{inline-insns-single-O2}, @option{inline-insns-auto}
14787when inline heuristics hints that inlining is
14788very profitable (will enable later optimizations).
14789
14790@item uninlined-thunk-insns
14791@item uninlined-thunk-time
14792Same as @option{--param uninlined-function-insns} and
14793@option{--param uninlined-function-time} but applied to function thunks.
14794
14795@item inline-min-speedup
14796When estimated performance improvement of caller + callee runtime exceeds this
14797threshold (in percent), the function can be inlined regardless of the limit on
14798@option{--param max-inline-insns-single} and @option{--param
14799max-inline-insns-auto}.
14800
14801@item large-function-insns
14802The limit specifying really large functions. For functions larger than this
14803limit after inlining, inlining is constrained by
14804@option{--param large-function-growth}. This parameter is useful primarily
14805to avoid extreme compilation time caused by non-linear algorithms used by the
14806back end.
14807
14808@item large-function-growth
14809Specifies maximal growth of large function caused by inlining in percents.
14810For example, parameter value 100 limits large function growth to 2.0 times
14811the original size.
14812
14813@item large-unit-insns
14814The limit specifying large translation unit. Growth caused by inlining of
14815units larger than this limit is limited by @option{--param inline-unit-growth}.
14816For small units this might be too tight.
14817For example, consider a unit consisting of function A
14818that is inline and B that just calls A three times. If B is small relative to
14819A, the growth of unit is 300\% and yet such inlining is very sane. For very
14820large units consisting of small inlineable functions, however, the overall unit
14821growth limit is needed to avoid exponential explosion of code size. Thus for
14822smaller units, the size is increased to @option{--param large-unit-insns}
14823before applying @option{--param inline-unit-growth}.
14824
14825@item lazy-modules
14826Maximum number of concurrently open C++ module files when lazy loading.
14827
14828@item inline-unit-growth
14829Specifies maximal overall growth of the compilation unit caused by inlining.
14830For example, parameter value 20 limits unit growth to 1.2 times the original
14831size. Cold functions (either marked cold via an attribute or by profile
14832feedback) are not accounted into the unit size.
14833
14834@item ipa-cp-unit-growth
14835Specifies maximal overall growth of the compilation unit caused by
14836interprocedural constant propagation. For example, parameter value 10 limits
14837unit growth to 1.1 times the original size.
14838
14839@item ipa-cp-large-unit-insns
14840The size of translation unit that IPA-CP pass considers large.
14841
14842@item large-stack-frame
14843The limit specifying large stack frames. While inlining the algorithm is trying
14844to not grow past this limit too much.
14845
14846@item large-stack-frame-growth
14847Specifies maximal growth of large stack frames caused by inlining in percents.
14848For example, parameter value 1000 limits large stack frame growth to 11 times
14849the original size.
14850
14851@item max-inline-insns-recursive
14852@itemx max-inline-insns-recursive-auto
14853Specifies the maximum number of instructions an out-of-line copy of a
14854self-recursive inline
14855function can grow into by performing recursive inlining.
14856
14857@option{--param max-inline-insns-recursive} applies to functions
14858declared inline.
14859For functions not declared inline, recursive inlining
14860happens only when @option{-finline-functions} (included in @option{-O3}) is
14861enabled; @option{--param max-inline-insns-recursive-auto} applies instead.
14862
14863@item max-inline-recursive-depth
14864@itemx max-inline-recursive-depth-auto
14865Specifies the maximum recursion depth used for recursive inlining.
14866
14867@option{--param max-inline-recursive-depth} applies to functions
14868declared inline. For functions not declared inline, recursive inlining
14869happens only when @option{-finline-functions} (included in @option{-O3}) is
14870enabled; @option{--param max-inline-recursive-depth-auto} applies instead.
14871
14872@item min-inline-recursive-probability
14873Recursive inlining is profitable only for function having deep recursion
14874in average and can hurt for function having little recursion depth by
14875increasing the prologue size or complexity of function body to other
14876optimizers.
14877
14878When profile feedback is available (see @option{-fprofile-generate}) the actual
14879recursion depth can be guessed from the probability that function recurses
14880via a given call expression. This parameter limits inlining only to call
14881expressions whose probability exceeds the given threshold (in percents).
14882
14883@item early-inlining-insns
14884Specify growth that the early inliner can make. In effect it increases
14885the amount of inlining for code having a large abstraction penalty.
14886
14887@item max-early-inliner-iterations
14888Limit of iterations of the early inliner. This basically bounds
14889the number of nested indirect calls the early inliner can resolve.
14890Deeper chains are still handled by late inlining.
14891
14892@item comdat-sharing-probability
14893Probability (in percent) that C++ inline function with comdat visibility
14894are shared across multiple compilation units.
14895
14896@item modref-max-bases
14897@item modref-max-refs
14898@item modref-max-accesses
14899Specifies the maximal number of base pointers, references and accesses stored
14900for a single function by mod/ref analysis.
14901
14902@item modref-max-tests
14903Specifies the maxmal number of tests alias oracle can perform to disambiguate
14904memory locations using the mod/ref information. This parameter ought to be
14905bigger than @option{--param modref-max-bases} and @option{--param
14906modref-max-refs}.
14907
14908@item modref-max-depth
14909Specifies the maximum depth of DFS walk used by modref escape analysis.
14910Setting to 0 disables the analysis completely.
14911
14912@item modref-max-escape-points
14913Specifies the maximum number of escape points tracked by modref per SSA-name.
14914
14915@item modref-max-adjustments
14916Specifies the maximum number the access range is enlarged during modref dataflow
14917analysis.
14918
14919@item profile-func-internal-id
14920A parameter to control whether to use function internal id in profile
14921database lookup. If the value is 0, the compiler uses an id that
14922is based on function assembler name and filename, which makes old profile
14923data more tolerant to source changes such as function reordering etc.
14924
14925@item min-vect-loop-bound
14926The minimum number of iterations under which loops are not vectorized
14927when @option{-ftree-vectorize} is used. The number of iterations after
14928vectorization needs to be greater than the value specified by this option
14929to allow vectorization.
14930
14931@item gcse-cost-distance-ratio
14932Scaling factor in calculation of maximum distance an expression
14933can be moved by GCSE optimizations. This is currently supported only in the
14934code hoisting pass. The bigger the ratio, the more aggressive code hoisting
14935is with simple expressions, i.e., the expressions that have cost
14936less than @option{gcse-unrestricted-cost}. Specifying 0 disables
14937hoisting of simple expressions.
14938
14939@item gcse-unrestricted-cost
14940Cost, roughly measured as the cost of a single typical machine
14941instruction, at which GCSE optimizations do not constrain
14942the distance an expression can travel. This is currently
14943supported only in the code hoisting pass. The lesser the cost,
14944the more aggressive code hoisting is. Specifying 0
14945allows all expressions to travel unrestricted distances.
14946
14947@item max-hoist-depth
14948The depth of search in the dominator tree for expressions to hoist.
14949This is used to avoid quadratic behavior in hoisting algorithm.
14950The value of 0 does not limit on the search, but may slow down compilation
14951of huge functions.
14952
14953@item max-tail-merge-comparisons
14954The maximum amount of similar bbs to compare a bb with. This is used to
14955avoid quadratic behavior in tree tail merging.
14956
14957@item max-tail-merge-iterations
14958The maximum amount of iterations of the pass over the function. This is used to
14959limit compilation time in tree tail merging.
14960
14961@item store-merging-allow-unaligned
14962Allow the store merging pass to introduce unaligned stores if it is legal to
14963do so.
14964
14965@item max-stores-to-merge
14966The maximum number of stores to attempt to merge into wider stores in the store
14967merging pass.
14968
14969@item max-store-chains-to-track
14970The maximum number of store chains to track at the same time in the attempt
14971to merge them into wider stores in the store merging pass.
14972
14973@item max-stores-to-track
14974The maximum number of stores to track at the same time in the attemt to
14975to merge them into wider stores in the store merging pass.
14976
14977@item max-unrolled-insns
14978The maximum number of instructions that a loop may have to be unrolled.
14979If a loop is unrolled, this parameter also determines how many times
14980the loop code is unrolled.
14981
14982@item max-average-unrolled-insns
14983The maximum number of instructions biased by probabilities of their execution
14984that a loop may have to be unrolled. If a loop is unrolled,
14985this parameter also determines how many times the loop code is unrolled.
14986
14987@item max-unroll-times
14988The maximum number of unrollings of a single loop.
14989
14990@item max-peeled-insns
14991The maximum number of instructions that a loop may have to be peeled.
14992If a loop is peeled, this parameter also determines how many times
14993the loop code is peeled.
14994
14995@item max-peel-times
14996The maximum number of peelings of a single loop.
14997
14998@item max-peel-branches
14999The maximum number of branches on the hot path through the peeled sequence.
15000
15001@item max-completely-peeled-insns
15002The maximum number of insns of a completely peeled loop.
15003
15004@item max-completely-peel-times
15005The maximum number of iterations of a loop to be suitable for complete peeling.
15006
15007@item max-completely-peel-loop-nest-depth
15008The maximum depth of a loop nest suitable for complete peeling.
15009
15010@item max-unswitch-insns
15011The maximum number of insns of an unswitched loop.
15012
5b50850c
RB
15013@item max-unswitch-depth
15014The maximum depth of a loop nest to be unswitched.
15015
d77de738
ML
15016@item lim-expensive
15017The minimum cost of an expensive expression in the loop invariant motion.
15018
15019@item min-loop-cond-split-prob
15020When FDO profile information is available, @option{min-loop-cond-split-prob}
15021specifies minimum threshold for probability of semi-invariant condition
15022statement to trigger loop split.
15023
15024@item iv-consider-all-candidates-bound
15025Bound on number of candidates for induction variables, below which
15026all candidates are considered for each use in induction variable
15027optimizations. If there are more candidates than this,
15028only the most relevant ones are considered to avoid quadratic time complexity.
15029
15030@item iv-max-considered-uses
15031The induction variable optimizations give up on loops that contain more
15032induction variable uses.
15033
15034@item iv-always-prune-cand-set-bound
15035If the number of candidates in the set is smaller than this value,
15036always try to remove unnecessary ivs from the set
15037when adding a new one.
15038
15039@item avg-loop-niter
15040Average number of iterations of a loop.
15041
15042@item dse-max-object-size
15043Maximum size (in bytes) of objects tracked bytewise by dead store elimination.
15044Larger values may result in larger compilation times.
15045
15046@item dse-max-alias-queries-per-store
15047Maximum number of queries into the alias oracle per store.
15048Larger values result in larger compilation times and may result in more
15049removed dead stores.
15050
15051@item scev-max-expr-size
15052Bound on size of expressions used in the scalar evolutions analyzer.
15053Large expressions slow the analyzer.
15054
15055@item scev-max-expr-complexity
15056Bound on the complexity of the expressions in the scalar evolutions analyzer.
15057Complex expressions slow the analyzer.
15058
15059@item max-tree-if-conversion-phi-args
15060Maximum number of arguments in a PHI supported by TREE if conversion
15061unless the loop is marked with simd pragma.
15062
15063@item vect-max-layout-candidates
15064The maximum number of possible vector layouts (such as permutations)
15065to consider when optimizing to-be-vectorized code.
15066
15067@item vect-max-version-for-alignment-checks
15068The maximum number of run-time checks that can be performed when
15069doing loop versioning for alignment in the vectorizer.
15070
15071@item vect-max-version-for-alias-checks
15072The maximum number of run-time checks that can be performed when
15073doing loop versioning for alias in the vectorizer.
15074
15075@item vect-max-peeling-for-alignment
15076The maximum number of loop peels to enhance access alignment
15077for vectorizer. Value -1 means no limit.
15078
15079@item max-iterations-to-track
15080The maximum number of iterations of a loop the brute-force algorithm
15081for analysis of the number of iterations of the loop tries to evaluate.
15082
15083@item hot-bb-count-fraction
15084The denominator n of fraction 1/n of the maximal execution count of a
15085basic block in the entire program that a basic block needs to at least
15086have in order to be considered hot. The default is 10000, which means
15087that a basic block is considered hot if its execution count is greater
15088than 1/10000 of the maximal execution count. 0 means that it is never
15089considered hot. Used in non-LTO mode.
15090
15091@item hot-bb-count-ws-permille
15092The number of most executed permilles, ranging from 0 to 1000, of the
15093profiled execution of the entire program to which the execution count
15094of a basic block must be part of in order to be considered hot. The
15095default is 990, which means that a basic block is considered hot if
15096its execution count contributes to the upper 990 permilles, or 99.0%,
15097of the profiled execution of the entire program. 0 means that it is
15098never considered hot. Used in LTO mode.
15099
15100@item hot-bb-frequency-fraction
15101The denominator n of fraction 1/n of the execution frequency of the
15102entry block of a function that a basic block of this function needs
15103to at least have in order to be considered hot. The default is 1000,
15104which means that a basic block is considered hot in a function if it
15105is executed more frequently than 1/1000 of the frequency of the entry
15106block of the function. 0 means that it is never considered hot.
15107
15108@item unlikely-bb-count-fraction
15109The denominator n of fraction 1/n of the number of profiled runs of
15110the entire program below which the execution count of a basic block
15111must be in order for the basic block to be considered unlikely executed.
15112The default is 20, which means that a basic block is considered unlikely
15113executed if it is executed in fewer than 1/20, or 5%, of the runs of
15114the program. 0 means that it is always considered unlikely executed.
15115
15116@item max-predicted-iterations
15117The maximum number of loop iterations we predict statically. This is useful
15118in cases where a function contains a single loop with known bound and
15119another loop with unknown bound.
15120The known number of iterations is predicted correctly, while
15121the unknown number of iterations average to roughly 10. This means that the
15122loop without bounds appears artificially cold relative to the other one.
15123
15124@item builtin-expect-probability
15125Control the probability of the expression having the specified value. This
15126parameter takes a percentage (i.e.@: 0 ... 100) as input.
15127
15128@item builtin-string-cmp-inline-length
15129The maximum length of a constant string for a builtin string cmp call
15130eligible for inlining.
15131
15132@item align-threshold
15133
15134Select fraction of the maximal frequency of executions of a basic block in
15135a function to align the basic block.
15136
15137@item align-loop-iterations
15138
15139A loop expected to iterate at least the selected number of iterations is
15140aligned.
15141
15142@item tracer-dynamic-coverage
15143@itemx tracer-dynamic-coverage-feedback
15144
15145This value is used to limit superblock formation once the given percentage of
15146executed instructions is covered. This limits unnecessary code size
15147expansion.
15148
15149The @option{tracer-dynamic-coverage-feedback} parameter
15150is used only when profile
15151feedback is available. The real profiles (as opposed to statically estimated
15152ones) are much less balanced allowing the threshold to be larger value.
15153
15154@item tracer-max-code-growth
15155Stop tail duplication once code growth has reached given percentage. This is
15156a rather artificial limit, as most of the duplicates are eliminated later in
15157cross jumping, so it may be set to much higher values than is the desired code
15158growth.
15159
15160@item tracer-min-branch-ratio
15161
15162Stop reverse growth when the reverse probability of best edge is less than this
15163threshold (in percent).
15164
15165@item tracer-min-branch-probability
15166@itemx tracer-min-branch-probability-feedback
15167
15168Stop forward growth if the best edge has probability lower than this
15169threshold.
15170
15171Similarly to @option{tracer-dynamic-coverage} two parameters are
15172provided. @option{tracer-min-branch-probability-feedback} is used for
15173compilation with profile feedback and @option{tracer-min-branch-probability}
15174compilation without. The value for compilation with profile feedback
15175needs to be more conservative (higher) in order to make tracer
15176effective.
15177
15178@item stack-clash-protection-guard-size
15179Specify the size of the operating system provided stack guard as
151802 raised to @var{num} bytes. Higher values may reduce the
15181number of explicit probes, but a value larger than the operating system
15182provided guard will leave code vulnerable to stack clash style attacks.
15183
15184@item stack-clash-protection-probe-interval
15185Stack clash protection involves probing stack space as it is allocated. This
15186param controls the maximum distance between probes into the stack as 2 raised
15187to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value
15188larger than the operating system provided guard will leave code vulnerable to
15189stack clash style attacks.
15190
15191@item max-cse-path-length
15192
15193The maximum number of basic blocks on path that CSE considers.
15194
15195@item max-cse-insns
15196The maximum number of instructions CSE processes before flushing.
15197
15198@item ggc-min-expand
15199
15200GCC uses a garbage collector to manage its own memory allocation. This
15201parameter specifies the minimum percentage by which the garbage
15202collector's heap should be allowed to expand between collections.
15203Tuning this may improve compilation speed; it has no effect on code
15204generation.
15205
15206The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when
15207RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is
15208the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If
15209GCC is not able to calculate RAM on a particular platform, the lower
15210bound of 30% is used. Setting this parameter and
15211@option{ggc-min-heapsize} to zero causes a full collection to occur at
15212every opportunity. This is extremely slow, but can be useful for
15213debugging.
15214
15215@item ggc-min-heapsize
15216
15217Minimum size of the garbage collector's heap before it begins bothering
15218to collect garbage. The first collection occurs after the heap expands
15219by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again,
15220tuning this may improve compilation speed, and has no effect on code
15221generation.
15222
15223The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that
15224tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but
15225with a lower bound of 4096 (four megabytes) and an upper bound of
15226131072 (128 megabytes). If GCC is not able to calculate RAM on a
15227particular platform, the lower bound is used. Setting this parameter
15228very large effectively disables garbage collection. Setting this
15229parameter and @option{ggc-min-expand} to zero causes a full collection
15230to occur at every opportunity.
15231
15232@item max-reload-search-insns
15233The maximum number of instruction reload should look backward for equivalent
15234register. Increasing values mean more aggressive optimization, making the
15235compilation time increase with probably slightly better performance.
15236
15237@item max-cselib-memory-locations
15238The maximum number of memory locations cselib should take into account.
15239Increasing values mean more aggressive optimization, making the compilation time
15240increase with probably slightly better performance.
15241
15242@item max-sched-ready-insns
15243The maximum number of instructions ready to be issued the scheduler should
15244consider at any given time during the first scheduling pass. Increasing
15245values mean more thorough searches, making the compilation time increase
15246with probably little benefit.
15247
15248@item max-sched-region-blocks
15249The maximum number of blocks in a region to be considered for
15250interblock scheduling.
15251
15252@item max-pipeline-region-blocks
15253The maximum number of blocks in a region to be considered for
15254pipelining in the selective scheduler.
15255
15256@item max-sched-region-insns
15257The maximum number of insns in a region to be considered for
15258interblock scheduling.
15259
15260@item max-pipeline-region-insns
15261The maximum number of insns in a region to be considered for
15262pipelining in the selective scheduler.
15263
15264@item min-spec-prob
15265The minimum probability (in percents) of reaching a source block
15266for interblock speculative scheduling.
15267
15268@item max-sched-extend-regions-iters
15269The maximum number of iterations through CFG to extend regions.
15270A value of 0 disables region extensions.
15271
15272@item max-sched-insn-conflict-delay
15273The maximum conflict delay for an insn to be considered for speculative motion.
15274
15275@item sched-spec-prob-cutoff
15276The minimal probability of speculation success (in percents), so that
15277speculative insns are scheduled.
15278
15279@item sched-state-edge-prob-cutoff
15280The minimum probability an edge must have for the scheduler to save its
15281state across it.
15282
15283@item sched-mem-true-dep-cost
15284Minimal distance (in CPU cycles) between store and load targeting same
15285memory locations.
15286
15287@item selsched-max-lookahead
15288The maximum size of the lookahead window of selective scheduling. It is a
15289depth of search for available instructions.
15290
15291@item selsched-max-sched-times
15292The maximum number of times that an instruction is scheduled during
15293selective scheduling. This is the limit on the number of iterations
15294through which the instruction may be pipelined.
15295
15296@item selsched-insns-to-rename
15297The maximum number of best instructions in the ready list that are considered
15298for renaming in the selective scheduler.
15299
15300@item sms-min-sc
15301The minimum value of stage count that swing modulo scheduler
15302generates.
15303
15304@item max-last-value-rtl
15305The maximum size measured as number of RTLs that can be recorded in an expression
15306in combiner for a pseudo register as last known value of that register.
15307
15308@item max-combine-insns
15309The maximum number of instructions the RTL combiner tries to combine.
15310
15311@item integer-share-limit
15312Small integer constants can use a shared data structure, reducing the
15313compiler's memory usage and increasing its speed. This sets the maximum
15314value of a shared integer constant.
15315
15316@item ssp-buffer-size
15317The minimum size of buffers (i.e.@: arrays) that receive stack smashing
15318protection when @option{-fstack-protector} is used.
15319
15320@item min-size-for-stack-sharing
15321The minimum size of variables taking part in stack slot sharing when not
15322optimizing.
15323
15324@item max-jump-thread-duplication-stmts
15325Maximum number of statements allowed in a block that needs to be
15326duplicated when threading jumps.
15327
15328@item max-jump-thread-paths
15329The maximum number of paths to consider when searching for jump threading
15330opportunities. When arriving at a block, incoming edges are only considered
15331if the number of paths to be searched so far multiplied by the number of
15332incoming edges does not exhaust the specified maximum number of paths to
15333consider.
15334
15335@item max-fields-for-field-sensitive
15336Maximum number of fields in a structure treated in
15337a field sensitive manner during pointer analysis.
15338
15339@item prefetch-latency
15340Estimate on average number of instructions that are executed before
15341prefetch finishes. The distance prefetched ahead is proportional
15342to this constant. Increasing this number may also lead to less
15343streams being prefetched (see @option{simultaneous-prefetches}).
15344
15345@item simultaneous-prefetches
15346Maximum number of prefetches that can run at the same time.
15347
15348@item l1-cache-line-size
15349The size of cache line in L1 data cache, in bytes.
15350
15351@item l1-cache-size
15352The size of L1 data cache, in kilobytes.
15353
15354@item l2-cache-size
15355The size of L2 data cache, in kilobytes.
15356
15357@item prefetch-dynamic-strides
15358Whether the loop array prefetch pass should issue software prefetch hints
15359for strides that are non-constant. In some cases this may be
15360beneficial, though the fact the stride is non-constant may make it
15361hard to predict when there is clear benefit to issuing these hints.
15362
15363Set to 1 if the prefetch hints should be issued for non-constant
15364strides. Set to 0 if prefetch hints should be issued only for strides that
15365are known to be constant and below @option{prefetch-minimum-stride}.
15366
15367@item prefetch-minimum-stride
15368Minimum constant stride, in bytes, to start using prefetch hints for. If
15369the stride is less than this threshold, prefetch hints will not be issued.
15370
15371This setting is useful for processors that have hardware prefetchers, in
15372which case there may be conflicts between the hardware prefetchers and
15373the software prefetchers. If the hardware prefetchers have a maximum
15374stride they can handle, it should be used here to improve the use of
15375software prefetchers.
15376
15377A value of -1 means we don't have a threshold and therefore
15378prefetch hints can be issued for any constant stride.
15379
15380This setting is only useful for strides that are known and constant.
15381
15382@item destructive-interference-size
15383@item constructive-interference-size
15384The values for the C++17 variables
15385@code{std::hardware_destructive_interference_size} and
15386@code{std::hardware_constructive_interference_size}. The destructive
15387interference size is the minimum recommended offset between two
15388independent concurrently-accessed objects; the constructive
15389interference size is the maximum recommended size of contiguous memory
15390accessed together. Typically both will be the size of an L1 cache
15391line for the target, in bytes. For a generic target covering a range of L1
15392cache line sizes, typically the constructive interference size will be
15393the small end of the range and the destructive size will be the large
15394end.
15395
15396The destructive interference size is intended to be used for layout,
15397and thus has ABI impact. The default value is not expected to be
15398stable, and on some targets varies with @option{-mtune}, so use of
15399this variable in a context where ABI stability is important, such as
15400the public interface of a library, is strongly discouraged; if it is
15401used in that context, users can stabilize the value using this
15402option.
15403
15404The constructive interference size is less sensitive, as it is
15405typically only used in a @samp{static_assert} to make sure that a type
15406fits within a cache line.
15407
15408See also @option{-Winterference-size}.
15409
15410@item loop-interchange-max-num-stmts
15411The maximum number of stmts in a loop to be interchanged.
15412
15413@item loop-interchange-stride-ratio
15414The minimum ratio between stride of two loops for interchange to be profitable.
15415
15416@item min-insn-to-prefetch-ratio
15417The minimum ratio between the number of instructions and the
15418number of prefetches to enable prefetching in a loop.
15419
15420@item prefetch-min-insn-to-mem-ratio
15421The minimum ratio between the number of instructions and the
15422number of memory references to enable prefetching in a loop.
15423
15424@item use-canonical-types
15425Whether the compiler should use the ``canonical'' type system.
15426Should always be 1, which uses a more efficient internal
15427mechanism for comparing types in C++ and Objective-C++. However, if
15428bugs in the canonical type system are causing compilation failures,
15429set this value to 0 to disable canonical types.
15430
15431@item switch-conversion-max-branch-ratio
15432Switch initialization conversion refuses to create arrays that are
15433bigger than @option{switch-conversion-max-branch-ratio} times the number of
15434branches in the switch.
15435
15436@item max-partial-antic-length
15437Maximum length of the partial antic set computed during the tree
15438partial redundancy elimination optimization (@option{-ftree-pre}) when
15439optimizing at @option{-O3} and above. For some sorts of source code
15440the enhanced partial redundancy elimination optimization can run away,
15441consuming all of the memory available on the host machine. This
15442parameter sets a limit on the length of the sets that are computed,
15443which prevents the runaway behavior. Setting a value of 0 for
15444this parameter allows an unlimited set length.
15445
15446@item rpo-vn-max-loop-depth
15447Maximum loop depth that is value-numbered optimistically.
15448When the limit hits the innermost
15449@var{rpo-vn-max-loop-depth} loops and the outermost loop in the
15450loop nest are value-numbered optimistically and the remaining ones not.
15451
15452@item sccvn-max-alias-queries-per-access
15453Maximum number of alias-oracle queries we perform when looking for
15454redundancies for loads and stores. If this limit is hit the search
15455is aborted and the load or store is not considered redundant. The
15456number of queries is algorithmically limited to the number of
15457stores on all paths from the load to the function entry.
15458
15459@item ira-max-loops-num
15460IRA uses regional register allocation by default. If a function
15461contains more loops than the number given by this parameter, only at most
15462the given number of the most frequently-executed loops form regions
15463for regional register allocation.
15464
15465@item ira-max-conflict-table-size
15466Although IRA uses a sophisticated algorithm to compress the conflict
15467table, the table can still require excessive amounts of memory for
15468huge functions. If the conflict table for a function could be more
15469than the size in MB given by this parameter, the register allocator
15470instead uses a faster, simpler, and lower-quality
15471algorithm that does not require building a pseudo-register conflict table.
15472
15473@item ira-loop-reserved-regs
15474IRA can be used to evaluate more accurate register pressure in loops
15475for decisions to move loop invariants (see @option{-O3}). The number
15476of available registers reserved for some other purposes is given
15477by this parameter. Default of the parameter
15478is the best found from numerous experiments.
15479
15480@item ira-consider-dup-in-all-alts
15481Make IRA to consider matching constraint (duplicated operand number)
15482heavily in all available alternatives for preferred register class.
15483If it is set as zero, it means IRA only respects the matching
15484constraint when it's in the only available alternative with an
15485appropriate register class. Otherwise, it means IRA will check all
15486available alternatives for preferred register class even if it has
15487found some choice with an appropriate register class and respect the
15488found qualified matching constraint.
15489
15490@item lra-inheritance-ebb-probability-cutoff
15491LRA tries to reuse values reloaded in registers in subsequent insns.
15492This optimization is called inheritance. EBB is used as a region to
15493do this optimization. The parameter defines a minimal fall-through
15494edge probability in percentage used to add BB to inheritance EBB in
15495LRA. The default value was chosen
15496from numerous runs of SPEC2000 on x86-64.
15497
15498@item loop-invariant-max-bbs-in-loop
15499Loop invariant motion can be very expensive, both in compilation time and
15500in amount of needed compile-time memory, with very large loops. Loops
15501with more basic blocks than this parameter won't have loop invariant
15502motion optimization performed on them.
15503
15504@item loop-max-datarefs-for-datadeps
15505Building data dependencies is expensive for very large loops. This
15506parameter limits the number of data references in loops that are
15507considered for data dependence analysis. These large loops are no
15508handled by the optimizations using loop data dependencies.
15509
15510@item max-vartrack-size
15511Sets a maximum number of hash table slots to use during variable
15512tracking dataflow analysis of any function. If this limit is exceeded
15513with variable tracking at assignments enabled, analysis for that
15514function is retried without it, after removing all debug insns from
15515the function. If the limit is exceeded even without debug insns, var
15516tracking analysis is completely disabled for the function. Setting
15517the parameter to zero makes it unlimited.
15518
15519@item max-vartrack-expr-depth
15520Sets a maximum number of recursion levels when attempting to map
15521variable names or debug temporaries to value expressions. This trades
15522compilation time for more complete debug information. If this is set too
15523low, value expressions that are available and could be represented in
15524debug information may end up not being used; setting this higher may
15525enable the compiler to find more complex debug expressions, but compile
15526time and memory use may grow.
15527
15528@item max-debug-marker-count
15529Sets a threshold on the number of debug markers (e.g.@: begin stmt
15530markers) to avoid complexity explosion at inlining or expanding to RTL.
15531If a function has more such gimple stmts than the set limit, such stmts
15532will be dropped from the inlined copy of a function, and from its RTL
15533expansion.
15534
15535@item min-nondebug-insn-uid
15536Use uids starting at this parameter for nondebug insns. The range below
15537the parameter is reserved exclusively for debug insns created by
15538@option{-fvar-tracking-assignments}, but debug insns may get
15539(non-overlapping) uids above it if the reserved range is exhausted.
15540
10478270
MJ
15541@item ipa-sra-deref-prob-threshold
15542IPA-SRA replaces a pointer which is known not be NULL with one or more
15543new parameters only when the probability (in percent, relative to
15544function entry) of it being dereferenced is higher than this parameter.
15545
d77de738
ML
15546@item ipa-sra-ptr-growth-factor
15547IPA-SRA replaces a pointer to an aggregate with one or more new
15548parameters only when their cumulative size is less or equal to
15549@option{ipa-sra-ptr-growth-factor} times the size of the original
15550pointer parameter.
15551
69363825
ML
15552@item ipa-sra-ptrwrap-growth-factor
15553Additional maximum allowed growth of total size of new parameters
15554that ipa-sra replaces a pointer to an aggregate with,
049dccd0
MJ
15555if it points to a local variable that the caller only writes to and
15556passes it as an argument to other functions.
69363825 15557
d77de738
ML
15558@item ipa-sra-max-replacements
15559Maximum pieces of an aggregate that IPA-SRA tracks. As a
15560consequence, it is also the maximum number of replacements of a formal
15561parameter.
15562
15563@item sra-max-scalarization-size-Ospeed
15564@itemx sra-max-scalarization-size-Osize
15565The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to
15566replace scalar parts of aggregates with uses of independent scalar
15567variables. These parameters control the maximum size, in storage units,
15568of aggregate which is considered for replacement when compiling for
15569speed
15570(@option{sra-max-scalarization-size-Ospeed}) or size
15571(@option{sra-max-scalarization-size-Osize}) respectively.
15572
15573@item sra-max-propagations
15574The maximum number of artificial accesses that Scalar Replacement of
15575Aggregates (SRA) will track, per one local variable, in order to
15576facilitate copy propagation.
15577
15578@item tm-max-aggregate-size
15579When making copies of thread-local variables in a transaction, this
15580parameter specifies the size in bytes after which variables are
15581saved with the logging functions as opposed to save/restore code
15582sequence pairs. This option only applies when using
15583@option{-fgnu-tm}.
15584
15585@item graphite-max-nb-scop-params
15586To avoid exponential effects in the Graphite loop transforms, the
15587number of parameters in a Static Control Part (SCoP) is bounded.
15588A value of zero can be used to lift
15589the bound. A variable whose value is unknown at compilation time and
15590defined outside a SCoP is a parameter of the SCoP.
15591
15592@item loop-block-tile-size
15593Loop blocking or strip mining transforms, enabled with
15594@option{-floop-block} or @option{-floop-strip-mine}, strip mine each
15595loop in the loop nest by a given number of iterations. The strip
15596length can be changed using the @option{loop-block-tile-size}
15597parameter.
15598
15599@item ipa-jump-function-lookups
15600Specifies number of statements visited during jump function offset discovery.
15601
15602@item ipa-cp-value-list-size
15603IPA-CP attempts to track all possible values and types passed to a function's
15604parameter in order to propagate them and perform devirtualization.
15605@option{ipa-cp-value-list-size} is the maximum number of values and types it
15606stores per one formal parameter of a function.
15607
15608@item ipa-cp-eval-threshold
15609IPA-CP calculates its own score of cloning profitability heuristics
15610and performs those cloning opportunities with scores that exceed
15611@option{ipa-cp-eval-threshold}.
15612
15613@item ipa-cp-max-recursive-depth
15614Maximum depth of recursive cloning for self-recursive function.
15615
15616@item ipa-cp-min-recursive-probability
15617Recursive cloning only when the probability of call being executed exceeds
15618the parameter.
15619
15620@item ipa-cp-profile-count-base
15621When using @option{-fprofile-use} option, IPA-CP will consider the measured
15622execution count of a call graph edge at this percentage position in their
15623histogram as the basis for its heuristics calculation.
15624
15625@item ipa-cp-recursive-freq-factor
15626The number of times interprocedural copy propagation expects recursive
15627functions to call themselves.
15628
15629@item ipa-cp-recursion-penalty
15630Percentage penalty the recursive functions will receive when they
15631are evaluated for cloning.
15632
15633@item ipa-cp-single-call-penalty
15634Percentage penalty functions containing a single call to another
15635function will receive when they are evaluated for cloning.
15636
15637@item ipa-max-agg-items
15638IPA-CP is also capable to propagate a number of scalar values passed
15639in an aggregate. @option{ipa-max-agg-items} controls the maximum
15640number of such values per one parameter.
15641
15642@item ipa-cp-loop-hint-bonus
15643When IPA-CP determines that a cloning candidate would make the number
15644of iterations of a loop known, it adds a bonus of
15645@option{ipa-cp-loop-hint-bonus} to the profitability score of
15646the candidate.
15647
15648@item ipa-max-loop-predicates
15649The maximum number of different predicates IPA will use to describe when
15650loops in a function have known properties.
15651
15652@item ipa-max-aa-steps
15653During its analysis of function bodies, IPA-CP employs alias analysis
15654in order to track values pointed to by function parameters. In order
15655not spend too much time analyzing huge functions, it gives up and
15656consider all memory clobbered after examining
15657@option{ipa-max-aa-steps} statements modifying memory.
15658
15659@item ipa-max-switch-predicate-bounds
15660Maximal number of boundary endpoints of case ranges of switch statement.
15661For switch exceeding this limit, IPA-CP will not construct cloning cost
15662predicate, which is used to estimate cloning benefit, for default case
15663of the switch statement.
15664
15665@item ipa-max-param-expr-ops
15666IPA-CP will analyze conditional statement that references some function
15667parameter to estimate benefit for cloning upon certain constant value.
15668But if number of operations in a parameter expression exceeds
15669@option{ipa-max-param-expr-ops}, the expression is treated as complicated
15670one, and is not handled by IPA analysis.
15671
15672@item lto-partitions
15673Specify desired number of partitions produced during WHOPR compilation.
15674The number of partitions should exceed the number of CPUs used for compilation.
15675
15676@item lto-min-partition
15677Size of minimal partition for WHOPR (in estimated instructions).
15678This prevents expenses of splitting very small programs into too many
15679partitions.
15680
15681@item lto-max-partition
15682Size of max partition for WHOPR (in estimated instructions).
15683to provide an upper bound for individual size of partition.
15684Meant to be used only with balanced partitioning.
15685
15686@item lto-max-streaming-parallelism
15687Maximal number of parallel processes used for LTO streaming.
15688
15689@item cxx-max-namespaces-for-diagnostic-help
15690The maximum number of namespaces to consult for suggestions when C++
15691name lookup fails for an identifier.
15692
15693@item sink-frequency-threshold
15694The maximum relative execution frequency (in percents) of the target block
15695relative to a statement's original block to allow statement sinking of a
15696statement. Larger numbers result in more aggressive statement sinking.
15697A small positive adjustment is applied for
15698statements with memory operands as those are even more profitable so sink.
15699
15700@item max-stores-to-sink
15701The maximum number of conditional store pairs that can be sunk. Set to 0
15702if either vectorization (@option{-ftree-vectorize}) or if-conversion
15703(@option{-ftree-loop-if-convert}) is disabled.
15704
15705@item case-values-threshold
15706The smallest number of different values for which it is best to use a
15707jump-table instead of a tree of conditional branches. If the value is
157080, use the default for the machine.
15709
15710@item jump-table-max-growth-ratio-for-size
15711The maximum code size growth ratio when expanding
15712into a jump table (in percent). The parameter is used when
15713optimizing for size.
15714
15715@item jump-table-max-growth-ratio-for-speed
15716The maximum code size growth ratio when expanding
15717into a jump table (in percent). The parameter is used when
15718optimizing for speed.
15719
15720@item tree-reassoc-width
15721Set the maximum number of instructions executed in parallel in
15722reassociated tree. This parameter overrides target dependent
15723heuristics used by default if has non zero value.
15724
15725@item sched-pressure-algorithm
15726Choose between the two available implementations of
15727@option{-fsched-pressure}. Algorithm 1 is the original implementation
15728and is the more likely to prevent instructions from being reordered.
15729Algorithm 2 was designed to be a compromise between the relatively
15730conservative approach taken by algorithm 1 and the rather aggressive
15731approach taken by the default scheduler. It relies more heavily on
15732having a regular register file and accurate register pressure classes.
15733See @file{haifa-sched.cc} in the GCC sources for more details.
15734
15735The default choice depends on the target.
15736
15737@item max-slsr-cand-scan
15738Set the maximum number of existing candidates that are considered when
15739seeking a basis for a new straight-line strength reduction candidate.
15740
15741@item asan-globals
15742Enable buffer overflow detection for global objects. This kind
15743of protection is enabled by default if you are using
15744@option{-fsanitize=address} option.
15745To disable global objects protection use @option{--param asan-globals=0}.
15746
15747@item asan-stack
15748Enable buffer overflow detection for stack objects. This kind of
15749protection is enabled by default when using @option{-fsanitize=address}.
15750To disable stack protection use @option{--param asan-stack=0} option.
15751
15752@item asan-instrument-reads
15753Enable buffer overflow detection for memory reads. This kind of
15754protection is enabled by default when using @option{-fsanitize=address}.
15755To disable memory reads protection use
15756@option{--param asan-instrument-reads=0}.
15757
15758@item asan-instrument-writes
15759Enable buffer overflow detection for memory writes. This kind of
15760protection is enabled by default when using @option{-fsanitize=address}.
15761To disable memory writes protection use
15762@option{--param asan-instrument-writes=0} option.
15763
15764@item asan-memintrin
15765Enable detection for built-in functions. This kind of protection
15766is enabled by default when using @option{-fsanitize=address}.
15767To disable built-in functions protection use
15768@option{--param asan-memintrin=0}.
15769
15770@item asan-use-after-return
15771Enable detection of use-after-return. This kind of protection
15772is enabled by default when using the @option{-fsanitize=address} option.
15773To disable it use @option{--param asan-use-after-return=0}.
15774
15775Note: By default the check is disabled at run time. To enable it,
15776add @code{detect_stack_use_after_return=1} to the environment variable
15777@env{ASAN_OPTIONS}.
15778
15779@item asan-instrumentation-with-call-threshold
15780If number of memory accesses in function being instrumented
15781is greater or equal to this number, use callbacks instead of inline checks.
15782E.g. to disable inline code use
15783@option{--param asan-instrumentation-with-call-threshold=0}.
15784
15785@item hwasan-instrument-stack
15786Enable hwasan instrumentation of statically sized stack-allocated variables.
15787This kind of instrumentation is enabled by default when using
15788@option{-fsanitize=hwaddress} and disabled by default when using
15789@option{-fsanitize=kernel-hwaddress}.
15790To disable stack instrumentation use
15791@option{--param hwasan-instrument-stack=0}, and to enable it use
15792@option{--param hwasan-instrument-stack=1}.
15793
15794@item hwasan-random-frame-tag
15795When using stack instrumentation, decide tags for stack variables using a
15796deterministic sequence beginning at a random tag for each frame. With this
15797parameter unset tags are chosen using the same sequence but beginning from 1.
15798This is enabled by default for @option{-fsanitize=hwaddress} and unavailable
15799for @option{-fsanitize=kernel-hwaddress}.
15800To disable it use @option{--param hwasan-random-frame-tag=0}.
15801
15802@item hwasan-instrument-allocas
15803Enable hwasan instrumentation of dynamically sized stack-allocated variables.
15804This kind of instrumentation is enabled by default when using
15805@option{-fsanitize=hwaddress} and disabled by default when using
15806@option{-fsanitize=kernel-hwaddress}.
15807To disable instrumentation of such variables use
15808@option{--param hwasan-instrument-allocas=0}, and to enable it use
15809@option{--param hwasan-instrument-allocas=1}.
15810
15811@item hwasan-instrument-reads
15812Enable hwasan checks on memory reads. Instrumentation of reads is enabled by
15813default for both @option{-fsanitize=hwaddress} and
15814@option{-fsanitize=kernel-hwaddress}.
15815To disable checking memory reads use
15816@option{--param hwasan-instrument-reads=0}.
15817
15818@item hwasan-instrument-writes
15819Enable hwasan checks on memory writes. Instrumentation of writes is enabled by
15820default for both @option{-fsanitize=hwaddress} and
15821@option{-fsanitize=kernel-hwaddress}.
15822To disable checking memory writes use
15823@option{--param hwasan-instrument-writes=0}.
15824
15825@item hwasan-instrument-mem-intrinsics
15826Enable hwasan instrumentation of builtin functions. Instrumentation of these
15827builtin functions is enabled by default for both @option{-fsanitize=hwaddress}
15828and @option{-fsanitize=kernel-hwaddress}.
15829To disable instrumentation of builtin functions use
15830@option{--param hwasan-instrument-mem-intrinsics=0}.
15831
15832@item use-after-scope-direct-emission-threshold
15833If the size of a local variable in bytes is smaller or equal to this
15834number, directly poison (or unpoison) shadow memory instead of using
15835run-time callbacks.
15836
15837@item tsan-distinguish-volatile
15838Emit special instrumentation for accesses to volatiles.
15839
15840@item tsan-instrument-func-entry-exit
15841Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit().
15842
15843@item max-fsm-thread-path-insns
15844Maximum number of instructions to copy when duplicating blocks on a
15845finite state automaton jump thread path.
15846
15847@item threader-debug
15848threader-debug=[none|all] Enables verbose dumping of the threader solver.
15849
15850@item parloops-chunk-size
15851Chunk size of omp schedule for loops parallelized by parloops.
15852
15853@item parloops-schedule
15854Schedule type of omp schedule for loops parallelized by parloops (static,
15855dynamic, guided, auto, runtime).
15856
15857@item parloops-min-per-thread
15858The minimum number of iterations per thread of an innermost parallelized
15859loop for which the parallelized variant is preferred over the single threaded
15860one. Note that for a parallelized loop nest the
15861minimum number of iterations of the outermost loop per thread is two.
15862
15863@item max-ssa-name-query-depth
15864Maximum depth of recursion when querying properties of SSA names in things
15865like fold routines. One level of recursion corresponds to following a
15866use-def chain.
15867
15868@item max-speculative-devirt-maydefs
15869The maximum number of may-defs we analyze when looking for a must-def
15870specifying the dynamic type of an object that invokes a virtual call
15871we may be able to devirtualize speculatively.
15872
d77de738
ML
15873@item evrp-sparse-threshold
15874Maximum number of basic blocks before EVRP uses a sparse cache.
15875
d77de738
ML
15876@item ranger-debug
15877Specifies the type of debug output to be issued for ranges.
15878
15879@item evrp-switch-limit
15880Specifies the maximum number of switch cases before EVRP ignores a switch.
15881
15882@item unroll-jam-min-percent
15883The minimum percentage of memory references that must be optimized
15884away for the unroll-and-jam transformation to be considered profitable.
15885
15886@item unroll-jam-max-unroll
15887The maximum number of times the outer loop should be unrolled by
15888the unroll-and-jam transformation.
15889
15890@item max-rtl-if-conversion-unpredictable-cost
15891Maximum permissible cost for the sequence that would be generated
15892by the RTL if-conversion pass for a branch that is considered unpredictable.
15893
15894@item max-variable-expansions-in-unroller
15895If @option{-fvariable-expansion-in-unroller} is used, the maximum number
15896of times that an individual variable will be expanded during loop unrolling.
15897
15898@item partial-inlining-entry-probability
15899Maximum probability of the entry BB of split region
15900(in percent relative to entry BB of the function)
15901to make partial inlining happen.
15902
15903@item max-tracked-strlens
15904Maximum number of strings for which strlen optimization pass will
15905track string lengths.
15906
15907@item gcse-after-reload-partial-fraction
15908The threshold ratio for performing partial redundancy
15909elimination after reload.
15910
15911@item gcse-after-reload-critical-fraction
15912The threshold ratio of critical edges execution count that
15913permit performing redundancy elimination after reload.
15914
15915@item max-loop-header-insns
15916The maximum number of insns in loop header duplicated
15917by the copy loop headers pass.
15918
15919@item vect-epilogues-nomask
15920Enable loop epilogue vectorization using smaller vector size.
15921
15922@item vect-partial-vector-usage
15923Controls when the loop vectorizer considers using partial vector loads
15924and stores as an alternative to falling back to scalar code. 0 stops
15925the vectorizer from ever using partial vector loads and stores. 1 allows
15926partial vector loads and stores if vectorization removes the need for the
15927code to iterate. 2 allows partial vector loads and stores in all loops.
15928The parameter only has an effect on targets that support partial
15929vector loads and stores.
15930
15931@item vect-inner-loop-cost-factor
15932The maximum factor which the loop vectorizer applies to the cost of statements
15933in an inner loop relative to the loop being vectorized. The factor applied
15934is the maximum of the estimated number of iterations of the inner loop and
15935this parameter. The default value of this parameter is 50.
15936
15937@item vect-induction-float
15938Enable loop vectorization of floating point inductions.
15939
15940@item avoid-fma-max-bits
15941Maximum number of bits for which we avoid creating FMAs.
15942
15943@item sms-loop-average-count-threshold
15944A threshold on the average loop count considered by the swing modulo scheduler.
15945
15946@item sms-dfa-history
15947The number of cycles the swing modulo scheduler considers when checking
15948conflicts using DFA.
15949
15950@item graphite-allow-codegen-errors
15951Whether codegen errors should be ICEs when @option{-fchecking}.
15952
15953@item sms-max-ii-factor
15954A factor for tuning the upper bound that swing modulo scheduler
15955uses for scheduling a loop.
15956
15957@item lra-max-considered-reload-pseudos
15958The max number of reload pseudos which are considered during
15959spilling a non-reload pseudo.
15960
15961@item max-pow-sqrt-depth
15962Maximum depth of sqrt chains to use when synthesizing exponentiation
15963by a real constant.
15964
15965@item max-dse-active-local-stores
15966Maximum number of active local stores in RTL dead store elimination.
15967
15968@item asan-instrument-allocas
15969Enable asan allocas/VLAs protection.
15970
15971@item max-iterations-computation-cost
15972Bound on the cost of an expression to compute the number of iterations.
15973
15974@item max-isl-operations
15975Maximum number of isl operations, 0 means unlimited.
15976
15977@item graphite-max-arrays-per-scop
15978Maximum number of arrays per scop.
15979
15980@item max-vartrack-reverse-op-size
15981Max. size of loc list for which reverse ops should be added.
15982
15983@item fsm-scale-path-stmts
15984Scale factor to apply to the number of statements in a threading path
7c9f20fc
RB
15985crossing a loop backedge when comparing to
15986@option{--param=max-jump-thread-duplication-stmts}.
d77de738
ML
15987
15988@item uninit-control-dep-attempts
15989Maximum number of nested calls to search for control dependencies
15990during uninitialized variable analysis.
15991
d77de738
ML
15992@item sched-autopref-queue-depth
15993Hardware autoprefetcher scheduler model control flag.
15994Number of lookahead cycles the model looks into; at '
15995' only enable instruction sorting heuristic.
15996
15997@item loop-versioning-max-inner-insns
15998The maximum number of instructions that an inner loop can have
15999before the loop versioning pass considers it too big to copy.
16000
16001@item loop-versioning-max-outer-insns
16002The maximum number of instructions that an outer loop can have
16003before the loop versioning pass considers it too big to copy,
16004discounting any instructions in inner loops that directly benefit
16005from versioning.
16006
16007@item ssa-name-def-chain-limit
16008The maximum number of SSA_NAME assignments to follow in determining
16009a property of a variable such as its value. This limits the number
16010of iterations or recursive calls GCC performs when optimizing certain
16011statements or when determining their validity prior to issuing
16012diagnostics.
16013
16014@item store-merging-max-size
16015Maximum size of a single store merging region in bytes.
16016
16017@item hash-table-verification-limit
16018The number of elements for which hash table verification is done
16019for each searched element.
16020
16021@item max-find-base-term-values
16022Maximum number of VALUEs handled during a single find_base_term call.
16023
16024@item analyzer-max-enodes-per-program-point
16025The maximum number of exploded nodes per program point within
16026the analyzer, before terminating analysis of that point.
16027
16028@item analyzer-max-constraints
16029The maximum number of constraints per state.
16030
16031@item analyzer-min-snodes-for-call-summary
16032The minimum number of supernodes within a function for the
16033analyzer to consider summarizing its effects at call sites.
16034
16035@item analyzer-max-enodes-for-full-dump
16036The maximum depth of exploded nodes that should appear in a dot dump
16037before switching to a less verbose format.
16038
16039@item analyzer-max-recursion-depth
16040The maximum number of times a callsite can appear in a call stack
16041within the analyzer, before terminating analysis of a call that would
16042recurse deeper.
16043
16044@item analyzer-max-svalue-depth
16045The maximum depth of a symbolic value, before approximating
16046the value as unknown.
16047
16048@item analyzer-max-infeasible-edges
16049The maximum number of infeasible edges to reject before declaring
16050a diagnostic as infeasible.
16051
16052@item gimple-fe-computed-hot-bb-threshold
16053The number of executions of a basic block which is considered hot.
16054The parameter is used only in GIMPLE FE.
16055
16056@item analyzer-bb-explosion-factor
16057The maximum number of 'after supernode' exploded nodes within the analyzer
16058per supernode, before terminating analysis.
16059
16060@item ranger-logical-depth
16061Maximum depth of logical expression evaluation ranger will look through
16062when evaluating outgoing edge ranges.
16063
16064@item relation-block-limit
16065Maximum number of relations the oracle will register in a basic block.
16066
16067@item min-pagesize
16068Minimum page size for warning purposes.
16069
16070@item openacc-kernels
16071Specify mode of OpenACC `kernels' constructs handling.
16072With @option{--param=openacc-kernels=decompose}, OpenACC `kernels'
16073constructs are decomposed into parts, a sequence of compute
16074constructs, each then handled individually.
16075This is work in progress.
16076With @option{--param=openacc-kernels=parloops}, OpenACC `kernels'
16077constructs are handled by the @samp{parloops} pass, en bloc.
16078This is the current default.
16079
16080@item openacc-privatization
16081Specify mode of OpenACC privatization diagnostics for
16082@option{-fopt-info-omp-note} and applicable
16083@option{-fdump-tree-*-details}.
16084With @option{--param=openacc-privatization=quiet}, don't diagnose.
16085This is the current default.
16086With @option{--param=openacc-privatization=noisy}, do diagnose.
16087
16088@end table
16089
16090The following choices of @var{name} are available on AArch64 targets:
16091
16092@table @gcctabopt
16093@item aarch64-sve-compare-costs
16094When vectorizing for SVE, consider using ``unpacked'' vectors for
16095smaller elements and use the cost model to pick the cheapest approach.
16096Also use the cost model to choose between SVE and Advanced SIMD vectorization.
16097
16098Using unpacked vectors includes storing smaller elements in larger
16099containers and accessing elements with extending loads and truncating
16100stores.
16101
16102@item aarch64-float-recp-precision
16103The number of Newton iterations for calculating the reciprocal for float type.
16104The precision of division is proportional to this param when division
16105approximation is enabled. The default value is 1.
16106
16107@item aarch64-double-recp-precision
16108The number of Newton iterations for calculating the reciprocal for double type.
16109The precision of division is propotional to this param when division
16110approximation is enabled. The default value is 2.
16111
16112@item aarch64-autovec-preference
16113Force an ISA selection strategy for auto-vectorization. Accepts values from
161140 to 4, inclusive.
16115@table @samp
16116@item 0
16117Use the default heuristics.
16118@item 1
16119Use only Advanced SIMD for auto-vectorization.
16120@item 2
16121Use only SVE for auto-vectorization.
16122@item 3
16123Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are
16124deemed equal.
16125@item 4
16126Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal.
16127@end table
16128The default value is 0.
16129
16130@item aarch64-loop-vect-issue-rate-niters
16131The tuning for some AArch64 CPUs tries to take both latencies and issue
16132rates into account when deciding whether a loop should be vectorized
16133using SVE, vectorized using Advanced SIMD, or not vectorized at all.
16134If this parameter is set to @var{n}, GCC will not use this heuristic
16135for loops that are known to execute in fewer than @var{n} Advanced
16136SIMD iterations.
16137
16138@item aarch64-vect-unroll-limit
16139The vectorizer will use available tuning information to determine whether it
16140would be beneficial to unroll the main vectorized loop and by how much. This
16141parameter set's the upper bound of how much the vectorizer will unroll the main
16142loop. The default value is four.
16143
16144@end table
16145
16146The following choices of @var{name} are available on i386 and x86_64 targets:
16147
16148@table @gcctabopt
16149@item x86-stlf-window-ninsns
16150Instructions number above which STFL stall penalty can be compensated.
16151
16152@end table
16153
16154@end table
16155
16156@node Instrumentation Options
16157@section Program Instrumentation Options
16158@cindex instrumentation options
16159@cindex program instrumentation options
16160@cindex run-time error checking options
16161@cindex profiling options
16162@cindex options, program instrumentation
16163@cindex options, run-time error checking
16164@cindex options, profiling
16165
16166GCC supports a number of command-line options that control adding
16167run-time instrumentation to the code it normally generates.
16168For example, one purpose of instrumentation is collect profiling
16169statistics for use in finding program hot spots, code coverage
16170analysis, or profile-guided optimizations.
16171Another class of program instrumentation is adding run-time checking
16172to detect programming errors like invalid pointer
16173dereferences or out-of-bounds array accesses, as well as deliberately
16174hostile attacks such as stack smashing or C++ vtable hijacking.
16175There is also a general hook which can be used to implement other
16176forms of tracing or function-level instrumentation for debug or
16177program analysis purposes.
16178
16179@table @gcctabopt
16180@cindex @command{prof}
16181@cindex @command{gprof}
16182@item -p
16183@itemx -pg
16184@opindex p
16185@opindex pg
16186Generate extra code to write profile information suitable for the
16187analysis program @command{prof} (for @option{-p}) or @command{gprof}
16188(for @option{-pg}). You must use this option when compiling
16189the source files you want data about, and you must also use it when
16190linking.
16191
16192You can use the function attribute @code{no_instrument_function} to
16193suppress profiling of individual functions when compiling with these options.
16194@xref{Common Function Attributes}.
16195
16196@item -fprofile-arcs
16197@opindex fprofile-arcs
16198Add code so that program flow @dfn{arcs} are instrumented. During
16199execution the program records how many times each branch and call is
16200executed and how many times it is taken or returns. On targets that support
16201constructors with priority support, profiling properly handles constructors,
16202destructors and C++ constructors (and destructors) of classes which are used
16203as a type of a global variable.
16204
16205When the compiled
16206program exits it saves this data to a file called
16207@file{@var{auxname}.gcda} for each source file. The data may be used for
16208profile-directed optimizations (@option{-fbranch-probabilities}), or for
16209test coverage analysis (@option{-ftest-coverage}). Each object file's
16210@var{auxname} is generated from the name of the output file, if
16211explicitly specified and it is not the final executable, otherwise it is
16212the basename of the source file. In both cases any suffix is removed
16213(e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or
16214@file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
16215
16216Note that if a command line directly links source files, the corresponding
16217@var{.gcda} files will be prefixed with the unsuffixed name of the output file.
16218E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and
16219@file{binary-b.gcda} files.
16220
16221@xref{Cross-profiling}.
16222
16223@cindex @command{gcov}
16224@item --coverage
16225@opindex coverage
16226
16227This option is used to compile and link code instrumented for coverage
16228analysis. The option is a synonym for @option{-fprofile-arcs}
16229@option{-ftest-coverage} (when compiling) and @option{-lgcov} (when
16230linking). See the documentation for those options for more details.
16231
16232@itemize
16233
16234@item
16235Compile the source files with @option{-fprofile-arcs} plus optimization
16236and code generation options. For test coverage analysis, use the
16237additional @option{-ftest-coverage} option. You do not need to profile
16238every source file in a program.
16239
16240@item
16241Compile the source files additionally with @option{-fprofile-abs-path}
16242to create absolute path names in the @file{.gcno} files. This allows
16243@command{gcov} to find the correct sources in projects where compilations
16244occur with different working directories.
16245
16246@item
16247Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
16248(the latter implies the former).
16249
16250@item
16251Run the program on a representative workload to generate the arc profile
16252information. This may be repeated any number of times. You can run
16253concurrent instances of your program, and provided that the file system
16254supports locking, the data files will be correctly updated. Unless
16255a strict ISO C dialect option is in effect, @code{fork} calls are
16256detected and correctly handled without double counting.
16257
16258Moreover, an object file can be recompiled multiple times
16259and the corresponding @file{.gcda} file merges as long as
16260the source file and the compiler options are unchanged.
16261
16262@item
16263For profile-directed optimizations, compile the source files again with
16264the same optimization and code generation options plus
16265@option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
16266Control Optimization}).
16267
16268@item
16269For test coverage analysis, use @command{gcov} to produce human readable
16270information from the @file{.gcno} and @file{.gcda} files. Refer to the
16271@command{gcov} documentation for further information.
16272
16273@end itemize
16274
16275With @option{-fprofile-arcs}, for each function of your program GCC
16276creates a program flow graph, then finds a spanning tree for the graph.
16277Only arcs that are not on the spanning tree have to be instrumented: the
16278compiler adds code to count the number of times that these arcs are
16279executed. When an arc is the only exit or only entrance to a block, the
16280instrumentation code can be added to the block; otherwise, a new basic
16281block must be created to hold the instrumentation code.
16282
16283@need 2000
16284@item -ftest-coverage
16285@opindex ftest-coverage
16286Produce a notes file that the @command{gcov} code-coverage utility
16287(@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
16288show program coverage. Each source file's note file is called
16289@file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
16290above for a description of @var{auxname} and instructions on how to
16291generate test coverage data. Coverage data matches the source files
16292more closely if you do not optimize.
16293
16294@item -fprofile-abs-path
16295@opindex fprofile-abs-path
16296Automatically convert relative source file names to absolute path names
16297in the @file{.gcno} files. This allows @command{gcov} to find the correct
16298sources in projects where compilations occur with different working
16299directories.
16300
16301@item -fprofile-dir=@var{path}
16302@opindex fprofile-dir
16303
16304Set the directory to search for the profile data files in to @var{path}.
16305This option affects only the profile data generated by
16306@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs}
16307and used by @option{-fprofile-use} and @option{-fbranch-probabilities}
16308and its related options. Both absolute and relative paths can be used.
16309By default, GCC uses the current directory as @var{path}, thus the
16310profile data file appears in the same directory as the object file.
16311In order to prevent the file name clashing, if the object file name is
16312not an absolute path, we mangle the absolute path of the
16313@file{@var{sourcename}.gcda} file and use it as the file name of a
16314@file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}.
16315See similar option @option{-fprofile-note}.
16316
16317When an executable is run in a massive parallel environment, it is recommended
16318to save profile to different folders. That can be done with variables
16319in @var{path} that are exported during run-time:
16320
16321@table @gcctabopt
16322
16323@item %p
16324process ID.
16325
16326@item %q@{VAR@}
16327value of environment variable @var{VAR}
16328
16329@end table
16330
16331@item -fprofile-generate
16332@itemx -fprofile-generate=@var{path}
16333@opindex fprofile-generate
16334
16335Enable options usually used for instrumenting application to produce
16336profile useful for later recompilation with profile feedback based
16337optimization. You must use @option{-fprofile-generate} both when
16338compiling and when linking your program.
16339
16340The following options are enabled:
16341@option{-fprofile-arcs}, @option{-fprofile-values},
16342@option{-finline-functions}, and @option{-fipa-bit-cp}.
16343
16344If @var{path} is specified, GCC looks at the @var{path} to find
16345the profile feedback data files. See @option{-fprofile-dir}.
16346
16347To optimize the program based on the collected profile information, use
16348@option{-fprofile-use}. @xref{Optimize Options}, for more information.
16349
16350@item -fprofile-info-section
16351@itemx -fprofile-info-section=@var{name}
16352@opindex fprofile-info-section
16353
16354Register the profile information in the specified section instead of using a
16355constructor/destructor. The section name is @var{name} if it is specified,
16356otherwise the section name defaults to @code{.gcov_info}. A pointer to the
16357profile information generated by @option{-fprofile-arcs} is placed in the
16358specified section for each translation unit. This option disables the profile
16359information registration through a constructor and it disables the profile
16360information processing through a destructor. This option is not intended to be
16361used in hosted environments such as GNU/Linux. It targets freestanding
16362environments (for example embedded systems) with limited resources which do not
16363support constructors/destructors or the C library file I/O.
16364
16365The linker could collect the input sections in a continuous memory block and
16366define start and end symbols. A GNU linker script example which defines a
16367linker output section follows:
16368
16369@smallexample
16370 .gcov_info :
16371 @{
16372 PROVIDE (__gcov_info_start = .);
16373 KEEP (*(.gcov_info))
16374 PROVIDE (__gcov_info_end = .);
16375 @}
16376@end smallexample
16377
16378The program could dump the profiling information registered in this linker set
16379for example like this:
16380
16381@smallexample
16382#include <gcov.h>
16383#include <stdio.h>
16384#include <stdlib.h>
16385
16386extern const struct gcov_info *const __gcov_info_start[];
16387extern const struct gcov_info *const __gcov_info_end[];
16388
16389static void
16390dump (const void *d, unsigned n, void *arg)
16391@{
16392 const unsigned char *c = d;
16393
16394 for (unsigned i = 0; i < n; ++i)
16395 printf ("%02x", c[i]);
16396@}
16397
16398static void
16399filename (const char *f, void *arg)
16400@{
16401 __gcov_filename_to_gcfn (f, dump, arg );
16402@}
16403
16404static void *
16405allocate (unsigned length, void *arg)
16406@{
16407 return malloc (length);
16408@}
16409
16410static void
16411dump_gcov_info (void)
16412@{
16413 const struct gcov_info *const *info = __gcov_info_start;
16414 const struct gcov_info *const *end = __gcov_info_end;
16415
16416 /* Obfuscate variable to prevent compiler optimizations. */
16417 __asm__ ("" : "+r" (info));
16418
16419 while (info != end)
16420 @{
16421 void *arg = NULL;
16422 __gcov_info_to_gcda (*info, filename, dump, allocate, arg);
16423 putchar ('\n');
16424 ++info;
16425 @}
16426@}
16427
16428int
16429main (void)
16430@{
16431 dump_gcov_info ();
16432 return 0;
16433@}
16434@end smallexample
16435
16436The @command{merge-stream} subcommand of @command{gcov-tool} may be used to
16437deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and
16438@code{__gcov_info_to_gcda} functions and merge the profile information into
16439@file{.gcda} files on the host filesystem.
16440
16441@item -fprofile-note=@var{path}
16442@opindex fprofile-note
16443
16444If @var{path} is specified, GCC saves @file{.gcno} file into @var{path}
16445location. If you combine the option with multiple source files,
16446the @file{.gcno} file will be overwritten.
16447
16448@item -fprofile-prefix-path=@var{path}
16449@opindex fprofile-prefix-path
16450
16451This option can be used in combination with
16452@option{profile-generate=}@var{profile_dir} and
16453@option{profile-use=}@var{profile_dir} to inform GCC where is the base
16454directory of built source tree. By default @var{profile_dir} will contain
16455files with mangled absolute paths of all object files in the built project.
16456This is not desirable when directory used to build the instrumented binary
16457differs from the directory used to build the binary optimized with profile
16458feedback because the profile data will not be found during the optimized build.
16459In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path}
16460pointing to the base directory of the build can be used to strip the irrelevant
16461part of the path and keep all file names relative to the main build directory.
16462
16463@item -fprofile-prefix-map=@var{old}=@var{new}
16464@opindex fprofile-prefix-map
16465When compiling files residing in directory @file{@var{old}}, record
16466profiling information (with @option{--coverage})
16467describing them as if the files resided in
16468directory @file{@var{new}} instead.
16469See also @option{-ffile-prefix-map}.
16470
16471@item -fprofile-update=@var{method}
16472@opindex fprofile-update
16473
16474Alter the update method for an application instrumented for profile
16475feedback based optimization. The @var{method} argument should be one of
16476@samp{single}, @samp{atomic} or @samp{prefer-atomic}.
16477The first one is useful for single-threaded applications,
16478while the second one prevents profile corruption by emitting thread-safe code.
16479
16480@strong{Warning:} When an application does not properly join all threads
16481(or creates an detached thread), a profile file can be still corrupted.
16482
16483Using @samp{prefer-atomic} would be transformed either to @samp{atomic},
16484when supported by a target, or to @samp{single} otherwise. The GCC driver
16485automatically selects @samp{prefer-atomic} when @option{-pthread}
16486is present in the command line.
16487
16488@item -fprofile-filter-files=@var{regex}
16489@opindex fprofile-filter-files
16490
16491Instrument only functions from files whose name matches
16492any of the regular expressions (separated by semi-colons).
16493
16494For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument
16495only @file{main.c} and all C files starting with 'module'.
16496
16497@item -fprofile-exclude-files=@var{regex}
16498@opindex fprofile-exclude-files
16499
16500Instrument only functions from files whose name does not match
16501any of the regular expressions (separated by semi-colons).
16502
16503For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation
16504of all files that are located in the @file{/usr/} folder.
16505
16506@item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]}
16507@opindex fprofile-reproducible
16508Control level of reproducibility of profile gathered by
16509@code{-fprofile-generate}. This makes it possible to rebuild program
16510with same outcome which is useful, for example, for distribution
16511packages.
16512
16513With @option{-fprofile-reproducible=serial} the profile gathered by
16514@option{-fprofile-generate} is reproducible provided the trained program
16515behaves the same at each invocation of the train run, it is not
16516multi-threaded and profile data streaming is always done in the same
16517order. Note that profile streaming happens at the end of program run but
16518also before @code{fork} function is invoked.
16519
16520Note that it is quite common that execution counts of some part of
16521programs depends, for example, on length of temporary file names or
16522memory space randomization (that may affect hash-table collision rate).
16523Such non-reproducible part of programs may be annotated by
16524@code{no_instrument_function} function attribute. @command{gcov-dump} with
16525@option{-l} can be used to dump gathered data and verify that they are
16526indeed reproducible.
16527
16528With @option{-fprofile-reproducible=parallel-runs} collected profile
16529stays reproducible regardless the order of streaming of the data into
16530gcda files. This setting makes it possible to run multiple instances of
16531instrumented program in parallel (such as with @code{make -j}). This
16532reduces quality of gathered data, in particular of indirect call
16533profiling.
16534
16535@item -fsanitize=address
16536@opindex fsanitize=address
16537Enable AddressSanitizer, a fast memory error detector.
16538Memory access instructions are instrumented to detect
16539out-of-bounds and use-after-free bugs.
16540The option enables @option{-fsanitize-address-use-after-scope}.
16541See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for
16542more details. The run-time behavior can be influenced using the
16543@env{ASAN_OPTIONS} environment variable. When set to @code{help=1},
16544the available options are shown at startup of the instrumented program. See
16545@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
16546for a list of supported options.
16547The option cannot be combined with @option{-fsanitize=thread} or
16548@option{-fsanitize=hwaddress}. Note that the only target
16549@option{-fsanitize=hwaddress} is currently supported on is AArch64.
16550
6a07798c
MP
16551To get more accurate stack traces, it is possible to use options such as
16552@option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent
16553most function inlining), @option{-fno-optimize-sibling-calls} (which prevents
16554optimizing sibling and tail recursive calls; this option is implicit for
16555@option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which
16556disables Identical Code Folding for functions). Since multiple runs of the
16557program may yield backtraces with different addresses due to ASLR (Address
16558Space Layout Randomization), it may be desirable to turn ASLR off. On Linux,
16559this can be achieved with @samp{setarch `uname -m` -R ./prog}.
16560
d77de738
ML
16561@item -fsanitize=kernel-address
16562@opindex fsanitize=kernel-address
16563Enable AddressSanitizer for Linux kernel.
16564See @uref{https://github.com/google/kasan} for more details.
16565
16566@item -fsanitize=hwaddress
16567@opindex fsanitize=hwaddress
16568Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to
16569ignore the top byte of a pointer to allow the detection of memory errors with
16570a low memory overhead.
16571Memory access instructions are instrumented to detect out-of-bounds and
16572use-after-free bugs.
16573The option enables @option{-fsanitize-address-use-after-scope}.
16574See
16575@uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html}
16576for more details. The run-time behavior can be influenced using the
16577@env{HWASAN_OPTIONS} environment variable. When set to @code{help=1},
16578the available options are shown at startup of the instrumented program.
16579The option cannot be combined with @option{-fsanitize=thread} or
16580@option{-fsanitize=address}, and is currently only available on AArch64.
16581
16582@item -fsanitize=kernel-hwaddress
16583@opindex fsanitize=kernel-hwaddress
16584Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel.
16585Similar to @option{-fsanitize=kernel-address} but using an alternate
16586instrumentation method, and similar to @option{-fsanitize=hwaddress} but with
16587instrumentation differences necessary for compiling the Linux kernel.
16588These differences are to avoid hwasan library initialization calls and to
16589account for the stack pointer having a different value in its top byte.
16590
16591@emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}.
16592Instrumenting the stack and alloca calls are not on by default but are still
16593possible by specifying the command-line options
16594@option{--param hwasan-instrument-stack=1} and
16595@option{--param hwasan-instrument-allocas=1} respectively. Using a random frame
16596tag is not implemented for kernel instrumentation.
16597
16598@item -fsanitize=pointer-compare
16599@opindex fsanitize=pointer-compare
16600Instrument comparison operation (<, <=, >, >=) with pointer operands.
16601The option must be combined with either @option{-fsanitize=kernel-address} or
16602@option{-fsanitize=address}
16603The option cannot be combined with @option{-fsanitize=thread}.
16604Note: By default the check is disabled at run time. To enable it,
16605add @code{detect_invalid_pointer_pairs=2} to the environment variable
16606@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16607invalid operation only when both pointers are non-null.
16608
16609@item -fsanitize=pointer-subtract
16610@opindex fsanitize=pointer-subtract
16611Instrument subtraction with pointer operands.
16612The option must be combined with either @option{-fsanitize=kernel-address} or
16613@option{-fsanitize=address}
16614The option cannot be combined with @option{-fsanitize=thread}.
16615Note: By default the check is disabled at run time. To enable it,
16616add @code{detect_invalid_pointer_pairs=2} to the environment variable
16617@env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects
16618invalid operation only when both pointers are non-null.
16619
16620@item -fsanitize=shadow-call-stack
16621@opindex fsanitize=shadow-call-stack
16622Enable ShadowCallStack, a security enhancement mechanism used to protect
16623programs against return address overwrites (e.g. stack buffer overflows.)
16624It works by saving a function's return address to a separately allocated
16625shadow call stack in the function prologue and restoring the return address
16626from the shadow call stack in the function epilogue. Instrumentation only
16627occurs in functions that need to save the return address to the stack.
16628
16629Currently it only supports the aarch64 platform. It is specifically
16630designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option.
16631For the user space programs, runtime support is not currently provided
16632in libc and libgcc. Users who want to use this feature in user space need
16633to provide their own support for the runtime. It should be noted that
16634this may cause the ABI rules to be broken.
16635
16636On aarch64, the instrumentation makes use of the platform register @code{x18}.
16637This generally means that any code that may run on the same thread as code
16638compiled with ShadowCallStack must be compiled with the flag
16639@option{-ffixed-x18}, otherwise functions compiled without
16640@option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow
16641stack pointer.
16642
16643Also, because there is no userspace runtime support, code compiled with
16644ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions}
16645to turn off exceptions.
16646
16647See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more
16648details.
16649
16650@item -fsanitize=thread
16651@opindex fsanitize=thread
16652Enable ThreadSanitizer, a fast data race detector.
16653Memory access instructions are instrumented to detect
16654data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more
16655details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS}
16656environment variable; see
16657@url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of
16658supported options.
16659The option cannot be combined with @option{-fsanitize=address},
16660@option{-fsanitize=leak}.
16661
16662Note that sanitized atomic builtins cannot throw exceptions when
16663operating on invalid memory addresses with non-call exceptions
16664(@option{-fnon-call-exceptions}).
16665
16666@item -fsanitize=leak
16667@opindex fsanitize=leak
16668Enable LeakSanitizer, a memory leak detector.
16669This option only matters for linking of executables and
16670the executable is linked against a library that overrides @code{malloc}
16671and other allocator functions. See
16672@uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more
16673details. The run-time behavior can be influenced using the
16674@env{LSAN_OPTIONS} environment variable.
16675The option cannot be combined with @option{-fsanitize=thread}.
16676
16677@item -fsanitize=undefined
16678@opindex fsanitize=undefined
16679Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector.
16680Various computations are instrumented to detect undefined behavior
16681at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the
16682@env{UBSAN_OPTIONS} environment variable. Current suboptions are:
16683
16684@table @gcctabopt
16685
16686@item -fsanitize=shift
16687@opindex fsanitize=shift
16688This option enables checking that the result of a shift operation is
16689not undefined. Note that what exactly is considered undefined differs
16690slightly between C and C++, as well as between ISO C90 and C99, etc.
16691This option has two suboptions, @option{-fsanitize=shift-base} and
16692@option{-fsanitize=shift-exponent}.
16693
16694@item -fsanitize=shift-exponent
16695@opindex fsanitize=shift-exponent
16696This option enables checking that the second argument of a shift operation
16697is not negative and is smaller than the precision of the promoted first
16698argument.
16699
16700@item -fsanitize=shift-base
16701@opindex fsanitize=shift-base
16702If the second argument of a shift operation is within range, check that the
16703result of a shift operation is not undefined. Note that what exactly is
16704considered undefined differs slightly between C and C++, as well as between
16705ISO C90 and C99, etc.
16706
16707@item -fsanitize=integer-divide-by-zero
16708@opindex fsanitize=integer-divide-by-zero
16709Detect integer division by zero.
16710
16711@item -fsanitize=unreachable
16712@opindex fsanitize=unreachable
16713With this option, the compiler turns the @code{__builtin_unreachable}
16714call into a diagnostics message call instead. When reaching the
16715@code{__builtin_unreachable} call, the behavior is undefined.
16716
16717@item -fsanitize=vla-bound
16718@opindex fsanitize=vla-bound
16719This option instructs the compiler to check that the size of a variable
16720length array is positive.
16721
16722@item -fsanitize=null
16723@opindex fsanitize=null
16724This option enables pointer checking. Particularly, the application
16725built with this option turned on will issue an error message when it
16726tries to dereference a NULL pointer, or if a reference (possibly an
16727rvalue reference) is bound to a NULL pointer, or if a method is invoked
16728on an object pointed by a NULL pointer.
16729
16730@item -fsanitize=return
16731@opindex fsanitize=return
16732This option enables return statement checking. Programs
16733built with this option turned on will issue an error message
16734when the end of a non-void function is reached without actually
16735returning a value. This option works in C++ only.
16736
16737@item -fsanitize=signed-integer-overflow
16738@opindex fsanitize=signed-integer-overflow
16739This option enables signed integer overflow checking. We check that
16740the result of @code{+}, @code{*}, and both unary and binary @code{-}
16741does not overflow in the signed arithmetics. This also detects
16742@code{INT_MIN / -1} signed division. Note, integer promotion
16743rules must be taken into account. That is, the following is not an
16744overflow:
16745@smallexample
16746signed char a = SCHAR_MAX;
16747a++;
16748@end smallexample
16749
16750@item -fsanitize=bounds
16751@opindex fsanitize=bounds
16752This option enables instrumentation of array bounds. Various out of bounds
16753accesses are detected. Flexible array members, flexible array member-like
16754arrays, and initializers of variables with static storage are not instrumented.
16755
16756@item -fsanitize=bounds-strict
16757@opindex fsanitize=bounds-strict
16758This option enables strict instrumentation of array bounds. Most out of bounds
16759accesses are detected, including flexible array members and flexible array
16760member-like arrays. Initializers of variables with static storage are not
16761instrumented.
16762
16763@item -fsanitize=alignment
16764@opindex fsanitize=alignment
16765
16766This option enables checking of alignment of pointers when they are
16767dereferenced, or when a reference is bound to insufficiently aligned target,
16768or when a method or constructor is invoked on insufficiently aligned object.
16769
16770@item -fsanitize=object-size
16771@opindex fsanitize=object-size
16772This option enables instrumentation of memory references using the
7283380a
SP
16773@code{__builtin_dynamic_object_size} function. Various out of bounds
16774pointer accesses are detected.
d77de738
ML
16775
16776@item -fsanitize=float-divide-by-zero
16777@opindex fsanitize=float-divide-by-zero
16778Detect floating-point division by zero. Unlike other similar options,
16779@option{-fsanitize=float-divide-by-zero} is not enabled by
16780@option{-fsanitize=undefined}, since floating-point division by zero can
16781be a legitimate way of obtaining infinities and NaNs.
16782
16783@item -fsanitize=float-cast-overflow
16784@opindex fsanitize=float-cast-overflow
16785This option enables floating-point type to integer conversion checking.
16786We check that the result of the conversion does not overflow.
16787Unlike other similar options, @option{-fsanitize=float-cast-overflow} is
16788not enabled by @option{-fsanitize=undefined}.
16789This option does not work well with @code{FE_INVALID} exceptions enabled.
16790
16791@item -fsanitize=nonnull-attribute
16792@opindex fsanitize=nonnull-attribute
16793
16794This option enables instrumentation of calls, checking whether null values
16795are not passed to arguments marked as requiring a non-null value by the
16796@code{nonnull} function attribute.
16797
16798@item -fsanitize=returns-nonnull-attribute
16799@opindex fsanitize=returns-nonnull-attribute
16800
16801This option enables instrumentation of return statements in functions
16802marked with @code{returns_nonnull} function attribute, to detect returning
16803of null values from such functions.
16804
16805@item -fsanitize=bool
16806@opindex fsanitize=bool
16807
16808This option enables instrumentation of loads from bool. If a value other
16809than 0/1 is loaded, a run-time error is issued.
16810
16811@item -fsanitize=enum
16812@opindex fsanitize=enum
16813
16814This option enables instrumentation of loads from an enum type. If
16815a value outside the range of values for the enum type is loaded,
16816a run-time error is issued.
16817
16818@item -fsanitize=vptr
16819@opindex fsanitize=vptr
16820
16821This option enables instrumentation of C++ member function calls, member
16822accesses and some conversions between pointers to base and derived classes,
16823to verify the referenced object has the correct dynamic type.
16824
16825@item -fsanitize=pointer-overflow
16826@opindex fsanitize=pointer-overflow
16827
16828This option enables instrumentation of pointer arithmetics. If the pointer
16829arithmetics overflows, a run-time error is issued.
16830
16831@item -fsanitize=builtin
16832@opindex fsanitize=builtin
16833
16834This option enables instrumentation of arguments to selected builtin
16835functions. If an invalid value is passed to such arguments, a run-time
16836error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz}
16837or @code{__builtin_clz} invokes undefined behavior and is diagnosed
16838by this option.
16839
16840@end table
16841
16842Note that sanitizers tend to increase the rate of false positive
16843warnings, most notably those around @option{-Wmaybe-uninitialized}.
16844We recommend against combining @option{-Werror} and [the use of]
16845sanitizers.
16846
16847While @option{-ftrapv} causes traps for signed overflows to be emitted,
16848@option{-fsanitize=undefined} gives a diagnostic message.
16849This currently works only for the C family of languages.
16850
16851@item -fno-sanitize=all
16852@opindex fno-sanitize=all
16853
16854This option disables all previously enabled sanitizers.
16855@option{-fsanitize=all} is not allowed, as some sanitizers cannot be used
16856together.
16857
16858@item -fasan-shadow-offset=@var{number}
16859@opindex fasan-shadow-offset
16860This option forces GCC to use custom shadow offset in AddressSanitizer checks.
16861It is useful for experimenting with different shadow memory layouts in
16862Kernel AddressSanitizer.
16863
16864@item -fsanitize-sections=@var{s1},@var{s2},...
16865@opindex fsanitize-sections
16866Sanitize global variables in selected user-defined sections. @var{si} may
16867contain wildcards.
16868
16869@item -fsanitize-recover@r{[}=@var{opts}@r{]}
16870@opindex fsanitize-recover
16871@opindex fno-sanitize-recover
16872@option{-fsanitize-recover=} controls error recovery mode for sanitizers
16873mentioned in comma-separated list of @var{opts}. Enabling this option
16874for a sanitizer component causes it to attempt to continue
16875running the program as if no error happened. This means multiple
16876runtime errors can be reported in a single program run, and the exit
16877code of the program may indicate success even when errors
16878have been reported. The @option{-fno-sanitize-recover=} option
16879can be used to alter
16880this behavior: only the first detected error is reported
16881and program then exits with a non-zero exit code.
16882
16883Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions
16884except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}),
16885@option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero},
16886@option{-fsanitize=bounds-strict},
16887@option{-fsanitize=kernel-address} and @option{-fsanitize=address}.
16888For these sanitizers error recovery is turned on by default,
16889except @option{-fsanitize=address}, for which this feature is experimental.
16890@option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also
16891accepted, the former enables recovery for all sanitizers that support it,
16892the latter disables recovery for all sanitizers that support it.
16893
16894Even if a recovery mode is turned on the compiler side, it needs to be also
16895enabled on the runtime library side, otherwise the failures are still fatal.
16896The runtime library defaults to @code{halt_on_error=0} for
16897ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for
16898AddressSanitizer is @code{halt_on_error=1}. This can be overridden through
16899setting the @code{halt_on_error} flag in the corresponding environment variable.
16900
16901Syntax without an explicit @var{opts} parameter is deprecated. It is
16902equivalent to specifying an @var{opts} list of:
16903
16904@smallexample
16905undefined,float-cast-overflow,float-divide-by-zero,bounds-strict
16906@end smallexample
16907
16908@item -fsanitize-address-use-after-scope
16909@opindex fsanitize-address-use-after-scope
16910Enable sanitization of local variables to detect use-after-scope bugs.
16911The option sets @option{-fstack-reuse} to @samp{none}.
16912
16913@item -fsanitize-trap@r{[}=@var{opts}@r{]}
16914@opindex fsanitize-trap
16915@opindex fno-sanitize-trap
16916The @option{-fsanitize-trap=} option instructs the compiler to
16917report for sanitizers mentioned in comma-separated list of @var{opts}
16918undefined behavior using @code{__builtin_trap} rather than a @code{libubsan}
16919library routine. If this option is enabled for certain sanitizer,
16920it takes precedence over the @option{-fsanitizer-recover=} for that
16921sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless
16922of whether recovery is enabled or disabled using @option{-fsanitize-recover=}.
16923
16924The advantage of this is that the @code{libubsan} library is not needed
16925and is not linked in, so this is usable even in freestanding environments.
16926
16927Currently this feature works with @option{-fsanitize=undefined} (and its suboptions
16928except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow},
16929@option{-fsanitize=float-divide-by-zero} and
16930@option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also
16931specified, which enables it for @code{undefined} suboptions,
16932@option{-fsanitize=float-cast-overflow},
16933@option{-fsanitize=float-divide-by-zero} and
16934@option{-fsanitize=bounds-strict}.
16935If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used
16936and @code{-fsanitize=vptr} is enabled on the command line, the
16937instrumentation is silently ignored as the instrumentation always needs
16938@code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed.
16939
16940@item -fsanitize-undefined-trap-on-error
16941@opindex fsanitize-undefined-trap-on-error
16942The @option{-fsanitize-undefined-trap-on-error} option is deprecated
16943equivalent of @option{-fsanitize-trap=all}.
16944
16945@item -fsanitize-coverage=trace-pc
16946@opindex fsanitize-coverage=trace-pc
16947Enable coverage-guided fuzzing code instrumentation.
16948Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block.
16949
16950@item -fsanitize-coverage=trace-cmp
16951@opindex fsanitize-coverage=trace-cmp
16952Enable dataflow guided fuzzing code instrumentation.
16953Inserts a call to @code{__sanitizer_cov_trace_cmp1},
16954@code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or
16955@code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands
16956variable or @code{__sanitizer_cov_trace_const_cmp1},
16957@code{__sanitizer_cov_trace_const_cmp2},
16958@code{__sanitizer_cov_trace_const_cmp4} or
16959@code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one
16960operand constant, @code{__sanitizer_cov_trace_cmpf} or
16961@code{__sanitizer_cov_trace_cmpd} for float or double comparisons and
16962@code{__sanitizer_cov_trace_switch} for switch statements.
16963
16964@item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]}
16965@opindex fcf-protection
16966Enable code instrumentation of control-flow transfers to increase
16967program security by checking that target addresses of control-flow
16968transfer instructions (such as indirect function call, function return,
16969indirect jump) are valid. This prevents diverting the flow of control
16970to an unexpected target. This is intended to protect against such
16971threats as Return-oriented Programming (ROP), and similarly
16972call/jmp-oriented programming (COP/JOP).
16973
16974The value @code{branch} tells the compiler to implement checking of
16975validity of control-flow transfer at the point of indirect branch
16976instructions, i.e.@: call/jmp instructions. The value @code{return}
16977implements checking of validity at the point of returning from a
16978function. The value @code{full} is an alias for specifying both
16979@code{branch} and @code{return}. The value @code{none} turns off
16980instrumentation.
16981
16982The value @code{check} is used for the final link with link-time
16983optimization (LTO). An error is issued if LTO object files are
16984compiled with different @option{-fcf-protection} values. The
16985value @code{check} is ignored at the compile time.
16986
16987The macro @code{__CET__} is defined when @option{-fcf-protection} is
16988used. The first bit of @code{__CET__} is set to 1 for the value
16989@code{branch} and the second bit of @code{__CET__} is set to 1 for
16990the @code{return}.
16991
16992You can also use the @code{nocf_check} attribute to identify
16993which functions and calls should be skipped from instrumentation
16994(@pxref{Function Attributes}).
16995
16996Currently the x86 GNU/Linux target provides an implementation based
16997on Intel Control-flow Enforcement Technology (CET) which works for
16998i686 processor or newer.
16999
17000@item -fharden-compares
17001@opindex fharden-compares
17002For every logical test that survives gimple optimizations and is
17003@emph{not} the condition in a conditional branch (for example,
17004conditions tested for conditional moves, or to store in boolean
17005variables), emit extra code to compute and verify the reversed
17006condition, and to call @code{__builtin_trap} if the results do not
17007match. Use with @samp{-fharden-conditional-branches} to cover all
17008conditionals.
17009
17010@item -fharden-conditional-branches
17011@opindex fharden-conditional-branches
17012For every non-vectorized conditional branch that survives gimple
17013optimizations, emit extra code to compute and verify the reversed
17014condition, and to call @code{__builtin_trap} if the result is
17015unexpected. Use with @samp{-fharden-compares} to cover all
17016conditionals.
17017
17018@item -fstack-protector
17019@opindex fstack-protector
17020Emit extra code to check for buffer overflows, such as stack smashing
17021attacks. This is done by adding a guard variable to functions with
17022vulnerable objects. This includes functions that call @code{alloca}, and
17023functions with buffers larger than or equal to 8 bytes. The guards are
17024initialized when a function is entered and then checked when the function
17025exits. If a guard check fails, an error message is printed and the program
17026exits. Only variables that are actually allocated on the stack are
17027considered, optimized away variables or variables allocated in registers
17028don't count.
17029
17030@item -fstack-protector-all
17031@opindex fstack-protector-all
17032Like @option{-fstack-protector} except that all functions are protected.
17033
17034@item -fstack-protector-strong
17035@opindex fstack-protector-strong
17036Like @option{-fstack-protector} but includes additional functions to
17037be protected --- those that have local array definitions, or have
17038references to local frame addresses. Only variables that are actually
17039allocated on the stack are considered, optimized away variables or variables
17040allocated in registers don't count.
17041
17042@item -fstack-protector-explicit
17043@opindex fstack-protector-explicit
17044Like @option{-fstack-protector} but only protects those functions which
17045have the @code{stack_protect} attribute.
17046
17047@item -fstack-check
17048@opindex fstack-check
17049Generate code to verify that you do not go beyond the boundary of the
17050stack. You should specify this flag if you are running in an
17051environment with multiple threads, but you only rarely need to specify it in
17052a single-threaded environment since stack overflow is automatically
17053detected on nearly all systems if there is only one stack.
17054
17055Note that this switch does not actually cause checking to be done; the
17056operating system or the language runtime must do that. The switch causes
17057generation of code to ensure that they see the stack being extended.
17058
17059You can additionally specify a string parameter: @samp{no} means no
17060checking, @samp{generic} means force the use of old-style checking,
17061@samp{specific} means use the best checking method and is equivalent
17062to bare @option{-fstack-check}.
17063
17064Old-style checking is a generic mechanism that requires no specific
17065target support in the compiler but comes with the following drawbacks:
17066
17067@enumerate
17068@item
17069Modified allocation strategy for large objects: they are always
17070allocated dynamically if their size exceeds a fixed threshold. Note this
17071may change the semantics of some code.
17072
17073@item
17074Fixed limit on the size of the static frame of functions: when it is
17075topped by a particular function, stack checking is not reliable and
17076a warning is issued by the compiler.
17077
17078@item
17079Inefficiency: because of both the modified allocation strategy and the
17080generic implementation, code performance is hampered.
17081@end enumerate
17082
17083Note that old-style stack checking is also the fallback method for
17084@samp{specific} if no target support has been added in the compiler.
17085
17086@samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion
17087and stack overflows. @samp{specific} is an excellent choice when compiling
17088Ada code. It is not generally sufficient to protect against stack-clash
17089attacks. To protect against those you want @samp{-fstack-clash-protection}.
17090
17091@item -fstack-clash-protection
17092@opindex fstack-clash-protection
17093Generate code to prevent stack clash style attacks. When this option is
17094enabled, the compiler will only allocate one page of stack space at a time
17095and each page is accessed immediately after allocation. Thus, it prevents
17096allocations from jumping over any stack guard page provided by the
17097operating system.
17098
17099Most targets do not fully support stack clash protection. However, on
17100those targets @option{-fstack-clash-protection} will protect dynamic stack
17101allocations. @option{-fstack-clash-protection} may also provide limited
17102protection for static stack allocations if the target supports
17103@option{-fstack-check=specific}.
17104
17105@item -fstack-limit-register=@var{reg}
17106@itemx -fstack-limit-symbol=@var{sym}
17107@itemx -fno-stack-limit
17108@opindex fstack-limit-register
17109@opindex fstack-limit-symbol
17110@opindex fno-stack-limit
17111Generate code to ensure that the stack does not grow beyond a certain value,
17112either the value of a register or the address of a symbol. If a larger
17113stack is required, a signal is raised at run time. For most targets,
17114the signal is raised before the stack overruns the boundary, so
17115it is possible to catch the signal without taking special precautions.
17116
17117For instance, if the stack starts at absolute address @samp{0x80000000}
17118and grows downwards, you can use the flags
17119@option{-fstack-limit-symbol=__stack_limit} and
17120@option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
17121of 128KB@. Note that this may only work with the GNU linker.
17122
17123You can locally override stack limit checking by using the
17124@code{no_stack_limit} function attribute (@pxref{Function Attributes}).
17125
17126@item -fsplit-stack
17127@opindex fsplit-stack
17128Generate code to automatically split the stack before it overflows.
17129The resulting program has a discontiguous stack which can only
17130overflow if the program is unable to allocate any more memory. This
17131is most useful when running threaded programs, as it is no longer
17132necessary to calculate a good stack size to use for each thread. This
17133is currently only implemented for the x86 targets running
17134GNU/Linux.
17135
17136When code compiled with @option{-fsplit-stack} calls code compiled
17137without @option{-fsplit-stack}, there may not be much stack space
17138available for the latter code to run. If compiling all code,
17139including library code, with @option{-fsplit-stack} is not an option,
17140then the linker can fix up these calls so that the code compiled
17141without @option{-fsplit-stack} always has a large stack. Support for
17142this is implemented in the gold linker in GNU binutils release 2.21
17143and later.
17144
17145@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
17146@opindex fvtable-verify
17147This option is only available when compiling C++ code.
17148It turns on (or off, if using @option{-fvtable-verify=none}) the security
17149feature that verifies at run time, for every virtual call, that
17150the vtable pointer through which the call is made is valid for the type of
17151the object, and has not been corrupted or overwritten. If an invalid vtable
17152pointer is detected at run time, an error is reported and execution of the
17153program is immediately halted.
17154
17155This option causes run-time data structures to be built at program startup,
17156which are used for verifying the vtable pointers.
17157The options @samp{std} and @samp{preinit}
17158control the timing of when these data structures are built. In both cases the
17159data structures are built before execution reaches @code{main}. Using
17160@option{-fvtable-verify=std} causes the data structures to be built after
17161shared libraries have been loaded and initialized.
17162@option{-fvtable-verify=preinit} causes them to be built before shared
17163libraries have been loaded and initialized.
17164
17165If this option appears multiple times in the command line with different
17166values specified, @samp{none} takes highest priority over both @samp{std} and
17167@samp{preinit}; @samp{preinit} takes priority over @samp{std}.
17168
17169@item -fvtv-debug
17170@opindex fvtv-debug
17171When used in conjunction with @option{-fvtable-verify=std} or
17172@option{-fvtable-verify=preinit}, causes debug versions of the
17173runtime functions for the vtable verification feature to be called.
17174This flag also causes the compiler to log information about which
17175vtable pointers it finds for each class.
17176This information is written to a file named @file{vtv_set_ptr_data.log}
17177in the directory named by the environment variable @env{VTV_LOGS_DIR}
17178if that is defined or the current working directory otherwise.
17179
17180Note: This feature @emph{appends} data to the log file. If you want a fresh log
17181file, be sure to delete any existing one.
17182
17183@item -fvtv-counts
17184@opindex fvtv-counts
17185This is a debugging flag. When used in conjunction with
17186@option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this
17187causes the compiler to keep track of the total number of virtual calls
17188it encounters and the number of verifications it inserts. It also
17189counts the number of calls to certain run-time library functions
17190that it inserts and logs this information for each compilation unit.
17191The compiler writes this information to a file named
17192@file{vtv_count_data.log} in the directory named by the environment
17193variable @env{VTV_LOGS_DIR} if that is defined or the current working
17194directory otherwise. It also counts the size of the vtable pointer sets
17195for each class, and writes this information to @file{vtv_class_set_sizes.log}
17196in the same directory.
17197
17198Note: This feature @emph{appends} data to the log files. To get fresh log
17199files, be sure to delete any existing ones.
17200
17201@item -finstrument-functions
17202@opindex finstrument-functions
17203Generate instrumentation calls for entry and exit to functions. Just
17204after function entry and just before function exit, the following
17205profiling functions are called with the address of the current
17206function and its call site. (On some platforms,
17207@code{__builtin_return_address} does not work beyond the current
17208function, so the call site information may not be available to the
17209profiling functions otherwise.)
17210
17211@smallexample
17212void __cyg_profile_func_enter (void *this_fn,
17213 void *call_site);
17214void __cyg_profile_func_exit (void *this_fn,
17215 void *call_site);
17216@end smallexample
17217
17218The first argument is the address of the start of the current function,
17219which may be looked up exactly in the symbol table.
17220
17221This instrumentation is also done for functions expanded inline in other
17222functions. The profiling calls indicate where, conceptually, the
17223inline function is entered and exited. This means that addressable
17224versions of such functions must be available. If all your uses of a
17225function are expanded inline, this may mean an additional expansion of
17226code size. If you use @code{extern inline} in your C code, an
17227addressable version of such functions must be provided. (This is
17228normally the case anyway, but if you get lucky and the optimizer always
17229expands the functions inline, you might have gotten away without
17230providing static copies.)
17231
17232A function may be given the attribute @code{no_instrument_function}, in
17233which case this instrumentation is not done. This can be used, for
17234example, for the profiling functions listed above, high-priority
17235interrupt routines, and any functions from which the profiling functions
17236cannot safely be called (perhaps signal handlers, if the profiling
17237routines generate output or allocate memory).
17238@xref{Common Function Attributes}.
17239
17240@item -finstrument-functions-once
9c19597c 17241@opindex finstrument-functions-once
d77de738
ML
17242This is similar to @option{-finstrument-functions}, but the profiling
17243functions are called only once per instrumented function, i.e. the first
17244profiling function is called after the first entry into the instrumented
17245function and the second profiling function is called before the exit
17246corresponding to this first entry.
17247
17248The definition of @code{once} for the purpose of this option is a little
17249vague because the implementation is not protected against data races.
17250As a result, the implementation only guarantees that the profiling
17251functions are called at @emph{least} once per process and at @emph{most}
17252once per thread, but the calls are always paired, that is to say, if a
17253thread calls the first function, then it will call the second function,
17254unless it never reaches the exit of the instrumented function.
17255
17256@item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{}
17257@opindex finstrument-functions-exclude-file-list
17258
17259Set the list of functions that are excluded from instrumentation (see
17260the description of @option{-finstrument-functions}). If the file that
17261contains a function definition matches with one of @var{file}, then
17262that function is not instrumented. The match is done on substrings:
17263if the @var{file} parameter is a substring of the file name, it is
17264considered to be a match.
17265
17266For example:
17267
17268@smallexample
17269-finstrument-functions-exclude-file-list=/bits/stl,include/sys
17270@end smallexample
17271
17272@noindent
17273excludes any inline function defined in files whose pathnames
17274contain @file{/bits/stl} or @file{include/sys}.
17275
17276If, for some reason, you want to include letter @samp{,} in one of
17277@var{sym}, write @samp{\,}. For example,
17278@option{-finstrument-functions-exclude-file-list='\,\,tmp'}
17279(note the single quote surrounding the option).
17280
17281@item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{}
17282@opindex finstrument-functions-exclude-function-list
17283
17284This is similar to @option{-finstrument-functions-exclude-file-list},
17285but this option sets the list of function names to be excluded from
17286instrumentation. The function name to be matched is its user-visible
17287name, such as @code{vector<int> blah(const vector<int> &)}, not the
17288internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The
17289match is done on substrings: if the @var{sym} parameter is a substring
17290of the function name, it is considered to be a match. For C99 and C++
17291extended identifiers, the function name must be given in UTF-8, not
17292using universal character names.
17293
17294@item -fpatchable-function-entry=@var{N}[,@var{M}]
17295@opindex fpatchable-function-entry
17296Generate @var{N} NOPs right at the beginning
17297of each function, with the function entry point before the @var{M}th NOP.
17298If @var{M} is omitted, it defaults to @code{0} so the
17299function entry points to the address just at the first NOP.
17300The NOP instructions reserve extra space which can be used to patch in
17301any desired instrumentation at run time, provided that the code segment
17302is writable. The amount of space is controllable indirectly via
17303the number of NOPs; the NOP instruction used corresponds to the instruction
17304emitted by the internal GCC back-end interface @code{gen_nop}. This behavior
17305is target-specific and may also depend on the architecture variant and/or
17306other compilation options.
17307
17308For run-time identification, the starting addresses of these areas,
17309which correspond to their respective function entries minus @var{M},
17310are additionally collected in the @code{__patchable_function_entries}
17311section of the resulting binary.
17312
17313Note that the value of @code{__attribute__ ((patchable_function_entry
17314(N,M)))} takes precedence over command-line option
17315@option{-fpatchable-function-entry=N,M}. This can be used to increase
17316the area size or to remove it completely on a single function.
17317If @code{N=0}, no pad location is recorded.
17318
17319The NOP instructions are inserted at---and maybe before, depending on
17320@var{M}---the function entry address, even before the prologue. On
17321PowerPC with the ELFv2 ABI, for a function with dual entry points,
17322the local entry point is this function entry address.
17323
17324The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the
17325ELFv2 ABI, for a function with dual entry points, the supported values
17326for @var{M} are 0, 2, 6 and 14.
17327@end table
17328
17329
17330@node Preprocessor Options
17331@section Options Controlling the Preprocessor
17332@cindex preprocessor options
17333@cindex options, preprocessor
17334
17335These options control the C preprocessor, which is run on each C source
17336file before actual compilation.
17337
17338If you use the @option{-E} option, nothing is done except preprocessing.
17339Some of these options make sense only together with @option{-E} because
17340they cause the preprocessor output to be unsuitable for actual
17341compilation.
17342
17343In addition to the options listed here, there are a number of options
17344to control search paths for include files documented in
17345@ref{Directory Options}.
17346Options to control preprocessor diagnostics are listed in
17347@ref{Warning Options}.
17348
17349@table @gcctabopt
17350@include cppopts.texi
17351
17352@item -Wp,@var{option}
17353@opindex Wp
17354You can use @option{-Wp,@var{option}} to bypass the compiler driver
17355and pass @var{option} directly through to the preprocessor. If
17356@var{option} contains commas, it is split into multiple options at the
17357commas. However, many options are modified, translated or interpreted
17358by the compiler driver before being passed to the preprocessor, and
17359@option{-Wp} forcibly bypasses this phase. The preprocessor's direct
17360interface is undocumented and subject to change, so whenever possible
17361you should avoid using @option{-Wp} and let the driver handle the
17362options instead.
17363
17364@item -Xpreprocessor @var{option}
17365@opindex Xpreprocessor
17366Pass @var{option} as an option to the preprocessor. You can use this to
17367supply system-specific preprocessor options that GCC does not
17368recognize.
17369
17370If you want to pass an option that takes an argument, you must use
17371@option{-Xpreprocessor} twice, once for the option and once for the argument.
17372
17373@item -no-integrated-cpp
17374@opindex no-integrated-cpp
17375Perform preprocessing as a separate pass before compilation.
17376By default, GCC performs preprocessing as an integrated part of
17377input tokenization and parsing.
17378If this option is provided, the appropriate language front end
17379(@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++,
17380and Objective-C, respectively) is instead invoked twice,
17381once for preprocessing only and once for actual compilation
17382of the preprocessed input.
17383This option may be useful in conjunction with the @option{-B} or
17384@option{-wrapper} options to specify an alternate preprocessor or
17385perform additional processing of the program source between
17386normal preprocessing and compilation.
17387
17388@item -flarge-source-files
17389@opindex flarge-source-files
17390Adjust GCC to expect large source files, at the expense of slower
17391compilation and higher memory usage.
17392
17393Specifically, GCC normally tracks both column numbers and line numbers
17394within source files and it normally prints both of these numbers in
17395diagnostics. However, once it has processed a certain number of source
17396lines, it stops tracking column numbers and only tracks line numbers.
17397This means that diagnostics for later lines do not include column numbers.
17398It also means that options like @option{-Wmisleading-indentation} cease to work
17399at that point, although the compiler prints a note if this happens.
17400Passing @option{-flarge-source-files} significantly increases the number
17401of source lines that GCC can process before it stops tracking columns.
17402
17403@end table
17404
17405@node Assembler Options
17406@section Passing Options to the Assembler
17407
17408@c prevent bad page break with this line
17409You can pass options to the assembler.
17410
17411@table @gcctabopt
17412@item -Wa,@var{option}
17413@opindex Wa
17414Pass @var{option} as an option to the assembler. If @var{option}
17415contains commas, it is split into multiple options at the commas.
17416
17417@item -Xassembler @var{option}
17418@opindex Xassembler
17419Pass @var{option} as an option to the assembler. You can use this to
17420supply system-specific assembler options that GCC does not
17421recognize.
17422
17423If you want to pass an option that takes an argument, you must use
17424@option{-Xassembler} twice, once for the option and once for the argument.
17425
17426@end table
17427
17428@node Link Options
17429@section Options for Linking
17430@cindex link options
17431@cindex options, linking
17432
17433These options come into play when the compiler links object files into
17434an executable output file. They are meaningless if the compiler is
17435not doing a link step.
17436
17437@table @gcctabopt
17438@cindex file names
17439@item @var{object-file-name}
17440A file name that does not end in a special recognized suffix is
17441considered to name an object file or library. (Object files are
17442distinguished from libraries by the linker according to the file
17443contents.) If linking is done, these object files are used as input
17444to the linker.
17445
17446@item -c
17447@itemx -S
17448@itemx -E
17449@opindex c
17450@opindex S
17451@opindex E
17452If any of these options is used, then the linker is not run, and
17453object file names should not be used as arguments. @xref{Overall
17454Options}.
17455
17456@item -flinker-output=@var{type}
17457@opindex flinker-output
17458This option controls code generation of the link-time optimizer. By
17459default the linker output is automatically determined by the linker
17460plugin. For debugging the compiler and if incremental linking with a
17461non-LTO object file is desired, it may be useful to control the type
17462manually.
17463
17464If @var{type} is @samp{exec}, code generation produces a static
17465binary. In this case @option{-fpic} and @option{-fpie} are both
17466disabled.
17467
17468If @var{type} is @samp{dyn}, code generation produces a shared
17469library. In this case @option{-fpic} or @option{-fPIC} is preserved,
17470but not enabled automatically. This allows to build shared libraries
17471without position-independent code on architectures where this is
17472possible, i.e.@: on x86.
17473
17474If @var{type} is @samp{pie}, code generation produces an @option{-fpie}
17475executable. This results in similar optimizations as @samp{exec}
17476except that @option{-fpie} is not disabled if specified at compilation
17477time.
17478
17479If @var{type} is @samp{rel}, the compiler assumes that incremental linking is
17480done. The sections containing intermediate code for link-time optimization are
17481merged, pre-optimized, and output to the resulting object file. In addition, if
17482@option{-ffat-lto-objects} is specified, binary code is produced for future
17483non-LTO linking. The object file produced by incremental linking is smaller
17484than a static library produced from the same object files. At link time the
17485result of incremental linking also loads faster than a static
17486library assuming that the majority of objects in the library are used.
17487
17488Finally @samp{nolto-rel} configures the compiler for incremental linking where
17489code generation is forced, a final binary is produced, and the intermediate
17490code for later link-time optimization is stripped. When multiple object files
17491are linked together the resulting code is better optimized than with
17492link-time optimizations disabled (for example, cross-module inlining
17493happens), but most of benefits of whole program optimizations are lost.
17494
17495During the incremental link (by @option{-r}) the linker plugin defaults to
17496@option{rel}. With current interfaces to GNU Binutils it is however not
17497possible to incrementally link LTO objects and non-LTO objects into a single
17498mixed object file. If any of object files in incremental link cannot
17499be used for link-time optimization, the linker plugin issues a warning and
17500uses @samp{nolto-rel}. To maintain whole program optimization, it is
17501recommended to link such objects into static library instead. Alternatively it
17502is possible to use H.J. Lu's binutils with support for mixed objects.
17503
17504@item -fuse-ld=bfd
17505@opindex fuse-ld=bfd
17506Use the @command{bfd} linker instead of the default linker.
17507
17508@item -fuse-ld=gold
17509@opindex fuse-ld=gold
17510Use the @command{gold} linker instead of the default linker.
17511
17512@item -fuse-ld=lld
17513@opindex fuse-ld=lld
17514Use the LLVM @command{lld} linker instead of the default linker.
17515
17516@item -fuse-ld=mold
17517@opindex fuse-ld=mold
17518Use the Modern Linker (@command{mold}) instead of the default linker.
17519
17520@cindex Libraries
17521@item -l@var{library}
17522@itemx -l @var{library}
17523@opindex l
17524Search the library named @var{library} when linking. (The second
17525alternative with the library as a separate argument is only for
17526POSIX compliance and is not recommended.)
17527
17528The @option{-l} option is passed directly to the linker by GCC. Refer
17529to your linker documentation for exact details. The general
17530description below applies to the GNU linker.
17531
17532The linker searches a standard list of directories for the library.
17533The directories searched include several standard system directories
17534plus any that you specify with @option{-L}.
17535
17536Static libraries are archives of object files, and have file names
17537like @file{lib@var{library}.a}. Some targets also support shared
17538libraries, which typically have names like @file{lib@var{library}.so}.
17539If both static and shared libraries are found, the linker gives
17540preference to linking with the shared library unless the
17541@option{-static} option is used.
17542
17543It makes a difference where in the command you write this option; the
17544linker searches and processes libraries and object files in the order they
17545are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
17546after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
17547to functions in @samp{z}, those functions may not be loaded.
17548
17549@item -lobjc
17550@opindex lobjc
17551You need this special case of the @option{-l} option in order to
17552link an Objective-C or Objective-C++ program.
17553
17554@item -nostartfiles
17555@opindex nostartfiles
17556Do not use the standard system startup files when linking.
17557The standard system libraries are used normally, unless @option{-nostdlib},
17558@option{-nolibc}, or @option{-nodefaultlibs} is used.
17559
17560@item -nodefaultlibs
17561@opindex nodefaultlibs
17562Do not use the standard system libraries when linking.
17563Only the libraries you specify are passed to the linker, and options
17564specifying linkage of the system libraries, such as @option{-static-libgcc}
17565or @option{-shared-libgcc}, are ignored.
17566The standard startup files are used normally, unless @option{-nostartfiles}
17567is used.
17568
17569The compiler may generate calls to @code{memcmp},
17570@code{memset}, @code{memcpy} and @code{memmove}.
17571These entries are usually resolved by entries in
17572libc. These entry points should be supplied through some other
17573mechanism when this option is specified.
17574
17575@item -nolibc
17576@opindex nolibc
17577Do not use the C library or system libraries tightly coupled with it when
17578linking. Still link with the startup files, @file{libgcc} or toolchain
17579provided language support libraries such as @file{libgnat}, @file{libgfortran}
17580or @file{libstdc++} unless options preventing their inclusion are used as
17581well. This typically removes @option{-lc} from the link command line, as well
17582as system libraries that normally go with it and become meaningless when
17583absence of a C library is assumed, for example @option{-lpthread} or
17584@option{-lm} in some configurations. This is intended for bare-board
17585targets when there is indeed no C library available.
17586
17587@item -nostdlib
17588@opindex nostdlib
17589Do not use the standard system startup files or libraries when linking.
17590No startup files and only the libraries you specify are passed to
17591the linker, and options specifying linkage of the system libraries, such as
17592@option{-static-libgcc} or @option{-shared-libgcc}, are ignored.
17593
17594The compiler may generate calls to @code{memcmp}, @code{memset},
17595@code{memcpy} and @code{memmove}.
17596These entries are usually resolved by entries in
17597libc. These entry points should be supplied through some other
17598mechanism when this option is specified.
17599
17600@cindex @option{-lgcc}, use with @option{-nostdlib}
17601@cindex @option{-nostdlib} and unresolved references
17602@cindex unresolved references and @option{-nostdlib}
17603@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
17604@cindex @option{-nodefaultlibs} and unresolved references
17605@cindex unresolved references and @option{-nodefaultlibs}
17606One of the standard libraries bypassed by @option{-nostdlib} and
17607@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
17608which GCC uses to overcome shortcomings of particular machines, or special
17609needs for some languages.
17610(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
17611Collection (GCC) Internals},
17612for more discussion of @file{libgcc.a}.)
17613In most cases, you need @file{libgcc.a} even when you want to avoid
17614other standard libraries. In other words, when you specify @option{-nostdlib}
17615or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
17616This ensures that you have no unresolved references to internal GCC
17617library subroutines.
17618(An example of such an internal subroutine is @code{__main}, used to ensure C++
17619constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
17620GNU Compiler Collection (GCC) Internals}.)
17621
17622@item -nostdlib++
17623@opindex nostdlib++
17624Do not implicitly link with standard C++ libraries.
17625
17626@item -e @var{entry}
17627@itemx --entry=@var{entry}
17628@opindex e
17629@opindex entry
17630
17631Specify that the program entry point is @var{entry}. The argument is
17632interpreted by the linker; the GNU linker accepts either a symbol name
17633or an address.
17634
17635@item -pie
17636@opindex pie
17637Produce a dynamically linked position independent executable on targets
17638that support it. For predictable results, you must also specify the same
17639set of options used for compilation (@option{-fpie}, @option{-fPIE},
17640or model suboptions) when you specify this linker option.
17641
17642@item -no-pie
17643@opindex no-pie
17644Don't produce a dynamically linked position independent executable.
17645
17646@item -static-pie
17647@opindex static-pie
17648Produce a static position independent executable on targets that support
17649it. A static position independent executable is similar to a static
17650executable, but can be loaded at any address without a dynamic linker.
17651For predictable results, you must also specify the same set of options
17652used for compilation (@option{-fpie}, @option{-fPIE}, or model
17653suboptions) when you specify this linker option.
17654
17655@item -pthread
17656@opindex pthread
17657Link with the POSIX threads library. This option is supported on
17658GNU/Linux targets, most other Unix derivatives, and also on
17659x86 Cygwin and MinGW targets. On some targets this option also sets
17660flags for the preprocessor, so it should be used consistently for both
17661compilation and linking.
17662
17663@item -r
17664@opindex r
17665Produce a relocatable object as output. This is also known as partial
17666linking.
17667
17668@item -rdynamic
17669@opindex rdynamic
17670Pass the flag @option{-export-dynamic} to the ELF linker, on targets
17671that support it. This instructs the linker to add all symbols, not
17672only used ones, to the dynamic symbol table. This option is needed
17673for some uses of @code{dlopen} or to allow obtaining backtraces
17674from within a program.
17675
17676@item -s
17677@opindex s
17678Remove all symbol table and relocation information from the executable.
17679
17680@item -static
17681@opindex static
17682On systems that support dynamic linking, this overrides @option{-pie}
17683and prevents linking with the shared libraries. On other systems, this
17684option has no effect.
17685
17686@item -shared
17687@opindex shared
17688Produce a shared object which can then be linked with other objects to
17689form an executable. Not all systems support this option. For predictable
17690results, you must also specify the same set of options used for compilation
17691(@option{-fpic}, @option{-fPIC}, or model suboptions) when
17692you specify this linker option.@footnote{On some systems, @samp{gcc -shared}
17693needs to build supplementary stub code for constructors to work. On
17694multi-libbed systems, @samp{gcc -shared} must select the correct support
17695libraries to link against. Failing to supply the correct flags may lead
17696to subtle defects. Supplying them in cases where they are not necessary
88b531d0 17697is innocuous. For x86, crtfastmath.o will not be added when
17698@option{-shared} is specified. }
d77de738
ML
17699
17700@item -shared-libgcc
17701@itemx -static-libgcc
17702@opindex shared-libgcc
17703@opindex static-libgcc
17704On systems that provide @file{libgcc} as a shared library, these options
17705force the use of either the shared or static version, respectively.
17706If no shared version of @file{libgcc} was built when the compiler was
17707configured, these options have no effect.
17708
17709There are several situations in which an application should use the
17710shared @file{libgcc} instead of the static version. The most common
17711of these is when the application wishes to throw and catch exceptions
17712across different shared libraries. In that case, each of the libraries
17713as well as the application itself should use the shared @file{libgcc}.
17714
17715Therefore, the G++ driver automatically adds @option{-shared-libgcc}
17716whenever you build a shared library or a main executable, because C++
17717programs typically use exceptions, so this is the right thing to do.
17718
17719If, instead, you use the GCC driver to create shared libraries, you may
17720find that they are not always linked with the shared @file{libgcc}.
17721If GCC finds, at its configuration time, that you have a non-GNU linker
17722or a GNU linker that does not support option @option{--eh-frame-hdr},
17723it links the shared version of @file{libgcc} into shared libraries
17724by default. Otherwise, it takes advantage of the linker and optimizes
17725away the linking with the shared version of @file{libgcc}, linking with
17726the static version of libgcc by default. This allows exceptions to
17727propagate through such shared libraries, without incurring relocation
17728costs at library load time.
17729
17730However, if a library or main executable is supposed to throw or catch
17731exceptions, you must link it using the G++ driver, or using the option
17732@option{-shared-libgcc}, such that it is linked with the shared
17733@file{libgcc}.
17734
17735@item -static-libasan
17736@opindex static-libasan
17737When the @option{-fsanitize=address} option is used to link a program,
17738the GCC driver automatically links against @option{libasan}. If
17739@file{libasan} is available as a shared library, and the @option{-static}
17740option is not used, then this links against the shared version of
17741@file{libasan}. The @option{-static-libasan} option directs the GCC
17742driver to link @file{libasan} statically, without necessarily linking
17743other libraries statically.
17744
17745@item -static-libtsan
17746@opindex static-libtsan
17747When the @option{-fsanitize=thread} option is used to link a program,
17748the GCC driver automatically links against @option{libtsan}. If
17749@file{libtsan} is available as a shared library, and the @option{-static}
17750option is not used, then this links against the shared version of
17751@file{libtsan}. The @option{-static-libtsan} option directs the GCC
17752driver to link @file{libtsan} statically, without necessarily linking
17753other libraries statically.
17754
17755@item -static-liblsan
17756@opindex static-liblsan
17757When the @option{-fsanitize=leak} option is used to link a program,
17758the GCC driver automatically links against @option{liblsan}. If
17759@file{liblsan} is available as a shared library, and the @option{-static}
17760option is not used, then this links against the shared version of
17761@file{liblsan}. The @option{-static-liblsan} option directs the GCC
17762driver to link @file{liblsan} statically, without necessarily linking
17763other libraries statically.
17764
17765@item -static-libubsan
17766@opindex static-libubsan
17767When the @option{-fsanitize=undefined} option is used to link a program,
17768the GCC driver automatically links against @option{libubsan}. If
17769@file{libubsan} is available as a shared library, and the @option{-static}
17770option is not used, then this links against the shared version of
17771@file{libubsan}. The @option{-static-libubsan} option directs the GCC
17772driver to link @file{libubsan} statically, without necessarily linking
17773other libraries statically.
17774
17775@item -static-libstdc++
17776@opindex static-libstdc++
17777When the @command{g++} program is used to link a C++ program, it
17778normally automatically links against @option{libstdc++}. If
17779@file{libstdc++} is available as a shared library, and the
17780@option{-static} option is not used, then this links against the
17781shared version of @file{libstdc++}. That is normally fine. However, it
17782is sometimes useful to freeze the version of @file{libstdc++} used by
17783the program without going all the way to a fully static link. The
17784@option{-static-libstdc++} option directs the @command{g++} driver to
17785link @file{libstdc++} statically, without necessarily linking other
17786libraries statically.
17787
17788@item -symbolic
17789@opindex symbolic
17790Bind references to global symbols when building a shared object. Warn
17791about any unresolved references (unless overridden by the link editor
17792option @option{-Xlinker -z -Xlinker defs}). Only a few systems support
17793this option.
17794
17795@item -T @var{script}
17796@opindex T
17797@cindex linker script
17798Use @var{script} as the linker script. This option is supported by most
17799systems using the GNU linker. On some targets, such as bare-board
17800targets without an operating system, the @option{-T} option may be required
17801when linking to avoid references to undefined symbols.
17802
17803@item -Xlinker @var{option}
17804@opindex Xlinker
17805Pass @var{option} as an option to the linker. You can use this to
17806supply system-specific linker options that GCC does not recognize.
17807
17808If you want to pass an option that takes a separate argument, you must use
17809@option{-Xlinker} twice, once for the option and once for the argument.
17810For example, to pass @option{-assert definitions}, you must write
17811@option{-Xlinker -assert -Xlinker definitions}. It does not work to write
17812@option{-Xlinker "-assert definitions"}, because this passes the entire
17813string as a single argument, which is not what the linker expects.
17814
17815When using the GNU linker, it is usually more convenient to pass
17816arguments to linker options using the @option{@var{option}=@var{value}}
17817syntax than as separate arguments. For example, you can specify
17818@option{-Xlinker -Map=output.map} rather than
17819@option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support
17820this syntax for command-line options.
17821
17822@item -Wl,@var{option}
17823@opindex Wl
17824Pass @var{option} as an option to the linker. If @var{option} contains
17825commas, it is split into multiple options at the commas. You can use this
17826syntax to pass an argument to the option.
17827For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the
17828linker. When using the GNU linker, you can also get the same effect with
17829@option{-Wl,-Map=output.map}.
17830
17831@item -u @var{symbol}
17832@opindex u
17833Pretend the symbol @var{symbol} is undefined, to force linking of
17834library modules to define it. You can use @option{-u} multiple times with
17835different symbols to force loading of additional library modules.
17836
17837@item -z @var{keyword}
17838@opindex z
17839@option{-z} is passed directly on to the linker along with the keyword
17840@var{keyword}. See the section in the documentation of your linker for
17841permitted values and their meanings.
17842@end table
17843
17844@node Directory Options
17845@section Options for Directory Search
17846@cindex directory options
17847@cindex options, directory search
17848@cindex search path
17849
17850These options specify directories to search for header files, for
17851libraries and for parts of the compiler:
17852
17853@table @gcctabopt
17854@include cppdiropts.texi
17855
17856@item -iplugindir=@var{dir}
17857@opindex iplugindir=
17858Set the directory to search for plugins that are passed
17859by @option{-fplugin=@var{name}} instead of
17860@option{-fplugin=@var{path}/@var{name}.so}. This option is not meant
17861to be used by the user, but only passed by the driver.
17862
17863@item -L@var{dir}
17864@opindex L
17865Add directory @var{dir} to the list of directories to be searched
17866for @option{-l}.
17867
17868@item -B@var{prefix}
17869@opindex B
17870This option specifies where to find the executables, libraries,
17871include files, and data files of the compiler itself.
17872
17873The compiler driver program runs one or more of the subprograms
17874@command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries
17875@var{prefix} as a prefix for each program it tries to run, both with and
17876without @samp{@var{machine}/@var{version}/} for the corresponding target
17877machine and compiler version.
17878
17879For each subprogram to be run, the compiler driver first tries the
17880@option{-B} prefix, if any. If that name is not found, or if @option{-B}
17881is not specified, the driver tries two standard prefixes,
17882@file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of
17883those results in a file name that is found, the unmodified program
17884name is searched for using the directories specified in your
17885@env{PATH} environment variable.
17886
17887The compiler checks to see if the path provided by @option{-B}
17888refers to a directory, and if necessary it adds a directory
17889separator character at the end of the path.
17890
17891@option{-B} prefixes that effectively specify directory names also apply
17892to libraries in the linker, because the compiler translates these
17893options into @option{-L} options for the linker. They also apply to
17894include files in the preprocessor, because the compiler translates these
17895options into @option{-isystem} options for the preprocessor. In this case,
17896the compiler appends @samp{include} to the prefix.
17897
17898The runtime support file @file{libgcc.a} can also be searched for using
17899the @option{-B} prefix, if needed. If it is not found there, the two
17900standard prefixes above are tried, and that is all. The file is left
17901out of the link if it is not found by those means.
17902
17903Another way to specify a prefix much like the @option{-B} prefix is to use
17904the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment
17905Variables}.
17906
17907As a special kludge, if the path provided by @option{-B} is
17908@file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to
179099, then it is replaced by @file{[dir/]include}. This is to help
17910with boot-strapping the compiler.
17911
17912@item -no-canonical-prefixes
17913@opindex no-canonical-prefixes
17914Do not expand any symbolic links, resolve references to @samp{/../}
17915or @samp{/./}, or make the path absolute when generating a relative
17916prefix.
17917
17918@item --sysroot=@var{dir}
17919@opindex sysroot
17920Use @var{dir} as the logical root directory for headers and libraries.
17921For example, if the compiler normally searches for headers in
17922@file{/usr/include} and libraries in @file{/usr/lib}, it instead
17923searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}.
17924
17925If you use both this option and the @option{-isysroot} option, then
17926the @option{--sysroot} option applies to libraries, but the
17927@option{-isysroot} option applies to header files.
17928
17929The GNU linker (beginning with version 2.16) has the necessary support
17930for this option. If your linker does not support this option, the
17931header file aspect of @option{--sysroot} still works, but the
17932library aspect does not.
17933
17934@item --no-sysroot-suffix
17935@opindex no-sysroot-suffix
17936For some targets, a suffix is added to the root directory specified
17937with @option{--sysroot}, depending on the other options used, so that
17938headers may for example be found in
17939@file{@var{dir}/@var{suffix}/usr/include} instead of
17940@file{@var{dir}/usr/include}. This option disables the addition of
17941such a suffix.
17942
17943@end table
17944
17945@node Code Gen Options
17946@section Options for Code Generation Conventions
17947@cindex code generation conventions
17948@cindex options, code generation
17949@cindex run-time options
17950
17951These machine-independent options control the interface conventions
17952used in code generation.
17953
17954Most of them have both positive and negative forms; the negative form
17955of @option{-ffoo} is @option{-fno-foo}. In the table below, only
17956one of the forms is listed---the one that is not the default. You
17957can figure out the other form by either removing @samp{no-} or adding
17958it.
17959
17960@table @gcctabopt
17961@item -fstack-reuse=@var{reuse-level}
17962@opindex fstack_reuse
17963This option controls stack space reuse for user declared local/auto variables
17964and compiler generated temporaries. @var{reuse_level} can be @samp{all},
17965@samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all
17966local variables and temporaries, @samp{named_vars} enables the reuse only for
17967user defined local variables with names, and @samp{none} disables stack reuse
17968completely. The default value is @samp{all}. The option is needed when the
17969program extends the lifetime of a scoped local variable or a compiler generated
17970temporary beyond the end point defined by the language. When a lifetime of
17971a variable ends, and if the variable lives in memory, the optimizing compiler
17972has the freedom to reuse its stack space with other temporaries or scoped
17973local variables whose live range does not overlap with it. Legacy code extending
17974local lifetime is likely to break with the stack reuse optimization.
17975
17976For example,
17977
17978@smallexample
17979 int *p;
17980 @{
17981 int local1;
17982
17983 p = &local1;
17984 local1 = 10;
17985 ....
17986 @}
17987 @{
17988 int local2;
17989 local2 = 20;
17990 ...
17991 @}
17992
17993 if (*p == 10) // out of scope use of local1
17994 @{
17995
17996 @}
17997@end smallexample
17998
17999Another example:
18000@smallexample
18001
18002 struct A
18003 @{
18004 A(int k) : i(k), j(k) @{ @}
18005 int i;
18006 int j;
18007 @};
18008
18009 A *ap;
18010
18011 void foo(const A& ar)
18012 @{
18013 ap = &ar;
18014 @}
18015
18016 void bar()
18017 @{
18018 foo(A(10)); // temp object's lifetime ends when foo returns
18019
18020 @{
18021 A a(20);
18022 ....
18023 @}
18024 ap->i+= 10; // ap references out of scope temp whose space
18025 // is reused with a. What is the value of ap->i?
18026 @}
18027
18028@end smallexample
18029
18030The lifetime of a compiler generated temporary is well defined by the C++
18031standard. When a lifetime of a temporary ends, and if the temporary lives
18032in memory, the optimizing compiler has the freedom to reuse its stack
18033space with other temporaries or scoped local variables whose live range
18034does not overlap with it. However some of the legacy code relies on
18035the behavior of older compilers in which temporaries' stack space is
18036not reused, the aggressive stack reuse can lead to runtime errors. This
18037option is used to control the temporary stack reuse optimization.
18038
18039@item -ftrapv
18040@opindex ftrapv
18041This option generates traps for signed overflow on addition, subtraction,
18042multiplication operations.
18043The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18044@option{-ftrapv} @option{-fwrapv} on the command-line results in
18045@option{-fwrapv} being effective. Note that only active options override, so
18046using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18047results in @option{-ftrapv} being effective.
18048
18049@item -fwrapv
18050@opindex fwrapv
18051This option instructs the compiler to assume that signed arithmetic
18052overflow of addition, subtraction and multiplication wraps around
18053using twos-complement representation. This flag enables some optimizations
18054and disables others.
18055The options @option{-ftrapv} and @option{-fwrapv} override each other, so using
18056@option{-ftrapv} @option{-fwrapv} on the command-line results in
18057@option{-fwrapv} being effective. Note that only active options override, so
18058using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line
18059results in @option{-ftrapv} being effective.
18060
18061@item -fwrapv-pointer
18062@opindex fwrapv-pointer
18063This option instructs the compiler to assume that pointer arithmetic
18064overflow on addition and subtraction wraps around using twos-complement
18065representation. This flag disables some optimizations which assume
18066pointer overflow is invalid.
18067
18068@item -fstrict-overflow
18069@opindex fstrict-overflow
18070This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when
18071negated implies @option{-fwrapv} @option{-fwrapv-pointer}.
18072
18073@item -fexceptions
18074@opindex fexceptions
18075Enable exception handling. Generates extra code needed to propagate
18076exceptions. For some targets, this implies GCC generates frame
18077unwind information for all functions, which can produce significant data
18078size overhead, although it does not affect execution. If you do not
18079specify this option, GCC enables it by default for languages like
18080C++ that normally require exception handling, and disables it for
18081languages like C that do not normally require it. However, you may need
18082to enable this option when compiling C code that needs to interoperate
18083properly with exception handlers written in C++. You may also wish to
18084disable this option if you are compiling older C++ programs that don't
18085use exception handling.
18086
18087@item -fnon-call-exceptions
18088@opindex fnon-call-exceptions
18089Generate code that allows trapping instructions to throw exceptions.
18090Note that this requires platform-specific runtime support that does
18091not exist everywhere. Moreover, it only allows @emph{trapping}
18092instructions to throw exceptions, i.e.@: memory references or floating-point
18093instructions. It does not allow exceptions to be thrown from
18094arbitrary signal handlers such as @code{SIGALRM}. This enables
18095@option{-fexceptions}.
18096
18097@item -fdelete-dead-exceptions
18098@opindex fdelete-dead-exceptions
18099Consider that instructions that may throw exceptions but don't otherwise
18100contribute to the execution of the program can be optimized away.
18101This does not affect calls to functions except those with the
18102@code{pure} or @code{const} attributes.
18103This option is enabled by default for the Ada and C++ compilers, as permitted by
18104the language specifications.
18105Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
18106
18107@item -funwind-tables
18108@opindex funwind-tables
18109Similar to @option{-fexceptions}, except that it just generates any needed
18110static data, but does not affect the generated code in any other way.
18111You normally do not need to enable this option; instead, a language processor
18112that needs this handling enables it on your behalf.
18113
18114@item -fasynchronous-unwind-tables
18115@opindex fasynchronous-unwind-tables
18116Generate unwind table in DWARF format, if supported by target machine. The
18117table is exact at each instruction boundary, so it can be used for stack
18118unwinding from asynchronous events (such as debugger or garbage collector).
18119
18120@item -fno-gnu-unique
18121@opindex fno-gnu-unique
18122@opindex fgnu-unique
18123On systems with recent GNU assembler and C library, the C++ compiler
18124uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions
18125of template static data members and static local variables in inline
18126functions are unique even in the presence of @code{RTLD_LOCAL}; this
18127is necessary to avoid problems with a library used by two different
18128@code{RTLD_LOCAL} plugins depending on a definition in one of them and
18129therefore disagreeing with the other one about the binding of the
18130symbol. But this causes @code{dlclose} to be ignored for affected
18131DSOs; if your program relies on reinitialization of a DSO via
18132@code{dlclose} and @code{dlopen}, you can use
18133@option{-fno-gnu-unique}.
18134
18135@item -fpcc-struct-return
18136@opindex fpcc-struct-return
18137Return ``short'' @code{struct} and @code{union} values in memory like
18138longer ones, rather than in registers. This convention is less
18139efficient, but it has the advantage of allowing intercallability between
18140GCC-compiled files and files compiled with other compilers, particularly
18141the Portable C Compiler (pcc).
18142
18143The precise convention for returning structures in memory depends
18144on the target configuration macros.
18145
18146Short structures and unions are those whose size and alignment match
18147that of some integer type.
18148
18149@strong{Warning:} code compiled with the @option{-fpcc-struct-return}
18150switch is not binary compatible with code compiled with the
18151@option{-freg-struct-return} switch.
18152Use it to conform to a non-default application binary interface.
18153
18154@item -freg-struct-return
18155@opindex freg-struct-return
18156Return @code{struct} and @code{union} values in registers when possible.
18157This is more efficient for small structures than
18158@option{-fpcc-struct-return}.
18159
18160If you specify neither @option{-fpcc-struct-return} nor
18161@option{-freg-struct-return}, GCC defaults to whichever convention is
18162standard for the target. If there is no standard convention, GCC
18163defaults to @option{-fpcc-struct-return}, except on targets where GCC is
18164the principal compiler. In those cases, we can choose the standard, and
18165we chose the more efficient register return alternative.
18166
18167@strong{Warning:} code compiled with the @option{-freg-struct-return}
18168switch is not binary compatible with code compiled with the
18169@option{-fpcc-struct-return} switch.
18170Use it to conform to a non-default application binary interface.
18171
18172@item -fshort-enums
18173@opindex fshort-enums
18174Allocate to an @code{enum} type only as many bytes as it needs for the
18175declared range of possible values. Specifically, the @code{enum} type
18176is equivalent to the smallest integer type that has enough room.
18177
18178@strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate
18179code that is not binary compatible with code generated without that switch.
18180Use it to conform to a non-default application binary interface.
18181
18182@item -fshort-wchar
18183@opindex fshort-wchar
18184Override the underlying type for @code{wchar_t} to be @code{short
18185unsigned int} instead of the default for the target. This option is
18186useful for building programs to run under WINE@.
18187
18188@strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate
18189code that is not binary compatible with code generated without that switch.
18190Use it to conform to a non-default application binary interface.
18191
18192@item -fcommon
18193@opindex fcommon
18194@opindex fno-common
18195@cindex tentative definitions
18196In C code, this option controls the placement of global variables
18197defined without an initializer, known as @dfn{tentative definitions}
18198in the C standard. Tentative definitions are distinct from declarations
18199of a variable with the @code{extern} keyword, which do not allocate storage.
18200
18201The default is @option{-fno-common}, which specifies that the compiler places
18202uninitialized global variables in the BSS section of the object file.
18203This inhibits the merging of tentative definitions by the linker so you get a
18204multiple-definition error if the same variable is accidentally defined in more
18205than one compilation unit.
18206
18207The @option{-fcommon} places uninitialized global variables in a common block.
18208This allows the linker to resolve all tentative definitions of the same variable
18209in different compilation units to the same object, or to a non-tentative
18210definition. This behavior is inconsistent with C++, and on many targets implies
18211a speed and code size penalty on global variable references. It is mainly
18212useful to enable legacy code to link without errors.
18213
18214@item -fno-ident
18215@opindex fno-ident
18216@opindex fident
18217Ignore the @code{#ident} directive.
18218
18219@item -finhibit-size-directive
18220@opindex finhibit-size-directive
18221Don't output a @code{.size} assembler directive, or anything else that
18222would cause trouble if the function is split in the middle, and the
18223two halves are placed at locations far apart in memory. This option is
18224used when compiling @file{crtstuff.c}; you should not need to use it
18225for anything else.
18226
18227@item -fverbose-asm
18228@opindex fverbose-asm
18229Put extra commentary information in the generated assembly code to
18230make it more readable. This option is generally only of use to those
18231who actually need to read the generated assembly code (perhaps while
18232debugging the compiler itself).
18233
18234@option{-fno-verbose-asm}, the default, causes the
18235extra information to be omitted and is useful when comparing two assembler
18236files.
18237
18238The added comments include:
18239
18240@itemize @bullet
18241
18242@item
18243information on the compiler version and command-line options,
18244
18245@item
18246the source code lines associated with the assembly instructions,
18247in the form FILENAME:LINENUMBER:CONTENT OF LINE,
18248
18249@item
18250hints on which high-level expressions correspond to
18251the various assembly instruction operands.
18252
18253@end itemize
18254
18255For example, given this C source file:
18256
18257@smallexample
18258int test (int n)
18259@{
18260 int i;
18261 int total = 0;
18262
18263 for (i = 0; i < n; i++)
18264 total += i * i;
18265
18266 return total;
18267@}
18268@end smallexample
18269
18270compiling to (x86_64) assembly via @option{-S} and emitting the result
18271direct to stdout via @option{-o} @option{-}
18272
18273@smallexample
18274gcc -S test.c -fverbose-asm -Os -o -
18275@end smallexample
18276
18277gives output similar to this:
18278
18279@smallexample
18280 .file "test.c"
18281# GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu)
18282 [...snip...]
18283# options passed:
18284 [...snip...]
18285
18286 .text
18287 .globl test
18288 .type test, @@function
18289test:
18290.LFB0:
18291 .cfi_startproc
18292# test.c:4: int total = 0;
18293 xorl %eax, %eax # <retval>
18294# test.c:6: for (i = 0; i < n; i++)
18295 xorl %edx, %edx # i
18296.L2:
18297# test.c:6: for (i = 0; i < n; i++)
18298 cmpl %edi, %edx # n, i
18299 jge .L5 #,
18300# test.c:7: total += i * i;
18301 movl %edx, %ecx # i, tmp92
18302 imull %edx, %ecx # i, tmp92
18303# test.c:6: for (i = 0; i < n; i++)
18304 incl %edx # i
18305# test.c:7: total += i * i;
18306 addl %ecx, %eax # tmp92, <retval>
18307 jmp .L2 #
18308.L5:
18309# test.c:10: @}
18310 ret
18311 .cfi_endproc
18312.LFE0:
18313 .size test, .-test
18314 .ident "GCC: (GNU) 7.0.0 20160809 (experimental)"
18315 .section .note.GNU-stack,"",@@progbits
18316@end smallexample
18317
18318The comments are intended for humans rather than machines and hence the
18319precise format of the comments is subject to change.
18320
18321@item -frecord-gcc-switches
18322@opindex frecord-gcc-switches
18323This switch causes the command line used to invoke the
18324compiler to be recorded into the object file that is being created.
18325This switch is only implemented on some targets and the exact format
18326of the recording is target and binary file format dependent, but it
18327usually takes the form of a section containing ASCII text. This
18328switch is related to the @option{-fverbose-asm} switch, but that
18329switch only records information in the assembler output file as
18330comments, so it never reaches the object file.
18331See also @option{-grecord-gcc-switches} for another
18332way of storing compiler options into the object file.
18333
18334@item -fpic
18335@opindex fpic
18336@cindex global offset table
18337@cindex PIC
18338Generate position-independent code (PIC) suitable for use in a shared
18339library, if supported for the target machine. Such code accesses all
18340constant addresses through a global offset table (GOT)@. The dynamic
18341loader resolves the GOT entries when the program starts (the dynamic
18342loader is not part of GCC; it is part of the operating system). If
18343the GOT size for the linked executable exceeds a machine-specific
18344maximum size, you get an error message from the linker indicating that
18345@option{-fpic} does not work; in that case, recompile with @option{-fPIC}
18346instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k
18347on the m68k and RS/6000. The x86 has no such limit.)
18348
18349Position-independent code requires special support, and therefore works
18350only on certain machines. For the x86, GCC supports PIC for System V
18351but not for the Sun 386i. Code generated for the IBM RS/6000 is always
18352position-independent.
18353
18354When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18355are defined to 1.
18356
18357@item -fPIC
18358@opindex fPIC
18359If supported for the target machine, emit position-independent code,
18360suitable for dynamic linking and avoiding any limit on the size of the
18361global offset table. This option makes a difference on AArch64, m68k,
18362PowerPC and SPARC@.
18363
18364Position-independent code requires special support, and therefore works
18365only on certain machines.
18366
18367When this flag is set, the macros @code{__pic__} and @code{__PIC__}
18368are defined to 2.
18369
18370@item -fpie
18371@itemx -fPIE
18372@opindex fpie
18373@opindex fPIE
18374These options are similar to @option{-fpic} and @option{-fPIC}, but the
18375generated position-independent code can be only linked into executables.
18376Usually these options are used to compile code that will be linked using
18377the @option{-pie} GCC option.
18378
18379@option{-fpie} and @option{-fPIE} both define the macros
18380@code{__pie__} and @code{__PIE__}. The macros have the value 1
18381for @option{-fpie} and 2 for @option{-fPIE}.
18382
18383@item -fno-plt
18384@opindex fno-plt
18385@opindex fplt
18386Do not use the PLT for external function calls in position-independent code.
18387Instead, load the callee address at call sites from the GOT and branch to it.
18388This leads to more efficient code by eliminating PLT stubs and exposing
18389GOT loads to optimizations. On architectures such as 32-bit x86 where
18390PLT stubs expect the GOT pointer in a specific register, this gives more
18391register allocation freedom to the compiler.
18392Lazy binding requires use of the PLT;
18393with @option{-fno-plt} all external symbols are resolved at load time.
18394
18395Alternatively, the function attribute @code{noplt} can be used to avoid calls
18396through the PLT for specific external functions.
18397
18398In position-dependent code, a few targets also convert calls to
18399functions that are marked to not use the PLT to use the GOT instead.
18400
18401@item -fno-jump-tables
18402@opindex fno-jump-tables
18403@opindex fjump-tables
18404Do not use jump tables for switch statements even where it would be
18405more efficient than other code generation strategies. This option is
18406of use in conjunction with @option{-fpic} or @option{-fPIC} for
18407building code that forms part of a dynamic linker and cannot
18408reference the address of a jump table. On some targets, jump tables
18409do not require a GOT and this option is not needed.
18410
18411@item -fno-bit-tests
18412@opindex fno-bit-tests
18413@opindex fbit-tests
18414Do not use bit tests for switch statements even where it would be
18415more efficient than other code generation strategies.
18416
18417@item -ffixed-@var{reg}
18418@opindex ffixed
18419Treat the register named @var{reg} as a fixed register; generated code
18420should never refer to it (except perhaps as a stack pointer, frame
18421pointer or in some other fixed role).
18422
18423@var{reg} must be the name of a register. The register names accepted
18424are machine-specific and are defined in the @code{REGISTER_NAMES}
18425macro in the machine description macro file.
18426
18427This flag does not have a negative form, because it specifies a
18428three-way choice.
18429
18430@item -fcall-used-@var{reg}
18431@opindex fcall-used
18432Treat the register named @var{reg} as an allocable register that is
18433clobbered by function calls. It may be allocated for temporaries or
18434variables that do not live across a call. Functions compiled this way
18435do not save and restore the register @var{reg}.
18436
18437It is an error to use this flag with the frame pointer or stack pointer.
18438Use of this flag for other registers that have fixed pervasive roles in
18439the machine's execution model produces disastrous results.
18440
18441This flag does not have a negative form, because it specifies a
18442three-way choice.
18443
18444@item -fcall-saved-@var{reg}
18445@opindex fcall-saved
18446Treat the register named @var{reg} as an allocable register saved by
18447functions. It may be allocated even for temporaries or variables that
18448live across a call. Functions compiled this way save and restore
18449the register @var{reg} if they use it.
18450
18451It is an error to use this flag with the frame pointer or stack pointer.
18452Use of this flag for other registers that have fixed pervasive roles in
18453the machine's execution model produces disastrous results.
18454
18455A different sort of disaster results from the use of this flag for
18456a register in which function values may be returned.
18457
18458This flag does not have a negative form, because it specifies a
18459three-way choice.
18460
18461@item -fpack-struct[=@var{n}]
18462@opindex fpack-struct
18463Without a value specified, pack all structure members together without
18464holes. When a value is specified (which must be a small power of two), pack
18465structure members according to this value, representing the maximum
18466alignment (that is, objects with default alignment requirements larger than
18467this are output potentially unaligned at the next fitting location.
18468
18469@strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate
18470code that is not binary compatible with code generated without that switch.
18471Additionally, it makes the code suboptimal.
18472Use it to conform to a non-default application binary interface.
18473
18474@item -fleading-underscore
18475@opindex fleading-underscore
18476This option and its counterpart, @option{-fno-leading-underscore}, forcibly
18477change the way C symbols are represented in the object file. One use
18478is to help link with legacy assembly code.
18479
18480@strong{Warning:} the @option{-fleading-underscore} switch causes GCC to
18481generate code that is not binary compatible with code generated without that
18482switch. Use it to conform to a non-default application binary interface.
18483Not all targets provide complete support for this switch.
18484
18485@item -ftls-model=@var{model}
18486@opindex ftls-model
18487Alter the thread-local storage model to be used (@pxref{Thread-Local}).
18488The @var{model} argument should be one of @samp{global-dynamic},
18489@samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}.
18490Note that the choice is subject to optimization: the compiler may use
18491a more efficient model for symbols not visible outside of the translation
18492unit, or if @option{-fpic} is not given on the command line.
18493
18494The default without @option{-fpic} is @samp{initial-exec}; with
18495@option{-fpic} the default is @samp{global-dynamic}.
18496
18497@item -ftrampolines
18498@opindex ftrampolines
18499For targets that normally need trampolines for nested functions, always
18500generate them instead of using descriptors. Otherwise, for targets that
18501do not need them, like for example HP-PA or IA-64, do nothing.
18502
18503A trampoline is a small piece of code that is created at run time on the
18504stack when the address of a nested function is taken, and is used to call
18505the nested function indirectly. Therefore, it requires the stack to be
18506made executable in order for the program to work properly.
18507
18508@option{-fno-trampolines} is enabled by default on a language by language
18509basis to let the compiler avoid generating them, if it computes that this
18510is safe, and replace them with descriptors. Descriptors are made up of data
18511only, but the generated code must be prepared to deal with them. As of this
18512writing, @option{-fno-trampolines} is enabled by default only for Ada.
18513
18514Moreover, code compiled with @option{-ftrampolines} and code compiled with
18515@option{-fno-trampolines} are not binary compatible if nested functions are
18516present. This option must therefore be used on a program-wide basis and be
18517manipulated with extreme care.
18518
18519For languages other than Ada, the @code{-ftrampolines} and
18520@code{-fno-trampolines} options currently have no effect, and
18521trampolines are always generated on platforms that need them
18522for nested functions.
18523
18524@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
18525@opindex fvisibility
18526Set the default ELF image symbol visibility to the specified option---all
18527symbols are marked with this unless overridden within the code.
18528Using this feature can very substantially improve linking and
18529load times of shared object libraries, produce more optimized
18530code, provide near-perfect API export and prevent symbol clashes.
18531It is @strong{strongly} recommended that you use this in any shared objects
18532you distribute.
18533
18534Despite the nomenclature, @samp{default} always means public; i.e.,
18535available to be linked against from outside the shared object.
18536@samp{protected} and @samp{internal} are pretty useless in real-world
18537usage so the only other commonly used option is @samp{hidden}.
18538The default if @option{-fvisibility} isn't specified is
18539@samp{default}, i.e., make every symbol public.
18540
18541A good explanation of the benefits offered by ensuring ELF
18542symbols have the correct visibility is given by ``How To Write
18543Shared Libraries'' by Ulrich Drepper (which can be found at
18544@w{@uref{https://www.akkadia.org/drepper/}})---however a superior
18545solution made possible by this option to marking things hidden when
18546the default is public is to make the default hidden and mark things
18547public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden}
18548and @code{__attribute__ ((visibility("default")))} instead of
18549@code{__declspec(dllexport)} you get almost identical semantics with
18550identical syntax. This is a great boon to those working with
18551cross-platform projects.
18552
18553For those adding visibility support to existing code, you may find
18554@code{#pragma GCC visibility} of use. This works by you enclosing
18555the declarations you wish to set visibility for with (for example)
18556@code{#pragma GCC visibility push(hidden)} and
18557@code{#pragma GCC visibility pop}.
18558Bear in mind that symbol visibility should be viewed @strong{as
18559part of the API interface contract} and thus all new code should
18560always specify visibility when it is not the default; i.e., declarations
18561only for use within the local DSO should @strong{always} be marked explicitly
18562as hidden as so to avoid PLT indirection overheads---making this
18563abundantly clear also aids readability and self-documentation of the code.
18564Note that due to ISO C++ specification requirements, @code{operator new} and
18565@code{operator delete} must always be of default visibility.
18566
18567Be aware that headers from outside your project, in particular system
18568headers and headers from any other library you use, may not be
18569expecting to be compiled with visibility other than the default. You
18570may need to explicitly say @code{#pragma GCC visibility push(default)}
18571before including any such headers.
18572
18573@code{extern} declarations are not affected by @option{-fvisibility}, so
18574a lot of code can be recompiled with @option{-fvisibility=hidden} with
18575no modifications. However, this means that calls to @code{extern}
18576functions with no explicit visibility use the PLT, so it is more
18577effective to use @code{__attribute ((visibility))} and/or
18578@code{#pragma GCC visibility} to tell the compiler which @code{extern}
18579declarations should be treated as hidden.
18580
18581Note that @option{-fvisibility} does affect C++ vague linkage
18582entities. This means that, for instance, an exception class that is
18583be thrown between DSOs must be explicitly marked with default
18584visibility so that the @samp{type_info} nodes are unified between
18585the DSOs.
18586
18587An overview of these techniques, their benefits and how to use them
18588is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}.
18589
18590@item -fstrict-volatile-bitfields
18591@opindex fstrict-volatile-bitfields
18592This option should be used if accesses to volatile bit-fields (or other
18593structure fields, although the compiler usually honors those types
18594anyway) should use a single access of the width of the
18595field's type, aligned to a natural alignment if possible. For
18596example, targets with memory-mapped peripheral registers might require
18597all such accesses to be 16 bits wide; with this flag you can
18598declare all peripheral bit-fields as @code{unsigned short} (assuming short
18599is 16 bits on these targets) to force GCC to use 16-bit accesses
18600instead of, perhaps, a more efficient 32-bit access.
18601
18602If this option is disabled, the compiler uses the most efficient
18603instruction. In the previous example, that might be a 32-bit load
18604instruction, even though that accesses bytes that do not contain
18605any portion of the bit-field, or memory-mapped registers unrelated to
18606the one being updated.
18607
18608In some cases, such as when the @code{packed} attribute is applied to a
18609structure field, it may not be possible to access the field with a single
18610read or write that is correctly aligned for the target machine. In this
18611case GCC falls back to generating multiple accesses rather than code that
18612will fault or truncate the result at run time.
18613
18614Note: Due to restrictions of the C/C++11 memory model, write accesses are
18615not allowed to touch non bit-field members. It is therefore recommended
18616to define all bits of the field's type as bit-field members.
18617
18618The default value of this option is determined by the application binary
18619interface for the target processor.
18620
18621@item -fsync-libcalls
18622@opindex fsync-libcalls
18623This option controls whether any out-of-line instance of the @code{__sync}
18624family of functions may be used to implement the C++11 @code{__atomic}
18625family of functions.
18626
18627The default value of this option is enabled, thus the only useful form
18628of the option is @option{-fno-sync-libcalls}. This option is used in
18629the implementation of the @file{libatomic} runtime library.
18630
18631@end table
18632
18633@node Developer Options
18634@section GCC Developer Options
18635@cindex developer options
18636@cindex debugging GCC
18637@cindex debug dump options
18638@cindex dump options
18639@cindex compilation statistics
18640
18641This section describes command-line options that are primarily of
18642interest to GCC developers, including options to support compiler
18643testing and investigation of compiler bugs and compile-time
18644performance problems. This includes options that produce debug dumps
18645at various points in the compilation; that print statistics such as
18646memory use and execution time; and that print information about GCC's
18647configuration, such as where it searches for libraries. You should
18648rarely need to use any of these options for ordinary compilation and
18649linking tasks.
18650
18651Many developer options that cause GCC to dump output to a file take an
18652optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
18653or @samp{-} to dump to standard output, and @samp{stderr} for standard
18654error.
18655
18656If @samp{=@var{filename}} is omitted, a default dump file name is
18657constructed by concatenating the base dump file name, a pass number,
18658phase letter, and pass name. The base dump file name is the name of
18659output file produced by the compiler if explicitly specified and not
18660an executable; otherwise it is the source file name.
18661The pass number is determined by the order passes are registered with
18662the compiler's pass manager.
18663This is generally the same as the order of execution, but passes
18664registered by plugins, target-specific passes, or passes that are
18665otherwise registered late are numbered higher than the pass named
18666@samp{final}, even if they are executed earlier. The phase letter is
18667one of @samp{i} (inter-procedural analysis), @samp{l}
18668(language-specific), @samp{r} (RTL), or @samp{t} (tree).
18669The files are created in the directory of the output file.
18670
18671@table @gcctabopt
18672
18673@item -fcallgraph-info
18674@itemx -fcallgraph-info=@var{MARKERS}
18675@opindex fcallgraph-info
18676Makes the compiler output callgraph information for the program, on a
18677per-object-file basis. The information is generated in the common VCG
18678format. It can be decorated with additional, per-node and/or per-edge
18679information, if a list of comma-separated markers is additionally
18680specified. When the @code{su} marker is specified, the callgraph is
18681decorated with stack usage information; it is equivalent to
18682@option{-fstack-usage}. When the @code{da} marker is specified, the
18683callgraph is decorated with information about dynamically allocated
18684objects.
18685
18686When compiling with @option{-flto}, no callgraph information is output
18687along with the object file. At LTO link time, @option{-fcallgraph-info}
18688may generate multiple callgraph information files next to intermediate
18689LTO output files.
18690
18691@item -d@var{letters}
18692@itemx -fdump-rtl-@var{pass}
18693@itemx -fdump-rtl-@var{pass}=@var{filename}
18694@opindex d
18695@opindex fdump-rtl-@var{pass}
18696Says to make debugging dumps during compilation at times specified by
18697@var{letters}. This is used for debugging the RTL-based passes of the
18698compiler.
18699
18700Some @option{-d@var{letters}} switches have different meaning when
18701@option{-E} is used for preprocessing. @xref{Preprocessor Options},
18702for information about preprocessor-specific dump options.
18703
18704Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
18705@option{-d} option @var{letters}. Here are the possible
18706letters for use in @var{pass} and @var{letters}, and their meanings:
18707
18708@table @gcctabopt
18709
18710@item -fdump-rtl-alignments
18711@opindex fdump-rtl-alignments
18712Dump after branch alignments have been computed.
18713
18714@item -fdump-rtl-asmcons
18715@opindex fdump-rtl-asmcons
18716Dump after fixing rtl statements that have unsatisfied in/out constraints.
18717
18718@item -fdump-rtl-auto_inc_dec
18719@opindex fdump-rtl-auto_inc_dec
18720Dump after auto-inc-dec discovery. This pass is only run on
18721architectures that have auto inc or auto dec instructions.
18722
18723@item -fdump-rtl-barriers
18724@opindex fdump-rtl-barriers
18725Dump after cleaning up the barrier instructions.
18726
18727@item -fdump-rtl-bbpart
18728@opindex fdump-rtl-bbpart
18729Dump after partitioning hot and cold basic blocks.
18730
18731@item -fdump-rtl-bbro
18732@opindex fdump-rtl-bbro
18733Dump after block reordering.
18734
18735@item -fdump-rtl-btl1
18736@itemx -fdump-rtl-btl2
18737@opindex fdump-rtl-btl2
18738@opindex fdump-rtl-btl2
18739@option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping
18740after the two branch
18741target load optimization passes.
18742
18743@item -fdump-rtl-bypass
18744@opindex fdump-rtl-bypass
18745Dump after jump bypassing and control flow optimizations.
18746
18747@item -fdump-rtl-combine
18748@opindex fdump-rtl-combine
18749Dump after the RTL instruction combination pass.
18750
18751@item -fdump-rtl-compgotos
18752@opindex fdump-rtl-compgotos
18753Dump after duplicating the computed gotos.
18754
18755@item -fdump-rtl-ce1
18756@itemx -fdump-rtl-ce2
18757@itemx -fdump-rtl-ce3
18758@opindex fdump-rtl-ce1
18759@opindex fdump-rtl-ce2
18760@opindex fdump-rtl-ce3
18761@option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and
18762@option{-fdump-rtl-ce3} enable dumping after the three
18763if conversion passes.
18764
18765@item -fdump-rtl-cprop_hardreg
18766@opindex fdump-rtl-cprop_hardreg
18767Dump after hard register copy propagation.
18768
18769@item -fdump-rtl-csa
18770@opindex fdump-rtl-csa
18771Dump after combining stack adjustments.
18772
18773@item -fdump-rtl-cse1
18774@itemx -fdump-rtl-cse2
18775@opindex fdump-rtl-cse1
18776@opindex fdump-rtl-cse2
18777@option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after
18778the two common subexpression elimination passes.
18779
18780@item -fdump-rtl-dce
18781@opindex fdump-rtl-dce
18782Dump after the standalone dead code elimination passes.
18783
18784@item -fdump-rtl-dbr
18785@opindex fdump-rtl-dbr
18786Dump after delayed branch scheduling.
18787
18788@item -fdump-rtl-dce1
18789@itemx -fdump-rtl-dce2
18790@opindex fdump-rtl-dce1
18791@opindex fdump-rtl-dce2
18792@option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after
18793the two dead store elimination passes.
18794
18795@item -fdump-rtl-eh
18796@opindex fdump-rtl-eh
18797Dump after finalization of EH handling code.
18798
18799@item -fdump-rtl-eh_ranges
18800@opindex fdump-rtl-eh_ranges
18801Dump after conversion of EH handling range regions.
18802
18803@item -fdump-rtl-expand
18804@opindex fdump-rtl-expand
18805Dump after RTL generation.
18806
18807@item -fdump-rtl-fwprop1
18808@itemx -fdump-rtl-fwprop2
18809@opindex fdump-rtl-fwprop1
18810@opindex fdump-rtl-fwprop2
18811@option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable
18812dumping after the two forward propagation passes.
18813
18814@item -fdump-rtl-gcse1
18815@itemx -fdump-rtl-gcse2
18816@opindex fdump-rtl-gcse1
18817@opindex fdump-rtl-gcse2
18818@option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping
18819after global common subexpression elimination.
18820
18821@item -fdump-rtl-init-regs
18822@opindex fdump-rtl-init-regs
18823Dump after the initialization of the registers.
18824
18825@item -fdump-rtl-initvals
18826@opindex fdump-rtl-initvals
18827Dump after the computation of the initial value sets.
18828
18829@item -fdump-rtl-into_cfglayout
18830@opindex fdump-rtl-into_cfglayout
18831Dump after converting to cfglayout mode.
18832
18833@item -fdump-rtl-ira
18834@opindex fdump-rtl-ira
18835Dump after iterated register allocation.
18836
18837@item -fdump-rtl-jump
18838@opindex fdump-rtl-jump
18839Dump after the second jump optimization.
18840
18841@item -fdump-rtl-loop2
18842@opindex fdump-rtl-loop2
18843@option{-fdump-rtl-loop2} enables dumping after the rtl
18844loop optimization passes.
18845
18846@item -fdump-rtl-mach
18847@opindex fdump-rtl-mach
18848Dump after performing the machine dependent reorganization pass, if that
18849pass exists.
18850
18851@item -fdump-rtl-mode_sw
18852@opindex fdump-rtl-mode_sw
18853Dump after removing redundant mode switches.
18854
18855@item -fdump-rtl-rnreg
18856@opindex fdump-rtl-rnreg
18857Dump after register renumbering.
18858
18859@item -fdump-rtl-outof_cfglayout
18860@opindex fdump-rtl-outof_cfglayout
18861Dump after converting from cfglayout mode.
18862
18863@item -fdump-rtl-peephole2
18864@opindex fdump-rtl-peephole2
18865Dump after the peephole pass.
18866
18867@item -fdump-rtl-postreload
18868@opindex fdump-rtl-postreload
18869Dump after post-reload optimizations.
18870
18871@item -fdump-rtl-pro_and_epilogue
18872@opindex fdump-rtl-pro_and_epilogue
18873Dump after generating the function prologues and epilogues.
18874
18875@item -fdump-rtl-sched1
18876@itemx -fdump-rtl-sched2
18877@opindex fdump-rtl-sched1
18878@opindex fdump-rtl-sched2
18879@option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping
18880after the basic block scheduling passes.
18881
18882@item -fdump-rtl-ree
18883@opindex fdump-rtl-ree
18884Dump after sign/zero extension elimination.
18885
18886@item -fdump-rtl-seqabstr
18887@opindex fdump-rtl-seqabstr
18888Dump after common sequence discovery.
18889
18890@item -fdump-rtl-shorten
18891@opindex fdump-rtl-shorten
18892Dump after shortening branches.
18893
18894@item -fdump-rtl-sibling
18895@opindex fdump-rtl-sibling
18896Dump after sibling call optimizations.
18897
18898@item -fdump-rtl-split1
18899@itemx -fdump-rtl-split2
18900@itemx -fdump-rtl-split3
18901@itemx -fdump-rtl-split4
18902@itemx -fdump-rtl-split5
18903@opindex fdump-rtl-split1
18904@opindex fdump-rtl-split2
18905@opindex fdump-rtl-split3
18906@opindex fdump-rtl-split4
18907@opindex fdump-rtl-split5
18908These options enable dumping after five rounds of
18909instruction splitting.
18910
18911@item -fdump-rtl-sms
18912@opindex fdump-rtl-sms
18913Dump after modulo scheduling. This pass is only run on some
18914architectures.
18915
18916@item -fdump-rtl-stack
18917@opindex fdump-rtl-stack
18918Dump after conversion from GCC's ``flat register file'' registers to the
18919x87's stack-like registers. This pass is only run on x86 variants.
18920
18921@item -fdump-rtl-subreg1
18922@itemx -fdump-rtl-subreg2
18923@opindex fdump-rtl-subreg1
18924@opindex fdump-rtl-subreg2
18925@option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after
18926the two subreg expansion passes.
18927
18928@item -fdump-rtl-unshare
18929@opindex fdump-rtl-unshare
18930Dump after all rtl has been unshared.
18931
18932@item -fdump-rtl-vartrack
18933@opindex fdump-rtl-vartrack
18934Dump after variable tracking.
18935
18936@item -fdump-rtl-vregs
18937@opindex fdump-rtl-vregs
18938Dump after converting virtual registers to hard registers.
18939
18940@item -fdump-rtl-web
18941@opindex fdump-rtl-web
18942Dump after live range splitting.
18943
18944@item -fdump-rtl-regclass
18945@itemx -fdump-rtl-subregs_of_mode_init
18946@itemx -fdump-rtl-subregs_of_mode_finish
18947@itemx -fdump-rtl-dfinit
18948@itemx -fdump-rtl-dfinish
18949@opindex fdump-rtl-regclass
18950@opindex fdump-rtl-subregs_of_mode_init
18951@opindex fdump-rtl-subregs_of_mode_finish
18952@opindex fdump-rtl-dfinit
18953@opindex fdump-rtl-dfinish
18954These dumps are defined but always produce empty files.
18955
18956@item -da
18957@itemx -fdump-rtl-all
18958@opindex da
18959@opindex fdump-rtl-all
18960Produce all the dumps listed above.
18961
18962@item -dA
18963@opindex dA
18964Annotate the assembler output with miscellaneous debugging information.
18965
18966@item -dD
18967@opindex dD
18968Dump all macro definitions, at the end of preprocessing, in addition to
18969normal output.
18970
18971@item -dH
18972@opindex dH
18973Produce a core dump whenever an error occurs.
18974
18975@item -dp
18976@opindex dp
18977Annotate the assembler output with a comment indicating which
18978pattern and alternative is used. The length and cost of each instruction are
18979also printed.
18980
18981@item -dP
18982@opindex dP
18983Dump the RTL in the assembler output as a comment before each instruction.
18984Also turns on @option{-dp} annotation.
18985
18986@item -dx
18987@opindex dx
18988Just generate RTL for a function instead of compiling it. Usually used
18989with @option{-fdump-rtl-expand}.
18990@end table
18991
18992@item -fdump-debug
18993@opindex fdump-debug
18994Dump debugging information generated during the debug
18995generation phase.
18996
18997@item -fdump-earlydebug
18998@opindex fdump-earlydebug
18999Dump debugging information generated during the early debug
19000generation phase.
19001
19002@item -fdump-noaddr
19003@opindex fdump-noaddr
19004When doing debugging dumps, suppress address output. This makes it more
19005feasible to use diff on debugging dumps for compiler invocations with
19006different compiler binaries and/or different
19007text / bss / data / heap / stack / dso start locations.
19008
19009@item -freport-bug
19010@opindex freport-bug
19011Collect and dump debug information into a temporary file if an
19012internal compiler error (ICE) occurs.
19013
19014@item -fdump-unnumbered
19015@opindex fdump-unnumbered
19016When doing debugging dumps, suppress instruction numbers and address output.
19017This makes it more feasible to use diff on debugging dumps for compiler
19018invocations with different options, in particular with and without
19019@option{-g}.
19020
19021@item -fdump-unnumbered-links
19022@opindex fdump-unnumbered-links
19023When doing debugging dumps (see @option{-d} option above), suppress
19024instruction numbers for the links to the previous and next instructions
19025in a sequence.
19026
19027@item -fdump-ipa-@var{switch}
19028@itemx -fdump-ipa-@var{switch}-@var{options}
19029@opindex fdump-ipa
19030Control the dumping at various stages of inter-procedural analysis
19031language tree to a file. The file name is generated by appending a
19032switch specific suffix to the source file name, and the file is created
19033in the same directory as the output file. The following dumps are
19034possible:
19035
19036@table @samp
19037@item all
19038Enables all inter-procedural analysis dumps.
19039
19040@item cgraph
19041Dumps information about call-graph optimization, unused function removal,
19042and inlining decisions.
19043
19044@item inline
19045Dump after function inlining.
19046
19047@end table
19048
19049Additionally, the options @option{-optimized}, @option{-missed},
19050@option{-note}, and @option{-all} can be provided, with the same meaning
19051as for @option{-fopt-info}, defaulting to @option{-optimized}.
19052
19053For example, @option{-fdump-ipa-inline-optimized-missed} will emit
19054information on callsites that were inlined, along with callsites
19055that were not inlined.
19056
19057By default, the dump will contain messages about successful
19058optimizations (equivalent to @option{-optimized}) together with
19059low-level details about the analysis.
19060
19061@item -fdump-lang
19062@opindex fdump-lang
19063Dump language-specific information. The file name is made by appending
19064@file{.lang} to the source file name.
19065
19066@item -fdump-lang-all
19067@itemx -fdump-lang-@var{switch}
19068@itemx -fdump-lang-@var{switch}-@var{options}
19069@itemx -fdump-lang-@var{switch}-@var{options}=@var{filename}
19070@opindex fdump-lang-all
19071@opindex fdump-lang
19072Control the dumping of language-specific information. The @var{options}
19073and @var{filename} portions behave as described in the
19074@option{-fdump-tree} option. The following @var{switch} values are
19075accepted:
19076
19077@table @samp
19078@item all
19079
19080Enable all language-specific dumps.
19081
19082@item class
19083Dump class hierarchy information. Virtual table information is emitted
19084unless '@option{slim}' is specified. This option is applicable to C++ only.
19085
19086@item module
19087Dump module information. Options @option{lineno} (locations),
19088@option{graph} (reachability), @option{blocks} (clusters),
19089@option{uid} (serialization), @option{alias} (mergeable),
19090@option{asmname} (Elrond), @option{eh} (mapper) & @option{vops}
19091(macros) may provide additional information. This option is
19092applicable to C++ only.
19093
19094@item raw
19095Dump the raw internal tree data. This option is applicable to C++ only.
19096
19097@end table
19098
19099@item -fdump-passes
19100@opindex fdump-passes
19101Print on @file{stderr} the list of optimization passes that are turned
19102on and off by the current command-line options.
19103
19104@item -fdump-statistics-@var{option}
19105@opindex fdump-statistics
19106Enable and control dumping of pass statistics in a separate file. The
19107file name is generated by appending a suffix ending in
19108@samp{.statistics} to the source file name, and the file is created in
19109the same directory as the output file. If the @samp{-@var{option}}
19110form is used, @samp{-stats} causes counters to be summed over the
19111whole compilation unit while @samp{-details} dumps every event as
19112the passes generate them. The default with no option is to sum
19113counters for each function compiled.
19114
19115@item -fdump-tree-all
19116@itemx -fdump-tree-@var{switch}
19117@itemx -fdump-tree-@var{switch}-@var{options}
19118@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
19119@opindex fdump-tree-all
19120@opindex fdump-tree
19121Control the dumping at various stages of processing the intermediate
19122language tree to a file. If the @samp{-@var{options}}
19123form is used, @var{options} is a list of @samp{-} separated options
19124which control the details of the dump. Not all options are applicable
19125to all dumps; those that are not meaningful are ignored. The
19126following options are available
19127
19128@table @samp
19129@item address
19130Print the address of each node. Usually this is not meaningful as it
19131changes according to the environment and source file. Its primary use
19132is for tying up a dump file with a debug environment.
19133@item asmname
19134If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that
19135in the dump instead of @code{DECL_NAME}. Its primary use is ease of
19136use working backward from mangled names in the assembly file.
19137@item slim
19138When dumping front-end intermediate representations, inhibit dumping
19139of members of a scope or body of a function merely because that scope
19140has been reached. Only dump such items when they are directly reachable
19141by some other path.
19142
19143When dumping pretty-printed trees, this option inhibits dumping the
19144bodies of control structures.
19145
19146When dumping RTL, print the RTL in slim (condensed) form instead of
19147the default LISP-like representation.
19148@item raw
19149Print a raw representation of the tree. By default, trees are
19150pretty-printed into a C-like representation.
19151@item details
19152Enable more detailed dumps (not honored by every dump option). Also
19153include information from the optimization passes.
19154@item stats
19155Enable dumping various statistics about the pass (not honored by every dump
19156option).
19157@item blocks
19158Enable showing basic block boundaries (disabled in raw dumps).
19159@item graph
19160For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}),
19161dump a representation of the control flow graph suitable for viewing with
19162GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in
19163the file is pretty-printed as a subgraph, so that GraphViz can render them
19164all in a single plot.
19165
19166This option currently only works for RTL dumps, and the RTL is always
19167dumped in slim form.
19168@item vops
19169Enable showing virtual operands for every statement.
19170@item lineno
19171Enable showing line numbers for statements.
19172@item uid
19173Enable showing the unique ID (@code{DECL_UID}) for each variable.
19174@item verbose
19175Enable showing the tree dump for each statement.
19176@item eh
19177Enable showing the EH region number holding each statement.
19178@item scev
19179Enable showing scalar evolution analysis details.
19180@item optimized
19181Enable showing optimization information (only available in certain
19182passes).
19183@item missed
19184Enable showing missed optimization information (only available in certain
19185passes).
19186@item note
19187Enable other detailed optimization information (only available in
19188certain passes).
19189@item all
19190Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
19191and @option{lineno}.
19192@item optall
19193Turn on all optimization options, i.e., @option{optimized},
19194@option{missed}, and @option{note}.
19195@end table
19196
19197To determine what tree dumps are available or find the dump for a pass
19198of interest follow the steps below.
19199
19200@enumerate
19201@item
19202Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output
19203look for a code that corresponds to the pass you are interested in.
19204For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and
19205@code{tree-vrp2} correspond to the three Value Range Propagation passes.
19206The number at the end distinguishes distinct invocations of the same pass.
19207@item
19208To enable the creation of the dump file, append the pass code to
19209the @option{-fdump-} option prefix and invoke GCC with it. For example,
19210to enable the dump from the Early Value Range Propagation pass, invoke
19211GCC with the @option{-fdump-tree-evrp} option. Optionally, you may
19212specify the name of the dump file. If you don't specify one, GCC
19213creates as described below.
19214@item
19215Find the pass dump in a file whose name is composed of three components
19216separated by a period: the name of the source file GCC was invoked to
19217compile, a numeric suffix indicating the pass number followed by the
19218letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes),
19219and finally the pass code. For example, the Early VRP pass dump might
19220be in a file named @file{myfile.c.038t.evrp} in the current working
19221directory. Note that the numeric codes are not stable and may change
19222from one version of GCC to another.
19223@end enumerate
19224
19225@item -fopt-info
19226@itemx -fopt-info-@var{options}
19227@itemx -fopt-info-@var{options}=@var{filename}
19228@opindex fopt-info
19229Controls optimization dumps from various optimization passes. If the
19230@samp{-@var{options}} form is used, @var{options} is a list of
19231@samp{-} separated option keywords to select the dump details and
19232optimizations.
19233
19234The @var{options} can be divided into three groups:
19235@enumerate
19236@item
19237options describing what kinds of messages should be emitted,
19238@item
19239options describing the verbosity of the dump, and
19240@item
19241options describing which optimizations should be included.
19242@end enumerate
19243The options from each group can be freely mixed as they are
19244non-overlapping. However, in case of any conflicts,
19245the later options override the earlier options on the command
19246line.
19247
19248The following options control which kinds of messages should be emitted:
19249
19250@table @samp
19251@item optimized
19252Print information when an optimization is successfully applied. It is
19253up to a pass to decide which information is relevant. For example, the
19254vectorizer passes print the source location of loops which are
19255successfully vectorized.
19256@item missed
19257Print information about missed optimizations. Individual passes
19258control which information to include in the output.
19259@item note
19260Print verbose information about optimizations, such as certain
19261transformations, more detailed messages about decisions etc.
19262@item all
19263Print detailed optimization information. This includes
19264@samp{optimized}, @samp{missed}, and @samp{note}.
19265@end table
19266
19267The following option controls the dump verbosity:
19268
19269@table @samp
19270@item internals
19271By default, only ``high-level'' messages are emitted. This option enables
19272additional, more detailed, messages, which are likely to only be of interest
19273to GCC developers.
19274@end table
19275
19276One or more of the following option keywords can be used to describe a
19277group of optimizations:
19278
19279@table @samp
19280@item ipa
19281Enable dumps from all interprocedural optimizations.
19282@item loop
19283Enable dumps from all loop optimizations.
19284@item inline
19285Enable dumps from all inlining optimizations.
19286@item omp
19287Enable dumps from all OMP (Offloading and Multi Processing) optimizations.
19288@item vec
19289Enable dumps from all vectorization optimizations.
19290@item optall
19291Enable dumps from all optimizations. This is a superset of
19292the optimization groups listed above.
19293@end table
19294
19295If @var{options} is
19296omitted, it defaults to @samp{optimized-optall}, which means to dump messages
19297about successful optimizations from all the passes, omitting messages
19298that are treated as ``internals''.
19299
19300If the @var{filename} is provided, then the dumps from all the
19301applicable optimizations are concatenated into the @var{filename}.
19302Otherwise the dump is output onto @file{stderr}. Though multiple
19303@option{-fopt-info} options are accepted, only one of them can include
19304a @var{filename}. If other filenames are provided then all but the
19305first such option are ignored.
19306
19307Note that the output @var{filename} is overwritten
19308in case of multiple translation units. If a combined output from
19309multiple translation units is desired, @file{stderr} should be used
19310instead.
19311
19312In the following example, the optimization info is output to
19313@file{stderr}:
19314
19315@smallexample
19316gcc -O3 -fopt-info
19317@end smallexample
19318
19319This example:
19320@smallexample
19321gcc -O3 -fopt-info-missed=missed.all
19322@end smallexample
19323
19324@noindent
19325outputs missed optimization report from all the passes into
19326@file{missed.all}, and this one:
19327
19328@smallexample
19329gcc -O2 -ftree-vectorize -fopt-info-vec-missed
19330@end smallexample
19331
19332@noindent
19333prints information about missed optimization opportunities from
19334vectorization passes on @file{stderr}.
19335Note that @option{-fopt-info-vec-missed} is equivalent to
19336@option{-fopt-info-missed-vec}. The order of the optimization group
19337names and message types listed after @option{-fopt-info} does not matter.
19338
19339As another example,
19340@smallexample
19341gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
19342@end smallexample
19343
19344@noindent
19345outputs information about missed optimizations as well as
19346optimized locations from all the inlining passes into
19347@file{inline.txt}.
19348
19349Finally, consider:
19350
19351@smallexample
19352gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
19353@end smallexample
19354
19355@noindent
19356Here the two output filenames @file{vec.miss} and @file{loop.opt} are
19357in conflict since only one output file is allowed. In this case, only
19358the first option takes effect and the subsequent options are
19359ignored. Thus only @file{vec.miss} is produced which contains
19360dumps from the vectorizer about missed opportunities.
19361
19362@item -fsave-optimization-record
19363@opindex fsave-optimization-record
19364Write a SRCFILE.opt-record.json.gz file detailing what optimizations
19365were performed, for those optimizations that support @option{-fopt-info}.
19366
19367This option is experimental and the format of the data within the
19368compressed JSON file is subject to change.
19369
19370It is roughly equivalent to a machine-readable version of
19371@option{-fopt-info-all}, as a collection of messages with source file,
19372line number and column number, with the following additional data for
19373each message:
19374
19375@itemize @bullet
19376
19377@item
19378the execution count of the code being optimized, along with metadata about
19379whether this was from actual profile data, or just an estimate, allowing
19380consumers to prioritize messages by code hotness,
19381
19382@item
19383the function name of the code being optimized, where applicable,
19384
19385@item
19386the ``inlining chain'' for the code being optimized, so that when
19387a function is inlined into several different places (which might
19388themselves be inlined), the reader can distinguish between the copies,
19389
19390@item
19391objects identifying those parts of the message that refer to expressions,
19392statements or symbol-table nodes, which of these categories they are, and,
19393when available, their source code location,
19394
19395@item
19396the GCC pass that emitted the message, and
19397
19398@item
19399the location in GCC's own code from which the message was emitted
19400
19401@end itemize
19402
19403Additionally, some messages are logically nested within other
19404messages, reflecting implementation details of the optimization
19405passes.
19406
19407@item -fsched-verbose=@var{n}
19408@opindex fsched-verbose
19409On targets that use instruction scheduling, this option controls the
19410amount of debugging output the scheduler prints to the dump files.
19411
19412For @var{n} greater than zero, @option{-fsched-verbose} outputs the
19413same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}.
19414For @var{n} greater than one, it also output basic block probabilities,
19415detailed ready list information and unit/insn info. For @var{n} greater
19416than two, it includes RTL at abort point, control-flow and regions info.
19417And for @var{n} over four, @option{-fsched-verbose} also includes
19418dependence info.
19419
19420
19421
19422@item -fenable-@var{kind}-@var{pass}
19423@itemx -fdisable-@var{kind}-@var{pass}=@var{range-list}
19424@opindex fdisable-
19425@opindex fenable-
19426
19427This is a set of options that are used to explicitly disable/enable
19428optimization passes. These options are intended for use for debugging GCC.
19429Compiler users should use regular options for enabling/disabling
19430passes instead.
19431
19432@table @gcctabopt
19433
19434@item -fdisable-ipa-@var{pass}
19435Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19436statically invoked in the compiler multiple times, the pass name should be
19437appended with a sequential number starting from 1.
19438
19439@item -fdisable-rtl-@var{pass}
19440@itemx -fdisable-rtl-@var{pass}=@var{range-list}
19441Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is
19442statically invoked in the compiler multiple times, the pass name should be
19443appended with a sequential number starting from 1. @var{range-list} is a
19444comma-separated list of function ranges or assembler names. Each range is a number
19445pair separated by a colon. The range is inclusive in both ends. If the range
19446is trivial, the number pair can be simplified as a single number. If the
19447function's call graph node's @var{uid} falls within one of the specified ranges,
19448the @var{pass} is disabled for that function. The @var{uid} is shown in the
19449function header of a dump file, and the pass names can be dumped by using
19450option @option{-fdump-passes}.
19451
19452@item -fdisable-tree-@var{pass}
19453@itemx -fdisable-tree-@var{pass}=@var{range-list}
19454Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of
19455option arguments.
19456
19457@item -fenable-ipa-@var{pass}
19458Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is
19459statically invoked in the compiler multiple times, the pass name should be
19460appended with a sequential number starting from 1.
19461
19462@item -fenable-rtl-@var{pass}
19463@itemx -fenable-rtl-@var{pass}=@var{range-list}
19464Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument
19465description and examples.
19466
19467@item -fenable-tree-@var{pass}
19468@itemx -fenable-tree-@var{pass}=@var{range-list}
19469Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description
19470of option arguments.
19471
19472@end table
19473
19474Here are some examples showing uses of these options.
19475
19476@smallexample
19477
19478# disable ccp1 for all functions
19479 -fdisable-tree-ccp1
19480# disable complete unroll for function whose cgraph node uid is 1
19481 -fenable-tree-cunroll=1
19482# disable gcse2 for functions at the following ranges [1,1],
19483# [300,400], and [400,1000]
19484# disable gcse2 for functions foo and foo2
19485 -fdisable-rtl-gcse2=foo,foo2
19486# disable early inlining
19487 -fdisable-tree-einline
19488# disable ipa inlining
19489 -fdisable-ipa-inline
19490# enable tree full unroll
19491 -fenable-tree-unroll
19492
19493@end smallexample
19494
19495@item -fchecking
19496@itemx -fchecking=@var{n}
19497@opindex fchecking
19498@opindex fno-checking
19499Enable internal consistency checking. The default depends on
19500the compiler configuration. @option{-fchecking=2} enables further
19501internal consistency checking that might affect code generation.
19502
19503@item -frandom-seed=@var{string}
19504@opindex frandom-seed
19505This option provides a seed that GCC uses in place of
19506random numbers in generating certain symbol names
19507that have to be different in every compiled file. It is also used to
19508place unique stamps in coverage data files and the object files that
19509produce them. You can use the @option{-frandom-seed} option to produce
19510reproducibly identical object files.
19511
19512The @var{string} can either be a number (decimal, octal or hex) or an
19513arbitrary string (in which case it's converted to a number by
19514computing CRC32).
19515
19516The @var{string} should be different for every file you compile.
19517
19518@item -save-temps
19519@opindex save-temps
19520Store the usual ``temporary'' intermediate files permanently; name them
19521as auxiliary output files, as specified described under
19522@option{-dumpbase} and @option{-dumpdir}.
19523
19524When used in combination with the @option{-x} command-line option,
19525@option{-save-temps} is sensible enough to avoid overwriting an
19526input source file with the same extension as an intermediate file.
19527The corresponding intermediate file may be obtained by renaming the
19528source file before using @option{-save-temps}.
19529
19530@item -save-temps=cwd
19531@opindex save-temps=cwd
19532Equivalent to @option{-save-temps -dumpdir ./}.
19533
19534@item -save-temps=obj
19535@opindex save-temps=obj
19536Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where
19537@file{outdir/} is the directory of the output file specified after the
19538@option{-o} option, including any directory separators. If the
19539@option{-o} option is not used, the @option{-save-temps=obj} switch
19540behaves like @option{-save-temps=cwd}.
19541
19542@item -time@r{[}=@var{file}@r{]}
19543@opindex time
19544Report the CPU time taken by each subprocess in the compilation
19545sequence. For C source files, this is the compiler proper and assembler
19546(plus the linker if linking is done).
19547
19548Without the specification of an output file, the output looks like this:
19549
19550@smallexample
19551# cc1 0.12 0.01
19552# as 0.00 0.01
19553@end smallexample
19554
19555The first number on each line is the ``user time'', that is time spent
19556executing the program itself. The second number is ``system time'',
19557time spent executing operating system routines on behalf of the program.
19558Both numbers are in seconds.
19559
19560With the specification of an output file, the output is appended to the
19561named file, and it looks like this:
19562
19563@smallexample
195640.12 0.01 cc1 @var{options}
195650.00 0.01 as @var{options}
19566@end smallexample
19567
19568The ``user time'' and the ``system time'' are moved before the program
19569name, and the options passed to the program are displayed, so that one
19570can later tell what file was being compiled, and with which options.
19571
19572@item -fdump-final-insns@r{[}=@var{file}@r{]}
19573@opindex fdump-final-insns
19574Dump the final internal representation (RTL) to @var{file}. If the
19575optional argument is omitted (or if @var{file} is @code{.}), the name
19576of the dump file is determined by appending @code{.gkd} to the
19577dump base name, see @option{-dumpbase}.
19578
19579@item -fcompare-debug@r{[}=@var{opts}@r{]}
19580@opindex fcompare-debug
19581@opindex fno-compare-debug
19582If no error occurs during compilation, run the compiler a second time,
19583adding @var{opts} and @option{-fcompare-debug-second} to the arguments
19584passed to the second compilation. Dump the final internal
19585representation in both compilations, and print an error if they differ.
19586
19587If the equal sign is omitted, the default @option{-gtoggle} is used.
19588
19589The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty
19590and nonzero, implicitly enables @option{-fcompare-debug}. If
19591@env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash,
19592then it is used for @var{opts}, otherwise the default @option{-gtoggle}
19593is used.
19594
19595@option{-fcompare-debug=}, with the equal sign but without @var{opts},
19596is equivalent to @option{-fno-compare-debug}, which disables the dumping
19597of the final representation and the second compilation, preventing even
19598@env{GCC_COMPARE_DEBUG} from taking effect.
19599
19600To verify full coverage during @option{-fcompare-debug} testing, set
19601@env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden},
19602which GCC rejects as an invalid option in any actual compilation
19603(rather than preprocessing, assembly or linking). To get just a
19604warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug
19605not overridden} will do.
19606
19607@item -fcompare-debug-second
19608@opindex fcompare-debug-second
19609This option is implicitly passed to the compiler for the second
19610compilation requested by @option{-fcompare-debug}, along with options to
19611silence warnings, and omitting other options that would cause the compiler
19612to produce output to files or to standard output as a side effect. Dump
19613files and preserved temporary files are renamed so as to contain the
19614@code{.gk} additional extension during the second compilation, to avoid
19615overwriting those generated by the first.
19616
19617When this option is passed to the compiler driver, it causes the
19618@emph{first} compilation to be skipped, which makes it useful for little
19619other than debugging the compiler proper.
19620
19621@item -gtoggle
19622@opindex gtoggle
19623Turn off generation of debug info, if leaving out this option
19624generates it, or turn it on at level 2 otherwise. The position of this
19625argument in the command line does not matter; it takes effect after all
19626other options are processed, and it does so only once, no matter how
19627many times it is given. This is mainly intended to be used with
19628@option{-fcompare-debug}.
19629
19630@item -fvar-tracking-assignments-toggle
19631@opindex fvar-tracking-assignments-toggle
19632@opindex fno-var-tracking-assignments-toggle
19633Toggle @option{-fvar-tracking-assignments}, in the same way that
19634@option{-gtoggle} toggles @option{-g}.
19635
19636@item -Q
19637@opindex Q
19638Makes the compiler print out each function name as it is compiled, and
19639print some statistics about each pass when it finishes.
19640
19641@item -ftime-report
19642@opindex ftime-report
19643Makes the compiler print some statistics about the time consumed by each
19644pass when it finishes.
19645
19646@item -ftime-report-details
19647@opindex ftime-report-details
19648Record the time consumed by infrastructure parts separately for each pass.
19649
19650@item -fira-verbose=@var{n}
19651@opindex fira-verbose
19652Control the verbosity of the dump file for the integrated register allocator.
19653The default value is 5. If the value @var{n} is greater or equal to 10,
19654the dump output is sent to stderr using the same format as @var{n} minus 10.
19655
19656@item -flto-report
19657@opindex flto-report
19658Prints a report with internal details on the workings of the link-time
19659optimizer. The contents of this report vary from version to version.
19660It is meant to be useful to GCC developers when processing object
19661files in LTO mode (via @option{-flto}).
19662
19663Disabled by default.
19664
19665@item -flto-report-wpa
19666@opindex flto-report-wpa
19667Like @option{-flto-report}, but only print for the WPA phase of link-time
19668optimization.
19669
19670@item -fmem-report
19671@opindex fmem-report
19672Makes the compiler print some statistics about permanent memory
19673allocation when it finishes.
19674
19675@item -fmem-report-wpa
19676@opindex fmem-report-wpa
19677Makes the compiler print some statistics about permanent memory
19678allocation for the WPA phase only.
19679
19680@item -fpre-ipa-mem-report
19681@opindex fpre-ipa-mem-report
19682@item -fpost-ipa-mem-report
19683@opindex fpost-ipa-mem-report
19684Makes the compiler print some statistics about permanent memory
19685allocation before or after interprocedural optimization.
19686
19687@item -fmultiflags
19688@opindex fmultiflags
19689This option enables multilib-aware @code{TFLAGS} to be used to build
19690target libraries with options different from those the compiler is
19691configured to use by default, through the use of specs (@xref{Spec
19692Files}) set up by compiler internals, by the target, or by builders at
19693configure time.
19694
19695Like @code{TFLAGS}, this allows the target libraries to be built for
19696portable baseline environments, while the compiler defaults to more
19697demanding ones. That's useful because users can easily override the
19698defaults the compiler is configured to use to build their own programs,
19699if the defaults are not ideal for their target environment, whereas
19700rebuilding the runtime libraries is usually not as easy or desirable.
19701
19702Unlike @code{TFLAGS}, the use of specs enables different flags to be
19703selected for different multilibs. The way to accomplish that is to
19704build with @samp{make TFLAGS=-fmultiflags}, after configuring
19705@samp{--with-specs=%@{fmultiflags:...@}}.
19706
19707This option is discarded by the driver once it's done processing driver
19708self spec.
19709
19710It is also useful to check that @code{TFLAGS} are being used to build
19711all target libraries, by configuring a non-bootstrap compiler
19712@samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building
19713the compiler and target libraries.
19714
19715@item -fprofile-report
19716@opindex fprofile-report
19717Makes the compiler print some statistics about consistency of the
19718(estimated) profile and effect of individual passes.
19719
19720@item -fstack-usage
19721@opindex fstack-usage
19722Makes the compiler output stack usage information for the program, on a
19723per-function basis. The filename for the dump is made by appending
19724@file{.su} to the @var{auxname}. @var{auxname} is generated from the name of
19725the output file, if explicitly specified and it is not an executable,
19726otherwise it is the basename of the source file. An entry is made up
19727of three fields:
19728
19729@itemize
19730@item
19731The name of the function.
19732@item
19733A number of bytes.
19734@item
19735One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}.
19736@end itemize
19737
19738The qualifier @code{static} means that the function manipulates the stack
19739statically: a fixed number of bytes are allocated for the frame on function
19740entry and released on function exit; no stack adjustments are otherwise made
19741in the function. The second field is this fixed number of bytes.
19742
19743The qualifier @code{dynamic} means that the function manipulates the stack
19744dynamically: in addition to the static allocation described above, stack
19745adjustments are made in the body of the function, for example to push/pop
19746arguments around function calls. If the qualifier @code{bounded} is also
19747present, the amount of these adjustments is bounded at compile time and
19748the second field is an upper bound of the total amount of stack used by
19749the function. If it is not present, the amount of these adjustments is
19750not bounded at compile time and the second field only represents the
19751bounded part.
19752
19753@item -fstats
19754@opindex fstats
19755Emit statistics about front-end processing at the end of the compilation.
19756This option is supported only by the C++ front end, and
19757the information is generally only useful to the G++ development team.
19758
19759@item -fdbg-cnt-list
19760@opindex fdbg-cnt-list
19761Print the name and the counter upper bound for all debug counters.
19762
19763
19764@item -fdbg-cnt=@var{counter-value-list}
19765@opindex fdbg-cnt
19766Set the internal debug counter lower and upper bound. @var{counter-value-list}
19767is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1}
19768[:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets
19769the name of the counter and list of closed intervals.
19770The @var{lower_bound} is optional and is zero
19771initialized if not set.
19772For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10},
19773@code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and
19774eleventh invocation.
19775For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations.
19776
19777@item -print-file-name=@var{library}
19778@opindex print-file-name
19779Print the full absolute name of the library file @var{library} that
19780would be used when linking---and don't do anything else. With this
19781option, GCC does not compile or link anything; it just prints the
19782file name.
19783
19784@item -print-multi-directory
19785@opindex print-multi-directory
19786Print the directory name corresponding to the multilib selected by any
19787other switches present in the command line. This directory is supposed
19788to exist in @env{GCC_EXEC_PREFIX}.
19789
19790@item -print-multi-lib
19791@opindex print-multi-lib
19792Print the mapping from multilib directory names to compiler switches
19793that enable them. The directory name is separated from the switches by
19794@samp{;}, and each switch starts with an @samp{@@} instead of the
19795@samp{-}, without spaces between multiple switches. This is supposed to
19796ease shell processing.
19797
19798@item -print-multi-os-directory
19799@opindex print-multi-os-directory
19800Print the path to OS libraries for the selected
19801multilib, relative to some @file{lib} subdirectory. If OS libraries are
19802present in the @file{lib} subdirectory and no multilibs are used, this is
19803usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}}
19804sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or
19805@file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}}
19806subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}.
19807
19808@item -print-multiarch
19809@opindex print-multiarch
19810Print the path to OS libraries for the selected multiarch,
19811relative to some @file{lib} subdirectory.
19812
19813@item -print-prog-name=@var{program}
19814@opindex print-prog-name
19815Like @option{-print-file-name}, but searches for a program such as @command{cpp}.
19816
19817@item -print-libgcc-file-name
19818@opindex print-libgcc-file-name
19819Same as @option{-print-file-name=libgcc.a}.
19820
19821This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
19822but you do want to link with @file{libgcc.a}. You can do:
19823
19824@smallexample
19825gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
19826@end smallexample
19827
19828@item -print-search-dirs
19829@opindex print-search-dirs
19830Print the name of the configured installation directory and a list of
19831program and library directories @command{gcc} searches---and don't do anything else.
19832
19833This is useful when @command{gcc} prints the error message
19834@samp{installation problem, cannot exec cpp0: No such file or directory}.
19835To resolve this you either need to put @file{cpp0} and the other compiler
19836components where @command{gcc} expects to find them, or you can set the environment
19837variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
19838Don't forget the trailing @samp{/}.
19839@xref{Environment Variables}.
19840
19841@item -print-sysroot
19842@opindex print-sysroot
19843Print the target sysroot directory that is used during
19844compilation. This is the target sysroot specified either at configure
19845time or using the @option{--sysroot} option, possibly with an extra
19846suffix that depends on compilation options. If no target sysroot is
19847specified, the option prints nothing.
19848
19849@item -print-sysroot-headers-suffix
19850@opindex print-sysroot-headers-suffix
19851Print the suffix added to the target sysroot when searching for
19852headers, or give an error if the compiler is not configured with such
19853a suffix---and don't do anything else.
19854
19855@item -dumpmachine
19856@opindex dumpmachine
19857Print the compiler's target machine (for example,
19858@samp{i686-pc-linux-gnu})---and don't do anything else.
19859
19860@item -dumpversion
19861@opindex dumpversion
19862Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do
19863anything else. This is the compiler version used in filesystem paths and
19864specs. Depending on how the compiler has been configured it can be just
19865a single number (major version), two numbers separated by a dot (major and
19866minor version) or three numbers separated by dots (major, minor and patchlevel
19867version).
19868
19869@item -dumpfullversion
19870@opindex dumpfullversion
19871Print the full compiler version---and don't do anything else. The output is
19872always three numbers separated by dots, major, minor and patchlevel version.
19873
19874@item -dumpspecs
19875@opindex dumpspecs
19876Print the compiler's built-in specs---and don't do anything else. (This
19877is used when GCC itself is being built.) @xref{Spec Files}.
19878@end table
19879
19880@node Submodel Options
19881@section Machine-Dependent Options
19882@cindex submodel options
19883@cindex specifying hardware config
19884@cindex hardware models and configurations, specifying
19885@cindex target-dependent options
19886@cindex machine-dependent options
19887
19888Each target machine supported by GCC can have its own options---for
19889example, to allow you to compile for a particular processor variant or
19890ABI, or to control optimizations specific to that machine. By
19891convention, the names of machine-specific options start with
19892@samp{-m}.
19893
19894Some configurations of the compiler also support additional target-specific
19895options, usually for compatibility with other compilers on the same
19896platform.
19897
19898@c This list is ordered alphanumerically by subsection name.
19899@c It should be the same order and spelling as these options are listed
19900@c in Machine Dependent Options
19901
19902@menu
19903* AArch64 Options::
19904* Adapteva Epiphany Options::
19905* AMD GCN Options::
19906* ARC Options::
19907* ARM Options::
19908* AVR Options::
19909* Blackfin Options::
19910* C6X Options::
19911* CRIS Options::
19912* C-SKY Options::
19913* Darwin Options::
19914* DEC Alpha Options::
19915* eBPF Options::
19916* FR30 Options::
19917* FT32 Options::
19918* FRV Options::
19919* GNU/Linux Options::
19920* H8/300 Options::
19921* HPPA Options::
19922* IA-64 Options::
19923* LM32 Options::
19924* LoongArch Options::
19925* M32C Options::
19926* M32R/D Options::
19927* M680x0 Options::
19928* MCore Options::
d77de738
ML
19929* MicroBlaze Options::
19930* MIPS Options::
19931* MMIX Options::
19932* MN10300 Options::
19933* Moxie Options::
19934* MSP430 Options::
19935* NDS32 Options::
19936* Nios II Options::
19937* Nvidia PTX Options::
19938* OpenRISC Options::
19939* PDP-11 Options::
d77de738
ML
19940* PowerPC Options::
19941* PRU Options::
19942* RISC-V Options::
19943* RL78 Options::
19944* RS/6000 and PowerPC Options::
19945* RX Options::
19946* S/390 and zSeries Options::
d77de738
ML
19947* SH Options::
19948* Solaris 2 Options::
19949* SPARC Options::
19950* System V Options::
19951* V850 Options::
19952* VAX Options::
19953* Visium Options::
19954* VMS Options::
19955* VxWorks Options::
19956* x86 Options::
19957* x86 Windows Options::
19958* Xstormy16 Options::
19959* Xtensa Options::
19960* zSeries Options::
19961@end menu
19962
19963@node AArch64 Options
19964@subsection AArch64 Options
19965@cindex AArch64 Options
19966
19967These options are defined for AArch64 implementations:
19968
19969@table @gcctabopt
19970
19971@item -mabi=@var{name}
19972@opindex mabi
19973Generate code for the specified data model. Permissible values
19974are @samp{ilp32} for SysV-like data model where int, long int and pointers
19975are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits,
19976but long int and pointers are 64 bits.
19977
19978The default depends on the specific target configuration. Note that
19979the LP64 and ILP32 ABIs are not link-compatible; you must compile your
19980entire program with the same ABI, and link with a compatible set of libraries.
19981
19982@item -mbig-endian
19983@opindex mbig-endian
19984Generate big-endian code. This is the default when GCC is configured for an
19985@samp{aarch64_be-*-*} target.
19986
19987@item -mgeneral-regs-only
19988@opindex mgeneral-regs-only
19989Generate code which uses only the general-purpose registers. This will prevent
19990the compiler from using floating-point and Advanced SIMD registers but will not
19991impose any restrictions on the assembler.
19992
19993@item -mlittle-endian
19994@opindex mlittle-endian
19995Generate little-endian code. This is the default when GCC is configured for an
19996@samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target.
19997
19998@item -mcmodel=tiny
19999@opindex mcmodel=tiny
20000Generate code for the tiny code model. The program and its statically defined
20001symbols must be within 1MB of each other. Programs can be statically or
20002dynamically linked.
20003
20004@item -mcmodel=small
20005@opindex mcmodel=small
20006Generate code for the small code model. The program and its statically defined
20007symbols must be within 4GB of each other. Programs can be statically or
20008dynamically linked. This is the default code model.
20009
20010@item -mcmodel=large
20011@opindex mcmodel=large
20012Generate code for the large code model. This makes no assumptions about
20013addresses and sizes of sections. Programs can be statically linked only. The
20014@option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32},
20015@option{-fpic} and @option{-fPIC}.
20016
20017@item -mstrict-align
20018@itemx -mno-strict-align
20019@opindex mstrict-align
20020@opindex mno-strict-align
20021Avoid or allow generating memory accesses that may not be aligned on a natural
20022object boundary as described in the architecture specification.
20023
20024@item -momit-leaf-frame-pointer
20025@itemx -mno-omit-leaf-frame-pointer
20026@opindex momit-leaf-frame-pointer
20027@opindex mno-omit-leaf-frame-pointer
20028Omit or keep the frame pointer in leaf functions. The former behavior is the
20029default.
20030
20031@item -mstack-protector-guard=@var{guard}
20032@itemx -mstack-protector-guard-reg=@var{reg}
20033@itemx -mstack-protector-guard-offset=@var{offset}
20034@opindex mstack-protector-guard
20035@opindex mstack-protector-guard-reg
20036@opindex mstack-protector-guard-offset
20037Generate stack protection code using canary at @var{guard}. Supported
20038locations are @samp{global} for a global canary or @samp{sysreg} for a
20039canary in an appropriate system register.
20040
20041With the latter choice the options
20042@option{-mstack-protector-guard-reg=@var{reg}} and
20043@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
20044which system register to use as base register for reading the canary,
20045and from what offset from that base register. There is no default
20046register or offset as this is entirely for use within the Linux
20047kernel.
20048
20049@item -mtls-dialect=desc
20050@opindex mtls-dialect=desc
20051Use TLS descriptors as the thread-local storage mechanism for dynamic accesses
20052of TLS variables. This is the default.
20053
20054@item -mtls-dialect=traditional
20055@opindex mtls-dialect=traditional
20056Use traditional TLS as the thread-local storage mechanism for dynamic accesses
20057of TLS variables.
20058
20059@item -mtls-size=@var{size}
20060@opindex mtls-size
20061Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48.
20062This option requires binutils 2.26 or newer.
20063
20064@item -mfix-cortex-a53-835769
20065@itemx -mno-fix-cortex-a53-835769
20066@opindex mfix-cortex-a53-835769
20067@opindex mno-fix-cortex-a53-835769
20068Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769.
20069This involves inserting a NOP instruction between memory instructions and
2007064-bit integer multiply-accumulate instructions.
20071
20072@item -mfix-cortex-a53-843419
20073@itemx -mno-fix-cortex-a53-843419
20074@opindex mfix-cortex-a53-843419
20075@opindex mno-fix-cortex-a53-843419
20076Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419.
20077This erratum workaround is made at link time and this will only pass the
20078corresponding flag to the linker.
20079
20080@item -mlow-precision-recip-sqrt
20081@itemx -mno-low-precision-recip-sqrt
20082@opindex mlow-precision-recip-sqrt
20083@opindex mno-low-precision-recip-sqrt
20084Enable or disable the reciprocal square root approximation.
20085This option only has an effect if @option{-ffast-math} or
20086@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20087precision of reciprocal square root results to about 16 bits for
20088single precision and to 32 bits for double precision.
20089
20090@item -mlow-precision-sqrt
20091@itemx -mno-low-precision-sqrt
20092@opindex mlow-precision-sqrt
20093@opindex mno-low-precision-sqrt
20094Enable or disable the square root approximation.
20095This option only has an effect if @option{-ffast-math} or
20096@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20097precision of square root results to about 16 bits for
20098single precision and to 32 bits for double precision.
20099If enabled, it implies @option{-mlow-precision-recip-sqrt}.
20100
20101@item -mlow-precision-div
20102@itemx -mno-low-precision-div
20103@opindex mlow-precision-div
20104@opindex mno-low-precision-div
20105Enable or disable the division approximation.
20106This option only has an effect if @option{-ffast-math} or
20107@option{-funsafe-math-optimizations} is used as well. Enabling this reduces
20108precision of division results to about 16 bits for
20109single precision and to 32 bits for double precision.
20110
20111@item -mtrack-speculation
20112@itemx -mno-track-speculation
20113Enable or disable generation of additional code to track speculative
20114execution through conditional branches. The tracking state can then
20115be used by the compiler when expanding calls to
20116@code{__builtin_speculation_safe_copy} to permit a more efficient code
20117sequence to be generated.
20118
20119@item -moutline-atomics
20120@itemx -mno-outline-atomics
20121Enable or disable calls to out-of-line helpers to implement atomic operations.
20122These helpers will, at runtime, determine if the LSE instructions from
20123ARMv8.1-A can be used; if not, they will use the load/store-exclusive
20124instructions that are present in the base ARMv8.0 ISA.
20125
20126This option is only applicable when compiling for the base ARMv8.0
20127instruction set. If using a later revision, e.g. @option{-march=armv8.1-a}
20128or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be
20129used directly. The same applies when using @option{-mcpu=} when the
20130selected cpu supports the @samp{lse} feature.
20131This option is on by default.
20132
20133@item -march=@var{name}
20134@opindex march
20135Specify the name of the target architecture and, optionally, one or
20136more feature modifiers. This option has the form
20137@option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}.
20138
20139The table below summarizes the permissible values for @var{arch}
20140and the features that they enable by default:
20141
20142@multitable @columnfractions 0.20 0.20 0.60
20143@headitem @var{arch} value @tab Architecture @tab Includes by default
20144@item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd}
20145@item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma}
20146@item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a}
20147@item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth}
20148@item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod}
20149@item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres}
20150@item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm}
20151@item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64}
20152@item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops}
20153@item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2}
20154@item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm}
20155@item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64}
20156@item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops}
20157@item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r}
20158@end multitable
20159
20160The value @samp{native} is available on native AArch64 GNU/Linux and
20161causes the compiler to pick the architecture of the host system. This
20162option has no effect if the compiler is unable to recognize the
20163architecture of the host system,
20164
20165The permissible values for @var{feature} are listed in the sub-section
20166on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20167Feature Modifiers}. Where conflicting feature modifiers are
20168specified, the right-most feature is used.
20169
20170GCC uses @var{name} to determine what kind of instructions it can emit
20171when generating assembly code. If @option{-march} is specified
20172without either of @option{-mtune} or @option{-mcpu} also being
20173specified, the code is tuned to perform well across a range of target
20174processors implementing the target architecture.
20175
20176@item -mtune=@var{name}
20177@opindex mtune
20178Specify the name of the target processor for which GCC should tune the
20179performance of the code. Permissible values for this option are:
20180@samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
20181@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
20182@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
20183@samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
20184@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c},
20185@samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
20186@samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1},
20187@samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx},
20188@samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan},
20189@samp{octeontx}, @samp{octeontx81}, @samp{octeontx83},
20190@samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}
20191@samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n},
20192@samp{octeontx2f95mm},
20193@samp{a64fx},
20194@samp{thunderx}, @samp{thunderxt88},
20195@samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110},
20196@samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
20197@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20198@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20199@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
ce51e843 20200@samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2},
e07556a8
SP
20201@samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715},
20202@samp{ampere1}, @samp{ampere1a}, and @samp{native}.
d77de738
ML
20203
20204The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
20205@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
20206@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC
20207should tune for a big.LITTLE system.
20208
20209The value @samp{neoverse-512tvb} specifies that GCC should tune
20210for Neoverse cores that (a) implement SVE and (b) have a total vector
20211bandwidth of 512 bits per cycle. In other words, the option tells GCC to
20212tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic
20213instructions a cycle and that can execute an equivalent number of SVE
20214arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE).
20215This is more general than tuning for a specific core like Neoverse V1
20216but is more specific than the default tuning described below.
20217
20218Additionally on native AArch64 GNU/Linux systems the value
20219@samp{native} tunes performance to the host system. This option has no effect
20220if the compiler is unable to recognize the processor of the host system.
20221
20222Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=}
20223are specified, the code is tuned to perform well across a range
20224of target processors.
20225
20226This option cannot be suffixed by feature modifiers.
20227
20228@item -mcpu=@var{name}
20229@opindex mcpu
20230Specify the name of the target processor, optionally suffixed by one
20231or more feature modifiers. This option has the form
20232@option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where
20233the permissible values for @var{cpu} are the same as those available
20234for @option{-mtune}. The permissible values for @var{feature} are
20235documented in the sub-section on
20236@ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu}
20237Feature Modifiers}. Where conflicting feature modifiers are
20238specified, the right-most feature is used.
20239
20240GCC uses @var{name} to determine what kind of instructions it can emit when
20241generating assembly code (as if by @option{-march}) and to determine
20242the target processor for which to tune for performance (as if
20243by @option{-mtune}). Where this option is used in conjunction
20244with @option{-march} or @option{-mtune}, those options take precedence
20245over the appropriate part of this option.
20246
20247@option{-mcpu=neoverse-512tvb} is special in that it does not refer
20248to a specific core, but instead refers to all Neoverse cores that
20249(a) implement SVE and (b) have a total vector bandwidth of 512 bits
20250a cycle. Unless overridden by @option{-march},
20251@option{-mcpu=neoverse-512tvb} generates code that can run on a
20252Neoverse V1 core, since Neoverse V1 is the first Neoverse core with
20253these properties. Unless overridden by @option{-mtune},
20254@option{-mcpu=neoverse-512tvb} tunes code in the same way as for
20255@option{-mtune=neoverse-512tvb}.
20256
20257@item -moverride=@var{string}
20258@opindex moverride
20259Override tuning decisions made by the back-end in response to a
20260@option{-mtune=} switch. The syntax, semantics, and accepted values
20261for @var{string} in this option are not guaranteed to be consistent
20262across releases.
20263
20264This option is only intended to be useful when developing GCC.
20265
20266@item -mverbose-cost-dump
20267@opindex mverbose-cost-dump
20268Enable verbose cost model dumping in the debug dump files. This option is
20269provided for use in debugging the compiler.
20270
20271@item -mpc-relative-literal-loads
20272@itemx -mno-pc-relative-literal-loads
20273@opindex mpc-relative-literal-loads
20274@opindex mno-pc-relative-literal-loads
20275Enable or disable PC-relative literal loads. With this option literal pools are
20276accessed using a single instruction and emitted after each function. This
20277limits the maximum size of functions to 1MB. This is enabled by default for
20278@option{-mcmodel=tiny}.
20279
20280@item -msign-return-address=@var{scope}
20281@opindex msign-return-address
20282Select the function scope on which return address signing will be applied.
20283Permissible values are @samp{none}, which disables return address signing,
20284@samp{non-leaf}, which enables pointer signing for functions which are not leaf
20285functions, and @samp{all}, which enables pointer signing for all functions. The
20286default value is @samp{none}. This option has been deprecated by
20287-mbranch-protection.
20288
20289@item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti}
20290@opindex mbranch-protection
20291Select the branch protection features to use.
20292@samp{none} is the default and turns off all types of branch protection.
20293@samp{standard} turns on all types of branch protection features. If a feature
20294has additional tuning options, then @samp{standard} sets it to its standard
20295level.
20296@samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard
20297level: signing functions that save the return address to memory (non-leaf
20298functions will practically always do this) using the a-key. The optional
20299argument @samp{leaf} can be used to extend the signing to include leaf
20300functions. The optional argument @samp{b-key} can be used to sign the functions
20301with the B-key instead of the A-key.
20302@samp{bti} turns on branch target identification mechanism.
20303
20304@item -mharden-sls=@var{opts}
20305@opindex mharden-sls
20306Enable compiler hardening against straight line speculation (SLS).
20307@var{opts} is a comma-separated list of the following options:
20308@table @samp
20309@item retbr
20310@item blr
20311@end table
20312In addition, @samp{-mharden-sls=all} enables all SLS hardening while
20313@samp{-mharden-sls=none} disables all SLS hardening.
20314
20315@item -msve-vector-bits=@var{bits}
20316@opindex msve-vector-bits
20317Specify the number of bits in an SVE vector register. This option only has
20318an effect when SVE is enabled.
20319
20320GCC supports two forms of SVE code generation: ``vector-length
20321agnostic'' output that works with any size of vector register and
20322``vector-length specific'' output that allows GCC to make assumptions
20323about the vector length when it is useful for optimization reasons.
20324The possible values of @samp{bits} are: @samp{scalable}, @samp{128},
20325@samp{256}, @samp{512}, @samp{1024} and @samp{2048}.
20326Specifying @samp{scalable} selects vector-length agnostic
20327output. At present @samp{-msve-vector-bits=128} also generates vector-length
20328agnostic output for big-endian targets. All other values generate
20329vector-length specific code. The behavior of these values may change
20330in future releases and no value except @samp{scalable} should be
20331relied on for producing code that is portable across different
20332hardware SVE vector lengths.
20333
20334The default is @samp{-msve-vector-bits=scalable}, which produces
20335vector-length agnostic code.
20336@end table
20337
20338@subsubsection @option{-march} and @option{-mcpu} Feature Modifiers
20339@anchor{aarch64-feature-modifiers}
20340@cindex @option{-march} feature modifiers
20341@cindex @option{-mcpu} feature modifiers
20342Feature modifiers used with @option{-march} and @option{-mcpu} can be any of
20343the following and their inverses @option{no@var{feature}}:
20344
20345@table @samp
20346@item crc
20347Enable CRC extension. This is on by default for
20348@option{-march=armv8.1-a}.
20349@item crypto
20350Enable Crypto extension. This also enables Advanced SIMD and floating-point
20351instructions.
20352@item fp
20353Enable floating-point instructions. This is on by default for all possible
20354values for options @option{-march} and @option{-mcpu}.
20355@item simd
20356Enable Advanced SIMD instructions. This also enables floating-point
20357instructions. This is on by default for all possible values for options
20358@option{-march} and @option{-mcpu}.
20359@item sve
20360Enable Scalable Vector Extension instructions. This also enables Advanced
20361SIMD and floating-point instructions.
20362@item lse
20363Enable Large System Extension instructions. This is on by default for
20364@option{-march=armv8.1-a}.
20365@item rdma
20366Enable Round Double Multiply Accumulate instructions. This is on by default
20367for @option{-march=armv8.1-a}.
20368@item fp16
20369Enable FP16 extension. This also enables floating-point instructions.
20370@item fp16fml
20371Enable FP16 fmla extension. This also enables FP16 extensions and
20372floating-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.
20373
20374@item rcpc
0431e8ae
AV
20375Enable the RCpc extension. This enables the use of the LDAPR instructions for
20376load-acquire atomic semantics, and passes it on to the assembler, enabling
20377inline asm statements to use instructions from the RCpc extension.
d77de738
ML
20378@item dotprod
20379Enable the Dot Product extension. This also enables Advanced SIMD instructions.
20380@item aes
20381Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced
20382SIMD instructions.
20383@item sha2
20384Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions.
20385@item sha3
20386Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD
20387instructions. Use of this option with architectures prior to Armv8.2-A is not supported.
20388@item sm4
20389Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions.
20390Use of this option with architectures prior to Armv8.2-A is not supported.
20391@item profile
20392Enable the Statistical Profiling extension. This option is only to enable the
20393extension at the assembler level and does not affect code generation.
20394@item rng
20395Enable the Armv8.5-a Random Number instructions. This option is only to
20396enable the extension at the assembler level and does not affect code
20397generation.
20398@item memtag
20399Enable the Armv8.5-a Memory Tagging Extensions.
20400Use of this option with architectures prior to Armv8.5-A is not supported.
20401@item sb
20402Enable the Armv8-a Speculation Barrier instruction. This option is only to
20403enable the extension at the assembler level and does not affect code
20404generation. This option is enabled by default for @option{-march=armv8.5-a}.
20405@item ssbs
20406Enable the Armv8-a Speculative Store Bypass Safe instruction. This option
20407is only to enable the extension at the assembler level and does not affect code
20408generation. This option is enabled by default for @option{-march=armv8.5-a}.
20409@item predres
20410Enable the Armv8-a Execution and Data Prediction Restriction instructions.
20411This option is only to enable the extension at the assembler level and does
20412not affect code generation. This option is enabled by default for
20413@option{-march=armv8.5-a}.
20414@item sve2
20415Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE
20416instructions.
20417@item sve2-bitperm
20418Enable SVE2 bitperm instructions. This also enables SVE2 instructions.
20419@item sve2-sm4
20420Enable SVE2 sm4 instructions. This also enables SVE2 instructions.
20421@item sve2-aes
20422Enable SVE2 aes instructions. This also enables SVE2 instructions.
20423@item sve2-sha3
20424Enable SVE2 sha3 instructions. This also enables SVE2 instructions.
20425@item tme
20426Enable the Transactional Memory Extension.
20427@item i8mm
20428Enable 8-bit Integer Matrix Multiply instructions. This also enables
20429Advanced SIMD and floating-point instructions. This option is enabled by
20430default for @option{-march=armv8.6-a}. Use of this option with architectures
20431prior to Armv8.2-A is not supported.
20432@item f32mm
20433Enable 32-bit Floating point Matrix Multiply instructions. This also enables
20434SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20435not supported.
20436@item f64mm
20437Enable 64-bit Floating point Matrix Multiply instructions. This also enables
20438SVE instructions. Use of this option with architectures prior to Armv8.2-A is
20439not supported.
20440@item bf16
20441Enable brain half-precision floating-point instructions. This also enables
20442Advanced SIMD and floating-point instructions. This option is enabled by
20443default for @option{-march=armv8.6-a}. Use of this option with architectures
20444prior to Armv8.2-A is not supported.
20445@item ls64
20446Enable the 64-byte atomic load and store instructions for accelerators.
20447This option is enabled by default for @option{-march=armv8.7-a}.
20448@item mops
20449Enable the instructions to accelerate memory operations like @code{memcpy},
20450@code{memmove}, @code{memset}. This option is enabled by default for
20451@option{-march=armv8.8-a}
20452@item flagm
20453Enable the Flag Manipulation instructions Extension.
20454@item pauth
20455Enable the Pointer Authentication Extension.
d758d190
KT
20456@item cssc
20457Enable the Common Short Sequence Compression instructions.
d77de738
ML
20458
20459@end table
20460
20461Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd},
20462which implies @option{fp}.
20463Conversely, @option{nofp} implies @option{nosimd}, which implies
20464@option{nocrypto}, @option{noaes} and @option{nosha2}.
20465
20466@node Adapteva Epiphany Options
20467@subsection Adapteva Epiphany Options
20468
20469These @samp{-m} options are defined for Adapteva Epiphany:
20470
20471@table @gcctabopt
20472@item -mhalf-reg-file
20473@opindex mhalf-reg-file
20474Don't allocate any register in the range @code{r32}@dots{}@code{r63}.
20475That allows code to run on hardware variants that lack these registers.
20476
20477@item -mprefer-short-insn-regs
20478@opindex mprefer-short-insn-regs
20479Preferentially allocate registers that allow short instruction generation.
20480This can result in increased instruction count, so this may either reduce or
20481increase overall code size.
20482
20483@item -mbranch-cost=@var{num}
20484@opindex mbranch-cost
20485Set the cost of branches to roughly @var{num} ``simple'' instructions.
20486This cost is only a heuristic and is not guaranteed to produce
20487consistent results across releases.
20488
20489@item -mcmove
20490@opindex mcmove
20491Enable the generation of conditional moves.
20492
20493@item -mnops=@var{num}
20494@opindex mnops
20495Emit @var{num} NOPs before every other generated instruction.
20496
20497@item -mno-soft-cmpsf
20498@opindex mno-soft-cmpsf
20499@opindex msoft-cmpsf
20500For single-precision floating-point comparisons, emit an @code{fsub} instruction
20501and test the flags. This is faster than a software comparison, but can
20502get incorrect results in the presence of NaNs, or when two different small
20503numbers are compared such that their difference is calculated as zero.
20504The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant,
20505software comparisons.
20506
20507@item -mstack-offset=@var{num}
20508@opindex mstack-offset
20509Set the offset between the top of the stack and the stack pointer.
20510E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7}
20511can be used by leaf functions without stack allocation.
20512Values other than @samp{8} or @samp{16} are untested and unlikely to work.
20513Note also that this option changes the ABI; compiling a program with a
20514different stack offset than the libraries have been compiled with
20515generally does not work.
20516This option can be useful if you want to evaluate if a different stack
20517offset would give you better code, but to actually use a different stack
20518offset to build working programs, it is recommended to configure the
20519toolchain with the appropriate @option{--with-stack-offset=@var{num}} option.
20520
20521@item -mno-round-nearest
20522@opindex mno-round-nearest
20523@opindex mround-nearest
20524Make the scheduler assume that the rounding mode has been set to
20525truncating. The default is @option{-mround-nearest}.
20526
20527@item -mlong-calls
20528@opindex mlong-calls
20529If not otherwise specified by an attribute, assume all calls might be beyond
20530the offset range of the @code{b} / @code{bl} instructions, and therefore load the
20531function address into a register before performing a (otherwise direct) call.
20532This is the default.
20533
20534@item -mshort-calls
20535@opindex short-calls
20536If not otherwise specified by an attribute, assume all direct calls are
20537in the range of the @code{b} / @code{bl} instructions, so use these instructions
20538for direct calls. The default is @option{-mlong-calls}.
20539
20540@item -msmall16
20541@opindex msmall16
20542Assume addresses can be loaded as 16-bit unsigned values. This does not
20543apply to function addresses for which @option{-mlong-calls} semantics
20544are in effect.
20545
20546@item -mfp-mode=@var{mode}
20547@opindex mfp-mode
20548Set the prevailing mode of the floating-point unit.
20549This determines the floating-point mode that is provided and expected
20550at function call and return time. Making this mode match the mode you
20551predominantly need at function start can make your programs smaller and
20552faster by avoiding unnecessary mode switches.
20553
20554@var{mode} can be set to one the following values:
20555
20556@table @samp
20557@item caller
20558Any mode at function entry is valid, and retained or restored when
20559the function returns, and when it calls other functions.
20560This mode is useful for compiling libraries or other compilation units
20561you might want to incorporate into different programs with different
20562prevailing FPU modes, and the convenience of being able to use a single
20563object file outweighs the size and speed overhead for any extra
20564mode switching that might be needed, compared with what would be needed
20565with a more specific choice of prevailing FPU mode.
20566
20567@item truncate
20568This is the mode used for floating-point calculations with
20569truncating (i.e.@: round towards zero) rounding mode. That includes
20570conversion from floating point to integer.
20571
20572@item round-nearest
20573This is the mode used for floating-point calculations with
20574round-to-nearest-or-even rounding mode.
20575
20576@item int
20577This is the mode used to perform integer calculations in the FPU, e.g.@:
20578integer multiply, or integer multiply-and-accumulate.
20579@end table
20580
20581The default is @option{-mfp-mode=caller}
20582
20583@item -mno-split-lohi
20584@itemx -mno-postinc
20585@itemx -mno-postmodify
20586@opindex mno-split-lohi
20587@opindex msplit-lohi
20588@opindex mno-postinc
20589@opindex mpostinc
20590@opindex mno-postmodify
20591@opindex mpostmodify
20592Code generation tweaks that disable, respectively, splitting of 32-bit
20593loads, generation of post-increment addresses, and generation of
20594post-modify addresses. The defaults are @option{msplit-lohi},
20595@option{-mpost-inc}, and @option{-mpost-modify}.
20596
20597@item -mnovect-double
20598@opindex mno-vect-double
20599@opindex mvect-double
20600Change the preferred SIMD mode to SImode. The default is
20601@option{-mvect-double}, which uses DImode as preferred SIMD mode.
20602
20603@item -max-vect-align=@var{num}
20604@opindex max-vect-align
20605The maximum alignment for SIMD vector mode types.
20606@var{num} may be 4 or 8. The default is 8.
20607Note that this is an ABI change, even though many library function
20608interfaces are unaffected if they don't use SIMD vector modes
20609in places that affect size and/or alignment of relevant types.
20610
20611@item -msplit-vecmove-early
20612@opindex msplit-vecmove-early
20613Split vector moves into single word moves before reload. In theory this
20614can give better register allocation, but so far the reverse seems to be
20615generally the case.
20616
20617@item -m1reg-@var{reg}
20618@opindex m1reg-
20619Specify a register to hold the constant @minus{}1, which makes loading small negative
20620constants and certain bitmasks faster.
20621Allowable values for @var{reg} are @samp{r43} and @samp{r63},
20622which specify use of that register as a fixed register,
20623and @samp{none}, which means that no register is used for this
20624purpose. The default is @option{-m1reg-none}.
20625
20626@end table
20627
20628@node AMD GCN Options
20629@subsection AMD GCN Options
20630@cindex AMD GCN Options
20631
20632These options are defined specifically for the AMD GCN port.
20633
20634@table @gcctabopt
20635
20636@item -march=@var{gpu}
20637@opindex march
20638@itemx -mtune=@var{gpu}
20639@opindex mtune
20640Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu}
20641are
20642
20643@table @samp
20644@item fiji
20645Compile for GCN3 Fiji devices (gfx803).
20646
20647@item gfx900
20648Compile for GCN5 Vega 10 devices (gfx900).
20649
20650@item gfx906
20651Compile for GCN5 Vega 20 devices (gfx906).
20652
20653@item gfx908
20654Compile for CDNA1 Instinct MI100 series devices (gfx908).
20655
20656@item gfx90a
20657Compile for CDNA2 Instinct MI200 series devices (gfx90a).
20658
20659@end table
20660
20661@item -msram-ecc=on
20662@itemx -msram-ecc=off
20663@itemx -msram-ecc=any
20664@opindex msram-ecc
20665Compile binaries suitable for devices with the SRAM-ECC feature enabled,
20666disabled, or either mode. This feature can be enabled per-process on some
20667devices. The compiled code must match the device mode. The default is
20668@samp{any}, for devices that support it.
20669
20670@item -mstack-size=@var{bytes}
20671@opindex mstack-size
20672Specify how many @var{bytes} of stack space will be requested for each GPU
20673thread (wave-front). Beware that there may be many threads and limited memory
20674available. The size of the stack allocation may also have an impact on
20675run-time performance. The default is 32KB when using OpenACC or OpenMP, and
206761MB otherwise.
20677
20678@item -mxnack
20679@opindex mxnack
20680Compile binaries suitable for devices with the XNACK feature enabled. Some
20681devices always require XNACK and some allow the user to configure XNACK. The
20682compiled code must match the device mode. The default is @samp{-mno-xnack}.
20683At present this option is a placeholder for support that is not yet
20684implemented.
20685
20686@end table
20687
20688@node ARC Options
20689@subsection ARC Options
20690@cindex ARC options
20691
20692The following options control the architecture variant for which code
20693is being compiled:
20694
20695@c architecture variants
20696@table @gcctabopt
20697
20698@item -mbarrel-shifter
20699@opindex mbarrel-shifter
20700Generate instructions supported by barrel shifter. This is the default
20701unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect.
20702
20703@item -mjli-always
20704@opindex mjli-always
20705Force to call a function using jli_s instruction. This option is
20706valid only for ARCv2 architecture.
20707
20708@item -mcpu=@var{cpu}
20709@opindex mcpu
20710Set architecture type, register usage, and instruction scheduling
20711parameters for @var{cpu}. There are also shortcut alias options
20712available for backward compatibility and convenience. Supported
20713values for @var{cpu} are
20714
20715@table @samp
20716@opindex mA6
20717@opindex mARC600
20718@item arc600
20719Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}.
20720
20721@item arc601
20722@opindex mARC601
20723Compile for ARC601. Alias: @option{-mARC601}.
20724
20725@item arc700
20726@opindex mA7
20727@opindex mARC700
20728Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}.
20729This is the default when configured with @option{--with-cpu=arc700}@.
20730
20731@item arcem
20732Compile for ARC EM.
20733
20734@item archs
20735Compile for ARC HS.
20736
20737@item em
20738Compile for ARC EM CPU with no hardware extensions.
20739
20740@item em4
20741Compile for ARC EM4 CPU.
20742
20743@item em4_dmips
20744Compile for ARC EM4 DMIPS CPU.
20745
20746@item em4_fpus
20747Compile for ARC EM4 DMIPS CPU with the single-precision floating-point
20748extension.
20749
20750@item em4_fpuda
20751Compile for ARC EM4 DMIPS CPU with single-precision floating-point and
20752double assist instructions.
20753
20754@item hs
20755Compile for ARC HS CPU with no hardware extensions except the atomic
20756instructions.
20757
20758@item hs34
20759Compile for ARC HS34 CPU.
20760
20761@item hs38
20762Compile for ARC HS38 CPU.
20763
20764@item hs38_linux
20765Compile for ARC HS38 CPU with all hardware extensions on.
20766
20767@item hs4x
20768Compile for ARC HS4x CPU.
20769
20770@item hs4xd
20771Compile for ARC HS4xD CPU.
20772
20773@item hs4x_rel31
20774Compile for ARC HS4x CPU release 3.10a.
20775
20776@item arc600_norm
20777Compile for ARC 600 CPU with @code{norm} instructions enabled.
20778
20779@item arc600_mul32x16
20780Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply
20781instructions enabled.
20782
20783@item arc600_mul64
20784Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family
20785instructions enabled.
20786
20787@item arc601_norm
20788Compile for ARC 601 CPU with @code{norm} instructions enabled.
20789
20790@item arc601_mul32x16
20791Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply
20792instructions enabled.
20793
20794@item arc601_mul64
20795Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family
20796instructions enabled.
20797
20798@item nps400
20799Compile for ARC 700 on NPS400 chip.
20800
20801@item em_mini
20802Compile for ARC EM minimalist configuration featuring reduced register
20803set.
20804
20805@end table
20806
20807@item -mdpfp
20808@opindex mdpfp
20809@itemx -mdpfp-compact
20810@opindex mdpfp-compact
20811Generate double-precision FPX instructions, tuned for the compact
20812implementation.
20813
20814@item -mdpfp-fast
20815@opindex mdpfp-fast
20816Generate double-precision FPX instructions, tuned for the fast
20817implementation.
20818
20819@item -mno-dpfp-lrsr
20820@opindex mno-dpfp-lrsr
20821Disable @code{lr} and @code{sr} instructions from using FPX extension
20822aux registers.
20823
20824@item -mea
20825@opindex mea
20826Generate extended arithmetic instructions. Currently only
20827@code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are
20828supported. Only valid for @option{-mcpu=ARC700}.
20829
20830@item -mno-mpy
20831@opindex mno-mpy
20832@opindex mmpy
20833Do not generate @code{mpy}-family instructions for ARC700. This option is
20834deprecated.
20835
20836@item -mmul32x16
20837@opindex mmul32x16
20838Generate 32x16-bit multiply and multiply-accumulate instructions.
20839
20840@item -mmul64
20841@opindex mmul64
20842Generate @code{mul64} and @code{mulu64} instructions.
20843Only valid for @option{-mcpu=ARC600}.
20844
20845@item -mnorm
20846@opindex mnorm
20847Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700}
20848is in effect.
20849
20850@item -mspfp
20851@opindex mspfp
20852@itemx -mspfp-compact
20853@opindex mspfp-compact
20854Generate single-precision FPX instructions, tuned for the compact
20855implementation.
20856
20857@item -mspfp-fast
20858@opindex mspfp-fast
20859Generate single-precision FPX instructions, tuned for the fast
20860implementation.
20861
20862@item -msimd
20863@opindex msimd
20864Enable generation of ARC SIMD instructions via target-specific
20865builtins. Only valid for @option{-mcpu=ARC700}.
20866
20867@item -msoft-float
20868@opindex msoft-float
20869This option ignored; it is provided for compatibility purposes only.
20870Software floating-point code is emitted by default, and this default
20871can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or
20872@option{-mspfp-fast} for single precision, and @option{-mdpfp},
20873@option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision.
20874
20875@item -mswap
20876@opindex mswap
20877Generate @code{swap} instructions.
20878
20879@item -matomic
20880@opindex matomic
20881This enables use of the locked load/store conditional extension to implement
20882atomic memory built-in functions. Not available for ARC 6xx or ARC
20883EM cores.
20884
20885@item -mdiv-rem
20886@opindex mdiv-rem
20887Enable @code{div} and @code{rem} instructions for ARCv2 cores.
20888
20889@item -mcode-density
20890@opindex mcode-density
20891Enable code density instructions for ARC EM.
20892This option is on by default for ARC HS.
20893
20894@item -mll64
20895@opindex mll64
20896Enable double load/store operations for ARC HS cores.
20897
20898@item -mtp-regno=@var{regno}
20899@opindex mtp-regno
20900Specify thread pointer register number.
20901
20902@item -mmpy-option=@var{multo}
20903@opindex mmpy-option
20904Compile ARCv2 code with a multiplier design option. You can specify
20905the option using either a string or numeric value for @var{multo}.
20906@samp{wlh1} is the default value. The recognized values are:
20907
20908@table @samp
20909@item 0
20910@itemx none
20911No multiplier available.
20912
20913@item 1
20914@itemx w
2091516x16 multiplier, fully pipelined.
20916The following instructions are enabled: @code{mpyw} and @code{mpyuw}.
20917
20918@item 2
20919@itemx wlh1
2092032x32 multiplier, fully
20921pipelined (1 stage). The following instructions are additionally
20922enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20923
20924@item 3
20925@itemx wlh2
2092632x32 multiplier, fully pipelined
20927(2 stages). The following instructions are additionally enabled: @code{mpy},
20928@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20929
20930@item 4
20931@itemx wlh3
20932Two 16x16 multipliers, blocking,
20933sequential. The following instructions are additionally enabled: @code{mpy},
20934@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20935
20936@item 5
20937@itemx wlh4
20938One 16x16 multiplier, blocking,
20939sequential. The following instructions are additionally enabled: @code{mpy},
20940@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20941
20942@item 6
20943@itemx wlh5
20944One 32x4 multiplier, blocking,
20945sequential. The following instructions are additionally enabled: @code{mpy},
20946@code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}.
20947
20948@item 7
20949@itemx plus_dmpy
20950ARC HS SIMD support.
20951
20952@item 8
20953@itemx plus_macd
20954ARC HS SIMD support.
20955
20956@item 9
20957@itemx plus_qmacw
20958ARC HS SIMD support.
20959
20960@end table
20961
20962This option is only available for ARCv2 cores@.
20963
20964@item -mfpu=@var{fpu}
20965@opindex mfpu
20966Enables support for specific floating-point hardware extensions for ARCv2
20967cores. Supported values for @var{fpu} are:
20968
20969@table @samp
20970
20971@item fpus
20972Enables support for single-precision floating-point hardware
20973extensions@.
20974
20975@item fpud
20976Enables support for double-precision floating-point hardware
20977extensions. The single-precision floating-point extension is also
20978enabled. Not available for ARC EM@.
20979
20980@item fpuda
20981Enables support for double-precision floating-point hardware
20982extensions using double-precision assist instructions. The single-precision
20983floating-point extension is also enabled. This option is
20984only available for ARC EM@.
20985
20986@item fpuda_div
20987Enables support for double-precision floating-point hardware
20988extensions using double-precision assist instructions.
20989The single-precision floating-point, square-root, and divide
20990extensions are also enabled. This option is
20991only available for ARC EM@.
20992
20993@item fpuda_fma
20994Enables support for double-precision floating-point hardware
20995extensions using double-precision assist instructions.
20996The single-precision floating-point and fused multiply and add
20997hardware extensions are also enabled. This option is
20998only available for ARC EM@.
20999
21000@item fpuda_all
21001Enables support for double-precision floating-point hardware
21002extensions using double-precision assist instructions.
21003All single-precision floating-point hardware extensions are also
21004enabled. This option is only available for ARC EM@.
21005
21006@item fpus_div
21007Enables support for single-precision floating-point, square-root and divide
21008hardware extensions@.
21009
21010@item fpud_div
21011Enables support for double-precision floating-point, square-root and divide
21012hardware extensions. This option
21013includes option @samp{fpus_div}. Not available for ARC EM@.
21014
21015@item fpus_fma
21016Enables support for single-precision floating-point and
21017fused multiply and add hardware extensions@.
21018
21019@item fpud_fma
21020Enables support for double-precision floating-point and
21021fused multiply and add hardware extensions. This option
21022includes option @samp{fpus_fma}. Not available for ARC EM@.
21023
21024@item fpus_all
21025Enables support for all single-precision floating-point hardware
21026extensions@.
21027
21028@item fpud_all
21029Enables support for all single- and double-precision floating-point
21030hardware extensions. Not available for ARC EM@.
21031
21032@end table
21033
21034@item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count}
21035@opindex mirq-ctrl-saved
21036Specifies general-purposes registers that the processor automatically
21037saves/restores on interrupt entry and exit. @var{register-range} is
21038specified as two registers separated by a dash. The register range
21039always starts with @code{r0}, the upper limit is @code{fp} register.
21040@var{blink} and @var{lp_count} are optional. This option is only
21041valid for ARC EM and ARC HS cores.
21042
21043@item -mrgf-banked-regs=@var{number}
21044@opindex mrgf-banked-regs
21045Specifies the number of registers replicated in second register bank
21046on entry to fast interrupt. Fast interrupts are interrupts with the
21047highest priority level P0. These interrupts save only PC and STATUS32
21048registers to avoid memory transactions during interrupt entry and exit
21049sequences. Use this option when you are using fast interrupts in an
21050ARC V2 family processor. Permitted values are 4, 8, 16, and 32.
21051
21052@item -mlpc-width=@var{width}
21053@opindex mlpc-width
21054Specify the width of the @code{lp_count} register. Valid values for
21055@var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is
21056fixed to 32 bits. If the width is less than 32, the compiler does not
21057attempt to transform loops in your program to use the zero-delay loop
21058mechanism unless it is known that the @code{lp_count} register can
21059hold the required loop-counter value. Depending on the width
21060specified, the compiler and run-time library might continue to use the
21061loop mechanism for various needs. This option defines macro
21062@code{__ARC_LPC_WIDTH__} with the value of @var{width}.
21063
21064@item -mrf16
21065@opindex mrf16
21066This option instructs the compiler to generate code for a 16-entry
21067register file. This option defines the @code{__ARC_RF16__}
21068preprocessor macro.
21069
21070@item -mbranch-index
21071@opindex mbranch-index
21072Enable use of @code{bi} or @code{bih} instructions to implement jump
21073tables.
21074
21075@end table
21076
21077The following options are passed through to the assembler, and also
21078define preprocessor macro symbols.
21079
21080@c Flags used by the assembler, but for which we define preprocessor
21081@c macro symbols as well.
21082@table @gcctabopt
21083@item -mdsp-packa
21084@opindex mdsp-packa
21085Passed down to the assembler to enable the DSP Pack A extensions.
21086Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is
21087deprecated.
21088
21089@item -mdvbf
21090@opindex mdvbf
21091Passed down to the assembler to enable the dual Viterbi butterfly
21092extension. Also sets the preprocessor symbol @code{__Xdvbf}. This
21093option is deprecated.
21094
21095@c ARC700 4.10 extension instruction
21096@item -mlock
21097@opindex mlock
21098Passed down to the assembler to enable the locked load/store
21099conditional extension. Also sets the preprocessor symbol
21100@code{__Xlock}.
21101
21102@item -mmac-d16
21103@opindex mmac-d16
21104Passed down to the assembler. Also sets the preprocessor symbol
21105@code{__Xxmac_d16}. This option is deprecated.
21106
21107@item -mmac-24
21108@opindex mmac-24
21109Passed down to the assembler. Also sets the preprocessor symbol
21110@code{__Xxmac_24}. This option is deprecated.
21111
21112@c ARC700 4.10 extension instruction
21113@item -mrtsc
21114@opindex mrtsc
21115Passed down to the assembler to enable the 64-bit time-stamp counter
21116extension instruction. Also sets the preprocessor symbol
21117@code{__Xrtsc}. This option is deprecated.
21118
21119@c ARC700 4.10 extension instruction
21120@item -mswape
21121@opindex mswape
21122Passed down to the assembler to enable the swap byte ordering
21123extension instruction. Also sets the preprocessor symbol
21124@code{__Xswape}.
21125
21126@item -mtelephony
21127@opindex mtelephony
21128Passed down to the assembler to enable dual- and single-operand
21129instructions for telephony. Also sets the preprocessor symbol
21130@code{__Xtelephony}. This option is deprecated.
21131
21132@item -mxy
21133@opindex mxy
21134Passed down to the assembler to enable the XY memory extension. Also
21135sets the preprocessor symbol @code{__Xxy}.
21136
21137@end table
21138
21139The following options control how the assembly code is annotated:
21140
21141@c Assembly annotation options
21142@table @gcctabopt
21143@item -misize
21144@opindex misize
21145Annotate assembler instructions with estimated addresses.
21146
21147@item -mannotate-align
21148@opindex mannotate-align
21149Explain what alignment considerations lead to the decision to make an
21150instruction short or long.
21151
21152@end table
21153
21154The following options are passed through to the linker:
21155
21156@c options passed through to the linker
21157@table @gcctabopt
21158@item -marclinux
21159@opindex marclinux
21160Passed through to the linker, to specify use of the @code{arclinux} emulation.
21161This option is enabled by default in tool chains built for
21162@w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets
21163when profiling is not requested.
21164
21165@item -marclinux_prof
21166@opindex marclinux_prof
21167Passed through to the linker, to specify use of the
21168@code{arclinux_prof} emulation. This option is enabled by default in
21169tool chains built for @w{@code{arc-linux-uclibc}} and
21170@w{@code{arceb-linux-uclibc}} targets when profiling is requested.
21171
21172@end table
21173
21174The following options control the semantics of generated code:
21175
21176@c semantically relevant code generation options
21177@table @gcctabopt
21178@item -mlong-calls
21179@opindex mlong-calls
21180Generate calls as register indirect calls, thus providing access
21181to the full 32-bit address range.
21182
21183@item -mmedium-calls
21184@opindex mmedium-calls
21185Don't use less than 25-bit addressing range for calls, which is the
21186offset available for an unconditional branch-and-link
21187instruction. Conditional execution of function calls is suppressed, to
21188allow use of the 25-bit range, rather than the 21-bit range with
21189conditional branch-and-link. This is the default for tool chains built
21190for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets.
21191
21192@item -G @var{num}
21193@opindex G
21194Put definitions of externally-visible data in a small data section if
21195that data is no bigger than @var{num} bytes. The default value of
21196@var{num} is 4 for any ARC configuration, or 8 when we have double
21197load/store operations.
21198
21199@item -mno-sdata
21200@opindex mno-sdata
21201@opindex msdata
21202Do not generate sdata references. This is the default for tool chains
21203built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}}
21204targets.
21205
21206@item -mvolatile-cache
21207@opindex mvolatile-cache
21208Use ordinarily cached memory accesses for volatile references. This is the
21209default.
21210
21211@item -mno-volatile-cache
21212@opindex mno-volatile-cache
21213@opindex mvolatile-cache
21214Enable cache bypass for volatile references.
21215
21216@end table
21217
21218The following options fine tune code generation:
21219@c code generation tuning options
21220@table @gcctabopt
21221@item -malign-call
21222@opindex malign-call
21223Does nothing. Preserved for backward compatibility.
21224
21225@item -mauto-modify-reg
21226@opindex mauto-modify-reg
21227Enable the use of pre/post modify with register displacement.
21228
21229@item -mbbit-peephole
21230@opindex mbbit-peephole
21231Enable bbit peephole2.
21232
21233@item -mno-brcc
21234@opindex mno-brcc
21235This option disables a target-specific pass in @file{arc_reorg} to
21236generate compare-and-branch (@code{br@var{cc}}) instructions.
21237It has no effect on
21238generation of these instructions driven by the combiner pass.
21239
21240@item -mcase-vector-pcrel
21241@opindex mcase-vector-pcrel
21242Use PC-relative switch case tables to enable case table shortening.
21243This is the default for @option{-Os}.
21244
21245@item -mcompact-casesi
21246@opindex mcompact-casesi
21247Enable compact @code{casesi} pattern. This is the default for @option{-Os},
21248and only available for ARCv1 cores. This option is deprecated.
21249
21250@item -mno-cond-exec
21251@opindex mno-cond-exec
21252Disable the ARCompact-specific pass to generate conditional
21253execution instructions.
21254
21255Due to delay slot scheduling and interactions between operand numbers,
21256literal sizes, instruction lengths, and the support for conditional execution,
21257the target-independent pass to generate conditional execution is often lacking,
21258so the ARC port has kept a special pass around that tries to find more
21259conditional execution generation opportunities after register allocation,
21260branch shortening, and delay slot scheduling have been done. This pass
21261generally, but not always, improves performance and code size, at the cost of
21262extra compilation time, which is why there is an option to switch it off.
21263If you have a problem with call instructions exceeding their allowable
21264offset range because they are conditionalized, you should consider using
21265@option{-mmedium-calls} instead.
21266
21267@item -mearly-cbranchsi
21268@opindex mearly-cbranchsi
21269Enable pre-reload use of the @code{cbranchsi} pattern.
21270
21271@item -mexpand-adddi
21272@opindex mexpand-adddi
21273Expand @code{adddi3} and @code{subdi3} at RTL generation time into
21274@code{add.f}, @code{adc} etc. This option is deprecated.
21275
21276@item -mindexed-loads
21277@opindex mindexed-loads
21278Enable the use of indexed loads. This can be problematic because some
21279optimizers then assume that indexed stores exist, which is not
21280the case.
21281
21282@item -mlra
21283@opindex mlra
21284Enable Local Register Allocation. This is still experimental for ARC,
21285so by default the compiler uses standard reload
21286(i.e.@: @option{-mno-lra}).
21287
21288@item -mlra-priority-none
21289@opindex mlra-priority-none
21290Don't indicate any priority for target registers.
21291
21292@item -mlra-priority-compact
21293@opindex mlra-priority-compact
21294Indicate target register priority for r0..r3 / r12..r15.
21295
21296@item -mlra-priority-noncompact
21297@opindex mlra-priority-noncompact
21298Reduce target register priority for r0..r3 / r12..r15.
21299
21300@item -mmillicode
21301@opindex mmillicode
21302When optimizing for size (using @option{-Os}), prologues and epilogues
21303that have to save or restore a large number of registers are often
21304shortened by using call to a special function in libgcc; this is
21305referred to as a @emph{millicode} call. As these calls can pose
21306performance issues, and/or cause linking issues when linking in a
21307nonstandard way, this option is provided to turn on or off millicode
21308call generation.
21309
21310@item -mcode-density-frame
21311@opindex mcode-density-frame
21312This option enable the compiler to emit @code{enter} and @code{leave}
21313instructions. These instructions are only valid for CPUs with
21314code-density feature.
21315
21316@item -mmixed-code
21317@opindex mmixed-code
21318Does nothing. Preserved for backward compatibility.
21319
21320@item -mq-class
21321@opindex mq-class
21322Ths option is deprecated. Enable @samp{q} instruction alternatives.
21323This is the default for @option{-Os}.
21324
21325@item -mRcq
21326@opindex mRcq
21327Does nothing. Preserved for backward compatibility.
21328
21329@item -mRcw
21330@opindex mRcw
21331Does nothing. Preserved for backward compatibility.
21332
21333@item -msize-level=@var{level}
21334@opindex msize-level
21335Fine-tune size optimization with regards to instruction lengths and alignment.
21336The recognized values for @var{level} are:
21337@table @samp
21338@item 0
21339No size optimization. This level is deprecated and treated like @samp{1}.
21340
21341@item 1
21342Short instructions are used opportunistically.
21343
21344@item 2
21345In addition, alignment of loops and of code after barriers are dropped.
21346
21347@item 3
21348In addition, optional data alignment is dropped, and the option @option{Os} is enabled.
21349
21350@end table
21351
21352This defaults to @samp{3} when @option{-Os} is in effect. Otherwise,
21353the behavior when this is not set is equivalent to level @samp{1}.
21354
21355@item -mtune=@var{cpu}
21356@opindex mtune
21357Set instruction scheduling parameters for @var{cpu}, overriding any implied
21358by @option{-mcpu=}.
21359
21360Supported values for @var{cpu} are
21361
21362@table @samp
21363@item ARC600
21364Tune for ARC600 CPU.
21365
21366@item ARC601
21367Tune for ARC601 CPU.
21368
21369@item ARC700
21370Tune for ARC700 CPU with standard multiplier block.
21371
21372@item ARC700-xmac
21373Tune for ARC700 CPU with XMAC block.
21374
21375@item ARC725D
21376Tune for ARC725D CPU.
21377
21378@item ARC750D
21379Tune for ARC750D CPU.
21380
21381@item core3
21382Tune for ARCv2 core3 type CPU. This option enable usage of
21383@code{dbnz} instruction.
21384
21385@item release31a
21386Tune for ARC4x release 3.10a.
21387
21388@end table
21389
21390@item -mmultcost=@var{num}
21391@opindex mmultcost
21392Cost to assume for a multiply instruction, with @samp{4} being equal to a
21393normal instruction.
21394
21395@item -munalign-prob-threshold=@var{probability}
21396@opindex munalign-prob-threshold
21397Does nothing. Preserved for backward compatibility.
21398
21399@end table
21400
21401The following options are maintained for backward compatibility, but
21402are now deprecated and will be removed in a future release:
21403
21404@c Deprecated options
21405@table @gcctabopt
21406
21407@item -margonaut
21408@opindex margonaut
21409Obsolete FPX.
21410
21411@item -mbig-endian
21412@opindex mbig-endian
21413@itemx -EB
21414@opindex EB
21415Compile code for big-endian targets. Use of these options is now
21416deprecated. Big-endian code is supported by configuring GCC to build
21417@w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets,
21418for which big endian is the default.
21419
21420@item -mlittle-endian
21421@opindex mlittle-endian
21422@itemx -EL
21423@opindex EL
21424Compile code for little-endian targets. Use of these options is now
21425deprecated. Little-endian code is supported by configuring GCC to build
21426@w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets,
21427for which little endian is the default.
21428
21429@item -mbarrel_shifter
21430@opindex mbarrel_shifter
21431Replaced by @option{-mbarrel-shifter}.
21432
21433@item -mdpfp_compact
21434@opindex mdpfp_compact
21435Replaced by @option{-mdpfp-compact}.
21436
21437@item -mdpfp_fast
21438@opindex mdpfp_fast
21439Replaced by @option{-mdpfp-fast}.
21440
21441@item -mdsp_packa
21442@opindex mdsp_packa
21443Replaced by @option{-mdsp-packa}.
21444
21445@item -mEA
21446@opindex mEA
21447Replaced by @option{-mea}.
21448
21449@item -mmac_24
21450@opindex mmac_24
21451Replaced by @option{-mmac-24}.
21452
21453@item -mmac_d16
21454@opindex mmac_d16
21455Replaced by @option{-mmac-d16}.
21456
21457@item -mspfp_compact
21458@opindex mspfp_compact
21459Replaced by @option{-mspfp-compact}.
21460
21461@item -mspfp_fast
21462@opindex mspfp_fast
21463Replaced by @option{-mspfp-fast}.
21464
21465@item -mtune=@var{cpu}
21466@opindex mtune
21467Values @samp{arc600}, @samp{arc601}, @samp{arc700} and
21468@samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600},
21469@samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively.
21470
21471@item -multcost=@var{num}
21472@opindex multcost
21473Replaced by @option{-mmultcost}.
21474
21475@end table
21476
21477@node ARM Options
21478@subsection ARM Options
21479@cindex ARM options
21480
21481These @samp{-m} options are defined for the ARM port:
21482
21483@table @gcctabopt
21484@item -mabi=@var{name}
21485@opindex mabi
21486Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu},
21487@samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}.
21488
21489@item -mapcs-frame
21490@opindex mapcs-frame
21491Generate a stack frame that is compliant with the ARM Procedure Call
21492Standard for all functions, even if this is not strictly necessary for
21493correct execution of the code. Specifying @option{-fomit-frame-pointer}
21494with this option causes the stack frames not to be generated for
21495leaf functions. The default is @option{-mno-apcs-frame}.
21496This option is deprecated.
21497
21498@item -mapcs
21499@opindex mapcs
21500This is a synonym for @option{-mapcs-frame} and is deprecated.
21501
21502@ignore
21503@c not currently implemented
21504@item -mapcs-stack-check
21505@opindex mapcs-stack-check
21506Generate code to check the amount of stack space available upon entry to
21507every function (that actually uses some stack space). If there is
21508insufficient space available then either the function
21509@code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is
21510called, depending upon the amount of stack space required. The runtime
21511system is required to provide these functions. The default is
21512@option{-mno-apcs-stack-check}, since this produces smaller code.
21513
21514@c not currently implemented
21515@item -mapcs-reentrant
21516@opindex mapcs-reentrant
21517Generate reentrant, position-independent code. The default is
21518@option{-mno-apcs-reentrant}.
21519@end ignore
21520
21521@item -mthumb-interwork
21522@opindex mthumb-interwork
21523Generate code that supports calling between the ARM and Thumb
21524instruction sets. Without this option, on pre-v5 architectures, the
21525two instruction sets cannot be reliably used inside one program. The
21526default is @option{-mno-thumb-interwork}, since slightly larger code
21527is generated when @option{-mthumb-interwork} is specified. In AAPCS
21528configurations this option is meaningless.
21529
21530@item -mno-sched-prolog
21531@opindex mno-sched-prolog
21532@opindex msched-prolog
21533Prevent the reordering of instructions in the function prologue, or the
21534merging of those instruction with the instructions in the function's
21535body. This means that all functions start with a recognizable set
21536of instructions (or in fact one of a choice from a small set of
21537different function prologues), and this information can be used to
21538locate the start of functions inside an executable piece of code. The
21539default is @option{-msched-prolog}.
21540
21541@item -mfloat-abi=@var{name}
21542@opindex mfloat-abi
21543Specifies which floating-point ABI to use. Permissible values
21544are: @samp{soft}, @samp{softfp} and @samp{hard}.
21545
21546Specifying @samp{soft} causes GCC to generate output containing
21547library calls for floating-point operations.
21548@samp{softfp} allows the generation of code using hardware floating-point
21549instructions, but still uses the soft-float calling conventions.
21550@samp{hard} allows generation of floating-point instructions
21551and uses FPU-specific calling conventions.
21552
21553The default depends on the specific target configuration. Note that
21554the hard-float and soft-float ABIs are not link-compatible; you must
21555compile your entire program with the same ABI, and link with a
21556compatible set of libraries.
21557
21558@item -mgeneral-regs-only
21559@opindex mgeneral-regs-only
21560Generate code which uses only the general-purpose registers. This will prevent
21561the compiler from using floating-point and Advanced SIMD registers but will not
21562impose any restrictions on the assembler.
21563
21564@item -mlittle-endian
21565@opindex mlittle-endian
21566Generate code for a processor running in little-endian mode. This is
21567the default for all standard configurations.
21568
21569@item -mbig-endian
21570@opindex mbig-endian
21571Generate code for a processor running in big-endian mode; the default is
21572to compile code for a little-endian processor.
21573
21574@item -mbe8
21575@itemx -mbe32
21576@opindex mbe8
21577When linking a big-endian image select between BE8 and BE32 formats.
21578The option has no effect for little-endian images and is ignored. The
21579default is dependent on the selected target architecture. For ARMv6
21580and later architectures the default is BE8, for older architectures
21581the default is BE32. BE32 format has been deprecated by ARM.
21582
21583@item -march=@var{name}@r{[}+extension@dots{}@r{]}
21584@opindex march
21585This specifies the name of the target ARM architecture. GCC uses this
21586name to determine what kind of instructions it can emit when generating
21587assembly code. This option can be used in conjunction with or instead
21588of the @option{-mcpu=} option.
21589
21590Permissible names are:
21591@samp{armv4t},
21592@samp{armv5t}, @samp{armv5te},
21593@samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2},
21594@samp{armv6z}, @samp{armv6zk},
21595@samp{armv7}, @samp{armv7-a}, @samp{armv7ve},
21596@samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a},
21597@samp{armv8.4-a},
21598@samp{armv8.5-a},
21599@samp{armv8.6-a},
21600@samp{armv9-a},
21601@samp{armv7-r},
21602@samp{armv8-r},
21603@samp{armv6-m}, @samp{armv6s-m},
21604@samp{armv7-m}, @samp{armv7e-m},
21605@samp{armv8-m.base}, @samp{armv8-m.main},
21606@samp{armv8.1-m.main},
21607@samp{armv9-a},
21608@samp{iwmmxt} and @samp{iwmmxt2}.
21609
21610Additionally, the following architectures, which lack support for the
21611Thumb execution state, are recognized but support is deprecated: @samp{armv4}.
21612
21613Many of the architectures support extensions. These can be added by
21614appending @samp{+@var{extension}} to the architecture name. Extension
21615options are processed in order and capabilities accumulate. An extension
21616will also enable any necessary base extensions
21617upon which it depends. For example, the @samp{+crypto} extension
21618will always enable the @samp{+simd} extension. The exception to the
21619additive construction is for extensions that are prefixed with
21620@samp{+no@dots{}}: these extensions disable the specified option and
21621any other extensions that may depend on the presence of that
21622extension.
21623
21624For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to
21625writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is
21626entirely disabled by the @samp{+nofp} option that follows it.
21627
21628Most extension names are generically named, but have an effect that is
21629dependent upon the architecture to which it is applied. For example,
21630the @samp{+simd} option can be applied to both @samp{armv7-a} and
21631@samp{armv8-a} architectures, but will enable the original ARMv7-A
21632Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A
21633variant for @samp{armv8-a}.
21634
21635The table below lists the supported extensions for each architecture.
21636Architectures not mentioned do not support any extensions.
21637
21638@table @samp
21639@item armv5te
21640@itemx armv6
21641@itemx armv6j
21642@itemx armv6k
21643@itemx armv6kz
21644@itemx armv6t2
21645@itemx armv6z
21646@itemx armv6zk
21647@table @samp
21648@item +fp
21649The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be
21650used as an alias for this extension.
21651
21652@item +nofp
21653Disable the floating-point instructions.
21654@end table
21655
21656@item armv7
21657The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures.
21658@table @samp
21659@item +fp
21660The VFPv3 floating-point instructions, with 16 double-precision
21661registers. The extension @samp{+vfpv3-d16} can be used as an alias
21662for this extension. Note that floating-point is not supported by the
21663base ARMv7-M architecture, but is compatible with both the ARMv7-A and
21664ARMv7-R architectures.
21665
21666@item +nofp
21667Disable the floating-point instructions.
21668@end table
21669
21670@item armv7-a
21671@table @samp
21672@item +mp
21673The multiprocessing extension.
21674
21675@item +sec
21676The security extension.
21677
21678@item +fp
21679The VFPv3 floating-point instructions, with 16 double-precision
21680registers. The extension @samp{+vfpv3-d16} can be used as an alias
21681for this extension.
21682
21683@item +simd
21684The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21685The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases
21686for this extension.
21687
21688@item +vfpv3
21689The VFPv3 floating-point instructions, with 32 double-precision
21690registers.
21691
21692@item +vfpv3-d16-fp16
21693The VFPv3 floating-point instructions, with 16 double-precision
21694registers and the half-precision floating-point conversion operations.
21695
21696@item +vfpv3-fp16
21697The VFPv3 floating-point instructions, with 32 double-precision
21698registers and the half-precision floating-point conversion operations.
21699
21700@item +vfpv4-d16
21701The VFPv4 floating-point instructions, with 16 double-precision
21702registers.
21703
21704@item +vfpv4
21705The VFPv4 floating-point instructions, with 32 double-precision
21706registers.
21707
21708@item +neon-fp16
21709The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21710the half-precision floating-point conversion operations.
21711
21712@item +neon-vfpv4
21713The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions.
21714
21715@item +nosimd
21716Disable the Advanced SIMD instructions (does not disable floating point).
21717
21718@item +nofp
21719Disable the floating-point and Advanced SIMD instructions.
21720@end table
21721
21722@item armv7ve
21723The extended version of the ARMv7-A architecture with support for
21724virtualization.
21725@table @samp
21726@item +fp
21727The VFPv4 floating-point instructions, with 16 double-precision registers.
21728The extension @samp{+vfpv4-d16} can be used as an alias for this extension.
21729
21730@item +simd
21731The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The
21732extension @samp{+neon-vfpv4} can be used as an alias for this extension.
21733
21734@item +vfpv3-d16
21735The VFPv3 floating-point instructions, with 16 double-precision
21736registers.
21737
21738@item +vfpv3
21739The VFPv3 floating-point instructions, with 32 double-precision
21740registers.
21741
21742@item +vfpv3-d16-fp16
21743The VFPv3 floating-point instructions, with 16 double-precision
21744registers and the half-precision floating-point conversion operations.
21745
21746@item +vfpv3-fp16
21747The VFPv3 floating-point instructions, with 32 double-precision
21748registers and the half-precision floating-point conversion operations.
21749
21750@item +vfpv4-d16
21751The VFPv4 floating-point instructions, with 16 double-precision
21752registers.
21753
21754@item +vfpv4
21755The VFPv4 floating-point instructions, with 32 double-precision
21756registers.
21757
21758@item +neon
21759The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions.
21760The extension @samp{+neon-vfpv3} can be used as an alias for this extension.
21761
21762@item +neon-fp16
21763The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with
21764the half-precision floating-point conversion operations.
21765
21766@item +nosimd
21767Disable the Advanced SIMD instructions (does not disable floating point).
21768
21769@item +nofp
21770Disable the floating-point and Advanced SIMD instructions.
21771@end table
21772
21773@item armv8-a
21774@table @samp
21775@item +crc
21776The Cyclic Redundancy Check (CRC) instructions.
21777@item +simd
21778The ARMv8-A Advanced SIMD and floating-point instructions.
21779@item +crypto
21780The cryptographic instructions.
21781@item +nocrypto
21782Disable the cryptographic instructions.
21783@item +nofp
21784Disable the floating-point, Advanced SIMD and cryptographic instructions.
21785@item +sb
21786Speculation Barrier Instruction.
21787@item +predres
21788Execution and Data Prediction Restriction Instructions.
21789@end table
21790
21791@item armv8.1-a
21792@table @samp
21793@item +simd
21794The ARMv8.1-A Advanced SIMD and floating-point instructions.
21795
21796@item +crypto
21797The cryptographic instructions. This also enables the Advanced SIMD and
21798floating-point instructions.
21799
21800@item +nocrypto
21801Disable the cryptographic instructions.
21802
21803@item +nofp
21804Disable the floating-point, Advanced SIMD and cryptographic instructions.
21805
21806@item +sb
21807Speculation Barrier Instruction.
21808
21809@item +predres
21810Execution and Data Prediction Restriction Instructions.
21811@end table
21812
21813@item armv8.2-a
21814@itemx armv8.3-a
21815@table @samp
21816@item +fp16
21817The half-precision floating-point data processing instructions.
21818This also enables the Advanced SIMD and floating-point instructions.
21819
21820@item +fp16fml
21821The half-precision floating-point fmla extension. This also enables
21822the half-precision floating-point extension and Advanced SIMD and
21823floating-point instructions.
21824
21825@item +simd
21826The ARMv8.1-A Advanced SIMD and floating-point instructions.
21827
21828@item +crypto
21829The cryptographic instructions. This also enables the Advanced SIMD and
21830floating-point instructions.
21831
21832@item +dotprod
21833Enable the Dot Product extension. This also enables Advanced SIMD instructions.
21834
21835@item +nocrypto
21836Disable the cryptographic extension.
21837
21838@item +nofp
21839Disable the floating-point, Advanced SIMD and cryptographic instructions.
21840
21841@item +sb
21842Speculation Barrier Instruction.
21843
21844@item +predres
21845Execution and Data Prediction Restriction Instructions.
21846
21847@item +i8mm
218488-bit Integer Matrix Multiply instructions.
21849This also enables Advanced SIMD and floating-point instructions.
21850
21851@item +bf16
21852Brain half-precision floating-point instructions.
21853This also enables Advanced SIMD and floating-point instructions.
21854@end table
21855
21856@item armv8.4-a
21857@table @samp
21858@item +fp16
21859The half-precision floating-point data processing instructions.
21860This also enables the Advanced SIMD and floating-point instructions as well
21861as the Dot Product extension and the half-precision floating-point fmla
21862extension.
21863
21864@item +simd
21865The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21866Dot Product extension.
21867
21868@item +crypto
21869The cryptographic instructions. This also enables the Advanced SIMD and
21870floating-point instructions as well as the Dot Product extension.
21871
21872@item +nocrypto
21873Disable the cryptographic extension.
21874
21875@item +nofp
21876Disable the floating-point, Advanced SIMD and cryptographic instructions.
21877
21878@item +sb
21879Speculation Barrier Instruction.
21880
21881@item +predres
21882Execution and Data Prediction Restriction Instructions.
21883
21884@item +i8mm
218858-bit Integer Matrix Multiply instructions.
21886This also enables Advanced SIMD and floating-point instructions.
21887
21888@item +bf16
21889Brain half-precision floating-point instructions.
21890This also enables Advanced SIMD and floating-point instructions.
21891@end table
21892
21893@item armv8.5-a
21894@table @samp
21895@item +fp16
21896The half-precision floating-point data processing instructions.
21897This also enables the Advanced SIMD and floating-point instructions as well
21898as the Dot Product extension and the half-precision floating-point fmla
21899extension.
21900
21901@item +simd
21902The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21903Dot Product extension.
21904
21905@item +crypto
21906The cryptographic instructions. This also enables the Advanced SIMD and
21907floating-point instructions as well as the Dot Product extension.
21908
21909@item +nocrypto
21910Disable the cryptographic extension.
21911
21912@item +nofp
21913Disable the floating-point, Advanced SIMD and cryptographic instructions.
21914
21915@item +i8mm
219168-bit Integer Matrix Multiply instructions.
21917This also enables Advanced SIMD and floating-point instructions.
21918
21919@item +bf16
21920Brain half-precision floating-point instructions.
21921This also enables Advanced SIMD and floating-point instructions.
21922@end table
21923
21924@item armv8.6-a
21925@table @samp
21926@item +fp16
21927The half-precision floating-point data processing instructions.
21928This also enables the Advanced SIMD and floating-point instructions as well
21929as the Dot Product extension and the half-precision floating-point fmla
21930extension.
21931
21932@item +simd
21933The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the
21934Dot Product extension.
21935
21936@item +crypto
21937The cryptographic instructions. This also enables the Advanced SIMD and
21938floating-point instructions as well as the Dot Product extension.
21939
21940@item +nocrypto
21941Disable the cryptographic extension.
21942
21943@item +nofp
21944Disable the floating-point, Advanced SIMD and cryptographic instructions.
21945
21946@item +i8mm
219478-bit Integer Matrix Multiply instructions.
21948This also enables Advanced SIMD and floating-point instructions.
21949
21950@item +bf16
21951Brain half-precision floating-point instructions.
21952This also enables Advanced SIMD and floating-point instructions.
21953@end table
21954
21955@item armv7-r
21956@table @samp
21957@item +fp.sp
21958The single-precision VFPv3 floating-point instructions. The extension
21959@samp{+vfpv3xd} can be used as an alias for this extension.
21960
21961@item +fp
21962The VFPv3 floating-point instructions with 16 double-precision registers.
21963The extension +vfpv3-d16 can be used as an alias for this extension.
21964
21965@item +vfpv3xd-d16-fp16
21966The single-precision VFPv3 floating-point instructions with 16 double-precision
21967registers and the half-precision floating-point conversion operations.
21968
21969@item +vfpv3-d16-fp16
21970The VFPv3 floating-point instructions with 16 double-precision
21971registers and the half-precision floating-point conversion operations.
21972
21973@item +nofp
21974Disable the floating-point extension.
21975
21976@item +idiv
21977The ARM-state integer division instructions.
21978
21979@item +noidiv
21980Disable the ARM-state integer division extension.
21981@end table
21982
21983@item armv7e-m
21984@table @samp
21985@item +fp
21986The single-precision VFPv4 floating-point instructions.
21987
21988@item +fpv5
21989The single-precision FPv5 floating-point instructions.
21990
21991@item +fp.dp
21992The single- and double-precision FPv5 floating-point instructions.
21993
21994@item +nofp
21995Disable the floating-point extensions.
21996@end table
21997
21998@item armv8.1-m.main
21999@table @samp
22000
22001@item +dsp
22002The DSP instructions.
22003
22004@item +mve
22005The M-Profile Vector Extension (MVE) integer instructions.
22006
22007@item +mve.fp
22008The M-Profile Vector Extension (MVE) integer and single precision
22009floating-point instructions.
22010
22011@item +fp
22012The single-precision floating-point instructions.
22013
22014@item +fp.dp
22015The single- and double-precision floating-point instructions.
22016
22017@item +nofp
22018Disable the floating-point extension.
22019
22020@item +cdecp0, +cdecp1, ... , +cdecp7
22021Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22022to the numbers given in the options in the range 0 to 7.
22023@end table
22024
22025@item armv8-m.main
22026@table @samp
22027@item +dsp
22028The DSP instructions.
22029
22030@item +nodsp
22031Disable the DSP extension.
22032
22033@item +fp
22034The single-precision floating-point instructions.
22035
22036@item +fp.dp
22037The single- and double-precision floating-point instructions.
22038
22039@item +nofp
22040Disable the floating-point extension.
22041
22042@item +cdecp0, +cdecp1, ... , +cdecp7
22043Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22044to the numbers given in the options in the range 0 to 7.
22045@end table
22046
22047@item armv8-r
22048@table @samp
22049@item +crc
22050The Cyclic Redundancy Check (CRC) instructions.
22051@item +fp.sp
22052The single-precision FPv5 floating-point instructions.
22053@item +simd
22054The ARMv8-A Advanced SIMD and floating-point instructions.
22055@item +crypto
22056The cryptographic instructions.
22057@item +nocrypto
22058Disable the cryptographic instructions.
22059@item +nofp
22060Disable the floating-point, Advanced SIMD and cryptographic instructions.
22061@end table
22062
22063@end table
22064
22065@option{-march=native} causes the compiler to auto-detect the architecture
22066of the build computer. At present, this feature is only supported on
22067GNU/Linux, and not all architectures are recognized. If the auto-detect
22068is unsuccessful the option has no effect.
22069
22070@item -mtune=@var{name}
22071@opindex mtune
22072This option specifies the name of the target ARM processor for
22073which GCC should tune the performance of the code.
22074For some ARM implementations better performance can be obtained by using
22075this option.
22076Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t},
22077@samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110},
22078@samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810},
22079@samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t},
22080@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s},
22081@samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t},
22082@samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e},
22083@samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp},
22084@samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s},
22085@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8},
22086@samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17},
22087@samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55},
22088@samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75},
22089@samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77},
22090@samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710},
22091@samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5},
22092@samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus},
22093@samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3},
22094@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33},
23a121d4 22095@samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-x1}, @samp{cortex-x1c},
d77de738
ML
22096@samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply},
22097@samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4},
22098@samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale},
22099@samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626},
22100@samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1},
22101@samp{xgene1}.
22102
22103Additionally, this option can specify that GCC should tune the performance
22104of the code for a big.LITTLE system. Permissible names are:
22105@samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7},
22106@samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22107@samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53},
22108@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}.
22109
22110@option{-mtune=generic-@var{arch}} specifies that GCC should tune the
22111performance for a blend of processors within architecture @var{arch}.
22112The aim is to generate code that run well on the current most popular
22113processors, balancing between optimizations that benefit some CPUs in the
22114range, and avoiding performance pitfalls of other CPUs. The effects of
22115this option may change in future GCC versions as CPU models come and go.
22116
22117@option{-mtune} permits the same extension options as @option{-mcpu}, but
22118the extension options do not affect the tuning of the generated code.
22119
22120@option{-mtune=native} causes the compiler to auto-detect the CPU
22121of the build computer. At present, this feature is only supported on
22122GNU/Linux, and not all architectures are recognized. If the auto-detect is
22123unsuccessful the option has no effect.
22124
22125@item -mcpu=@var{name}@r{[}+extension@dots{}@r{]}
22126@opindex mcpu
22127This specifies the name of the target ARM processor. GCC uses this name
22128to derive the name of the target ARM architecture (as if specified
22129by @option{-march}) and the ARM processor type for which to tune for
22130performance (as if specified by @option{-mtune}). Where this option
22131is used in conjunction with @option{-march} or @option{-mtune},
22132those options take precedence over the appropriate part of this option.
22133
22134Many of the supported CPUs implement optional architectural
22135extensions. Where this is so the architectural extensions are
22136normally enabled by default. If implementations that lack the
22137extension exist, then the extension syntax can be used to disable
22138those extensions that have been omitted. For floating-point and
22139Advanced SIMD (Neon) instructions, the settings of the options
22140@option{-mfloat-abi} and @option{-mfpu} must also be considered:
22141floating-point and Advanced SIMD instructions will only be used if
22142@option{-mfloat-abi} is not set to @samp{soft}; and any setting of
22143@option{-mfpu} other than @samp{auto} will override the available
22144floating-point and SIMD extension instructions.
22145
22146For example, @samp{cortex-a9} can be found in three major
22147configurations: integer only, with just a floating-point unit or with
22148floating-point and Advanced SIMD. The default is to enable all the
22149instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can
22150be used to disable just the SIMD or both the SIMD and floating-point
22151instructions respectively.
22152
22153Permissible names for this option are the same as those for
22154@option{-mtune}.
22155
22156The following extension options are common to the listed CPUs:
22157
22158@table @samp
22159@item +nodsp
22160Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}
22161and @samp{cortex-m55}. Also disable the M-Profile Vector Extension (MVE)
22162integer and single precision floating-point instructions on @samp{cortex-m55}.
22163
22164@item +nomve
22165Disable the M-Profile Vector Extension (MVE) integer and single precision
22166floating-point instructions on @samp{cortex-m55}.
22167
22168@item +nomve.fp
22169Disable the M-Profile Vector Extension (MVE) single precision floating-point
22170instructions on @samp{cortex-m55}.
22171
798a0d05
SP
22172@item +cdecp0, +cdecp1, ... , +cdecp7
22173Enable the Custom Datapath Extension (CDE) on selected coprocessors according
22174to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}.
22175
d77de738
ML
22176@item +nofp
22177Disables the floating-point instructions on @samp{arm9e},
22178@samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e},
22179@samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s},
22180@samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8},
22181@samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}
22182and @samp{cortex-m55}.
22183Disables the floating-point and SIMD instructions on
22184@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7},
22185@samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12},
22186@samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7},
22187@samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35},
22188@samp{cortex-a53} and @samp{cortex-a55}.
22189
22190@item +nofp.dp
22191Disables the double-precision component of the floating-point instructions
22192on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52},
22193@samp{cortex-r52plus} and @samp{cortex-m7}.
22194
22195@item +nosimd
22196Disables the SIMD (but not floating-point) instructions on
22197@samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}
22198and @samp{cortex-a9}.
22199
22200@item +crypto
22201Enables the cryptographic instructions on @samp{cortex-a32},
22202@samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57},
22203@samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1},
22204@samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
22205@samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and
22206@samp{cortex-a75.cortex-a55}.
22207@end table
22208
22209Additionally the @samp{generic-armv7-a} pseudo target defaults to
22210VFPv3 with 16 double-precision registers. It supports the following
22211extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16},
22212@samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16},
22213@samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3},
22214@samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for
22215the extensions to @option{-march=armv7-a}.
22216
22217@option{-mcpu=generic-@var{arch}} is also permissible, and is
22218equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}.
22219See @option{-mtune} for more information.
22220
22221@option{-mcpu=native} causes the compiler to auto-detect the CPU
22222of the build computer. At present, this feature is only supported on
22223GNU/Linux, and not all architectures are recognized. If the auto-detect
22224is unsuccessful the option has no effect.
22225
22226@item -mfpu=@var{name}
22227@opindex mfpu
22228This specifies what floating-point hardware (or hardware emulation) is
22229available on the target. Permissible names are: @samp{auto}, @samp{vfpv2},
22230@samp{vfpv3},
22231@samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd},
22232@samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4},
22233@samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4},
22234@samp{fpv5-d16}, @samp{fpv5-sp-d16},
22235@samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}.
22236Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp}
22237is an alias for @samp{vfpv2}.
22238
22239The setting @samp{auto} is the default and is special. It causes the
22240compiler to select the floating-point and Advanced SIMD instructions
22241based on the settings of @option{-mcpu} and @option{-march}.
22242
22243If the selected floating-point hardware includes the NEON extension
22244(e.g.@: @option{-mfpu=neon}), note that floating-point
22245operations are not generated by GCC's auto-vectorization pass unless
22246@option{-funsafe-math-optimizations} is also specified. This is
22247because NEON hardware does not fully implement the IEEE 754 standard for
22248floating-point arithmetic (in particular denormal values are treated as
22249zero), so the use of NEON instructions may lead to a loss of precision.
22250
22251You 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}).
22252
22253@item -mfp16-format=@var{name}
22254@opindex mfp16-format
22255Specify the format of the @code{__fp16} half-precision floating-point type.
22256Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative};
22257the default is @samp{none}, in which case the @code{__fp16} type is not
22258defined. @xref{Half-Precision}, for more information.
22259
22260@item -mstructure-size-boundary=@var{n}
22261@opindex mstructure-size-boundary
22262The sizes of all structures and unions are rounded up to a multiple
22263of the number of bits set by this option. Permissible values are 8, 32
22264and 64. The default value varies for different toolchains. For the COFF
22265targeted toolchain the default value is 8. A value of 64 is only allowed
22266if the underlying ABI supports it.
22267
22268Specifying a larger number can produce faster, more efficient code, but
22269can also increase the size of the program. Different values are potentially
22270incompatible. Code compiled with one value cannot necessarily expect to
22271work with code or libraries compiled with another value, if they exchange
22272information using structures or unions.
22273
22274This option is deprecated.
22275
22276@item -mabort-on-noreturn
22277@opindex mabort-on-noreturn
22278Generate a call to the function @code{abort} at the end of a
22279@code{noreturn} function. It is executed if the function tries to
22280return.
22281
22282@item -mlong-calls
22283@itemx -mno-long-calls
22284@opindex mlong-calls
22285@opindex mno-long-calls
22286Tells the compiler to perform function calls by first loading the
22287address of the function into a register and then performing a subroutine
22288call on this register. This switch is needed if the target function
22289lies outside of the 64-megabyte addressing range of the offset-based
22290version of subroutine call instruction.
22291
22292Even if this switch is enabled, not all function calls are turned
22293into long calls. The heuristic is that static functions, functions
22294that have the @code{short_call} attribute, functions that are inside
22295the scope of a @code{#pragma no_long_calls} directive, and functions whose
22296definitions have already been compiled within the current compilation
22297unit are not turned into long calls. The exceptions to this rule are
22298that weak function definitions, functions with the @code{long_call}
22299attribute or the @code{section} attribute, and functions that are within
22300the scope of a @code{#pragma long_calls} directive are always
22301turned into long calls.
22302
22303This feature is not enabled by default. Specifying
22304@option{-mno-long-calls} restores the default behavior, as does
22305placing the function calls within the scope of a @code{#pragma
22306long_calls_off} directive. Note these switches have no effect on how
22307the compiler generates code to handle function calls via function
22308pointers.
22309
22310@item -msingle-pic-base
22311@opindex msingle-pic-base
22312Treat the register used for PIC addressing as read-only, rather than
22313loading it in the prologue for each function. The runtime system is
22314responsible for initializing this register with an appropriate value
22315before execution begins.
22316
22317@item -mpic-register=@var{reg}
22318@opindex mpic-register
22319Specify the register to be used for PIC addressing.
22320For standard PIC base case, the default is any suitable register
22321determined by compiler. For single PIC base case, the default is
22322@samp{R9} if target is EABI based or stack-checking is enabled,
22323otherwise the default is @samp{R10}.
22324
22325@item -mpic-data-is-text-relative
22326@opindex mpic-data-is-text-relative
22327Assume that the displacement between the text and data segments is fixed
22328at static link time. This permits using PC-relative addressing
22329operations to access data known to be in the data segment. For
22330non-VxWorks RTP targets, this option is enabled by default. When
22331disabled on such targets, it will enable @option{-msingle-pic-base} by
22332default.
22333
22334@item -mpoke-function-name
22335@opindex mpoke-function-name
22336Write the name of each function into the text section, directly
22337preceding the function prologue. The generated code is similar to this:
22338
22339@smallexample
22340 t0
22341 .ascii "arm_poke_function_name", 0
22342 .align
22343 t1
22344 .word 0xff000000 + (t1 - t0)
22345 arm_poke_function_name
22346 mov ip, sp
22347 stmfd sp!, @{fp, ip, lr, pc@}
22348 sub fp, ip, #4
22349@end smallexample
22350
22351When performing a stack backtrace, code can inspect the value of
22352@code{pc} stored at @code{fp + 0}. If the trace function then looks at
22353location @code{pc - 12} and the top 8 bits are set, then we know that
22354there is a function name embedded immediately preceding this location
22355and has length @code{((pc[-3]) & 0xff000000)}.
22356
22357@item -mthumb
22358@itemx -marm
22359@opindex marm
22360@opindex mthumb
22361
22362Select between generating code that executes in ARM and Thumb
22363states. The default for most configurations is to generate code
22364that executes in ARM state, but the default can be changed by
22365configuring GCC with the @option{--with-mode=}@var{state}
22366configure option.
22367
22368You can also override the ARM and Thumb mode for each function
22369by using the @code{target("thumb")} and @code{target("arm")} function attributes
22370(@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
22371
22372@item -mflip-thumb
22373@opindex mflip-thumb
22374Switch ARM/Thumb modes on alternating functions.
22375This option is provided for regression testing of mixed Thumb/ARM code
22376generation, and is not intended for ordinary use in compiling code.
22377
22378@item -mtpcs-frame
22379@opindex mtpcs-frame
22380Generate a stack frame that is compliant with the Thumb Procedure Call
22381Standard for all non-leaf functions. (A leaf function is one that does
22382not call any other functions.) The default is @option{-mno-tpcs-frame}.
22383
22384@item -mtpcs-leaf-frame
22385@opindex mtpcs-leaf-frame
22386Generate a stack frame that is compliant with the Thumb Procedure Call
22387Standard for all leaf functions. (A leaf function is one that does
22388not call any other functions.) The default is @option{-mno-apcs-leaf-frame}.
22389
22390@item -mcallee-super-interworking
22391@opindex mcallee-super-interworking
22392Gives all externally visible functions in the file being compiled an ARM
22393instruction set header which switches to Thumb mode before executing the
22394rest of the function. This allows these functions to be called from
22395non-interworking code. This option is not valid in AAPCS configurations
22396because interworking is enabled by default.
22397
22398@item -mcaller-super-interworking
22399@opindex mcaller-super-interworking
22400Allows calls via function pointers (including virtual functions) to
22401execute correctly regardless of whether the target code has been
22402compiled for interworking or not. There is a small overhead in the cost
22403of executing a function pointer if this option is enabled. This option
22404is not valid in AAPCS configurations because interworking is enabled
22405by default.
22406
22407@item -mtp=@var{name}
22408@opindex mtp
22409Specify the access model for the thread local storage pointer. The valid
22410models are @samp{soft}, which generates calls to @code{__aeabi_read_tp},
22411@samp{cp15}, which fetches the thread pointer from @code{cp15} directly
22412(supported in the arm6k architecture), and @samp{auto}, which uses the
22413best available method for the selected processor. The default setting is
22414@samp{auto}.
22415
22416@item -mtls-dialect=@var{dialect}
22417@opindex mtls-dialect
22418Specify the dialect to use for accessing thread local storage. Two
22419@var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The
22420@samp{gnu} dialect selects the original GNU scheme for supporting
22421local and global dynamic TLS models. The @samp{gnu2} dialect
22422selects the GNU descriptor scheme, which provides better performance
22423for shared libraries. The GNU descriptor scheme is compatible with
22424the original scheme, but does require new assembler, linker and
22425library support. Initial and local exec TLS models are unaffected by
22426this option and always use the original scheme.
22427
22428@item -mword-relocations
22429@opindex mword-relocations
22430Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32).
22431This is enabled by default on targets (uClinux, SymbianOS) where the runtime
22432loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
22433is specified. This option conflicts with @option{-mslow-flash-data}.
22434
22435@item -mfix-cortex-m3-ldrd
22436@opindex mfix-cortex-m3-ldrd
22437Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions
22438with overlapping destination and base registers are used. This option avoids
22439generating these instructions. This option is enabled by default when
22440@option{-mcpu=cortex-m3} is specified.
22441
22442@item -mfix-cortex-a57-aes-1742098
22443@itemx -mno-fix-cortex-a57-aes-1742098
22444@itemx -mfix-cortex-a72-aes-1655431
22445@itemx -mno-fix-cortex-a72-aes-1655431
22446Enable (disable) mitigation for an erratum on Cortex-A57 and
22447Cortex-A72 that affects the AES cryptographic instructions. This
22448option is enabled by default when either @option{-mcpu=cortex-a57} or
22449@option{-mcpu=cortex-a72} is specified.
22450
22451@item -munaligned-access
22452@itemx -mno-unaligned-access
22453@opindex munaligned-access
22454@opindex mno-unaligned-access
22455Enables (or disables) reading and writing of 16- and 32- bit values
22456from addresses that are not 16- or 32- bit aligned. By default
22457unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for
22458ARMv8-M Baseline architectures, and enabled for all other
22459architectures. If unaligned access is not enabled then words in packed
22460data structures are accessed a byte at a time.
22461
22462The ARM attribute @code{Tag_CPU_unaligned_access} is set in the
22463generated object file to either true or false, depending upon the
22464setting of this option. If unaligned access is enabled then the
22465preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also
22466defined.
22467
22468@item -mneon-for-64bits
22469@opindex mneon-for-64bits
22470This option is deprecated and has no effect.
22471
22472@item -mslow-flash-data
22473@opindex mslow-flash-data
22474Assume loading data from flash is slower than fetching instruction.
22475Therefore literal load is minimized for better performance.
22476This option is only supported when compiling for ARMv7 M-profile and
22477off by default. It conflicts with @option{-mword-relocations}.
22478
22479@item -masm-syntax-unified
22480@opindex masm-syntax-unified
22481Assume inline assembler is using unified asm syntax. The default is
22482currently off which implies divided syntax. This option has no impact
22483on Thumb2. However, this may change in future releases of GCC.
22484Divided syntax should be considered deprecated.
22485
22486@item -mrestrict-it
22487@opindex mrestrict-it
22488Restricts generation of IT blocks to conform to the rules of ARMv8-A.
22489IT blocks can only contain a single 16-bit instruction from a select
22490set of instructions. This option is on by default for ARMv8-A Thumb mode.
22491
22492@item -mprint-tune-info
22493@opindex mprint-tune-info
22494Print CPU tuning information as comment in assembler file. This is
22495an option used only for regression testing of the compiler and not
22496intended for ordinary use in compiling code. This option is disabled
22497by default.
22498
22499@item -mverbose-cost-dump
22500@opindex mverbose-cost-dump
22501Enable verbose cost model dumping in the debug dump files. This option is
22502provided for use in debugging the compiler.
22503
22504@item -mpure-code
22505@opindex mpure-code
22506Do not allow constant data to be placed in code sections.
22507Additionally, when compiling for ELF object format give all text sections the
22508ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option
22509is only available when generating non-pic code for M-profile targets.
22510
22511@item -mcmse
22512@opindex mcmse
22513Generate secure code as per the "ARMv8-M Security Extensions: Requirements on
22514Development Tools Engineering Specification", which can be found on
22515@url{https://developer.arm.com/documentation/ecm0359818/latest/}.
22516
22517@item -mfix-cmse-cve-2021-35465
22518@opindex mfix-cmse-cve-2021-35465
22519Mitigate against a potential security issue with the @code{VLLDM} instruction
22520in some M-profile devices when using CMSE (CVE-2021-365465). This option is
22521enabled by default when the option @option{-mcpu=} is used with
22522@code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55} or @code{star-mc1}.
22523The option @option{-mno-fix-cmse-cve-2021-35465} can be used to disable
22524the mitigation.
22525
22526@item -mstack-protector-guard=@var{guard}
22527@itemx -mstack-protector-guard-offset=@var{offset}
22528@opindex mstack-protector-guard
22529@opindex mstack-protector-guard-offset
22530Generate stack protection code using canary at @var{guard}. Supported
22531locations are @samp{global} for a global canary or @samp{tls} for a
22532canary accessible via the TLS register. The option
22533@option{-mstack-protector-guard-offset=} is for use with
22534@option{-fstack-protector-guard=tls} and not for use in user-land code.
22535
22536@item -mfdpic
22537@itemx -mno-fdpic
22538@opindex mfdpic
22539@opindex mno-fdpic
22540Select the FDPIC ABI, which uses 64-bit function descriptors to
22541represent pointers to functions. When the compiler is configured for
22542@code{arm-*-uclinuxfdpiceabi} targets, this option is on by default
22543and implies @option{-fPIE} if none of the PIC/PIE-related options is
22544provided. On other targets, it only enables the FDPIC-specific code
22545generation features, and the user should explicitly provide the
22546PIC/PIE-related options as needed.
22547
22548Note that static linking is not supported because it would still
22549involve the dynamic linker when the program self-relocates. If such
22550behavior is acceptable, use -static and -Wl,-dynamic-linker options.
22551
22552The opposite @option{-mno-fdpic} option is useful (and required) to
22553build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi})
22554toolchain as the one used to build the userland programs.
22555
22556@end table
22557
22558@node AVR Options
22559@subsection AVR Options
22560@cindex AVR Options
22561
22562These options are defined for AVR implementations:
22563
22564@table @gcctabopt
22565@item -mmcu=@var{mcu}
22566@opindex mmcu
22567Specify Atmel AVR instruction set architectures (ISA) or MCU type.
22568
22569The default for this option is@tie{}@samp{avr2}.
22570
22571GCC supports the following AVR devices and ISAs:
22572
22573@include avr-mmcu.texi
22574
22575@item -mabsdata
22576@opindex mabsdata
22577
22578Assume that all data in static storage can be accessed by LDS / STS
22579instructions. This option has only an effect on reduced Tiny devices like
22580ATtiny40. See also the @code{absdata}
22581@ref{AVR Variable Attributes,variable attribute}.
22582
22583@item -maccumulate-args
22584@opindex maccumulate-args
22585Accumulate outgoing function arguments and acquire/release the needed
22586stack space for outgoing function arguments once in function
22587prologue/epilogue. Without this option, outgoing arguments are pushed
22588before calling a function and popped afterwards.
22589
22590Popping the arguments after the function call can be expensive on
22591AVR so that accumulating the stack space might lead to smaller
22592executables because arguments need not be removed from the
22593stack after such a function call.
22594
22595This option can lead to reduced code size for functions that perform
22596several calls to functions that get their arguments on the stack like
22597calls to printf-like functions.
22598
22599@item -mbranch-cost=@var{cost}
22600@opindex mbranch-cost
22601Set the branch costs for conditional branch instructions to
22602@var{cost}. Reasonable values for @var{cost} are small, non-negative
22603integers. The default branch cost is 0.
22604
22605@item -mcall-prologues
22606@opindex mcall-prologues
22607Functions prologues/epilogues are expanded as calls to appropriate
22608subroutines. Code size is smaller.
22609
22610@item -mdouble=@var{bits}
22611@itemx -mlong-double=@var{bits}
22612@opindex mdouble
22613@opindex mlong-double
22614Set the size (in bits) of the @code{double} or @code{long double} type,
22615respectively. Possible values for @var{bits} are 32 and 64.
22616Whether or not a specific value for @var{bits} is allowed depends on
22617the @code{--with-double=} and @code{--with-long-double=}
22618@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}},
22619and the same applies for the default values of the options.
22620
22621@item -mgas-isr-prologues
22622@opindex mgas-isr-prologues
22623Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo
22624instruction supported by GNU Binutils.
22625If this option is on, the feature can still be disabled for individual
22626ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}}
22627function attribute. This feature is activated per default
22628if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}),
22629and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}.
22630
22631@item -mint8
22632@opindex mint8
22633Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a
22634@code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes,
22635and @code{long long} is 4 bytes. Please note that this option does not
22636conform to the C standards, but it results in smaller code
22637size.
22638
22639@item -mmain-is-OS_task
22640@opindex mmain-is-OS_task
22641Do not save registers in @code{main}. The effect is the same like
22642attaching attribute @ref{AVR Function Attributes,,@code{OS_task}}
22643to @code{main}. It is activated per default if optimization is on.
22644
22645@item -mn-flash=@var{num}
22646@opindex mn-flash
22647Assume that the flash memory has a size of
22648@var{num} times 64@tie{}KiB.
22649
22650@item -mno-interrupts
22651@opindex mno-interrupts
22652Generated code is not compatible with hardware interrupts.
22653Code size is smaller.
22654
22655@item -mrelax
22656@opindex mrelax
22657Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
22658@code{RCALL} resp.@: @code{RJMP} instruction if applicable.
22659Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
22660the assembler's command line and the @option{--relax} option to the
22661linker's command line.
22662
22663Jump relaxing is performed by the linker because jump offsets are not
22664known before code is located. Therefore, the assembler code generated by the
22665compiler is the same, but the instructions in the executable may
22666differ from instructions in the assembler code.
22667
22668Relaxing must be turned on if linker stubs are needed, see the
22669section on @code{EIND} and linker stubs below.
22670
22671@item -mrmw
22672@opindex mrmw
22673Assume that the device supports the Read-Modify-Write
22674instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
22675
22676@item -mshort-calls
22677@opindex mshort-calls
22678
22679Assume that @code{RJMP} and @code{RCALL} can target the whole
22680program memory.
22681
22682This option is used internally for multilib selection. It is
22683not an optimization option, and you don't need to set it by hand.
22684
22685@item -msp8
22686@opindex msp8
22687Treat the stack pointer register as an 8-bit register,
22688i.e.@: assume the high byte of the stack pointer is zero.
22689In general, you don't need to set this option by hand.
22690
22691This option is used internally by the compiler to select and
22692build multilibs for architectures @code{avr2} and @code{avr25}.
22693These architectures mix devices with and without @code{SPH}.
22694For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25}
22695the compiler driver adds or removes this option from the compiler
22696proper's command line, because the compiler then knows if the device
22697or architecture has an 8-bit stack pointer and thus no @code{SPH}
22698register or not.
22699
22700@item -mstrict-X
22701@opindex mstrict-X
22702Use address register @code{X} in a way proposed by the hardware. This means
22703that @code{X} is only used in indirect, post-increment or
22704pre-decrement addressing.
22705
22706Without this option, the @code{X} register may be used in the same way
22707as @code{Y} or @code{Z} which then is emulated by additional
22708instructions.
22709For example, loading a value with @code{X+const} addressing with a
22710small non-negative @code{const < 64} to a register @var{Rn} is
22711performed as
22712
22713@example
22714adiw r26, const ; X += const
22715ld @var{Rn}, X ; @var{Rn} = *X
22716sbiw r26, const ; X -= const
22717@end example
22718
22719@item -mtiny-stack
22720@opindex mtiny-stack
22721Only change the lower 8@tie{}bits of the stack pointer.
22722
22723@item -mfract-convert-truncate
22724@opindex mfract-convert-truncate
22725Allow to use truncation instead of rounding towards zero for fractional fixed-point types.
22726
22727@item -nodevicelib
22728@opindex nodevicelib
22729Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}.
22730
22731@item -nodevicespecs
22732@opindex nodevicespecs
22733Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's
22734command line. The user takes responsibility for supplying the sub-processes
22735like compiler proper, assembler and linker with appropriate command line
22736options. This means that the user has to supply her private device specs
22737file by means of @option{-specs=@var{path-to-specs-file}}. There is no
22738more need for option @option{-mmcu=@var{mcu}}.
22739
22740This option can also serve as a replacement for the older way of
22741specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory
22742which contains a folder named @code{device-specs} which contains a specs file named
22743@code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}.
22744
22745@item -Waddr-space-convert
22746@opindex Waddr-space-convert
22747@opindex Wno-addr-space-convert
22748Warn about conversions between address spaces in the case where the
22749resulting address space is not contained in the incoming address space.
22750
22751@item -Wmisspelled-isr
22752@opindex Wmisspelled-isr
22753@opindex Wno-misspelled-isr
22754Warn if the ISR is misspelled, i.e.@: without __vector prefix.
22755Enabled by default.
22756@end table
22757
22758@subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash
22759@cindex @code{EIND}
22760Pointers in the implementation are 16@tie{}bits wide.
22761The address of a function or label is represented as word address so
22762that indirect jumps and calls can target any code address in the
22763range of 64@tie{}Ki words.
22764
22765In order to facilitate indirect jump on devices with more than 128@tie{}Ki
22766bytes of program memory space, there is a special function register called
22767@code{EIND} that serves as most significant part of the target address
22768when @code{EICALL} or @code{EIJMP} instructions are used.
22769
22770Indirect jumps and calls on these devices are handled as follows by
22771the compiler and are subject to some limitations:
22772
22773@itemize @bullet
22774
22775@item
22776The compiler never sets @code{EIND}.
22777
22778@item
22779The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP}
22780instructions or might read @code{EIND} directly in order to emulate an
22781indirect call/jump by means of a @code{RET} instruction.
22782
22783@item
22784The compiler assumes that @code{EIND} never changes during the startup
22785code or during the application. In particular, @code{EIND} is not
22786saved/restored in function or interrupt service routine
22787prologue/epilogue.
22788
22789@item
22790For indirect calls to functions and computed goto, the linker
22791generates @emph{stubs}. Stubs are jump pads sometimes also called
22792@emph{trampolines}. Thus, the indirect call/jump jumps to such a stub.
22793The stub contains a direct jump to the desired address.
22794
22795@item
22796Linker relaxation must be turned on so that the linker generates
22797the stubs correctly in all situations. See the compiler option
22798@option{-mrelax} and the linker option @option{--relax}.
22799There are corner cases where the linker is supposed to generate stubs
22800but aborts without relaxation and without a helpful error message.
22801
22802@item
22803The default linker script is arranged for code with @code{EIND = 0}.
22804If code is supposed to work for a setup with @code{EIND != 0}, a custom
22805linker script has to be used in order to place the sections whose
22806name start with @code{.trampolines} into the segment where @code{EIND}
22807points to.
22808
22809@item
22810The startup code from libgcc never sets @code{EIND}.
22811Notice that startup code is a blend of code from libgcc and AVR-LibC.
22812For the impact of AVR-LibC on @code{EIND}, see the
22813@w{@uref{http://nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}.
22814
22815@item
22816It is legitimate for user-specific startup code to set up @code{EIND}
22817early, for example by means of initialization code located in
22818section @code{.init3}. Such code runs prior to general startup code
22819that initializes RAM and calls constructors, but after the bit
22820of startup code from AVR-LibC that sets @code{EIND} to the segment
22821where the vector table is located.
22822@example
22823#include <avr/io.h>
22824
22825static void
22826__attribute__((section(".init3"),naked,used,no_instrument_function))
22827init3_set_eind (void)
22828@{
22829 __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t"
22830 "out %i0,r24" :: "n" (&EIND) : "r24","memory");
22831@}
22832@end example
22833
22834@noindent
22835The @code{__trampolines_start} symbol is defined in the linker script.
22836
22837@item
22838Stubs are generated automatically by the linker if
22839the following two conditions are met:
22840@itemize @minus
22841
22842@item The address of a label is taken by means of the @code{gs} modifier
22843(short for @emph{generate stubs}) like so:
22844@example
22845LDI r24, lo8(gs(@var{func}))
22846LDI r25, hi8(gs(@var{func}))
22847@end example
22848@item The final location of that label is in a code segment
22849@emph{outside} the segment where the stubs are located.
22850@end itemize
22851
22852@item
22853The compiler emits such @code{gs} modifiers for code labels in the
22854following situations:
22855@itemize @minus
22856@item Taking address of a function or code label.
22857@item Computed goto.
22858@item If prologue-save function is used, see @option{-mcall-prologues}
22859command-line option.
22860@item Switch/case dispatch tables. If you do not want such dispatch
22861tables you can specify the @option{-fno-jump-tables} command-line option.
22862@item C and C++ constructors/destructors called during startup/shutdown.
22863@item If the tools hit a @code{gs()} modifier explained above.
22864@end itemize
22865
22866@item
22867Jumping to non-symbolic addresses like so is @emph{not} supported:
22868
22869@example
22870int main (void)
22871@{
22872 /* Call function at word address 0x2 */
22873 return ((int(*)(void)) 0x2)();
22874@}
22875@end example
22876
22877Instead, a stub has to be set up, i.e.@: the function has to be called
22878through a symbol (@code{func_4} in the example):
22879
22880@example
22881int main (void)
22882@{
22883 extern int func_4 (void);
22884
22885 /* Call function at byte address 0x4 */
22886 return func_4();
22887@}
22888@end example
22889
22890and the application be linked with @option{-Wl,--defsym,func_4=0x4}.
22891Alternatively, @code{func_4} can be defined in the linker script.
22892@end itemize
22893
22894@subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers
22895@cindex @code{RAMPD}
22896@cindex @code{RAMPX}
22897@cindex @code{RAMPY}
22898@cindex @code{RAMPZ}
22899Some AVR devices support memories larger than the 64@tie{}KiB range
22900that can be accessed with 16-bit pointers. To access memory locations
22901outside this 64@tie{}KiB range, the content of a @code{RAMP}
22902register is used as high part of the address:
22903The @code{X}, @code{Y}, @code{Z} address register is concatenated
22904with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function
22905register, respectively, to get a wide address. Similarly,
22906@code{RAMPD} is used together with direct addressing.
22907
22908@itemize
22909@item
22910The startup code initializes the @code{RAMP} special function
22911registers with zero.
22912
22913@item
22914If a @ref{AVR Named Address Spaces,named address space} other than
22915generic or @code{__flash} is used, then @code{RAMPZ} is set
22916as needed before the operation.
22917
22918@item
22919If the device supports RAM larger than 64@tie{}KiB and the compiler
22920needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ}
22921is reset to zero after the operation.
22922
22923@item
22924If the device comes with a specific @code{RAMP} register, the ISR
22925prologue/epilogue saves/restores that SFR and initializes it with
22926zero in case the ISR code might (implicitly) use it.
22927
22928@item
22929RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets.
22930If you use inline assembler to read from locations outside the
2293116-bit address range and change one of the @code{RAMP} registers,
22932you must reset it to zero after the access.
22933
22934@end itemize
22935
22936@subsubsection AVR Built-in Macros
22937
22938GCC defines several built-in macros so that the user code can test
22939for the presence or absence of features. Almost any of the following
22940built-in macros are deduced from device capabilities and thus
22941triggered by the @option{-mmcu=} command-line option.
22942
22943For even more AVR-specific built-in macros see
22944@ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}.
22945
22946@table @code
22947
22948@item __AVR_ARCH__
22949Build-in macro that resolves to a decimal number that identifies the
22950architecture and depends on the @option{-mmcu=@var{mcu}} option.
22951Possible values are:
22952
22953@code{2}, @code{25}, @code{3}, @code{31}, @code{35},
22954@code{4}, @code{5}, @code{51}, @code{6}
22955
22956for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
22957@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
22958
22959respectively and
22960
22961@code{100},
22962@code{102}, @code{103}, @code{104},
22963@code{105}, @code{106}, @code{107}
22964
22965for @var{mcu}=@code{avrtiny},
22966@code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4},
22967@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
22968If @var{mcu} specifies a device, this built-in macro is set
22969accordingly. For example, with @option{-mmcu=atmega8} the macro is
22970defined to @code{4}.
22971
22972@item __AVR_@var{Device}__
22973Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
22974the device's name. For example, @option{-mmcu=atmega8} defines the
22975built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines
22976@code{__AVR_ATtiny261A__}, etc.
22977
22978The built-in macros' names follow
22979the scheme @code{__AVR_@var{Device}__} where @var{Device} is
22980the device name as from the AVR user manual. The difference between
22981@var{Device} in the built-in macro and @var{device} in
22982@option{-mmcu=@var{device}} is that the latter is always lowercase.
22983
22984If @var{device} is not a device but only a core architecture like
22985@samp{avr51}, this macro is not defined.
22986
22987@item __AVR_DEVICE_NAME__
22988Setting @option{-mmcu=@var{device}} defines this built-in macro to
22989the device's name. For example, with @option{-mmcu=atmega8} the macro
22990is defined to @code{atmega8}.
22991
22992If @var{device} is not a device but only a core architecture like
22993@samp{avr51}, this macro is not defined.
22994
22995@item __AVR_XMEGA__
22996The device / architecture belongs to the XMEGA family of devices.
22997
22998@item __AVR_HAVE_ELPM__
22999The device has the @code{ELPM} instruction.
23000
23001@item __AVR_HAVE_ELPMX__
23002The device has the @code{ELPM R@var{n},Z} and @code{ELPM
23003R@var{n},Z+} instructions.
23004
23005@item __AVR_HAVE_MOVW__
23006The device has the @code{MOVW} instruction to perform 16-bit
23007register-register moves.
23008
23009@item __AVR_HAVE_LPMX__
23010The device has the @code{LPM R@var{n},Z} and
23011@code{LPM R@var{n},Z+} instructions.
23012
23013@item __AVR_HAVE_MUL__
23014The device has a hardware multiplier.
23015
23016@item __AVR_HAVE_JMP_CALL__
23017The device has the @code{JMP} and @code{CALL} instructions.
23018This is the case for devices with more than 8@tie{}KiB of program
23019memory.
23020
23021@item __AVR_HAVE_EIJMP_EICALL__
23022@itemx __AVR_3_BYTE_PC__
23023The device has the @code{EIJMP} and @code{EICALL} instructions.
23024This is the case for devices with more than 128@tie{}KiB of program memory.
23025This also means that the program counter
23026(PC) is 3@tie{}bytes wide.
23027
23028@item __AVR_2_BYTE_PC__
23029The program counter (PC) is 2@tie{}bytes wide. This is the case for devices
23030with up to 128@tie{}KiB of program memory.
23031
23032@item __AVR_HAVE_8BIT_SP__
23033@itemx __AVR_HAVE_16BIT_SP__
23034The stack pointer (SP) register is treated as 8-bit respectively
2303516-bit register by the compiler.
23036The definition of these macros is affected by @option{-mtiny-stack}.
23037
23038@item __AVR_HAVE_SPH__
23039@itemx __AVR_SP8__
23040The device has the SPH (high part of stack pointer) special function
23041register or has an 8-bit stack pointer, respectively.
23042The definition of these macros is affected by @option{-mmcu=} and
23043in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also
23044by @option{-msp8}.
23045
23046@item __AVR_HAVE_RAMPD__
23047@itemx __AVR_HAVE_RAMPX__
23048@itemx __AVR_HAVE_RAMPY__
23049@itemx __AVR_HAVE_RAMPZ__
23050The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY},
23051@code{RAMPZ} special function register, respectively.
23052
23053@item __NO_INTERRUPTS__
23054This macro reflects the @option{-mno-interrupts} command-line option.
23055
23056@item __AVR_ERRATA_SKIP__
23057@itemx __AVR_ERRATA_SKIP_JMP_CALL__
23058Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit
23059instructions because of a hardware erratum. Skip instructions are
23060@code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}.
23061The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also
23062set.
23063
23064@item __AVR_ISA_RMW__
23065The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT).
23066
23067@item __AVR_SFR_OFFSET__=@var{offset}
23068Instructions that can address I/O special function registers directly
23069like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different
23070address as if addressed by an instruction to access RAM like @code{LD}
23071or @code{STS}. This offset depends on the device architecture and has
23072to be subtracted from the RAM address in order to get the
23073respective I/O@tie{}address.
23074
23075@item __AVR_SHORT_CALLS__
23076The @option{-mshort-calls} command line option is set.
23077
23078@item __AVR_PM_BASE_ADDRESS__=@var{addr}
23079Some devices support reading from flash memory by means of @code{LD*}
23080instructions. The flash memory is seen in the data address space
23081at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro
23082is not defined, this feature is not available. If defined,
23083the address space is linear and there is no need to put
23084@code{.rodata} into RAM. This is handled by the default linker
23085description file, and is currently available for
23086@code{avrtiny} and @code{avrxmega3}. Even more convenient,
23087there is no need to use address spaces like @code{__flash} or
23088features like attribute @code{progmem} and @code{pgm_read_*}.
23089
23090@item __WITH_AVRLIBC__
23091The compiler is configured to be used together with AVR-Libc.
23092See the @option{--with-avrlibc} configure option.
23093
23094@item __HAVE_DOUBLE_MULTILIB__
23095Defined if @option{-mdouble=} acts as a multilib option.
23096
23097@item __HAVE_DOUBLE32__
23098@itemx __HAVE_DOUBLE64__
23099Defined if the compiler supports 32-bit double resp. 64-bit double.
23100The actual layout is specified by option @option{-mdouble=}.
23101
23102@item __DEFAULT_DOUBLE__
23103The size in bits of @code{double} if @option{-mdouble=} is not set.
23104To test the layout of @code{double} in a program, use the built-in
23105macro @code{__SIZEOF_DOUBLE__}.
23106
23107@item __HAVE_LONG_DOUBLE32__
23108@itemx __HAVE_LONG_DOUBLE64__
23109@itemx __HAVE_LONG_DOUBLE_MULTILIB__
23110@itemx __DEFAULT_LONG_DOUBLE__
23111Same as above, but for @code{long double} instead of @code{double}.
23112
23113@item __WITH_DOUBLE_COMPARISON__
23114Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}}
23115@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}
23116and is defined to @code{2} or @code{3}.
23117
23118@item __WITH_LIBF7_LIBGCC__
23119@itemx __WITH_LIBF7_MATH__
23120@itemx __WITH_LIBF7_MATH_SYMBOLS__
23121Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}}
23122@w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}.
23123
23124@end table
23125
23126@node Blackfin Options
23127@subsection Blackfin Options
23128@cindex Blackfin Options
23129
23130@table @gcctabopt
23131@item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]}
23132@opindex mcpu=
23133Specifies the name of the target Blackfin processor. Currently, @var{cpu}
23134can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518},
23135@samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526},
23136@samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533},
23137@samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539},
23138@samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549},
23139@samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m},
23140@samp{bf561}, @samp{bf592}.
23141
23142The optional @var{sirevision} specifies the silicon revision of the target
23143Blackfin processor. Any workarounds available for the targeted silicon revision
23144are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled.
23145If @var{sirevision} is @samp{any}, all workarounds for the targeted processor
23146are enabled. The @code{__SILICON_REVISION__} macro is defined to two
23147hexadecimal digits representing the major and minor numbers in the silicon
23148revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__}
23149is not defined. If @var{sirevision} is @samp{any}, the
23150@code{__SILICON_REVISION__} is defined to be @code{0xffff}.
23151If this optional @var{sirevision} is not used, GCC assumes the latest known
23152silicon revision of the targeted Blackfin processor.
23153
23154GCC defines a preprocessor macro for the specified @var{cpu}.
23155For the @samp{bfin-elf} toolchain, this option causes the hardware BSP
23156provided by libgloss to be linked in if @option{-msim} is not given.
23157
23158Without this option, @samp{bf532} is used as the processor by default.
23159
23160Note that support for @samp{bf561} is incomplete. For @samp{bf561},
23161only the preprocessor macro is defined.
23162
23163@item -msim
23164@opindex msim
23165Specifies that the program will be run on the simulator. This causes
23166the simulator BSP provided by libgloss to be linked in. This option
23167has effect only for @samp{bfin-elf} toolchain.
23168Certain other options, such as @option{-mid-shared-library} and
23169@option{-mfdpic}, imply @option{-msim}.
23170
23171@item -momit-leaf-frame-pointer
23172@opindex momit-leaf-frame-pointer
23173Don't keep the frame pointer in a register for leaf functions. This
23174avoids the instructions to save, set up and restore frame pointers and
23175makes an extra register available in leaf functions.
23176
23177@item -mspecld-anomaly
23178@opindex mspecld-anomaly
23179When enabled, the compiler ensures that the generated code does not
23180contain speculative loads after jump instructions. If this option is used,
23181@code{__WORKAROUND_SPECULATIVE_LOADS} is defined.
23182
23183@item -mno-specld-anomaly
23184@opindex mno-specld-anomaly
23185@opindex mspecld-anomaly
23186Don't generate extra code to prevent speculative loads from occurring.
23187
23188@item -mcsync-anomaly
23189@opindex mcsync-anomaly
23190When enabled, the compiler ensures that the generated code does not
23191contain CSYNC or SSYNC instructions too soon after conditional branches.
23192If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined.
23193
23194@item -mno-csync-anomaly
23195@opindex mno-csync-anomaly
23196@opindex mcsync-anomaly
23197Don't generate extra code to prevent CSYNC or SSYNC instructions from
23198occurring too soon after a conditional branch.
23199
23200@item -mlow64k
23201@opindex mlow64k
23202When enabled, the compiler is free to take advantage of the knowledge that
23203the entire program fits into the low 64k of memory.
23204
23205@item -mno-low64k
23206@opindex mno-low64k
23207Assume that the program is arbitrarily large. This is the default.
23208
23209@item -mstack-check-l1
23210@opindex mstack-check-l1
23211Do stack checking using information placed into L1 scratchpad memory by the
23212uClinux kernel.
23213
23214@item -mid-shared-library
23215@opindex mid-shared-library
23216Generate code that supports shared libraries via the library ID method.
23217This allows for execute in place and shared libraries in an environment
23218without virtual memory management. This option implies @option{-fPIC}.
23219With a @samp{bfin-elf} target, this option implies @option{-msim}.
23220
23221@item -mno-id-shared-library
23222@opindex mno-id-shared-library
23223@opindex mid-shared-library
23224Generate code that doesn't assume ID-based shared libraries are being used.
23225This is the default.
23226
23227@item -mleaf-id-shared-library
23228@opindex mleaf-id-shared-library
23229Generate code that supports shared libraries via the library ID method,
23230but assumes that this library or executable won't link against any other
23231ID shared libraries. That allows the compiler to use faster code for jumps
23232and calls.
23233
23234@item -mno-leaf-id-shared-library
23235@opindex mno-leaf-id-shared-library
23236@opindex mleaf-id-shared-library
23237Do not assume that the code being compiled won't link against any ID shared
23238libraries. Slower code is generated for jump and call insns.
23239
23240@item -mshared-library-id=n
23241@opindex mshared-library-id
23242Specifies the identification number of the ID-based shared library being
23243compiled. Specifying a value of 0 generates more compact code; specifying
23244other values forces the allocation of that number to the current
23245library but is no more space- or time-efficient than omitting this option.
23246
23247@item -msep-data
23248@opindex msep-data
23249Generate code that allows the data segment to be located in a different
23250area of memory from the text segment. This allows for execute in place in
23251an environment without virtual memory management by eliminating relocations
23252against the text section.
23253
23254@item -mno-sep-data
23255@opindex mno-sep-data
23256@opindex msep-data
23257Generate code that assumes that the data segment follows the text segment.
23258This is the default.
23259
23260@item -mlong-calls
23261@itemx -mno-long-calls
23262@opindex mlong-calls
23263@opindex mno-long-calls
23264Tells the compiler to perform function calls by first loading the
23265address of the function into a register and then performing a subroutine
23266call on this register. This switch is needed if the target function
23267lies outside of the 24-bit addressing range of the offset-based
23268version of subroutine call instruction.
23269
23270This feature is not enabled by default. Specifying
23271@option{-mno-long-calls} restores the default behavior. Note these
23272switches have no effect on how the compiler generates code to handle
23273function calls via function pointers.
23274
23275@item -mfast-fp
23276@opindex mfast-fp
23277Link with the fast floating-point library. This library relaxes some of
23278the IEEE floating-point standard's rules for checking inputs against
23279Not-a-Number (NAN), in the interest of performance.
23280
23281@item -minline-plt
23282@opindex minline-plt
23283Enable inlining of PLT entries in function calls to functions that are
23284not known to bind locally. It has no effect without @option{-mfdpic}.
23285
23286@item -mmulticore
23287@opindex mmulticore
23288Build a standalone application for multicore Blackfin processors.
23289This option causes proper start files and link scripts supporting
23290multicore to be used, and defines the macro @code{__BFIN_MULTICORE}.
23291It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}.
23292
23293This option can be used with @option{-mcorea} or @option{-mcoreb}, which
23294selects the one-application-per-core programming model. Without
23295@option{-mcorea} or @option{-mcoreb}, the single-application/dual-core
23296programming model is used. In this model, the main function of Core B
23297should be named as @code{coreb_main}.
23298
23299If this option is not used, the single-core application programming
23300model is used.
23301
23302@item -mcorea
23303@opindex mcorea
23304Build a standalone application for Core A of BF561 when using
23305the one-application-per-core programming model. Proper start files
23306and link scripts are used to support Core A, and the macro
23307@code{__BFIN_COREA} is defined.
23308This option can only be used in conjunction with @option{-mmulticore}.
23309
23310@item -mcoreb
23311@opindex mcoreb
23312Build a standalone application for Core B of BF561 when using
23313the one-application-per-core programming model. Proper start files
23314and link scripts are used to support Core B, and the macro
23315@code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main}
23316should be used instead of @code{main}.
23317This option can only be used in conjunction with @option{-mmulticore}.
23318
23319@item -msdram
23320@opindex msdram
23321Build a standalone application for SDRAM. Proper start files and
23322link scripts are used to put the application into SDRAM, and the macro
23323@code{__BFIN_SDRAM} is defined.
23324The loader should initialize SDRAM before loading the application.
23325
23326@item -micplb
23327@opindex micplb
23328Assume that ICPLBs are enabled at run time. This has an effect on certain
23329anomaly workarounds. For Linux targets, the default is to assume ICPLBs
23330are enabled; for standalone applications the default is off.
23331@end table
23332
23333@node C6X Options
23334@subsection C6X Options
23335@cindex C6X Options
23336
23337@table @gcctabopt
23338@item -march=@var{name}
23339@opindex march
23340This specifies the name of the target architecture. GCC uses this
23341name to determine what kind of instructions it can emit when generating
23342assembly code. Permissible names are: @samp{c62x},
23343@samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}.
23344
23345@item -mbig-endian
23346@opindex mbig-endian
23347Generate code for a big-endian target.
23348
23349@item -mlittle-endian
23350@opindex mlittle-endian
23351Generate code for a little-endian target. This is the default.
23352
23353@item -msim
23354@opindex msim
23355Choose startup files and linker script suitable for the simulator.
23356
23357@item -msdata=default
23358@opindex msdata=default
23359Put small global and static data in the @code{.neardata} section,
23360which is pointed to by register @code{B14}. Put small uninitialized
23361global and static data in the @code{.bss} section, which is adjacent
23362to the @code{.neardata} section. Put small read-only data into the
23363@code{.rodata} section. The corresponding sections used for large
23364pieces of data are @code{.fardata}, @code{.far} and @code{.const}.
23365
23366@item -msdata=all
23367@opindex msdata=all
23368Put all data, not just small objects, into the sections reserved for
23369small data, and use addressing relative to the @code{B14} register to
23370access them.
23371
23372@item -msdata=none
23373@opindex msdata=none
23374Make no use of the sections reserved for small data, and use absolute
23375addresses to access all data. Put all initialized global and static
23376data in the @code{.fardata} section, and all uninitialized data in the
23377@code{.far} section. Put all constant data into the @code{.const}
23378section.
23379@end table
23380
23381@node CRIS Options
23382@subsection CRIS Options
23383@cindex CRIS Options
23384
23385These options are defined specifically for the CRIS ports.
23386
23387@table @gcctabopt
23388@item -march=@var{architecture-type}
23389@itemx -mcpu=@var{architecture-type}
23390@opindex march
23391@opindex mcpu
23392Generate code for the specified architecture. The choices for
23393@var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for
23394respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@.
23395Default is @samp{v0}.
23396
23397@item -mtune=@var{architecture-type}
23398@opindex mtune
23399Tune to @var{architecture-type} everything applicable about the generated
23400code, except for the ABI and the set of available instructions. The
23401choices for @var{architecture-type} are the same as for
23402@option{-march=@var{architecture-type}}.
23403
23404@item -mmax-stack-frame=@var{n}
23405@opindex mmax-stack-frame
23406Warn when the stack frame of a function exceeds @var{n} bytes.
23407
23408@item -metrax4
23409@itemx -metrax100
23410@opindex metrax4
23411@opindex metrax100
23412The options @option{-metrax4} and @option{-metrax100} are synonyms for
23413@option{-march=v3} and @option{-march=v8} respectively.
23414
23415@item -mmul-bug-workaround
23416@itemx -mno-mul-bug-workaround
23417@opindex mmul-bug-workaround
23418@opindex mno-mul-bug-workaround
23419Work around a bug in the @code{muls} and @code{mulu} instructions for CPU
23420models where it applies. This option is disabled by default.
23421
23422@item -mpdebug
23423@opindex mpdebug
23424Enable CRIS-specific verbose debug-related information in the assembly
23425code. This option also has the effect of turning off the @samp{#NO_APP}
23426formatted-code indicator to the assembler at the beginning of the
23427assembly file.
23428
23429@item -mcc-init
23430@opindex mcc-init
23431Do not use condition-code results from previous instruction; always emit
23432compare and test instructions before use of condition codes.
23433
23434@item -mno-side-effects
23435@opindex mno-side-effects
23436@opindex mside-effects
23437Do not emit instructions with side effects in addressing modes other than
23438post-increment.
23439
23440@item -mstack-align
23441@itemx -mno-stack-align
23442@itemx -mdata-align
23443@itemx -mno-data-align
23444@itemx -mconst-align
23445@itemx -mno-const-align
23446@opindex mstack-align
23447@opindex mno-stack-align
23448@opindex mdata-align
23449@opindex mno-data-align
23450@opindex mconst-align
23451@opindex mno-const-align
23452These options (@samp{no-} options) arrange (eliminate arrangements) for the
23453stack frame, individual data and constants to be aligned for the maximum
23454single data access size for the chosen CPU model. The default is to
23455arrange for 32-bit alignment. ABI details such as structure layout are
23456not affected by these options.
23457
23458@item -m32-bit
23459@itemx -m16-bit
23460@itemx -m8-bit
23461@opindex m32-bit
23462@opindex m16-bit
23463@opindex m8-bit
23464Similar to the stack- data- and const-align options above, these options
23465arrange for stack frame, writable data and constants to all be 32-bit,
2346616-bit or 8-bit aligned. The default is 32-bit alignment.
23467
23468@item -mno-prologue-epilogue
23469@itemx -mprologue-epilogue
23470@opindex mno-prologue-epilogue
23471@opindex mprologue-epilogue
23472With @option{-mno-prologue-epilogue}, the normal function prologue and
23473epilogue which set up the stack frame are omitted and no return
23474instructions or return sequences are generated in the code. Use this
23475option only together with visual inspection of the compiled code: no
23476warnings or errors are generated when call-saved registers must be saved,
23477or storage for local variables needs to be allocated.
23478
23479@item -melf
23480@opindex melf
23481Legacy no-op option.
23482
23483@item -sim
23484@opindex sim
23485This option arranges
23486to link with input-output functions from a simulator library. Code,
23487initialized data and zero-initialized data are allocated consecutively.
23488
23489@item -sim2
23490@opindex sim2
23491Like @option{-sim}, but pass linker options to locate initialized data at
234920x40000000 and zero-initialized data at 0x80000000.
23493@end table
23494
23495@node C-SKY Options
23496@subsection C-SKY Options
23497@cindex C-SKY Options
23498
23499GCC supports these options when compiling for C-SKY V2 processors.
23500
23501@table @gcctabopt
23502
23503@item -march=@var{arch}
23504@opindex march=
23505Specify the C-SKY target architecture. Valid values for @var{arch} are:
23506@samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}.
23507The default is @samp{ck810}.
23508
23509@item -mcpu=@var{cpu}
23510@opindex mcpu=
23511Specify the C-SKY target processor. Valid values for @var{cpu} are:
23512@samp{ck801}, @samp{ck801t},
23513@samp{ck802}, @samp{ck802t}, @samp{ck802j},
23514@samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht},
23515@samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh},
23516@samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh},
23517@samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1},
23518@samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1},
23519@samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1},
23520@samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1},
23521@samp{ck803eftr1}, @samp{ck803efhtr1},
23522@samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf},
23523@samp{ck803sef}, @samp{ck803seft},
23524@samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f},
23525@samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft},
23526@samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv},
23527@samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}.
23528
23529@item -mbig-endian
23530@opindex mbig-endian
23531@itemx -EB
23532@opindex EB
23533@itemx -mlittle-endian
23534@opindex mlittle-endian
23535@itemx -EL
23536@opindex EL
23537
23538Select big- or little-endian code. The default is little-endian.
23539
23540@item -mfloat-abi=@var{name}
23541@opindex mfloat-abi
23542Specifies which floating-point ABI to use. Permissible values
23543are: @samp{soft}, @samp{softfp} and @samp{hard}.
23544
23545Specifying @samp{soft} causes GCC to generate output containing
23546library calls for floating-point operations.
23547@samp{softfp} allows the generation of code using hardware floating-point
23548instructions, but still uses the soft-float calling conventions.
23549@samp{hard} allows generation of floating-point instructions
23550and uses FPU-specific calling conventions.
23551
23552The default depends on the specific target configuration. Note that
23553the hard-float and soft-float ABIs are not link-compatible; you must
23554compile your entire program with the same ABI, and link with a
23555compatible set of libraries.
23556
23557@item -mhard-float
23558@opindex mhard-float
23559@itemx -msoft-float
23560@opindex msoft-float
23561
23562Select hardware or software floating-point implementations.
23563The default is soft float.
23564
23565@item -mdouble-float
23566@itemx -mno-double-float
23567@opindex mdouble-float
23568When @option{-mhard-float} is in effect, enable generation of
23569double-precision float instructions. This is the default except
23570when compiling for CK803.
23571
23572@item -mfdivdu
23573@itemx -mno-fdivdu
23574@opindex mfdivdu
23575When @option{-mhard-float} is in effect, enable generation of
23576@code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions.
23577This is the default except when compiling for CK803.
23578
23579@item -mfpu=@var{fpu}
23580@opindex mfpu=
23581Select the floating-point processor. This option can only be used with
23582@option{-mhard-float}.
23583Values for @var{fpu} are
23584@samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}),
23585@samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and
23586@samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}).
23587
23588@item -melrw
23589@itemx -mno-elrw
23590@opindex melrw
23591Enable the extended @code{lrw} instruction. This option defaults to on
23592for CK801 and off otherwise.
23593
23594@item -mistack
23595@itemx -mno-istack
23596@opindex mistack
23597Enable interrupt stack instructions; the default is off.
23598
23599The @option{-mistack} option is required to handle the
23600@code{interrupt} and @code{isr} function attributes
23601(@pxref{C-SKY Function Attributes}).
23602
23603@item -mmp
23604@opindex mmp
23605Enable multiprocessor instructions; the default is off.
23606
23607@item -mcp
23608@opindex mcp
23609Enable coprocessor instructions; the default is off.
23610
23611@item -mcache
23612@opindex mcache
23613Enable coprocessor instructions; the default is off.
23614
23615@item -msecurity
23616@opindex msecurity
23617Enable C-SKY security instructions; the default is off.
23618
23619@item -mtrust
23620@opindex mtrust
23621Enable C-SKY trust instructions; the default is off.
23622
23623@item -mdsp
23624@opindex mdsp
23625@itemx -medsp
23626@opindex medsp
23627@itemx -mvdsp
23628@opindex mvdsp
23629Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively.
23630All of these options default to off.
23631
23632@item -mdiv
23633@itemx -mno-div
23634@opindex mdiv
23635Generate divide instructions. Default is off.
23636
23637@item -msmart
23638@itemx -mno-smart
23639@opindex msmart
23640Generate code for Smart Mode, using only registers numbered 0-7 to allow
23641use of 16-bit instructions. This option is ignored for CK801 where this
23642is the required behavior, and it defaults to on for CK802.
23643For other targets, the default is off.
23644
23645@item -mhigh-registers
23646@itemx -mno-high-registers
23647@opindex mhigh-registers
23648Generate code using the high registers numbered 16-31. This option
23649is not supported on CK801, CK802, or CK803, and is enabled by default
23650for other processors.
23651
23652@item -manchor
23653@itemx -mno-anchor
23654@opindex manchor
23655Generate code using global anchor symbol addresses.
23656
23657@item -mpushpop
23658@itemx -mno-pushpop
23659@opindex mpushpop
23660Generate code using @code{push} and @code{pop} instructions. This option
23661defaults to on.
23662
23663@item -mmultiple-stld
23664@itemx -mstm
23665@itemx -mno-multiple-stld
23666@itemx -mno-stm
23667@opindex mmultiple-stld
23668Generate code using @code{stm} and @code{ldm} instructions. This option
23669isn't supported on CK801 but is enabled by default on other processors.
23670
23671@item -mconstpool
23672@itemx -mno-constpool
23673@opindex mconstpool
23674Create constant pools in the compiler instead of deferring it to the
23675assembler. This option is the default and required for correct code
23676generation on CK801 and CK802, and is optional on other processors.
23677
23678@item -mstack-size
23679@item -mno-stack-size
23680@opindex mstack-size
23681Emit @code{.stack_size} directives for each function in the assembly
23682output. This option defaults to off.
23683
23684@item -mccrt
23685@itemx -mno-ccrt
23686@opindex mccrt
23687Generate code for the C-SKY compiler runtime instead of libgcc. This
23688option defaults to off.
23689
23690@item -mbranch-cost=@var{n}
23691@opindex mbranch-cost=
23692Set the branch costs to roughly @code{n} instructions. The default is 1.
23693
23694@item -msched-prolog
23695@itemx -mno-sched-prolog
23696@opindex msched-prolog
23697Permit scheduling of function prologue and epilogue sequences. Using
23698this option can result in code that is not compliant with the C-SKY V2 ABI
23699prologue requirements and that cannot be debugged or backtraced.
23700It is disabled by default.
23701
23702@item -msim
23703@opindex msim
23704Links the library libsemi.a which is in compatible with simulator. Applicable
23705to ELF compiler only.
23706
23707@end table
23708
23709@node Darwin Options
23710@subsection Darwin Options
23711@cindex Darwin options
23712
23713These options are defined for all architectures running the Darwin operating
23714system.
23715
23716FSF GCC on Darwin does not create ``fat'' object files; it creates
23717an object file for the single architecture that GCC was built to
23718target. Apple's GCC on Darwin does create ``fat'' files if multiple
23719@option{-arch} options are used; it does so by running the compiler or
23720linker multiple times and joining the results together with
23721@file{lipo}.
23722
23723The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or
23724@samp{i686}) is determined by the flags that specify the ISA
23725that GCC is targeting, like @option{-mcpu} or @option{-march}. The
23726@option{-force_cpusubtype_ALL} option can be used to override this.
23727
23728The Darwin tools vary in their behavior when presented with an ISA
23729mismatch. The assembler, @file{as}, only permits instructions to
23730be used that are valid for the subtype of the file it is generating,
23731so you cannot put 64-bit instructions in a @samp{ppc750} object file.
23732The linker for shared libraries, @file{/usr/bin/libtool}, fails
23733and prints an error if asked to create a shared library with a less
23734restrictive subtype than its input files (for instance, trying to put
23735a @samp{ppc970} object file in a @samp{ppc7400} library). The linker
23736for executables, @command{ld}, quietly gives the executable the most
23737restrictive subtype of any of its input files.
23738
23739@table @gcctabopt
23740@item -F@var{dir}
23741@opindex F
23742Add the framework directory @var{dir} to the head of the list of
23743directories to be searched for header files. These directories are
23744interleaved with those specified by @option{-I} options and are
23745scanned in a left-to-right order.
23746
23747A framework directory is a directory with frameworks in it. A
23748framework is a directory with a @file{Headers} and/or
23749@file{PrivateHeaders} directory contained directly in it that ends
23750in @file{.framework}. The name of a framework is the name of this
23751directory excluding the @file{.framework}. Headers associated with
23752the framework are found in one of those two directories, with
23753@file{Headers} being searched first. A subframework is a framework
23754directory that is in a framework's @file{Frameworks} directory.
23755Includes of subframework headers can only appear in a header of a
23756framework that contains the subframework, or in a sibling subframework
23757header. Two subframeworks are siblings if they occur in the same
23758framework. A subframework should not have the same name as a
23759framework; a warning is issued if this is violated. Currently a
23760subframework cannot have subframeworks; in the future, the mechanism
23761may be extended to support this. The standard frameworks can be found
23762in @file{/System/Library/Frameworks} and
23763@file{/Library/Frameworks}. An example include looks like
23764@code{#include <Framework/header.h>}, where @file{Framework} denotes
23765the name of the framework and @file{header.h} is found in the
23766@file{PrivateHeaders} or @file{Headers} directory.
23767
23768@item -iframework@var{dir}
23769@opindex iframework
23770Like @option{-F} except the directory is a treated as a system
23771directory. The main difference between this @option{-iframework} and
23772@option{-F} is that with @option{-iframework} the compiler does not
23773warn about constructs contained within header files found via
23774@var{dir}. This option is valid only for the C family of languages.
23775
23776@item -gused
23777@opindex gused
23778Emit debugging information for symbols that are used. For stabs
23779debugging format, this enables @option{-feliminate-unused-debug-symbols}.
23780This is by default ON@.
23781
23782@item -gfull
23783@opindex gfull
23784Emit debugging information for all symbols and types.
23785
23786@item -mmacosx-version-min=@var{version}
23787The earliest version of MacOS X that this executable will run on
23788is @var{version}. Typical values of @var{version} include @code{10.1},
23789@code{10.2}, and @code{10.3.9}.
23790
23791If the compiler was built to use the system's headers by default,
23792then the default for this option is the system version on which the
23793compiler is running, otherwise the default is to make choices that
23794are compatible with as many systems and code bases as possible.
23795
23796@item -mkernel
23797@opindex mkernel
23798Enable kernel development mode. The @option{-mkernel} option sets
23799@option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit},
23800@option{-fno-exceptions}, @option{-fno-non-call-exceptions},
23801@option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where
23802applicable. This mode also sets @option{-mno-altivec},
23803@option{-msoft-float}, @option{-fno-builtin} and
23804@option{-mlong-branch} for PowerPC targets.
23805
23806@item -mone-byte-bool
23807@opindex mone-byte-bool
23808Override the defaults for @code{bool} so that @code{sizeof(bool)==1}.
23809By default @code{sizeof(bool)} is @code{4} when compiling for
23810Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this
23811option has no effect on x86.
23812
23813@strong{Warning:} The @option{-mone-byte-bool} switch causes GCC
23814to generate code that is not binary compatible with code generated
23815without that switch. Using this switch may require recompiling all
23816other modules in a program, including system libraries. Use this
23817switch to conform to a non-default data model.
23818
23819@item -mfix-and-continue
23820@itemx -ffix-and-continue
23821@itemx -findirect-data
23822@opindex mfix-and-continue
23823@opindex ffix-and-continue
23824@opindex findirect-data
23825Generate code suitable for fast turnaround development, such as to
23826allow GDB to dynamically load @file{.o} files into already-running
23827programs. @option{-findirect-data} and @option{-ffix-and-continue}
23828are provided for backwards compatibility.
23829
23830@item -all_load
23831@opindex all_load
23832Loads all members of static archive libraries.
23833See man ld(1) for more information.
23834
23835@item -arch_errors_fatal
23836@opindex arch_errors_fatal
23837Cause the errors having to do with files that have the wrong architecture
23838to be fatal.
23839
23840@item -bind_at_load
23841@opindex bind_at_load
23842Causes the output file to be marked such that the dynamic linker will
23843bind all undefined references when the file is loaded or launched.
23844
23845@item -bundle
23846@opindex bundle
23847Produce a Mach-o bundle format file.
23848See man ld(1) for more information.
23849
23850@item -bundle_loader @var{executable}
23851@opindex bundle_loader
23852This option specifies the @var{executable} that will load the build
23853output file being linked. See man ld(1) for more information.
23854
23855@item -dynamiclib
23856@opindex dynamiclib
23857When passed this option, GCC produces a dynamic library instead of
23858an executable when linking, using the Darwin @file{libtool} command.
23859
23860@item -force_cpusubtype_ALL
23861@opindex force_cpusubtype_ALL
23862This causes GCC's output file to have the @samp{ALL} subtype, instead of
23863one controlled by the @option{-mcpu} or @option{-march} option.
23864
23865@item -allowable_client @var{client_name}
23866@itemx -client_name
23867@itemx -compatibility_version
23868@itemx -current_version
23869@itemx -dead_strip
23870@itemx -dependency-file
23871@itemx -dylib_file
23872@itemx -dylinker_install_name
23873@itemx -dynamic
23874@itemx -exported_symbols_list
23875@itemx -filelist
23876@need 800
23877@itemx -flat_namespace
23878@itemx -force_flat_namespace
23879@itemx -headerpad_max_install_names
23880@itemx -image_base
23881@itemx -init
23882@itemx -install_name
23883@itemx -keep_private_externs
23884@itemx -multi_module
23885@itemx -multiply_defined
23886@itemx -multiply_defined_unused
23887@need 800
23888@itemx -noall_load
23889@itemx -no_dead_strip_inits_and_terms
23890@itemx -nofixprebinding
23891@itemx -nomultidefs
23892@itemx -noprebind
23893@itemx -noseglinkedit
23894@itemx -pagezero_size
23895@itemx -prebind
23896@itemx -prebind_all_twolevel_modules
23897@itemx -private_bundle
23898@need 800
23899@itemx -read_only_relocs
23900@itemx -sectalign
23901@itemx -sectobjectsymbols
23902@itemx -whyload
23903@itemx -seg1addr
23904@itemx -sectcreate
23905@itemx -sectobjectsymbols
23906@itemx -sectorder
23907@itemx -segaddr
23908@itemx -segs_read_only_addr
23909@need 800
23910@itemx -segs_read_write_addr
23911@itemx -seg_addr_table
23912@itemx -seg_addr_table_filename
23913@itemx -seglinkedit
23914@itemx -segprot
23915@itemx -segs_read_only_addr
23916@itemx -segs_read_write_addr
23917@itemx -single_module
23918@itemx -static
23919@itemx -sub_library
23920@need 800
23921@itemx -sub_umbrella
23922@itemx -twolevel_namespace
23923@itemx -umbrella
23924@itemx -undefined
23925@itemx -unexported_symbols_list
23926@itemx -weak_reference_mismatches
23927@itemx -whatsloaded
23928@opindex allowable_client
23929@opindex client_name
23930@opindex compatibility_version
23931@opindex current_version
23932@opindex dead_strip
23933@opindex dependency-file
23934@opindex dylib_file
23935@opindex dylinker_install_name
23936@opindex dynamic
23937@opindex exported_symbols_list
23938@opindex filelist
23939@opindex flat_namespace
23940@opindex force_flat_namespace
23941@opindex headerpad_max_install_names
23942@opindex image_base
23943@opindex init
23944@opindex install_name
23945@opindex keep_private_externs
23946@opindex multi_module
23947@opindex multiply_defined
23948@opindex multiply_defined_unused
23949@opindex noall_load
23950@opindex no_dead_strip_inits_and_terms
23951@opindex nofixprebinding
23952@opindex nomultidefs
23953@opindex noprebind
23954@opindex noseglinkedit
23955@opindex pagezero_size
23956@opindex prebind
23957@opindex prebind_all_twolevel_modules
23958@opindex private_bundle
23959@opindex read_only_relocs
23960@opindex sectalign
23961@opindex sectobjectsymbols
23962@opindex whyload
23963@opindex seg1addr
23964@opindex sectcreate
23965@opindex sectobjectsymbols
23966@opindex sectorder
23967@opindex segaddr
23968@opindex segs_read_only_addr
23969@opindex segs_read_write_addr
23970@opindex seg_addr_table
23971@opindex seg_addr_table_filename
23972@opindex seglinkedit
23973@opindex segprot
23974@opindex segs_read_only_addr
23975@opindex segs_read_write_addr
23976@opindex single_module
23977@opindex static
23978@opindex sub_library
23979@opindex sub_umbrella
23980@opindex twolevel_namespace
23981@opindex umbrella
23982@opindex undefined
23983@opindex unexported_symbols_list
23984@opindex weak_reference_mismatches
23985@opindex whatsloaded
23986These options are passed to the Darwin linker. The Darwin linker man page
23987describes them in detail.
23988@end table
23989
23990@node DEC Alpha Options
23991@subsection DEC Alpha Options
23992
23993These @samp{-m} options are defined for the DEC Alpha implementations:
23994
23995@table @gcctabopt
23996@item -mno-soft-float
23997@itemx -msoft-float
23998@opindex mno-soft-float
23999@opindex msoft-float
24000Use (do not use) the hardware floating-point instructions for
24001floating-point operations. When @option{-msoft-float} is specified,
24002functions in @file{libgcc.a} are used to perform floating-point
24003operations. Unless they are replaced by routines that emulate the
24004floating-point operations, or compiled in such a way as to call such
24005emulations routines, these routines issue floating-point
24006operations. If you are compiling for an Alpha without floating-point
24007operations, you must ensure that the library is built so as not to call
24008them.
24009
24010Note that Alpha implementations without floating-point operations are
24011required to have floating-point registers.
24012
24013@item -mfp-reg
24014@itemx -mno-fp-regs
24015@opindex mfp-reg
24016@opindex mno-fp-regs
24017Generate code that uses (does not use) the floating-point register set.
24018@option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point
24019register set is not used, floating-point operands are passed in integer
24020registers as if they were integers and floating-point results are passed
24021in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence,
24022so any function with a floating-point argument or return value called by code
24023compiled with @option{-mno-fp-regs} must also be compiled with that
24024option.
24025
24026A typical use of this option is building a kernel that does not use,
24027and hence need not save and restore, any floating-point registers.
24028
24029@item -mieee
24030@opindex mieee
24031The Alpha architecture implements floating-point hardware optimized for
24032maximum performance. It is mostly compliant with the IEEE floating-point
24033standard. However, for full compliance, software assistance is
24034required. This option generates code fully IEEE-compliant code
24035@emph{except} that the @var{inexact-flag} is not maintained (see below).
24036If this option is turned on, the preprocessor macro @code{_IEEE_FP} is
24037defined during compilation. The resulting code is less efficient but is
24038able to correctly support denormalized numbers and exceptional IEEE
24039values such as not-a-number and plus/minus infinity. Other Alpha
24040compilers call this option @option{-ieee_with_no_inexact}.
24041
24042@item -mieee-with-inexact
24043@opindex mieee-with-inexact
24044This is like @option{-mieee} except the generated code also maintains
24045the IEEE @var{inexact-flag}. Turning on this option causes the
24046generated code to implement fully-compliant IEEE math. In addition to
24047@code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor
24048macro. On some Alpha implementations the resulting code may execute
24049significantly slower than the code generated by default. Since there is
24050very little code that depends on the @var{inexact-flag}, you should
24051normally not specify this option. Other Alpha compilers call this
24052option @option{-ieee_with_inexact}.
24053
24054@item -mfp-trap-mode=@var{trap-mode}
24055@opindex mfp-trap-mode
24056This option controls what floating-point related traps are enabled.
24057Other Alpha compilers call this option @option{-fptm @var{trap-mode}}.
24058The trap mode can be set to one of four values:
24059
24060@table @samp
24061@item n
24062This is the default (normal) setting. The only traps that are enabled
24063are the ones that cannot be disabled in software (e.g., division by zero
24064trap).
24065
24066@item u
24067In addition to the traps enabled by @samp{n}, underflow traps are enabled
24068as well.
24069
24070@item su
24071Like @samp{u}, but the instructions are marked to be safe for software
24072completion (see Alpha architecture manual for details).
24073
24074@item sui
24075Like @samp{su}, but inexact traps are enabled as well.
24076@end table
24077
24078@item -mfp-rounding-mode=@var{rounding-mode}
24079@opindex mfp-rounding-mode
24080Selects the IEEE rounding mode. Other Alpha compilers call this option
24081@option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one
24082of:
24083
24084@table @samp
24085@item n
24086Normal IEEE rounding mode. Floating-point numbers are rounded towards
24087the nearest machine number or towards the even machine number in case
24088of a tie.
24089
24090@item m
24091Round towards minus infinity.
24092
24093@item c
24094Chopped rounding mode. Floating-point numbers are rounded towards zero.
24095
24096@item d
24097Dynamic rounding mode. A field in the floating-point control register
24098(@var{fpcr}, see Alpha architecture reference manual) controls the
24099rounding mode in effect. The C library initializes this register for
24100rounding towards plus infinity. Thus, unless your program modifies the
24101@var{fpcr}, @samp{d} corresponds to round towards plus infinity.
24102@end table
24103
24104@item -mtrap-precision=@var{trap-precision}
24105@opindex mtrap-precision
24106In the Alpha architecture, floating-point traps are imprecise. This
24107means without software assistance it is impossible to recover from a
24108floating trap and program execution normally needs to be terminated.
24109GCC can generate code that can assist operating system trap handlers
24110in determining the exact location that caused a floating-point trap.
24111Depending on the requirements of an application, different levels of
24112precisions can be selected:
24113
24114@table @samp
24115@item p
24116Program precision. This option is the default and means a trap handler
24117can only identify which program caused a floating-point exception.
24118
24119@item f
24120Function precision. The trap handler can determine the function that
24121caused a floating-point exception.
24122
24123@item i
24124Instruction precision. The trap handler can determine the exact
24125instruction that caused a floating-point exception.
24126@end table
24127
24128Other Alpha compilers provide the equivalent options called
24129@option{-scope_safe} and @option{-resumption_safe}.
24130
24131@item -mieee-conformant
24132@opindex mieee-conformant
24133This option marks the generated code as IEEE conformant. You must not
24134use this option unless you also specify @option{-mtrap-precision=i} and either
24135@option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect
24136is to emit the line @samp{.eflag 48} in the function prologue of the
24137generated assembly file.
24138
24139@item -mbuild-constants
24140@opindex mbuild-constants
24141Normally GCC examines a 32- or 64-bit integer constant to
24142see if it can construct it from smaller constants in two or three
24143instructions. If it cannot, it outputs the constant as a literal and
24144generates code to load it from the data segment at run time.
24145
24146Use this option to require GCC to construct @emph{all} integer constants
24147using code, even if it takes more instructions (the maximum is six).
24148
24149You typically use this option to build a shared library dynamic
24150loader. Itself a shared library, it must relocate itself in memory
24151before it can find the variables and constants in its own data segment.
24152
24153@item -mbwx
24154@itemx -mno-bwx
24155@itemx -mcix
24156@itemx -mno-cix
24157@itemx -mfix
24158@itemx -mno-fix
24159@itemx -mmax
24160@itemx -mno-max
24161@opindex mbwx
24162@opindex mno-bwx
24163@opindex mcix
24164@opindex mno-cix
24165@opindex mfix
24166@opindex mno-fix
24167@opindex mmax
24168@opindex mno-max
24169Indicate whether GCC should generate code to use the optional BWX,
24170CIX, FIX and MAX instruction sets. The default is to use the instruction
24171sets supported by the CPU type specified via @option{-mcpu=} option or that
24172of the CPU on which GCC was built if none is specified.
24173
24174@item -mfloat-vax
24175@itemx -mfloat-ieee
24176@opindex mfloat-vax
24177@opindex mfloat-ieee
24178Generate code that uses (does not use) VAX F and G floating-point
24179arithmetic instead of IEEE single and double precision.
24180
24181@item -mexplicit-relocs
24182@itemx -mno-explicit-relocs
24183@opindex mexplicit-relocs
24184@opindex mno-explicit-relocs
24185Older Alpha assemblers provided no way to generate symbol relocations
24186except via assembler macros. Use of these macros does not allow
24187optimal instruction scheduling. GNU binutils as of version 2.12
24188supports a new syntax that allows the compiler to explicitly mark
24189which relocations should apply to which instructions. This option
24190is mostly useful for debugging, as GCC detects the capabilities of
24191the assembler when it is built and sets the default accordingly.
24192
24193@item -msmall-data
24194@itemx -mlarge-data
24195@opindex msmall-data
24196@opindex mlarge-data
24197When @option{-mexplicit-relocs} is in effect, static data is
24198accessed via @dfn{gp-relative} relocations. When @option{-msmall-data}
24199is used, objects 8 bytes long or smaller are placed in a @dfn{small data area}
24200(the @code{.sdata} and @code{.sbss} sections) and are accessed via
2420116-bit relocations off of the @code{$gp} register. This limits the
24202size of the small data area to 64KB, but allows the variables to be
24203directly accessed via a single instruction.
24204
24205The default is @option{-mlarge-data}. With this option the data area
24206is limited to just below 2GB@. Programs that require more than 2GB of
24207data must use @code{malloc} or @code{mmap} to allocate the data in the
24208heap instead of in the program's data segment.
24209
24210When generating code for shared libraries, @option{-fpic} implies
24211@option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}.
24212
24213@item -msmall-text
24214@itemx -mlarge-text
24215@opindex msmall-text
24216@opindex mlarge-text
24217When @option{-msmall-text} is used, the compiler assumes that the
24218code of the entire program (or shared library) fits in 4MB, and is
24219thus reachable with a branch instruction. When @option{-msmall-data}
24220is used, the compiler can assume that all local symbols share the
24221same @code{$gp} value, and thus reduce the number of instructions
24222required for a function call from 4 to 1.
24223
24224The default is @option{-mlarge-text}.
24225
24226@item -mcpu=@var{cpu_type}
24227@opindex mcpu
24228Set the instruction set and instruction scheduling parameters for
24229machine type @var{cpu_type}. You can specify either the @samp{EV}
24230style name or the corresponding chip number. GCC supports scheduling
24231parameters for the EV4, EV5 and EV6 family of processors and
24232chooses the default values for the instruction set from the processor
24233you specify. If you do not specify a processor type, GCC defaults
24234to the processor on which the compiler was built.
24235
24236Supported values for @var{cpu_type} are
24237
24238@table @samp
24239@item ev4
24240@itemx ev45
24241@itemx 21064
24242Schedules as an EV4 and has no instruction set extensions.
24243
24244@item ev5
24245@itemx 21164
24246Schedules as an EV5 and has no instruction set extensions.
24247
24248@item ev56
24249@itemx 21164a
24250Schedules as an EV5 and supports the BWX extension.
24251
24252@item pca56
24253@itemx 21164pc
24254@itemx 21164PC
24255Schedules as an EV5 and supports the BWX and MAX extensions.
24256
24257@item ev6
24258@itemx 21264
24259Schedules as an EV6 and supports the BWX, FIX, and MAX extensions.
24260
24261@item ev67
24262@itemx 21264a
24263Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions.
24264@end table
24265
24266Native toolchains also support the value @samp{native},
24267which selects the best architecture option for the host processor.
24268@option{-mcpu=native} has no effect if GCC does not recognize
24269the processor.
24270
24271@item -mtune=@var{cpu_type}
24272@opindex mtune
24273Set only the instruction scheduling parameters for machine type
24274@var{cpu_type}. The instruction set is not changed.
24275
24276Native toolchains also support the value @samp{native},
24277which selects the best architecture option for the host processor.
24278@option{-mtune=native} has no effect if GCC does not recognize
24279the processor.
24280
24281@item -mmemory-latency=@var{time}
24282@opindex mmemory-latency
24283Sets the latency the scheduler should assume for typical memory
24284references as seen by the application. This number is highly
24285dependent on the memory access patterns used by the application
24286and the size of the external cache on the machine.
24287
24288Valid options for @var{time} are
24289
24290@table @samp
24291@item @var{number}
24292A decimal number representing clock cycles.
24293
24294@item L1
24295@itemx L2
24296@itemx L3
24297@itemx main
24298The compiler contains estimates of the number of clock cycles for
24299``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches
24300(also called Dcache, Scache, and Bcache), as well as to main memory.
24301Note that L3 is only valid for EV5.
24302
24303@end table
24304@end table
24305
24306@node eBPF Options
24307@subsection eBPF Options
24308@cindex eBPF Options
24309
24310@table @gcctabopt
24311@item -mframe-limit=@var{bytes}
24312This specifies the hard limit for frame sizes, in bytes. Currently,
24313the value that can be specified should be less than or equal to
24314@samp{32767}. Defaults to whatever limit is imposed by the version of
24315the Linux kernel targeted.
24316
24317@item -mkernel=@var{version}
24318@opindex mkernel
24319This specifies the minimum version of the kernel that will run the
24320compiled program. GCC uses this version to determine which
24321instructions to use, what kernel helpers to allow, etc. Currently,
24322@var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2},
24323@samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7},
24324@samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12},
24325@samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17},
24326@samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1},
24327@samp{5.2}, @samp{latest} and @samp{native}.
24328
24329@item -mbig-endian
24330@opindex mbig-endian
24331Generate code for a big-endian target.
24332
24333@item -mlittle-endian
24334@opindex mlittle-endian
24335Generate code for a little-endian target. This is the default.
24336
24337@item -mjmpext
24338@opindex mjmpext
24339Enable generation of extra conditional-branch instructions.
24340Enabled for CPU v2 and above.
24341
24342@item -mjmp32
24343@opindex mjmp32
24344Enable 32-bit jump instructions. Enabled for CPU v3 and above.
24345
24346@item -malu32
24347@opindex malu32
24348Enable 32-bit ALU instructions. Enabled for CPU v3 and above.
24349
24350@item -mcpu=@var{version}
24351@opindex mcpu
24352This specifies which version of the eBPF ISA to target. Newer versions
24353may not be supported by all kernels. The default is @samp{v3}.
24354
24355Supported values for @var{version} are:
24356
24357@table @samp
24358@item v1
24359The first stable eBPF ISA with no special features or extensions.
24360
24361@item v2
24362Supports the jump extensions, as in @option{-mjmpext}.
24363
24364@item v3
24365All features of v2, plus:
24366@itemize @minus
24367@item 32-bit jump operations, as in @option{-mjmp32}
24368@item 32-bit ALU operations, as in @option{-malu32}
24369@end itemize
24370
24371@end table
24372
24373@item -mco-re
24374@opindex mco-re
24375Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and
24376is implied by @option{-gbtf}.
24377
24378@item -mno-co-re
24379@opindex mno-co-re
24380Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE
24381support is enabled by default when generating BTF debug information for
24382the BPF target.
24383
24384@item -mxbpf
24385Generate code for an expanded version of BPF, which relaxes some of
24386the restrictions imposed by the BPF architecture:
24387@itemize @minus
24388@item Save and restore callee-saved registers at function entry and
24389exit, respectively.
24390@end itemize
24391@end table
24392
24393@node FR30 Options
24394@subsection FR30 Options
24395@cindex FR30 Options
24396
24397These options are defined specifically for the FR30 port.
24398
24399@table @gcctabopt
24400
24401@item -msmall-model
24402@opindex msmall-model
24403Use the small address space model. This can produce smaller code, but
24404it does assume that all symbolic values and addresses fit into a
2440520-bit range.
24406
24407@item -mno-lsim
24408@opindex mno-lsim
24409Assume that runtime support has been provided and so there is no need
24410to include the simulator library (@file{libsim.a}) on the linker
24411command line.
24412
24413@end table
24414
24415@node FT32 Options
24416@subsection FT32 Options
24417@cindex FT32 Options
24418
24419These options are defined specifically for the FT32 port.
24420
24421@table @gcctabopt
24422
24423@item -msim
24424@opindex msim
24425Specifies that the program will be run on the simulator. This causes
24426an alternate runtime startup and library to be linked.
24427You must not use this option when generating programs that will run on
24428real hardware; you must provide your own runtime library for whatever
24429I/O functions are needed.
24430
24431@item -mlra
24432@opindex mlra
24433Enable Local Register Allocation. This is still experimental for FT32,
24434so by default the compiler uses standard reload.
24435
24436@item -mnodiv
24437@opindex mnodiv
24438Do not use div and mod instructions.
24439
24440@item -mft32b
24441@opindex mft32b
24442Enable use of the extended instructions of the FT32B processor.
24443
24444@item -mcompress
24445@opindex mcompress
24446Compress all code using the Ft32B code compression scheme.
24447
24448@item -mnopm
24449@opindex mnopm
24450Do not generate code that reads program memory.
24451
24452@end table
24453
24454@node FRV Options
24455@subsection FRV Options
24456@cindex FRV Options
24457
24458@table @gcctabopt
24459@item -mgpr-32
24460@opindex mgpr-32
24461
24462Only use the first 32 general-purpose registers.
24463
24464@item -mgpr-64
24465@opindex mgpr-64
24466
24467Use all 64 general-purpose registers.
24468
24469@item -mfpr-32
24470@opindex mfpr-32
24471
24472Use only the first 32 floating-point registers.
24473
24474@item -mfpr-64
24475@opindex mfpr-64
24476
24477Use all 64 floating-point registers.
24478
24479@item -mhard-float
24480@opindex mhard-float
24481
24482Use hardware instructions for floating-point operations.
24483
24484@item -msoft-float
24485@opindex msoft-float
24486
24487Use library routines for floating-point operations.
24488
24489@item -malloc-cc
24490@opindex malloc-cc
24491
24492Dynamically allocate condition code registers.
24493
24494@item -mfixed-cc
24495@opindex mfixed-cc
24496
24497Do not try to dynamically allocate condition code registers, only
24498use @code{icc0} and @code{fcc0}.
24499
24500@item -mdword
24501@opindex mdword
24502
24503Change ABI to use double word insns.
24504
24505@item -mno-dword
24506@opindex mno-dword
24507@opindex mdword
24508
24509Do not use double word instructions.
24510
24511@item -mdouble
24512@opindex mdouble
24513
24514Use floating-point double instructions.
24515
24516@item -mno-double
24517@opindex mno-double
24518
24519Do not use floating-point double instructions.
24520
24521@item -mmedia
24522@opindex mmedia
24523
24524Use media instructions.
24525
24526@item -mno-media
24527@opindex mno-media
24528
24529Do not use media instructions.
24530
24531@item -mmuladd
24532@opindex mmuladd
24533
24534Use multiply and add/subtract instructions.
24535
24536@item -mno-muladd
24537@opindex mno-muladd
24538
24539Do not use multiply and add/subtract instructions.
24540
24541@item -mfdpic
24542@opindex mfdpic
24543
24544Select the FDPIC ABI, which uses function descriptors to represent
24545pointers to functions. Without any PIC/PIE-related options, it
24546implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it
24547assumes GOT entries and small data are within a 12-bit range from the
24548GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets
24549are computed with 32 bits.
24550With a @samp{bfin-elf} target, this option implies @option{-msim}.
24551
24552@item -minline-plt
24553@opindex minline-plt
24554
24555Enable inlining of PLT entries in function calls to functions that are
24556not known to bind locally. It has no effect without @option{-mfdpic}.
24557It's enabled by default if optimizing for speed and compiling for
24558shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an
24559optimization option such as @option{-O3} or above is present in the
24560command line.
24561
24562@item -mTLS
24563@opindex mTLS
24564
24565Assume a large TLS segment when generating thread-local code.
24566
24567@item -mtls
24568@opindex mtls
24569
24570Do not assume a large TLS segment when generating thread-local code.
24571
24572@item -mgprel-ro
24573@opindex mgprel-ro
24574
24575Enable the use of @code{GPREL} relocations in the FDPIC ABI for data
24576that is known to be in read-only sections. It's enabled by default,
24577except for @option{-fpic} or @option{-fpie}: even though it may help
24578make the global offset table smaller, it trades 1 instruction for 4.
24579With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4,
24580one of which may be shared by multiple symbols, and it avoids the need
24581for a GOT entry for the referenced symbol, so it's more likely to be a
24582win. If it is not, @option{-mno-gprel-ro} can be used to disable it.
24583
24584@item -multilib-library-pic
24585@opindex multilib-library-pic
24586
24587Link with the (library, not FD) pic libraries. It's implied by
24588@option{-mlibrary-pic}, as well as by @option{-fPIC} and
24589@option{-fpic} without @option{-mfdpic}. You should never have to use
24590it explicitly.
24591
24592@item -mlinked-fp
24593@opindex mlinked-fp
24594
24595Follow the EABI requirement of always creating a frame pointer whenever
24596a stack frame is allocated. This option is enabled by default and can
24597be disabled with @option{-mno-linked-fp}.
24598
24599@item -mlong-calls
24600@opindex mlong-calls
24601
24602Use indirect addressing to call functions outside the current
24603compilation unit. This allows the functions to be placed anywhere
24604within the 32-bit address space.
24605
24606@item -malign-labels
24607@opindex malign-labels
24608
24609Try to align labels to an 8-byte boundary by inserting NOPs into the
24610previous packet. This option only has an effect when VLIW packing
24611is enabled. It doesn't create new packets; it merely adds NOPs to
24612existing ones.
24613
24614@item -mlibrary-pic
24615@opindex mlibrary-pic
24616
24617Generate position-independent EABI code.
24618
24619@item -macc-4
24620@opindex macc-4
24621
24622Use only the first four media accumulator registers.
24623
24624@item -macc-8
24625@opindex macc-8
24626
24627Use all eight media accumulator registers.
24628
24629@item -mpack
24630@opindex mpack
24631
24632Pack VLIW instructions.
24633
24634@item -mno-pack
24635@opindex mno-pack
24636
24637Do not pack VLIW instructions.
24638
24639@item -mno-eflags
24640@opindex mno-eflags
24641
24642Do not mark ABI switches in e_flags.
24643
24644@item -mcond-move
24645@opindex mcond-move
24646
24647Enable the use of conditional-move instructions (default).
24648
24649This switch is mainly for debugging the compiler and will likely be removed
24650in a future version.
24651
24652@item -mno-cond-move
24653@opindex mno-cond-move
24654
24655Disable the use of conditional-move instructions.
24656
24657This switch is mainly for debugging the compiler and will likely be removed
24658in a future version.
24659
24660@item -mscc
24661@opindex mscc
24662
24663Enable the use of conditional set instructions (default).
24664
24665This switch is mainly for debugging the compiler and will likely be removed
24666in a future version.
24667
24668@item -mno-scc
24669@opindex mno-scc
24670
24671Disable the use of conditional set instructions.
24672
24673This switch is mainly for debugging the compiler and will likely be removed
24674in a future version.
24675
24676@item -mcond-exec
24677@opindex mcond-exec
24678
24679Enable the use of conditional execution (default).
24680
24681This switch is mainly for debugging the compiler and will likely be removed
24682in a future version.
24683
24684@item -mno-cond-exec
24685@opindex mno-cond-exec
24686
24687Disable the use of conditional execution.
24688
24689This switch is mainly for debugging the compiler and will likely be removed
24690in a future version.
24691
24692@item -mvliw-branch
24693@opindex mvliw-branch
24694
24695Run a pass to pack branches into VLIW instructions (default).
24696
24697This switch is mainly for debugging the compiler and will likely be removed
24698in a future version.
24699
24700@item -mno-vliw-branch
24701@opindex mno-vliw-branch
24702
24703Do not run a pass to pack branches into VLIW instructions.
24704
24705This switch is mainly for debugging the compiler and will likely be removed
24706in a future version.
24707
24708@item -mmulti-cond-exec
24709@opindex mmulti-cond-exec
24710
24711Enable optimization of @code{&&} and @code{||} in conditional execution
24712(default).
24713
24714This switch is mainly for debugging the compiler and will likely be removed
24715in a future version.
24716
24717@item -mno-multi-cond-exec
24718@opindex mno-multi-cond-exec
24719
24720Disable optimization of @code{&&} and @code{||} in conditional execution.
24721
24722This switch is mainly for debugging the compiler and will likely be removed
24723in a future version.
24724
24725@item -mnested-cond-exec
24726@opindex mnested-cond-exec
24727
24728Enable nested conditional execution optimizations (default).
24729
24730This switch is mainly for debugging the compiler and will likely be removed
24731in a future version.
24732
24733@item -mno-nested-cond-exec
24734@opindex mno-nested-cond-exec
24735
24736Disable nested conditional execution optimizations.
24737
24738This switch is mainly for debugging the compiler and will likely be removed
24739in a future version.
24740
24741@item -moptimize-membar
24742@opindex moptimize-membar
24743
24744This switch removes redundant @code{membar} instructions from the
24745compiler-generated code. It is enabled by default.
24746
24747@item -mno-optimize-membar
24748@opindex mno-optimize-membar
24749@opindex moptimize-membar
24750
24751This switch disables the automatic removal of redundant @code{membar}
24752instructions from the generated code.
24753
24754@item -mtomcat-stats
24755@opindex mtomcat-stats
24756
24757Cause gas to print out tomcat statistics.
24758
24759@item -mcpu=@var{cpu}
24760@opindex mcpu
24761
24762Select the processor type for which to generate code. Possible values are
24763@samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450},
24764@samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}.
24765
24766@end table
24767
24768@node GNU/Linux Options
24769@subsection GNU/Linux Options
24770
24771These @samp{-m} options are defined for GNU/Linux targets:
24772
24773@table @gcctabopt
24774@item -mglibc
24775@opindex mglibc
24776Use the GNU C library. This is the default except
24777on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
24778@samp{*-*-linux-*android*} targets.
24779
24780@item -muclibc
24781@opindex muclibc
24782Use uClibc C library. This is the default on
24783@samp{*-*-linux-*uclibc*} targets.
24784
24785@item -mmusl
24786@opindex mmusl
24787Use the musl C library. This is the default on
24788@samp{*-*-linux-*musl*} targets.
24789
24790@item -mbionic
24791@opindex mbionic
24792Use Bionic C library. This is the default on
24793@samp{*-*-linux-*android*} targets.
24794
24795@item -mandroid
24796@opindex mandroid
24797Compile code compatible with Android platform. This is the default on
24798@samp{*-*-linux-*android*} targets.
24799
24800When compiling, this option enables @option{-mbionic}, @option{-fPIC},
24801@option{-fno-exceptions} and @option{-fno-rtti} by default. When linking,
24802this option makes the GCC driver pass Android-specific options to the linker.
24803Finally, this option causes the preprocessor macro @code{__ANDROID__}
24804to be defined.
24805
24806@item -tno-android-cc
24807@opindex tno-android-cc
24808Disable compilation effects of @option{-mandroid}, i.e., do not enable
24809@option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and
24810@option{-fno-rtti} by default.
24811
24812@item -tno-android-ld
24813@opindex tno-android-ld
24814Disable linking effects of @option{-mandroid}, i.e., pass standard Linux
24815linking options to the linker.
24816
24817@end table
24818
24819@node H8/300 Options
24820@subsection H8/300 Options
24821
24822These @samp{-m} options are defined for the H8/300 implementations:
24823
24824@table @gcctabopt
24825@item -mrelax
24826@opindex mrelax
24827Shorten some address references at link time, when possible; uses the
24828linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
24829ld, Using ld}, for a fuller description.
24830
24831@item -mh
24832@opindex mh
24833Generate code for the H8/300H@.
24834
24835@item -ms
24836@opindex ms
24837Generate code for the H8S@.
24838
24839@item -mn
24840@opindex mn
24841Generate code for the H8S and H8/300H in the normal mode. This switch
24842must be used either with @option{-mh} or @option{-ms}.
24843
24844@item -ms2600
24845@opindex ms2600
24846Generate code for the H8S/2600. This switch must be used with @option{-ms}.
24847
24848@item -mexr
24849@opindex mexr
24850Extended registers are stored on stack before execution of function
24851with monitor attribute. Default option is @option{-mexr}.
24852This option is valid only for H8S targets.
24853
24854@item -mno-exr
24855@opindex mno-exr
24856@opindex mexr
24857Extended registers are not stored on stack before execution of function
24858with monitor attribute. Default option is @option{-mno-exr}.
24859This option is valid only for H8S targets.
24860
24861@item -mint32
24862@opindex mint32
24863Make @code{int} data 32 bits by default.
24864
24865@item -malign-300
24866@opindex malign-300
24867On the H8/300H and H8S, use the same alignment rules as for the H8/300.
24868The default for the H8/300H and H8S is to align longs and floats on
248694-byte boundaries.
24870@option{-malign-300} causes them to be aligned on 2-byte boundaries.
24871This option has no effect on the H8/300.
24872@end table
24873
24874@node HPPA Options
24875@subsection HPPA Options
24876@cindex HPPA Options
24877
24878These @samp{-m} options are defined for the HPPA family of computers:
24879
24880@table @gcctabopt
24881@item -march=@var{architecture-type}
24882@opindex march
24883Generate code for the specified architecture. The choices for
24884@var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA
248851.1, and @samp{2.0} for PA 2.0 processors. Refer to
24886@file{/usr/lib/sched.models} on an HP-UX system to determine the proper
24887architecture option for your machine. Code compiled for lower numbered
24888architectures runs on higher numbered architectures, but not the
24889other way around.
24890
24891@item -mpa-risc-1-0
24892@itemx -mpa-risc-1-1
24893@itemx -mpa-risc-2-0
24894@opindex mpa-risc-1-0
24895@opindex mpa-risc-1-1
24896@opindex mpa-risc-2-0
24897Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively.
24898
cf467fb9
JDA
24899@item -matomic-libcalls
24900@opindex matomic-libcalls
24901@opindex mno-atomic-libcalls
24902Generate libcalls for atomic loads and stores when sync libcalls are disabled.
24903This option is enabled by default. It only affects the generation of
24904atomic libcalls by the HPPA backend.
24905
24906Both the sync and @file{libatomic} libcall implementations use locking.
24907As a result, processor stores are not atomic with respect to other
24908atomic operations. Processor loads up to DImode are atomic with
24909respect to other atomic operations provided they are implemented as
24910a single access.
24911
24912The PA-RISC architecture does not support any atomic operations in
24913hardware except for the @code{ldcw} instruction. Thus, all atomic
24914support is implemented using sync and atomic libcalls. Sync libcall
24915support is in @file{libgcc.a}. Atomic libcall support is in
24916@file{libatomic}.
24917
24918This option generates @code{__atomic_exchange} calls for atomic stores.
24919It also provides special handling for atomic DImode accesses on 32-bit
24920targets.
24921
24922@item -mbig-switch
24923@opindex mbig-switch
24924Does nothing. Preserved for backward compatibility.
24925
d77de738
ML
24926@item -mcaller-copies
24927@opindex mcaller-copies
24928The caller copies function arguments passed by hidden reference. This
24929option should be used with care as it is not compatible with the default
2493032-bit runtime. However, only aggregates larger than eight bytes are
24931passed by hidden reference and the option provides better compatibility
24932with OpenMP.
24933
cf467fb9
JDA
24934@item -mcoherent-ldcw
24935@opindex mcoherent-ldcw
24936Use ldcw/ldcd coherent cache-control hint.
d77de738
ML
24937
24938@item -mdisable-fpregs
24939@opindex mdisable-fpregs
cf467fb9 24940Disable floating-point registers. Equivalent to @code{-msoft-float}.
d77de738
ML
24941
24942@item -mdisable-indexing
24943@opindex mdisable-indexing
24944Prevent the compiler from using indexing address modes. This avoids some
24945rather obscure problems when compiling MIG generated code under MACH@.
24946
d77de738
ML
24947@item -mfast-indirect-calls
24948@opindex mfast-indirect-calls
24949Generate code that assumes calls never cross space boundaries. This
24950allows GCC to emit code that performs faster indirect calls.
24951
24952This option does not work in the presence of shared libraries or nested
24953functions.
24954
24955@item -mfixed-range=@var{register-range}
24956@opindex mfixed-range
24957Generate code treating the given register range as fixed registers.
24958A fixed register is one that the register allocator cannot use. This is
24959useful when compiling kernel code. A register range is specified as
24960two registers separated by a dash. Multiple register ranges can be
24961specified separated by a comma.
24962
d77de738
ML
24963@item -mgas
24964@opindex mgas
24965Enable the use of assembler directives only GAS understands.
24966
d77de738
ML
24967@item -mgnu-ld
24968@opindex mgnu-ld
24969Use options specific to GNU @command{ld}.
24970This passes @option{-shared} to @command{ld} when
24971building a shared library. It is the default when GCC is configured,
24972explicitly or implicitly, with the GNU linker. This option does not
24973affect which @command{ld} is called; it only changes what parameters
24974are passed to that @command{ld}.
24975The @command{ld} that is called is determined by the
24976@option{--with-ld} configure option, GCC's program search path, and
24977finally by the user's @env{PATH}. The linker used by GCC can be printed
24978using @samp{which `gcc -print-prog-name=ld`}. This option is only available
24979on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
24980
24981@item -mhp-ld
24982@opindex mhp-ld
24983Use options specific to HP @command{ld}.
24984This passes @option{-b} to @command{ld} when building
24985a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all
24986links. It is the default when GCC is configured, explicitly or
24987implicitly, with the HP linker. This option does not affect
24988which @command{ld} is called; it only changes what parameters are passed to that
24989@command{ld}.
24990The @command{ld} that is called is determined by the @option{--with-ld}
24991configure option, GCC's program search path, and finally by the user's
24992@env{PATH}. The linker used by GCC can be printed using @samp{which
24993`gcc -print-prog-name=ld`}. This option is only available on the 64-bit
24994HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
24995
cf467fb9
JDA
24996@item -mlinker-opt
24997@opindex mlinker-opt
24998Enable the optimization pass in the HP-UX linker. Note this makes symbolic
24999debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9
25000linkers in which they give bogus error messages when linking some programs.
25001
d77de738
ML
25002@item -mlong-calls
25003@opindex mno-long-calls
25004@opindex mlong-calls
25005Generate code that uses long call sequences. This ensures that a call
25006is always able to reach linker generated stubs. The default is to generate
25007long calls only when the distance from the call site to the beginning
25008of the function or translation unit, as the case may be, exceeds a
25009predefined limit set by the branch type being used. The limits for
25010normal calls are 7,600,000 and 240,000 bytes, respectively for the
25011PA 2.0 and PA 1.X architectures. Sibcalls are always limited at
25012240,000 bytes.
25013
25014Distances are measured from the beginning of functions when using the
25015@option{-ffunction-sections} option, or when using the @option{-mgas}
25016and @option{-mno-portable-runtime} options together under HP-UX with
25017the SOM linker.
25018
25019It is normally not desirable to use this option as it degrades
25020performance. However, it may be useful in large applications,
25021particularly when partial linking is used to build the application.
25022
25023The types of long calls used depends on the capabilities of the
25024assembler and linker, and the type of code being generated. The
25025impact on systems that support long absolute calls, and long pic
25026symbol-difference or pc-relative calls should be relatively small.
25027However, an indirect call is used on 32-bit ELF systems in pic code
25028and it is quite long.
25029
cf467fb9
JDA
25030@item -mlong-load-store
25031@opindex mlong-load-store
25032Generate 3-instruction load and store sequences as sometimes required by
25033the HP-UX 10 linker. This is equivalent to the @samp{+k} option to
25034the HP compilers.
25035
25036@item -mjump-in-delay
25037@opindex mjump-in-delay
25038This option is ignored and provided for compatibility purposes only.
25039
25040@item -mno-space-regs
25041@opindex mno-space-regs
25042@opindex mspace-regs
25043Generate code that assumes the target has no space registers. This allows
25044GCC to generate faster indirect calls and use unscaled index address modes.
25045
25046Such code is suitable for level 0 PA systems and kernels.
25047
25048@item -mordered
25049@opindex mordered
25050Assume memory references are ordered and barriers are not needed.
25051
25052@item -mportable-runtime
25053@opindex mportable-runtime
25054Use the portable calling conventions proposed by HP for ELF systems.
25055
25056@item -mschedule=@var{cpu-type}
25057@opindex mschedule
25058Schedule code according to the constraints for the machine type
25059@var{cpu-type}. The choices for @var{cpu-type} are @samp{700}
25060@samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer
25061to @file{/usr/lib/sched.models} on an HP-UX system to determine the
25062proper scheduling option for your machine. The default scheduling is
25063@samp{8000}.
25064
25065@item -msio
25066@opindex msio
25067Generate the predefine, @code{_SIO}, for server IO@. The default is
25068@option{-mwsio}. This generates the predefines, @code{__hp9000s700},
25069@code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These
25070options are available under HP-UX and HI-UX@.
25071
25072@item -msoft-float
25073@opindex msoft-float
25074Generate output containing library calls for floating point.
25075@strong{Warning:} the requisite libraries are not available for all HPPA
25076targets. Normally the facilities of the machine's usual C compiler are
25077used, but this cannot be done directly in cross-compilation. You must make
25078your own arrangements to provide suitable library functions for
25079cross-compilation.
25080
25081@option{-msoft-float} changes the calling convention in the output file;
25082therefore, it is only useful if you compile @emph{all} of a program with
25083this option. In particular, you need to compile @file{libgcc.a}, the
25084library that comes with GCC, with @option{-msoft-float} in order for
25085this to work.
25086
25087@item -msoft-mult
25088@opindex msoft-mult
25089Use software integer multiplication.
25090
25091This disables the use of the @code{xmpyu} instruction.
25092
d77de738
ML
25093@item -munix=@var{unix-std}
25094@opindex march
25095Generate compiler predefines and select a startfile for the specified
25096UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95}
25097and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95}
25098is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX
2509911.11 and later. The default values are @samp{93} for HP-UX 10.00,
25100@samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11
25101and later.
25102
25103@option{-munix=93} provides the same predefines as GCC 3.3 and 3.4.
25104@option{-munix=95} provides additional predefines for @code{XOPEN_UNIX}
25105and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}.
25106@option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX},
25107@code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and
25108@code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}.
25109
25110It is @emph{important} to note that this option changes the interfaces
25111for various library routines. It also affects the operational behavior
25112of the C library. Thus, @emph{extreme} care is needed in using this
25113option.
25114
25115Library code that is intended to operate with more than one UNIX
25116standard must test, set and restore the variable @code{__xpg4_extended_mask}
25117as appropriate. Most GNU software doesn't provide this capability.
25118
25119@item -nolibdld
25120@opindex nolibdld
25121Suppress the generation of link options to search libdld.sl when the
25122@option{-static} option is specified on HP-UX 10 and later.
25123
25124@item -static
25125@opindex static
25126The HP-UX implementation of setlocale in libc has a dependency on
25127libdld.sl. There isn't an archive version of libdld.sl. Thus,
25128when the @option{-static} option is specified, special link options
25129are needed to resolve this dependency.
25130
25131On HP-UX 10 and later, the GCC driver adds the necessary options to
25132link with libdld.sl when the @option{-static} option is specified.
25133This causes the resulting binary to be dynamic. On the 64-bit port,
25134the linkers generate dynamic binaries by default in any case. The
25135@option{-nolibdld} option can be used to prevent the GCC driver from
25136adding these link options.
25137
25138@item -threads
25139@opindex threads
25140Add support for multithreading with the @dfn{dce thread} library
25141under HP-UX@. This option sets flags for both the preprocessor and
25142linker.
25143@end table
25144
25145@node IA-64 Options
25146@subsection IA-64 Options
25147@cindex IA-64 Options
25148
25149These are the @samp{-m} options defined for the Intel IA-64 architecture.
25150
25151@table @gcctabopt
25152@item -mbig-endian
25153@opindex mbig-endian
25154Generate code for a big-endian target. This is the default for HP-UX@.
25155
25156@item -mlittle-endian
25157@opindex mlittle-endian
25158Generate code for a little-endian target. This is the default for AIX5
25159and GNU/Linux.
25160
25161@item -mgnu-as
25162@itemx -mno-gnu-as
25163@opindex mgnu-as
25164@opindex mno-gnu-as
25165Generate (or don't) code for the GNU assembler. This is the default.
25166@c Also, this is the default if the configure option @option{--with-gnu-as}
25167@c is used.
25168
25169@item -mgnu-ld
25170@itemx -mno-gnu-ld
25171@opindex mgnu-ld
25172@opindex mno-gnu-ld
25173Generate (or don't) code for the GNU linker. This is the default.
25174@c Also, this is the default if the configure option @option{--with-gnu-ld}
25175@c is used.
25176
25177@item -mno-pic
25178@opindex mno-pic
25179Generate code that does not use a global pointer register. The result
25180is not position independent code, and violates the IA-64 ABI@.
25181
25182@item -mvolatile-asm-stop
25183@itemx -mno-volatile-asm-stop
25184@opindex mvolatile-asm-stop
25185@opindex mno-volatile-asm-stop
25186Generate (or don't) a stop bit immediately before and after volatile asm
25187statements.
25188
25189@item -mregister-names
25190@itemx -mno-register-names
25191@opindex mregister-names
25192@opindex mno-register-names
25193Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for
25194the stacked registers. This may make assembler output more readable.
25195
25196@item -mno-sdata
25197@itemx -msdata
25198@opindex mno-sdata
25199@opindex msdata
25200Disable (or enable) optimizations that use the small data section. This may
25201be useful for working around optimizer bugs.
25202
25203@item -mconstant-gp
25204@opindex mconstant-gp
25205Generate code that uses a single constant global pointer value. This is
25206useful when compiling kernel code.
25207
25208@item -mauto-pic
25209@opindex mauto-pic
25210Generate code that is self-relocatable. This implies @option{-mconstant-gp}.
25211This is useful when compiling firmware code.
25212
25213@item -minline-float-divide-min-latency
25214@opindex minline-float-divide-min-latency
25215Generate code for inline divides of floating-point values
25216using the minimum latency algorithm.
25217
25218@item -minline-float-divide-max-throughput
25219@opindex minline-float-divide-max-throughput
25220Generate code for inline divides of floating-point values
25221using the maximum throughput algorithm.
25222
25223@item -mno-inline-float-divide
25224@opindex mno-inline-float-divide
25225Do not generate inline code for divides of floating-point values.
25226
25227@item -minline-int-divide-min-latency
25228@opindex minline-int-divide-min-latency
25229Generate code for inline divides of integer values
25230using the minimum latency algorithm.
25231
25232@item -minline-int-divide-max-throughput
25233@opindex minline-int-divide-max-throughput
25234Generate code for inline divides of integer values
25235using the maximum throughput algorithm.
25236
25237@item -mno-inline-int-divide
25238@opindex mno-inline-int-divide
25239@opindex minline-int-divide
25240Do not generate inline code for divides of integer values.
25241
25242@item -minline-sqrt-min-latency
25243@opindex minline-sqrt-min-latency
25244Generate code for inline square roots
25245using the minimum latency algorithm.
25246
25247@item -minline-sqrt-max-throughput
25248@opindex minline-sqrt-max-throughput
25249Generate code for inline square roots
25250using the maximum throughput algorithm.
25251
25252@item -mno-inline-sqrt
25253@opindex mno-inline-sqrt
25254Do not generate inline code for @code{sqrt}.
25255
25256@item -mfused-madd
25257@itemx -mno-fused-madd
25258@opindex mfused-madd
25259@opindex mno-fused-madd
25260Do (don't) generate code that uses the fused multiply/add or multiply/subtract
25261instructions. The default is to use these instructions.
25262
25263@item -mno-dwarf2-asm
25264@itemx -mdwarf2-asm
25265@opindex mno-dwarf2-asm
25266@opindex mdwarf2-asm
25267Don't (or do) generate assembler code for the DWARF line number debugging
25268info. This may be useful when not using the GNU assembler.
25269
25270@item -mearly-stop-bits
25271@itemx -mno-early-stop-bits
25272@opindex mearly-stop-bits
25273@opindex mno-early-stop-bits
25274Allow stop bits to be placed earlier than immediately preceding the
25275instruction that triggered the stop bit. This can improve instruction
25276scheduling, but does not always do so.
25277
25278@item -mfixed-range=@var{register-range}
25279@opindex mfixed-range
25280Generate code treating the given register range as fixed registers.
25281A fixed register is one that the register allocator cannot use. This is
25282useful when compiling kernel code. A register range is specified as
25283two registers separated by a dash. Multiple register ranges can be
25284specified separated by a comma.
25285
25286@item -mtls-size=@var{tls-size}
25287@opindex mtls-size
25288Specify bit size of immediate TLS offsets. Valid values are 14, 22, and
2528964.
25290
25291@item -mtune=@var{cpu-type}
25292@opindex mtune
25293Tune the instruction scheduling for a particular CPU, Valid values are
25294@samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2},
25295and @samp{mckinley}.
25296
25297@item -milp32
25298@itemx -mlp64
25299@opindex milp32
25300@opindex mlp64
25301Generate code for a 32-bit or 64-bit environment.
25302The 32-bit environment sets int, long and pointer to 32 bits.
25303The 64-bit environment sets int to 32 bits and long and pointer
25304to 64 bits. These are HP-UX specific flags.
25305
25306@item -mno-sched-br-data-spec
25307@itemx -msched-br-data-spec
25308@opindex mno-sched-br-data-spec
25309@opindex msched-br-data-spec
25310(Dis/En)able data speculative scheduling before reload.
25311This results in generation of @code{ld.a} instructions and
25312the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25313The default setting is disabled.
25314
25315@item -msched-ar-data-spec
25316@itemx -mno-sched-ar-data-spec
25317@opindex msched-ar-data-spec
25318@opindex mno-sched-ar-data-spec
25319(En/Dis)able data speculative scheduling after reload.
25320This results in generation of @code{ld.a} instructions and
25321the corresponding check instructions (@code{ld.c} / @code{chk.a}).
25322The default setting is enabled.
25323
25324@item -mno-sched-control-spec
25325@itemx -msched-control-spec
25326@opindex mno-sched-control-spec
25327@opindex msched-control-spec
25328(Dis/En)able control speculative scheduling. This feature is
25329available only during region scheduling (i.e.@: before reload).
25330This results in generation of the @code{ld.s} instructions and
25331the corresponding check instructions @code{chk.s}.
25332The default setting is disabled.
25333
25334@item -msched-br-in-data-spec
25335@itemx -mno-sched-br-in-data-spec
25336@opindex msched-br-in-data-spec
25337@opindex mno-sched-br-in-data-spec
25338(En/Dis)able speculative scheduling of the instructions that
25339are dependent on the data speculative loads before reload.
25340This is effective only with @option{-msched-br-data-spec} enabled.
25341The default setting is enabled.
25342
25343@item -msched-ar-in-data-spec
25344@itemx -mno-sched-ar-in-data-spec
25345@opindex msched-ar-in-data-spec
25346@opindex mno-sched-ar-in-data-spec
25347(En/Dis)able speculative scheduling of the instructions that
25348are dependent on the data speculative loads after reload.
25349This is effective only with @option{-msched-ar-data-spec} enabled.
25350The default setting is enabled.
25351
25352@item -msched-in-control-spec
25353@itemx -mno-sched-in-control-spec
25354@opindex msched-in-control-spec
25355@opindex mno-sched-in-control-spec
25356(En/Dis)able speculative scheduling of the instructions that
25357are dependent on the control speculative loads.
25358This is effective only with @option{-msched-control-spec} enabled.
25359The default setting is enabled.
25360
25361@item -mno-sched-prefer-non-data-spec-insns
25362@itemx -msched-prefer-non-data-spec-insns
25363@opindex mno-sched-prefer-non-data-spec-insns
25364@opindex msched-prefer-non-data-spec-insns
25365If enabled, data-speculative instructions are chosen for schedule
25366only if there are no other choices at the moment. This makes
25367the use of the data speculation much more conservative.
25368The default setting is disabled.
25369
25370@item -mno-sched-prefer-non-control-spec-insns
25371@itemx -msched-prefer-non-control-spec-insns
25372@opindex mno-sched-prefer-non-control-spec-insns
25373@opindex msched-prefer-non-control-spec-insns
25374If enabled, control-speculative instructions are chosen for schedule
25375only if there are no other choices at the moment. This makes
25376the use of the control speculation much more conservative.
25377The default setting is disabled.
25378
25379@item -mno-sched-count-spec-in-critical-path
25380@itemx -msched-count-spec-in-critical-path
25381@opindex mno-sched-count-spec-in-critical-path
25382@opindex msched-count-spec-in-critical-path
25383If enabled, speculative dependencies are considered during
25384computation of the instructions priorities. This makes the use of the
25385speculation a bit more conservative.
25386The default setting is disabled.
25387
25388@item -msched-spec-ldc
25389@opindex msched-spec-ldc
25390Use a simple data speculation check. This option is on by default.
25391
25392@item -msched-control-spec-ldc
25393@opindex msched-spec-ldc
25394Use a simple check for control speculation. This option is on by default.
25395
25396@item -msched-stop-bits-after-every-cycle
25397@opindex msched-stop-bits-after-every-cycle
25398Place a stop bit after every cycle when scheduling. This option is on
25399by default.
25400
25401@item -msched-fp-mem-deps-zero-cost
25402@opindex msched-fp-mem-deps-zero-cost
25403Assume that floating-point stores and loads are not likely to cause a conflict
25404when placed into the same instruction group. This option is disabled by
25405default.
25406
25407@item -msel-sched-dont-check-control-spec
25408@opindex msel-sched-dont-check-control-spec
25409Generate checks for control speculation in selective scheduling.
25410This flag is disabled by default.
25411
25412@item -msched-max-memory-insns=@var{max-insns}
25413@opindex msched-max-memory-insns
25414Limit on the number of memory insns per instruction group, giving lower
25415priority to subsequent memory insns attempting to schedule in the same
25416instruction group. Frequently useful to prevent cache bank conflicts.
25417The default value is 1.
25418
25419@item -msched-max-memory-insns-hard-limit
25420@opindex msched-max-memory-insns-hard-limit
25421Makes the limit specified by @option{msched-max-memory-insns} a hard limit,
25422disallowing more than that number in an instruction group.
25423Otherwise, the limit is ``soft'', meaning that non-memory operations
25424are preferred when the limit is reached, but memory operations may still
25425be scheduled.
25426
25427@end table
25428
25429@node LM32 Options
25430@subsection LM32 Options
25431@cindex LM32 options
25432
25433These @option{-m} options are defined for the LatticeMico32 architecture:
25434
25435@table @gcctabopt
25436@item -mbarrel-shift-enabled
25437@opindex mbarrel-shift-enabled
25438Enable barrel-shift instructions.
25439
25440@item -mdivide-enabled
25441@opindex mdivide-enabled
25442Enable divide and modulus instructions.
25443
25444@item -mmultiply-enabled
25445@opindex multiply-enabled
25446Enable multiply instructions.
25447
25448@item -msign-extend-enabled
25449@opindex msign-extend-enabled
25450Enable sign extend instructions.
25451
25452@item -muser-enabled
25453@opindex muser-enabled
25454Enable user-defined instructions.
25455
25456@end table
25457
25458@node LoongArch Options
25459@subsection LoongArch Options
25460@cindex LoongArch Options
25461
25462These command-line options are defined for LoongArch targets:
25463
25464@table @gcctabopt
25465@item -march=@var{cpu-type}
9c19597c 25466@opindex march
d77de738
ML
25467Generate instructions for the machine type @var{cpu-type}. In contrast to
25468@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
25469for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
25470to generate code that may not run at all on processors other than the one
25471indicated. Specifying @option{-march=@var{cpu-type}} implies
25472@option{-mtune=@var{cpu-type}}, except where noted otherwise.
25473
25474The choices for @var{cpu-type} are:
25475
25476@table @samp
25477@item native
25478This selects the CPU to generate code for at compilation time by determining
25479the processor type of the compiling machine. Using @option{-march=native}
25480enables all instruction subsets supported by the local machine (hence
25481the result might not run on different machines). Using @option{-mtune=native}
25482produces code optimized for the local machine under the constraints
25483of the selected instruction set.
25484@item loongarch64
25485A generic CPU with 64-bit extensions.
25486@item la464
25487LoongArch LA464 CPU with LBT, LSX, LASX, LVZ.
25488@end table
25489
25490@item -mtune=@var{cpu-type}
25491@opindex mtune
25492Optimize the output for the given processor, specified by microarchitecture
25493name.
25494
25495@item -mabi=@var{base-abi-type}
25496@opindex mabi
25497Generate code for the specified calling convention.
25498@var{base-abi-type} can be one of:
25499@table @samp
25500@item lp64d
25501Uses 64-bit general purpose registers and 32/64-bit floating-point
25502registers for parameter passing. Data model is LP64, where @samp{int}
25503is 32 bits, while @samp{long int} and pointers are 64 bits.
25504@item lp64f
25505Uses 64-bit general purpose registers and 32-bit floating-point
25506registers for parameter passing. Data model is LP64, where @samp{int}
25507is 32 bits, while @samp{long int} and pointers are 64 bits.
25508@item lp64s
25509Uses 64-bit general purpose registers and no floating-point
25510registers for parameter passing. Data model is LP64, where @samp{int}
25511is 32 bits, while @samp{long int} and pointers are 64 bits.
25512@end table
25513
25514@item -mfpu=@var{fpu-type}
25515@opindex mfpu
25516Generate code for the specified FPU type, which can be one of:
25517@table @samp
25518@item 64
25519Allow the use of hardware floating-point instructions for 32-bit
25520and 64-bit operations.
25521@item 32
25522Allow the use of hardware floating-point instructions for 32-bit
25523operations.
25524@item none
25525@item 0
25526Prevent the use of hardware floating-point instructions.
25527@end table
25528
25529@item -msoft-float
25530@opindex msoft-float
25531Force @option{-mfpu=none} and prevents the use of floating-point
25532registers for parameter passing. This option may change the target
25533ABI.
25534
25535@item -msingle-float
9c19597c 25536@opindex msingle-float
d77de738
ML
25537Force @option{-mfpu=32} and allow the use of 32-bit floating-point
25538registers for parameter passing. This option may change the target
25539ABI.
25540
25541@item -mdouble-float
9c19597c 25542@opindex mdouble-float
d77de738
ML
25543Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point
25544registers for parameter passing. This option may change the target
25545ABI.
25546
25547@item -mbranch-cost=@var{n}
9c19597c 25548@opindex mbranch-cost
d77de738
ML
25549Set the cost of branches to roughly @var{n} instructions.
25550
25551@item -mcheck-zero-division
25552@itemx -mno-check-zero-divison
9c19597c 25553@opindex mcheck-zero-division
d77de738
ML
25554Trap (do not trap) on integer division by zero. The default is
25555@option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and
25556@option{-mno-check-zero-division} for other optimization levels.
25557
25558@item -mcond-move-int
25559@itemx -mno-cond-move-int
9c19597c 25560@opindex mcond-move-int
d77de738
ML
25561Conditional moves for integral data in general-purpose registers
25562are enabled (disabled). The default is @option{-mcond-move-int}.
25563
25564@item -mcond-move-float
25565@itemx -mno-cond-move-float
9c19597c 25566@opindex mcond-move-float
d77de738
ML
25567Conditional moves for floating-point registers are enabled (disabled).
25568The default is @option{-mcond-move-float}.
25569
25570@item -mmemcpy
25571@itemx -mno-memcpy
9c19597c 25572@opindex mmemcpy
d77de738
ML
25573Force (do not force) the use of @code{memcpy} for non-trivial block moves.
25574The default is @option{-mno-memcpy}, which allows GCC to inline most
25575constant-sized copies. Setting optimization level to @option{-Os} also
25576forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this
25577behavior if explicitly specified, regardless of the order these options on
25578the command line.
25579
25580@item -mstrict-align
25581@itemx -mno-strict-align
9c19597c 25582@opindex mstrict-align
d77de738
ML
25583Avoid or allow generating memory accesses that may not be aligned on a natural
25584object boundary as described in the architecture specification. The default is
25585@option{-mno-strict-align}.
25586
25587@item -msmall-data-limit=@var{number}
9c19597c 25588@opindex msmall-data-limit
d77de738
ML
25589Put global and static data smaller than @var{number} bytes into a special
25590section (on some targets). The default value is 0.
25591
25592@item -mmax-inline-memcpy-size=@var{n}
9c19597c 25593@opindex mmax-inline-memcpy-size
d77de738
ML
25594Inline all block moves (such as calls to @code{memcpy} or structure copies)
25595less than or equal to @var{n} bytes. The default value of @var{n} is 1024.
25596
25597@item -mcmodel=@var{code-model}
25598Set the code model to one of:
25599@table @samp
25600@item tiny-static (Not implemented yet)
25601@item tiny (Not implemented yet)
25602
25603@item normal
25604The text segment must be within 128MB addressing space. The data segment must
25605be within 2GB addressing space.
25606
25607@item medium
25608The text segment and data segment must be within 2GB addressing space.
25609
25610@item large (Not implemented yet)
25611
25612@item extreme
25613This mode does not limit the size of the code segment and data segment.
25614The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and
25615@option{-mno-explicit-relocs}.
25616@end table
25617The default code model is @code{normal}.
25618
25619@item -mexplicit-relocs
25620@itemx -mno-explicit-relocs
25621@opindex mexplicit-relocs
25622@opindex mno-explicit-relocs
25623Use or do not use assembler relocation operators when dealing with symbolic
25624addresses. The alternative is to use assembler macros instead, which may
25625limit optimization. The default value for the option is determined during
25626GCC build-time by detecting corresponding assembler support:
25627@code{-mexplicit-relocs} if said support is present,
25628@code{-mno-explicit-relocs} otherwise. This option is mostly useful for
25629debugging, or interoperation with assemblers different from the build-time
25630one.
25631
25632@item -mdirect-extern-access
25633@itemx -mno-direct-extern-access
25634@opindex mdirect-extern-access
25635Do not use or use GOT to access external symbols. The default is
25636@option{-mno-direct-extern-access}: GOT is used for external symbols with
25637default visibility, but not used for other external symbols.
25638
25639With @option{-mdirect-extern-access}, GOT is not used and all external
25640symbols are PC-relatively addressed. It is @strong{only} suitable for
25641environments where no dynamic link is performed, like firmwares, OS
25642kernels, executables linked with @option{-static} or @option{-static-pie}.
25643@option{-mdirect-extern-access} is not compatible with @option{-fPIC} or
25644@option{-fpic}.
25645@end table
25646
25647@node M32C Options
25648@subsection M32C Options
25649@cindex M32C options
25650
25651@table @gcctabopt
25652@item -mcpu=@var{name}
25653@opindex mcpu=
25654Select the CPU for which code is generated. @var{name} may be one of
25655@samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to
25656/60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for
25657the M32C/80 series.
25658
25659@item -msim
25660@opindex msim
25661Specifies that the program will be run on the simulator. This causes
25662an alternate runtime library to be linked in which supports, for
25663example, file I/O@. You must not use this option when generating
25664programs that will run on real hardware; you must provide your own
25665runtime library for whatever I/O functions are needed.
25666
25667@item -memregs=@var{number}
25668@opindex memregs=
25669Specifies the number of memory-based pseudo-registers GCC uses
25670during code generation. These pseudo-registers are used like real
25671registers, so there is a tradeoff between GCC's ability to fit the
25672code into available registers, and the performance penalty of using
25673memory instead of registers. Note that all modules in a program must
25674be compiled with the same value for this option. Because of that, you
25675must not use this option with GCC's default runtime libraries.
25676
25677@end table
25678
25679@node M32R/D Options
25680@subsection M32R/D Options
25681@cindex M32R/D options
25682
25683These @option{-m} options are defined for Renesas M32R/D architectures:
25684
25685@table @gcctabopt
25686@item -m32r2
25687@opindex m32r2
25688Generate code for the M32R/2@.
25689
25690@item -m32rx
25691@opindex m32rx
25692Generate code for the M32R/X@.
25693
25694@item -m32r
25695@opindex m32r
25696Generate code for the M32R@. This is the default.
25697
25698@item -mmodel=small
25699@opindex mmodel=small
25700Assume all objects live in the lower 16MB of memory (so that their addresses
25701can be loaded with the @code{ld24} instruction), and assume all subroutines
25702are reachable with the @code{bl} instruction.
25703This is the default.
25704
25705The addressability of a particular object can be set with the
25706@code{model} attribute.
25707
25708@item -mmodel=medium
25709@opindex mmodel=medium
25710Assume objects may be anywhere in the 32-bit address space (the compiler
25711generates @code{seth/add3} instructions to load their addresses), and
25712assume all subroutines are reachable with the @code{bl} instruction.
25713
25714@item -mmodel=large
25715@opindex mmodel=large
25716Assume objects may be anywhere in the 32-bit address space (the compiler
25717generates @code{seth/add3} instructions to load their addresses), and
25718assume subroutines may not be reachable with the @code{bl} instruction
25719(the compiler generates the much slower @code{seth/add3/jl}
25720instruction sequence).
25721
25722@item -msdata=none
25723@opindex msdata=none
25724Disable use of the small data area. Variables are put into
25725one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the
25726@code{section} attribute has been specified).
25727This is the default.
25728
25729The small data area consists of sections @code{.sdata} and @code{.sbss}.
25730Objects may be explicitly put in the small data area with the
25731@code{section} attribute using one of these sections.
25732
25733@item -msdata=sdata
25734@opindex msdata=sdata
25735Put small global and static data in the small data area, but do not
25736generate special code to reference them.
25737
25738@item -msdata=use
25739@opindex msdata=use
25740Put small global and static data in the small data area, and generate
25741special instructions to reference them.
25742
25743@item -G @var{num}
25744@opindex G
25745@cindex smaller data references
25746Put global and static objects less than or equal to @var{num} bytes
25747into the small data or BSS sections instead of the normal data or BSS
25748sections. The default value of @var{num} is 8.
25749The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use}
25750for this option to have any effect.
25751
25752All modules should be compiled with the same @option{-G @var{num}} value.
25753Compiling with different values of @var{num} may or may not work; if it
25754doesn't the linker gives an error message---incorrect code is not
25755generated.
25756
25757@item -mdebug
25758@opindex mdebug
25759Makes the M32R-specific code in the compiler display some statistics
25760that might help in debugging programs.
25761
25762@item -malign-loops
25763@opindex malign-loops
25764Align all loops to a 32-byte boundary.
25765
25766@item -mno-align-loops
25767@opindex mno-align-loops
25768Do not enforce a 32-byte alignment for loops. This is the default.
25769
25770@item -missue-rate=@var{number}
25771@opindex missue-rate=@var{number}
25772Issue @var{number} instructions per cycle. @var{number} can only be 1
25773or 2.
25774
25775@item -mbranch-cost=@var{number}
25776@opindex mbranch-cost=@var{number}
25777@var{number} can only be 1 or 2. If it is 1 then branches are
25778preferred over conditional code, if it is 2, then the opposite applies.
25779
25780@item -mflush-trap=@var{number}
25781@opindex mflush-trap=@var{number}
25782Specifies the trap number to use to flush the cache. The default is
2578312. Valid numbers are between 0 and 15 inclusive.
25784
25785@item -mno-flush-trap
25786@opindex mno-flush-trap
25787Specifies that the cache cannot be flushed by using a trap.
25788
25789@item -mflush-func=@var{name}
25790@opindex mflush-func=@var{name}
25791Specifies the name of the operating system function to call to flush
25792the cache. The default is @samp{_flush_cache}, but a function call
25793is only used if a trap is not available.
25794
25795@item -mno-flush-func
25796@opindex mno-flush-func
25797Indicates that there is no OS function for flushing the cache.
25798
25799@end table
25800
25801@node M680x0 Options
25802@subsection M680x0 Options
25803@cindex M680x0 options
25804
25805These are the @samp{-m} options defined for M680x0 and ColdFire processors.
25806The default settings depend on which architecture was selected when
25807the compiler was configured; the defaults for the most common choices
25808are given below.
25809
25810@table @gcctabopt
25811@item -march=@var{arch}
25812@opindex march
25813Generate code for a specific M680x0 or ColdFire instruction set
25814architecture. Permissible values of @var{arch} for M680x0
25815architectures are: @samp{68000}, @samp{68010}, @samp{68020},
25816@samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire
25817architectures are selected according to Freescale's ISA classification
25818and the permissible values are: @samp{isaa}, @samp{isaaplus},
25819@samp{isab} and @samp{isac}.
25820
25821GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating
25822code for a ColdFire target. The @var{arch} in this macro is one of the
25823@option{-march} arguments given above.
25824
25825When used together, @option{-march} and @option{-mtune} select code
25826that runs on a family of similar processors but that is optimized
25827for a particular microarchitecture.
25828
25829@item -mcpu=@var{cpu}
25830@opindex mcpu
25831Generate code for a specific M680x0 or ColdFire processor.
25832The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020},
25833@samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332}
25834and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table
25835below, which also classifies the CPUs into families:
25836
25837@multitable @columnfractions 0.20 0.80
25838@headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments}
25839@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}
25840@item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206}
25841@item @samp{5206e} @tab @samp{5206e}
25842@item @samp{5208} @tab @samp{5207} @samp{5208}
25843@item @samp{5211a} @tab @samp{5210a} @samp{5211a}
25844@item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213}
25845@item @samp{5216} @tab @samp{5214} @samp{5216}
25846@item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235}
25847@item @samp{5225} @tab @samp{5224} @samp{5225}
25848@item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259}
25849@item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x}
25850@item @samp{5249} @tab @samp{5249}
25851@item @samp{5250} @tab @samp{5250}
25852@item @samp{5271} @tab @samp{5270} @samp{5271}
25853@item @samp{5272} @tab @samp{5272}
25854@item @samp{5275} @tab @samp{5274} @samp{5275}
25855@item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x}
25856@item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017}
25857@item @samp{5307} @tab @samp{5307}
25858@item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x}
25859@item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x}
25860@item @samp{5407} @tab @samp{5407}
25861@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}
25862@end multitable
25863
25864@option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if
25865@var{arch} is compatible with @var{cpu}. Other combinations of
25866@option{-mcpu} and @option{-march} are rejected.
25867
25868GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target
25869@var{cpu} is selected. It also defines @code{__mcf_family_@var{family}},
25870where the value of @var{family} is given by the table above.
25871
25872@item -mtune=@var{tune}
25873@opindex mtune
25874Tune the code for a particular microarchitecture within the
25875constraints set by @option{-march} and @option{-mcpu}.
25876The M680x0 microarchitectures are: @samp{68000}, @samp{68010},
25877@samp{68020}, @samp{68030}, @samp{68040}, @samp{68060}
25878and @samp{cpu32}. The ColdFire microarchitectures
25879are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}.
25880
25881You can also use @option{-mtune=68020-40} for code that needs
25882to run relatively well on 68020, 68030 and 68040 targets.
25883@option{-mtune=68020-60} is similar but includes 68060 targets
25884as well. These two options select the same tuning decisions as
25885@option{-m68020-40} and @option{-m68020-60} respectively.
25886
25887GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__}
25888when tuning for 680x0 architecture @var{arch}. It also defines
25889@code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
25890option is used. If GCC is tuning for a range of architectures,
25891as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
25892it defines the macros for every architecture in the range.
25893
25894GCC also defines the macro @code{__m@var{uarch}__} when tuning for
25895ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
25896of the arguments given above.
25897
25898@item -m68000
25899@itemx -mc68000
25900@opindex m68000
25901@opindex mc68000
25902Generate output for a 68000. This is the default
25903when the compiler is configured for 68000-based systems.
25904It is equivalent to @option{-march=68000}.
25905
25906Use this option for microcontrollers with a 68000 or EC000 core,
25907including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356.
25908
25909@item -m68010
25910@opindex m68010
25911Generate output for a 68010. This is the default
25912when the compiler is configured for 68010-based systems.
25913It is equivalent to @option{-march=68010}.
25914
25915@item -m68020
25916@itemx -mc68020
25917@opindex m68020
25918@opindex mc68020
25919Generate output for a 68020. This is the default
25920when the compiler is configured for 68020-based systems.
25921It is equivalent to @option{-march=68020}.
25922
25923@item -m68030
25924@opindex m68030
25925Generate output for a 68030. This is the default when the compiler is
25926configured for 68030-based systems. It is equivalent to
25927@option{-march=68030}.
25928
25929@item -m68040
25930@opindex m68040
25931Generate output for a 68040. This is the default when the compiler is
25932configured for 68040-based systems. It is equivalent to
25933@option{-march=68040}.
25934
25935This option inhibits the use of 68881/68882 instructions that have to be
25936emulated by software on the 68040. Use this option if your 68040 does not
25937have code to emulate those instructions.
25938
25939@item -m68060
25940@opindex m68060
25941Generate output for a 68060. This is the default when the compiler is
25942configured for 68060-based systems. It is equivalent to
25943@option{-march=68060}.
25944
25945This option inhibits the use of 68020 and 68881/68882 instructions that
25946have to be emulated by software on the 68060. Use this option if your 68060
25947does not have code to emulate those instructions.
25948
25949@item -mcpu32
25950@opindex mcpu32
25951Generate output for a CPU32. This is the default
25952when the compiler is configured for CPU32-based systems.
25953It is equivalent to @option{-march=cpu32}.
25954
25955Use this option for microcontrollers with a
25956CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334,
2595768336, 68340, 68341, 68349 and 68360.
25958
25959@item -m5200
25960@opindex m5200
25961Generate output for a 520X ColdFire CPU@. This is the default
25962when the compiler is configured for 520X-based systems.
25963It is equivalent to @option{-mcpu=5206}, and is now deprecated
25964in favor of that option.
25965
25966Use this option for microcontroller with a 5200 core, including
25967the MCF5202, MCF5203, MCF5204 and MCF5206.
25968
25969@item -m5206e
25970@opindex m5206e
25971Generate output for a 5206e ColdFire CPU@. The option is now
25972deprecated in favor of the equivalent @option{-mcpu=5206e}.
25973
25974@item -m528x
25975@opindex m528x
25976Generate output for a member of the ColdFire 528X family.
25977The option is now deprecated in favor of the equivalent
25978@option{-mcpu=528x}.
25979
25980@item -m5307
25981@opindex m5307
25982Generate output for a ColdFire 5307 CPU@. The option is now deprecated
25983in favor of the equivalent @option{-mcpu=5307}.
25984
25985@item -m5407
25986@opindex m5407
25987Generate output for a ColdFire 5407 CPU@. The option is now deprecated
25988in favor of the equivalent @option{-mcpu=5407}.
25989
25990@item -mcfv4e
25991@opindex mcfv4e
25992Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x).
25993This includes use of hardware floating-point instructions.
25994The option is equivalent to @option{-mcpu=547x}, and is now
25995deprecated in favor of that option.
25996
25997@item -m68020-40
25998@opindex m68020-40
25999Generate output for a 68040, without using any of the new instructions.
26000This results in code that can run relatively efficiently on either a
2600168020/68881 or a 68030 or a 68040. The generated code does use the
2600268881 instructions that are emulated on the 68040.
26003
26004The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}.
26005
26006@item -m68020-60
26007@opindex m68020-60
26008Generate output for a 68060, without using any of the new instructions.
26009This results in code that can run relatively efficiently on either a
2601068020/68881 or a 68030 or a 68040. The generated code does use the
2601168881 instructions that are emulated on the 68060.
26012
26013The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}.
26014
26015@item -mhard-float
26016@itemx -m68881
26017@opindex mhard-float
26018@opindex m68881
26019Generate floating-point instructions. This is the default for 68020
26020and above, and for ColdFire devices that have an FPU@. It defines the
26021macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__}
26022on ColdFire targets.
26023
26024@item -msoft-float
26025@opindex msoft-float
26026Do not generate floating-point instructions; use library calls instead.
26027This is the default for 68000, 68010, and 68832 targets. It is also
26028the default for ColdFire devices that have no FPU.
26029
26030@item -mdiv
26031@itemx -mno-div
26032@opindex mdiv
26033@opindex mno-div
26034Generate (do not generate) ColdFire hardware divide and remainder
26035instructions. If @option{-march} is used without @option{-mcpu},
26036the default is ``on'' for ColdFire architectures and ``off'' for M680x0
26037architectures. Otherwise, the default is taken from the target CPU
26038(either the default CPU, or the one specified by @option{-mcpu}). For
26039example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for
26040@option{-mcpu=5206e}.
26041
26042GCC defines the macro @code{__mcfhwdiv__} when this option is enabled.
26043
26044@item -mshort
26045@opindex mshort
26046Consider type @code{int} to be 16 bits wide, like @code{short int}.
26047Additionally, parameters passed on the stack are also aligned to a
2604816-bit boundary even on targets whose API mandates promotion to 32-bit.
26049
26050@item -mno-short
26051@opindex mno-short
26052Do not consider type @code{int} to be 16 bits wide. This is the default.
26053
26054@item -mnobitfield
26055@itemx -mno-bitfield
26056@opindex mnobitfield
26057@opindex mno-bitfield
26058Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32}
26059and @option{-m5200} options imply @w{@option{-mnobitfield}}.
26060
26061@item -mbitfield
26062@opindex mbitfield
26063Do use the bit-field instructions. The @option{-m68020} option implies
26064@option{-mbitfield}. This is the default if you use a configuration
26065designed for a 68020.
26066
26067@item -mrtd
26068@opindex mrtd
26069Use a different function-calling convention, in which functions
26070that take a fixed number of arguments return with the @code{rtd}
26071instruction, which pops their arguments while returning. This
26072saves one instruction in the caller since there is no need to pop
26073the arguments there.
26074
26075This calling convention is incompatible with the one normally
26076used on Unix, so you cannot use it if you need to call libraries
26077compiled with the Unix compiler.
26078
26079Also, you must provide function prototypes for all functions that
26080take variable numbers of arguments (including @code{printf});
26081otherwise incorrect code is generated for calls to those
26082functions.
26083
26084In addition, seriously incorrect code results if you call a
26085function with too many arguments. (Normally, extra arguments are
26086harmlessly ignored.)
26087
26088The @code{rtd} instruction is supported by the 68010, 68020, 68030,
2608968040, 68060 and CPU32 processors, but not by the 68000 or 5200.
26090
26091The default is @option{-mno-rtd}.
26092
26093@item -malign-int
26094@itemx -mno-align-int
26095@opindex malign-int
26096@opindex mno-align-int
26097Control whether GCC aligns @code{int}, @code{long}, @code{long long},
26098@code{float}, @code{double}, and @code{long double} variables on a 32-bit
26099boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}).
26100Aligning variables on 32-bit boundaries produces code that runs somewhat
26101faster on processors with 32-bit busses at the expense of more memory.
26102
26103@strong{Warning:} if you use the @option{-malign-int} switch, GCC
26104aligns structures containing the above types differently than
26105most published application binary interface specifications for the m68k.
26106
26107@opindex mpcrel
26108Use the pc-relative addressing mode of the 68000 directly, instead of
26109using a global offset table. At present, this option implies @option{-fpic},
26110allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is
26111not presently supported with @option{-mpcrel}, though this could be supported for
2611268020 and higher processors.
26113
26114@item -mno-strict-align
26115@itemx -mstrict-align
26116@opindex mno-strict-align
26117@opindex mstrict-align
26118Do not (do) assume that unaligned memory references are handled by
26119the system.
26120
26121@item -msep-data
26122Generate code that allows the data segment to be located in a different
26123area of memory from the text segment. This allows for execute-in-place in
26124an environment without virtual memory management. This option implies
26125@option{-fPIC}.
26126
26127@item -mno-sep-data
26128Generate code that assumes that the data segment follows the text segment.
26129This is the default.
26130
26131@item -mid-shared-library
26132Generate code that supports shared libraries via the library ID method.
26133This allows for execute-in-place and shared libraries in an environment
26134without virtual memory management. This option implies @option{-fPIC}.
26135
26136@item -mno-id-shared-library
26137Generate code that doesn't assume ID-based shared libraries are being used.
26138This is the default.
26139
26140@item -mshared-library-id=n
26141Specifies the identification number of the ID-based shared library being
26142compiled. Specifying a value of 0 generates more compact code; specifying
26143other values forces the allocation of that number to the current
26144library, but is no more space- or time-efficient than omitting this option.
26145
26146@item -mxgot
26147@itemx -mno-xgot
26148@opindex mxgot
26149@opindex mno-xgot
26150When generating position-independent code for ColdFire, generate code
26151that works if the GOT has more than 8192 entries. This code is
26152larger and slower than code generated without this option. On M680x0
26153processors, this option is not needed; @option{-fPIC} suffices.
26154
26155GCC normally uses a single instruction to load values from the GOT@.
26156While this is relatively efficient, it only works if the GOT
26157is smaller than about 64k. Anything larger causes the linker
26158to report an error such as:
26159
26160@cindex relocation truncated to fit (ColdFire)
26161@smallexample
26162relocation truncated to fit: R_68K_GOT16O foobar
26163@end smallexample
26164
26165If this happens, you should recompile your code with @option{-mxgot}.
26166It should then work with very large GOTs. However, code generated with
26167@option{-mxgot} is less efficient, since it takes 4 instructions to fetch
26168the value of a global symbol.
26169
26170Note that some linkers, including newer versions of the GNU linker,
26171can create multiple GOTs and sort GOT entries. If you have such a linker,
26172you should only need to use @option{-mxgot} when compiling a single
26173object file that accesses more than 8192 GOT entries. Very few do.
26174
26175These options have no effect unless GCC is generating
26176position-independent code.
26177
26178@item -mlong-jump-table-offsets
26179@opindex mlong-jump-table-offsets
26180Use 32-bit offsets in @code{switch} tables. The default is to use
2618116-bit offsets.
26182
26183@end table
26184
26185@node MCore Options
26186@subsection MCore Options
26187@cindex MCore options
26188
26189These are the @samp{-m} options defined for the Motorola M*Core
26190processors.
26191
26192@table @gcctabopt
26193
26194@item -mhardlit
26195@itemx -mno-hardlit
26196@opindex mhardlit
26197@opindex mno-hardlit
26198Inline constants into the code stream if it can be done in two
26199instructions or less.
26200
26201@item -mdiv
26202@itemx -mno-div
26203@opindex mdiv
26204@opindex mno-div
26205Use the divide instruction. (Enabled by default).
26206
26207@item -mrelax-immediate
26208@itemx -mno-relax-immediate
26209@opindex mrelax-immediate
26210@opindex mno-relax-immediate
26211Allow arbitrary-sized immediates in bit operations.
26212
26213@item -mwide-bitfields
26214@itemx -mno-wide-bitfields
26215@opindex mwide-bitfields
26216@opindex mno-wide-bitfields
26217Always treat bit-fields as @code{int}-sized.
26218
26219@item -m4byte-functions
26220@itemx -mno-4byte-functions
26221@opindex m4byte-functions
26222@opindex mno-4byte-functions
26223Force all functions to be aligned to a 4-byte boundary.
26224
26225@item -mcallgraph-data
26226@itemx -mno-callgraph-data
26227@opindex mcallgraph-data
26228@opindex mno-callgraph-data
26229Emit callgraph information.
26230
26231@item -mslow-bytes
26232@itemx -mno-slow-bytes
26233@opindex mslow-bytes
26234@opindex mno-slow-bytes
26235Prefer word access when reading byte quantities.
26236
26237@item -mlittle-endian
26238@itemx -mbig-endian
26239@opindex mlittle-endian
26240@opindex mbig-endian
26241Generate code for a little-endian target.
26242
26243@item -m210
26244@itemx -m340
26245@opindex m210
26246@opindex m340
26247Generate code for the 210 processor.
26248
26249@item -mno-lsim
26250@opindex mno-lsim
26251Assume that runtime support has been provided and so omit the
26252simulator library (@file{libsim.a)} from the linker command line.
26253
26254@item -mstack-increment=@var{size}
26255@opindex mstack-increment
26256Set the maximum amount for a single stack increment operation. Large
26257values can increase the speed of programs that contain functions
26258that need a large amount of stack space, but they can also trigger a
26259segmentation fault if the stack is extended too much. The default
26260value is 0x1000.
26261
26262@end table
26263
d77de738
ML
26264@node MicroBlaze Options
26265@subsection MicroBlaze Options
26266@cindex MicroBlaze Options
26267
26268@table @gcctabopt
26269
26270@item -msoft-float
26271@opindex msoft-float
26272Use software emulation for floating point (default).
26273
26274@item -mhard-float
26275@opindex mhard-float
26276Use hardware floating-point instructions.
26277
26278@item -mmemcpy
26279@opindex mmemcpy
26280Do not optimize block moves, use @code{memcpy}.
26281
26282@item -mno-clearbss
26283@opindex mno-clearbss
26284This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead.
26285
26286@item -mcpu=@var{cpu-type}
26287@opindex mcpu=
26288Use features of, and schedule code for, the given CPU.
26289Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}},
26290where @var{X} is a major version, @var{YY} is the minor version, and
26291@var{Z} is compatibility code. Example values are @samp{v3.00.a},
26292@samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}.
26293
26294@item -mxl-soft-mul
26295@opindex mxl-soft-mul
26296Use software multiply emulation (default).
26297
26298@item -mxl-soft-div
26299@opindex mxl-soft-div
26300Use software emulation for divides (default).
26301
26302@item -mxl-barrel-shift
26303@opindex mxl-barrel-shift
26304Use the hardware barrel shifter.
26305
26306@item -mxl-pattern-compare
26307@opindex mxl-pattern-compare
26308Use pattern compare instructions.
26309
26310@item -msmall-divides
26311@opindex msmall-divides
26312Use table lookup optimization for small signed integer divisions.
26313
26314@item -mxl-stack-check
26315@opindex mxl-stack-check
26316This option is deprecated. Use @option{-fstack-check} instead.
26317
26318@item -mxl-gp-opt
26319@opindex mxl-gp-opt
26320Use GP-relative @code{.sdata}/@code{.sbss} sections.
26321
26322@item -mxl-multiply-high
26323@opindex mxl-multiply-high
26324Use multiply high instructions for high part of 32x32 multiply.
26325
26326@item -mxl-float-convert
26327@opindex mxl-float-convert
26328Use hardware floating-point conversion instructions.
26329
26330@item -mxl-float-sqrt
26331@opindex mxl-float-sqrt
26332Use hardware floating-point square root instruction.
26333
26334@item -mbig-endian
26335@opindex mbig-endian
26336Generate code for a big-endian target.
26337
26338@item -mlittle-endian
26339@opindex mlittle-endian
26340Generate code for a little-endian target.
26341
26342@item -mxl-reorder
26343@opindex mxl-reorder
26344Use reorder instructions (swap and byte reversed load/store).
26345
26346@item -mxl-mode-@var{app-model}
26347Select application model @var{app-model}. Valid models are
26348@table @samp
26349@item executable
26350normal executable (default), uses startup code @file{crt0.o}.
26351
26352@item xmdstub
26353for use with Xilinx Microprocessor Debugger (XMD) based
26354software intrusive debug agent called xmdstub. This uses startup file
26355@file{crt1.o} and sets the start address of the program to 0x800.
26356
26357@item bootstrap
26358for applications that are loaded using a bootloader.
26359This model uses startup file @file{crt2.o} which does not contain a processor
26360reset vector handler. This is suitable for transferring control on a
26361processor reset to the bootloader rather than the application.
26362
26363@item novectors
26364for applications that do not require any of the
26365MicroBlaze vectors. This option may be useful for applications running
26366within a monitoring application. This model uses @file{crt3.o} as a startup file.
26367@end table
26368
26369Option @option{-xl-mode-@var{app-model}} is a deprecated alias for
26370@option{-mxl-mode-@var{app-model}}.
26371
26372@item -mpic-data-is-text-relative
26373@opindex mpic-data-is-text-relative
26374Assume that the displacement between the text and data segments is fixed
26375at static link time. This allows data to be referenced by offset from start of
26376text address instead of GOT since PC-relative addressing is not supported.
26377
26378@end table
26379
26380@node MIPS Options
26381@subsection MIPS Options
26382@cindex MIPS options
26383
26384@table @gcctabopt
26385
26386@item -EB
26387@opindex EB
26388Generate big-endian code.
26389
26390@item -EL
26391@opindex EL
26392Generate little-endian code. This is the default for @samp{mips*el-*-*}
26393configurations.
26394
26395@item -march=@var{arch}
26396@opindex march
26397Generate code that runs on @var{arch}, which can be the name of a
26398generic MIPS ISA, or the name of a particular processor.
26399The ISA names are:
26400@samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4},
26401@samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5},
26402@samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3},
26403@samp{mips64r5} and @samp{mips64r6}.
26404The processor names are:
26405@samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc},
26406@samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd},
26407@samp{5kc}, @samp{5kf},
26408@samp{20kc},
26409@samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1},
26410@samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1},
26411@samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn},
26412@samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2},
26413@samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
26414@samp{i6400}, @samp{i6500},
26415@samp{interaptiv},
26416@samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464},
26417@samp{gs464e}, @samp{gs264e},
26418@samp{m4k},
26419@samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec},
26420@samp{m5100}, @samp{m5101},
26421@samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3},
26422@samp{orion},
26423@samp{p5600}, @samp{p6600},
26424@samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
26425@samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900},
26426@samp{r6000}, @samp{r8000},
26427@samp{rm7000}, @samp{rm9000},
26428@samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000},
26429@samp{sb1},
26430@samp{sr71000},
26431@samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300},
26432@samp{vr5000}, @samp{vr5400}, @samp{vr5500},
26433@samp{xlr} and @samp{xlp}.
26434The special value @samp{from-abi} selects the
26435most compatible architecture for the selected ABI (that is,
26436@samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@.
26437
26438The native Linux/GNU toolchain also supports the value @samp{native},
26439which selects the best architecture option for the host processor.
26440@option{-march=native} has no effect if GCC does not recognize
26441the processor.
26442
26443In processor names, a final @samp{000} can be abbreviated as @samp{k}
26444(for example, @option{-march=r2k}). Prefixes are optional, and
26445@samp{vr} may be written @samp{r}.
26446
26447Names of the form @samp{@var{n}f2_1} refer to processors with
26448FPUs clocked at half the rate of the core, names of the form
26449@samp{@var{n}f1_1} refer to processors with FPUs clocked at the same
26450rate as the core, and names of the form @samp{@var{n}f3_2} refer to
26451processors with FPUs clocked a ratio of 3:2 with respect to the core.
26452For compatibility reasons, @samp{@var{n}f} is accepted as a synonym
26453for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are
26454accepted as synonyms for @samp{@var{n}f1_1}.
26455
26456GCC defines two macros based on the value of this option. The first
26457is @code{_MIPS_ARCH}, which gives the name of target architecture, as
26458a string. The second has the form @code{_MIPS_ARCH_@var{foo}},
26459where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@.
26460For example, @option{-march=r2000} sets @code{_MIPS_ARCH}
26461to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}.
26462
26463Note that the @code{_MIPS_ARCH} macro uses the processor names given
26464above. In other words, it has the full prefix and does not
26465abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi},
26466the macro names the resolved architecture (either @code{"mips1"} or
26467@code{"mips3"}). It names the default architecture when no
26468@option{-march} option is given.
26469
26470@item -mtune=@var{arch}
26471@opindex mtune
26472Optimize for @var{arch}. Among other things, this option controls
26473the way instructions are scheduled, and the perceived cost of arithmetic
26474operations. The list of @var{arch} values is the same as for
26475@option{-march}.
26476
26477When this option is not used, GCC optimizes for the processor
26478specified by @option{-march}. By using @option{-march} and
26479@option{-mtune} together, it is possible to generate code that
26480runs on a family of processors, but optimize the code for one
26481particular member of that family.
26482
26483@option{-mtune} defines the macros @code{_MIPS_TUNE} and
26484@code{_MIPS_TUNE_@var{foo}}, which work in the same way as the
26485@option{-march} ones described above.
26486
26487@item -mips1
26488@opindex mips1
26489Equivalent to @option{-march=mips1}.
26490
26491@item -mips2
26492@opindex mips2
26493Equivalent to @option{-march=mips2}.
26494
26495@item -mips3
26496@opindex mips3
26497Equivalent to @option{-march=mips3}.
26498
26499@item -mips4
26500@opindex mips4
26501Equivalent to @option{-march=mips4}.
26502
26503@item -mips32
26504@opindex mips32
26505Equivalent to @option{-march=mips32}.
26506
26507@item -mips32r3
26508@opindex mips32r3
26509Equivalent to @option{-march=mips32r3}.
26510
26511@item -mips32r5
26512@opindex mips32r5
26513Equivalent to @option{-march=mips32r5}.
26514
26515@item -mips32r6
26516@opindex mips32r6
26517Equivalent to @option{-march=mips32r6}.
26518
26519@item -mips64
26520@opindex mips64
26521Equivalent to @option{-march=mips64}.
26522
26523@item -mips64r2
26524@opindex mips64r2
26525Equivalent to @option{-march=mips64r2}.
26526
26527@item -mips64r3
26528@opindex mips64r3
26529Equivalent to @option{-march=mips64r3}.
26530
26531@item -mips64r5
26532@opindex mips64r5
26533Equivalent to @option{-march=mips64r5}.
26534
26535@item -mips64r6
26536@opindex mips64r6
26537Equivalent to @option{-march=mips64r6}.
26538
26539@item -mips16
26540@itemx -mno-mips16
26541@opindex mips16
26542@opindex mno-mips16
26543Generate (do not generate) MIPS16 code. If GCC is targeting a
26544MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@.
26545
26546MIPS16 code generation can also be controlled on a per-function basis
26547by means of @code{mips16} and @code{nomips16} attributes.
26548@xref{Function Attributes}, for more information.
26549
26550@item -mflip-mips16
26551@opindex mflip-mips16
26552Generate MIPS16 code on alternating functions. This option is provided
26553for regression testing of mixed MIPS16/non-MIPS16 code generation, and is
26554not intended for ordinary use in compiling user code.
26555
26556@item -minterlink-compressed
26557@itemx -mno-interlink-compressed
26558@opindex minterlink-compressed
26559@opindex mno-interlink-compressed
26560Require (do not require) that code using the standard (uncompressed) MIPS ISA
26561be link-compatible with MIPS16 and microMIPS code, and vice versa.
26562
26563For example, code using the standard ISA encoding cannot jump directly
26564to MIPS16 or microMIPS code; it must either use a call or an indirect jump.
26565@option{-minterlink-compressed} therefore disables direct jumps unless GCC
26566knows that the target of the jump is not compressed.
26567
26568@item -minterlink-mips16
26569@itemx -mno-interlink-mips16
26570@opindex minterlink-mips16
26571@opindex mno-interlink-mips16
26572Aliases of @option{-minterlink-compressed} and
26573@option{-mno-interlink-compressed}. These options predate the microMIPS ASE
26574and are retained for backwards compatibility.
26575
26576@item -mabi=32
26577@itemx -mabi=o64
26578@itemx -mabi=n32
26579@itemx -mabi=64
26580@itemx -mabi=eabi
26581@opindex mabi=32
26582@opindex mabi=o64
26583@opindex mabi=n32
26584@opindex mabi=64
26585@opindex mabi=eabi
26586Generate code for the given ABI@.
26587
26588Note that the EABI has a 32-bit and a 64-bit variant. GCC normally
26589generates 64-bit code when you select a 64-bit architecture, but you
26590can use @option{-mgp32} to get 32-bit code instead.
26591
26592For information about the O64 ABI, see
26593@uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}.
26594
26595GCC supports a variant of the o32 ABI in which floating-point registers
26596are 64 rather than 32 bits wide. You can select this combination with
26597@option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1}
26598and @code{mfhc1} instructions and is therefore only supported for
26599MIPS32R2, MIPS32R3 and MIPS32R5 processors.
26600
26601The register assignments for arguments and return values remain the
26602same, but each scalar value is passed in a single 64-bit register
26603rather than a pair of 32-bit registers. For example, scalar
26604floating-point values are returned in @samp{$f0} only, not a
26605@samp{$f0}/@samp{$f1} pair. The set of call-saved registers also
26606remains the same in that the even-numbered double-precision registers
26607are saved.
26608
26609Two additional variants of the o32 ABI are supported to enable
26610a transition from 32-bit to 64-bit registers. These are FPXX
26611(@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}).
26612The FPXX extension mandates that all code must execute correctly
26613when run using 32-bit or 64-bit registers. The code can be interlinked
26614with either FP32 or FP64, but not both.
26615The FP64A extension is similar to the FP64 extension but forbids the
26616use of odd-numbered single-precision registers. This can be used
26617in conjunction with the @code{FRE} mode of FPUs in MIPS32R5
26618processors and allows both FP32 and FP64A code to interlink and
26619run in the same process without changing FPU modes.
26620
26621@item -mabicalls
26622@itemx -mno-abicalls
26623@opindex mabicalls
26624@opindex mno-abicalls
26625Generate (do not generate) code that is suitable for SVR4-style
26626dynamic objects. @option{-mabicalls} is the default for SVR4-based
26627systems.
26628
26629@item -mshared
26630@itemx -mno-shared
26631Generate (do not generate) code that is fully position-independent,
26632and that can therefore be linked into shared libraries. This option
26633only affects @option{-mabicalls}.
26634
26635All @option{-mabicalls} code has traditionally been position-independent,
26636regardless of options like @option{-fPIC} and @option{-fpic}. However,
26637as an extension, the GNU toolchain allows executables to use absolute
26638accesses for locally-binding symbols. It can also use shorter GP
26639initialization sequences and generate direct calls to locally-defined
26640functions. This mode is selected by @option{-mno-shared}.
26641
26642@option{-mno-shared} depends on binutils 2.16 or higher and generates
26643objects that can only be linked by the GNU linker. However, the option
26644does not affect the ABI of the final executable; it only affects the ABI
26645of relocatable objects. Using @option{-mno-shared} generally makes
26646executables both smaller and quicker.
26647
26648@option{-mshared} is the default.
26649
26650@item -mplt
26651@itemx -mno-plt
26652@opindex mplt
26653@opindex mno-plt
26654Assume (do not assume) that the static and dynamic linkers
26655support PLTs and copy relocations. This option only affects
26656@option{-mno-shared -mabicalls}. For the n64 ABI, this option
26657has no effect without @option{-msym32}.
26658
26659You can make @option{-mplt} the default by configuring
26660GCC with @option{--with-mips-plt}. The default is
26661@option{-mno-plt} otherwise.
26662
26663@item -mxgot
26664@itemx -mno-xgot
26665@opindex mxgot
26666@opindex mno-xgot
26667Lift (do not lift) the usual restrictions on the size of the global
26668offset table.
26669
26670GCC normally uses a single instruction to load values from the GOT@.
26671While this is relatively efficient, it only works if the GOT
26672is smaller than about 64k. Anything larger causes the linker
26673to report an error such as:
26674
26675@cindex relocation truncated to fit (MIPS)
26676@smallexample
26677relocation truncated to fit: R_MIPS_GOT16 foobar
26678@end smallexample
26679
26680If this happens, you should recompile your code with @option{-mxgot}.
26681This works with very large GOTs, although the code is also
26682less efficient, since it takes three instructions to fetch the
26683value of a global symbol.
26684
26685Note that some linkers can create multiple GOTs. If you have such a
26686linker, you should only need to use @option{-mxgot} when a single object
26687file accesses more than 64k's worth of GOT entries. Very few do.
26688
26689These options have no effect unless GCC is generating position
26690independent code.
26691
26692@item -mgp32
26693@opindex mgp32
26694Assume that general-purpose registers are 32 bits wide.
26695
26696@item -mgp64
26697@opindex mgp64
26698Assume that general-purpose registers are 64 bits wide.
26699
26700@item -mfp32
26701@opindex mfp32
26702Assume that floating-point registers are 32 bits wide.
26703
26704@item -mfp64
26705@opindex mfp64
26706Assume that floating-point registers are 64 bits wide.
26707
26708@item -mfpxx
26709@opindex mfpxx
26710Do not assume the width of floating-point registers.
26711
26712@item -mhard-float
26713@opindex mhard-float
26714Use floating-point coprocessor instructions.
26715
26716@item -msoft-float
26717@opindex msoft-float
26718Do not use floating-point coprocessor instructions. Implement
26719floating-point calculations using library calls instead.
26720
26721@item -mno-float
26722@opindex mno-float
26723Equivalent to @option{-msoft-float}, but additionally asserts that the
26724program being compiled does not perform any floating-point operations.
26725This option is presently supported only by some bare-metal MIPS
26726configurations, where it may select a special set of libraries
26727that lack all floating-point support (including, for example, the
26728floating-point @code{printf} formats).
26729If code compiled with @option{-mno-float} accidentally contains
26730floating-point operations, it is likely to suffer a link-time
26731or run-time failure.
26732
26733@item -msingle-float
26734@opindex msingle-float
26735Assume that the floating-point coprocessor only supports single-precision
26736operations.
26737
26738@item -mdouble-float
26739@opindex mdouble-float
26740Assume that the floating-point coprocessor supports double-precision
26741operations. This is the default.
26742
26743@item -modd-spreg
26744@itemx -mno-odd-spreg
26745@opindex modd-spreg
26746@opindex mno-odd-spreg
26747Enable the use of odd-numbered single-precision floating-point registers
26748for the o32 ABI. This is the default for processors that are known to
26749support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg}
26750is set by default.
26751
26752@item -mabs=2008
26753@itemx -mabs=legacy
26754@opindex mabs=2008
26755@opindex mabs=legacy
26756These options control the treatment of the special not-a-number (NaN)
26757IEEE 754 floating-point data with the @code{abs.@i{fmt}} and
26758@code{neg.@i{fmt}} machine instructions.
26759
26760By default or when @option{-mabs=legacy} is used the legacy
26761treatment is selected. In this case these instructions are considered
26762arithmetic and avoided where correct operation is required and the
26763input operand might be a NaN. A longer sequence of instructions that
26764manipulate the sign bit of floating-point datum manually is used
26765instead unless the @option{-ffinite-math-only} option has also been
26766specified.
26767
26768The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In
26769this case these instructions are considered non-arithmetic and therefore
26770operating correctly in all cases, including in particular where the
26771input operand is a NaN. These instructions are therefore always used
26772for the respective operations.
26773
26774@item -mnan=2008
26775@itemx -mnan=legacy
26776@opindex mnan=2008
26777@opindex mnan=legacy
26778These options control the encoding of the special not-a-number (NaN)
26779IEEE 754 floating-point data.
26780
26781The @option{-mnan=legacy} option selects the legacy encoding. In this
26782case quiet NaNs (qNaNs) are denoted by the first bit of their trailing
26783significand field being 0, whereas signaling NaNs (sNaNs) are denoted
26784by the first bit of their trailing significand field being 1.
26785
26786The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In
26787this case qNaNs are denoted by the first bit of their trailing
26788significand field being 1, whereas sNaNs are denoted by the first bit of
26789their trailing significand field being 0.
26790
26791The default is @option{-mnan=legacy} unless GCC has been configured with
26792@option{--with-nan=2008}.
26793
26794@item -mllsc
26795@itemx -mno-llsc
26796@opindex mllsc
26797@opindex mno-llsc
26798Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to
26799implement atomic memory built-in functions. When neither option is
26800specified, GCC uses the instructions if the target architecture
26801supports them.
26802
26803@option{-mllsc} is useful if the runtime environment can emulate the
26804instructions and @option{-mno-llsc} can be useful when compiling for
26805nonstandard ISAs. You can make either option the default by
26806configuring GCC with @option{--with-llsc} and @option{--without-llsc}
26807respectively. @option{--with-llsc} is the default for some
26808configurations; see the installation documentation for details.
26809
26810@item -mdsp
26811@itemx -mno-dsp
26812@opindex mdsp
26813@opindex mno-dsp
26814Use (do not use) revision 1 of the MIPS DSP ASE@.
26815@xref{MIPS DSP Built-in Functions}. This option defines the
26816preprocessor macro @code{__mips_dsp}. It also defines
26817@code{__mips_dsp_rev} to 1.
26818
26819@item -mdspr2
26820@itemx -mno-dspr2
26821@opindex mdspr2
26822@opindex mno-dspr2
26823Use (do not use) revision 2 of the MIPS DSP ASE@.
26824@xref{MIPS DSP Built-in Functions}. This option defines the
26825preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}.
26826It also defines @code{__mips_dsp_rev} to 2.
26827
26828@item -msmartmips
26829@itemx -mno-smartmips
26830@opindex msmartmips
26831@opindex mno-smartmips
26832Use (do not use) the MIPS SmartMIPS ASE.
26833
26834@item -mpaired-single
26835@itemx -mno-paired-single
26836@opindex mpaired-single
26837@opindex mno-paired-single
26838Use (do not use) paired-single floating-point instructions.
26839@xref{MIPS Paired-Single Support}. This option requires
26840hardware floating-point support to be enabled.
26841
26842@item -mdmx
26843@itemx -mno-mdmx
26844@opindex mdmx
26845@opindex mno-mdmx
26846Use (do not use) MIPS Digital Media Extension instructions.
26847This option can only be used when generating 64-bit code and requires
26848hardware floating-point support to be enabled.
26849
26850@item -mips3d
26851@itemx -mno-mips3d
26852@opindex mips3d
26853@opindex mno-mips3d
26854Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}.
26855The option @option{-mips3d} implies @option{-mpaired-single}.
26856
26857@item -mmicromips
26858@itemx -mno-micromips
26859@opindex mmicromips
26860@opindex mno-mmicromips
26861Generate (do not generate) microMIPS code.
26862
26863MicroMIPS code generation can also be controlled on a per-function basis
26864by means of @code{micromips} and @code{nomicromips} attributes.
26865@xref{Function Attributes}, for more information.
26866
26867@item -mmt
26868@itemx -mno-mt
26869@opindex mmt
26870@opindex mno-mt
26871Use (do not use) MT Multithreading instructions.
26872
26873@item -mmcu
26874@itemx -mno-mcu
26875@opindex mmcu
26876@opindex mno-mcu
26877Use (do not use) the MIPS MCU ASE instructions.
26878
26879@item -meva
26880@itemx -mno-eva
26881@opindex meva
26882@opindex mno-eva
26883Use (do not use) the MIPS Enhanced Virtual Addressing instructions.
26884
26885@item -mvirt
26886@itemx -mno-virt
26887@opindex mvirt
26888@opindex mno-virt
26889Use (do not use) the MIPS Virtualization (VZ) instructions.
26890
26891@item -mxpa
26892@itemx -mno-xpa
26893@opindex mxpa
26894@opindex mno-xpa
26895Use (do not use) the MIPS eXtended Physical Address (XPA) instructions.
26896
26897@item -mcrc
26898@itemx -mno-crc
26899@opindex mcrc
26900@opindex mno-crc
26901Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions.
26902
26903@item -mginv
26904@itemx -mno-ginv
26905@opindex mginv
26906@opindex mno-ginv
26907Use (do not use) the MIPS Global INValidate (GINV) instructions.
26908
26909@item -mloongson-mmi
26910@itemx -mno-loongson-mmi
26911@opindex mloongson-mmi
26912@opindex mno-loongson-mmi
26913Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI).
26914
26915@item -mloongson-ext
26916@itemx -mno-loongson-ext
26917@opindex mloongson-ext
26918@opindex mno-loongson-ext
26919Use (do not use) the MIPS Loongson EXTensions (EXT) instructions.
26920
26921@item -mloongson-ext2
26922@itemx -mno-loongson-ext2
26923@opindex mloongson-ext2
26924@opindex mno-loongson-ext2
26925Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions.
26926
26927@item -mlong64
26928@opindex mlong64
26929Force @code{long} types to be 64 bits wide. See @option{-mlong32} for
26930an explanation of the default and the way that the pointer size is
26931determined.
26932
26933@item -mlong32
26934@opindex mlong32
26935Force @code{long}, @code{int}, and pointer types to be 32 bits wide.
26936
26937The default size of @code{int}s, @code{long}s and pointers depends on
26938the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI
26939uses 64-bit @code{long}s, as does the 64-bit EABI; the others use
2694032-bit @code{long}s. Pointers are the same size as @code{long}s,
26941or the same size as integer registers, whichever is smaller.
26942
26943@item -msym32
26944@itemx -mno-sym32
26945@opindex msym32
26946@opindex mno-sym32
26947Assume (do not assume) that all symbols have 32-bit values, regardless
26948of the selected ABI@. This option is useful in combination with
26949@option{-mabi=64} and @option{-mno-abicalls} because it allows GCC
26950to generate shorter and faster references to symbolic addresses.
26951
26952@item -G @var{num}
26953@opindex G
26954Put definitions of externally-visible data in a small data section
26955if that data is no bigger than @var{num} bytes. GCC can then generate
26956more efficient accesses to the data; see @option{-mgpopt} for details.
26957
26958The default @option{-G} option depends on the configuration.
26959
26960@item -mlocal-sdata
26961@itemx -mno-local-sdata
26962@opindex mlocal-sdata
26963@opindex mno-local-sdata
26964Extend (do not extend) the @option{-G} behavior to local data too,
26965such as to static variables in C@. @option{-mlocal-sdata} is the
26966default for all configurations.
26967
26968If the linker complains that an application is using too much small data,
26969you might want to try rebuilding the less performance-critical parts with
26970@option{-mno-local-sdata}. You might also want to build large
26971libraries with @option{-mno-local-sdata}, so that the libraries leave
26972more room for the main program.
26973
26974@item -mextern-sdata
26975@itemx -mno-extern-sdata
26976@opindex mextern-sdata
26977@opindex mno-extern-sdata
26978Assume (do not assume) that externally-defined data is in
26979a small data section if the size of that data is within the @option{-G} limit.
26980@option{-mextern-sdata} is the default for all configurations.
26981
26982If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G
26983@var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var}
26984that is no bigger than @var{num} bytes, you must make sure that @var{Var}
26985is placed in a small data section. If @var{Var} is defined by another
26986module, you must either compile that module with a high-enough
26987@option{-G} setting or attach a @code{section} attribute to @var{Var}'s
26988definition. If @var{Var} is common, you must link the application
26989with a high-enough @option{-G} setting.
26990
26991The easiest way of satisfying these restrictions is to compile
26992and link every module with the same @option{-G} option. However,
26993you may wish to build a library that supports several different
26994small data limits. You can do this by compiling the library with
26995the highest supported @option{-G} setting and additionally using
26996@option{-mno-extern-sdata} to stop the library from making assumptions
26997about externally-defined data.
26998
26999@item -mgpopt
27000@itemx -mno-gpopt
27001@opindex mgpopt
27002@opindex mno-gpopt
27003Use (do not use) GP-relative accesses for symbols that are known to be
27004in a small data section; see @option{-G}, @option{-mlocal-sdata} and
27005@option{-mextern-sdata}. @option{-mgpopt} is the default for all
27006configurations.
27007
27008@option{-mno-gpopt} is useful for cases where the @code{$gp} register
27009might not hold the value of @code{_gp}. For example, if the code is
27010part of a library that might be used in a boot monitor, programs that
27011call boot monitor routines pass an unknown value in @code{$gp}.
27012(In such situations, the boot monitor itself is usually compiled
27013with @option{-G0}.)
27014
27015@option{-mno-gpopt} implies @option{-mno-local-sdata} and
27016@option{-mno-extern-sdata}.
27017
27018@item -membedded-data
27019@itemx -mno-embedded-data
27020@opindex membedded-data
27021@opindex mno-embedded-data
27022Allocate variables to the read-only data section first if possible, then
27023next in the small data section if possible, otherwise in data. This gives
27024slightly slower code than the default, but reduces the amount of RAM required
27025when executing, and thus may be preferred for some embedded systems.
27026
27027@item -muninit-const-in-rodata
27028@itemx -mno-uninit-const-in-rodata
27029@opindex muninit-const-in-rodata
27030@opindex mno-uninit-const-in-rodata
27031Put uninitialized @code{const} variables in the read-only data section.
27032This option is only meaningful in conjunction with @option{-membedded-data}.
27033
27034@item -mcode-readable=@var{setting}
27035@opindex mcode-readable
27036Specify whether GCC may generate code that reads from executable sections.
27037There are three possible settings:
27038
27039@table @gcctabopt
27040@item -mcode-readable=yes
27041Instructions may freely access executable sections. This is the
27042default setting.
27043
27044@item -mcode-readable=pcrel
27045MIPS16 PC-relative load instructions can access executable sections,
27046but other instructions must not do so. This option is useful on 4KSc
27047and 4KSd processors when the code TLBs have the Read Inhibit bit set.
27048It is also useful on processors that can be configured to have a dual
27049instruction/data SRAM interface and that, like the M4K, automatically
27050redirect PC-relative loads to the instruction RAM.
27051
27052@item -mcode-readable=no
27053Instructions must not access executable sections. This option can be
27054useful on targets that are configured to have a dual instruction/data
27055SRAM interface but that (unlike the M4K) do not automatically redirect
27056PC-relative loads to the instruction RAM.
27057@end table
27058
27059@item -msplit-addresses
27060@itemx -mno-split-addresses
27061@opindex msplit-addresses
27062@opindex mno-split-addresses
27063Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler
27064relocation operators. This option has been superseded by
27065@option{-mexplicit-relocs} but is retained for backwards compatibility.
27066
27067@item -mexplicit-relocs
27068@itemx -mno-explicit-relocs
27069@opindex mexplicit-relocs
27070@opindex mno-explicit-relocs
27071Use (do not use) assembler relocation operators when dealing with symbolic
27072addresses. The alternative, selected by @option{-mno-explicit-relocs},
27073is to use assembler macros instead.
27074
27075@option{-mexplicit-relocs} is the default if GCC was configured
27076to use an assembler that supports relocation operators.
27077
27078@item -mcheck-zero-division
27079@itemx -mno-check-zero-division
27080@opindex mcheck-zero-division
27081@opindex mno-check-zero-division
27082Trap (do not trap) on integer division by zero.
27083
27084The default is @option{-mcheck-zero-division}.
27085
27086@item -mdivide-traps
27087@itemx -mdivide-breaks
27088@opindex mdivide-traps
27089@opindex mdivide-breaks
27090MIPS systems check for division by zero by generating either a
27091conditional trap or a break instruction. Using traps results in
27092smaller code, but is only supported on MIPS II and later. Also, some
27093versions of the Linux kernel have a bug that prevents trap from
27094generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to
27095allow conditional traps on architectures that support them and
27096@option{-mdivide-breaks} to force the use of breaks.
27097
27098The default is usually @option{-mdivide-traps}, but this can be
27099overridden at configure time using @option{--with-divide=breaks}.
27100Divide-by-zero checks can be completely disabled using
27101@option{-mno-check-zero-division}.
27102
27103@item -mload-store-pairs
27104@itemx -mno-load-store-pairs
27105@opindex mload-store-pairs
27106@opindex mno-load-store-pairs
27107Enable (disable) an optimization that pairs consecutive load or store
27108instructions to enable load/store bonding. This option is enabled by
27109default but only takes effect when the selected architecture is known
27110to support bonding.
27111
27112@item -munaligned-access
27113@itemx -mno-unaligned-access
27114@opindex munaligned-access
27115@opindex mno-unaligned-access
27116Enable (disable) direct unaligned access for MIPS Release 6.
27117MIPSr6 requires load/store unaligned-access support,
27118by hardware or trap&emulate.
27119So @option{-mno-unaligned-access} may be needed by kernel.
27120
27121@item -mmemcpy
27122@itemx -mno-memcpy
27123@opindex mmemcpy
27124@opindex mno-memcpy
27125Force (do not force) the use of @code{memcpy} for non-trivial block
27126moves. The default is @option{-mno-memcpy}, which allows GCC to inline
27127most constant-sized copies.
27128
27129@item -mlong-calls
27130@itemx -mno-long-calls
27131@opindex mlong-calls
27132@opindex mno-long-calls
27133Disable (do not disable) use of the @code{jal} instruction. Calling
27134functions using @code{jal} is more efficient but requires the caller
27135and callee to be in the same 256 megabyte segment.
27136
27137This option has no effect on abicalls code. The default is
27138@option{-mno-long-calls}.
27139
27140@item -mmad
27141@itemx -mno-mad
27142@opindex mmad
27143@opindex mno-mad
27144Enable (disable) use of the @code{mad}, @code{madu} and @code{mul}
27145instructions, as provided by the R4650 ISA@.
27146
27147@item -mimadd
27148@itemx -mno-imadd
27149@opindex mimadd
27150@opindex mno-imadd
27151Enable (disable) use of the @code{madd} and @code{msub} integer
27152instructions. The default is @option{-mimadd} on architectures
27153that support @code{madd} and @code{msub} except for the 74k
27154architecture where it was found to generate slower code.
27155
27156@item -mfused-madd
27157@itemx -mno-fused-madd
27158@opindex mfused-madd
27159@opindex mno-fused-madd
27160Enable (disable) use of the floating-point multiply-accumulate
27161instructions, when they are available. The default is
27162@option{-mfused-madd}.
27163
27164On the R8000 CPU when multiply-accumulate instructions are used,
27165the intermediate product is calculated to infinite precision
27166and is not subject to the FCSR Flush to Zero bit. This may be
27167undesirable in some circumstances. On other processors the result
27168is numerically identical to the equivalent computation using
27169separate multiply, add, subtract and negate instructions.
27170
27171@item -nocpp
27172@opindex nocpp
27173Tell the MIPS assembler to not run its preprocessor over user
27174assembler files (with a @samp{.s} suffix) when assembling them.
27175
27176@item -mfix-24k
27177@itemx -mno-fix-24k
27178@opindex mfix-24k
27179@opindex mno-fix-24k
27180Work around the 24K E48 (lost data on stores during refill) errata.
27181The workarounds are implemented by the assembler rather than by GCC@.
27182
27183@item -mfix-r4000
27184@itemx -mno-fix-r4000
27185@opindex mfix-r4000
27186@opindex mno-fix-r4000
27187Work around certain R4000 CPU errata:
27188@itemize @minus
27189@item
27190A double-word or a variable shift may give an incorrect result if executed
27191immediately after starting an integer division.
27192@item
27193A double-word or a variable shift may give an incorrect result if executed
27194while an integer multiplication is in progress.
27195@item
27196An integer division may give an incorrect result if started in a delay slot
27197of a taken branch or a jump.
27198@end itemize
27199
27200@item -mfix-r4400
27201@itemx -mno-fix-r4400
27202@opindex mfix-r4400
27203@opindex mno-fix-r4400
27204Work around certain R4400 CPU errata:
27205@itemize @minus
27206@item
27207A double-word or a variable shift may give an incorrect result if executed
27208immediately after starting an integer division.
27209@end itemize
27210
27211@item -mfix-r10000
27212@itemx -mno-fix-r10000
27213@opindex mfix-r10000
27214@opindex mno-fix-r10000
27215Work around certain R10000 errata:
27216@itemize @minus
27217@item
27218@code{ll}/@code{sc} sequences may not behave atomically on revisions
27219prior to 3.0. They may deadlock on revisions 2.6 and earlier.
27220@end itemize
27221
27222This option can only be used if the target architecture supports
27223branch-likely instructions. @option{-mfix-r10000} is the default when
27224@option{-march=r10000} is used; @option{-mno-fix-r10000} is the default
27225otherwise.
27226
27227@item -mfix-r5900
27228@itemx -mno-fix-r5900
27229@opindex mfix-r5900
27230Do not attempt to schedule the preceding instruction into the delay slot
27231of a branch instruction placed at the end of a short loop of six
27232instructions or fewer and always schedule a @code{nop} instruction there
27233instead. The short loop bug under certain conditions causes loops to
27234execute only once or twice, due to a hardware bug in the R5900 chip. The
27235workaround is implemented by the assembler rather than by GCC@.
27236
27237@item -mfix-rm7000
27238@itemx -mno-fix-rm7000
27239@opindex mfix-rm7000
27240Work around the RM7000 @code{dmult}/@code{dmultu} errata. The
27241workarounds are implemented by the assembler rather than by GCC@.
27242
27243@item -mfix-vr4120
27244@itemx -mno-fix-vr4120
27245@opindex mfix-vr4120
27246Work around certain VR4120 errata:
27247@itemize @minus
27248@item
27249@code{dmultu} does not always produce the correct result.
27250@item
27251@code{div} and @code{ddiv} do not always produce the correct result if one
27252of the operands is negative.
27253@end itemize
27254The workarounds for the division errata rely on special functions in
27255@file{libgcc.a}. At present, these functions are only provided by
27256the @code{mips64vr*-elf} configurations.
27257
27258Other VR4120 errata require a NOP to be inserted between certain pairs of
27259instructions. These errata are handled by the assembler, not by GCC itself.
27260
27261@item -mfix-vr4130
27262@opindex mfix-vr4130
27263Work around the VR4130 @code{mflo}/@code{mfhi} errata. The
27264workarounds are implemented by the assembler rather than by GCC,
27265although GCC avoids using @code{mflo} and @code{mfhi} if the
27266VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi}
27267instructions are available instead.
27268
27269@item -mfix-sb1
27270@itemx -mno-fix-sb1
27271@opindex mfix-sb1
27272Work around certain SB-1 CPU core errata.
27273(This flag currently works around the SB-1 revision 2
27274``F1'' and ``F2'' floating-point errata.)
27275
27276@item -mr10k-cache-barrier=@var{setting}
27277@opindex mr10k-cache-barrier
27278Specify whether GCC should insert cache barriers to avoid the
27279side effects of speculation on R10K processors.
27280
27281In common with many processors, the R10K tries to predict the outcome
27282of a conditional branch and speculatively executes instructions from
27283the ``taken'' branch. It later aborts these instructions if the
27284predicted outcome is wrong. However, on the R10K, even aborted
27285instructions can have side effects.
27286
27287This problem only affects kernel stores and, depending on the system,
27288kernel loads. As an example, a speculatively-executed store may load
27289the target memory into cache and mark the cache line as dirty, even if
27290the store itself is later aborted. If a DMA operation writes to the
27291same area of memory before the ``dirty'' line is flushed, the cached
27292data overwrites the DMA-ed data. See the R10K processor manual
27293for a full description, including other potential problems.
27294
27295One workaround is to insert cache barrier instructions before every memory
27296access that might be speculatively executed and that might have side
27297effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}}
27298controls GCC's implementation of this workaround. It assumes that
27299aborted accesses to any byte in the following regions does not have
27300side effects:
27301
27302@enumerate
27303@item
27304the memory occupied by the current function's stack frame;
27305
27306@item
27307the memory occupied by an incoming stack argument;
27308
27309@item
27310the memory occupied by an object with a link-time-constant address.
27311@end enumerate
27312
27313It is the kernel's responsibility to ensure that speculative
27314accesses to these regions are indeed safe.
27315
27316If the input program contains a function declaration such as:
27317
27318@smallexample
27319void foo (void);
27320@end smallexample
27321
27322then the implementation of @code{foo} must allow @code{j foo} and
27323@code{jal foo} to be executed speculatively. GCC honors this
27324restriction for functions it compiles itself. It expects non-GCC
27325functions (such as hand-written assembly code) to do the same.
27326
27327The option has three forms:
27328
27329@table @gcctabopt
27330@item -mr10k-cache-barrier=load-store
27331Insert a cache barrier before a load or store that might be
27332speculatively executed and that might have side effects even
27333if aborted.
27334
27335@item -mr10k-cache-barrier=store
27336Insert a cache barrier before a store that might be speculatively
27337executed and that might have side effects even if aborted.
27338
27339@item -mr10k-cache-barrier=none
27340Disable the insertion of cache barriers. This is the default setting.
27341@end table
27342
27343@item -mflush-func=@var{func}
27344@itemx -mno-flush-func
27345@opindex mflush-func
27346Specifies the function to call to flush the I and D caches, or to not
27347call any such function. If called, the function must take the same
27348arguments as the common @code{_flush_func}, that is, the address of the
27349memory range for which the cache is being flushed, the size of the
27350memory range, and the number 3 (to flush both caches). The default
27351depends on the target GCC was configured for, but commonly is either
27352@code{_flush_func} or @code{__cpu_flush}.
27353
27354@item mbranch-cost=@var{num}
27355@opindex mbranch-cost
27356Set the cost of branches to roughly @var{num} ``simple'' instructions.
27357This cost is only a heuristic and is not guaranteed to produce
27358consistent results across releases. A zero cost redundantly selects
27359the default, which is based on the @option{-mtune} setting.
27360
27361@item -mbranch-likely
27362@itemx -mno-branch-likely
27363@opindex mbranch-likely
27364@opindex mno-branch-likely
27365Enable or disable use of Branch Likely instructions, regardless of the
27366default for the selected architecture. By default, Branch Likely
27367instructions may be generated if they are supported by the selected
27368architecture. An exception is for the MIPS32 and MIPS64 architectures
27369and processors that implement those architectures; for those, Branch
27370Likely instructions are not be generated by default because the MIPS32
27371and MIPS64 architectures specifically deprecate their use.
27372
27373@item -mcompact-branches=never
27374@itemx -mcompact-branches=optimal
27375@itemx -mcompact-branches=always
27376@opindex mcompact-branches=never
27377@opindex mcompact-branches=optimal
27378@opindex mcompact-branches=always
27379These options control which form of branches will be generated. The
27380default is @option{-mcompact-branches=optimal}.
27381
27382The @option{-mcompact-branches=never} option ensures that compact branch
27383instructions will never be generated.
27384
27385The @option{-mcompact-branches=always} option ensures that a compact
27386branch instruction will be generated if available for MIPS Release 6 onwards.
27387If a compact branch instruction is not available (or pre-R6),
27388a delay slot form of the branch will be used instead.
27389
27390If it is used for MIPS16/microMIPS targets, it will be just ignored now.
27391The behaviour for MIPS16/microMIPS may change in future,
27392since they do have some compact branch instructions.
27393
27394The @option{-mcompact-branches=optimal} option will cause a delay slot
27395branch to be used if one is available in the current ISA and the delay
27396slot is successfully filled. If the delay slot is not filled, a compact
27397branch will be chosen if one is available.
27398
27399@item -mfp-exceptions
27400@itemx -mno-fp-exceptions
27401@opindex mfp-exceptions
27402Specifies whether FP exceptions are enabled. This affects how
27403FP instructions are scheduled for some processors.
27404The default is that FP exceptions are
27405enabled.
27406
27407For instance, on the SB-1, if FP exceptions are disabled, and we are emitting
2740864-bit code, then we can use both FP pipes. Otherwise, we can only use one
27409FP pipe.
27410
27411@item -mvr4130-align
27412@itemx -mno-vr4130-align
27413@opindex mvr4130-align
27414The VR4130 pipeline is two-way superscalar, but can only issue two
27415instructions together if the first one is 8-byte aligned. When this
27416option is enabled, GCC aligns pairs of instructions that it
27417thinks should execute in parallel.
27418
27419This option only has an effect when optimizing for the VR4130.
27420It normally makes code faster, but at the expense of making it bigger.
27421It is enabled by default at optimization level @option{-O3}.
27422
27423@item -msynci
27424@itemx -mno-synci
27425@opindex msynci
27426Enable (disable) generation of @code{synci} instructions on
27427architectures that support it. The @code{synci} instructions (if
27428enabled) are generated when @code{__builtin___clear_cache} is
27429compiled.
27430
27431This option defaults to @option{-mno-synci}, but the default can be
27432overridden by configuring GCC with @option{--with-synci}.
27433
27434When compiling code for single processor systems, it is generally safe
27435to use @code{synci}. However, on many multi-core (SMP) systems, it
27436does not invalidate the instruction caches on all cores and may lead
27437to undefined behavior.
27438
27439@item -mrelax-pic-calls
27440@itemx -mno-relax-pic-calls
27441@opindex mrelax-pic-calls
27442Try to turn PIC calls that are normally dispatched via register
27443@code{$25} into direct calls. This is only possible if the linker can
27444resolve the destination at link time and if the destination is within
27445range for a direct call.
27446
27447@option{-mrelax-pic-calls} is the default if GCC was configured to use
27448an assembler and a linker that support the @code{.reloc} assembly
27449directive and @option{-mexplicit-relocs} is in effect. With
27450@option{-mno-explicit-relocs}, this optimization can be performed by the
27451assembler and the linker alone without help from the compiler.
27452
27453@item -mmcount-ra-address
27454@itemx -mno-mcount-ra-address
27455@opindex mmcount-ra-address
27456@opindex mno-mcount-ra-address
27457Emit (do not emit) code that allows @code{_mcount} to modify the
27458calling function's return address. When enabled, this option extends
27459the usual @code{_mcount} interface with a new @var{ra-address}
27460parameter, which has type @code{intptr_t *} and is passed in register
27461@code{$12}. @code{_mcount} can then modify the return address by
27462doing both of the following:
27463@itemize
27464@item
27465Returning the new address in register @code{$31}.
27466@item
27467Storing the new address in @code{*@var{ra-address}},
27468if @var{ra-address} is nonnull.
27469@end itemize
27470
27471The default is @option{-mno-mcount-ra-address}.
27472
27473@item -mframe-header-opt
27474@itemx -mno-frame-header-opt
27475@opindex mframe-header-opt
27476Enable (disable) frame header optimization in the o32 ABI. When using the
27477o32 ABI, calling functions will allocate 16 bytes on the stack for the called
27478function to write out register arguments. When enabled, this optimization
27479will suppress the allocation of the frame header if it can be determined that
27480it is unused.
27481
27482This optimization is off by default at all optimization levels.
27483
27484@item -mlxc1-sxc1
27485@itemx -mno-lxc1-sxc1
27486@opindex mlxc1-sxc1
27487When applicable, enable (disable) the generation of @code{lwxc1},
27488@code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default.
27489
27490@item -mmadd4
27491@itemx -mno-madd4
27492@opindex mmadd4
27493When applicable, enable (disable) the generation of 4-operand @code{madd.s},
27494@code{madd.d} and related instructions. Enabled by default.
27495
27496@end table
27497
27498@node MMIX Options
27499@subsection MMIX Options
27500@cindex MMIX Options
27501
27502These options are defined for the MMIX:
27503
27504@table @gcctabopt
27505@item -mlibfuncs
27506@itemx -mno-libfuncs
27507@opindex mlibfuncs
27508@opindex mno-libfuncs
27509Specify that intrinsic library functions are being compiled, passing all
27510values in registers, no matter the size.
27511
27512@item -mepsilon
27513@itemx -mno-epsilon
27514@opindex mepsilon
27515@opindex mno-epsilon
27516Generate floating-point comparison instructions that compare with respect
27517to the @code{rE} epsilon register.
27518
27519@item -mabi=mmixware
27520@itemx -mabi=gnu
27521@opindex mabi=mmixware
27522@opindex mabi=gnu
27523Generate code that passes function parameters and return values that (in
27524the called function) are seen as registers @code{$0} and up, as opposed to
27525the GNU ABI which uses global registers @code{$231} and up.
27526
27527@item -mzero-extend
27528@itemx -mno-zero-extend
27529@opindex mzero-extend
27530@opindex mno-zero-extend
27531When reading data from memory in sizes shorter than 64 bits, use (do not
27532use) zero-extending load instructions by default, rather than
27533sign-extending ones.
27534
27535@item -mknuthdiv
27536@itemx -mno-knuthdiv
27537@opindex mknuthdiv
27538@opindex mno-knuthdiv
27539Make the result of a division yielding a remainder have the same sign as
27540the divisor. With the default, @option{-mno-knuthdiv}, the sign of the
27541remainder follows the sign of the dividend. Both methods are
27542arithmetically valid, the latter being almost exclusively used.
27543
27544@item -mtoplevel-symbols
27545@itemx -mno-toplevel-symbols
27546@opindex mtoplevel-symbols
27547@opindex mno-toplevel-symbols
27548Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly
27549code can be used with the @code{PREFIX} assembly directive.
27550
27551@item -melf
27552@opindex melf
27553Generate an executable in the ELF format, rather than the default
27554@samp{mmo} format used by the @command{mmix} simulator.
27555
27556@item -mbranch-predict
27557@itemx -mno-branch-predict
27558@opindex mbranch-predict
27559@opindex mno-branch-predict
27560Use (do not use) the probable-branch instructions, when static branch
27561prediction indicates a probable branch.
27562
27563@item -mbase-addresses
27564@itemx -mno-base-addresses
27565@opindex mbase-addresses
27566@opindex mno-base-addresses
27567Generate (do not generate) code that uses @emph{base addresses}. Using a
27568base address automatically generates a request (handled by the assembler
27569and the linker) for a constant to be set up in a global register. The
27570register is used for one or more base address requests within the range 0
27571to 255 from the value held in the register. The generally leads to short
27572and fast code, but the number of different data items that can be
27573addressed is limited. This means that a program that uses lots of static
27574data may require @option{-mno-base-addresses}.
27575
27576@item -msingle-exit
27577@itemx -mno-single-exit
27578@opindex msingle-exit
27579@opindex mno-single-exit
27580Force (do not force) generated code to have a single exit point in each
27581function.
27582@end table
27583
27584@node MN10300 Options
27585@subsection MN10300 Options
27586@cindex MN10300 options
27587
27588These @option{-m} options are defined for Matsushita MN10300 architectures:
27589
27590@table @gcctabopt
27591@item -mmult-bug
27592@opindex mmult-bug
27593Generate code to avoid bugs in the multiply instructions for the MN10300
27594processors. This is the default.
27595
27596@item -mno-mult-bug
27597@opindex mno-mult-bug
27598Do not generate code to avoid bugs in the multiply instructions for the
27599MN10300 processors.
27600
27601@item -mam33
27602@opindex mam33
27603Generate code using features specific to the AM33 processor.
27604
27605@item -mno-am33
27606@opindex mno-am33
27607Do not generate code using features specific to the AM33 processor. This
27608is the default.
27609
27610@item -mam33-2
27611@opindex mam33-2
27612Generate code using features specific to the AM33/2.0 processor.
27613
27614@item -mam34
27615@opindex mam34
27616Generate code using features specific to the AM34 processor.
27617
27618@item -mtune=@var{cpu-type}
27619@opindex mtune
27620Use the timing characteristics of the indicated CPU type when
27621scheduling instructions. This does not change the targeted processor
27622type. The CPU type must be one of @samp{mn10300}, @samp{am33},
27623@samp{am33-2} or @samp{am34}.
27624
27625@item -mreturn-pointer-on-d0
27626@opindex mreturn-pointer-on-d0
27627When generating a function that returns a pointer, return the pointer
27628in both @code{a0} and @code{d0}. Otherwise, the pointer is returned
27629only in @code{a0}, and attempts to call such functions without a prototype
27630result in errors. Note that this option is on by default; use
27631@option{-mno-return-pointer-on-d0} to disable it.
27632
27633@item -mno-crt0
27634@opindex mno-crt0
27635Do not link in the C run-time initialization object file.
27636
27637@item -mrelax
27638@opindex mrelax
27639Indicate to the linker that it should perform a relaxation optimization pass
27640to shorten branches, calls and absolute memory addresses. This option only
27641has an effect when used on the command line for the final link step.
27642
27643This option makes symbolic debugging impossible.
27644
27645@item -mliw
27646@opindex mliw
27647Allow the compiler to generate @emph{Long Instruction Word}
27648instructions if the target is the @samp{AM33} or later. This is the
27649default. This option defines the preprocessor macro @code{__LIW__}.
27650
27651@item -mno-liw
27652@opindex mno-liw
27653Do not allow the compiler to generate @emph{Long Instruction Word}
27654instructions. This option defines the preprocessor macro
27655@code{__NO_LIW__}.
27656
27657@item -msetlb
27658@opindex msetlb
27659Allow the compiler to generate the @emph{SETLB} and @emph{Lcc}
27660instructions if the target is the @samp{AM33} or later. This is the
27661default. This option defines the preprocessor macro @code{__SETLB__}.
27662
27663@item -mno-setlb
27664@opindex mno-setlb
27665Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc}
27666instructions. This option defines the preprocessor macro
27667@code{__NO_SETLB__}.
27668
27669@end table
27670
27671@node Moxie Options
27672@subsection Moxie Options
27673@cindex Moxie Options
27674
27675@table @gcctabopt
27676
27677@item -meb
27678@opindex meb
27679Generate big-endian code. This is the default for @samp{moxie-*-*}
27680configurations.
27681
27682@item -mel
27683@opindex mel
27684Generate little-endian code.
27685
27686@item -mmul.x
27687@opindex mmul.x
27688Generate mul.x and umul.x instructions. This is the default for
27689@samp{moxiebox-*-*} configurations.
27690
27691@item -mno-crt0
27692@opindex mno-crt0
27693Do not link in the C run-time initialization object file.
27694
27695@end table
27696
27697@node MSP430 Options
27698@subsection MSP430 Options
27699@cindex MSP430 Options
27700
27701These options are defined for the MSP430:
27702
27703@table @gcctabopt
27704
27705@item -masm-hex
27706@opindex masm-hex
27707Force assembly output to always use hex constants. Normally such
27708constants are signed decimals, but this option is available for
27709testsuite and/or aesthetic purposes.
27710
27711@item -mmcu=
27712@opindex mmcu=
27713Select the MCU to target. This is used to create a C preprocessor
27714symbol based upon the MCU name, converted to upper case and pre- and
27715post-fixed with @samp{__}. This in turn is used by the
27716@file{msp430.h} header file to select an MCU-specific supplementary
27717header file.
27718
27719The option also sets the ISA to use. If the MCU name is one that is
27720known to only support the 430 ISA then that is selected, otherwise the
27721430X ISA is selected. A generic MCU name of @samp{msp430} can also be
27722used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU
27723name selects the 430X ISA.
27724
27725In addition an MCU-specific linker script is added to the linker
27726command line. The script's name is the name of the MCU with
27727@file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc}
27728command line defines the C preprocessor symbol @code{__XXX__} and
27729cause the linker to search for a script called @file{xxx.ld}.
27730
27731The ISA and hardware multiply supported for the different MCUs is hard-coded
27732into GCC. However, an external @samp{devices.csv} file can be used to
27733extend device support beyond those that have been hard-coded.
27734
27735GCC searches for the @samp{devices.csv} file using the following methods in the
27736given precedence order, where the first method takes precendence over the
27737second which takes precedence over the third.
27738
27739@table @asis
27740@item Include path specified with @code{-I} and @code{-L}
27741@samp{devices.csv} will be searched for in each of the directories specified by
27742include paths and linker library search paths.
27743@item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR}
27744Define the value of the global environment variable
27745@samp{MSP430_GCC_INCLUDE_DIR}
27746to the full path to the directory containing devices.csv, and GCC will search
27747this directory for devices.csv. If devices.csv is found, this directory will
27748also be registered as an include path, and linker library path. Header files
27749and linker scripts in this directory can therefore be used without manually
27750specifying @code{-I} and @code{-L} on the command line.
27751@item The @samp{msp430-elf@{,bare@}/include/devices} directory
27752Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
27753toolchain root directory. This directory does not exist in a default
27754installation, but if the user has created it and copied @samp{devices.csv}
27755there, then the MCU data will be read. As above, this directory will
27756also be registered as an include path, and linker library path.
27757
27758@end table
27759If none of the above search methods find @samp{devices.csv}, then the
27760hard-coded MCU data is used.
27761
27762
27763@item -mwarn-mcu
27764@itemx -mno-warn-mcu
27765@opindex mwarn-mcu
27766@opindex mno-warn-mcu
27767This option enables or disables warnings about conflicts between the
27768MCU name specified by the @option{-mmcu} option and the ISA set by the
27769@option{-mcpu} option and/or the hardware multiply support set by the
27770@option{-mhwmult} option. It also toggles warnings about unrecognized
27771MCU names. This option is on by default.
27772
27773@item -mcpu=
27774@opindex mcpu=
27775Specifies the ISA to use. Accepted values are @samp{msp430},
27776@samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The
27777@option{-mmcu=} option should be used to select the ISA.
27778
27779@item -msim
27780@opindex msim
27781Link to the simulator runtime libraries and linker script. Overrides
27782any scripts that would be selected by the @option{-mmcu=} option.
27783
27784@item -mlarge
27785@opindex mlarge
27786Use large-model addressing (20-bit pointers, 20-bit @code{size_t}).
27787
27788@item -msmall
27789@opindex msmall
27790Use small-model addressing (16-bit pointers, 16-bit @code{size_t}).
27791
27792@item -mrelax
27793@opindex mrelax
27794This option is passed to the assembler and linker, and allows the
27795linker to perform certain optimizations that cannot be done until
27796the final link.
27797
27798@item mhwmult=
27799@opindex mhwmult=
27800Describes the type of hardware multiply supported by the target.
27801Accepted values are @samp{none} for no hardware multiply, @samp{16bit}
27802for the original 16-bit-only multiply supported by early MCUs.
27803@samp{32bit} for the 16/32-bit multiply supported by later MCUs and
27804@samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs.
27805A value of @samp{auto} can also be given. This tells GCC to deduce
27806the hardware multiply support based upon the MCU name provided by the
27807@option{-mmcu} option. If no @option{-mmcu} option is specified or if
27808the MCU name is not recognized then no hardware multiply support is
27809assumed. @code{auto} is the default setting.
27810
27811Hardware multiplies are normally performed by calling a library
27812routine. This saves space in the generated code. When compiling at
27813@option{-O3} or higher however the hardware multiplier is invoked
27814inline. This makes for bigger, but faster code.
27815
27816The hardware multiply routines disable interrupts whilst running and
27817restore the previous interrupt state when they finish. This makes
27818them safe to use inside interrupt handlers as well as in normal code.
27819
27820@item -minrt
27821@opindex minrt
27822Enable the use of a minimum runtime environment - no static
27823initializers or constructors. This is intended for memory-constrained
27824devices. The compiler includes special symbols in some objects
27825that tell the linker and runtime which code fragments are required.
27826
27827@item -mtiny-printf
27828@opindex mtiny-printf
27829Enable reduced code size @code{printf} and @code{puts} library functions.
27830The @samp{tiny} implementations of these functions are not reentrant, so
27831must be used with caution in multi-threaded applications.
27832
27833Support for streams has been removed and the string to be printed will
27834always be sent to stdout via the @code{write} syscall. The string is not
27835buffered before it is sent to write.
27836
27837This option requires Newlib Nano IO, so GCC must be configured with
27838@samp{--enable-newlib-nano-formatted-io}.
27839
27840@item -mmax-inline-shift=
27841@opindex mmax-inline-shift=
27842This option takes an integer between 0 and 64 inclusive, and sets
27843the maximum number of inline shift instructions which should be emitted to
27844perform a shift operation by a constant amount. When this value needs to be
27845exceeded, an mspabi helper function is used instead. The default value is 4.
27846
27847This only affects cases where a shift by multiple positions cannot be
27848completed with a single instruction (e.g. all shifts >1 on the 430 ISA).
27849
27850Shifts of a 32-bit value are at least twice as costly, so the value passed for
27851this option is divided by 2 and the resulting value used instead.
27852
27853@item -mcode-region=
27854@itemx -mdata-region=
27855@opindex mcode-region
27856@opindex mdata-region
27857These options tell the compiler where to place functions and data that
27858do not have one of the @code{lower}, @code{upper}, @code{either} or
27859@code{section} attributes. Possible values are @code{lower},
27860@code{upper}, @code{either} or @code{any}. The first three behave
27861like the corresponding attribute. The fourth possible value -
27862@code{any} - is the default. It leaves placement entirely up to the
27863linker script and how it assigns the standard sections
27864(@code{.text}, @code{.data}, etc) to the memory regions.
27865
27866@item -msilicon-errata=
27867@opindex msilicon-errata
27868This option passes on a request to assembler to enable the fixes for
27869the named silicon errata.
27870
27871@item -msilicon-errata-warn=
27872@opindex msilicon-errata-warn
27873This option passes on a request to the assembler to enable warning
27874messages when a silicon errata might need to be applied.
27875
27876@item -mwarn-devices-csv
27877@itemx -mno-warn-devices-csv
27878@opindex mwarn-devices-csv
27879@opindex mno-warn-devices-csv
27880Warn if @samp{devices.csv} is not found or there are problem parsing it
27881(default: on).
27882
27883@end table
27884
27885@node NDS32 Options
27886@subsection NDS32 Options
27887@cindex NDS32 Options
27888
27889These options are defined for NDS32 implementations:
27890
27891@table @gcctabopt
27892
27893@item -mbig-endian
27894@opindex mbig-endian
27895Generate code in big-endian mode.
27896
27897@item -mlittle-endian
27898@opindex mlittle-endian
27899Generate code in little-endian mode.
27900
27901@item -mreduced-regs
27902@opindex mreduced-regs
27903Use reduced-set registers for register allocation.
27904
27905@item -mfull-regs
27906@opindex mfull-regs
27907Use full-set registers for register allocation.
27908
27909@item -mcmov
27910@opindex mcmov
27911Generate conditional move instructions.
27912
27913@item -mno-cmov
27914@opindex mno-cmov
27915Do not generate conditional move instructions.
27916
27917@item -mext-perf
27918@opindex mext-perf
27919Generate performance extension instructions.
27920
27921@item -mno-ext-perf
27922@opindex mno-ext-perf
27923Do not generate performance extension instructions.
27924
27925@item -mext-perf2
27926@opindex mext-perf2
27927Generate performance extension 2 instructions.
27928
27929@item -mno-ext-perf2
27930@opindex mno-ext-perf2
27931Do not generate performance extension 2 instructions.
27932
27933@item -mext-string
27934@opindex mext-string
27935Generate string extension instructions.
27936
27937@item -mno-ext-string
27938@opindex mno-ext-string
27939Do not generate string extension instructions.
27940
27941@item -mv3push
27942@opindex mv3push
27943Generate v3 push25/pop25 instructions.
27944
27945@item -mno-v3push
27946@opindex mno-v3push
27947Do not generate v3 push25/pop25 instructions.
27948
27949@item -m16-bit
27950@opindex m16-bit
27951Generate 16-bit instructions.
27952
27953@item -mno-16-bit
27954@opindex mno-16-bit
27955Do not generate 16-bit instructions.
27956
27957@item -misr-vector-size=@var{num}
27958@opindex misr-vector-size
27959Specify the size of each interrupt vector, which must be 4 or 16.
27960
27961@item -mcache-block-size=@var{num}
27962@opindex mcache-block-size
27963Specify the size of each cache block,
27964which must be a power of 2 between 4 and 512.
27965
27966@item -march=@var{arch}
27967@opindex march
27968Specify the name of the target architecture.
27969
27970@item -mcmodel=@var{code-model}
27971@opindex mcmodel
27972Set the code model to one of
27973@table @asis
27974@item @samp{small}
27975All the data and read-only data segments must be within 512KB addressing space.
27976The text segment must be within 16MB addressing space.
27977@item @samp{medium}
27978The data segment must be within 512KB while the read-only data segment can be
27979within 4GB addressing space. The text segment should be still within 16MB
27980addressing space.
27981@item @samp{large}
27982All the text and data segments can be within 4GB addressing space.
27983@end table
27984
27985@item -mctor-dtor
27986@opindex mctor-dtor
27987Enable constructor/destructor feature.
27988
27989@item -mrelax
27990@opindex mrelax
27991Guide linker to relax instructions.
27992
27993@end table
27994
27995@node Nios II Options
27996@subsection Nios II Options
27997@cindex Nios II options
27998@cindex Altera Nios II options
27999
28000These are the options defined for the Altera Nios II processor.
28001
28002@table @gcctabopt
28003
28004@item -G @var{num}
28005@opindex G
28006@cindex smaller data references
28007Put global and static objects less than or equal to @var{num} bytes
28008into the small data or BSS sections instead of the normal data or BSS
28009sections. The default value of @var{num} is 8.
28010
28011@item -mgpopt=@var{option}
28012@itemx -mgpopt
28013@itemx -mno-gpopt
28014@opindex mgpopt
28015@opindex mno-gpopt
28016Generate (do not generate) GP-relative accesses. The following
28017@var{option} names are recognized:
28018
28019@table @samp
28020
28021@item none
28022Do not generate GP-relative accesses.
28023
28024@item local
28025Generate GP-relative accesses for small data objects that are not
28026external, weak, or uninitialized common symbols.
28027Also use GP-relative addressing for objects that
28028have been explicitly placed in a small data section via a @code{section}
28029attribute.
28030
28031@item global
28032As for @samp{local}, but also generate GP-relative accesses for
28033small data objects that are external, weak, or common. If you use this option,
28034you must ensure that all parts of your program (including libraries) are
28035compiled with the same @option{-G} setting.
28036
28037@item data
28038Generate GP-relative accesses for all data objects in the program. If you
28039use this option, the entire data and BSS segments
28040of your program must fit in 64K of memory and you must use an appropriate
28041linker script to allocate them within the addressable range of the
28042global pointer.
28043
28044@item all
28045Generate GP-relative addresses for function pointers as well as data
28046pointers. If you use this option, the entire text, data, and BSS segments
28047of your program must fit in 64K of memory and you must use an appropriate
28048linker script to allocate them within the addressable range of the
28049global pointer.
28050
28051@end table
28052
28053@option{-mgpopt} is equivalent to @option{-mgpopt=local}, and
28054@option{-mno-gpopt} is equivalent to @option{-mgpopt=none}.
28055
28056The default is @option{-mgpopt} except when @option{-fpic} or
28057@option{-fPIC} is specified to generate position-independent code.
28058Note that the Nios II ABI does not permit GP-relative accesses from
28059shared libraries.
28060
28061You may need to specify @option{-mno-gpopt} explicitly when building
28062programs that include large amounts of small data, including large
28063GOT data sections. In this case, the 16-bit offset for GP-relative
28064addressing may not be large enough to allow access to the entire
28065small data section.
28066
28067@item -mgprel-sec=@var{regexp}
28068@opindex mgprel-sec
28069This option specifies additional section names that can be accessed via
28070GP-relative addressing. It is most useful in conjunction with
28071@code{section} attributes on variable declarations
28072(@pxref{Common Variable Attributes}) and a custom linker script.
28073The @var{regexp} is a POSIX Extended Regular Expression.
28074
28075This option does not affect the behavior of the @option{-G} option, and
28076the specified sections are in addition to the standard @code{.sdata}
28077and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}.
28078
28079@item -mr0rel-sec=@var{regexp}
28080@opindex mr0rel-sec
28081This option specifies names of sections that can be accessed via a
2808216-bit offset from @code{r0}; that is, in the low 32K or high 32K
28083of the 32-bit address space. It is most useful in conjunction with
28084@code{section} attributes on variable declarations
28085(@pxref{Common Variable Attributes}) and a custom linker script.
28086The @var{regexp} is a POSIX Extended Regular Expression.
28087
28088In contrast to the use of GP-relative addressing for small data,
28089zero-based addressing is never generated by default and there are no
28090conventional section names used in standard linker scripts for sections
28091in the low or high areas of memory.
28092
28093@item -mel
28094@itemx -meb
28095@opindex mel
28096@opindex meb
28097Generate little-endian (default) or big-endian (experimental) code,
28098respectively.
28099
28100@item -march=@var{arch}
28101@opindex march
28102This specifies the name of the target Nios II architecture. GCC uses this
28103name to determine what kind of instructions it can emit when generating
28104assembly code. Permissible names are: @samp{r1}, @samp{r2}.
28105
28106The preprocessor macro @code{__nios2_arch__} is available to programs,
28107with value 1 or 2, indicating the targeted ISA level.
28108
28109@item -mbypass-cache
28110@itemx -mno-bypass-cache
28111@opindex mno-bypass-cache
28112@opindex mbypass-cache
28113Force all load and store instructions to always bypass cache by
28114using I/O variants of the instructions. The default is not to
28115bypass the cache.
28116
28117@item -mno-cache-volatile
28118@itemx -mcache-volatile
28119@opindex mcache-volatile
28120@opindex mno-cache-volatile
28121Volatile memory access bypass the cache using the I/O variants of
28122the load and store instructions. The default is not to bypass the cache.
28123
28124@item -mno-fast-sw-div
28125@itemx -mfast-sw-div
28126@opindex mno-fast-sw-div
28127@opindex mfast-sw-div
28128Do not use table-based fast divide for small numbers. The default
28129is to use the fast divide at @option{-O3} and above.
28130
28131@item -mno-hw-mul
28132@itemx -mhw-mul
28133@itemx -mno-hw-mulx
28134@itemx -mhw-mulx
28135@itemx -mno-hw-div
28136@itemx -mhw-div
28137@opindex mno-hw-mul
28138@opindex mhw-mul
28139@opindex mno-hw-mulx
28140@opindex mhw-mulx
28141@opindex mno-hw-div
28142@opindex mhw-div
28143Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of
28144instructions by the compiler. The default is to emit @code{mul}
28145and not emit @code{div} and @code{mulx}.
28146
28147@item -mbmx
28148@itemx -mno-bmx
28149@itemx -mcdx
28150@itemx -mno-cdx
28151Enable or disable generation of Nios II R2 BMX (bit manipulation) and
28152CDX (code density) instructions. Enabling these instructions also
28153requires @option{-march=r2}. Since these instructions are optional
28154extensions to the R2 architecture, the default is not to emit them.
28155
28156@item -mcustom-@var{insn}=@var{N}
28157@itemx -mno-custom-@var{insn}
28158@opindex mcustom-@var{insn}
28159@opindex mno-custom-@var{insn}
28160Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a
28161custom instruction with encoding @var{N} when generating code that uses
28162@var{insn}. For example, @option{-mcustom-fadds=253} generates custom
28163instruction 253 for single-precision floating-point add operations instead
28164of the default behavior of using a library call.
28165
28166The following values of @var{insn} are supported. Except as otherwise
28167noted, floating-point operations are expected to be implemented with
28168normal IEEE 754 semantics and correspond directly to the C operators or the
28169equivalent GCC built-in functions (@pxref{Other Builtins}).
28170
28171Single-precision floating point:
28172@table @asis
28173
28174@item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls}
28175Binary arithmetic operations.
28176
28177@item @samp{fnegs}
28178Unary negation.
28179
28180@item @samp{fabss}
28181Unary absolute value.
28182
28183@item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes}
28184Comparison operations.
28185
28186@item @samp{fmins}, @samp{fmaxs}
28187Floating-point minimum and maximum. These instructions are only
28188generated if @option{-ffinite-math-only} is specified.
28189
28190@item @samp{fsqrts}
28191Unary square root operation.
28192
28193@item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs}
28194Floating-point trigonometric and exponential functions. These instructions
28195are only generated if @option{-funsafe-math-optimizations} is also specified.
28196
28197@end table
28198
28199Double-precision floating point:
28200@table @asis
28201
28202@item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld}
28203Binary arithmetic operations.
28204
28205@item @samp{fnegd}
28206Unary negation.
28207
28208@item @samp{fabsd}
28209Unary absolute value.
28210
28211@item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned}
28212Comparison operations.
28213
28214@item @samp{fmind}, @samp{fmaxd}
28215Double-precision minimum and maximum. These instructions are only
28216generated if @option{-ffinite-math-only} is specified.
28217
28218@item @samp{fsqrtd}
28219Unary square root operation.
28220
28221@item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd}
28222Double-precision trigonometric and exponential functions. These instructions
28223are only generated if @option{-funsafe-math-optimizations} is also specified.
28224
28225@end table
28226
28227Conversions:
28228@table @asis
28229@item @samp{fextsd}
28230Conversion from single precision to double precision.
28231
28232@item @samp{ftruncds}
28233Conversion from double precision to single precision.
28234
28235@item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu}
28236Conversion from floating point to signed or unsigned integer types, with
28237truncation towards zero.
28238
28239@item @samp{round}
28240Conversion from single-precision floating point to signed integer,
28241rounding to the nearest integer and ties away from zero.
28242This corresponds to the @code{__builtin_lroundf} function when
28243@option{-fno-math-errno} is used.
28244
28245@item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud}
28246Conversion from signed or unsigned integer types to floating-point types.
28247
28248@end table
28249
28250In addition, all of the following transfer instructions for internal
28251registers X and Y must be provided to use any of the double-precision
28252floating-point instructions. Custom instructions taking two
28253double-precision source operands expect the first operand in the
2825464-bit register X. The other operand (or only operand of a unary
28255operation) is given to the custom arithmetic instruction with the
28256least significant half in source register @var{src1} and the most
28257significant half in @var{src2}. A custom instruction that returns a
28258double-precision result returns the most significant 32 bits in the
28259destination register and the other half in 32-bit register Y.
28260GCC automatically generates the necessary code sequences to write
28261register X and/or read register Y when double-precision floating-point
28262instructions are used.
28263
28264@table @asis
28265
28266@item @samp{fwrx}
28267Write @var{src1} into the least significant half of X and @var{src2} into
28268the most significant half of X.
28269
28270@item @samp{fwry}
28271Write @var{src1} into Y.
28272
28273@item @samp{frdxhi}, @samp{frdxlo}
28274Read the most or least (respectively) significant half of X and store it in
28275@var{dest}.
28276
28277@item @samp{frdy}
28278Read the value of Y and store it into @var{dest}.
28279@end table
28280
28281Note that you can gain more local control over generation of Nios II custom
28282instructions by using the @code{target("custom-@var{insn}=@var{N}")}
28283and @code{target("no-custom-@var{insn}")} function attributes
28284(@pxref{Function Attributes})
28285or pragmas (@pxref{Function Specific Option Pragmas}).
28286
28287@item -mcustom-fpu-cfg=@var{name}
28288@opindex mcustom-fpu-cfg
28289
28290This option enables a predefined, named set of custom instruction encodings
28291(see @option{-mcustom-@var{insn}} above).
28292Currently, the following sets are defined:
28293
28294@option{-mcustom-fpu-cfg=60-1} is equivalent to:
28295@gccoptlist{-mcustom-fmuls=252 @gol
28296-mcustom-fadds=253 @gol
28297-mcustom-fsubs=254 @gol
28298-fsingle-precision-constant}
28299
28300@option{-mcustom-fpu-cfg=60-2} is equivalent to:
28301@gccoptlist{-mcustom-fmuls=252 @gol
28302-mcustom-fadds=253 @gol
28303-mcustom-fsubs=254 @gol
28304-mcustom-fdivs=255 @gol
28305-fsingle-precision-constant}
28306
28307@option{-mcustom-fpu-cfg=72-3} is equivalent to:
28308@gccoptlist{-mcustom-floatus=243 @gol
28309-mcustom-fixsi=244 @gol
28310-mcustom-floatis=245 @gol
28311-mcustom-fcmpgts=246 @gol
28312-mcustom-fcmples=249 @gol
28313-mcustom-fcmpeqs=250 @gol
28314-mcustom-fcmpnes=251 @gol
28315-mcustom-fmuls=252 @gol
28316-mcustom-fadds=253 @gol
28317-mcustom-fsubs=254 @gol
28318-mcustom-fdivs=255 @gol
28319-fsingle-precision-constant}
28320
28321@option{-mcustom-fpu-cfg=fph2} is equivalent to:
28322@gccoptlist{-mcustom-fabss=224 @gol
28323-mcustom-fnegs=225 @gol
28324-mcustom-fcmpnes=226 @gol
28325-mcustom-fcmpeqs=227 @gol
28326-mcustom-fcmpges=228 @gol
28327-mcustom-fcmpgts=229 @gol
28328-mcustom-fcmples=230 @gol
28329-mcustom-fcmplts=231 @gol
28330-mcustom-fmaxs=232 @gol
28331-mcustom-fmins=233 @gol
28332-mcustom-round=248 @gol
28333-mcustom-fixsi=249 @gol
28334-mcustom-floatis=250 @gol
28335-mcustom-fsqrts=251 @gol
28336-mcustom-fmuls=252 @gol
28337-mcustom-fadds=253 @gol
28338-mcustom-fsubs=254 @gol
28339-mcustom-fdivs=255 @gol}
28340
28341Custom instruction assignments given by individual
28342@option{-mcustom-@var{insn}=} options override those given by
28343@option{-mcustom-fpu-cfg=}, regardless of the
28344order of the options on the command line.
28345
28346Note that you can gain more local control over selection of a FPU
28347configuration by using the @code{target("custom-fpu-cfg=@var{name}")}
28348function attribute (@pxref{Function Attributes})
28349or pragma (@pxref{Function Specific Option Pragmas}).
28350
28351The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point
28352Hardware 2 Component}. Please note that the custom instructions enabled by
28353@option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated
28354if @option{-ffinite-math-only} is specified. The custom instruction enabled by
28355@option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is
28356specified. In contrast to the other configurations,
28357@option{-fsingle-precision-constant} is not set.
28358
28359@end table
28360
28361These additional @samp{-m} options are available for the Altera Nios II
28362ELF (bare-metal) target:
28363
28364@table @gcctabopt
28365
28366@item -mhal
28367@opindex mhal
28368Link with HAL BSP. This suppresses linking with the GCC-provided C runtime
28369startup and termination code, and is typically used in conjunction with
28370@option{-msys-crt0=} to specify the location of the alternate startup code
28371provided by the HAL BSP.
28372
28373@item -msmallc
28374@opindex msmallc
28375Link with a limited version of the C library, @option{-lsmallc}, rather than
28376Newlib.
28377
28378@item -msys-crt0=@var{startfile}
28379@opindex msys-crt0
28380@var{startfile} is the file name of the startfile (crt0) to use
28381when linking. This option is only useful in conjunction with @option{-mhal}.
28382
28383@item -msys-lib=@var{systemlib}
28384@opindex msys-lib
28385@var{systemlib} is the library name of the library that provides
28386low-level system calls required by the C library,
28387e.g.@: @code{read} and @code{write}.
28388This option is typically used to link with a library provided by a HAL BSP.
28389
28390@end table
28391
28392@node Nvidia PTX Options
28393@subsection Nvidia PTX Options
28394@cindex Nvidia PTX options
28395@cindex nvptx options
28396
28397These options are defined for Nvidia PTX:
28398
28399@table @gcctabopt
28400
28401@item -m64
28402@opindex m64
28403Ignored, but preserved for backward compatibility. Only 64-bit ABI is
28404supported.
28405
28406@item -march=@var{architecture-string}
28407@opindex march
28408Generate code for the specified PTX ISA target architecture
28409(e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30},
28410@samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and
28411@samp{sm_80}.
28412The default depends on how the compiler has been configured, see
28413@option{--with-arch}.
28414
28415This option sets the value of the preprocessor macro
28416@code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value
28417@samp{350}.
28418
28419@item -misa=@var{architecture-string}
28420@opindex misa
28421Alias of @option{-march=}.
28422
28423@item -march-map=@var{architecture-string}
28424@opindex march
28425Select the closest available @option{-march=} value that is not more
28426capable. For instance, for @option{-march-map=sm_50} select
28427@option{-march=sm_35}, and for @option{-march-map=sm_53} select
28428@option{-march=sm_53}.
28429
28430@item -mptx=@var{version-string}
28431@opindex mptx
28432Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}).
28433Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and
28434@samp{7.0}. The default PTX ISA version is 6.0, unless a higher
28435version is required for specified PTX ISA target architecture via
28436option @option{-march=}.
28437
28438This option sets the values of the preprocessor macros
28439@code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__};
28440for instance, for @samp{3.1} the macros have the values @samp{3} and
28441@samp{1}, respectively.
28442
28443@item -mmainkernel
28444@opindex mmainkernel
28445Link in code for a __main kernel. This is for stand-alone instead of
28446offloading execution.
28447
28448@item -moptimize
28449@opindex moptimize
28450Apply partitioned execution optimizations. This is the default when any
28451level of optimization is selected.
28452
28453@item -msoft-stack
28454@opindex msoft-stack
28455Generate code that does not use @code{.local} memory
28456directly for stack storage. Instead, a per-warp stack pointer is
28457maintained explicitly. This enables variable-length stack allocation (with
28458variable-length arrays or @code{alloca}), and when global memory is used for
28459underlying storage, makes it possible to access automatic variables from other
28460threads, or with atomic instructions. This code generation variant is used
28461for OpenMP offloading, but the option is exposed on its own for the purpose
28462of testing the compiler; to generate code suitable for linking into programs
28463using OpenMP offloading, use option @option{-mgomp}.
28464
28465@item -muniform-simt
28466@opindex muniform-simt
28467Switch to code generation variant that allows to execute all threads in each
28468warp, while maintaining memory state and side effects as if only one thread
28469in each warp was active outside of OpenMP SIMD regions. All atomic operations
28470and calls to runtime (malloc, free, vprintf) are conditionally executed (iff
28471current lane index equals the master lane index), and the register being
28472assigned is copied via a shuffle instruction from the master lane. Outside of
28473SIMD regions lane 0 is the master; inside, each thread sees itself as the
28474master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or
28475all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD
28476regions). Each thread can bitwise-and the bitmask at position @code{tid.y}
28477with current lane index to compute the master lane index.
28478
28479@item -mgomp
28480@opindex mgomp
28481Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and
28482@option{-muniform-simt} options, and selects corresponding multilib variant.
28483
28484@end table
28485
28486@node OpenRISC Options
28487@subsection OpenRISC Options
28488@cindex OpenRISC Options
28489
28490These options are defined for OpenRISC:
28491
28492@table @gcctabopt
28493
28494@item -mboard=@var{name}
28495@opindex mboard
28496Configure a board specific runtime. This will be passed to the linker for
28497newlib board library linking. The default is @code{or1ksim}.
28498
28499@item -mnewlib
28500@opindex mnewlib
28501This option is ignored; it is for compatibility purposes only. This used to
28502select linker and preprocessor options for use with newlib.
28503
28504@item -msoft-div
28505@itemx -mhard-div
28506@opindex msoft-div
28507@opindex mhard-div
28508Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
28509This default is hardware divide.
28510
28511@item -msoft-mul
28512@itemx -mhard-mul
28513@opindex msoft-mul
28514@opindex mhard-mul
28515Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
28516This default is hardware multiply.
28517
28518@item -msoft-float
28519@itemx -mhard-float
28520@opindex msoft-float
28521@opindex mhard-float
28522Select software or hardware for floating point operations.
28523The default is software.
28524
28525@item -mdouble-float
28526@opindex mdouble-float
28527When @option{-mhard-float} is selected, enables generation of double-precision
28528floating point instructions. By default functions from @file{libgcc} are used
28529to perform double-precision floating point operations.
28530
28531@item -munordered-float
28532@opindex munordered-float
28533When @option{-mhard-float} is selected, enables generation of unordered
28534floating point compare and set flag (@code{lf.sfun*}) instructions. By default
28535functions from @file{libgcc} are used to perform unordered floating point
28536compare and set flag operations.
28537
28538@item -mcmov
28539@opindex mcmov
28540Enable generation of conditional move (@code{l.cmov}) instructions. By
28541default the equivalent will be generated using set and branch.
28542
28543@item -mror
28544@opindex mror
28545Enable generation of rotate right (@code{l.ror}) instructions. By default
28546functions from @file{libgcc} are used to perform rotate right operations.
28547
28548@item -mrori
28549@opindex mrori
28550Enable generation of rotate right with immediate (@code{l.rori}) instructions.
28551By default functions from @file{libgcc} are used to perform rotate right with
28552immediate operations.
28553
28554@item -msext
28555@opindex msext
28556Enable generation of sign extension (@code{l.ext*}) instructions. By default
28557memory loads are used to perform sign extension.
28558
28559@item -msfimm
28560@opindex msfimm
28561Enable generation of compare and set flag with immediate (@code{l.sf*i})
28562instructions. By default extra instructions will be generated to store the
28563immediate to a register first.
28564
28565@item -mshftimm
28566@opindex mshftimm
28567Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
28568@code{l.slli}) instructions. By default extra instructions will be generated
28569to store the immediate to a register first.
28570
28571@item -mcmodel=small
28572@opindex mcmodel=small
28573Generate OpenRISC code for the small model: The GOT is limited to 64k. This is
28574the default model.
28575
28576@item -mcmodel=large
28577@opindex mcmodel=large
28578Generate OpenRISC code for the large model: The GOT may grow up to 4G in size.
28579
28580
28581@end table
28582
28583@node PDP-11 Options
28584@subsection PDP-11 Options
28585@cindex PDP-11 Options
28586
28587These options are defined for the PDP-11:
28588
28589@table @gcctabopt
28590@item -mfpu
28591@opindex mfpu
28592Use hardware FPP floating point. This is the default. (FIS floating
28593point on the PDP-11/40 is not supported.) Implies -m45.
28594
28595@item -msoft-float
28596@opindex msoft-float
28597Do not use hardware floating point.
28598
28599@item -mac0
28600@opindex mac0
28601Return floating-point results in ac0 (fr0 in Unix assembler syntax).
28602
28603@item -mno-ac0
28604@opindex mno-ac0
28605Return floating-point results in memory. This is the default.
28606
28607@item -m40
28608@opindex m40
28609Generate code for a PDP-11/40. Implies -msoft-float -mno-split.
28610
28611@item -m45
28612@opindex m45
28613Generate code for a PDP-11/45. This is the default.
28614
28615@item -m10
28616@opindex m10
28617Generate code for a PDP-11/10. Implies -msoft-float -mno-split.
28618
28619@item -mint16
28620@itemx -mno-int32
28621@opindex mint16
28622@opindex mno-int32
28623Use 16-bit @code{int}. This is the default.
28624
28625@item -mint32
28626@itemx -mno-int16
28627@opindex mint32
28628@opindex mno-int16
28629Use 32-bit @code{int}.
28630
28631@item -msplit
28632@opindex msplit
28633Target has split instruction and data space. Implies -m45.
28634
28635@item -munix-asm
28636@opindex munix-asm
28637Use Unix assembler syntax.
28638
28639@item -mdec-asm
28640@opindex mdec-asm
28641Use DEC assembler syntax.
28642
28643@item -mgnu-asm
28644@opindex mgnu-asm
28645Use GNU assembler syntax. This is the default.
28646
28647@item -mlra
28648@opindex mlra
28649Use the new LRA register allocator. By default, the old ``reload''
28650allocator is used.
28651@end table
28652
d77de738
ML
28653@node PowerPC Options
28654@subsection PowerPC Options
28655@cindex PowerPC options
28656
28657These are listed under @xref{RS/6000 and PowerPC Options}.
28658
28659@node PRU Options
28660@subsection PRU Options
28661@cindex PRU Options
28662
28663These command-line options are defined for PRU target:
28664
28665@table @gcctabopt
28666@item -minrt
28667@opindex minrt
28668Link with a minimum runtime environment, with no support for static
28669initializers and constructors. Using this option can significantly reduce
28670the size of the final ELF binary. Beware that the compiler could still
28671generate code with static initializers and constructors. It is up to the
28672programmer to ensure that the source program will not use those features.
28673
28674@item -mmcu=@var{mcu}
28675@opindex mmcu
28676Specify the PRU MCU variant to use. Check Newlib for the exact list of
28677supported MCUs.
28678
28679@item -mno-relax
28680@opindex mno-relax
28681Make GCC pass the @option{--no-relax} command-line option to the linker
28682instead of the @option{--relax} option.
28683
28684@item -mloop
28685@opindex mloop
28686Allow (or do not allow) GCC to use the LOOP instruction.
28687
28688@item -mabi=@var{variant}
28689@opindex mabi
28690Specify the ABI variant to output code for. @option{-mabi=ti} selects the
28691unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes
28692more naturally with certain GCC assumptions. These are the differences:
28693
28694@table @samp
28695@item Function Pointer Size
28696TI ABI specifies that function (code) pointers are 16-bit, whereas GNU
28697supports only 32-bit data and code pointers.
28698
28699@item Optional Return Value Pointer
28700Function return values larger than 64 bits are passed by using a hidden
28701pointer as the first argument of the function. TI ABI, though, mandates that
28702the pointer can be NULL in case the caller is not using the returned value.
28703GNU always passes and expects a valid return value pointer.
28704
28705@end table
28706
28707The current @option{-mabi=ti} implementation simply raises a compile error
28708when any of the above code constructs is detected. As a consequence
28709the standard C library cannot be built and it is omitted when linking with
28710@option{-mabi=ti}.
28711
28712Relaxation is a GNU feature and for safety reasons is disabled when using
28713@option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx
28714instructions, so the GNU linker cannot adjust them when shortening adjacent
28715LDI32 pseudo instructions.
28716
28717@end table
28718
28719@node RISC-V Options
28720@subsection RISC-V Options
28721@cindex RISC-V Options
28722
28723These command-line options are defined for RISC-V targets:
28724
28725@table @gcctabopt
28726@item -mbranch-cost=@var{n}
28727@opindex mbranch-cost
28728Set the cost of branches to roughly @var{n} instructions.
28729
28730@item -mplt
28731@itemx -mno-plt
28732@opindex plt
28733When generating PIC code, do or don't allow the use of PLTs. Ignored for
28734non-PIC. The default is @option{-mplt}.
28735
28736@item -mabi=@var{ABI-string}
28737@opindex mabi
28738Specify integer and floating-point calling convention. @var{ABI-string}
28739contains two parts: the size of integer types and the registers used for
28740floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that
28741@samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be
2874232-bit), and that floating-point values up to 64 bits wide are passed in F
28743registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still
28744allows the compiler to generate code that uses the F and D extensions but only
28745allows floating-point values up to 32 bits long to be passed in registers; or
28746@samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be
28747passed in registers.
28748
28749The default for this argument is system dependent, users who want a specific
28750calling convention should specify one explicitly. The valid calling
28751conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64},
28752@samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to
28753implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is
28754invalid because the ABI requires 64-bit values be passed in F registers, but F
28755registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can
28756only be used with the @samp{rv32e} architecture. This ABI is not well
28757specified at present, and is subject to change.
28758
28759@item -mfdiv
28760@itemx -mno-fdiv
28761@opindex mfdiv
28762Do or don't use hardware floating-point divide and square root instructions.
28763This requires the F or D extensions for floating-point registers. The default
28764is to use them if the specified architecture has these instructions.
28765
28766@item -mdiv
28767@itemx -mno-div
28768@opindex mdiv
28769Do or don't use hardware instructions for integer division. This requires the
28770M extension. The default is to use them if the specified architecture has
28771these instructions.
28772
28773@item -misa-spec=@var{ISA-spec-string}
28774@opindex misa-spec
28775Specify the version of the RISC-V Unprivileged (formerly User-Level)
28776ISA specification to produce code conforming to. The possibilities
28777for @var{ISA-spec-string} are:
28778@table @code
28779@item 2.2
28780Produce code conforming to version 2.2.
28781@item 20190608
28782Produce code conforming to version 20190608.
28783@item 20191213
28784Produce code conforming to version 20191213.
28785@end table
28786The default is @option{-misa-spec=20191213} unless GCC has been configured
28787with @option{--with-isa-spec=} specifying a different default version.
28788
28789@item -march=@var{ISA-string}
28790@opindex march
28791Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be
28792lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and
28793@samp{rv32imaf}.
28794
28795When @option{-march=} is not specified, use the setting from @option{-mcpu}.
28796
28797If both @option{-march} and @option{-mcpu=} are not specified, the default for
28798this argument is system dependent, users who want a specific architecture
28799extensions should specify one explicitly.
28800
28801@item -mcpu=@var{processor-string}
28802@opindex mcpu
28803Use architecture of and optimize the output for the given processor, specified
28804by particular CPU name.
28805Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21},
28806@samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76},
28807@samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76},
aa37a91c 28808@samp{sifive-u54}, and @samp{sifive-u74}.
d77de738
ML
28809
28810@item -mtune=@var{processor-string}
28811@opindex mtune
28812Optimize the output for the given processor, specified by microarchitecture or
28813particular CPU name. Permissible values for this option are: @samp{rocket},
28814@samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series},
aa37a91c 28815@samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}.
d77de738
ML
28816
28817When @option{-mtune=} is not specified, use the setting from @option{-mcpu},
28818the default is @samp{rocket} if both are not specified.
28819
28820The @samp{size} choice is not intended for use by end-users. This is used
28821when @option{-Os} is specified. It overrides the instruction cost info
28822provided by @option{-mtune=}, but does not override the pipeline info. This
28823helps reduce code size while still giving good performance.
28824
28825@item -mpreferred-stack-boundary=@var{num}
28826@opindex mpreferred-stack-boundary
28827Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
28828byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
28829the default is 4 (16 bytes or 128-bits).
28830
28831@strong{Warning:} If you use this switch, then you must build all modules with
28832the same value, including any libraries. This includes the system libraries
28833and startup modules.
28834
28835@item -msmall-data-limit=@var{n}
28836@opindex msmall-data-limit
28837Put global and static data smaller than @var{n} bytes into a special section
28838(on some targets).
28839
28840@item -msave-restore
28841@itemx -mno-save-restore
28842@opindex msave-restore
28843Do or don't use smaller but slower prologue and epilogue code that uses
28844library function calls. The default is to use fast inline prologues and
28845epilogues.
28846
28847@item -mshorten-memrefs
28848@itemx -mno-shorten-memrefs
28849@opindex mshorten-memrefs
28850Do or do not attempt to make more use of compressed load/store instructions by
28851replacing a load/store of 'base register + large offset' with a new load/store
28852of 'new base + small offset'. If the new base gets stored in a compressed
28853register, then the new load/store can be compressed. Currently targets 32-bit
28854integer load/stores only.
28855
28856@item -mstrict-align
28857@itemx -mno-strict-align
28858@opindex mstrict-align
28859Do not or do generate unaligned memory accesses. The default is set depending
28860on whether the processor we are optimizing for supports fast unaligned access
28861or not.
28862
28863@item -mcmodel=medlow
28864@opindex mcmodel=medlow
28865Generate code for the medium-low code model. The program and its statically
28866defined symbols must lie within a single 2 GiB address range and must lie
28867between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be
28868statically or dynamically linked. This is the default code model.
28869
28870@item -mcmodel=medany
28871@opindex mcmodel=medany
28872Generate code for the medium-any code model. The program and its statically
28873defined symbols must be within any single 2 GiB address range. Programs can be
28874statically or dynamically linked.
28875
28876The code generated by the medium-any code model is position-independent, but is
28877not guaranteed to function correctly when linked into position-independent
28878executables or libraries.
28879
28880@item -mexplicit-relocs
28881@itemx -mno-exlicit-relocs
28882Use or do not use assembler relocation operators when dealing with symbolic
28883addresses. The alternative is to use assembler macros instead, which may
28884limit optimization.
28885
28886@item -mrelax
28887@itemx -mno-relax
28888@opindex mrelax
28889Take advantage of linker relaxations to reduce the number of instructions
28890required to materialize symbol addresses. The default is to take advantage of
28891linker relaxations.
28892
28893@item -mriscv-attribute
28894@itemx -mno-riscv-attribute
28895@opindex mriscv-attribute
28896Emit (do not emit) RISC-V attribute to record extra information into ELF
28897objects. This feature requires at least binutils 2.32.
28898
28899@item -mcsr-check
28900@itemx -mno-csr-check
28901@opindex mcsr-check
28902Enables or disables the CSR checking.
28903
28904@item -malign-data=@var{type}
28905@opindex malign-data
28906Control how GCC aligns variables and constants of array, structure, or union
28907types. Supported values for @var{type} are @samp{xlen} which uses x register
28908width as the alignment value, and @samp{natural} which uses natural alignment.
28909@samp{xlen} is the default.
28910
28911@item -mbig-endian
28912@opindex mbig-endian
28913Generate big-endian code. This is the default when GCC is configured for a
28914@samp{riscv64be-*-*} or @samp{riscv32be-*-*} target.
28915
28916@item -mlittle-endian
28917@opindex mlittle-endian
28918Generate little-endian code. This is the default when GCC is configured for a
28919@samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or
28920@samp{riscv32be-*-*} target.
28921
28922@item -mstack-protector-guard=@var{guard}
28923@itemx -mstack-protector-guard-reg=@var{reg}
28924@itemx -mstack-protector-guard-offset=@var{offset}
28925@opindex mstack-protector-guard
28926@opindex mstack-protector-guard-reg
28927@opindex mstack-protector-guard-offset
28928Generate stack protection code using canary at @var{guard}. Supported
28929locations are @samp{global} for a global canary or @samp{tls} for per-thread
28930canary in the TLS block.
28931
28932With the latter choice the options
28933@option{-mstack-protector-guard-reg=@var{reg}} and
28934@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
28935which register to use as base register for reading the canary,
28936and from what offset from that base register. There is no default
28937register or offset as this is entirely for use within the Linux
28938kernel.
28939@end table
28940
28941@node RL78 Options
28942@subsection RL78 Options
28943@cindex RL78 Options
28944
28945@table @gcctabopt
28946
28947@item -msim
28948@opindex msim
28949Links in additional target libraries to support operation within a
28950simulator.
28951
28952@item -mmul=none
28953@itemx -mmul=g10
28954@itemx -mmul=g13
28955@itemx -mmul=g14
28956@itemx -mmul=rl78
28957@opindex mmul
28958Specifies the type of hardware multiplication and division support to
28959be used. The simplest is @code{none}, which uses software for both
28960multiplication and division. This is the default. The @code{g13}
28961value is for the hardware multiply/divide peripheral found on the
28962RL78/G13 (S2 core) targets. The @code{g14} value selects the use of
28963the multiplication and division instructions supported by the RL78/G14
28964(S3 core) parts. The value @code{rl78} is an alias for @code{g14} and
28965the value @code{mg10} is an alias for @code{none}.
28966
28967In addition a C preprocessor macro is defined, based upon the setting
28968of this option. Possible values are: @code{__RL78_MUL_NONE__},
28969@code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}.
28970
28971@item -mcpu=g10
28972@itemx -mcpu=g13
28973@itemx -mcpu=g14
28974@itemx -mcpu=rl78
28975@opindex mcpu
28976Specifies the RL78 core to target. The default is the G14 core, also
28977known as an S3 core or just RL78. The G13 or S2 core does not have
28978multiply or divide instructions, instead it uses a hardware peripheral
28979for these operations. The G10 or S1 core does not have register
28980banks, so it uses a different calling convention.
28981
28982If this option is set it also selects the type of hardware multiply
28983support to use, unless this is overridden by an explicit
28984@option{-mmul=none} option on the command line. Thus specifying
28985@option{-mcpu=g13} enables the use of the G13 hardware multiply
28986peripheral and specifying @option{-mcpu=g10} disables the use of
28987hardware multiplications altogether.
28988
28989Note, although the RL78/G14 core is the default target, specifying
28990@option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does
28991change the behavior of the toolchain since it also enables G14
28992hardware multiply support. If these options are not specified on the
28993command line then software multiplication routines will be used even
28994though the code targets the RL78 core. This is for backwards
28995compatibility with older toolchains which did not have hardware
28996multiply and divide support.
28997
28998In addition a C preprocessor macro is defined, based upon the setting
28999of this option. Possible values are: @code{__RL78_G10__},
29000@code{__RL78_G13__} or @code{__RL78_G14__}.
29001
29002@item -mg10
29003@itemx -mg13
29004@itemx -mg14
29005@itemx -mrl78
29006@opindex mg10
29007@opindex mg13
29008@opindex mg14
29009@opindex mrl78
29010These are aliases for the corresponding @option{-mcpu=} option. They
29011are provided for backwards compatibility.
29012
29013@item -mallregs
29014@opindex mallregs
29015Allow the compiler to use all of the available registers. By default
29016registers @code{r24..r31} are reserved for use in interrupt handlers.
29017With this option enabled these registers can be used in ordinary
29018functions as well.
29019
29020@item -m64bit-doubles
29021@itemx -m32bit-doubles
29022@opindex m64bit-doubles
29023@opindex m32bit-doubles
29024Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
29025or 32 bits (@option{-m32bit-doubles}) in size. The default is
29026@option{-m32bit-doubles}.
29027
29028@item -msave-mduc-in-interrupts
29029@itemx -mno-save-mduc-in-interrupts
29030@opindex msave-mduc-in-interrupts
29031@opindex mno-save-mduc-in-interrupts
29032Specifies that interrupt handler functions should preserve the
29033MDUC registers. This is only necessary if normal code might use
29034the MDUC registers, for example because it performs multiplication
29035and division operations. The default is to ignore the MDUC registers
29036as this makes the interrupt handlers faster. The target option -mg13
29037needs to be passed for this to work as this feature is only available
29038on the G13 target (S2 core). The MDUC registers will only be saved
29039if the interrupt handler performs a multiplication or division
29040operation or it calls another function.
29041
29042@end table
29043
29044@node RS/6000 and PowerPC Options
29045@subsection IBM RS/6000 and PowerPC Options
29046@cindex RS/6000 and PowerPC Options
29047@cindex IBM RS/6000 and PowerPC Options
29048
29049These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
29050@table @gcctabopt
29051@item -mpowerpc-gpopt
29052@itemx -mno-powerpc-gpopt
29053@itemx -mpowerpc-gfxopt
29054@itemx -mno-powerpc-gfxopt
29055@need 800
29056@itemx -mpowerpc64
29057@itemx -mno-powerpc64
29058@itemx -mmfcrf
29059@itemx -mno-mfcrf
29060@itemx -mpopcntb
29061@itemx -mno-popcntb
29062@itemx -mpopcntd
29063@itemx -mno-popcntd
29064@itemx -mfprnd
29065@itemx -mno-fprnd
29066@need 800
29067@itemx -mcmpb
29068@itemx -mno-cmpb
29069@itemx -mhard-dfp
29070@itemx -mno-hard-dfp
29071@opindex mpowerpc-gpopt
29072@opindex mno-powerpc-gpopt
29073@opindex mpowerpc-gfxopt
29074@opindex mno-powerpc-gfxopt
29075@opindex mpowerpc64
29076@opindex mno-powerpc64
29077@opindex mmfcrf
29078@opindex mno-mfcrf
29079@opindex mpopcntb
29080@opindex mno-popcntb
29081@opindex mpopcntd
29082@opindex mno-popcntd
29083@opindex mfprnd
29084@opindex mno-fprnd
29085@opindex mcmpb
29086@opindex mno-cmpb
29087@opindex mhard-dfp
29088@opindex mno-hard-dfp
29089You use these options to specify which instructions are available on the
29090processor you are using. The default value of these options is
29091determined when configuring GCC@. Specifying the
29092@option{-mcpu=@var{cpu_type}} overrides the specification of these
29093options. We recommend you use the @option{-mcpu=@var{cpu_type}} option
29094rather than the options listed above.
29095
29096Specifying @option{-mpowerpc-gpopt} allows
29097GCC to use the optional PowerPC architecture instructions in the
29098General Purpose group, including floating-point square root. Specifying
29099@option{-mpowerpc-gfxopt} allows GCC to
29100use the optional PowerPC architecture instructions in the Graphics
29101group, including floating-point select.
29102
29103The @option{-mmfcrf} option allows GCC to generate the move from
29104condition register field instruction implemented on the POWER4
29105processor and other processors that support the PowerPC V2.01
29106architecture.
29107The @option{-mpopcntb} option allows GCC to generate the popcount and
29108double-precision FP reciprocal estimate instruction implemented on the
29109POWER5 processor and other processors that support the PowerPC V2.02
29110architecture.
29111The @option{-mpopcntd} option allows GCC to generate the popcount
29112instruction implemented on the POWER7 processor and other processors
29113that support the PowerPC V2.06 architecture.
29114The @option{-mfprnd} option allows GCC to generate the FP round to
29115integer instructions implemented on the POWER5+ processor and other
29116processors that support the PowerPC V2.03 architecture.
29117The @option{-mcmpb} option allows GCC to generate the compare bytes
29118instruction implemented on the POWER6 processor and other processors
29119that support the PowerPC V2.05 architecture.
29120The @option{-mhard-dfp} option allows GCC to generate the decimal
29121floating-point instructions implemented on some POWER processors.
29122
29123The @option{-mpowerpc64} option allows GCC to generate the additional
2912464-bit instructions that are found in the full PowerPC64 architecture
29125and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to
29126@option{-mno-powerpc64}.
29127
29128@item -mcpu=@var{cpu_type}
29129@opindex mcpu
29130Set architecture type, register usage, and
29131instruction scheduling parameters for machine type @var{cpu_type}.
29132Supported values for @var{cpu_type} are @samp{401}, @samp{403},
29133@samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp},
29134@samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603},
29135@samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740},
29136@samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823},
29137@samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2},
29138@samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500},
29139@samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5},
29140@samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+},
29141@samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8},
29142@samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64},
29143@samp{powerpc64le}, @samp{rs64}, and @samp{native}.
29144
29145@option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and
29146@option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either
29147endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC
29148architecture machine types, with an appropriate, generic processor
29149model assumed for scheduling purposes.
29150
29151Specifying @samp{native} as cpu type detects and selects the
29152architecture option that corresponds to the host processor of the
29153system performing the compilation.
29154@option{-mcpu=native} has no effect if GCC does not recognize the
29155processor.
29156
29157The other options specify a specific processor. Code generated under
29158those options runs best on that processor, and may not run at all on
29159others.
29160
29161The @option{-mcpu} options automatically enable or disable the
29162following options:
29163
29164@gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple @gol
29165-mpopcntb -mpopcntd -mpowerpc64 @gol
29166-mpowerpc-gpopt -mpowerpc-gfxopt @gol
29167-mmulhw -mdlmzb -mmfpgpr -mvsx @gol
29168-mcrypto -mhtm -mpower8-fusion -mpower8-vector @gol
29169-mquad-memory -mquad-memory-atomic -mfloat128 @gol
29170-mfloat128-hardware -mprefixed -mpcrel -mmma @gol
29171-mrop-protect}
29172
29173The particular options set for any particular CPU varies between
29174compiler versions, depending on what setting seems to produce optimal
29175code for that CPU; it doesn't necessarily reflect the actual hardware's
29176capabilities. If you wish to set an individual option to a particular
29177value, you may specify it after the @option{-mcpu} option, like
29178@option{-mcpu=970 -mno-altivec}.
29179
29180On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are
29181not enabled or disabled by the @option{-mcpu} option at present because
29182AIX does not have full support for these options. You may still
29183enable or disable them individually if you're sure it'll work in your
29184environment.
29185
29186@item -mtune=@var{cpu_type}
29187@opindex mtune
29188Set the instruction scheduling parameters for machine type
29189@var{cpu_type}, but do not set the architecture type or register usage,
29190as @option{-mcpu=@var{cpu_type}} does. The same
29191values for @var{cpu_type} are used for @option{-mtune} as for
29192@option{-mcpu}. If both are specified, the code generated uses the
29193architecture and registers set by @option{-mcpu}, but the
29194scheduling parameters set by @option{-mtune}.
29195
29196@item -mcmodel=small
29197@opindex mcmodel=small
29198Generate PowerPC64 code for the small model: The TOC is limited to
2919964k.
29200
29201@item -mcmodel=medium
29202@opindex mcmodel=medium
29203Generate PowerPC64 code for the medium model: The TOC and other static
29204data may be up to a total of 4G in size. This is the default for 64-bit
29205Linux.
29206
29207@item -mcmodel=large
29208@opindex mcmodel=large
29209Generate PowerPC64 code for the large model: The TOC may be up to 4G
29210in size. Other data and code is only limited by the 64-bit address
29211space.
29212
29213@item -maltivec
29214@itemx -mno-altivec
29215@opindex maltivec
29216@opindex mno-altivec
29217Generate code that uses (does not use) AltiVec instructions, and also
29218enable the use of built-in functions that allow more direct access to
29219the AltiVec instruction set. You may also need to set
29220@option{-mabi=altivec} to adjust the current ABI with AltiVec ABI
29221enhancements.
29222
29223When @option{-maltivec} is used, the element order for AltiVec intrinsics
29224such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert}
29225match array element order corresponding to the endianness of the
29226target. That is, element zero identifies the leftmost element in a
29227vector register when targeting a big-endian platform, and identifies
29228the rightmost element in a vector register when targeting a
29229little-endian platform.
29230
29231@item -mvrsave
29232@itemx -mno-vrsave
29233@opindex mvrsave
29234@opindex mno-vrsave
29235Generate VRSAVE instructions when generating AltiVec code.
29236
29237@item -msecure-plt
29238@opindex msecure-plt
29239Generate code that allows @command{ld} and @command{ld.so}
29240to build executables and shared
29241libraries with non-executable @code{.plt} and @code{.got} sections.
29242This is a PowerPC
2924332-bit SYSV ABI option.
29244
29245@item -mbss-plt
29246@opindex mbss-plt
29247Generate code that uses a BSS @code{.plt} section that @command{ld.so}
29248fills in, and
29249requires @code{.plt} and @code{.got}
29250sections that are both writable and executable.
29251This is a PowerPC 32-bit SYSV ABI option.
29252
29253@item -misel
29254@itemx -mno-isel
29255@opindex misel
29256@opindex mno-isel
29257This switch enables or disables the generation of ISEL instructions.
29258
29259@item -mvsx
29260@itemx -mno-vsx
29261@opindex mvsx
29262@opindex mno-vsx
29263Generate code that uses (does not use) vector/scalar (VSX)
29264instructions, and also enable the use of built-in functions that allow
29265more direct access to the VSX instruction set.
29266
29267@item -mcrypto
29268@itemx -mno-crypto
29269@opindex mcrypto
29270@opindex mno-crypto
29271Enable the use (disable) of the built-in functions that allow direct
29272access to the cryptographic instructions that were added in version
292732.07 of the PowerPC ISA.
29274
29275@item -mhtm
29276@itemx -mno-htm
29277@opindex mhtm
29278@opindex mno-htm
29279Enable (disable) the use of the built-in functions that allow direct
29280access to the Hardware Transactional Memory (HTM) instructions that
29281were added in version 2.07 of the PowerPC ISA.
29282
29283@item -mpower8-fusion
29284@itemx -mno-power8-fusion
29285@opindex mpower8-fusion
29286@opindex mno-power8-fusion
29287Generate code that keeps (does not keeps) some integer operations
29288adjacent so that the instructions can be fused together on power8 and
29289later processors.
29290
29291@item -mpower8-vector
29292@itemx -mno-power8-vector
29293@opindex mpower8-vector
29294@opindex mno-power8-vector
29295Generate code that uses (does not use) the vector and scalar
29296instructions that were added in version 2.07 of the PowerPC ISA. Also
29297enable the use of built-in functions that allow more direct access to
29298the vector instructions.
29299
29300@item -mquad-memory
29301@itemx -mno-quad-memory
29302@opindex mquad-memory
29303@opindex mno-quad-memory
29304Generate code that uses (does not use) the non-atomic quad word memory
29305instructions. The @option{-mquad-memory} option requires use of
2930664-bit mode.
29307
29308@item -mquad-memory-atomic
29309@itemx -mno-quad-memory-atomic
29310@opindex mquad-memory-atomic
29311@opindex mno-quad-memory-atomic
29312Generate code that uses (does not use) the atomic quad word memory
29313instructions. The @option{-mquad-memory-atomic} option requires use of
2931464-bit mode.
29315
29316@item -mfloat128
29317@itemx -mno-float128
29318@opindex mfloat128
29319@opindex mno-float128
29320Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point
29321and use either software emulation for IEEE 128-bit floating point or
29322hardware instructions.
29323
29324The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE
29325128-bit floating point support. The IEEE 128-bit floating point is only
29326supported on Linux.
29327
29328The default for @option{-mfloat128} is enabled on PowerPC Linux
29329systems using the VSX instruction set, and disabled on other systems.
29330
29331If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or
29332@option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating
29333point support will also enable the generation of ISA 3.0 IEEE 128-bit
29334floating point instructions. Otherwise, if you do not specify to
29335generate ISA 3.0 instructions or you are targeting a 32-bit big endian
29336system, IEEE 128-bit floating point will be done with software
29337emulation.
29338
29339@item -mfloat128-hardware
29340@itemx -mno-float128-hardware
29341@opindex mfloat128-hardware
29342@opindex mno-float128-hardware
29343Enable/disable using ISA 3.0 hardware instructions to support the
29344@var{__float128} data type.
29345
29346The default for @option{-mfloat128-hardware} is enabled on PowerPC
29347Linux systems using the ISA 3.0 instruction set, and disabled on other
29348systems.
29349
29350@item -m32
29351@itemx -m64
29352@opindex m32
29353@opindex m64
29354Generate code for 32-bit or 64-bit environments of Darwin and SVR4
29355targets (including GNU/Linux). The 32-bit environment sets int, long
29356and pointer to 32 bits and generates code that runs on any PowerPC
29357variant. The 64-bit environment sets int to 32 bits and long and
29358pointer to 64 bits, and generates code for PowerPC64, as for
29359@option{-mpowerpc64}.
29360
29361@item -mfull-toc
29362@itemx -mno-fp-in-toc
29363@itemx -mno-sum-in-toc
29364@itemx -mminimal-toc
29365@opindex mfull-toc
29366@opindex mno-fp-in-toc
29367@opindex mno-sum-in-toc
29368@opindex mminimal-toc
29369Modify generation of the TOC (Table Of Contents), which is created for
29370every executable file. The @option{-mfull-toc} option is selected by
29371default. In that case, GCC allocates at least one TOC entry for
29372each unique non-automatic variable reference in your program. GCC
29373also places floating-point constants in the TOC@. However, only
2937416,384 entries are available in the TOC@.
29375
29376If you receive a linker error message that saying you have overflowed
29377the available TOC space, you can reduce the amount of TOC space used
29378with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options.
29379@option{-mno-fp-in-toc} prevents GCC from putting floating-point
29380constants in the TOC and @option{-mno-sum-in-toc} forces GCC to
29381generate code to calculate the sum of an address and a constant at
29382run time instead of putting that sum into the TOC@. You may specify one
29383or both of these options. Each causes GCC to produce very slightly
29384slower and larger code at the expense of conserving TOC space.
29385
29386If you still run out of space in the TOC even when you specify both of
29387these options, specify @option{-mminimal-toc} instead. This option causes
29388GCC to make only one TOC entry for every file. When you specify this
29389option, GCC produces code that is slower and larger but which
29390uses extremely little TOC space. You may wish to use this option
29391only on files that contain less frequently-executed code.
29392
29393@item -maix64
29394@itemx -maix32
29395@opindex maix64
29396@opindex maix32
29397Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit
29398@code{long} type, and the infrastructure needed to support them.
29399Specifying @option{-maix64} implies @option{-mpowerpc64},
29400while @option{-maix32} disables the 64-bit ABI and
29401implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}.
29402
29403@item -mxl-compat
29404@itemx -mno-xl-compat
29405@opindex mxl-compat
29406@opindex mno-xl-compat
29407Produce code that conforms more closely to IBM XL compiler semantics
29408when using AIX-compatible ABI@. Pass floating-point arguments to
29409prototyped functions beyond the register save area (RSA) on the stack
29410in addition to argument FPRs. Do not assume that most significant
29411double in 128-bit long double value is properly rounded when comparing
29412values and converting to double. Use XL symbol names for long double
29413support routines.
29414
29415The AIX calling convention was extended but not initially documented to
29416handle an obscure K&R C case of calling a function that takes the
29417address of its arguments with fewer arguments than declared. IBM XL
29418compilers access floating-point arguments that do not fit in the
29419RSA from the stack when a subroutine is compiled without
29420optimization. Because always storing floating-point arguments on the
29421stack is inefficient and rarely needed, this option is not enabled by
29422default and only is necessary when calling subroutines compiled by IBM
29423XL compilers without optimization.
29424
29425@item -mpe
29426@opindex mpe
29427Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an
29428application written to use message passing with special startup code to
29429enable the application to run. The system must have PE installed in the
29430standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file
29431must be overridden with the @option{-specs=} option to specify the
29432appropriate directory location. The Parallel Environment does not
29433support threads, so the @option{-mpe} option and the @option{-pthread}
29434option are incompatible.
29435
29436@item -malign-natural
29437@itemx -malign-power
29438@opindex malign-natural
29439@opindex malign-power
29440On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option
29441@option{-malign-natural} overrides the ABI-defined alignment of larger
29442types, such as floating-point doubles, on their natural size-based boundary.
29443The option @option{-malign-power} instructs GCC to follow the ABI-specified
29444alignment rules. GCC defaults to the standard alignment defined in the ABI@.
29445
29446On 64-bit Darwin, natural alignment is the default, and @option{-malign-power}
29447is not supported.
29448
29449@item -msoft-float
29450@itemx -mhard-float
29451@opindex msoft-float
29452@opindex mhard-float
29453Generate code that does not use (uses) the floating-point register set.
29454Software floating-point emulation is provided if you use the
29455@option{-msoft-float} option, and pass the option to GCC when linking.
29456
29457@item -mmultiple
29458@itemx -mno-multiple
29459@opindex mmultiple
29460@opindex mno-multiple
29461Generate code that uses (does not use) the load multiple word
29462instructions and the store multiple word instructions. These
29463instructions are generated by default on POWER systems, and not
29464generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian
29465PowerPC systems, since those instructions do not work when the
29466processor is in little-endian mode. The exceptions are PPC740 and
29467PPC750 which permit these instructions in little-endian mode.
29468
29469@item -mupdate
29470@itemx -mno-update
29471@opindex mupdate
29472@opindex mno-update
29473Generate code that uses (does not use) the load or store instructions
29474that update the base register to the address of the calculated memory
29475location. These instructions are generated by default. If you use
29476@option{-mno-update}, there is a small window between the time that the
29477stack pointer is updated and the address of the previous frame is
29478stored, which means code that walks the stack frame across interrupts or
29479signals may get corrupted data.
29480
29481@item -mavoid-indexed-addresses
29482@itemx -mno-avoid-indexed-addresses
29483@opindex mavoid-indexed-addresses
29484@opindex mno-avoid-indexed-addresses
29485Generate code that tries to avoid (not avoid) the use of indexed load
29486or store instructions. These instructions can incur a performance
29487penalty on Power6 processors in certain situations, such as when
29488stepping through large arrays that cross a 16M boundary. This option
29489is enabled by default when targeting Power6 and disabled otherwise.
29490
29491@item -mfused-madd
29492@itemx -mno-fused-madd
29493@opindex mfused-madd
29494@opindex mno-fused-madd
29495Generate code that uses (does not use) the floating-point multiply and
29496accumulate instructions. These instructions are generated by default
29497if hardware floating point is used. The machine-dependent
29498@option{-mfused-madd} option is now mapped to the machine-independent
29499@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
29500mapped to @option{-ffp-contract=off}.
29501
29502@item -mmulhw
29503@itemx -mno-mulhw
29504@opindex mmulhw
29505@opindex mno-mulhw
29506Generate code that uses (does not use) the half-word multiply and
29507multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors.
29508These instructions are generated by default when targeting those
29509processors.
29510
29511@item -mdlmzb
29512@itemx -mno-dlmzb
29513@opindex mdlmzb
29514@opindex mno-dlmzb
29515Generate code that uses (does not use) the string-search @samp{dlmzb}
29516instruction on the IBM 405, 440, 464 and 476 processors. This instruction is
29517generated by default when targeting those processors.
29518
29519@item -mno-bit-align
29520@itemx -mbit-align
29521@opindex mno-bit-align
29522@opindex mbit-align
29523On System V.4 and embedded PowerPC systems do not (do) force structures
29524and unions that contain bit-fields to be aligned to the base type of the
29525bit-field.
29526
29527For example, by default a structure containing nothing but 8
29528@code{unsigned} bit-fields of length 1 is aligned to a 4-byte
29529boundary and has a size of 4 bytes. By using @option{-mno-bit-align},
29530the structure is aligned to a 1-byte boundary and is 1 byte in
29531size.
29532
29533@item -mno-strict-align
29534@itemx -mstrict-align
29535@opindex mno-strict-align
29536@opindex mstrict-align
29537On System V.4 and embedded PowerPC systems do not (do) assume that
29538unaligned memory references are handled by the system.
29539
29540@item -mrelocatable
29541@itemx -mno-relocatable
29542@opindex mrelocatable
29543@opindex mno-relocatable
29544Generate code that allows (does not allow) a static executable to be
29545relocated to a different address at run time. A simple embedded
29546PowerPC system loader should relocate the entire contents of
29547@code{.got2} and 4-byte locations listed in the @code{.fixup} section,
29548a table of 32-bit addresses generated by this option. For this to
29549work, all objects linked together must be compiled with
29550@option{-mrelocatable} or @option{-mrelocatable-lib}.
29551@option{-mrelocatable} code aligns the stack to an 8-byte boundary.
29552
29553@item -mrelocatable-lib
29554@itemx -mno-relocatable-lib
29555@opindex mrelocatable-lib
29556@opindex mno-relocatable-lib
29557Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a
29558@code{.fixup} section to allow static executables to be relocated at
29559run time, but @option{-mrelocatable-lib} does not use the smaller stack
29560alignment of @option{-mrelocatable}. Objects compiled with
29561@option{-mrelocatable-lib} may be linked with objects compiled with
29562any combination of the @option{-mrelocatable} options.
29563
29564@item -mno-toc
29565@itemx -mtoc
29566@opindex mno-toc
29567@opindex mtoc
29568On System V.4 and embedded PowerPC systems do not (do) assume that
29569register 2 contains a pointer to a global area pointing to the addresses
29570used in the program.
29571
29572@item -mlittle
29573@itemx -mlittle-endian
29574@opindex mlittle
29575@opindex mlittle-endian
29576On System V.4 and embedded PowerPC systems compile code for the
29577processor in little-endian mode. The @option{-mlittle-endian} option is
29578the same as @option{-mlittle}.
29579
29580@item -mbig
29581@itemx -mbig-endian
29582@opindex mbig
29583@opindex mbig-endian
29584On System V.4 and embedded PowerPC systems compile code for the
29585processor in big-endian mode. The @option{-mbig-endian} option is
29586the same as @option{-mbig}.
29587
29588@item -mdynamic-no-pic
29589@opindex mdynamic-no-pic
29590On Darwin and Mac OS X systems, compile code so that it is not
29591relocatable, but that its external references are relocatable. The
29592resulting code is suitable for applications, but not shared
29593libraries.
29594
29595@item -msingle-pic-base
29596@opindex msingle-pic-base
29597Treat the register used for PIC addressing as read-only, rather than
29598loading it in the prologue for each function. The runtime system is
29599responsible for initializing this register with an appropriate value
29600before execution begins.
29601
29602@item -mprioritize-restricted-insns=@var{priority}
29603@opindex mprioritize-restricted-insns
29604This option controls the priority that is assigned to
29605dispatch-slot restricted instructions during the second scheduling
29606pass. The argument @var{priority} takes the value @samp{0}, @samp{1},
29607or @samp{2} to assign no, highest, or second-highest (respectively)
29608priority to dispatch-slot restricted
29609instructions.
29610
29611@item -msched-costly-dep=@var{dependence_type}
29612@opindex msched-costly-dep
29613This option controls which dependences are considered costly
29614by the target during instruction scheduling. The argument
29615@var{dependence_type} takes one of the following values:
29616
29617@table @asis
29618@item @samp{no}
29619No dependence is costly.
29620
29621@item @samp{all}
29622All dependences are costly.
29623
29624@item @samp{true_store_to_load}
29625A true dependence from store to load is costly.
29626
29627@item @samp{store_to_load}
29628Any dependence from store to load is costly.
29629
29630@item @var{number}
29631Any dependence for which the latency is greater than or equal to
29632@var{number} is costly.
29633@end table
29634
29635@item -minsert-sched-nops=@var{scheme}
29636@opindex minsert-sched-nops
29637This option controls which NOP insertion scheme is used during
29638the second scheduling pass. The argument @var{scheme} takes one of the
29639following values:
29640
29641@table @asis
29642@item @samp{no}
29643Don't insert NOPs.
29644
29645@item @samp{pad}
29646Pad with NOPs any dispatch group that has vacant issue slots,
29647according to the scheduler's grouping.
29648
29649@item @samp{regroup_exact}
29650Insert NOPs to force costly dependent insns into
29651separate groups. Insert exactly as many NOPs as needed to force an insn
29652to a new group, according to the estimated processor grouping.
29653
29654@item @var{number}
29655Insert NOPs to force costly dependent insns into
29656separate groups. Insert @var{number} NOPs to force an insn to a new group.
29657@end table
29658
29659@item -mcall-sysv
29660@opindex mcall-sysv
29661On System V.4 and embedded PowerPC systems compile code using calling
29662conventions that adhere to the March 1995 draft of the System V
29663Application Binary Interface, PowerPC processor supplement. This is the
29664default unless you configured GCC using @samp{powerpc-*-eabiaix}.
29665
29666@item -mcall-sysv-eabi
29667@itemx -mcall-eabi
29668@opindex mcall-sysv-eabi
29669@opindex mcall-eabi
29670Specify both @option{-mcall-sysv} and @option{-meabi} options.
29671
29672@item -mcall-sysv-noeabi
29673@opindex mcall-sysv-noeabi
29674Specify both @option{-mcall-sysv} and @option{-mno-eabi} options.
29675
29676@item -mcall-aixdesc
d7971cf7 29677@opindex mcall-aixdesc
d77de738
ML
29678On System V.4 and embedded PowerPC systems compile code for the AIX
29679operating system.
29680
29681@item -mcall-linux
29682@opindex mcall-linux
29683On System V.4 and embedded PowerPC systems compile code for the
29684Linux-based GNU system.
29685
29686@item -mcall-freebsd
29687@opindex mcall-freebsd
29688On System V.4 and embedded PowerPC systems compile code for the
29689FreeBSD operating system.
29690
29691@item -mcall-netbsd
29692@opindex mcall-netbsd
29693On System V.4 and embedded PowerPC systems compile code for the
29694NetBSD operating system.
29695
29696@item -mcall-openbsd
d7971cf7 29697@opindex mcall-openbsd
d77de738
ML
29698On System V.4 and embedded PowerPC systems compile code for the
29699OpenBSD operating system.
29700
29701@item -mtraceback=@var{traceback_type}
29702@opindex mtraceback
29703Select the type of traceback table. Valid values for @var{traceback_type}
29704are @samp{full}, @samp{part}, and @samp{no}.
29705
29706@item -maix-struct-return
29707@opindex maix-struct-return
29708Return all structures in memory (as specified by the AIX ABI)@.
29709
29710@item -msvr4-struct-return
29711@opindex msvr4-struct-return
29712Return structures smaller than 8 bytes in registers (as specified by the
29713SVR4 ABI)@.
29714
29715@item -mabi=@var{abi-type}
29716@opindex mabi
29717Extend the current ABI with a particular extension, or remove such extension.
29718Valid values are: @samp{altivec}, @samp{no-altivec},
29719@samp{ibmlongdouble}, @samp{ieeelongdouble},
29720@samp{elfv1}, @samp{elfv2},
29721and for AIX: @samp{vec-extabi}, @samp{vec-default}@.
29722
29723@item -mabi=ibmlongdouble
29724@opindex mabi=ibmlongdouble
29725Change the current ABI to use IBM extended-precision long double.
29726This is not likely to work if your system defaults to using IEEE
29727extended-precision long double. If you change the long double type
29728from IEEE extended-precision, the compiler will issue a warning unless
29729you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29730to be enabled.
29731
29732@item -mabi=ieeelongdouble
29733@opindex mabi=ieeelongdouble
29734Change the current ABI to use IEEE extended-precision long double.
29735This is not likely to work if your system defaults to using IBM
29736extended-precision long double. If you change the long double type
29737from IBM extended-precision, the compiler will issue a warning unless
29738you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128}
29739to be enabled.
29740
29741@item -mabi=elfv1
29742@opindex mabi=elfv1
29743Change the current ABI to use the ELFv1 ABI.
29744This is the default ABI for big-endian PowerPC 64-bit Linux.
29745Overriding the default ABI requires special system support and is
29746likely to fail in spectacular ways.
29747
29748@item -mabi=elfv2
29749@opindex mabi=elfv2
29750Change the current ABI to use the ELFv2 ABI.
29751This is the default ABI for little-endian PowerPC 64-bit Linux.
29752Overriding the default ABI requires special system support and is
29753likely to fail in spectacular ways.
29754
29755@item -mgnu-attribute
29756@itemx -mno-gnu-attribute
29757@opindex mgnu-attribute
29758@opindex mno-gnu-attribute
29759Emit .gnu_attribute assembly directives to set tag/value pairs in a
29760.gnu.attributes section that specify ABI variations in function
29761parameters or return values.
29762
29763@item -mprototype
29764@itemx -mno-prototype
29765@opindex mprototype
29766@opindex mno-prototype
29767On System V.4 and embedded PowerPC systems assume that all calls to
29768variable argument functions are properly prototyped. Otherwise, the
29769compiler must insert an instruction before every non-prototyped call to
29770set or clear bit 6 of the condition code register (@code{CR}) to
29771indicate whether floating-point values are passed in the floating-point
29772registers in case the function takes variable arguments. With
29773@option{-mprototype}, only calls to prototyped variable argument functions
29774set or clear the bit.
29775
29776@item -msim
29777@opindex msim
29778On embedded PowerPC systems, assume that the startup module is called
29779@file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and
29780@file{libc.a}. This is the default for @samp{powerpc-*-eabisim}
29781configurations.
29782
29783@item -mmvme
29784@opindex mmvme
29785On embedded PowerPC systems, assume that the startup module is called
29786@file{crt0.o} and the standard C libraries are @file{libmvme.a} and
29787@file{libc.a}.
29788
29789@item -mads
29790@opindex mads
29791On embedded PowerPC systems, assume that the startup module is called
29792@file{crt0.o} and the standard C libraries are @file{libads.a} and
29793@file{libc.a}.
29794
29795@item -myellowknife
29796@opindex myellowknife
29797On embedded PowerPC systems, assume that the startup module is called
29798@file{crt0.o} and the standard C libraries are @file{libyk.a} and
29799@file{libc.a}.
29800
29801@item -mvxworks
29802@opindex mvxworks
29803On System V.4 and embedded PowerPC systems, specify that you are
29804compiling for a VxWorks system.
29805
29806@item -memb
29807@opindex memb
29808On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags
29809header to indicate that @samp{eabi} extended relocations are used.
29810
29811@item -meabi
29812@itemx -mno-eabi
29813@opindex meabi
29814@opindex mno-eabi
29815On System V.4 and embedded PowerPC systems do (do not) adhere to the
29816Embedded Applications Binary Interface (EABI), which is a set of
29817modifications to the System V.4 specifications. Selecting @option{-meabi}
29818means that the stack is aligned to an 8-byte boundary, a function
29819@code{__eabi} is called from @code{main} to set up the EABI
29820environment, and the @option{-msdata} option can use both @code{r2} and
29821@code{r13} to point to two separate small data areas. Selecting
29822@option{-mno-eabi} means that the stack is aligned to a 16-byte boundary,
29823no EABI initialization function is called from @code{main}, and the
29824@option{-msdata} option only uses @code{r13} to point to a single
29825small data area. The @option{-meabi} option is on by default if you
29826configured GCC using one of the @samp{powerpc*-*-eabi*} options.
29827
29828@item -msdata=eabi
29829@opindex msdata=eabi
29830On System V.4 and embedded PowerPC systems, put small initialized
29831@code{const} global and static data in the @code{.sdata2} section, which
29832is pointed to by register @code{r2}. Put small initialized
29833non-@code{const} global and static data in the @code{.sdata} section,
29834which is pointed to by register @code{r13}. Put small uninitialized
29835global and static data in the @code{.sbss} section, which is adjacent to
29836the @code{.sdata} section. The @option{-msdata=eabi} option is
29837incompatible with the @option{-mrelocatable} option. The
29838@option{-msdata=eabi} option also sets the @option{-memb} option.
29839
29840@item -msdata=sysv
29841@opindex msdata=sysv
29842On System V.4 and embedded PowerPC systems, put small global and static
29843data in the @code{.sdata} section, which is pointed to by register
29844@code{r13}. Put small uninitialized global and static data in the
29845@code{.sbss} section, which is adjacent to the @code{.sdata} section.
29846The @option{-msdata=sysv} option is incompatible with the
29847@option{-mrelocatable} option.
29848
29849@item -msdata=default
29850@itemx -msdata
29851@opindex msdata=default
29852@opindex msdata
29853On System V.4 and embedded PowerPC systems, if @option{-meabi} is used,
29854compile code the same as @option{-msdata=eabi}, otherwise compile code the
29855same as @option{-msdata=sysv}.
29856
29857@item -msdata=data
29858@opindex msdata=data
29859On System V.4 and embedded PowerPC systems, put small global
29860data in the @code{.sdata} section. Put small uninitialized global
29861data in the @code{.sbss} section. Do not use register @code{r13}
29862to address small data however. This is the default behavior unless
29863other @option{-msdata} options are used.
29864
29865@item -msdata=none
29866@itemx -mno-sdata
29867@opindex msdata=none
29868@opindex mno-sdata
29869On embedded PowerPC systems, put all initialized global and static data
29870in the @code{.data} section, and all uninitialized data in the
29871@code{.bss} section.
29872
29873@item -mreadonly-in-sdata
29874@opindex mreadonly-in-sdata
29875@opindex mno-readonly-in-sdata
29876Put read-only objects in the @code{.sdata} section as well. This is the
29877default.
29878
29879@item -mblock-move-inline-limit=@var{num}
29880@opindex mblock-move-inline-limit
29881Inline all block moves (such as calls to @code{memcpy} or structure
29882copies) less than or equal to @var{num} bytes. The minimum value for
29883@var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit
29884targets. The default value is target-specific.
29885
29886@item -mblock-compare-inline-limit=@var{num}
29887@opindex mblock-compare-inline-limit
29888Generate non-looping inline code for all block compares (such as calls
29889to @code{memcmp} or structure compares) less than or equal to @var{num}
29890bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of
29891block compare is disabled. The default value is target-specific.
29892
29893@item -mblock-compare-inline-loop-limit=@var{num}
29894@opindex mblock-compare-inline-loop-limit
29895Generate an inline expansion using loop code for all block compares that
29896are less than or equal to @var{num} bytes, but greater than the limit
29897for non-loop inline block compare expansion. If the block length is not
29898constant, at most @var{num} bytes will be compared before @code{memcmp}
29899is called to compare the remainder of the block. The default value is
29900target-specific.
29901
29902@item -mstring-compare-inline-limit=@var{num}
29903@opindex mstring-compare-inline-limit
29904Compare at most @var{num} string bytes with inline code.
29905If the difference or end of string is not found at the
29906end of the inline compare a call to @code{strcmp} or @code{strncmp} will
29907take care of the rest of the comparison. The default is 64 bytes.
29908
29909@item -G @var{num}
29910@opindex G
29911@cindex smaller data references (PowerPC)
29912@cindex .sdata/.sdata2 references (PowerPC)
29913On embedded PowerPC systems, put global and static items less than or
29914equal to @var{num} bytes into the small data or BSS sections instead of
29915the normal data or BSS section. By default, @var{num} is 8. The
29916@option{-G @var{num}} switch is also passed to the linker.
29917All modules should be compiled with the same @option{-G @var{num}} value.
29918
29919@item -mregnames
29920@itemx -mno-regnames
29921@opindex mregnames
29922@opindex mno-regnames
29923On System V.4 and embedded PowerPC systems do (do not) emit register
29924names in the assembly language output using symbolic forms.
29925
29926@item -mlongcall
29927@itemx -mno-longcall
29928@opindex mlongcall
29929@opindex mno-longcall
29930By default assume that all calls are far away so that a longer and more
29931expensive calling sequence is required. This is required for calls
29932farther than 32 megabytes (33,554,432 bytes) from the current location.
29933A short call is generated if the compiler knows
29934the call cannot be that far away. This setting can be overridden by
29935the @code{shortcall} function attribute, or by @code{#pragma
29936longcall(0)}.
29937
29938Some linkers are capable of detecting out-of-range calls and generating
29939glue code on the fly. On these systems, long calls are unnecessary and
29940generate slower code. As of this writing, the AIX linker can do this,
29941as can the GNU linker for PowerPC/64. It is planned to add this feature
29942to the GNU linker for 32-bit PowerPC systems as well.
29943
29944On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers,
29945GCC can generate long calls using an inline PLT call sequence (see
29946@option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64
29947ELFv1 (big-endian) do not support inline PLT calls.
29948
29949On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr
29950callee, L42}, plus a @dfn{branch island} (glue code). The two target
29951addresses represent the callee and the branch island. The
29952Darwin/PPC linker prefers the first address and generates a @code{bl
29953callee} if the PPC @code{bl} instruction reaches the callee directly;
29954otherwise, the linker generates @code{bl L42} to call the branch
29955island. The branch island is appended to the body of the
29956calling function; it computes the full 32-bit address of the callee
29957and jumps to it.
29958
29959On Mach-O (Darwin) systems, this option directs the compiler emit to
29960the glue for every direct call, and the Darwin linker decides whether
29961to use or discard it.
29962
29963In the future, GCC may ignore all longcall specifications
29964when the linker is known to generate glue.
29965
29966@item -mpltseq
29967@itemx -mno-pltseq
29968@opindex mpltseq
29969@opindex mno-pltseq
29970Implement (do not implement) -fno-plt and long calls using an inline
29971PLT call sequence that supports lazy linking and long calls to
29972functions in dlopen'd shared libraries. Inline PLT calls are only
29973supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU
29974linkers, and are enabled by default if the support is detected when
29975configuring GCC, and, in the case of 32-bit PowerPC, if GCC is
29976configured with @option{--enable-secureplt}. @option{-mpltseq} code
29977and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be
29978linked together.
29979
29980@item -mtls-markers
29981@itemx -mno-tls-markers
29982@opindex mtls-markers
29983@opindex mno-tls-markers
29984Mark (do not mark) calls to @code{__tls_get_addr} with a relocation
29985specifying the function argument. The relocation allows the linker to
29986reliably associate function call with argument setup instructions for
29987TLS optimization, which in turn allows GCC to better schedule the
29988sequence.
29989
29990@item -mrecip
29991@itemx -mno-recip
29992@opindex mrecip
29993This option enables use of the reciprocal estimate and
29994reciprocal square root estimate instructions with additional
29995Newton-Raphson steps to increase precision instead of doing a divide or
29996square root and divide for floating-point arguments. You should use
29997the @option{-ffast-math} option when using @option{-mrecip} (or at
29998least @option{-funsafe-math-optimizations},
29999@option{-ffinite-math-only}, @option{-freciprocal-math} and
30000@option{-fno-trapping-math}). Note that while the throughput of the
30001sequence is generally higher than the throughput of the non-reciprocal
30002instruction, the precision of the sequence can be decreased by up to 2
30003ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square
30004roots.
30005
30006@item -mrecip=@var{opt}
30007@opindex mrecip=opt
30008This option controls which reciprocal estimate instructions
30009may be used. @var{opt} is a comma-separated list of options, which may
30010be preceded by a @code{!} to invert the option:
30011
30012@table @samp
30013
30014@item all
30015Enable all estimate instructions.
30016
30017@item default
30018Enable the default instructions, equivalent to @option{-mrecip}.
30019
30020@item none
30021Disable all estimate instructions, equivalent to @option{-mno-recip}.
30022
30023@item div
30024Enable the reciprocal approximation instructions for both
30025single and double precision.
30026
30027@item divf
30028Enable the single-precision reciprocal approximation instructions.
30029
30030@item divd
30031Enable the double-precision reciprocal approximation instructions.
30032
30033@item rsqrt
30034Enable the reciprocal square root approximation instructions for both
30035single and double precision.
30036
30037@item rsqrtf
30038Enable the single-precision reciprocal square root approximation instructions.
30039
30040@item rsqrtd
30041Enable the double-precision reciprocal square root approximation instructions.
30042
30043@end table
30044
30045So, for example, @option{-mrecip=all,!rsqrtd} enables
30046all of the reciprocal estimate instructions, except for the
30047@code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions
30048which handle the double-precision reciprocal square root calculations.
30049
30050@item -mrecip-precision
30051@itemx -mno-recip-precision
30052@opindex mrecip-precision
30053Assume (do not assume) that the reciprocal estimate instructions
30054provide higher-precision estimates than is mandated by the PowerPC
30055ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or
30056@option{-mcpu=power8} automatically selects @option{-mrecip-precision}.
30057The double-precision square root estimate instructions are not generated by
30058default on low-precision machines, since they do not provide an
30059estimate that converges after three steps.
30060
30061@item -mveclibabi=@var{type}
30062@opindex mveclibabi
30063Specifies the ABI type to use for vectorizing intrinsics using an
30064external library. The only type supported at present is @samp{mass},
30065which specifies to use IBM's Mathematical Acceleration Subsystem
30066(MASS) libraries for vectorizing intrinsics using external libraries.
30067GCC currently emits calls to @code{acosd2}, @code{acosf4},
30068@code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4},
30069@code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4},
30070@code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4},
30071@code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4},
30072@code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4},
30073@code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4},
30074@code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4},
30075@code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4},
30076@code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4},
30077@code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4},
30078@code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2},
30079@code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2},
30080@code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code
30081for power7. Both @option{-ftree-vectorize} and
30082@option{-funsafe-math-optimizations} must also be enabled. The MASS
30083libraries must be specified at link time.
30084
30085@item -mfriz
30086@itemx -mno-friz
30087@opindex mfriz
30088Generate (do not generate) the @code{friz} instruction when the
30089@option{-funsafe-math-optimizations} option is used to optimize
30090rounding of floating-point values to 64-bit integer and back to floating
30091point. The @code{friz} instruction does not return the same value if
30092the floating-point number is too large to fit in an integer.
30093
30094@item -mpointers-to-nested-functions
30095@itemx -mno-pointers-to-nested-functions
30096@opindex mpointers-to-nested-functions
30097Generate (do not generate) code to load up the static chain register
30098(@code{r11}) when calling through a pointer on AIX and 64-bit Linux
30099systems where a function pointer points to a 3-word descriptor giving
30100the function address, TOC value to be loaded in register @code{r2}, and
30101static chain value to be loaded in register @code{r11}. The
30102@option{-mpointers-to-nested-functions} is on by default. You cannot
30103call through pointers to nested functions or pointers
30104to functions compiled in other languages that use the static chain if
30105you use @option{-mno-pointers-to-nested-functions}.
30106
30107@item -msave-toc-indirect
30108@itemx -mno-save-toc-indirect
30109@opindex msave-toc-indirect
30110Generate (do not generate) code to save the TOC value in the reserved
30111stack location in the function prologue if the function calls through
30112a pointer on AIX and 64-bit Linux systems. If the TOC value is not
30113saved in the prologue, it is saved just before the call through the
30114pointer. The @option{-mno-save-toc-indirect} option is the default.
30115
30116@item -mcompat-align-parm
30117@itemx -mno-compat-align-parm
30118@opindex mcompat-align-parm
30119Generate (do not generate) code to pass structure parameters with a
30120maximum alignment of 64 bits, for compatibility with older versions
30121of GCC.
30122
30123Older versions of GCC (prior to 4.9.0) incorrectly did not align a
30124structure parameter on a 128-bit boundary when that structure contained
30125a member requiring 128-bit alignment. This is corrected in more
30126recent versions of GCC. This option may be used to generate code
30127that is compatible with functions compiled with older versions of
30128GCC.
30129
30130The @option{-mno-compat-align-parm} option is the default.
30131
30132@item -mstack-protector-guard=@var{guard}
30133@itemx -mstack-protector-guard-reg=@var{reg}
30134@itemx -mstack-protector-guard-offset=@var{offset}
30135@itemx -mstack-protector-guard-symbol=@var{symbol}
30136@opindex mstack-protector-guard
30137@opindex mstack-protector-guard-reg
30138@opindex mstack-protector-guard-offset
30139@opindex mstack-protector-guard-symbol
30140Generate stack protection code using canary at @var{guard}. Supported
30141locations are @samp{global} for global canary or @samp{tls} for per-thread
30142canary in the TLS block (the default with GNU libc version 2.4 or later).
30143
30144With the latter choice the options
30145@option{-mstack-protector-guard-reg=@var{reg}} and
30146@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
30147which register to use as base register for reading the canary, and from what
30148offset from that base register. The default for those is as specified in the
30149relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides
30150the offset with a symbol reference to a canary in the TLS block.
30151
30152@item -mpcrel
30153@itemx -mno-pcrel
30154@opindex mpcrel
30155@opindex mno-pcrel
30156Generate (do not generate) pc-relative addressing. The @option{-mpcrel}
30157option requires that the medium code model (@option{-mcmodel=medium})
30158and prefixed addressing (@option{-mprefixed}) options are enabled.
30159
30160@item -mprefixed
30161@itemx -mno-prefixed
30162@opindex mprefixed
30163@opindex mno-prefixed
30164Generate (do not generate) addressing modes using prefixed load and
30165store instructions. The @option{-mprefixed} option requires that
30166the option @option{-mcpu=power10} (or later) is enabled.
30167
30168@item -mmma
30169@itemx -mno-mma
30170@opindex mmma
30171@opindex mno-mma
30172Generate (do not generate) the MMA instructions. The @option{-mma}
30173option requires that the option @option{-mcpu=power10} (or later)
30174is enabled.
30175
30176@item -mrop-protect
30177@itemx -mno-rop-protect
30178@opindex mrop-protect
30179@opindex mno-rop-protect
30180Generate (do not generate) ROP protection instructions when the target
30181processor supports them. Currently this option disables the shrink-wrap
30182optimization (@option{-fshrink-wrap}).
30183
30184@item -mprivileged
30185@itemx -mno-privileged
30186@opindex mprivileged
30187@opindex mno-privileged
30188Generate (do not generate) code that will run in privileged state.
30189
30190@item -mblock-ops-unaligned-vsx
30191@itemx -mno-block-ops-unaligned-vsx
30192@opindex block-ops-unaligned-vsx
30193@opindex no-block-ops-unaligned-vsx
30194Generate (do not generate) unaligned vsx loads and stores for
30195inline expansion of @code{memcpy} and @code{memmove}.
30196
30197@item --param rs6000-vect-unroll-limit=
30198The vectorizer will check with target information to determine whether it
30199would be beneficial to unroll the main vectorized loop and by how much. This
30200parameter sets the upper bound of how much the vectorizer will unroll the main
30201loop. The default value is four.
30202
30203@end table
30204
30205@node RX Options
30206@subsection RX Options
30207@cindex RX Options
30208
30209These command-line options are defined for RX targets:
30210
30211@table @gcctabopt
30212@item -m64bit-doubles
30213@itemx -m32bit-doubles
30214@opindex m64bit-doubles
30215@opindex m32bit-doubles
30216Make the @code{double} data type be 64 bits (@option{-m64bit-doubles})
30217or 32 bits (@option{-m32bit-doubles}) in size. The default is
30218@option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only
30219works on 32-bit values, which is why the default is
30220@option{-m32bit-doubles}.
30221
30222@item -fpu
30223@itemx -nofpu
30224@opindex fpu
30225@opindex nofpu
30226Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX
30227floating-point hardware. The default is enabled for the RX600
30228series and disabled for the RX200 series.
30229
30230Floating-point instructions are only generated for 32-bit floating-point
30231values, however, so the FPU hardware is not used for doubles if the
30232@option{-m64bit-doubles} option is used.
30233
30234@emph{Note} If the @option{-fpu} option is enabled then
30235@option{-funsafe-math-optimizations} is also enabled automatically.
30236This is because the RX FPU instructions are themselves unsafe.
30237
30238@item -mcpu=@var{name}
30239@opindex mcpu
30240Selects the type of RX CPU to be targeted. Currently three types are
30241supported, the generic @samp{RX600} and @samp{RX200} series hardware and
30242the specific @samp{RX610} CPU. The default is @samp{RX600}.
30243
30244The only difference between @samp{RX600} and @samp{RX610} is that the
30245@samp{RX610} does not support the @code{MVTIPL} instruction.
30246
30247The @samp{RX200} series does not have a hardware floating-point unit
30248and so @option{-nofpu} is enabled by default when this type is
30249selected.
30250
30251@item -mbig-endian-data
30252@itemx -mlittle-endian-data
30253@opindex mbig-endian-data
30254@opindex mlittle-endian-data
30255Store data (but not code) in the big-endian format. The default is
30256@option{-mlittle-endian-data}, i.e.@: to store data in the little-endian
30257format.
30258
30259@item -msmall-data-limit=@var{N}
30260@opindex msmall-data-limit
30261Specifies the maximum size in bytes of global and static variables
30262which can be placed into the small data area. Using the small data
30263area can lead to smaller and faster code, but the size of area is
30264limited and it is up to the programmer to ensure that the area does
30265not overflow. Also when the small data area is used one of the RX's
30266registers (usually @code{r13}) is reserved for use pointing to this
30267area, so it is no longer available for use by the compiler. This
30268could result in slower and/or larger code if variables are pushed onto
30269the stack instead of being held in this register.
30270
30271Note, common variables (variables that have not been initialized) and
30272constants are not placed into the small data area as they are assigned
30273to other sections in the output executable.
30274
30275The default value is zero, which disables this feature. Note, this
30276feature is not enabled by default with higher optimization levels
30277(@option{-O2} etc) because of the potentially detrimental effects of
30278reserving a register. It is up to the programmer to experiment and
30279discover whether this feature is of benefit to their program. See the
30280description of the @option{-mpid} option for a description of how the
30281actual register to hold the small data area pointer is chosen.
30282
30283@item -msim
30284@itemx -mno-sim
30285@opindex msim
30286@opindex mno-sim
30287Use the simulator runtime. The default is to use the libgloss
30288board-specific runtime.
30289
30290@item -mas100-syntax
30291@itemx -mno-as100-syntax
30292@opindex mas100-syntax
30293@opindex mno-as100-syntax
30294When generating assembler output use a syntax that is compatible with
30295Renesas's AS100 assembler. This syntax can also be handled by the GAS
30296assembler, but it has some restrictions so it is not generated by default.
30297
30298@item -mmax-constant-size=@var{N}
30299@opindex mmax-constant-size
30300Specifies the maximum size, in bytes, of a constant that can be used as
30301an operand in a RX instruction. Although the RX instruction set does
30302allow constants of up to 4 bytes in length to be used in instructions,
30303a longer value equates to a longer instruction. Thus in some
30304circumstances it can be beneficial to restrict the size of constants
30305that are used in instructions. Constants that are too big are instead
30306placed into a constant pool and referenced via register indirection.
30307
30308The value @var{N} can be between 0 and 4. A value of 0 (the default)
30309or 4 means that constants of any size are allowed.
30310
30311@item -mrelax
30312@opindex mrelax
30313Enable linker relaxation. Linker relaxation is a process whereby the
30314linker attempts to reduce the size of a program by finding shorter
30315versions of various instructions. Disabled by default.
30316
30317@item -mint-register=@var{N}
30318@opindex mint-register
30319Specify the number of registers to reserve for fast interrupt handler
30320functions. The value @var{N} can be between 0 and 4. A value of 1
30321means that register @code{r13} is reserved for the exclusive use
30322of fast interrupt handlers. A value of 2 reserves @code{r13} and
30323@code{r12}. A value of 3 reserves @code{r13}, @code{r12} and
30324@code{r11}, and a value of 4 reserves @code{r13} through @code{r10}.
30325A value of 0, the default, does not reserve any registers.
30326
30327@item -msave-acc-in-interrupts
30328@opindex msave-acc-in-interrupts
30329Specifies that interrupt handler functions should preserve the
30330accumulator register. This is only necessary if normal code might use
30331the accumulator register, for example because it performs 64-bit
30332multiplications. The default is to ignore the accumulator as this
30333makes the interrupt handlers faster.
30334
30335@item -mpid
30336@itemx -mno-pid
30337@opindex mpid
30338@opindex mno-pid
30339Enables the generation of position independent data. When enabled any
30340access to constant data is done via an offset from a base address
30341held in a register. This allows the location of constant data to be
30342determined at run time without requiring the executable to be
30343relocated, which is a benefit to embedded applications with tight
30344memory constraints. Data that can be modified is not affected by this
30345option.
30346
30347Note, using this feature reserves a register, usually @code{r13}, for
30348the constant data base address. This can result in slower and/or
30349larger code, especially in complicated functions.
30350
30351The actual register chosen to hold the constant data base address
30352depends upon whether the @option{-msmall-data-limit} and/or the
30353@option{-mint-register} command-line options are enabled. Starting
30354with register @code{r13} and proceeding downwards, registers are
30355allocated first to satisfy the requirements of @option{-mint-register},
30356then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it
30357is possible for the small data area register to be @code{r8} if both
30358@option{-mint-register=4} and @option{-mpid} are specified on the
30359command line.
30360
30361By default this feature is not enabled. The default can be restored
30362via the @option{-mno-pid} command-line option.
30363
30364@item -mno-warn-multiple-fast-interrupts
30365@itemx -mwarn-multiple-fast-interrupts
30366@opindex mno-warn-multiple-fast-interrupts
30367@opindex mwarn-multiple-fast-interrupts
30368Prevents GCC from issuing a warning message if it finds more than one
30369fast interrupt handler when it is compiling a file. The default is to
30370issue a warning for each extra fast interrupt handler found, as the RX
30371only supports one such interrupt.
30372
30373@item -mallow-string-insns
30374@itemx -mno-allow-string-insns
30375@opindex mallow-string-insns
30376@opindex mno-allow-string-insns
30377Enables or disables the use of the string manipulation instructions
30378@code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL}
30379@code{SWHILE} and also the @code{RMPA} instruction. These
30380instructions may prefetch data, which is not safe to do if accessing
30381an I/O register. (See section 12.2.7 of the RX62N Group User's Manual
30382for more information).
30383
30384The default is to allow these instructions, but it is not possible for
30385GCC to reliably detect all circumstances where a string instruction
30386might be used to access an I/O register, so their use cannot be
30387disabled automatically. Instead it is reliant upon the programmer to
30388use the @option{-mno-allow-string-insns} option if their program
30389accesses I/O space.
30390
30391When the instructions are enabled GCC defines the C preprocessor
30392symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the
30393symbol @code{__RX_DISALLOW_STRING_INSNS__}.
30394
30395@item -mjsr
30396@itemx -mno-jsr
30397@opindex mjsr
30398@opindex mno-jsr
30399Use only (or not only) @code{JSR} instructions to access functions.
30400This option can be used when code size exceeds the range of @code{BSR}
30401instructions. Note that @option{-mno-jsr} does not mean to not use
30402@code{JSR} but instead means that any type of branch may be used.
30403@end table
30404
30405@emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}}
30406has special significance to the RX port when used with the
30407@code{interrupt} function attribute. This attribute indicates a
30408function intended to process fast interrupts. GCC ensures
30409that it only uses the registers @code{r10}, @code{r11}, @code{r12}
30410and/or @code{r13} and only provided that the normal use of the
30411corresponding registers have been restricted via the
30412@option{-ffixed-@var{reg}} or @option{-mint-register} command-line
30413options.
30414
30415@node S/390 and zSeries Options
30416@subsection S/390 and zSeries Options
30417@cindex S/390 and zSeries Options
30418
30419These are the @samp{-m} options defined for the S/390 and zSeries architecture.
30420
30421@table @gcctabopt
30422@item -mhard-float
30423@itemx -msoft-float
30424@opindex mhard-float
30425@opindex msoft-float
30426Use (do not use) the hardware floating-point instructions and registers
30427for floating-point operations. When @option{-msoft-float} is specified,
30428functions in @file{libgcc.a} are used to perform floating-point
30429operations. When @option{-mhard-float} is specified, the compiler
30430generates IEEE floating-point instructions. This is the default.
30431
30432@item -mhard-dfp
30433@itemx -mno-hard-dfp
30434@opindex mhard-dfp
30435@opindex mno-hard-dfp
30436Use (do not use) the hardware decimal-floating-point instructions for
30437decimal-floating-point operations. When @option{-mno-hard-dfp} is
30438specified, functions in @file{libgcc.a} are used to perform
30439decimal-floating-point operations. When @option{-mhard-dfp} is
30440specified, the compiler generates decimal-floating-point hardware
30441instructions. This is the default for @option{-march=z9-ec} or higher.
30442
30443@item -mlong-double-64
30444@itemx -mlong-double-128
30445@opindex mlong-double-64
30446@opindex mlong-double-128
30447These switches control the size of @code{long double} type. A size
30448of 64 bits makes the @code{long double} type equivalent to the @code{double}
30449type. This is the default.
30450
30451@item -mbackchain
30452@itemx -mno-backchain
30453@opindex mbackchain
30454@opindex mno-backchain
30455Store (do not store) the address of the caller's frame as backchain pointer
30456into the callee's stack frame.
30457A backchain may be needed to allow debugging using tools that do not understand
30458DWARF call frame information.
30459When @option{-mno-packed-stack} is in effect, the backchain pointer is stored
30460at the bottom of the stack frame; when @option{-mpacked-stack} is in effect,
30461the backchain is placed into the topmost word of the 96/160 byte register
30462save area.
30463
30464In general, code compiled with @option{-mbackchain} is call-compatible with
30465code compiled with @option{-mno-backchain}; however, use of the backchain
30466for debugging purposes usually requires that the whole binary is built with
30467@option{-mbackchain}. Note that the combination of @option{-mbackchain},
30468@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30469to build a linux kernel use @option{-msoft-float}.
30470
30471The default is to not maintain the backchain.
30472
30473@item -mpacked-stack
30474@itemx -mno-packed-stack
30475@opindex mpacked-stack
30476@opindex mno-packed-stack
30477Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is
30478specified, the compiler uses the all fields of the 96/160 byte register save
30479area only for their default purpose; unused fields still take up stack space.
30480When @option{-mpacked-stack} is specified, register save slots are densely
30481packed at the top of the register save area; unused space is reused for other
30482purposes, allowing for more efficient use of the available stack space.
30483However, when @option{-mbackchain} is also in effect, the topmost word of
30484the save area is always used to store the backchain, and the return address
30485register is always saved two words below the backchain.
30486
30487As long as the stack frame backchain is not used, code generated with
30488@option{-mpacked-stack} is call-compatible with code generated with
30489@option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for
30490S/390 or zSeries generated code that uses the stack frame backchain at run
30491time, not just for debugging purposes. Such code is not call-compatible
30492with code compiled with @option{-mpacked-stack}. Also, note that the
30493combination of @option{-mbackchain},
30494@option{-mpacked-stack} and @option{-mhard-float} is not supported. In order
30495to build a linux kernel use @option{-msoft-float}.
30496
30497The default is to not use the packed stack layout.
30498
30499@item -msmall-exec
30500@itemx -mno-small-exec
30501@opindex msmall-exec
30502@opindex mno-small-exec
30503Generate (or do not generate) code using the @code{bras} instruction
30504to do subroutine calls.
30505This only works reliably if the total executable size does not
30506exceed 64k. The default is to use the @code{basr} instruction instead,
30507which does not have this limitation.
30508
30509@item -m64
30510@itemx -m31
30511@opindex m64
30512@opindex m31
30513When @option{-m31} is specified, generate code compliant to the
30514GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate
30515code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in
30516particular to generate 64-bit instructions. For the @samp{s390}
30517targets, the default is @option{-m31}, while the @samp{s390x}
30518targets default to @option{-m64}.
30519
30520@item -mzarch
30521@itemx -mesa
30522@opindex mzarch
30523@opindex mesa
30524When @option{-mzarch} is specified, generate code using the
30525instructions available on z/Architecture.
30526When @option{-mesa} is specified, generate code using the
30527instructions available on ESA/390. Note that @option{-mesa} is
30528not possible with @option{-m64}.
30529When generating code compliant to the GNU/Linux for S/390 ABI,
30530the default is @option{-mesa}. When generating code compliant
30531to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}.
30532
30533@item -mhtm
30534@itemx -mno-htm
30535@opindex mhtm
30536@opindex mno-htm
30537The @option{-mhtm} option enables a set of builtins making use of
30538instructions available with the transactional execution facility
30539introduced with the IBM zEnterprise EC12 machine generation
30540@ref{S/390 System z Built-in Functions}.
30541@option{-mhtm} is enabled by default when using @option{-march=zEC12}.
30542
30543@item -mvx
30544@itemx -mno-vx
30545@opindex mvx
30546@opindex mno-vx
30547When @option{-mvx} is specified, generate code using the instructions
30548available with the vector extension facility introduced with the IBM
30549z13 machine generation.
30550This option changes the ABI for some vector type values with regard to
30551alignment and calling conventions. In case vector type values are
30552being used in an ABI-relevant context a GAS @samp{.gnu_attribute}
30553command will be added to mark the resulting binary with the ABI used.
30554@option{-mvx} is enabled by default when using @option{-march=z13}.
30555
30556@item -mzvector
30557@itemx -mno-zvector
30558@opindex mzvector
30559@opindex mno-zvector
30560The @option{-mzvector} option enables vector language extensions and
30561builtins using instructions available with the vector extension
30562facility introduced with the IBM z13 machine generation.
30563This option adds support for @samp{vector} to be used as a keyword to
30564define vector type variables and arguments. @samp{vector} is only
30565available when GNU extensions are enabled. It will not be expanded
30566when requesting strict standard compliance e.g.@: with @option{-std=c99}.
30567In addition to the GCC low-level builtins @option{-mzvector} enables
30568a set of builtins added for compatibility with AltiVec-style
30569implementations like Power and Cell. In order to make use of these
30570builtins the header file @file{vecintrin.h} needs to be included.
30571@option{-mzvector} is disabled by default.
30572
30573@item -mmvcle
30574@itemx -mno-mvcle
30575@opindex mmvcle
30576@opindex mno-mvcle
30577Generate (or do not generate) code using the @code{mvcle} instruction
30578to perform block moves. When @option{-mno-mvcle} is specified,
30579use a @code{mvc} loop instead. This is the default unless optimizing for
30580size.
30581
30582@item -mdebug
30583@itemx -mno-debug
30584@opindex mdebug
30585@opindex mno-debug
30586Print (or do not print) additional debug information when compiling.
30587The default is to not print debug information.
30588
30589@item -march=@var{cpu-type}
30590@opindex march
30591Generate code that runs on @var{cpu-type}, which is the name of a
30592system representing a certain processor type. Possible values for
30593@var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6},
30594@samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8},
30595@samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11},
30596@samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13},
30597@samp{z16}/@samp{arch14}, and @samp{native}.
30598
30599The default is @option{-march=z900}.
30600
30601Specifying @samp{native} as cpu type can be used to select the best
30602architecture option for the host processor.
30603@option{-march=native} has no effect if GCC does not recognize the
30604processor.
30605
30606@item -mtune=@var{cpu-type}
30607@opindex mtune
30608Tune to @var{cpu-type} everything applicable about the generated code,
30609except for the ABI and the set of available instructions.
30610The list of @var{cpu-type} values is the same as for @option{-march}.
30611The default is the value used for @option{-march}.
30612
30613@item -mtpf-trace
30614@itemx -mno-tpf-trace
30615@opindex mtpf-trace
30616@opindex mno-tpf-trace
30617Generate code that adds (does not add) in TPF OS specific branches to trace
30618routines in the operating system. This option is off by default, even
30619when compiling for the TPF OS@.
30620
30621@item -mtpf-trace-skip
30622@itemx -mno-tpf-trace-skip
30623@opindex mtpf-trace-skip
30624@opindex mno-tpf-trace-skip
30625Generate code that changes (does not change) the default branch
30626targets enabled by @option{-mtpf-trace} to point to specialized trace
30627routines providing the ability of selectively skipping function trace
30628entries for the TPF OS. This option is off by default, even when
30629compiling for the TPF OS and specifying @option{-mtpf-trace}.
30630
30631@item -mfused-madd
30632@itemx -mno-fused-madd
30633@opindex mfused-madd
30634@opindex mno-fused-madd
30635Generate code that uses (does not use) the floating-point multiply and
30636accumulate instructions. These instructions are generated by default if
30637hardware floating point is used.
30638
30639@item -mwarn-framesize=@var{framesize}
30640@opindex mwarn-framesize
30641Emit a warning if the current function exceeds the given frame size. Because
30642this is a compile-time check it doesn't need to be a real problem when the program
30643runs. It is intended to identify functions that most probably cause
30644a stack overflow. It is useful to be used in an environment with limited stack
30645size e.g.@: the linux kernel.
30646
30647@item -mwarn-dynamicstack
30648@opindex mwarn-dynamicstack
30649Emit a warning if the function calls @code{alloca} or uses dynamically-sized
30650arrays. This is generally a bad idea with a limited stack size.
30651
30652@item -mstack-guard=@var{stack-guard}
30653@itemx -mstack-size=@var{stack-size}
30654@opindex mstack-guard
30655@opindex mstack-size
30656If these options are provided the S/390 back end emits additional instructions in
30657the function prologue that trigger a trap if the stack size is @var{stack-guard}
30658bytes above the @var{stack-size} (remember that the stack on S/390 grows downward).
30659If the @var{stack-guard} option is omitted the smallest power of 2 larger than
30660the frame size of the compiled function is chosen.
30661These options are intended to be used to help debugging stack overflow problems.
30662The additionally emitted code causes only little overhead and hence can also be
30663used in production-like systems without greater performance degradation. The given
30664values have to be exact powers of 2 and @var{stack-size} has to be greater than
30665@var{stack-guard} without exceeding 64k.
30666In order to be efficient the extra code makes the assumption that the stack starts
30667at an address aligned to the value given by @var{stack-size}.
30668The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
30669
30670@item -mhotpatch=@var{pre-halfwords},@var{post-halfwords}
30671@opindex mhotpatch
30672If the hotpatch option is enabled, a ``hot-patching'' function
30673prologue is generated for all functions in the compilation unit.
30674The funtion label is prepended with the given number of two-byte
30675NOP instructions (@var{pre-halfwords}, maximum 1000000). After
30676the label, 2 * @var{post-halfwords} bytes are appended, using the
30677largest NOP like instructions the architecture allows (maximum
306781000000).
30679
30680If both arguments are zero, hotpatching is disabled.
30681
30682This option can be overridden for individual functions with the
30683@code{hotpatch} attribute.
30684@end table
30685
d77de738
ML
30686@node SH Options
30687@subsection SH Options
30688
30689These @samp{-m} options are defined for the SH implementations:
30690
30691@table @gcctabopt
30692@item -m1
30693@opindex m1
30694Generate code for the SH1.
30695
30696@item -m2
30697@opindex m2
30698Generate code for the SH2.
30699
30700@item -m2e
30701Generate code for the SH2e.
30702
30703@item -m2a-nofpu
30704@opindex m2a-nofpu
30705Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way
30706that the floating-point unit is not used.
30707
30708@item -m2a-single-only
30709@opindex m2a-single-only
30710Generate code for the SH2a-FPU, in such a way that no double-precision
30711floating-point operations are used.
30712
30713@item -m2a-single
30714@opindex m2a-single
30715Generate code for the SH2a-FPU assuming the floating-point unit is in
30716single-precision mode by default.
30717
30718@item -m2a
30719@opindex m2a
30720Generate code for the SH2a-FPU assuming the floating-point unit is in
30721double-precision mode by default.
30722
30723@item -m3
30724@opindex m3
30725Generate code for the SH3.
30726
30727@item -m3e
30728@opindex m3e
30729Generate code for the SH3e.
30730
30731@item -m4-nofpu
30732@opindex m4-nofpu
30733Generate code for the SH4 without a floating-point unit.
30734
30735@item -m4-single-only
30736@opindex m4-single-only
30737Generate code for the SH4 with a floating-point unit that only
30738supports single-precision arithmetic.
30739
30740@item -m4-single
30741@opindex m4-single
30742Generate code for the SH4 assuming the floating-point unit is in
30743single-precision mode by default.
30744
30745@item -m4
30746@opindex m4
30747Generate code for the SH4.
30748
30749@item -m4-100
30750@opindex m4-100
30751Generate code for SH4-100.
30752
30753@item -m4-100-nofpu
30754@opindex m4-100-nofpu
30755Generate code for SH4-100 in such a way that the
30756floating-point unit is not used.
30757
30758@item -m4-100-single
30759@opindex m4-100-single
30760Generate code for SH4-100 assuming the floating-point unit is in
30761single-precision mode by default.
30762
30763@item -m4-100-single-only
30764@opindex m4-100-single-only
30765Generate code for SH4-100 in such a way that no double-precision
30766floating-point operations are used.
30767
30768@item -m4-200
30769@opindex m4-200
30770Generate code for SH4-200.
30771
30772@item -m4-200-nofpu
30773@opindex m4-200-nofpu
30774Generate code for SH4-200 without in such a way that the
30775floating-point unit is not used.
30776
30777@item -m4-200-single
30778@opindex m4-200-single
30779Generate code for SH4-200 assuming the floating-point unit is in
30780single-precision mode by default.
30781
30782@item -m4-200-single-only
30783@opindex m4-200-single-only
30784Generate code for SH4-200 in such a way that no double-precision
30785floating-point operations are used.
30786
30787@item -m4-300
30788@opindex m4-300
30789Generate code for SH4-300.
30790
30791@item -m4-300-nofpu
30792@opindex m4-300-nofpu
30793Generate code for SH4-300 without in such a way that the
30794floating-point unit is not used.
30795
30796@item -m4-300-single
30797@opindex m4-300-single
30798Generate code for SH4-300 in such a way that no double-precision
30799floating-point operations are used.
30800
30801@item -m4-300-single-only
30802@opindex m4-300-single-only
30803Generate code for SH4-300 in such a way that no double-precision
30804floating-point operations are used.
30805
30806@item -m4-340
30807@opindex m4-340
30808Generate code for SH4-340 (no MMU, no FPU).
30809
30810@item -m4-500
30811@opindex m4-500
30812Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the
30813assembler.
30814
30815@item -m4a-nofpu
30816@opindex m4a-nofpu
30817Generate code for the SH4al-dsp, or for a SH4a in such a way that the
30818floating-point unit is not used.
30819
30820@item -m4a-single-only
30821@opindex m4a-single-only
30822Generate code for the SH4a, in such a way that no double-precision
30823floating-point operations are used.
30824
30825@item -m4a-single
30826@opindex m4a-single
30827Generate code for the SH4a assuming the floating-point unit is in
30828single-precision mode by default.
30829
30830@item -m4a
30831@opindex m4a
30832Generate code for the SH4a.
30833
30834@item -m4al
30835@opindex m4al
30836Same as @option{-m4a-nofpu}, except that it implicitly passes
30837@option{-dsp} to the assembler. GCC doesn't generate any DSP
30838instructions at the moment.
30839
30840@item -mb
30841@opindex mb
30842Compile code for the processor in big-endian mode.
30843
30844@item -ml
30845@opindex ml
30846Compile code for the processor in little-endian mode.
30847
30848@item -mdalign
30849@opindex mdalign
30850Align doubles at 64-bit boundaries. Note that this changes the calling
30851conventions, and thus some functions from the standard C library do
30852not work unless you recompile it first with @option{-mdalign}.
30853
30854@item -mrelax
30855@opindex mrelax
30856Shorten some address references at link time, when possible; uses the
30857linker option @option{-relax}.
30858
30859@item -mbigtable
30860@opindex mbigtable
30861Use 32-bit offsets in @code{switch} tables. The default is to use
3086216-bit offsets.
30863
30864@item -mbitops
30865@opindex mbitops
30866Enable the use of bit manipulation instructions on SH2A.
30867
30868@item -mfmovd
30869@opindex mfmovd
30870Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for
30871alignment constraints.
30872
30873@item -mrenesas
30874@opindex mrenesas
30875Comply with the calling conventions defined by Renesas.
30876
30877@item -mno-renesas
30878@opindex mno-renesas
30879Comply with the calling conventions defined for GCC before the Renesas
30880conventions were available. This option is the default for all
30881targets of the SH toolchain.
30882
30883@item -mnomacsave
30884@opindex mnomacsave
30885Mark the @code{MAC} register as call-clobbered, even if
30886@option{-mrenesas} is given.
30887
30888@item -mieee
30889@itemx -mno-ieee
30890@opindex mieee
30891@opindex mno-ieee
30892Control the IEEE compliance of floating-point comparisons, which affects the
30893handling of cases where the result of a comparison is unordered. By default
30894@option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is
30895enabled @option{-mno-ieee} is implicitly set, which results in faster
30896floating-point greater-equal and less-equal comparisons. The implicit settings
30897can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}.
30898
30899@item -minline-ic_invalidate
30900@opindex minline-ic_invalidate
30901Inline code to invalidate instruction cache entries after setting up
30902nested function trampolines.
30903This option has no effect if @option{-musermode} is in effect and the selected
30904code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi}
30905instruction.
30906If the selected code generation option does not allow the use of the @code{icbi}
30907instruction, and @option{-musermode} is not in effect, the inlined code
30908manipulates the instruction cache address array directly with an associative
30909write. This not only requires privileged mode at run time, but it also
30910fails if the cache line had been mapped via the TLB and has become unmapped.
30911
30912@item -misize
30913@opindex misize
30914Dump instruction size and location in the assembly code.
30915
30916@item -mpadstruct
30917@opindex mpadstruct
30918This option is deprecated. It pads structures to multiple of 4 bytes,
30919which is incompatible with the SH ABI@.
30920
30921@item -matomic-model=@var{model}
30922@opindex matomic-model=@var{model}
30923Sets the model of atomic operations and additional parameters as a comma
30924separated list. For details on the atomic built-in functions see
30925@ref{__atomic Builtins}. The following models and parameters are supported:
30926
30927@table @samp
30928
30929@item none
30930Disable compiler generated atomic sequences and emit library calls for atomic
30931operations. This is the default if the target is not @code{sh*-*-linux*}.
30932
30933@item soft-gusa
30934Generate GNU/Linux compatible gUSA software atomic sequences for the atomic
30935built-in functions. The generated atomic sequences require additional support
30936from the interrupt/exception handling code of the system and are only suitable
30937for SH3* and SH4* single-core systems. This option is enabled by default when
30938the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A,
30939this option also partially utilizes the hardware atomic instructions
30940@code{movli.l} and @code{movco.l} to create more efficient code, unless
30941@samp{strict} is specified.
30942
30943@item soft-tcb
30944Generate software atomic sequences that use a variable in the thread control
30945block. This is a variation of the gUSA sequences which can also be used on
30946SH1* and SH2* targets. The generated atomic sequences require additional
30947support from the interrupt/exception handling code of the system and are only
30948suitable for single-core systems. When using this model, the @samp{gbr-offset=}
30949parameter has to be specified as well.
30950
30951@item soft-imask
30952Generate software atomic sequences that temporarily disable interrupts by
30953setting @code{SR.IMASK = 1111}. This model works only when the program runs
30954in privileged mode and is only suitable for single-core systems. Additional
30955support from the interrupt/exception handling code of the system is not
30956required. This model is enabled by default when the target is
30957@code{sh*-*-linux*} and SH1* or SH2*.
30958
30959@item hard-llcs
30960Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l}
30961instructions only. This is only available on SH4A and is suitable for
30962multi-core systems. Since the hardware instructions support only 32 bit atomic
30963variables access to 8 or 16 bit variables is emulated with 32 bit accesses.
30964Code compiled with this option is also compatible with other software
30965atomic model interrupt/exception handling systems if executed on an SH4A
30966system. Additional support from the interrupt/exception handling code of the
30967system is not required for this model.
30968
30969@item gbr-offset=
30970This parameter specifies the offset in bytes of the variable in the thread
30971control block structure that should be used by the generated atomic sequences
30972when the @samp{soft-tcb} model has been selected. For other models this
30973parameter is ignored. The specified value must be an integer multiple of four
30974and in the range 0-1020.
30975
30976@item strict
30977This parameter prevents mixed usage of multiple atomic models, even if they
30978are compatible, and makes the compiler generate atomic sequences of the
30979specified model only.
30980
30981@end table
30982
30983@item -mtas
30984@opindex mtas
30985Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}.
30986Notice that depending on the particular hardware and software configuration
30987this can degrade overall performance due to the operand cache line flushes
30988that are implied by the @code{tas.b} instruction. On multi-core SH4A
30989processors the @code{tas.b} instruction must be used with caution since it
30990can result in data corruption for certain cache configurations.
30991
30992@item -mprefergot
30993@opindex mprefergot
30994When generating position-independent code, emit function calls using
30995the Global Offset Table instead of the Procedure Linkage Table.
30996
30997@item -musermode
30998@itemx -mno-usermode
30999@opindex musermode
31000@opindex mno-usermode
31001Don't allow (allow) the compiler generating privileged mode code. Specifying
31002@option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the
31003inlined code would not work in user mode. @option{-musermode} is the default
31004when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2*
31005@option{-musermode} has no effect, since there is no user mode.
31006
31007@item -multcost=@var{number}
31008@opindex multcost=@var{number}
31009Set the cost to assume for a multiply insn.
31010
31011@item -mdiv=@var{strategy}
31012@opindex mdiv=@var{strategy}
31013Set the division strategy to be used for integer division operations.
31014@var{strategy} can be one of:
31015
31016@table @samp
31017
31018@item call-div1
31019Calls a library function that uses the single-step division instruction
31020@code{div1} to perform the operation. Division by zero calculates an
31021unspecified result and does not trap. This is the default except for SH4,
31022SH2A and SHcompact.
31023
31024@item call-fp
31025Calls a library function that performs the operation in double precision
31026floating point. Division by zero causes a floating-point exception. This is
31027the default for SHcompact with FPU. Specifying this for targets that do not
31028have a double precision FPU defaults to @code{call-div1}.
31029
31030@item call-table
31031Calls a library function that uses a lookup table for small divisors and
31032the @code{div1} instruction with case distinction for larger divisors. Division
31033by zero calculates an unspecified result and does not trap. This is the default
31034for SH4. Specifying this for targets that do not have dynamic shift
31035instructions defaults to @code{call-div1}.
31036
31037@end table
31038
31039When a division strategy has not been specified the default strategy is
31040selected based on the current target. For SH2A the default strategy is to
31041use the @code{divs} and @code{divu} instructions instead of library function
31042calls.
31043
31044@item -maccumulate-outgoing-args
31045@opindex maccumulate-outgoing-args
31046Reserve space once for outgoing arguments in the function prologue rather
31047than around each call. Generally beneficial for performance and size. Also
31048needed for unwinding to avoid changing the stack frame around conditional code.
31049
31050@item -mdivsi3_libfunc=@var{name}
31051@opindex mdivsi3_libfunc=@var{name}
31052Set the name of the library function used for 32-bit signed division to
31053@var{name}.
31054This only affects the name used in the @samp{call} division strategies, and
31055the compiler still expects the same sets of input/output/clobbered registers as
31056if this option were not present.
31057
31058@item -mfixed-range=@var{register-range}
31059@opindex mfixed-range
31060Generate code treating the given register range as fixed registers.
31061A fixed register is one that the register allocator cannot use. This is
31062useful when compiling kernel code. A register range is specified as
31063two registers separated by a dash. Multiple register ranges can be
31064specified separated by a comma.
31065
31066@item -mbranch-cost=@var{num}
31067@opindex mbranch-cost=@var{num}
31068Assume @var{num} to be the cost for a branch instruction. Higher numbers
31069make the compiler try to generate more branch-free code if possible.
31070If not specified the value is selected depending on the processor type that
31071is being compiled for.
31072
31073@item -mzdcbranch
31074@itemx -mno-zdcbranch
31075@opindex mzdcbranch
31076@opindex mno-zdcbranch
31077Assume (do not assume) that zero displacement conditional branch instructions
31078@code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the
31079compiler prefers zero displacement branch code sequences. This is
31080enabled by default when generating code for SH4 and SH4A. It can be explicitly
31081disabled by specifying @option{-mno-zdcbranch}.
31082
31083@item -mcbranch-force-delay-slot
31084@opindex mcbranch-force-delay-slot
31085Force the usage of delay slots for conditional branches, which stuffs the delay
31086slot with a @code{nop} if a suitable instruction cannot be found. By default
31087this option is disabled. It can be enabled to work around hardware bugs as
31088found in the original SH7055.
31089
31090@item -mfused-madd
31091@itemx -mno-fused-madd
31092@opindex mfused-madd
31093@opindex mno-fused-madd
31094Generate code that uses (does not use) the floating-point multiply and
31095accumulate instructions. These instructions are generated by default
31096if hardware floating point is used. The machine-dependent
31097@option{-mfused-madd} option is now mapped to the machine-independent
31098@option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is
31099mapped to @option{-ffp-contract=off}.
31100
31101@item -mfsca
31102@itemx -mno-fsca
31103@opindex mfsca
31104@opindex mno-fsca
31105Allow or disallow the compiler to emit the @code{fsca} instruction for sine
31106and cosine approximations. The option @option{-mfsca} must be used in
31107combination with @option{-funsafe-math-optimizations}. It is enabled by default
31108when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine
31109approximations even if @option{-funsafe-math-optimizations} is in effect.
31110
31111@item -mfsrra
31112@itemx -mno-fsrra
31113@opindex mfsrra
31114@opindex mno-fsrra
31115Allow or disallow the compiler to emit the @code{fsrra} instruction for
31116reciprocal square root approximations. The option @option{-mfsrra} must be used
31117in combination with @option{-funsafe-math-optimizations} and
31118@option{-ffinite-math-only}. It is enabled by default when generating code for
31119SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations
31120even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are
31121in effect.
31122
31123@item -mpretend-cmove
31124@opindex mpretend-cmove
31125Prefer zero-displacement conditional branches for conditional move instruction
31126patterns. This can result in faster code on the SH4 processor.
31127
31128@item -mfdpic
31129@opindex fdpic
31130Generate code using the FDPIC ABI.
31131
31132@end table
31133
31134@node Solaris 2 Options
31135@subsection Solaris 2 Options
31136@cindex Solaris 2 options
31137
31138These @samp{-m} options are supported on Solaris 2:
31139
31140@table @gcctabopt
31141@item -mclear-hwcap
31142@opindex mclear-hwcap
31143@option{-mclear-hwcap} tells the compiler to remove the hardware
31144capabilities generated by the Solaris assembler. This is only necessary
31145when object files use ISA extensions not supported by the current
31146machine, but check at runtime whether or not to use them.
31147
31148@item -mimpure-text
31149@opindex mimpure-text
31150@option{-mimpure-text}, used in addition to @option{-shared}, tells
31151the compiler to not pass @option{-z text} to the linker when linking a
31152shared object. Using this option, you can link position-dependent
31153code into a shared object.
31154
31155@option{-mimpure-text} suppresses the ``relocations remain against
31156allocatable but non-writable sections'' linker error message.
31157However, the necessary relocations trigger copy-on-write, and the
31158shared object is not actually shared across processes. Instead of
31159using @option{-mimpure-text}, you should compile all source code with
31160@option{-fpic} or @option{-fPIC}.
31161
31162@end table
31163
31164These switches are supported in addition to the above on Solaris 2:
31165
31166@table @gcctabopt
31167@item -pthreads
31168@opindex pthreads
31169This is a synonym for @option{-pthread}.
31170@end table
31171
31172@node SPARC Options
31173@subsection SPARC Options
31174@cindex SPARC options
31175
31176These @samp{-m} options are supported on the SPARC:
31177
31178@table @gcctabopt
31179@item -mno-app-regs
31180@itemx -mapp-regs
31181@opindex mno-app-regs
31182@opindex mapp-regs
31183Specify @option{-mapp-regs} to generate output using the global registers
311842 through 4, which the SPARC SVR4 ABI reserves for applications. Like the
31185global register 1, each global register 2 through 4 is then treated as an
31186allocable register that is clobbered by function calls. This is the default.
31187
31188To be fully SVR4 ABI-compliant at the cost of some performance loss,
31189specify @option{-mno-app-regs}. You should compile libraries and system
31190software with this option.
31191
31192@item -mflat
31193@itemx -mno-flat
31194@opindex mflat
31195@opindex mno-flat
31196With @option{-mflat}, the compiler does not generate save/restore instructions
31197and uses a ``flat'' or single register window model. This model is compatible
31198with the regular register window model. The local registers and the input
31199registers (0--5) are still treated as ``call-saved'' registers and are
31200saved on the stack as needed.
31201
31202With @option{-mno-flat} (the default), the compiler generates save/restore
31203instructions (except for leaf functions). This is the normal operating mode.
31204
31205@item -mfpu
31206@itemx -mhard-float
31207@opindex mfpu
31208@opindex mhard-float
31209Generate output containing floating-point instructions. This is the
31210default.
31211
31212@item -mno-fpu
31213@itemx -msoft-float
31214@opindex mno-fpu
31215@opindex msoft-float
31216Generate output containing library calls for floating point.
31217@strong{Warning:} the requisite libraries are not available for all SPARC
31218targets. Normally the facilities of the machine's usual C compiler are
31219used, but this cannot be done directly in cross-compilation. You must make
31220your own arrangements to provide suitable library functions for
31221cross-compilation. The embedded targets @samp{sparc-*-aout} and
31222@samp{sparclite-*-*} do provide software floating-point support.
31223
31224@option{-msoft-float} changes the calling convention in the output file;
31225therefore, it is only useful if you compile @emph{all} of a program with
31226this option. In particular, you need to compile @file{libgcc.a}, the
31227library that comes with GCC, with @option{-msoft-float} in order for
31228this to work.
31229
31230@item -mhard-quad-float
31231@opindex mhard-quad-float
31232Generate output containing quad-word (long double) floating-point
31233instructions.
31234
31235@item -msoft-quad-float
31236@opindex msoft-quad-float
31237Generate output containing library calls for quad-word (long double)
31238floating-point instructions. The functions called are those specified
31239in the SPARC ABI@. This is the default.
31240
31241As of this writing, there are no SPARC implementations that have hardware
31242support for the quad-word floating-point instructions. They all invoke
31243a trap handler for one of these instructions, and then the trap handler
31244emulates the effect of the instruction. Because of the trap handler overhead,
31245this is much slower than calling the ABI library routines. Thus the
31246@option{-msoft-quad-float} option is the default.
31247
31248@item -mno-unaligned-doubles
31249@itemx -munaligned-doubles
31250@opindex mno-unaligned-doubles
31251@opindex munaligned-doubles
31252Assume that doubles have 8-byte alignment. This is the default.
31253
31254With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte
31255alignment only if they are contained in another type, or if they have an
31256absolute address. Otherwise, it assumes they have 4-byte alignment.
31257Specifying this option avoids some rare compatibility problems with code
31258generated by other compilers. It is not the default because it results
31259in a performance loss, especially for floating-point code.
31260
31261@item -muser-mode
31262@itemx -mno-user-mode
31263@opindex muser-mode
31264@opindex mno-user-mode
31265Do not generate code that can only run in supervisor mode. This is relevant
31266only for the @code{casa} instruction emitted for the LEON3 processor. This
31267is the default.
31268
31269@item -mfaster-structs
31270@itemx -mno-faster-structs
31271@opindex mfaster-structs
31272@opindex mno-faster-structs
31273With @option{-mfaster-structs}, the compiler assumes that structures
31274should have 8-byte alignment. This enables the use of pairs of
31275@code{ldd} and @code{std} instructions for copies in structure
31276assignment, in place of twice as many @code{ld} and @code{st} pairs.
31277However, the use of this changed alignment directly violates the SPARC
31278ABI@. Thus, it's intended only for use on targets where the developer
31279acknowledges that their resulting code is not directly in line with
31280the rules of the ABI@.
31281
31282@item -mstd-struct-return
31283@itemx -mno-std-struct-return
31284@opindex mstd-struct-return
31285@opindex mno-std-struct-return
31286With @option{-mstd-struct-return}, the compiler generates checking code
31287in functions returning structures or unions to detect size mismatches
31288between the two sides of function calls, as per the 32-bit ABI@.
31289
31290The default is @option{-mno-std-struct-return}. This option has no effect
31291in 64-bit mode.
31292
31293@item -mlra
31294@itemx -mno-lra
31295@opindex mlra
31296@opindex mno-lra
31297Enable Local Register Allocation. This is the default for SPARC since GCC 7
31298so @option{-mno-lra} needs to be passed to get old Reload.
31299
31300@item -mcpu=@var{cpu_type}
31301@opindex mcpu
31302Set the instruction set, register set, and instruction scheduling parameters
31303for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31304@samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc},
31305@samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite},
31306@samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701},
31307@samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara},
31308@samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and
31309@samp{m8}.
31310
31311Native Solaris and GNU/Linux toolchains also support the value @samp{native},
31312which selects the best architecture option for the host processor.
31313@option{-mcpu=native} has no effect if GCC does not recognize
31314the processor.
31315
31316Default instruction scheduling parameters are used for values that select
31317an architecture and not an implementation. These are @samp{v7}, @samp{v8},
31318@samp{sparclite}, @samp{sparclet}, @samp{v9}.
31319
31320Here is a list of each supported architecture and their supported
31321implementations.
31322
31323@table @asis
31324@item v7
31325cypress, leon3v7
31326
31327@item v8
31328supersparc, hypersparc, leon, leon3, leon5
31329
31330@item sparclite
31331f930, f934, sparclite86x
31332
31333@item sparclet
31334tsc701
31335
31336@item v9
31337ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4,
31338niagara7, m8
31339@end table
31340
31341By default (unless configured otherwise), GCC generates code for the V7
31342variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler
31343additionally optimizes it for the Cypress CY7C602 chip, as used in the
31344SPARCStation/SPARCServer 3xx series. This is also appropriate for the older
31345SPARCStation 1, 2, IPX etc.
31346
31347With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC
31348architecture. The only difference from V7 code is that the compiler emits
31349the integer multiply and integer divide instructions which exist in SPARC-V8
31350but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally
31351optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and
313522000 series.
31353
31354With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of
31355the SPARC architecture. This adds the integer multiply, integer divide step
31356and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7.
31357With @option{-mcpu=f930}, the compiler additionally optimizes it for the
31358Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With
31359@option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu
31360MB86934 chip, which is the more recent SPARClite with FPU@.
31361
31362With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of
31363the SPARC architecture. This adds the integer multiply, multiply/accumulate,
31364integer divide step and scan (@code{ffs}) instructions which exist in SPARClet
31365but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally
31366optimizes it for the TEMIC SPARClet chip.
31367
31368With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC
31369architecture. This adds 64-bit integer and floating-point move instructions,
313703 additional floating-point condition code registers and conditional move
31371instructions. With @option{-mcpu=ultrasparc}, the compiler additionally
31372optimizes it for the Sun UltraSPARC I/II/IIi chips. With
31373@option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the
31374Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With
31375@option{-mcpu=niagara}, the compiler additionally optimizes it for
31376Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler
31377additionally optimizes it for Sun UltraSPARC T2 chips. With
31378@option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun
31379UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler
31380additionally optimizes it for Sun UltraSPARC T4 chips. With
31381@option{-mcpu=niagara7}, the compiler additionally optimizes it for
31382Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler
31383additionally optimizes it for Oracle M8 chips.
31384
31385@item -mtune=@var{cpu_type}
31386@opindex mtune
31387Set the instruction scheduling parameters for machine type
31388@var{cpu_type}, but do not set the instruction set or register set that the
31389option @option{-mcpu=@var{cpu_type}} does.
31390
31391The same values for @option{-mcpu=@var{cpu_type}} can be used for
31392@option{-mtune=@var{cpu_type}}, but the only useful values are those
31393that select a particular CPU implementation. Those are
31394@samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon},
31395@samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934},
31396@samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc},
31397@samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3},
31398@samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris
31399and GNU/Linux toolchains, @samp{native} can also be used.
31400
31401@item -mv8plus
31402@itemx -mno-v8plus
31403@opindex mv8plus
31404@opindex mno-v8plus
31405With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The
31406difference from the V8 ABI is that the global and out registers are
31407considered 64 bits wide. This is enabled by default on Solaris in 32-bit
31408mode for all SPARC-V9 processors.
31409
31410@item -mvis
31411@itemx -mno-vis
31412@opindex mvis
31413@opindex mno-vis
31414With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC
31415Visual Instruction Set extensions. The default is @option{-mno-vis}.
31416
31417@item -mvis2
31418@itemx -mno-vis2
31419@opindex mvis2
31420@opindex mno-vis2
31421With @option{-mvis2}, GCC generates code that takes advantage of
31422version 2.0 of the UltraSPARC Visual Instruction Set extensions. The
31423default is @option{-mvis2} when targeting a cpu that supports such
31424instructions, such as UltraSPARC-III and later. Setting @option{-mvis2}
31425also sets @option{-mvis}.
31426
31427@item -mvis3
31428@itemx -mno-vis3
31429@opindex mvis3
31430@opindex mno-vis3
31431With @option{-mvis3}, GCC generates code that takes advantage of
31432version 3.0 of the UltraSPARC Visual Instruction Set extensions. The
31433default is @option{-mvis3} when targeting a cpu that supports such
31434instructions, such as niagara-3 and later. Setting @option{-mvis3}
31435also sets @option{-mvis2} and @option{-mvis}.
31436
31437@item -mvis4
31438@itemx -mno-vis4
31439@opindex mvis4
31440@opindex mno-vis4
31441With @option{-mvis4}, GCC generates code that takes advantage of
31442version 4.0 of the UltraSPARC Visual Instruction Set extensions. The
31443default is @option{-mvis4} when targeting a cpu that supports such
31444instructions, such as niagara-7 and later. Setting @option{-mvis4}
31445also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}.
31446
31447@item -mvis4b
31448@itemx -mno-vis4b
31449@opindex mvis4b
31450@opindex mno-vis4b
31451With @option{-mvis4b}, GCC generates code that takes advantage of
31452version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus
31453the additional VIS instructions introduced in the Oracle SPARC
31454Architecture 2017. The default is @option{-mvis4b} when targeting a
31455cpu that supports such instructions, such as m8 and later. Setting
31456@option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3},
31457@option{-mvis2} and @option{-mvis}.
31458
31459@item -mcbcond
31460@itemx -mno-cbcond
31461@opindex mcbcond
31462@opindex mno-cbcond
31463With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC
31464Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond}
31465when targeting a CPU that supports such instructions, such as Niagara-4 and
31466later.
31467
31468@item -mfmaf
31469@itemx -mno-fmaf
31470@opindex mfmaf
31471@opindex mno-fmaf
31472With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC
31473Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf}
31474when targeting a CPU that supports such instructions, such as Niagara-3 and
31475later.
31476
31477@item -mfsmuld
31478@itemx -mno-fsmuld
31479@opindex mfsmuld
31480@opindex mno-fsmuld
31481With @option{-mfsmuld}, GCC generates code that takes advantage of the
31482Floating-point Multiply Single to Double (FsMULd) instruction. The default is
31483@option{-mfsmuld} when targeting a CPU supporting the architecture versions V8
31484or V9 with FPU except @option{-mcpu=leon}.
31485
31486@item -mpopc
31487@itemx -mno-popc
31488@opindex mpopc
31489@opindex mno-popc
31490With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC
31491Population Count instruction. The default is @option{-mpopc}
31492when targeting a CPU that supports such an instruction, such as Niagara-2 and
31493later.
31494
31495@item -msubxc
31496@itemx -mno-subxc
31497@opindex msubxc
31498@opindex mno-subxc
31499With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC
31500Subtract-Extended-with-Carry instruction. The default is @option{-msubxc}
31501when targeting a CPU that supports such an instruction, such as Niagara-7 and
31502later.
31503
31504@item -mfix-at697f
31505@opindex mfix-at697f
31506Enable the documented workaround for the single erratum of the Atmel AT697F
31507processor (which corresponds to erratum #13 of the AT697E processor).
31508
31509@item -mfix-ut699
31510@opindex mfix-ut699
31511Enable the documented workarounds for the floating-point errata and the data
31512cache nullify errata of the UT699 processor.
31513
31514@item -mfix-ut700
31515@opindex mfix-ut700
31516Enable the documented workaround for the back-to-back store errata of
31517the UT699E/UT700 processor.
31518
31519@item -mfix-gr712rc
31520@opindex mfix-gr712rc
31521Enable the documented workaround for the back-to-back store errata of
31522the GR712RC processor.
31523@end table
31524
31525These @samp{-m} options are supported in addition to the above
31526on SPARC-V9 processors in 64-bit environments:
31527
31528@table @gcctabopt
31529@item -m32
31530@itemx -m64
31531@opindex m32
31532@opindex m64
31533Generate code for a 32-bit or 64-bit environment.
31534The 32-bit environment sets int, long and pointer to 32 bits.
31535The 64-bit environment sets int to 32 bits and long and pointer
31536to 64 bits.
31537
31538@item -mcmodel=@var{which}
31539@opindex mcmodel
31540Set the code model to one of
31541
31542@table @samp
31543@item medlow
31544The Medium/Low code model: 64-bit addresses, programs
31545must be linked in the low 32 bits of memory. Programs can be statically
31546or dynamically linked.
31547
31548@item medmid
31549The Medium/Middle code model: 64-bit addresses, programs
31550must be linked in the low 44 bits of memory, the text and data segments must
31551be less than 2GB in size and the data segment must be located within 2GB of
31552the text segment.
31553
31554@item medany
31555The Medium/Anywhere code model: 64-bit addresses, programs
31556may be linked anywhere in memory, the text and data segments must be less
31557than 2GB in size and the data segment must be located within 2GB of the
31558text segment.
31559
31560@item embmedany
31561The Medium/Anywhere code model for embedded systems:
3156264-bit addresses, the text and data segments must be less than 2GB in
31563size, both starting anywhere in memory (determined at link time). The
31564global register %g4 points to the base of the data segment. Programs
31565are statically linked and PIC is not supported.
31566@end table
31567
31568@item -mmemory-model=@var{mem-model}
31569@opindex mmemory-model
31570Set the memory model in force on the processor to one of
31571
31572@table @samp
31573@item default
31574The default memory model for the processor and operating system.
31575
31576@item rmo
31577Relaxed Memory Order
31578
31579@item pso
31580Partial Store Order
31581
31582@item tso
31583Total Store Order
31584
31585@item sc
31586Sequential Consistency
31587@end table
31588
31589These memory models are formally defined in Appendix D of the SPARC-V9
31590architecture manual, as set in the processor's @code{PSTATE.MM} field.
31591
31592@item -mstack-bias
31593@itemx -mno-stack-bias
31594@opindex mstack-bias
31595@opindex mno-stack-bias
31596With @option{-mstack-bias}, GCC assumes that the stack pointer, and
31597frame pointer if present, are offset by @minus{}2047 which must be added back
31598when making stack frame references. This is the default in 64-bit mode.
31599Otherwise, assume no such offset is present.
31600@end table
31601
31602@node System V Options
31603@subsection Options for System V
31604
31605These additional options are available on System V Release 4 for
31606compatibility with other compilers on those systems:
31607
31608@table @gcctabopt
31609@item -G
31610@opindex G
31611Create a shared object.
31612It is recommended that @option{-symbolic} or @option{-shared} be used instead.
31613
31614@item -Qy
31615@opindex Qy
31616Identify the versions of each tool used by the compiler, in a
31617@code{.ident} assembler directive in the output.
31618
31619@item -Qn
31620@opindex Qn
31621Refrain from adding @code{.ident} directives to the output file (this is
31622the default).
31623
31624@item -YP,@var{dirs}
31625@opindex YP
31626Search the directories @var{dirs}, and no others, for libraries
31627specified with @option{-l}.
31628
31629@item -Ym,@var{dir}
31630@opindex Ym
31631Look in the directory @var{dir} to find the M4 preprocessor.
31632The assembler uses this option.
31633@c This is supposed to go with a -Yd for predefined M4 macro files, but
31634@c the generic assembler that comes with Solaris takes just -Ym.
31635@end table
31636
31637@node V850 Options
31638@subsection V850 Options
31639@cindex V850 Options
31640
31641These @samp{-m} options are defined for V850 implementations:
31642
31643@table @gcctabopt
31644@item -mlong-calls
31645@itemx -mno-long-calls
31646@opindex mlong-calls
31647@opindex mno-long-calls
31648Treat all calls as being far away (near). If calls are assumed to be
31649far away, the compiler always loads the function's address into a
31650register, and calls indirect through the pointer.
31651
31652@item -mno-ep
31653@itemx -mep
31654@opindex mno-ep
31655@opindex mep
31656Do not optimize (do optimize) basic blocks that use the same index
31657pointer 4 or more times to copy pointer into the @code{ep} register, and
31658use the shorter @code{sld} and @code{sst} instructions. The @option{-mep}
31659option is on by default if you optimize.
31660
31661@item -mno-prolog-function
31662@itemx -mprolog-function
31663@opindex mno-prolog-function
31664@opindex mprolog-function
31665Do not use (do use) external functions to save and restore registers
31666at the prologue and epilogue of a function. The external functions
31667are slower, but use less code space if more than one function saves
31668the same number of registers. The @option{-mprolog-function} option
31669is on by default if you optimize.
31670
31671@item -mspace
31672@opindex mspace
31673Try to make the code as small as possible. At present, this just turns
31674on the @option{-mep} and @option{-mprolog-function} options.
31675
31676@item -mtda=@var{n}
31677@opindex mtda
31678Put static or global variables whose size is @var{n} bytes or less into
31679the tiny data area that register @code{ep} points to. The tiny data
31680area can hold up to 256 bytes in total (128 bytes for byte references).
31681
31682@item -msda=@var{n}
31683@opindex msda
31684Put static or global variables whose size is @var{n} bytes or less into
31685the small data area that register @code{gp} points to. The small data
31686area can hold up to 64 kilobytes.
31687
31688@item -mzda=@var{n}
31689@opindex mzda
31690Put static or global variables whose size is @var{n} bytes or less into
31691the first 32 kilobytes of memory.
31692
31693@item -mv850
31694@opindex mv850
31695Specify that the target processor is the V850.
31696
31697@item -mv850e3v5
31698@opindex mv850e3v5
31699Specify that the target processor is the V850E3V5. The preprocessor
31700constant @code{__v850e3v5__} is defined if this option is used.
31701
31702@item -mv850e2v4
31703@opindex mv850e2v4
31704Specify that the target processor is the V850E3V5. This is an alias for
31705the @option{-mv850e3v5} option.
31706
31707@item -mv850e2v3
31708@opindex mv850e2v3
31709Specify that the target processor is the V850E2V3. The preprocessor
31710constant @code{__v850e2v3__} is defined if this option is used.
31711
31712@item -mv850e2
31713@opindex mv850e2
31714Specify that the target processor is the V850E2. The preprocessor
31715constant @code{__v850e2__} is defined if this option is used.
31716
31717@item -mv850e1
31718@opindex mv850e1
31719Specify that the target processor is the V850E1. The preprocessor
31720constants @code{__v850e1__} and @code{__v850e__} are defined if
31721this option is used.
31722
31723@item -mv850es
31724@opindex mv850es
31725Specify that the target processor is the V850ES. This is an alias for
31726the @option{-mv850e1} option.
31727
31728@item -mv850e
31729@opindex mv850e
31730Specify that the target processor is the V850E@. The preprocessor
31731constant @code{__v850e__} is defined if this option is used.
31732
31733If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1}
31734nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5}
31735are defined then a default target processor is chosen and the
31736relevant @samp{__v850*__} preprocessor constant is defined.
31737
31738The preprocessor constants @code{__v850} and @code{__v851__} are always
31739defined, regardless of which processor variant is the target.
31740
31741@item -mdisable-callt
31742@itemx -mno-disable-callt
31743@opindex mdisable-callt
31744@opindex mno-disable-callt
31745This option suppresses generation of the @code{CALLT} instruction for the
31746v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850
31747architecture.
31748
31749This option is enabled by default when the RH850 ABI is
31750in use (see @option{-mrh850-abi}), and disabled by default when the
31751GCC ABI is in use. If @code{CALLT} instructions are being generated
31752then the C preprocessor symbol @code{__V850_CALLT__} is defined.
31753
31754@item -mrelax
31755@itemx -mno-relax
31756@opindex mrelax
31757@opindex mno-relax
31758Pass on (or do not pass on) the @option{-mrelax} command-line option
31759to the assembler.
31760
31761@item -mlong-jumps
31762@itemx -mno-long-jumps
31763@opindex mlong-jumps
31764@opindex mno-long-jumps
31765Disable (or re-enable) the generation of PC-relative jump instructions.
31766
31767@item -msoft-float
31768@itemx -mhard-float
31769@opindex msoft-float
31770@opindex mhard-float
31771Disable (or re-enable) the generation of hardware floating point
31772instructions. This option is only significant when the target
31773architecture is @samp{V850E2V3} or higher. If hardware floating point
31774instructions are being generated then the C preprocessor symbol
31775@code{__FPU_OK__} is defined, otherwise the symbol
31776@code{__NO_FPU__} is defined.
31777
31778@item -mloop
31779@opindex mloop
31780Enables the use of the e3v5 LOOP instruction. The use of this
31781instruction is not enabled by default when the e3v5 architecture is
31782selected because its use is still experimental.
31783
31784@item -mrh850-abi
31785@itemx -mghs
31786@opindex mrh850-abi
31787@opindex mghs
31788Enables support for the RH850 version of the V850 ABI. This is the
31789default. With this version of the ABI the following rules apply:
31790
31791@itemize
31792@item
31793Integer sized structures and unions are returned via a memory pointer
31794rather than a register.
31795
31796@item
31797Large structures and unions (more than 8 bytes in size) are passed by
31798value.
31799
31800@item
31801Functions are aligned to 16-bit boundaries.
31802
31803@item
31804The @option{-m8byte-align} command-line option is supported.
31805
31806@item
31807The @option{-mdisable-callt} command-line option is enabled by
31808default. The @option{-mno-disable-callt} command-line option is not
31809supported.
31810@end itemize
31811
31812When this version of the ABI is enabled the C preprocessor symbol
31813@code{__V850_RH850_ABI__} is defined.
31814
31815@item -mgcc-abi
31816@opindex mgcc-abi
31817Enables support for the old GCC version of the V850 ABI. With this
31818version of the ABI the following rules apply:
31819
31820@itemize
31821@item
31822Integer sized structures and unions are returned in register @code{r10}.
31823
31824@item
31825Large structures and unions (more than 8 bytes in size) are passed by
31826reference.
31827
31828@item
31829Functions are aligned to 32-bit boundaries, unless optimizing for
31830size.
31831
31832@item
31833The @option{-m8byte-align} command-line option is not supported.
31834
31835@item
31836The @option{-mdisable-callt} command-line option is supported but not
31837enabled by default.
31838@end itemize
31839
31840When this version of the ABI is enabled the C preprocessor symbol
31841@code{__V850_GCC_ABI__} is defined.
31842
31843@item -m8byte-align
31844@itemx -mno-8byte-align
31845@opindex m8byte-align
31846@opindex mno-8byte-align
31847Enables support for @code{double} and @code{long long} types to be
31848aligned on 8-byte boundaries. The default is to restrict the
31849alignment of all objects to at most 4-bytes. When
31850@option{-m8byte-align} is in effect the C preprocessor symbol
31851@code{__V850_8BYTE_ALIGN__} is defined.
31852
31853@item -mbig-switch
31854@opindex mbig-switch
31855Generate code suitable for big switch tables. Use this option only if
31856the assembler/linker complain about out of range branches within a switch
31857table.
31858
31859@item -mapp-regs
31860@opindex mapp-regs
31861This option causes r2 and r5 to be used in the code generated by
31862the compiler. This setting is the default.
31863
31864@item -mno-app-regs
31865@opindex mno-app-regs
31866This option causes r2 and r5 to be treated as fixed registers.
31867
31868@end table
31869
31870@node VAX Options
31871@subsection VAX Options
31872@cindex VAX options
31873
31874These @samp{-m} options are defined for the VAX:
31875
31876@table @gcctabopt
31877@item -munix
31878@opindex munix
31879Do not output certain jump instructions (@code{aobleq} and so on)
31880that the Unix assembler for the VAX cannot handle across long
31881ranges.
31882
31883@item -mgnu
31884@opindex mgnu
31885Do output those jump instructions, on the assumption that the
31886GNU assembler is being used.
31887
31888@item -mg
31889@opindex mg
31890Output code for G-format floating-point numbers instead of D-format.
31891
31892@item -mlra
31893@itemx -mno-lra
31894@opindex mlra
31895@opindex mno-lra
31896Enable Local Register Allocation. This is still experimental for the VAX,
31897so by default the compiler uses standard reload.
31898@end table
31899
31900@node Visium Options
31901@subsection Visium Options
31902@cindex Visium options
31903
31904@table @gcctabopt
31905
31906@item -mdebug
31907@opindex mdebug
31908A program which performs file I/O and is destined to run on an MCM target
31909should be linked with this option. It causes the libraries libc.a and
31910libdebug.a to be linked. The program should be run on the target under
31911the control of the GDB remote debugging stub.
31912
31913@item -msim
31914@opindex msim
31915A program which performs file I/O and is destined to run on the simulator
31916should be linked with option. This causes libraries libc.a and libsim.a to
31917be linked.
31918
31919@item -mfpu
31920@itemx -mhard-float
31921@opindex mfpu
31922@opindex mhard-float
31923Generate code containing floating-point instructions. This is the
31924default.
31925
31926@item -mno-fpu
31927@itemx -msoft-float
31928@opindex mno-fpu
31929@opindex msoft-float
31930Generate code containing library calls for floating-point.
31931
31932@option{-msoft-float} changes the calling convention in the output file;
31933therefore, it is only useful if you compile @emph{all} of a program with
31934this option. In particular, you need to compile @file{libgcc.a}, the
31935library that comes with GCC, with @option{-msoft-float} in order for
31936this to work.
31937
31938@item -mcpu=@var{cpu_type}
31939@opindex mcpu
31940Set the instruction set, register set, and instruction scheduling parameters
31941for machine type @var{cpu_type}. Supported values for @var{cpu_type} are
31942@samp{mcm}, @samp{gr5} and @samp{gr6}.
31943
31944@samp{mcm} is a synonym of @samp{gr5} present for backward compatibility.
31945
31946By default (unless configured otherwise), GCC generates code for the GR5
31947variant of the Visium architecture.
31948
31949With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium
31950architecture. The only difference from GR5 code is that the compiler will
31951generate block move instructions.
31952
31953@item -mtune=@var{cpu_type}
31954@opindex mtune
31955Set the instruction scheduling parameters for machine type @var{cpu_type},
31956but do not set the instruction set or register set that the option
31957@option{-mcpu=@var{cpu_type}} would.
31958
31959@item -msv-mode
31960@opindex msv-mode
31961Generate code for the supervisor mode, where there are no restrictions on
31962the access to general registers. This is the default.
31963
31964@item -muser-mode
31965@opindex muser-mode
31966Generate code for the user mode, where the access to some general registers
31967is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this
31968mode; on the GR6, only registers r29 to r31 are affected.
31969@end table
31970
31971@node VMS Options
31972@subsection VMS Options
31973
31974These @samp{-m} options are defined for the VMS implementations:
31975
31976@table @gcctabopt
31977@item -mvms-return-codes
31978@opindex mvms-return-codes
31979Return VMS condition codes from @code{main}. The default is to return POSIX-style
31980condition (e.g.@: error) codes.
31981
31982@item -mdebug-main=@var{prefix}
31983@opindex mdebug-main=@var{prefix}
31984Flag the first routine whose name starts with @var{prefix} as the main
31985routine for the debugger.
31986
31987@item -mmalloc64
31988@opindex mmalloc64
31989Default to 64-bit memory allocation routines.
31990
31991@item -mpointer-size=@var{size}
31992@opindex mpointer-size=@var{size}
31993Set the default size of pointers. Possible options for @var{size} are
31994@samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long}
31995for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers.
31996The later option disables @code{pragma pointer_size}.
31997@end table
31998
31999@node VxWorks Options
32000@subsection VxWorks Options
32001@cindex VxWorks Options
32002
32003The options in this section are defined for all VxWorks targets.
32004Options specific to the target hardware are listed with the other
32005options for that target.
32006
32007@table @gcctabopt
32008@item -mrtp
32009@opindex mrtp
32010GCC can generate code for both VxWorks kernels and real time processes
32011(RTPs). This option switches from the former to the latter. It also
32012defines the preprocessor macro @code{__RTP__}.
32013
32014@item -non-static
32015@opindex non-static
32016Link an RTP executable against shared libraries rather than static
32017libraries. The options @option{-static} and @option{-shared} can
32018also be used for RTPs (@pxref{Link Options}); @option{-static}
32019is the default.
32020
32021@item -Bstatic
32022@itemx -Bdynamic
32023@opindex Bstatic
32024@opindex Bdynamic
32025These options are passed down to the linker. They are defined for
32026compatibility with Diab.
32027
32028@item -Xbind-lazy
32029@opindex Xbind-lazy
32030Enable lazy binding of function calls. This option is equivalent to
32031@option{-Wl,-z,now} and is defined for compatibility with Diab.
32032
32033@item -Xbind-now
32034@opindex Xbind-now
32035Disable lazy binding of function calls. This option is the default and
32036is defined for compatibility with Diab.
32037@end table
32038
32039@node x86 Options
32040@subsection x86 Options
32041@cindex x86 Options
32042
32043These @samp{-m} options are defined for the x86 family of computers.
32044
32045@table @gcctabopt
32046
32047@item -march=@var{cpu-type}
32048@opindex march
32049Generate instructions for the machine type @var{cpu-type}. In contrast to
32050@option{-mtune=@var{cpu-type}}, which merely tunes the generated code
32051for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC
32052to generate code that may not run at all on processors other than the one
32053indicated. Specifying @option{-march=@var{cpu-type}} implies
32054@option{-mtune=@var{cpu-type}}, except where noted otherwise.
32055
32056The choices for @var{cpu-type} are:
32057
32058@table @samp
32059@item native
32060This selects the CPU to generate code for at compilation time by determining
32061the processor type of the compiling machine. Using @option{-march=native}
32062enables all instruction subsets supported by the local machine (hence
32063the result might not run on different machines). Using @option{-mtune=native}
32064produces code optimized for the local machine under the constraints
32065of the selected instruction set.
32066
32067@item x86-64
32068A generic CPU with 64-bit extensions.
32069
32070@item x86-64-v2
32071@itemx x86-64-v3
32072@itemx x86-64-v4
32073These choices for @var{cpu-type} select the corresponding
32074micro-architecture level from the x86-64 psABI. On ABIs other than
32075the x86-64 psABI they select the same CPU features as the x86-64 psABI
32076documents for the particular micro-architecture level.
32077
32078Since these @var{cpu-type} values do not have a corresponding
32079@option{-mtune} setting, using @option{-march} with these values enables
32080generic tuning. Specific tuning can be enabled using the
32081@option{-mtune=@var{other-cpu-type}} option with an appropriate
32082@var{other-cpu-type} value.
32083
32084@item i386
32085Original Intel i386 CPU@.
32086
32087@item i486
32088Intel i486 CPU@. (No scheduling is implemented for this chip.)
32089
32090@item i586
32091@itemx pentium
32092Intel Pentium CPU with no MMX support.
32093
32094@item lakemont
32095Intel Lakemont MCU, based on Intel Pentium CPU.
32096
32097@item pentium-mmx
32098Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support.
32099
32100@item pentiumpro
32101Intel Pentium Pro CPU@.
32102
32103@item i686
32104When used with @option{-march}, the Pentium Pro
32105instruction set is used, so the code runs on all i686 family chips.
32106When used with @option{-mtune}, it has the same meaning as @samp{generic}.
32107
32108@item pentium2
32109Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction
32110set support.
32111
32112@item pentium3
32113@itemx pentium3m
32114Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE
32115instruction set support.
32116
32117@item pentium-m
32118Intel Pentium M; low-power version of Intel Pentium III CPU
32119with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino
32120notebooks.
32121
32122@item pentium4
32123@itemx pentium4m
32124Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support.
32125
32126@item prescott
32127Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR
32128instruction set support.
32129
32130@item nocona
32131Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE,
32132SSE2, SSE3 and FXSR instruction set support.
32133
32134@item core2
32135Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16,
32136SAHF and FXSR instruction set support.
32137
32138@item nehalem
32139Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32140SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support.
32141
32142@item westmere
32143Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32144SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support.
32145
32146@item sandybridge
32147Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32148SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set
32149support.
32150
32151@item ivybridge
32152Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3,
32153SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND
32154and F16C instruction set support.
32155
32156@item haswell
32157Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32158SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32159F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support.
32160
32161@item broadwell
32162Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32163SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32164F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW
32165instruction set support.
32166
32167@item skylake
32168Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32169SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32170F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32171CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support.
32172
32173@item bonnell
32174Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3
32175instruction set support.
32176
32177@item silvermont
32178Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32179SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND
32180instruction set support.
32181
32182@item goldmont
32183Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32184SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32185RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction
32186set support.
32187
32188@item goldmont-plus
32189Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32190SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES,
32191SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE,
32192RDPID and SGX instruction set support.
32193
32194@item tremont
32195Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32196SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA,
32197RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID,
32198SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set
32199support.
32200
32201@item sierraforest
32202Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32203SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32204XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32205MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32206PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32207AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
32208
32209@item grandridge
32210Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32211SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
32212XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
32213MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
32214PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
32215AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set
32216support.
32217
32218@item knl
32219Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32220SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32221RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32222AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support.
32223
32224@item knm
32225Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32226SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32227RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32228AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW,
32229AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support.
32230
32231@item skylake-avx512
32232Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32233SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32234RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32235AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW,
32236AVX512DQ and AVX512CD instruction set support.
32237
32238@item cannonlake
32239Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
32240SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL,
32241FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX,
32242PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW,
32243AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set
32244support.
32245
32246@item icelake-client
32247Intel Icelake Client 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
32252, VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32253
32254@item icelake-server
32255Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32256SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32257RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32258AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32259AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2
32260, VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB
32261instruction set support.
32262
32263@item cascadelake
32264Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32265SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32266F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32267CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32268AVX512CD and AVX512VNNI instruction set support.
32269
32270@item cooperlake
32271Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32272SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32273F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32274CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ,
32275AVX512CD, AVX512VNNI and AVX512BF16 instruction set support.
32276
32277@item tigerlake
32278Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32279SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32280F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32281CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32282PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32283VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB,
32284AVX512VP2INTERSECT and KEYLOCKER instruction set support.
32285
32286@item sapphirerapids
32287Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32288SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32289RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32290AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32291AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32292VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32293MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK,
32294UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16 and AVX512BF16
32295instruction set support.
32296
32297@item alderlake
32298Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3,
32299SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES,
32300XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B,
32301CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
32302VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set
32303support.
32304
32305@item rocketlake
32306Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3
32307, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND,
32308F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES,
32309CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD
32310PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32311VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
32312
32313@item graniterapids
32314Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
32315SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE,
32316RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW,
32317AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ,
32318AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2,
32319VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB,
32320MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG,
32321SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16,
32322AVX512BF16, AMX-FP16 and PREFETCHI instruction set support.
32323
32324@item k6
32325AMD K6 CPU with MMX instruction set support.
32326
32327@item k6-2
32328@itemx k6-3
32329Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support.
32330
32331@item athlon
32332@itemx athlon-tbird
32333AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions
32334support.
32335
32336@item athlon-4
32337@itemx athlon-xp
32338@itemx athlon-mp
32339Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE
32340instruction set support.
32341
32342@item k8
32343@itemx opteron
32344@itemx athlon64
32345@itemx athlon-fx
32346Processors based on the AMD K8 core with x86-64 instruction set support,
32347including the AMD Opteron, Athlon 64, and Athlon 64 FX processors.
32348(This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit
32349instruction set extensions.)
32350
32351@item k8-sse3
32352@itemx opteron-sse3
32353@itemx athlon64-sse3
32354Improved versions of AMD K8 cores with SSE3 instruction set support.
32355
32356@item amdfam10
32357@itemx barcelona
32358CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This
32359supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit
32360instruction set extensions.)
32361
32362@item bdver1
32363CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This
32364supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A,
32365SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.)
32366
32367@item bdver2
32368AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32369supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX,
32370SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set
32371extensions.)
32372
32373@item bdver3
32374AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32375supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES,
32376PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and
3237764-bit instruction set extensions.)
32378
32379@item bdver4
32380AMD Family 15h core based CPUs with x86-64 instruction set support. (This
32381supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP,
32382AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1,
32383SSE4.2, ABM and 64-bit instruction set extensions.)
32384
32385@item znver1
32386AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32387supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX,
32388SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3,
32389SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit
32390instruction set extensions.)
32391
32392@item znver2
32393AMD Family 17h core based CPUs with x86-64 instruction set support. (This
32394supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32395MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32396SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32397WBNOINVD, and 64-bit instruction set extensions.)
32398
32399@item znver3
32400AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32401supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32402MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32403SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32404WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.)
32405
32406@item znver4
32407AMD Family 19h core based CPUs with x86-64 instruction set support. (This
32408supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED,
32409MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A,
32410SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID,
32411WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD,
32412AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI,
32413AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.)
32414
32415@item btver1
32416CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This
32417supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit
32418instruction set extensions.)
32419
32420@item btver2
32421CPUs based on AMD Family 16h cores with x86-64 instruction set support. This
32422includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM,
32423SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions.
32424
32425@item winchip-c6
32426IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction
32427set support.
32428
32429@item winchip2
32430IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@:
32431instruction set support.
32432
32433@item c3
32434VIA C3 CPU with MMX and 3DNow!@: instruction set support.
32435(No scheduling is implemented for this chip.)
32436
32437@item c3-2
32438VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support.
32439(No scheduling is implemented for this chip.)
32440
32441@item c7
32442VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32443(No scheduling is implemented for this chip.)
32444
32445@item samuel-2
32446VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support.
32447(No scheduling is implemented for this chip.)
32448
32449@item nehemiah
32450VIA Eden Nehemiah CPU with MMX and SSE instruction set support.
32451(No scheduling is implemented for this chip.)
32452
32453@item esther
32454VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support.
32455(No scheduling is implemented for this chip.)
32456
32457@item eden-x2
32458VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support.
32459(No scheduling is implemented for this chip.)
32460
32461@item eden-x4
32462VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2,
32463AVX and AVX2 instruction set support.
32464(No scheduling is implemented for this chip.)
32465
32466@item nano
32467Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32468instruction set support.
32469(No scheduling is implemented for this chip.)
32470
32471@item nano-1000
32472VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32473instruction set support.
32474(No scheduling is implemented for this chip.)
32475
32476@item nano-2000
32477VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3
32478instruction set support.
32479(No scheduling is implemented for this chip.)
32480
32481@item nano-3000
32482VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32483instruction set support.
32484(No scheduling is implemented for this chip.)
32485
32486@item nano-x2
32487VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32488instruction set support.
32489(No scheduling is implemented for this chip.)
32490
32491@item nano-x4
32492VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1
32493instruction set support.
32494(No scheduling is implemented for this chip.)
32495
32496@item lujiazui
32497ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1,
32498SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16,
32499ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support.
32500
32501@item geode
32502AMD Geode embedded processor with MMX and 3DNow!@: instruction set support.
32503@end table
32504
32505@item -mtune=@var{cpu-type}
32506@opindex mtune
32507Tune to @var{cpu-type} everything applicable about the generated code, except
32508for the ABI and the set of available instructions.
32509While picking a specific @var{cpu-type} schedules things appropriately
32510for that particular chip, the compiler does not generate any code that
32511cannot run on the default machine type unless you use a
32512@option{-march=@var{cpu-type}} option.
32513For example, if GCC is configured for i686-pc-linux-gnu
32514then @option{-mtune=pentium4} generates code that is tuned for Pentium 4
32515but still runs on i686 machines.
32516
32517The choices for @var{cpu-type} are the same as for @option{-march}.
32518In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}:
32519
32520@table @samp
32521@item generic
32522Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors.
32523If you know the CPU on which your code will run, then you should use
32524the corresponding @option{-mtune} or @option{-march} option instead of
32525@option{-mtune=generic}. But, if you do not know exactly what CPU users
32526of your application will have, then you should use this option.
32527
32528As new processors are deployed in the marketplace, the behavior of this
32529option will change. Therefore, if you upgrade to a newer version of
32530GCC, code generation controlled by this option will change to reflect
32531the processors
32532that are most common at the time that version of GCC is released.
32533
32534There is no @option{-march=generic} option because @option{-march}
32535indicates the instruction set the compiler can use, and there is no
32536generic instruction set applicable to all processors. In contrast,
32537@option{-mtune} indicates the processor (or, in this case, collection of
32538processors) for which the code is optimized.
32539
32540@item intel
32541Produce code optimized for the most current Intel processors, which are
32542Haswell and Silvermont for this version of GCC. If you know the CPU
32543on which your code will run, then you should use the corresponding
32544@option{-mtune} or @option{-march} option instead of @option{-mtune=intel}.
32545But, if you want your application performs better on both Haswell and
32546Silvermont, then you should use this option.
32547
32548As new Intel processors are deployed in the marketplace, the behavior of
32549this option will change. Therefore, if you upgrade to a newer version of
32550GCC, code generation controlled by this option will change to reflect
32551the most current Intel processors at the time that version of GCC is
32552released.
32553
32554There is no @option{-march=intel} option because @option{-march} indicates
32555the instruction set the compiler can use, and there is no common
32556instruction set applicable to all processors. In contrast,
32557@option{-mtune} indicates the processor (or, in this case, collection of
32558processors) for which the code is optimized.
32559@end table
32560
32561@item -mcpu=@var{cpu-type}
32562@opindex mcpu
32563A deprecated synonym for @option{-mtune}.
32564
32565@item -mfpmath=@var{unit}
32566@opindex mfpmath
32567Generate floating-point arithmetic for selected unit @var{unit}. The choices
32568for @var{unit} are:
32569
32570@table @samp
32571@item 387
32572Use the standard 387 floating-point coprocessor present on the majority of chips and
32573emulated otherwise. Code compiled with this option runs almost everywhere.
32574The temporary results are computed in 80-bit precision instead of the precision
32575specified by the type, resulting in slightly different results compared to most
32576of other chips. See @option{-ffloat-store} for more detailed description.
32577
32578This is the default choice for non-Darwin x86-32 targets.
32579
32580@item sse
32581Use scalar floating-point instructions present in the SSE instruction set.
32582This instruction set is supported by Pentium III and newer chips,
32583and in the AMD line
32584by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE
32585instruction set supports only single-precision arithmetic, thus the double and
32586extended-precision arithmetic are still done using 387. A later version, present
32587only in Pentium 4 and AMD x86-64 chips, supports double-precision
32588arithmetic too.
32589
32590For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse}
32591or @option{-msse2} switches to enable SSE extensions and make this option
32592effective. For the x86-64 compiler, these extensions are enabled by default.
32593
32594The resulting code should be considerably faster in the majority of cases and avoid
32595the numerical instability problems of 387 code, but may break some existing
32596code that expects temporaries to be 80 bits.
32597
32598This is the default choice for the x86-64 compiler, Darwin x86-32 targets,
32599and the default choice for x86-32 targets with the SSE2 instruction set
32600when @option{-ffast-math} is enabled.
32601
32602@item sse,387
32603@itemx sse+387
32604@itemx both
32605Attempt to utilize both instruction sets at once. This effectively doubles the
32606amount of available registers, and on chips with separate execution units for
32607387 and SSE the execution resources too. Use this option with care, as it is
32608still experimental, because the GCC register allocator does not model separate
32609functional units well, resulting in unstable performance.
32610@end table
32611
32612@item -masm=@var{dialect}
32613@opindex masm=@var{dialect}
32614Output assembly instructions using selected @var{dialect}. Also affects
32615which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and
32616extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect
32617order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does
32618not support @samp{intel}.
32619
32620@item -mieee-fp
32621@itemx -mno-ieee-fp
32622@opindex mieee-fp
32623@opindex mno-ieee-fp
32624Control whether or not the compiler uses IEEE floating-point
32625comparisons. These correctly handle the case where the result of a
32626comparison is unordered.
32627
32628@item -m80387
32629@itemx -mhard-float
30348d30 32630@opindex m80387
d77de738
ML
32631@opindex mhard-float
32632Generate output containing 80387 instructions for floating point.
32633
32634@item -mno-80387
32635@itemx -msoft-float
32636@opindex no-80387
32637@opindex msoft-float
32638Generate output containing library calls for floating point.
32639
32640@strong{Warning:} the requisite libraries are not part of GCC@.
32641Normally the facilities of the machine's usual C compiler are used, but
32642this cannot be done directly in cross-compilation. You must make your
32643own arrangements to provide suitable library functions for
32644cross-compilation.
32645
32646On machines where a function returns floating-point results in the 80387
32647register stack, some floating-point opcodes may be emitted even if
32648@option{-msoft-float} is used.
32649
32650@item -mno-fp-ret-in-387
32651@opindex mno-fp-ret-in-387
32652@opindex mfp-ret-in-387
32653Do not use the FPU registers for return values of functions.
32654
32655The usual calling convention has functions return values of types
32656@code{float} and @code{double} in an FPU register, even if there
32657is no FPU@. The idea is that the operating system should emulate
32658an FPU@.
32659
32660The option @option{-mno-fp-ret-in-387} causes such values to be returned
32661in ordinary CPU registers instead.
32662
32663@item -mno-fancy-math-387
32664@opindex mno-fancy-math-387
32665@opindex mfancy-math-387
32666Some 387 emulators do not support the @code{sin}, @code{cos} and
32667@code{sqrt} instructions for the 387. Specify this option to avoid
32668generating those instructions.
32669This option is overridden when @option{-march}
32670indicates that the target CPU always has an FPU and so the
32671instruction does not need emulation. These
32672instructions are not generated unless you also use the
32673@option{-funsafe-math-optimizations} switch.
32674
32675@item -malign-double
32676@itemx -mno-align-double
32677@opindex malign-double
32678@opindex mno-align-double
32679Control whether GCC aligns @code{double}, @code{long double}, and
32680@code{long long} variables on a two-word boundary or a one-word
32681boundary. Aligning @code{double} variables on a two-word boundary
32682produces code that runs somewhat faster on a Pentium at the
32683expense of more memory.
32684
32685On x86-64, @option{-malign-double} is enabled by default.
32686
32687@strong{Warning:} if you use the @option{-malign-double} switch,
32688structures containing the above types are aligned differently than
32689the published application binary interface specifications for the x86-32
32690and are not binary compatible with structures in code compiled
32691without that switch.
32692
32693@item -m96bit-long-double
32694@itemx -m128bit-long-double
32695@opindex m96bit-long-double
32696@opindex m128bit-long-double
32697These switches control the size of @code{long double} type. The x86-32
32698application binary interface specifies the size to be 96 bits,
32699so @option{-m96bit-long-double} is the default in 32-bit mode.
32700
32701Modern architectures (Pentium and newer) prefer @code{long double}
32702to be aligned to an 8- or 16-byte boundary. In arrays or structures
32703conforming to the ABI, this is not possible. So specifying
32704@option{-m128bit-long-double} aligns @code{long double}
32705to a 16-byte boundary by padding the @code{long double} with an additional
3270632-bit zero.
32707
32708In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as
32709its ABI specifies that @code{long double} is aligned on 16-byte boundary.
32710
32711Notice that neither of these options enable any extra precision over the x87
32712standard of 80 bits for a @code{long double}.
32713
32714@strong{Warning:} if you override the default value for your target ABI, this
32715changes the size of
32716structures and arrays containing @code{long double} variables,
32717as well as modifying the function calling convention for functions taking
32718@code{long double}. Hence they are not binary-compatible
32719with code compiled without that switch.
32720
32721@item -mlong-double-64
32722@itemx -mlong-double-80
32723@itemx -mlong-double-128
32724@opindex mlong-double-64
32725@opindex mlong-double-80
32726@opindex mlong-double-128
32727These switches control the size of @code{long double} type. A size
32728of 64 bits makes the @code{long double} type equivalent to the @code{double}
32729type. This is the default for 32-bit Bionic C library. A size
32730of 128 bits makes the @code{long double} type equivalent to the
32731@code{__float128} type. This is the default for 64-bit Bionic C library.
32732
32733@strong{Warning:} if you override the default value for your target ABI, this
32734changes the size of
32735structures and arrays containing @code{long double} variables,
32736as well as modifying the function calling convention for functions taking
32737@code{long double}. Hence they are not binary-compatible
32738with code compiled without that switch.
32739
32740@item -malign-data=@var{type}
32741@opindex malign-data
32742Control how GCC aligns variables. Supported values for @var{type} are
32743@samp{compat} uses increased alignment value compatible uses GCC 4.8
32744and earlier, @samp{abi} uses alignment value as specified by the
32745psABI, and @samp{cacheline} uses increased alignment value to match
32746the cache line size. @samp{compat} is the default.
32747
32748@item -mlarge-data-threshold=@var{threshold}
32749@opindex mlarge-data-threshold
32750When @option{-mcmodel=medium} is specified, data objects larger than
32751@var{threshold} are placed in the large data section. This value must be the
32752same across all objects linked into the binary, and defaults to 65535.
32753
32754@item -mrtd
32755@opindex mrtd
32756Use a different function-calling convention, in which functions that
32757take a fixed number of arguments return with the @code{ret @var{num}}
32758instruction, which pops their arguments while returning. This saves one
32759instruction in the caller since there is no need to pop the arguments
32760there.
32761
32762You can specify that an individual function is called with this calling
32763sequence with the function attribute @code{stdcall}. You can also
32764override the @option{-mrtd} option by using the function attribute
32765@code{cdecl}. @xref{Function Attributes}.
32766
32767@strong{Warning:} this calling convention is incompatible with the one
32768normally used on Unix, so you cannot use it if you need to call
32769libraries compiled with the Unix compiler.
32770
32771Also, you must provide function prototypes for all functions that
32772take variable numbers of arguments (including @code{printf});
32773otherwise incorrect code is generated for calls to those
32774functions.
32775
32776In addition, seriously incorrect code results if you call a
32777function with too many arguments. (Normally, extra arguments are
32778harmlessly ignored.)
32779
32780@item -mregparm=@var{num}
32781@opindex mregparm
32782Control how many registers are used to pass integer arguments. By
32783default, no registers are used to pass arguments, and at most 3
32784registers can be used. You can control this behavior for a specific
32785function by using the function attribute @code{regparm}.
32786@xref{Function Attributes}.
32787
32788@strong{Warning:} if you use this switch, and
32789@var{num} is nonzero, then you must build all modules with the same
32790value, including any libraries. This includes the system libraries and
32791startup modules.
32792
32793@item -msseregparm
32794@opindex msseregparm
32795Use SSE register passing conventions for float and double arguments
32796and return values. You can control this behavior for a specific
32797function by using the function attribute @code{sseregparm}.
32798@xref{Function Attributes}.
32799
32800@strong{Warning:} if you use this switch then you must build all
32801modules with the same value, including any libraries. This includes
32802the system libraries and startup modules.
32803
32804@item -mvect8-ret-in-mem
32805@opindex mvect8-ret-in-mem
32806Return 8-byte vectors in memory instead of MMX registers. This is the
32807default on VxWorks to match the ABI of the Sun Studio compilers until
32808version 12. @emph{Only} use this option if you need to remain
32809compatible with existing code produced by those previous compiler
32810versions or older versions of GCC@.
32811
32812@item -mpc32
32813@itemx -mpc64
32814@itemx -mpc80
32815@opindex mpc32
32816@opindex mpc64
32817@opindex mpc80
32818
32819Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32}
32820is specified, the significands of results of floating-point operations are
32821rounded to 24 bits (single precision); @option{-mpc64} rounds the
32822significands of results of floating-point operations to 53 bits (double
32823precision) and @option{-mpc80} rounds the significands of results of
32824floating-point operations to 64 bits (extended double precision), which is
32825the default. When this option is used, floating-point operations in higher
32826precisions are not available to the programmer without setting the FPU
32827control word explicitly.
32828
32829Setting the rounding of floating-point operations to less than the default
3283080 bits can speed some programs by 2% or more. Note that some mathematical
32831libraries assume that extended-precision (80-bit) floating-point operations
32832are enabled by default; routines in such libraries could suffer significant
32833loss of accuracy, typically through so-called ``catastrophic cancellation'',
32834when this option is used to set the precision to less than extended precision.
32835
e54375d8 32836@item -mdaz-ftz
32837@opindex mdaz-ftz
32838
32839The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register
32840are used to control floating-point calculations.SSE and AVX instructions
32841including scalar and vector instructions could benefit from enabling the FTZ
32842and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags
32843when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz}
32844will set FTZ/DAZ flags even with @option{-shared}.
32845
d77de738
ML
32846@item -mstackrealign
32847@opindex mstackrealign
32848Realign the stack at entry. On the x86, the @option{-mstackrealign}
32849option generates an alternate prologue and epilogue that realigns the
32850run-time stack if necessary. This supports mixing legacy codes that keep
328514-byte stack alignment with modern codes that keep 16-byte stack alignment for
32852SSE compatibility. See also the attribute @code{force_align_arg_pointer},
32853applicable to individual functions.
32854
32855@item -mpreferred-stack-boundary=@var{num}
32856@opindex mpreferred-stack-boundary
32857Attempt to keep the stack boundary aligned to a 2 raised to @var{num}
32858byte boundary. If @option{-mpreferred-stack-boundary} is not specified,
32859the default is 4 (16 bytes or 128 bits).
32860
32861@strong{Warning:} When generating code for the x86-64 architecture with
32862SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be
32863used to keep the stack boundary aligned to 8 byte boundary. Since
32864x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and
32865intended to be used in controlled environment where stack space is
32866important limitation. This option leads to wrong code when functions
32867compiled with 16 byte stack alignment (such as functions from a standard
32868library) are called with misaligned stack. In this case, SSE
32869instructions may lead to misaligned memory access traps. In addition,
32870variable arguments are handled incorrectly for 16 byte aligned
32871objects (including x87 long double and __int128), leading to wrong
32872results. You must build all modules with
32873@option{-mpreferred-stack-boundary=3}, including any libraries. This
32874includes the system libraries and startup modules.
32875
32876@item -mincoming-stack-boundary=@var{num}
32877@opindex mincoming-stack-boundary
32878Assume the incoming stack is aligned to a 2 raised to @var{num} byte
32879boundary. If @option{-mincoming-stack-boundary} is not specified,
32880the one specified by @option{-mpreferred-stack-boundary} is used.
32881
32882On Pentium and Pentium Pro, @code{double} and @code{long double} values
32883should be aligned to an 8-byte boundary (see @option{-malign-double}) or
32884suffer significant run time performance penalties. On Pentium III, the
32885Streaming SIMD Extension (SSE) data type @code{__m128} may not work
32886properly if it is not 16-byte aligned.
32887
32888To ensure proper alignment of this values on the stack, the stack boundary
32889must be as aligned as that required by any value stored on the stack.
32890Further, every function must be generated such that it keeps the stack
32891aligned. Thus calling a function compiled with a higher preferred
32892stack boundary from a function compiled with a lower preferred stack
32893boundary most likely misaligns the stack. It is recommended that
32894libraries that use callbacks always use the default setting.
32895
32896This extra alignment does consume extra stack space, and generally
32897increases code size. Code that is sensitive to stack space usage, such
32898as embedded systems and operating system kernels, may want to reduce the
32899preferred alignment to @option{-mpreferred-stack-boundary=2}.
32900
32901@need 200
32902@item -mmmx
32903@opindex mmmx
32904@need 200
32905@itemx -msse
32906@opindex msse
32907@need 200
32908@itemx -msse2
32909@opindex msse2
32910@need 200
32911@itemx -msse3
32912@opindex msse3
32913@need 200
32914@itemx -mssse3
32915@opindex mssse3
32916@need 200
32917@itemx -msse4
32918@opindex msse4
32919@need 200
32920@itemx -msse4a
32921@opindex msse4a
32922@need 200
32923@itemx -msse4.1
32924@opindex msse4.1
32925@need 200
32926@itemx -msse4.2
32927@opindex msse4.2
32928@need 200
32929@itemx -mavx
32930@opindex mavx
32931@need 200
32932@itemx -mavx2
32933@opindex mavx2
32934@need 200
32935@itemx -mavx512f
32936@opindex mavx512f
32937@need 200
32938@itemx -mavx512pf
32939@opindex mavx512pf
32940@need 200
32941@itemx -mavx512er
32942@opindex mavx512er
32943@need 200
32944@itemx -mavx512cd
32945@opindex mavx512cd
32946@need 200
32947@itemx -mavx512vl
32948@opindex mavx512vl
32949@need 200
32950@itemx -mavx512bw
32951@opindex mavx512bw
32952@need 200
32953@itemx -mavx512dq
32954@opindex mavx512dq
32955@need 200
32956@itemx -mavx512ifma
32957@opindex mavx512ifma
32958@need 200
32959@itemx -mavx512vbmi
32960@opindex mavx512vbmi
32961@need 200
32962@itemx -msha
32963@opindex msha
32964@need 200
32965@itemx -maes
32966@opindex maes
32967@need 200
32968@itemx -mpclmul
32969@opindex mpclmul
32970@need 200
32971@itemx -mclflushopt
32972@opindex mclflushopt
32973@need 200
32974@itemx -mclwb
32975@opindex mclwb
32976@need 200
32977@itemx -mfsgsbase
32978@opindex mfsgsbase
32979@need 200
32980@itemx -mptwrite
32981@opindex mptwrite
32982@need 200
32983@itemx -mrdrnd
32984@opindex mrdrnd
32985@need 200
32986@itemx -mf16c
32987@opindex mf16c
32988@need 200
32989@itemx -mfma
32990@opindex mfma
32991@need 200
32992@itemx -mpconfig
32993@opindex mpconfig
32994@need 200
32995@itemx -mwbnoinvd
32996@opindex mwbnoinvd
32997@need 200
32998@itemx -mfma4
32999@opindex mfma4
33000@need 200
33001@itemx -mprfchw
33002@opindex mprfchw
33003@need 200
33004@itemx -mrdpid
33005@opindex mrdpid
33006@need 200
33007@itemx -mprefetchwt1
33008@opindex mprefetchwt1
33009@need 200
33010@itemx -mrdseed
33011@opindex mrdseed
33012@need 200
33013@itemx -msgx
33014@opindex msgx
33015@need 200
33016@itemx -mxop
33017@opindex mxop
33018@need 200
33019@itemx -mlwp
33020@opindex mlwp
33021@need 200
33022@itemx -m3dnow
33023@opindex m3dnow
33024@need 200
33025@itemx -m3dnowa
33026@opindex m3dnowa
33027@need 200
33028@itemx -mpopcnt
33029@opindex mpopcnt
33030@need 200
33031@itemx -mabm
33032@opindex mabm
33033@need 200
33034@itemx -madx
33035@opindex madx
33036@need 200
33037@itemx -mbmi
33038@opindex mbmi
33039@need 200
33040@itemx -mbmi2
33041@opindex mbmi2
33042@need 200
33043@itemx -mlzcnt
33044@opindex mlzcnt
33045@need 200
33046@itemx -mfxsr
33047@opindex mfxsr
33048@need 200
33049@itemx -mxsave
33050@opindex mxsave
33051@need 200
33052@itemx -mxsaveopt
33053@opindex mxsaveopt
33054@need 200
33055@itemx -mxsavec
33056@opindex mxsavec
33057@need 200
33058@itemx -mxsaves
33059@opindex mxsaves
33060@need 200
33061@itemx -mrtm
33062@opindex mrtm
33063@need 200
33064@itemx -mhle
33065@opindex mhle
33066@need 200
33067@itemx -mtbm
33068@opindex mtbm
33069@need 200
33070@itemx -mmwaitx
33071@opindex mmwaitx
33072@need 200
33073@itemx -mclzero
33074@opindex mclzero
33075@need 200
33076@itemx -mpku
33077@opindex mpku
33078@need 200
33079@itemx -mavx512vbmi2
33080@opindex mavx512vbmi2
33081@need 200
33082@itemx -mavx512bf16
33083@opindex mavx512bf16
33084@need 200
33085@itemx -mavx512fp16
33086@opindex mavx512fp16
33087@need 200
33088@itemx -mgfni
33089@opindex mgfni
33090@need 200
33091@itemx -mvaes
33092@opindex mvaes
33093@need 200
33094@itemx -mwaitpkg
33095@opindex mwaitpkg
33096@need 200
33097@itemx -mvpclmulqdq
33098@opindex mvpclmulqdq
33099@need 200
33100@itemx -mavx512bitalg
33101@opindex mavx512bitalg
33102@need 200
33103@itemx -mmovdiri
33104@opindex mmovdiri
33105@need 200
33106@itemx -mmovdir64b
33107@opindex mmovdir64b
33108@need 200
33109@itemx -menqcmd
33110@opindex menqcmd
33111@itemx -muintr
33112@opindex muintr
33113@need 200
33114@itemx -mtsxldtrk
33115@opindex mtsxldtrk
33116@need 200
33117@itemx -mavx512vpopcntdq
33118@opindex mavx512vpopcntdq
33119@need 200
33120@itemx -mavx512vp2intersect
33121@opindex mavx512vp2intersect
33122@need 200
33123@itemx -mavx5124fmaps
33124@opindex mavx5124fmaps
33125@need 200
33126@itemx -mavx512vnni
33127@opindex mavx512vnni
33128@need 200
33129@itemx -mavxvnni
33130@opindex mavxvnni
33131@need 200
33132@itemx -mavx5124vnniw
33133@opindex mavx5124vnniw
33134@need 200
33135@itemx -mcldemote
33136@opindex mcldemote
33137@need 200
33138@itemx -mserialize
33139@opindex mserialize
33140@need 200
33141@itemx -mamx-tile
33142@opindex mamx-tile
33143@need 200
33144@itemx -mamx-int8
33145@opindex mamx-int8
33146@need 200
33147@itemx -mamx-bf16
33148@opindex mamx-bf16
33149@need 200
33150@itemx -mhreset
33151@opindex mhreset
33152@itemx -mkl
33153@opindex mkl
33154@need 200
33155@itemx -mwidekl
33156@opindex mwidekl
33157@need 200
33158@itemx -mavxifma
33159@opindex mavxifma
33160@need 200
33161@itemx -mavxvnniint8
33162@opindex mavxvnniint8
33163@need 200
33164@itemx -mavxneconvert
33165@opindex mavxneconvert
33166@need 200
33167@itemx -mcmpccxadd
33168@opindex mcmpccxadd
33169@need 200
33170@itemx -mamx-fp16
33171@opindex mamx-fp16
33172@need 200
33173@itemx -mprefetchi
33174@opindex mprefetchi
33175@need 200
33176@itemx -mraoint
33177@opindex mraoint
33178These switches enable the use of instructions in the MMX, SSE,
33179SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF,
33180AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA,
33181AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG,
33182WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP,
331833DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE,
33184XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2,
33185GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16,
33186ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE,
33187UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512FP16,
33188AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT or
33189CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-}
33190option to disable use of these instructions.
33191
33192These extensions are also available as built-in functions: see
33193@ref{x86 Built-in Functions}, for details of the functions enabled and
33194disabled by these switches.
33195
33196To generate SSE/SSE2 instructions automatically from floating-point
33197code (as opposed to 387 instructions), see @option{-mfpmath=sse}.
33198
33199GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it
33200generates new AVX instructions or AVX equivalence for all SSEx instructions
33201when needed.
33202
33203These options enable GCC to use these extended instructions in
33204generated code, even without @option{-mfpmath=sse}. Applications that
33205perform run-time CPU detection must compile separate files for each
33206supported architecture, using the appropriate flags. In particular,
33207the file containing the CPU detection code should be compiled without
33208these options.
33209
33210@item -mdump-tune-features
33211@opindex mdump-tune-features
33212This option instructs GCC to dump the names of the x86 performance
33213tuning features and default settings. The names can be used in
33214@option{-mtune-ctrl=@var{feature-list}}.
33215
33216@item -mtune-ctrl=@var{feature-list}
33217@opindex mtune-ctrl=@var{feature-list}
33218This option is used to do fine grain control of x86 code generation features.
33219@var{feature-list} is a comma separated list of @var{feature} names. See also
33220@option{-mdump-tune-features}. When specified, the @var{feature} is turned
33221on if it is not preceded with @samp{^}, otherwise, it is turned off.
33222@option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC
33223developers. Using it may lead to code paths not covered by testing and can
33224potentially result in compiler ICEs or runtime errors.
33225
33226@item -mno-default
33227@opindex mno-default
33228This option instructs GCC to turn off all tunable features. See also
33229@option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}.
33230
33231@item -mcld
33232@opindex mcld
33233This option instructs GCC to emit a @code{cld} instruction in the prologue
33234of functions that use string instructions. String instructions depend on
33235the DF flag to select between autoincrement or autodecrement mode. While the
33236ABI specifies the DF flag to be cleared on function entry, some operating
33237systems violate this specification by not clearing the DF flag in their
33238exception dispatchers. The exception handler can be invoked with the DF flag
33239set, which leads to wrong direction mode when string instructions are used.
33240This option can be enabled by default on 32-bit x86 targets by configuring
33241GCC with the @option{--enable-cld} configure option. Generation of @code{cld}
33242instructions can be suppressed with the @option{-mno-cld} compiler option
33243in this case.
33244
33245@item -mvzeroupper
33246@opindex mvzeroupper
33247This option instructs GCC to emit a @code{vzeroupper} instruction
33248before a transfer of control flow out of the function to minimize
33249the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper}
33250intrinsics.
33251
33252@item -mprefer-avx128
33253@opindex mprefer-avx128
33254This option instructs GCC to use 128-bit AVX instructions instead of
33255256-bit AVX instructions in the auto-vectorizer.
33256
33257@item -mprefer-vector-width=@var{opt}
33258@opindex mprefer-vector-width
33259This option instructs GCC to use @var{opt}-bit vector width in instructions
33260instead of default on the selected platform.
33261
33262@item -mmove-max=@var{bits}
33263@opindex mmove-max
33264This option instructs GCC to set the maximum number of bits can be
33265moved from memory to memory efficiently to @var{bits}. The valid
33266@var{bits} are 128, 256 and 512.
33267
33268@item -mstore-max=@var{bits}
33269@opindex mstore-max
33270This option instructs GCC to set the maximum number of bits can be
33271stored to memory efficiently to @var{bits}. The valid @var{bits} are
33272128, 256 and 512.
33273
33274@table @samp
33275@item none
33276No extra limitations applied to GCC other than defined by the selected platform.
33277
33278@item 128
33279Prefer 128-bit vector width for instructions.
33280
33281@item 256
33282Prefer 256-bit vector width for instructions.
33283
33284@item 512
33285Prefer 512-bit vector width for instructions.
33286@end table
33287
33288@item -mcx16
33289@opindex mcx16
33290This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit
33291code to implement compare-and-exchange operations on 16-byte aligned 128-bit
33292objects. This is useful for atomic updates of data structures exceeding one
33293machine word in size. The compiler uses this instruction to implement
33294@ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on
33295128-bit integers, a library call is always used.
33296
33297@item -msahf
33298@opindex msahf
33299This option enables generation of @code{SAHF} instructions in 64-bit code.
33300Early Intel Pentium 4 CPUs with Intel 64 support,
33301prior to the introduction of Pentium 4 G1 step in December 2005,
33302lacked the @code{LAHF} and @code{SAHF} instructions
33303which are supported by AMD64.
33304These are load and store instructions, respectively, for certain status flags.
33305In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod},
33306@code{drem}, and @code{remainder} built-in functions;
33307see @ref{Other Builtins} for details.
33308
33309@item -mmovbe
33310@opindex mmovbe
33311This option enables use of the @code{movbe} instruction to implement
33312@code{__builtin_bswap32} and @code{__builtin_bswap64}.
33313
33314@item -mshstk
33315@opindex mshstk
33316The @option{-mshstk} option enables shadow stack built-in functions
33317from x86 Control-flow Enforcement Technology (CET).
33318
33319@item -mcrc32
33320@opindex mcrc32
33321This option enables built-in functions @code{__builtin_ia32_crc32qi},
33322@code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and
33323@code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction.
33324
33325@item -mmwait
33326@opindex mmwait
33327This option enables built-in functions @code{__builtin_ia32_monitor},
33328and @code{__builtin_ia32_mwait} to generate the @code{monitor} and
33329@code{mwait} machine instructions.
33330
33331@item -mrecip
33332@opindex mrecip
33333This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions
33334(and their vectorized variants @code{RCPPS} and @code{RSQRTPS})
33335with an additional Newton-Raphson step
33336to increase precision instead of @code{DIVSS} and @code{SQRTSS}
33337(and their vectorized
33338variants) for single-precision floating-point arguments. These instructions
33339are generated only when @option{-funsafe-math-optimizations} is enabled
33340together with @option{-ffinite-math-only} and @option{-fno-trapping-math}.
33341Note that while the throughput of the sequence is higher than the throughput
33342of the non-reciprocal instruction, the precision of the sequence can be
33343decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994).
33344
33345Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS}
33346(or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option
33347combination), and doesn't need @option{-mrecip}.
33348
33349Also note that GCC emits the above sequence with additional Newton-Raphson step
33350for vectorized single-float division and vectorized @code{sqrtf(@var{x})}
33351already with @option{-ffast-math} (or the above option combination), and
33352doesn't need @option{-mrecip}.
33353
33354@item -mrecip=@var{opt}
33355@opindex mrecip=opt
33356This option controls which reciprocal estimate instructions
33357may be used. @var{opt} is a comma-separated list of options, which may
33358be preceded by a @samp{!} to invert the option:
33359
33360@table @samp
33361@item all
33362Enable all estimate instructions.
33363
33364@item default
33365Enable the default instructions, equivalent to @option{-mrecip}.
33366
33367@item none
33368Disable all estimate instructions, equivalent to @option{-mno-recip}.
33369
33370@item div
33371Enable the approximation for scalar division.
33372
33373@item vec-div
33374Enable the approximation for vectorized division.
33375
33376@item sqrt
33377Enable the approximation for scalar square root.
33378
33379@item vec-sqrt
33380Enable the approximation for vectorized square root.
33381@end table
33382
33383So, for example, @option{-mrecip=all,!sqrt} enables
33384all of the reciprocal approximations, except for square root.
33385
33386@item -mveclibabi=@var{type}
33387@opindex mveclibabi
33388Specifies the ABI type to use for vectorizing intrinsics using an
33389external library. Supported values for @var{type} are @samp{svml}
33390for the Intel short
33391vector math library and @samp{acml} for the AMD math core library.
33392To use this option, both @option{-ftree-vectorize} and
33393@option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML
33394ABI-compatible library must be specified at link time.
33395
33396GCC currently emits calls to @code{vmldExp2},
33397@code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2},
33398@code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2},
33399@code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2},
33400@code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2},
33401@code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4},
33402@code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4},
33403@code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4},
33404@code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4},
33405@code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding
33406function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin},
33407@code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2},
33408@code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf},
33409@code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f},
33410@code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type
33411when @option{-mveclibabi=acml} is used.
33412
33413@item -mabi=@var{name}
33414@opindex mabi
33415Generate code for the specified calling convention. Permissible values
33416are @samp{sysv} for the ABI used on GNU/Linux and other systems, and
33417@samp{ms} for the Microsoft ABI. The default is to use the Microsoft
33418ABI when targeting Microsoft Windows and the SysV ABI on all other systems.
33419You can control this behavior for specific functions by
33420using the function attributes @code{ms_abi} and @code{sysv_abi}.
33421@xref{Function Attributes}.
33422
33423@item -mforce-indirect-call
33424@opindex mforce-indirect-call
33425Force all calls to functions to be indirect. This is useful
33426when using Intel Processor Trace where it generates more precise timing
33427information for function calls.
33428
33429@item -mmanual-endbr
33430@opindex mmanual-endbr
33431Insert ENDBR instruction at function entry only via the @code{cf_check}
33432function attribute. This is useful when used with the option
33433@option{-fcf-protection=branch} to control ENDBR insertion at the
33434function entry.
33435
33436@item -mcet-switch
33437@opindex mcet-switch
33438By default, CET instrumentation is turned off on switch statements that
33439use a jump table and indirect branch track is disabled. Since jump
33440tables are stored in read-only memory, this does not result in a direct
33441loss of hardening. But if the jump table index is attacker-controlled,
33442the indirect jump may not be constrained by CET. This option turns on
33443CET instrumentation to enable indirect branch track for switch statements
33444with jump tables which leads to the jump targets reachable via any indirect
33445jumps.
33446
33447@item -mcall-ms2sysv-xlogues
33448@opindex mcall-ms2sysv-xlogues
33449@opindex mno-call-ms2sysv-xlogues
33450Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a
33451System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By
33452default, the code for saving and restoring these registers is emitted inline,
33453resulting in fairly lengthy prologues and epilogues. Using
33454@option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that
33455use stubs in the static portion of libgcc to perform these saves and restores,
33456thus reducing function size at the cost of a few extra instructions.
33457
33458@item -mtls-dialect=@var{type}
33459@opindex mtls-dialect
33460Generate code to access thread-local storage using the @samp{gnu} or
33461@samp{gnu2} conventions. @samp{gnu} is the conservative default;
33462@samp{gnu2} is more efficient, but it may add compile- and run-time
33463requirements that cannot be satisfied on all systems.
33464
33465@item -mpush-args
33466@itemx -mno-push-args
33467@opindex mpush-args
33468@opindex mno-push-args
33469Use PUSH operations to store outgoing parameters. This method is shorter
33470and usually equally fast as method using SUB/MOV operations and is enabled
33471by default. In some cases disabling it may improve performance because of
33472improved scheduling and reduced dependencies.
33473
33474@item -maccumulate-outgoing-args
33475@opindex maccumulate-outgoing-args
33476If enabled, the maximum amount of space required for outgoing arguments is
33477computed in the function prologue. This is faster on most modern CPUs
33478because of reduced dependencies, improved scheduling and reduced stack usage
33479when the preferred stack boundary is not equal to 2. The drawback is a notable
33480increase in code size. This switch implies @option{-mno-push-args}.
33481
33482@item -mthreads
33483@opindex mthreads
33484Support thread-safe exception handling on MinGW. Programs that rely
33485on thread-safe exception handling must compile and link all code with the
33486@option{-mthreads} option. When compiling, @option{-mthreads} defines
33487@option{-D_MT}; when linking, it links in a special thread helper library
33488@option{-lmingwthrd} which cleans up per-thread exception-handling data.
33489
33490@item -mms-bitfields
33491@itemx -mno-ms-bitfields
33492@opindex mms-bitfields
33493@opindex mno-ms-bitfields
33494
33495Enable/disable bit-field layout compatible with the native Microsoft
33496Windows compiler.
33497
33498If @code{packed} is used on a structure, or if bit-fields are used,
33499it may be that the Microsoft ABI lays out the structure differently
33500than the way GCC normally does. Particularly when moving packed
33501data between functions compiled with GCC and the native Microsoft compiler
33502(either via function call or as data in a file), it may be necessary to access
33503either format.
33504
33505This option is enabled by default for Microsoft Windows
33506targets. This behavior can also be controlled locally by use of variable
33507or type attributes. For more information, see @ref{x86 Variable Attributes}
33508and @ref{x86 Type Attributes}.
33509
33510The Microsoft structure layout algorithm is fairly simple with the exception
33511of the bit-field packing.
33512The padding and alignment of members of structures and whether a bit-field
33513can straddle a storage-unit boundary are determine by these rules:
33514
33515@enumerate
33516@item Structure members are stored sequentially in the order in which they are
33517declared: the first member has the lowest memory address and the last member
33518the highest.
33519
33520@item Every data object has an alignment requirement. The alignment requirement
33521for all data except structures, unions, and arrays is either the size of the
33522object or the current packing size (specified with either the
33523@code{aligned} attribute or the @code{pack} pragma),
33524whichever is less. For structures, unions, and arrays,
33525the alignment requirement is the largest alignment requirement of its members.
33526Every object is allocated an offset so that:
33527
33528@smallexample
33529offset % alignment_requirement == 0
33530@end smallexample
33531
33532@item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation
33533unit if the integral types are the same size and if the next bit-field fits
33534into the current allocation unit without crossing the boundary imposed by the
33535common alignment requirements of the bit-fields.
33536@end enumerate
33537
33538MSVC interprets zero-length bit-fields in the following ways:
33539
33540@enumerate
33541@item If a zero-length bit-field is inserted between two bit-fields that
33542are normally coalesced, the bit-fields are not coalesced.
33543
33544For example:
33545
33546@smallexample
33547struct
33548 @{
33549 unsigned long bf_1 : 12;
33550 unsigned long : 0;
33551 unsigned long bf_2 : 12;
33552 @} t1;
33553@end smallexample
33554
33555@noindent
33556The size of @code{t1} is 8 bytes with the zero-length bit-field. If the
33557zero-length bit-field were removed, @code{t1}'s size would be 4 bytes.
33558
33559@item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the
33560alignment of the zero-length bit-field is greater than the member that follows it,
33561@code{bar}, @code{bar} is aligned as the type of the zero-length bit-field.
33562
33563For example:
33564
33565@smallexample
33566struct
33567 @{
33568 char foo : 4;
33569 short : 0;
33570 char bar;
33571 @} t2;
33572
33573struct
33574 @{
33575 char foo : 4;
33576 short : 0;
33577 double bar;
33578 @} t3;
33579@end smallexample
33580
33581@noindent
33582For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1.
33583Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length
33584bit-field does not affect the alignment of @code{bar} or, as a result, the size
33585of the structure.
33586
33587Taking this into account, it is important to note the following:
33588
33589@enumerate
33590@item If a zero-length bit-field follows a normal bit-field, the type of the
33591zero-length bit-field may affect the alignment of the structure as whole. For
33592example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a
33593normal bit-field, and is of type short.
33594
33595@item Even if a zero-length bit-field is not followed by a normal bit-field, it may
33596still affect the alignment of the structure:
33597
33598@smallexample
33599struct
33600 @{
33601 char foo : 6;
33602 long : 0;
33603 @} t4;
33604@end smallexample
33605
33606@noindent
33607Here, @code{t4} takes up 4 bytes.
33608@end enumerate
33609
33610@item Zero-length bit-fields following non-bit-field members are ignored:
33611
33612@smallexample
33613struct
33614 @{
33615 char foo;
33616 long : 0;
33617 char bar;
33618 @} t5;
33619@end smallexample
33620
33621@noindent
33622Here, @code{t5} takes up 2 bytes.
33623@end enumerate
33624
33625
33626@item -mno-align-stringops
33627@opindex mno-align-stringops
33628@opindex malign-stringops
33629Do not align the destination of inlined string operations. This switch reduces
33630code size and improves performance in case the destination is already aligned,
33631but GCC doesn't know about it.
33632
33633@item -minline-all-stringops
33634@opindex minline-all-stringops
33635By default GCC inlines string operations only when the destination is
33636known to be aligned to least a 4-byte boundary.
33637This enables more inlining and increases code
33638size, but may improve performance of code that depends on fast
33639@code{memcpy} and @code{memset} for short lengths.
33640The option enables inline expansion of @code{strlen} for all
33641pointer alignments.
33642
33643@item -minline-stringops-dynamically
33644@opindex minline-stringops-dynamically
33645For string operations of unknown size, use run-time checks with
33646inline code for small blocks and a library call for large blocks.
33647
33648@item -mstringop-strategy=@var{alg}
33649@opindex mstringop-strategy=@var{alg}
33650Override the internal decision heuristic for the particular algorithm to use
33651for inlining string operations. The allowed values for @var{alg} are:
33652
33653@table @samp
33654@item rep_byte
33655@itemx rep_4byte
33656@itemx rep_8byte
33657Expand using i386 @code{rep} prefix of the specified size.
33658
33659@item byte_loop
33660@itemx loop
33661@itemx unrolled_loop
33662Expand into an inline loop.
33663
33664@item libcall
33665Always use a library call.
33666@end table
33667
33668@item -mmemcpy-strategy=@var{strategy}
33669@opindex mmemcpy-strategy=@var{strategy}
33670Override the internal decision heuristic to decide if @code{__builtin_memcpy}
33671should be inlined and what inline algorithm to use when the expected size
33672of the copy operation is known. @var{strategy}
33673is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets.
33674@var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies
33675the max byte size with which inline algorithm @var{alg} is allowed. For the last
33676triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets
33677in the list must be specified in increasing order. The minimal byte size for
33678@var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the
33679preceding range.
33680
33681@item -mmemset-strategy=@var{strategy}
33682@opindex mmemset-strategy=@var{strategy}
33683The option is similar to @option{-mmemcpy-strategy=} except that it is to control
33684@code{__builtin_memset} expansion.
33685
33686@item -momit-leaf-frame-pointer
33687@opindex momit-leaf-frame-pointer
33688Don't keep the frame pointer in a register for leaf functions. This
33689avoids the instructions to save, set up, and restore frame pointers and
33690makes an extra register available in leaf functions. The option
33691@option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions,
33692which might make debugging harder.
33693
33694@item -mtls-direct-seg-refs
33695@itemx -mno-tls-direct-seg-refs
33696@opindex mtls-direct-seg-refs
33697Controls whether TLS variables may be accessed with offsets from the
33698TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit),
33699or whether the thread base pointer must be added. Whether or not this
33700is valid depends on the operating system, and whether it maps the
33701segment to cover the entire TLS area.
33702
33703For systems that use the GNU C Library, the default is on.
33704
33705@item -msse2avx
33706@itemx -mno-sse2avx
33707@opindex msse2avx
33708Specify that the assembler should encode SSE instructions with VEX
33709prefix. The option @option{-mavx} turns this on by default.
33710
33711@item -mfentry
33712@itemx -mno-fentry
33713@opindex mfentry
33714If profiling is active (@option{-pg}), put the profiling
33715counter call before the prologue.
33716Note: On x86 architectures the attribute @code{ms_hook_prologue}
33717isn't possible at the moment for @option{-mfentry} and @option{-pg}.
33718
33719@item -mrecord-mcount
33720@itemx -mno-record-mcount
33721@opindex mrecord-mcount
33722If profiling is active (@option{-pg}), generate a __mcount_loc section
33723that contains pointers to each profiling call. This is useful for
33724automatically patching and out calls.
33725
33726@item -mnop-mcount
33727@itemx -mno-nop-mcount
33728@opindex mnop-mcount
33729If profiling is active (@option{-pg}), generate the calls to
33730the profiling functions as NOPs. This is useful when they
33731should be patched in later dynamically. This is likely only
33732useful together with @option{-mrecord-mcount}.
33733
33734@item -minstrument-return=@var{type}
33735@opindex minstrument-return
33736Instrument function exit in -pg -mfentry instrumented functions with
33737call to specified function. This only instruments true returns ending
33738with ret, but not sibling calls ending with jump. Valid types
33739are @var{none} to not instrument, @var{call} to generate a call to __return__,
33740or @var{nop5} to generate a 5 byte nop.
33741
33742@item -mrecord-return
33743@itemx -mno-record-return
33744@opindex mrecord-return
33745Generate a __return_loc section pointing to all return instrumentation code.
33746
33747@item -mfentry-name=@var{name}
33748@opindex mfentry-name
33749Set name of __fentry__ symbol called at function entry for -pg -mfentry functions.
33750
33751@item -mfentry-section=@var{name}
33752@opindex mfentry-section
33753Set name of section to record -mrecord-mcount calls (default __mcount_loc).
33754
33755@item -mskip-rax-setup
33756@itemx -mno-skip-rax-setup
33757@opindex mskip-rax-setup
33758When generating code for the x86-64 architecture with SSE extensions
33759disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX
33760register when there are no variable arguments passed in vector registers.
33761
33762@strong{Warning:} Since RAX register is used to avoid unnecessarily
33763saving vector registers on stack when passing variable arguments, the
33764impacts of this option are callees may waste some stack space,
33765misbehave or jump to a random location. GCC 4.4 or newer don't have
33766those issues, regardless the RAX register value.
33767
33768@item -m8bit-idiv
33769@itemx -mno-8bit-idiv
33770@opindex m8bit-idiv
33771On some processors, like Intel Atom, 8-bit unsigned integer divide is
33772much faster than 32-bit/64-bit integer divide. This option generates a
33773run-time check. If both dividend and divisor are within range of 0
33774to 255, 8-bit unsigned integer divide is used instead of
3377532-bit/64-bit integer divide.
33776
33777@item -mavx256-split-unaligned-load
33778@itemx -mavx256-split-unaligned-store
33779@opindex mavx256-split-unaligned-load
33780@opindex mavx256-split-unaligned-store
33781Split 32-byte AVX unaligned load and store.
33782
33783@item -mstack-protector-guard=@var{guard}
33784@itemx -mstack-protector-guard-reg=@var{reg}
33785@itemx -mstack-protector-guard-offset=@var{offset}
33786@opindex mstack-protector-guard
33787@opindex mstack-protector-guard-reg
33788@opindex mstack-protector-guard-offset
33789Generate stack protection code using canary at @var{guard}. Supported
33790locations are @samp{global} for global canary or @samp{tls} for per-thread
33791canary in the TLS block (the default). This option has effect only when
33792@option{-fstack-protector} or @option{-fstack-protector-all} is specified.
33793
33794With the latter choice the options
33795@option{-mstack-protector-guard-reg=@var{reg}} and
33796@option{-mstack-protector-guard-offset=@var{offset}} furthermore specify
33797which segment register (@code{%fs} or @code{%gs}) to use as base register
33798for reading the canary, and from what offset from that base register.
33799The default for those is as specified in the relevant ABI.
33800
33801@item -mgeneral-regs-only
33802@opindex mgeneral-regs-only
33803Generate code that uses only the general-purpose registers. This
33804prevents the compiler from using floating-point, vector, mask and bound
33805registers.
33806
33807@item -mrelax-cmpxchg-loop
33808@opindex mrelax-cmpxchg-loop
85966f0d
AM
33809When emitting a compare-and-swap loop for @ref{__sync Builtins}
33810and @ref{__atomic Builtins} lacking a native instruction, optimize
33811for the highly contended case by issuing an atomic load before the
33812@code{CMPXCHG} instruction, and using the @code{PAUSE} instruction
33813to save CPU power when restarting the loop.
d77de738
ML
33814
33815@item -mindirect-branch=@var{choice}
33816@opindex mindirect-branch
33817Convert indirect call and jump with @var{choice}. The default is
33818@samp{keep}, which keeps indirect call and jump unmodified.
33819@samp{thunk} converts indirect call and jump to call and return thunk.
33820@samp{thunk-inline} converts indirect call and jump to inlined call
33821and return thunk. @samp{thunk-extern} converts indirect call and jump
33822to external call and return thunk provided in a separate object file.
33823You can control this behavior for a specific function by using the
33824function attribute @code{indirect_branch}. @xref{Function Attributes}.
33825
33826Note that @option{-mcmodel=large} is incompatible with
33827@option{-mindirect-branch=thunk} and
33828@option{-mindirect-branch=thunk-extern} since the thunk function may
33829not be reachable in the large code model.
33830
33831Note that @option{-mindirect-branch=thunk-extern} is compatible with
33832@option{-fcf-protection=branch} since the external thunk can be made
33833to enable control-flow check.
33834
33835@item -mfunction-return=@var{choice}
33836@opindex mfunction-return
33837Convert function return with @var{choice}. The default is @samp{keep},
33838which keeps function return unmodified. @samp{thunk} converts function
33839return to call and return thunk. @samp{thunk-inline} converts function
33840return to inlined call and return thunk. @samp{thunk-extern} converts
33841function return to external call and return thunk provided in a separate
33842object file. You can control this behavior for a specific function by
33843using the function attribute @code{function_return}.
33844@xref{Function Attributes}.
33845
33846Note that @option{-mindirect-return=thunk-extern} is compatible with
33847@option{-fcf-protection=branch} since the external thunk can be made
33848to enable control-flow check.
33849
33850Note that @option{-mcmodel=large} is incompatible with
33851@option{-mfunction-return=thunk} and
33852@option{-mfunction-return=thunk-extern} since the thunk function may
33853not be reachable in the large code model.
33854
33855
33856@item -mindirect-branch-register
33857@opindex mindirect-branch-register
33858Force indirect call and jump via register.
33859
33860@item -mharden-sls=@var{choice}
33861@opindex mharden-sls
33862Generate code to mitigate against straight line speculation (SLS) with
33863@var{choice}. The default is @samp{none} which disables all SLS
33864hardening. @samp{return} enables SLS hardening for function returns.
33865@samp{indirect-jmp} enables SLS hardening for indirect jumps.
33866@samp{all} enables all SLS hardening.
33867
33868@item -mindirect-branch-cs-prefix
33869@opindex mindirect-branch-cs-prefix
33870Add CS prefix to call and jmp to indirect thunk with branch target in
33871r8-r15 registers so that the call and jmp instruction length is 6 bytes
33872to allow them to be replaced with @samp{lfence; call *%r8-r15} or
33873@samp{lfence; jmp *%r8-r15} at run-time.
33874
33875@end table
33876
33877These @samp{-m} switches are supported in addition to the above
33878on x86-64 processors in 64-bit environments.
33879
33880@table @gcctabopt
33881@item -m32
33882@itemx -m64
33883@itemx -mx32
33884@itemx -m16
33885@itemx -miamcu
33886@opindex m32
33887@opindex m64
33888@opindex mx32
33889@opindex m16
33890@opindex miamcu
33891Generate code for a 16-bit, 32-bit or 64-bit environment.
33892The @option{-m32} option sets @code{int}, @code{long}, and pointer types
33893to 32 bits, and
33894generates code that runs on any i386 system.
33895
33896The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
33897types to 64 bits, and generates code for the x86-64 architecture.
33898For Darwin only the @option{-m64} option also turns off the @option{-fno-pic}
33899and @option{-mdynamic-no-pic} options.
33900
33901The @option{-mx32} option sets @code{int}, @code{long}, and pointer types
33902to 32 bits, and
33903generates code for the x86-64 architecture.
33904
33905The @option{-m16} option is the same as @option{-m32}, except for that
33906it outputs the @code{.code16gcc} assembly directive at the beginning of
33907the assembly output so that the binary can run in 16-bit mode.
33908
33909The @option{-miamcu} option generates code which conforms to Intel MCU
33910psABI. It requires the @option{-m32} option to be turned on.
33911
33912@item -mno-red-zone
33913@opindex mno-red-zone
33914@opindex mred-zone
33915Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated
33916by the x86-64 ABI; it is a 128-byte area beyond the location of the
33917stack pointer that is not modified by signal or interrupt handlers
33918and therefore can be used for temporary data without adjusting the stack
33919pointer. The flag @option{-mno-red-zone} disables this red zone.
33920
33921@item -mcmodel=small
33922@opindex mcmodel=small
33923Generate code for the small code model: the program and its symbols must
33924be linked in the lower 2 GB of the address space. Pointers are 64 bits.
33925Programs can be statically or dynamically linked. This is the default
33926code model.
33927
33928@item -mcmodel=kernel
33929@opindex mcmodel=kernel
33930Generate code for the kernel code model. The kernel runs in the
33931negative 2 GB of the address space.
33932This model has to be used for Linux kernel code.
33933
33934@item -mcmodel=medium
33935@opindex mcmodel=medium
33936Generate code for the medium model: the program is linked in the lower 2
33937GB of the address space. Small symbols are also placed there. Symbols
33938with sizes larger than @option{-mlarge-data-threshold} are put into
33939large data or BSS sections and can be located above 2GB. Programs can
33940be statically or dynamically linked.
33941
33942@item -mcmodel=large
33943@opindex mcmodel=large
33944Generate code for the large model. This model makes no assumptions
33945about addresses and sizes of sections.
33946
33947@item -maddress-mode=long
33948@opindex maddress-mode=long
33949Generate code for long address mode. This is only supported for 64-bit
33950and x32 environments. It is the default address mode for 64-bit
33951environments.
33952
33953@item -maddress-mode=short
33954@opindex maddress-mode=short
33955Generate code for short address mode. This is only supported for 32-bit
33956and x32 environments. It is the default address mode for 32-bit and
33957x32 environments.
33958
33959@item -mneeded
33960@itemx -mno-needed
33961@opindex mneeded
33962Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to
33963indicate the micro-architecture ISA level required to execute the binary.
33964
33965@item -mno-direct-extern-access
33966@opindex mno-direct-extern-access
33967@opindex mdirect-extern-access
33968Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer
33969to access external symbols. With @option{-fpic} or @option{-fPIC},
33970treat access to protected symbols as local symbols. The default is
33971@option{-mdirect-extern-access}.
33972
33973@strong{Warning:} shared libraries compiled with
33974@option{-mno-direct-extern-access} and executable compiled with
33975@option{-mdirect-extern-access} may not be binary compatible if
33976protected symbols are used in shared libraries and executable.
ce51e843
ML
33977
33978@item -munroll-only-small-loops
33979@opindex munroll-only-small-loops
33980@opindex mno-unroll-only-small-loops
33981Controls conservative small loop unrolling. It is default enabled by
33982O2, and unrolls loop with less than 4 insns by 1 time. Explicit
33983-f[no-]unroll-[all-]loops would disable this flag to avoid any
33984unintended unrolling behavior that user does not want.
bb576017 33985
33986@item -mlam=@var{choice}
33987@opindex mlam
33988LAM(linear-address masking) allows special bits in the pointer to be used
33989for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in
33990positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in
33991positions 62:57 can be used for metadata.
d77de738
ML
33992@end table
33993
33994@node x86 Windows Options
33995@subsection x86 Windows Options
33996@cindex x86 Windows Options
33997@cindex Windows Options for x86
33998
33999These additional options are available for Microsoft Windows targets:
34000
34001@table @gcctabopt
34002@item -mconsole
34003@opindex mconsole
34004This option
34005specifies that a console application is to be generated, by
34006instructing the linker to set the PE header subsystem type
34007required for console applications.
34008This option is available for Cygwin and MinGW targets and is
34009enabled by default on those targets.
34010
34011@item -mdll
34012@opindex mdll
34013This option is available for Cygwin and MinGW targets. It
34014specifies that a DLL---a dynamic link library---is to be
34015generated, enabling the selection of the required runtime
34016startup object and entry point.
34017
34018@item -mnop-fun-dllimport
34019@opindex mnop-fun-dllimport
34020This option is available for Cygwin and MinGW targets. It
34021specifies that the @code{dllimport} attribute should be ignored.
34022
34023@item -mthreads
34024@opindex mthreads
34025This option is available for MinGW targets. It specifies
34026that MinGW-specific thread support is to be used.
34027
34028@item -municode
34029@opindex municode
34030This option is available for MinGW-w64 targets. It causes
34031the @code{UNICODE} preprocessor macro to be predefined, and
34032chooses Unicode-capable runtime startup code.
34033
34034@item -mwin32
34035@opindex mwin32
34036This option is available for Cygwin and MinGW targets. It
34037specifies that the typical Microsoft Windows predefined macros are to
34038be set in the pre-processor, but does not influence the choice
34039of runtime library/startup code.
34040
34041@item -mwindows
34042@opindex mwindows
34043This option is available for Cygwin and MinGW targets. It
34044specifies that a GUI application is to be generated by
34045instructing the linker to set the PE header subsystem type
34046appropriately.
34047
34048@item -fno-set-stack-executable
34049@opindex fno-set-stack-executable
34050@opindex fset-stack-executable
34051This option is available for MinGW targets. It specifies that
34052the executable flag for the stack used by nested functions isn't
34053set. This is necessary for binaries running in kernel mode of
34054Microsoft Windows, as there the User32 API, which is used to set executable
34055privileges, isn't available.
34056
34057@item -fwritable-relocated-rdata
34058@opindex fno-writable-relocated-rdata
34059@opindex fwritable-relocated-rdata
34060This option is available for MinGW and Cygwin targets. It specifies
34061that relocated-data in read-only section is put into the @code{.data}
34062section. This is a necessary for older runtimes not supporting
34063modification of @code{.rdata} sections for pseudo-relocation.
34064
34065@item -mpe-aligned-commons
34066@opindex mpe-aligned-commons
34067This option is available for Cygwin and MinGW targets. It
34068specifies that the GNU extension to the PE file format that
34069permits the correct alignment of COMMON variables should be
34070used when generating code. It is enabled by default if
34071GCC detects that the target assembler found during configuration
34072supports the feature.
34073@end table
34074
34075See also under @ref{x86 Options} for standard options.
34076
34077@node Xstormy16 Options
34078@subsection Xstormy16 Options
34079@cindex Xstormy16 Options
34080
34081These options are defined for Xstormy16:
34082
34083@table @gcctabopt
34084@item -msim
34085@opindex msim
34086Choose startup files and linker script suitable for the simulator.
34087@end table
34088
34089@node Xtensa Options
34090@subsection Xtensa Options
34091@cindex Xtensa Options
34092
34093These options are supported for Xtensa targets:
34094
34095@table @gcctabopt
34096@item -mconst16
34097@itemx -mno-const16
34098@opindex mconst16
34099@opindex mno-const16
34100Enable or disable use of @code{CONST16} instructions for loading
34101constant values. The @code{CONST16} instruction is currently not a
34102standard option from Tensilica. When enabled, @code{CONST16}
34103instructions are always used in place of the standard @code{L32R}
34104instructions. The use of @code{CONST16} is enabled by default only if
34105the @code{L32R} instruction is not available.
34106
34107@item -mfused-madd
34108@itemx -mno-fused-madd
34109@opindex mfused-madd
34110@opindex mno-fused-madd
34111Enable or disable use of fused multiply/add and multiply/subtract
34112instructions in the floating-point option. This has no effect if the
34113floating-point option is not also enabled. Disabling fused multiply/add
34114and multiply/subtract instructions forces the compiler to use separate
34115instructions for the multiply and add/subtract operations. This may be
34116desirable in some cases where strict IEEE 754-compliant results are
34117required: the fused multiply add/subtract instructions do not round the
34118intermediate result, thereby producing results with @emph{more} bits of
34119precision than specified by the IEEE standard. Disabling fused multiply
34120add/subtract instructions also ensures that the program output is not
34121sensitive to the compiler's ability to combine multiply and add/subtract
34122operations.
34123
34124@item -mserialize-volatile
34125@itemx -mno-serialize-volatile
34126@opindex mserialize-volatile
34127@opindex mno-serialize-volatile
34128When this option is enabled, GCC inserts @code{MEMW} instructions before
34129@code{volatile} memory references to guarantee sequential consistency.
34130The default is @option{-mserialize-volatile}. Use
34131@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
34132
34133@item -mforce-no-pic
34134@opindex mforce-no-pic
34135For targets, like GNU/Linux, where all user-mode Xtensa code must be
34136position-independent code (PIC), this option disables PIC for compiling
34137kernel code.
34138
34139@item -mtext-section-literals
34140@itemx -mno-text-section-literals
34141@opindex mtext-section-literals
34142@opindex mno-text-section-literals
34143These options control the treatment of literal pools. The default is
34144@option{-mno-text-section-literals}, which places literals in a separate
34145section in the output file. This allows the literal pool to be placed
34146in a data RAM/ROM, and it also allows the linker to combine literal
34147pools from separate object files to remove redundant literals and
34148improve code size. With @option{-mtext-section-literals}, the literals
34149are interspersed in the text section in order to keep them as close as
34150possible to their references. This may be necessary for large assembly
34151files. Literals for each function are placed right before that function.
34152
34153@item -mauto-litpools
34154@itemx -mno-auto-litpools
34155@opindex mauto-litpools
34156@opindex mno-auto-litpools
34157These options control the treatment of literal pools. The default is
34158@option{-mno-auto-litpools}, which places literals in a separate
34159section in the output file unless @option{-mtext-section-literals} is
34160used. With @option{-mauto-litpools} the literals are interspersed in
34161the text section by the assembler. Compiler does not produce explicit
34162@code{.literal} directives and loads literals into registers with
34163@code{MOVI} instructions instead of @code{L32R} to let the assembler
34164do relaxation and place literals as necessary. This option allows
34165assembler to create several literal pools per function and assemble
34166very big functions, which may not be possible with
34167@option{-mtext-section-literals}.
34168
34169@item -mtarget-align
34170@itemx -mno-target-align
34171@opindex mtarget-align
34172@opindex mno-target-align
34173When this option is enabled, GCC instructs the assembler to
34174automatically align instructions to reduce branch penalties at the
34175expense of some code density. The assembler attempts to widen density
34176instructions to align branch targets and the instructions following call
34177instructions. If there are not enough preceding safe density
34178instructions to align a target, no widening is performed. The
34179default is @option{-mtarget-align}. These options do not affect the
34180treatment of auto-aligned instructions like @code{LOOP}, which the
34181assembler always aligns, either by widening density instructions or
34182by inserting NOP instructions.
34183
34184@item -mlongcalls
34185@itemx -mno-longcalls
34186@opindex mlongcalls
34187@opindex mno-longcalls
34188When this option is enabled, GCC instructs the assembler to translate
34189direct calls to indirect calls unless it can determine that the target
34190of a direct call is in the range allowed by the call instruction. This
34191translation typically occurs for calls to functions in other source
34192files. Specifically, the assembler translates a direct @code{CALL}
34193instruction into an @code{L32R} followed by a @code{CALLX} instruction.
34194The default is @option{-mno-longcalls}. This option should be used in
34195programs where the call target can potentially be out of range. This
34196option is implemented in the assembler, not the compiler, so the
34197assembly code generated by GCC still shows direct call
34198instructions---look at the disassembled object code to see the actual
34199instructions. Note that the assembler uses an indirect call for
34200every cross-file call, not just those that really are out of range.
34201
34202@item -mabi=@var{name}
34203@opindex mabi
34204Generate code for the specified ABI@. Permissible values are: @samp{call0},
34205@samp{windowed}. Default ABI is chosen by the Xtensa core configuration.
34206
34207@item -mabi=call0
34208@opindex mabi=call0
34209When this option is enabled function parameters are passed in registers
34210@code{a2} through @code{a7}, registers @code{a12} through @code{a15} are
34211caller-saved, and register @code{a15} may be used as a frame pointer.
34212When this version of the ABI is enabled the C preprocessor symbol
34213@code{__XTENSA_CALL0_ABI__} is defined.
34214
34215@item -mabi=windowed
34216@opindex mabi=windowed
34217When this option is enabled function parameters are passed in registers
34218@code{a10} through @code{a15}, and called function rotates register window
34219by 8 registers on entry so that its arguments are found in registers
34220@code{a2} through @code{a7}. Register @code{a7} may be used as a frame
34221pointer. Register window is rotated 8 registers back upon return.
34222When this version of the ABI is enabled the C preprocessor symbol
34223@code{__XTENSA_WINDOWED_ABI__} is defined.
34224
34225@item -mextra-l32r-costs=@var{n}
34226@opindex mextra-l32r-costs
34227Specify an extra cost of instruction RAM/ROM access for @code{L32R}
34228instructions, in clock cycles. This affects, when optimizing for speed,
34229whether loading a constant from literal pool using @code{L32R} or
34230synthesizing the constant from a small one with a couple of arithmetic
34231instructions. The default value is 0.
34232@end table
34233
34234@node zSeries Options
34235@subsection zSeries Options
34236@cindex zSeries options
34237
34238These are listed under @xref{S/390 and zSeries Options}.
34239
34240
34241@c man end
34242
34243@node Spec Files
34244@section Specifying Subprocesses and the Switches to Pass to Them
34245@cindex Spec Files
34246
34247@command{gcc} is a driver program. It performs its job by invoking a
34248sequence of other programs to do the work of compiling, assembling and
34249linking. GCC interprets its command-line parameters and uses these to
34250deduce which programs it should invoke, and which command-line options
34251it ought to place on their command lines. This behavior is controlled
34252by @dfn{spec strings}. In most cases there is one spec string for each
34253program that GCC can invoke, but a few programs have multiple spec
34254strings to control their behavior. The spec strings built into GCC can
34255be overridden by using the @option{-specs=} command-line switch to specify
34256a spec file.
34257
34258@dfn{Spec files} are plain-text files that are used to construct spec
34259strings. They consist of a sequence of directives separated by blank
34260lines. The type of directive is determined by the first non-whitespace
34261character on the line, which can be one of the following:
34262
34263@table @code
34264@item %@var{command}
34265Issues a @var{command} to the spec file processor. The commands that can
34266appear here are:
34267
34268@table @code
34269@item %include <@var{file}>
34270@cindex @code{%include}
34271Search for @var{file} and insert its text at the current point in the
34272specs file.
34273
34274@item %include_noerr <@var{file}>
34275@cindex @code{%include_noerr}
34276Just like @samp{%include}, but do not generate an error message if the include
34277file cannot be found.
34278
34279@item %rename @var{old_name} @var{new_name}
34280@cindex @code{%rename}
34281Rename the spec string @var{old_name} to @var{new_name}.
34282
34283@end table
34284
34285@item *[@var{spec_name}]:
34286This tells the compiler to create, override or delete the named spec
34287string. All lines after this directive up to the next directive or
34288blank line are considered to be the text for the spec string. If this
34289results in an empty string then the spec is deleted. (Or, if the
34290spec did not exist, then nothing happens.) Otherwise, if the spec
34291does not currently exist a new spec is created. If the spec does
34292exist then its contents are overridden by the text of this
34293directive, unless the first character of that text is the @samp{+}
34294character, in which case the text is appended to the spec.
34295
34296@item [@var{suffix}]:
34297Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive
34298and up to the next directive or blank line are considered to make up the
34299spec string for the indicated suffix. When the compiler encounters an
34300input file with the named suffix, it processes the spec string in
34301order to work out how to compile that file. For example:
34302
34303@smallexample
34304.ZZ:
34305z-compile -input %i
34306@end smallexample
34307
34308This says that any input file whose name ends in @samp{.ZZ} should be
34309passed to the program @samp{z-compile}, which should be invoked with the
34310command-line switch @option{-input} and with the result of performing the
34311@samp{%i} substitution. (See below.)
34312
34313As an alternative to providing a spec string, the text following a
34314suffix directive can be one of the following:
34315
34316@table @code
34317@item @@@var{language}
34318This says that the suffix is an alias for a known @var{language}. This is
34319similar to using the @option{-x} command-line switch to GCC to specify a
34320language explicitly. For example:
34321
34322@smallexample
34323.ZZ:
34324@@c++
34325@end smallexample
34326
34327Says that .ZZ files are, in fact, C++ source files.
34328
34329@item #@var{name}
34330This causes an error messages saying:
34331
34332@smallexample
34333@var{name} compiler not installed on this system.
34334@end smallexample
34335@end table
34336
34337GCC already has an extensive list of suffixes built into it.
34338This directive adds an entry to the end of the list of suffixes, but
34339since the list is searched from the end backwards, it is effectively
34340possible to override earlier entries using this technique.
34341
34342@end table
34343
34344GCC has the following spec strings built into it. Spec files can
34345override these strings or create their own. Note that individual
34346targets can also add their own spec strings to this list.
34347
34348@smallexample
34349asm Options to pass to the assembler
34350asm_final Options to pass to the assembler post-processor
34351cpp Options to pass to the C preprocessor
34352cc1 Options to pass to the C compiler
34353cc1plus Options to pass to the C++ compiler
34354endfile Object files to include at the end of the link
34355link Options to pass to the linker
34356lib Libraries to include on the command line to the linker
34357libgcc Decides which GCC support library to pass to the linker
34358linker Sets the name of the linker
34359predefines Defines to be passed to the C preprocessor
34360signed_char Defines to pass to CPP to say whether @code{char} is signed
34361 by default
34362startfile Object files to include at the start of the link
34363@end smallexample
34364
34365Here is a small example of a spec file:
34366
34367@smallexample
34368%rename lib old_lib
34369
34370*lib:
34371--start-group -lgcc -lc -leval1 --end-group %(old_lib)
34372@end smallexample
34373
34374This example renames the spec called @samp{lib} to @samp{old_lib} and
34375then overrides the previous definition of @samp{lib} with a new one.
34376The new definition adds in some extra command-line options before
34377including the text of the old definition.
34378
34379@dfn{Spec strings} are a list of command-line options to be passed to their
34380corresponding program. In addition, the spec strings can contain
34381@samp{%}-prefixed sequences to substitute variable text or to
34382conditionally insert text into the command line. Using these constructs
34383it is possible to generate quite complex command lines.
34384
34385Here is a table of all defined @samp{%}-sequences for spec
34386strings. Note that spaces are not generated automatically around the
34387results of expanding these sequences. Therefore you can concatenate them
34388together or combine them with constant text in a single argument.
34389
34390@table @code
34391@item %%
34392Substitute one @samp{%} into the program name or argument.
34393
34394@item %"
34395Substitute an empty argument.
34396
34397@item %i
34398Substitute the name of the input file being processed.
34399
34400@item %b
34401Substitute the basename for outputs related with the input file being
34402processed. This is often the substring up to (and not including) the
34403last period and not including the directory but, unless %w is active, it
34404expands to the basename for auxiliary outputs, which may be influenced
34405by an explicit output name, and by various other options that control
34406how auxiliary outputs are named.
34407
34408@item %B
34409This is the same as @samp{%b}, but include the file suffix (text after
34410the last period). Without %w, it expands to the basename for dump
34411outputs.
34412
34413@item %d
34414Marks the argument containing or following the @samp{%d} as a
34415temporary file name, so that that file is deleted if GCC exits
34416successfully. Unlike @samp{%g}, this contributes no text to the
34417argument.
34418
34419@item %g@var{suffix}
34420Substitute a file name that has suffix @var{suffix} and is chosen
34421once per compilation, and mark the argument in the same way as
34422@samp{%d}. To reduce exposure to denial-of-service attacks, the file
34423name is now chosen in a way that is hard to predict even when previously
34424chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s}
34425might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches
34426the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is
34427treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g}
34428was simply substituted with a file name chosen once per compilation,
34429without regard to any appended suffix (which was therefore treated
34430just like ordinary text), making such attacks more likely to succeed.
34431
34432@item %u@var{suffix}
34433Like @samp{%g}, but generates a new temporary file name
34434each time it appears instead of once per compilation.
34435
34436@item %U@var{suffix}
34437Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a
34438new one if there is no such last file name. In the absence of any
34439@samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share
34440the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s}
34441involves the generation of two distinct file names, one
34442for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was
34443simply substituted with a file name chosen for the previous @samp{%u},
34444without regard to any appended suffix.
34445
34446@item %j@var{suffix}
34447Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is
34448writable, and if @option{-save-temps} is not used;
34449otherwise, substitute the name
34450of a temporary file, just like @samp{%u}. This temporary file is not
34451meant for communication between processes, but rather as a junk
34452disposal mechanism.
34453
34454@item %|@var{suffix}
34455@itemx %m@var{suffix}
34456Like @samp{%g}, except if @option{-pipe} is in effect. In that case
34457@samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at
34458all. These are the two most common ways to instruct a program that it
34459should read from standard input or write to standard output. If you
34460need something more elaborate you can use an @samp{%@{pipe:@code{X}@}}
34461construct: see for example @file{gcc/fortran/lang-specs.h}.
34462
34463@item %.@var{SUFFIX}
34464Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args
34465when it is subsequently output with @samp{%*}. @var{SUFFIX} is
34466terminated by the next space or %.
34467
34468@item %w
34469Marks the argument containing or following the @samp{%w} as the
34470designated output file of this compilation. This puts the argument
34471into the sequence of arguments that @samp{%o} substitutes.
34472
34473@item %V
34474Indicates that this compilation produces no output file.
34475
34476@item %o
34477Substitutes the names of all the output files, with spaces
34478automatically placed around them. You should write spaces
34479around the @samp{%o} as well or the results are undefined.
34480@samp{%o} is for use in the specs for running the linker.
34481Input files whose names have no recognized suffix are not compiled
34482at all, but they are included among the output files, so they are
34483linked.
34484
34485@item %O
34486Substitutes the suffix for object files. Note that this is
34487handled specially when it immediately follows @samp{%g, %u, or %U},
34488because of the need for those to form complete file names. The
34489handling is such that @samp{%O} is treated exactly as if it had already
34490been substituted, except that @samp{%g, %u, and %U} do not currently
34491support additional @var{suffix} characters following @samp{%O} as they do
34492following, for example, @samp{.o}.
34493
34494@item %I
34495Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}),
34496@option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}),
34497@option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options)
34498and @option{-imultilib} as necessary.
34499
34500@item %s
34501Current argument is the name of a library or startup file of some sort.
34502Search for that file in a standard list of directories and substitute
34503the full name found. The current working directory is included in the
34504list of directories scanned.
34505
34506@item %T
34507Current argument is the name of a linker script. Search for that file
34508in the current list of directories to scan for libraries. If the file
34509is located insert a @option{--script} option into the command line
34510followed by the full path name found. If the file is not found then
34511generate an error message. Note: the current working directory is not
34512searched.
34513
34514@item %e@var{str}
34515Print @var{str} as an error message. @var{str} is terminated by a newline.
34516Use this when inconsistent options are detected.
34517
34518@item %n@var{str}
34519Print @var{str} as a notice. @var{str} is terminated by a newline.
34520
34521@item %(@var{name})
34522Substitute the contents of spec string @var{name} at this point.
34523
34524@item %x@{@var{option}@}
34525Accumulate an option for @samp{%X}.
34526
34527@item %X
34528Output the accumulated linker options specified by a @samp{%x} spec string.
34529
34530@item %Y
34531Output the accumulated assembler options specified by @option{-Wa}.
34532
34533@item %Z
34534Output the accumulated preprocessor options specified by @option{-Wp}.
34535
34536@item %M
34537Output @code{multilib_os_dir}.
34538
34539@item %R
34540Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}.
34541
34542@item %a
34543Process the @code{asm} spec. This is used to compute the
34544switches to be passed to the assembler.
34545
34546@item %A
34547Process the @code{asm_final} spec. This is a spec string for
34548passing switches to an assembler post-processor, if such a program is
34549needed.
34550
34551@item %l
34552Process the @code{link} spec. This is the spec for computing the
34553command line passed to the linker. Typically it makes use of the
34554@samp{%L %G %S %D and %E} sequences.
34555
34556@item %D
34557Dump out a @option{-L} option for each directory that GCC believes might
34558contain startup files. If the target supports multilibs then the
34559current multilib directory is prepended to each of these paths.
34560
34561@item %L
34562Process the @code{lib} spec. This is a spec string for deciding which
34563libraries are included on the command line to the linker.
34564
34565@item %G
34566Process the @code{libgcc} spec. This is a spec string for deciding
34567which GCC support library is included on the command line to the linker.
34568
34569@item %S
34570Process the @code{startfile} spec. This is a spec for deciding which
34571object files are the first ones passed to the linker. Typically
34572this might be a file named @file{crt0.o}.
34573
34574@item %E
34575Process the @code{endfile} spec. This is a spec string that specifies
34576the last object files that are passed to the linker.
34577
34578@item %C
34579Process the @code{cpp} spec. This is used to construct the arguments
34580to be passed to the C preprocessor.
34581
34582@item %1
34583Process the @code{cc1} spec. This is used to construct the options to be
34584passed to the actual C compiler (@command{cc1}).
34585
34586@item %2
34587Process the @code{cc1plus} spec. This is used to construct the options to be
34588passed to the actual C++ compiler (@command{cc1plus}).
34589
34590@item %*
34591Substitute the variable part of a matched option. See below.
34592Note that each comma in the substituted string is replaced by
34593a single space.
34594
34595@item %<S
34596Remove all occurrences of @code{-S} from the command line. Note---this
34597command is position dependent. @samp{%} commands in the spec string
34598before this one see @code{-S}, @samp{%} commands in the spec string
34599after this one do not.
34600
34601@item %<S*
34602Similar to @samp{%<S}, but match all switches beginning with @code{-S}.
34603
34604@item %>S
34605Similar to @samp{%<S}, but keep @code{-S} in the GCC command line.
34606
34607@item %:@var{function}(@var{args})
34608Call the named function @var{function}, passing it @var{args}.
34609@var{args} is first processed as a nested spec string, then split
34610into an argument vector in the usual fashion. The function returns
34611a string which is processed as if it had appeared literally as part
34612of the current spec.
34613
34614The following built-in spec functions are provided:
34615
34616@table @code
34617@item @code{getenv}
34618The @code{getenv} spec function takes two arguments: an environment
34619variable name and a string. If the environment variable is not
34620defined, a fatal error is issued. Otherwise, the return value is the
34621value of the environment variable concatenated with the string. For
34622example, if @env{TOPDIR} is defined as @file{/path/to/top}, then:
34623
34624@smallexample
34625%:getenv(TOPDIR /include)
34626@end smallexample
34627
34628expands to @file{/path/to/top/include}.
34629
34630@item @code{if-exists}
34631The @code{if-exists} spec function takes one argument, an absolute
34632pathname to a file. If the file exists, @code{if-exists} returns the
34633pathname. Here is a small example of its usage:
34634
34635@smallexample
34636*startfile:
34637crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s
34638@end smallexample
34639
34640@item @code{if-exists-else}
34641The @code{if-exists-else} spec function is similar to the @code{if-exists}
34642spec function, except that it takes two arguments. The first argument is
34643an absolute pathname to a file. If the file exists, @code{if-exists-else}
34644returns the pathname. If it does not exist, it returns the second argument.
34645This way, @code{if-exists-else} can be used to select one file or another,
34646based on the existence of the first. Here is a small example of its usage:
34647
34648@smallexample
34649*startfile:
34650crt0%O%s %:if-exists(crti%O%s) \
34651%:if-exists-else(crtbeginT%O%s crtbegin%O%s)
34652@end smallexample
34653
34654@item @code{if-exists-then-else}
34655The @code{if-exists-then-else} spec function takes at least two arguments
34656and an optional third one. The first argument is an absolute pathname to a
34657file. If the file exists, the function returns the second argument.
34658If the file does not exist, the function returns the third argument if there
34659is one, or NULL otherwise. This can be used to expand one text, or optionally
34660another, based on the existence of a file. Here is a small example of its
34661usage:
34662
34663@smallexample
34664-l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net)
34665@end smallexample
34666
34667@item @code{sanitize}
34668The @code{sanitize} spec function takes no arguments. It returns non-NULL if
34669any address, thread or undefined behavior sanitizers are active.
34670
34671@smallexample
34672%@{%:sanitize(address):-funwind-tables@}
34673@end smallexample
34674
34675@item @code{replace-outfile}
34676The @code{replace-outfile} spec function takes two arguments. It looks for the
34677first argument in the outfiles array and replaces it with the second argument. Here
34678is a small example of its usage:
34679
34680@smallexample
34681%@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@}
34682@end smallexample
34683
34684@item @code{remove-outfile}
34685The @code{remove-outfile} spec function takes one argument. It looks for the
34686first argument in the outfiles array and removes it. Here is a small example
34687its usage:
34688
34689@smallexample
34690%:remove-outfile(-lm)
34691@end smallexample
34692
34693@item @code{version-compare}
34694The @code{version-compare} spec function takes four or five arguments of the following
34695form:
34696
34697@smallexample
34698<comparison-op> <arg1> [<arg2>] <switch> <result>
34699@end smallexample
34700
34701It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't.
34702The supported @code{comparison-op} values are:
34703
34704@table @code
34705@item >=
34706True if @code{switch} is a later (or same) version than @code{arg1}
34707
34708@item !>
34709Opposite of @code{>=}
34710
34711@item <
34712True if @code{switch} is an earlier version than @code{arg1}
34713
34714@item !<
34715Opposite of @code{<}
34716
34717@item ><
34718True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2}
34719
34720@item <>
34721True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later
34722@end table
34723
34724If the @code{switch} is not present at all, the condition is false unless the first character
34725of the @code{comparison-op} is @code{!}.
34726
34727@smallexample
34728%:version-compare(>= 10.3 mmacosx-version-min= -lmx)
34729@end smallexample
34730
34731The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was
34732passed.
34733
34734@item @code{include}
34735The @code{include} spec function behaves much like @code{%include}, with the advantage
34736that it can be nested inside a spec and thus be conditionalized. It takes one argument,
34737the filename, and looks for it in the startfile path. It always returns NULL.
34738
34739@smallexample
34740%@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@}
34741@end smallexample
34742
34743@item @code{pass-through-libs}
34744The @code{pass-through-libs} spec function takes any number of arguments. It
34745finds any @option{-l} options and any non-options ending in @file{.a} (which it
34746assumes are the names of linker input library archive files) and returns a
34747result containing all the found arguments each prepended by
34748@option{-plugin-opt=-pass-through=} and joined by spaces. This list is
34749intended to be passed to the LTO linker plugin.
34750
34751@smallexample
34752%:pass-through-libs(%G %L %G)
34753@end smallexample
34754
34755@item @code{print-asm-header}
34756The @code{print-asm-header} function takes no arguments and simply
34757prints a banner like:
34758
34759@smallexample
34760Assembler options
34761=================
34762
34763Use "-Wa,OPTION" to pass "OPTION" to the assembler.
34764@end smallexample
34765
34766It is used to separate compiler options from assembler options
34767in the @option{--target-help} output.
34768
34769@item @code{gt}
34770The @code{gt} spec function takes two or more arguments. It returns @code{""} (the
34771empty string) if the second-to-last argument is greater than the last argument, and NULL
34772otherwise. The following example inserts the @code{link_gomp} spec if the last
34773@option{-ftree-parallelize-loops=} option given on the command line is greater than 1:
34774
34775@smallexample
34776%@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@}
34777@end smallexample
34778
34779@item @code{debug-level-gt}
34780The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the
34781empty string) if @code{debug_info_level} is greater than the specified number, and NULL
34782otherwise.
34783
34784@smallexample
34785%@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@}
34786@end smallexample
34787@end table
34788
34789@item %@{S@}
34790Substitutes the @code{-S} switch, if that switch is given to GCC@.
34791If that switch is not specified, this substitutes nothing. Note that
34792the leading dash is omitted when specifying this option, and it is
34793automatically inserted if the substitution is performed. Thus the spec
34794string @samp{%@{foo@}} matches the command-line option @option{-foo}
34795and outputs the command-line option @option{-foo}.
34796
34797@item %W@{S@}
34798Like %@{@code{S}@} but mark last argument supplied within as a file to be
34799deleted on failure.
34800
34801@item %@@@{S@}
34802Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes
34803@code{@@FILE} if an @code{@@file} argument has been supplied.
34804
34805@item %@{S*@}
34806Substitutes all the switches specified to GCC whose names start
34807with @code{-S}, but which also take an argument. This is used for
34808switches like @option{-o}, @option{-D}, @option{-I}, etc.
34809GCC considers @option{-o foo} as being
34810one switch whose name starts with @samp{o}. %@{o*@} substitutes this
34811text, including the space. Thus two arguments are generated.
34812
34813@item %@{S*&T*@}
34814Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options
34815(the order of @code{S} and @code{T} in the spec is not significant).
34816There can be any number of ampersand-separated variables; for each the
34817wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}.
34818
34819@item %@{S:X@}
34820Substitutes @code{X}, if the @option{-S} switch is given to GCC@.
34821
34822@item %@{!S:X@}
34823Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@.
34824
34825@item %@{S*:X@}
34826Substitutes @code{X} if one or more switches whose names start with
34827@code{-S} are specified to GCC@. Normally @code{X} is substituted only
34828once, no matter how many such switches appeared. However, if @code{%*}
34829appears somewhere in @code{X}, then @code{X} is substituted once
34830for each matching switch, with the @code{%*} replaced by the part of
34831that switch matching the @code{*}.
34832
34833If @code{%*} appears as the last part of a spec sequence then a space
34834is added after the end of the last substitution. If there is more
34835text in the sequence, however, then a space is not generated. This
34836allows the @code{%*} substitution to be used as part of a larger
34837string. For example, a spec string like this:
34838
34839@smallexample
34840%@{mcu=*:--script=%*/memory.ld@}
34841@end smallexample
34842
34843@noindent
34844when matching an option like @option{-mcu=newchip} produces:
34845
34846@smallexample
34847--script=newchip/memory.ld
34848@end smallexample
34849
34850@item %@{.S:X@}
34851Substitutes @code{X}, if processing a file with suffix @code{S}.
34852
34853@item %@{!.S:X@}
34854Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}.
34855
34856@item %@{,S:X@}
34857Substitutes @code{X}, if processing a file for language @code{S}.
34858
34859@item %@{!,S:X@}
34860Substitutes @code{X}, if not processing a file for language @code{S}.
34861
34862@item %@{S|P:X@}
34863Substitutes @code{X} if either @code{-S} or @code{-P} is given to
34864GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and
34865@code{*} sequences as well, although they have a stronger binding than
34866the @samp{|}. If @code{%*} appears in @code{X}, all of the
34867alternatives must be starred, and only the first matching alternative
34868is substituted.
34869
34870For example, a spec string like this:
34871
34872@smallexample
34873%@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@}
34874@end smallexample
34875
34876@noindent
34877outputs the following command-line options from the following input
34878command-line options:
34879
34880@smallexample
34881fred.c -foo -baz
34882jim.d -bar -boggle
34883-d fred.c -foo -baz -boggle
34884-d jim.d -bar -baz -boggle
34885@end smallexample
34886
34887@item %@{%:@var{function}(@var{args}):X@}
34888
34889Call function named @var{function} with args @var{args}. If the
34890function returns non-NULL, then @code{X} is substituted, if it returns
34891NULL, it isn't substituted.
34892
34893@item %@{S:X; T:Y; :D@}
34894
34895If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is
34896given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can
34897be as many clauses as you need. This may be combined with @code{.},
34898@code{,}, @code{!}, @code{|}, and @code{*} as needed.
34899
34900
34901@end table
34902
34903The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}}
34904or similar construct can use a backslash to ignore the special meaning
34905of the character following it, thus allowing literal matching of a
34906character that is otherwise specially treated. For example,
34907@samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the
34908@option{-std=iso9899:1999} option is given.
34909
34910The conditional text @code{X} in a @samp{%@{S:X@}} or similar
34911construct may contain other nested @samp{%} constructs or spaces, or
34912even newlines. They are processed as usual, as described above.
34913Trailing white space in @code{X} is ignored. White space may also
34914appear anywhere on the left side of the colon in these constructs,
34915except between @code{.} or @code{*} and the corresponding word.
34916
34917The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are
34918handled specifically in these constructs. If another value of
34919@option{-O} or the negated form of a @option{-f}, @option{-m}, or
34920@option{-W} switch is found later in the command line, the earlier
34921switch value is ignored, except with @{@code{S}*@} where @code{S} is
34922just one letter, which passes all matching options.
34923
34924The character @samp{|} at the beginning of the predicate text is used to
34925indicate that a command should be piped to the following command, but
34926only if @option{-pipe} is specified.
34927
34928It is built into GCC which switches take arguments and which do not.
34929(You might think it would be useful to generalize this to allow each
34930compiler's spec to say which switches take arguments. But this cannot
34931be done in a consistent fashion. GCC cannot even decide which input
34932files have been specified without knowing which switches take arguments,
34933and it must know which input files to compile in order to tell which
34934compilers to run).
34935
34936GCC also knows implicitly that arguments starting in @option{-l} are to be
34937treated as compiler output files, and passed to the linker in their
34938proper position among the other output files.
34939
34940@node Environment Variables
34941@section Environment Variables Affecting GCC
34942@cindex environment variables
34943
34944@c man begin ENVIRONMENT
34945This section describes several environment variables that affect how GCC
34946operates. Some of them work by specifying directories or prefixes to use
34947when searching for various kinds of files. Some are used to specify other
34948aspects of the compilation environment.
34949
34950Note that you can also specify places to search using options such as
34951@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
34952take precedence over places specified using environment variables, which
34953in turn take precedence over those specified by the configuration of GCC@.
34954@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
34955GNU Compiler Collection (GCC) Internals}.
34956
34957@table @env
34958@item LANG
34959@itemx LC_CTYPE
34960@c @itemx LC_COLLATE
34961@itemx LC_MESSAGES
34962@c @itemx LC_MONETARY
34963@c @itemx LC_NUMERIC
34964@c @itemx LC_TIME
34965@itemx LC_ALL
34966@findex LANG
34967@findex LC_CTYPE
34968@c @findex LC_COLLATE
34969@findex LC_MESSAGES
34970@c @findex LC_MONETARY
34971@c @findex LC_NUMERIC
34972@c @findex LC_TIME
34973@findex LC_ALL
34974@cindex locale
34975These environment variables control the way that GCC uses
34976localization information which allows GCC to work with different
34977national conventions. GCC inspects the locale categories
34978@env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do
34979so. These locale categories can be set to any value supported by your
34980installation. A typical value is @samp{en_GB.UTF-8} for English in the United
34981Kingdom encoded in UTF-8.
34982
34983The @env{LC_CTYPE} environment variable specifies character
34984classification. GCC uses it to determine the character boundaries in
34985a string; this is needed for some multibyte encodings that contain quote
34986and escape characters that are otherwise interpreted as a string
34987end or escape.
34988
34989The @env{LC_MESSAGES} environment variable specifies the language to
34990use in diagnostic messages.
34991
34992If the @env{LC_ALL} environment variable is set, it overrides the value
34993of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE}
34994and @env{LC_MESSAGES} default to the value of the @env{LANG}
34995environment variable. If none of these variables are set, GCC
34996defaults to traditional C English behavior.
34997
34998@item TMPDIR
34999@findex TMPDIR
35000If @env{TMPDIR} is set, it specifies the directory to use for temporary
35001files. GCC uses temporary files to hold the output of one stage of
35002compilation which is to be used as input to the next stage: for example,
35003the output of the preprocessor, which is the input to the compiler
35004proper.
35005
35006@item GCC_COMPARE_DEBUG
35007@findex GCC_COMPARE_DEBUG
35008Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing
35009@option{-fcompare-debug} to the compiler driver. See the documentation
35010of this option for more details.
35011
35012@item GCC_EXEC_PREFIX
35013@findex GCC_EXEC_PREFIX
35014If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
35015names of the subprograms executed by the compiler. No slash is added
35016when this prefix is combined with the name of a subprogram, but you can
35017specify a prefix that ends with a slash if you wish.
35018
35019If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out
35020an appropriate prefix to use based on the pathname it is invoked with.
35021
35022If GCC cannot find the subprogram using the specified prefix, it
35023tries looking in the usual places for the subprogram.
35024
35025The default value of @env{GCC_EXEC_PREFIX} is
35026@file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to
35027the installed compiler. In many cases @var{prefix} is the value
35028of @code{prefix} when you ran the @file{configure} script.
35029
35030Other prefixes specified with @option{-B} take precedence over this prefix.
35031
35032This prefix is also used for finding files such as @file{crt0.o} that are
35033used for linking.
35034
35035In addition, the prefix is used in an unusual way in finding the
35036directories to search for header files. For each of the standard
35037directories whose name normally begins with @samp{/usr/local/lib/gcc}
35038(more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries
35039replacing that beginning with the specified prefix to produce an
35040alternate directory name. Thus, with @option{-Bfoo/}, GCC searches
35041@file{foo/bar} just before it searches the standard directory
35042@file{/usr/local/lib/bar}.
35043If a standard directory begins with the configured
35044@var{prefix} then the value of @var{prefix} is replaced by
35045@env{GCC_EXEC_PREFIX} when looking for header files.
35046
35047@item COMPILER_PATH
35048@findex COMPILER_PATH
35049The value of @env{COMPILER_PATH} is a colon-separated list of
35050directories, much like @env{PATH}. GCC tries the directories thus
35051specified when searching for subprograms, if it cannot find the
35052subprograms using @env{GCC_EXEC_PREFIX}.
35053
35054@item LIBRARY_PATH
35055@findex LIBRARY_PATH
35056The value of @env{LIBRARY_PATH} is a colon-separated list of
35057directories, much like @env{PATH}. When configured as a native compiler,
35058GCC tries the directories thus specified when searching for special
35059linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking
35060using GCC also uses these directories when searching for ordinary
35061libraries for the @option{-l} option (but directories specified with
35062@option{-L} come first).
35063
35064@item LANG
35065@findex LANG
35066@cindex locale definition
35067This variable is used to pass locale information to the compiler. One way in
35068which this information is used is to determine the character set to be used
35069when character literals, string literals and comments are parsed in C and C++.
35070When the compiler is configured to allow multibyte characters,
35071the following values for @env{LANG} are recognized:
35072
35073@table @samp
35074@item C-JIS
35075Recognize JIS characters.
35076@item C-SJIS
35077Recognize SJIS characters.
35078@item C-EUCJP
35079Recognize EUCJP characters.
35080@end table
35081
35082If @env{LANG} is not defined, or if it has some other value, then the
35083compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to
35084recognize and translate multibyte characters.
35085
35086@item GCC_EXTRA_DIAGNOSTIC_OUTPUT
35087@findex GCC_EXTRA_DIAGNOSTIC_OUTPUT
35088If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values,
35089then additional text will be emitted to stderr when fix-it hints are
35090emitted. @option{-fdiagnostics-parseable-fixits} and
35091@option{-fno-diagnostics-parseable-fixits} take precedence over this
35092environment variable.
35093
35094@table @samp
35095@item fixits-v1
35096Emit parseable fix-it hints, equivalent to
35097@option{-fdiagnostics-parseable-fixits}. In particular, columns are
35098expressed as a count of bytes, starting at byte 1 for the initial column.
35099
35100@item fixits-v2
35101As @code{fixits-v1}, but columns are expressed as display columns,
35102as per @option{-fdiagnostics-column-unit=display}.
35103@end table
35104
35105@end table
35106
35107@noindent
35108Some additional environment variables affect the behavior of the
35109preprocessor.
35110
35111@include cppenv.texi
35112
35113@c man end
35114
35115@node Precompiled Headers
35116@section Using Precompiled Headers
35117@cindex precompiled headers
35118@cindex speed of compilation
35119
35120Often large projects have many header files that are included in every
35121source file. The time the compiler takes to process these header files
35122over and over again can account for nearly all of the time required to
35123build the project. To make builds faster, GCC allows you to
35124@dfn{precompile} a header file.
35125
35126To create a precompiled header file, simply compile it as you would any
35127other file, if necessary using the @option{-x} option to make the driver
35128treat it as a C or C++ header file. You may want to use a
35129tool like @command{make} to keep the precompiled header up-to-date when
35130the headers it contains change.
35131
35132A precompiled header file is searched for when @code{#include} is
35133seen in the compilation. As it searches for the included file
35134(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
35135compiler looks for a precompiled header in each directory just before it
35136looks for the include file in that directory. The name searched for is
35137the name specified in the @code{#include} with @samp{.gch} appended. If
35138the precompiled header file cannot be used, it is ignored.
35139
35140For instance, if you have @code{#include "all.h"}, and you have
35141@file{all.h.gch} in the same directory as @file{all.h}, then the
35142precompiled header file is used if possible, and the original
35143header is used otherwise.
35144
35145Alternatively, you might decide to put the precompiled header file in a
35146directory and use @option{-I} to ensure that directory is searched
35147before (or instead of) the directory containing the original header.
35148Then, if you want to check that the precompiled header file is always
35149used, you can put a file of the same name as the original header in this
35150directory containing an @code{#error} command.
35151
35152This also works with @option{-include}. So yet another way to use
35153precompiled headers, good for projects not designed with precompiled
35154header files in mind, is to simply take most of the header files used by
35155a project, include them from another header file, precompile that header
35156file, and @option{-include} the precompiled header. If the header files
35157have guards against multiple inclusion, they are skipped because
35158they've already been included (in the precompiled header).
35159
35160If you need to precompile the same header file for different
35161languages, targets, or compiler options, you can instead make a
35162@emph{directory} named like @file{all.h.gch}, and put each precompiled
35163header in the directory, perhaps using @option{-o}. It doesn't matter
35164what you call the files in the directory; every precompiled header in
35165the directory is considered. The first precompiled header
35166encountered in the directory that is valid for this compilation is
35167used; they're searched in no particular order.
35168
35169There are many other possibilities, limited only by your imagination,
35170good sense, and the constraints of your build system.
35171
35172A precompiled header file can be used only when these conditions apply:
35173
35174@itemize
35175@item
35176Only one precompiled header can be used in a particular compilation.
35177
35178@item
35179A precompiled header cannot be used once the first C token is seen. You
35180can have preprocessor directives before a precompiled header; you cannot
35181include a precompiled header from inside another header.
35182
35183@item
35184The precompiled header file must be produced for the same language as
35185the current compilation. You cannot use a C precompiled header for a C++
35186compilation.
35187
35188@item
35189The precompiled header file must have been produced by the same compiler
35190binary as the current compilation is using.
35191
35192@item
35193Any macros defined before the precompiled header is included must
35194either be defined in the same way as when the precompiled header was
35195generated, or must not affect the precompiled header, which usually
35196means that they don't appear in the precompiled header at all.
35197
35198The @option{-D} option is one way to define a macro before a
35199precompiled header is included; using a @code{#define} can also do it.
35200There are also some options that define macros implicitly, like
35201@option{-O} and @option{-Wdeprecated}; the same rule applies to macros
35202defined this way.
35203
35204@item If debugging information is output when using the precompiled
35205header, using @option{-g} or similar, the same kind of debugging information
35206must have been output when building the precompiled header. However,
35207a precompiled header built using @option{-g} can be used in a compilation
35208when no debugging information is being output.
35209
35210@item The same @option{-m} options must generally be used when building
35211and using the precompiled header. @xref{Submodel Options},
35212for any cases where this rule is relaxed.
35213
35214@item Each of the following options must be the same when building and using
35215the precompiled header:
35216
35217@gccoptlist{-fexceptions}
35218
35219@item
35220Some other command-line options starting with @option{-f},
35221@option{-p}, or @option{-O} must be defined in the same way as when
35222the precompiled header was generated. At present, it's not clear
35223which options are safe to change and which are not; the safest choice
35224is to use exactly the same options when generating and using the
35225precompiled header. The following are known to be safe:
35226
35227@gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock @gol
35228-fsched-spec -fsched-spec-load -fsched-spec-load-dangerous @gol
35229-fsched-verbose=@var{number} -fschedule-insns -fvisibility= @gol
35230-pedantic-errors}
35231
35232@item Address space layout randomization (ASLR) can lead to not binary identical
35233PCH files. If you rely on stable PCH file contents disable ASLR when generating
35234PCH files.
35235
35236@end itemize
35237
35238For all of these except the last, the compiler automatically
35239ignores the precompiled header if the conditions aren't met. If you
35240find an option combination that doesn't work and doesn't cause the
35241precompiled header to be ignored, please consider filing a bug report,
35242see @ref{Bugs}.
35243
35244If you do use differing options when generating and using the
35245precompiled header, the actual behavior is a mixture of the
35246behavior for the options. For instance, if you use @option{-g} to
35247generate the precompiled header but not when using it, you may or may
35248not get debugging information for routines in the precompiled header.
35249
35250@node C++ Modules
35251@section C++ Modules
35252@cindex speed of compilation
35253
35254Modules are a C++20 language feature. As the name suggests, they
35255provides a modular compilation system, intending to provide both
35256faster builds and better library isolation. The ``Merging Modules''
35257paper @uref{https://wg21.link/p1103}, provides the easiest to read set
35258of changes to the standard, although it does not capture later
35259changes.
35260
35261@emph{G++'s modules support is not complete.} Other than bugs, the
35262known missing pieces are:
35263
35264@table @emph
35265
35266@item Private Module Fragment
35267The Private Module Fragment is recognized, but an error is emitted.
35268
35269@item Partition definition visibility rules
35270Entities may be defined in implementation partitions, and those
35271definitions are not available outside of the module. This is not
35272implemented, and the definitions are available to extra-module use.
35273
35274@item Textual merging of reachable GM entities
35275Entities may be multiply defined across different header-units.
35276These must be de-duplicated, and this is implemented across imports,
35277or when an import redefines a textually-defined entity. However the
35278reverse is not implemented---textually redefining an entity that has
35279been defined in an imported header-unit. A redefinition error is
35280emitted.
35281
35282@item Translation-Unit local referencing rules
35283Papers p1815 (@uref{https://wg21.link/p1815}) and p2003
35284(@uref{https://wg21.link/p2003}) add limitations on which entities an
35285exported region may reference (for instance, the entities an exported
35286template definition may reference). These are not fully implemented.
35287
35288@item Standard Library Header Units
35289The Standard Library is not provided as importable header units. If
35290you want to import such units, you must explicitly build them first.
35291If you do not do this with care, you may have multiple declarations,
35292which the module machinery must merge---compiler resource usage can be
35293affected by how you partition header files into header units.
35294
35295@end table
35296
35297Modular compilation is @emph{not} enabled with just the
35298@option{-std=c++20} option. You must explicitly enable it with the
35299@option{-fmodules-ts} option. It is independent of the language
35300version selected, although in pre-C++20 versions, it is of course an
35301extension.
35302
35303No new source file suffixes are required or supported. If you wish to
35304use a non-standard suffix (@pxref{Overall Options}), you also need
35305to provide a @option{-x c++} option too.@footnote{Some users like to
35306distinguish module interface files with a new suffix, such as naming
35307the source @code{module.cppm}, which involves
35308teaching all tools about the new suffix. A different scheme, such as
35309naming @code{module-m.cpp} would be less invasive.}
35310
35311Compiling a module interface unit produces an additional output (to
35312the assembly or object file), called a Compiled Module Interface
35313(CMI). This encodes the exported declarations of the module.
35314Importing a module reads in the CMI. The import graph is a Directed
35315Acyclic Graph (DAG). You must build imports before the importer.
35316
35317Header files may themselves be compiled to header units, which are a
35318transitional ability aiming at faster compilation. The
35319@option{-fmodule-header} option is used to enable this, and implies
35320the @option{-fmodules-ts} option. These CMIs are named by the fully
35321resolved underlying header file, and thus may be a complete pathname
35322containing subdirectories. If the header file is found at an absolute
35323pathname, the CMI location is still relative to a CMI root directory.
35324
35325As header files often have no suffix, you commonly have to specify a
35326@option{-x} option to tell the compiler the source is a header file.
35327You may use @option{-x c++-header}, @option{-x c++-user-header} or
35328@option{-x c++-system-header}. When used in conjunction with
35329@option{-fmodules-ts}, these all imply an appropriate
35330@option{-fmodule-header} option. The latter two variants use the
35331user or system include path to search for the file specified. This
35332allows you to, for instance, compile standard library header files as
35333header units, without needing to know exactly where they are
35334installed. Specifying the language as one of these variants also
35335inhibits output of the object file, as header files have no associated
35336object file.
35337
35338The @option{-fmodule-only} option disables generation of the
35339associated object file for compiling a module interface. Only the CMI
35340is generated. This option is implied when using the
35341@option{-fmodule-header} option.
35342
35343The @option{-flang-info-include-translate} and
35344@option{-flang-info-include-translate-not} options notes whether
35345include translation occurs or not. With no argument, the first will
35346note all include translation. The second will note all
35347non-translations of include files not known to intentionally be
35348textual. With an argument, queries about include translation of a
35349header files with that particular trailing pathname are noted. You
35350may repeat this form to cover several different header files. This
35351option may be helpful in determining whether include translation is
35352happening---if it is working correctly, it behaves as if it isn't
35353there at all.
35354
35355The @option{-flang-info-module-cmi} option can be used to determine
35356where the compiler is reading a CMI from. Without the option, the
35357compiler is silent when such a read is successful. This option has an
35358optional argument, which will restrict the notification to just the
35359set of named modules or header units specified.
35360
35361The @option{-Winvalid-imported-macros} option causes all imported macros
35362to be resolved at the end of compilation. Without this, imported
35363macros are only resolved when expanded or (re)defined. This option
35364detects conflicting import definitions for all macros.
35365
35366For details of the @option{-fmodule-mapper} family of options,
35367@pxref{C++ Module Mapper}.
35368
35369@menu
35370* C++ Module Mapper:: Module Mapper
35371* C++ Module Preprocessing:: Module Preprocessing
35372* C++ Compiled Module Interface:: Compiled Module Interface
35373@end menu
35374
35375@node C++ Module Mapper
35376@subsection Module Mapper
35377@cindex C++ Module Mapper
35378
35379A module mapper provides a server or file that the compiler queries to
35380determine the mapping between module names and CMI files. It is also
35381used to build CMIs on demand. @emph{Mapper functionality is in its
35382infancy and is intended for experimentation with build system
35383interactions.}
35384
35385You can specify a mapper with the @option{-fmodule-mapper=@var{val}}
35386option or @env{CXX_MODULE_MAPPER} environment variable. The value may
35387have one of the following forms:
35388
35389@table @gcctabopt
35390
35391@item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]}
35392An optional hostname and a numeric port number to connect to. If the
35393hostname is omitted, the loopback address is used. If the hostname
35394corresponds to multiple IPV6 addresses, these are tried in turn, until
35395one is successful. If your host lacks IPv6, this form is
35396non-functional. If you must use IPv4 use
35397@option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}.
35398
35399@item =@var{socket}@r{[}?@var{ident}@r{]}
35400A local domain socket. If your host lacks local domain sockets, this
35401form is non-functional.
35402
35403@item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]}
35404A program to spawn, and communicate with on its stdin/stdout streams.
35405Your @var{PATH} environment variable is searched for the program.
35406Arguments are separated by space characters, (it is not possible for
35407one of the arguments delivered to the program to contain a space). An
35408exception is if @var{program} begins with @@. In that case
35409@var{program} (sans @@) is looked for in the compiler's internal
35410binary directory. Thus the sample mapper-server can be specified
35411with @code{@@g++-mapper-server}.
35412
35413@item <>@r{[}?@var{ident}@r{]}
35414@item <>@var{inout}@r{[}?@var{ident}@r{]}
35415@item <@var{in}>@var{out}@r{[}?@var{ident}@r{]}
35416Named pipes or file descriptors to communicate over. The first form,
35417@option{<>}, communicates over stdin and stdout. The other forms
35418allow you to specify a file descriptor or name a pipe. A numeric value
35419is interpreted as a file descriptor, otherwise named pipe is opened.
35420The second form specifies a bidirectional pipe and the last form
35421allows specifying two independent pipes. Using file descriptors
35422directly in this manner is fragile in general, as it can require the
35423cooperation of intermediate processes. In particular using stdin &
35424stdout is fraught with danger as other compiler options might also
35425cause the compiler to read stdin or write stdout, and it can have
35426unfortunate interactions with signal delivery from the terminal.
35427
35428@item @var{file}@r{[}?@var{ident}@r{]}
35429A mapping file consisting of space-separated module-name, filename
35430pairs, one per line. Only the mappings for the direct imports and any
35431module export name need be provided. If other mappings are provided,
35432they override those stored in any imported CMI files. A repository
35433root may be specified in the mapping file by using @samp{$root} as the
35434module name in the first active line. Use of this option will disable
35435any default module->CMI name mapping.
35436
35437@end table
35438
35439As shown, an optional @var{ident} may suffix the first word of the
35440option, indicated by a @samp{?} prefix. The value is used in the
35441initial handshake with the module server, or to specify a prefix on
35442mapping file lines. In the server case, the main source file name is
35443used if no @var{ident} is specified. In the file case, all non-blank
35444lines are significant, unless a value is specified, in which case only
35445lines beginning with @var{ident} are significant. The @var{ident}
35446must be separated by whitespace from the module name. Be aware that
35447@samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often
35448significant to the shell, and therefore may need quoting.
35449
35450The mapper is connected to or loaded lazily, when the first module
35451mapping is required. The networking protocols are only supported on
35452hosts that provide networking. If no mapper is specified a default is
35453provided.
35454
35455A project-specific mapper is expected to be provided by the build
35456system that invokes the compiler. It is not expected that a
35457general-purpose server is provided for all compilations. As such, the
35458server will know the build configuration, the compiler it invoked, and
35459the environment (such as working directory) in which that is
35460operating. As it may parallelize builds, several compilations may
35461connect to the same socket.
35462
35463The default mapper generates CMI files in a @samp{gcm.cache}
35464directory. CMI files have a @samp{.gcm} suffix. The module unit name
35465is used directly to provide the basename. Header units construct a
35466relative path using the underlying header file name. If the path is
35467already relative, a @samp{,} directory is prepended. Internal
35468@samp{..} components are translated to @samp{,,}. No attempt is made
35469to canonicalize these filenames beyond that done by the preprocessor's
35470include search algorithm, as in general it is ambiguous when symbolic
35471links are present.
35472
35473The mapper protocol was published as ``A Module Mapper''
35474@uref{https://wg21.link/p1184}. The implementation is provided by
35475@command{libcody}, @uref{https://github.com/urnathan/libcody},
35476which specifies the canonical protocol definition. A proof of concept
35477server implementation embedded in @command{make} was described in
35478''Make Me A Module'', @uref{https://wg21.link/p1602}.
35479
35480@node C++ Module Preprocessing
35481@subsection Module Preprocessing
35482@cindex C++ Module Preprocessing
35483
35484Modules affect preprocessing because of header units and include
35485translation. Some uses of the preprocessor as a separate step either
35486do not produce a correct output, or require CMIs to be available.
35487
35488Header units import macros. These macros can affect later conditional
35489inclusion, which therefore can cascade to differing import sets. When
35490preprocessing, it is necessary to load the CMI. If a header unit is
35491unavailable, the preprocessor issues a warning and continue (when
35492not just preprocessing, an error is emitted). Detecting such imports
35493requires preprocessor tokenization of the input stream to phase 4
35494(macro expansion).
35495
35496Include translation converts @code{#include}, @code{#include_next} and
35497@code{#import} directives to internal @code{import} declarations.
35498Whether a particular directive is translated is controlled by the
35499module mapper. Header unit names are canonicalized during
35500preprocessing.
35501
35502Dependency information can be emitted for macro import, extending the
35503functionality of @option{-MD} and @option{-MMD} options. Detection of
35504import declarations also requires phase 4 preprocessing, and thus
35505requires full preprocessing (or compilation).
35506
35507The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt
35508preprocessing before phase 4.
35509
35510The @option{-save-temps} option uses @option{-fdirectives-only} for
35511preprocessing, and preserve the macro definitions in the preprocessed
35512output. Usually you also want to use this option when explicitly
35513preprocessing a header-unit, or consuming such preprocessed output:
35514
35515@smallexample
35516g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii
35517g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii
35518@end smallexample
35519
35520@node C++ Compiled Module Interface
35521@subsection Compiled Module Interface
35522@cindex C++ Compiled Module Interface
35523
35524CMIs are an additional artifact when compiling named module
35525interfaces, partitions or header units. These are read when
35526importing. CMI contents are implementation-specific, and in GCC's
35527case tied to the compiler version. Consider them a rebuildable cache
35528artifact, not a distributable object.
35529
35530When creating an output CMI, any missing directory components are
35531created in a manner that is safe for concurrent builds creating
35532multiple, different, CMIs within a common subdirectory tree.
35533
35534CMI contents are written to a temporary file, which is then atomically
35535renamed. Observers either see old contents (if there is an
35536existing file), or complete new contents. They do not observe the
35537CMI during its creation. This is unlike object file writing, which
35538may be observed by an external process.
35539
35540CMIs are read in lazily, if the host OS provides @code{mmap}
35541functionality. Generally blocks are read when name lookup or template
35542instantiation occurs. To inhibit this, the @option{-fno-module-lazy}
35543option may be used.
35544
35545The @option{--param lazy-modules=@var{n}} parameter controls the limit
35546on the number of concurrently open module files during lazy loading.
35547Should more modules be imported, an LRU algorithm is used to determine
35548which files to close---until that file is needed again. This limit
35549may be exceeded with deep module dependency hierarchies. With large
35550code bases there may be more imports than the process limit of file
35551descriptors. By default, the limit is a few less than the per-process
35552file descriptor hard limit, if that is determinable.@footnote{Where
35553applicable the soft limit is incremented as needed towards the hard limit.}
35554
35555GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism.
35556You may use @command{readelf} to inspect them, although section
35557contents are largely undecipherable. There is a section named
35558@code{.gnu.c++.README}, which contains human-readable text. Other
35559than the first line, each line consists of @code{@var{tag}: @code{value}}
35560tuples.
35561
35562@smallexample
35563> @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm}
35564
35565String dump of section '.gnu.c++.README':
35566 [ 0] GNU C++ primary module interface
35567 [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454]
35568 [ 6f] version: 2020/11/16-04:54
35569 [ 89] module: foo
35570 [ 95] source: c_b.ii
35571 [ a4] dialect: C++20/coroutines
35572 [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc
35573 [ ee] repository: gcm.cache
35574 [ 104] buildtime: 2020/11/16 15:03:21 UTC
35575 [ 127] localtime: 2020/11/16 07:03:21 PST
35576 [ 14a] export: foo:part1 foo-part1.gcm
35577@end smallexample
35578
35579Amongst other things, this lists the source that was built, C++
35580dialect used and imports of the module.@footnote{The precise contents
35581of this output may change.} The timestamp is the same value as that
35582provided by the @code{__DATE__} & @code{__TIME__} macros, and may be
35583explicitly specified with the environment variable
35584@code{SOURCE_DATE_EPOCH}. For further details
35585@pxref{Environment Variables}.
35586
35587A set of related CMIs may be copied, provided the relative pathnames
35588are preserved.
35589
35590The @code{.gnu.c++.README} contents do not affect CMI integrity, and
35591it may be removed or altered. The section numbering of the sections
35592whose names do not begin with @code{.gnu.c++.}, or are not the string
35593section is significant and must not be altered.